Flutter Engine
fl_method_response.cc File Reference
#include "flutter/shell/platform/linux/public/flutter_linux/fl_method_response.h"
#include <gmodule.h>

Go to the source code of this file.

Classes

struct  _FlMethodSuccessResponse
 
struct  _FlMethodErrorResponse
 
struct  _FlMethodNotImplementedResponse
 

Functions

G_MODULE_EXPORT GType fl_method_response_get_type ()
 
G_MODULE_EXPORT GType fl_method_success_response_get_type ()
 
G_MODULE_EXPORT GType fl_method_error_response_get_type ()
 
G_MODULE_EXPORT GType fl_method_not_implemented_response_get_type ()
 
 G_DEFINE_TYPE (FlMethodSuccessResponse, fl_method_success_response, fl_method_response_get_type()) G_DEFINE_TYPE(FlMethodErrorResponse
 
static void fl_method_response_init (FlMethodResponse *self)
 
static void fl_method_success_response_dispose (GObject *object)
 
static void fl_method_success_response_class_init (FlMethodSuccessResponseClass *klass)
 
static void fl_method_success_response_init (FlMethodSuccessResponse *self)
 
static void fl_method_error_response_dispose (GObject *object)
 
static void fl_method_error_response_class_init (FlMethodErrorResponseClass *klass)
 
static void fl_method_error_response_init (FlMethodErrorResponse *self)
 
static void fl_method_not_implemented_response_class_init (FlMethodNotImplementedResponseClass *klass)
 
static void fl_method_not_implemented_response_init (FlMethodNotImplementedResponse *self)
 
G_MODULE_EXPORT FlValuefl_method_response_get_result (FlMethodResponse *self, GError **error)
 
G_MODULE_EXPORT FlMethodSuccessResponse * fl_method_success_response_new (FlValue *result)
 
G_MODULE_EXPORT FlValuefl_method_success_response_get_result (FlMethodSuccessResponse *self)
 
G_MODULE_EXPORT FlMethodErrorResponse * fl_method_error_response_new (const gchar *code, const gchar *message, FlValue *details)
 
G_MODULE_EXPORT const gchar * fl_method_error_response_get_code (FlMethodErrorResponse *self)
 
G_MODULE_EXPORT const gchar * fl_method_error_response_get_message (FlMethodErrorResponse *self)
 
G_MODULE_EXPORT FlValuefl_method_error_response_get_details (FlMethodErrorResponse *self)
 
G_MODULE_EXPORT FlMethodNotImplementedResponse * fl_method_not_implemented_response_new ()
 

Variables

 fl_method_error_response
 
 fl_method_not_implemented_response
 

Function Documentation

◆ fl_method_error_response_class_init()

static void fl_method_error_response_class_init ( FlMethodErrorResponseClass *  klass)
static

Definition at line 75 of file fl_method_response.cc.

References fl_method_error_response_dispose().

76  {
77  G_OBJECT_CLASS(klass)->dispose = fl_method_error_response_dispose;
78 }
static void fl_method_error_response_dispose(GObject *object)

◆ fl_method_error_response_dispose()

static void fl_method_error_response_dispose ( GObject *  object)
static

Definition at line 65 of file fl_method_response.cc.

References fl_value_unref().

Referenced by fl_method_error_response_class_init().

65  {
66  FlMethodErrorResponse* self = FL_METHOD_ERROR_RESPONSE(object);
67 
68  g_clear_pointer(&self->code, g_free);
69  g_clear_pointer(&self->message, g_free);
70  g_clear_pointer(&self->details, fl_value_unref);
71 
72  G_OBJECT_CLASS(fl_method_error_response_parent_class)->dispose(object);
73 }
G_MODULE_EXPORT void fl_value_unref(FlValue *self)
Definition: fl_value.cc:341

◆ fl_method_error_response_get_code()

G_MODULE_EXPORT const gchar* fl_method_error_response_get_code ( FlMethodErrorResponse *  self)

Definition at line 166 of file fl_method_response.cc.

Referenced by cancel_exception_response_cb(), decode_response_with_error(), error_response_cb(), fl_method_channel_respond(), fl_method_response_get_result(), listen_exception_response_cb(), message_cb(), method_call_error_response_cb(), and TEST().

167  {
168  g_return_val_if_fail(FL_IS_METHOD_ERROR_RESPONSE(self), nullptr);
169  return self->code;
170 }

◆ fl_method_error_response_get_details()

G_MODULE_EXPORT FlValue* fl_method_error_response_get_details ( FlMethodErrorResponse *  self)

Definition at line 178 of file fl_method_response.cc.

Referenced by decode_response_with_error(), error_response_cb(), fl_method_channel_respond(), fl_method_response_get_result(), message_cb(), method_call_error_response_cb(), and TEST().

179  {
180  g_return_val_if_fail(FL_IS_METHOD_ERROR_RESPONSE(self), nullptr);
181  return self->details;
182 }

◆ fl_method_error_response_get_message()

G_MODULE_EXPORT const gchar* fl_method_error_response_get_message ( FlMethodErrorResponse *  self)

Definition at line 172 of file fl_method_response.cc.

Referenced by cancel_exception_response_cb(), decode_response_with_error(), error_response_cb(), fl_method_channel_respond(), fl_method_response_get_result(), listen_exception_response_cb(), message_cb(), method_call_error_response_cb(), and TEST().

173  {
174  g_return_val_if_fail(FL_IS_METHOD_ERROR_RESPONSE(self), nullptr);
175  return self->message;
176 }

◆ fl_method_error_response_get_type()

G_MODULE_EXPORT GType fl_method_error_response_get_type ( )

◆ fl_method_error_response_init()

static void fl_method_error_response_init ( FlMethodErrorResponse *  self)
static

Definition at line 80 of file fl_method_response.cc.

80 {}

◆ fl_method_error_response_new()

G_MODULE_EXPORT FlMethodErrorResponse* fl_method_error_response_new ( const gchar *  code,
const gchar *  message,
FlValue details 
)

Definition at line 150 of file fl_method_response.cc.

References fl_method_error_response_get_type(), and fl_value_ref().

Referenced by activate_system_cursor(), cancel_exception_cancel_cb(), clipboard_get_data_async(), clipboard_set_data(), fl_json_method_codec_decode_response(), fl_method_call_respond_error(), fl_standard_method_codec_decode_response(), fl_test_codec_decode_response(), handle_method_call(), listen_exception_listen_cb(), set_client(), system_navigator_pop(), and TEST().

153  {
154  g_return_val_if_fail(code != nullptr, nullptr);
155 
156  FlMethodErrorResponse* self = FL_METHOD_ERROR_RESPONSE(
157  g_object_new(fl_method_error_response_get_type(), nullptr));
158 
159  self->code = g_strdup(code);
160  self->message = g_strdup(message);
161  self->details = details != nullptr ? fl_value_ref(details) : nullptr;
162 
163  return self;
164 }
G_MODULE_EXPORT GType fl_method_error_response_get_type()
G_MODULE_EXPORT FlValue * fl_value_ref(FlValue *self)
Definition: fl_value.cc:335

◆ fl_method_not_implemented_response_class_init()

static void fl_method_not_implemented_response_class_init ( FlMethodNotImplementedResponseClass *  klass)
static

Definition at line 82 of file fl_method_response.cc.

83  {}

◆ fl_method_not_implemented_response_get_type()

G_MODULE_EXPORT GType fl_method_not_implemented_response_get_type ( )

◆ fl_method_not_implemented_response_init()

static void fl_method_not_implemented_response_init ( FlMethodNotImplementedResponse *  self)
static

Definition at line 85 of file fl_method_response.cc.

86  {}

◆ fl_method_not_implemented_response_new()

G_MODULE_EXPORT FlMethodNotImplementedResponse* fl_method_not_implemented_response_new ( )

Definition at line 185 of file fl_method_response.cc.

References fl_method_not_implemented_response_get_type().

Referenced by fl_method_call_respond_not_implemented(), fl_method_codec_decode_response(), method_call_cb(), and TEST().

185  {
186  return FL_METHOD_NOT_IMPLEMENTED_RESPONSE(
187  g_object_new(fl_method_not_implemented_response_get_type(), nullptr));
188 }
G_MODULE_EXPORT GType fl_method_not_implemented_response_get_type()

◆ fl_method_response_get_result()

G_MODULE_EXPORT FlValue* fl_method_response_get_result ( FlMethodResponse *  self,
GError **  error 
)

Definition at line 88 of file fl_method_response.cc.

References _FlMethodErrorResponse::code, _FlMethodErrorResponse::details, fl_method_error_response_get_code(), fl_method_error_response_get_details(), fl_method_error_response_get_message(), FL_METHOD_RESPONSE_ERROR, FL_METHOD_RESPONSE_ERROR_FAILED, FL_METHOD_RESPONSE_ERROR_NOT_IMPLEMENTED, FL_METHOD_RESPONSE_ERROR_REMOTE_ERROR, fl_method_success_response_get_result(), fl_value_to_string(), and _FlMethodErrorResponse::message.

Referenced by finish_method(), method_response_cb(), nullptr_args_response_cb(), send_events_events_cb(), and TEST().

89  {
90  if (FL_IS_METHOD_SUCCESS_RESPONSE(self)) {
92  FL_METHOD_SUCCESS_RESPONSE(self));
93  }
94 
95  if (FL_IS_METHOD_ERROR_RESPONSE(self)) {
96  const gchar* code =
97  fl_method_error_response_get_code(FL_METHOD_ERROR_RESPONSE(self));
98  const gchar* message =
99  fl_method_error_response_get_message(FL_METHOD_ERROR_RESPONSE(self));
100  FlValue* details =
101  fl_method_error_response_get_details(FL_METHOD_ERROR_RESPONSE(self));
102  g_autofree gchar* details_text = nullptr;
103  if (details != nullptr) {
104  details_text = fl_value_to_string(details);
105  }
106 
107  g_autoptr(GString) error_message = g_string_new("");
108  g_string_append_printf(error_message, "Remote code returned error %s",
109  code);
110  if (message != nullptr) {
111  g_string_append_printf(error_message, ": %s", message);
112  }
113  if (details_text != nullptr) {
114  g_string_append_printf(error_message, " %s", details_text);
115  }
116  g_set_error_literal(error, FL_METHOD_RESPONSE_ERROR,
118  error_message->str);
119  return nullptr;
120  } else if (FL_IS_METHOD_NOT_IMPLEMENTED_RESPONSE(self)) {
121  g_set_error(error, FL_METHOD_RESPONSE_ERROR,
123  "Requested method is not implemented");
124  return nullptr;
125  } else {
126  g_set_error(error, FL_METHOD_RESPONSE_ERROR,
127  FL_METHOD_RESPONSE_ERROR_FAILED, "Unknown response type");
128  return nullptr;
129  }
130 }
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition: fl_value.h:39
FlMethodResponse GError ** error
G_MODULE_EXPORT FlValue * fl_method_success_response_get_result(FlMethodSuccessResponse *self)
G_MODULE_EXPORT const gchar * fl_method_error_response_get_message(FlMethodErrorResponse *self)
G_MODULE_EXPORT gchar * fl_value_to_string(FlValue *value)
Definition: fl_value.cc:723
#define FL_METHOD_RESPONSE_ERROR
G_MODULE_EXPORT const gchar * fl_method_error_response_get_code(FlMethodErrorResponse *self)
G_MODULE_EXPORT FlValue * fl_method_error_response_get_details(FlMethodErrorResponse *self)

◆ fl_method_response_get_type()

fl_method_response_get_type ( )

Definition at line 44 of file fl_method_response.cc.

46  {}

◆ fl_method_response_init()

static void fl_method_response_init ( FlMethodResponse *  self)
static

Definition at line 48 of file fl_method_response.cc.

48 {}

◆ fl_method_success_response_class_init()

static void fl_method_success_response_class_init ( FlMethodSuccessResponseClass *  klass)
static

Definition at line 58 of file fl_method_response.cc.

References fl_method_success_response_dispose().

59  {
60  G_OBJECT_CLASS(klass)->dispose = fl_method_success_response_dispose;
61 }
static void fl_method_success_response_dispose(GObject *object)

◆ fl_method_success_response_dispose()

static void fl_method_success_response_dispose ( GObject *  object)
static

Definition at line 50 of file fl_method_response.cc.

References fl_value_unref().

Referenced by fl_method_success_response_class_init().

50  {
51  FlMethodSuccessResponse* self = FL_METHOD_SUCCESS_RESPONSE(object);
52 
53  g_clear_pointer(&self->result, fl_value_unref);
54 
55  G_OBJECT_CLASS(fl_method_success_response_parent_class)->dispose(object);
56 }
G_MODULE_EXPORT void fl_value_unref(FlValue *self)
Definition: fl_value.cc:341

◆ fl_method_success_response_get_result()

G_MODULE_EXPORT FlValue* fl_method_success_response_get_result ( FlMethodSuccessResponse *  response)

fl_method_success_response_get_result: : an #FlMethodSuccessResponse.

Gets the result of the method call.

Returns: an FlValue.

Definition at line 144 of file fl_method_response.cc.

Referenced by decode_response_with_success(), fl_method_channel_respond(), fl_method_response_get_result(), method_call_success_response_cb(), and TEST().

145  {
146  g_return_val_if_fail(FL_IS_METHOD_SUCCESS_RESPONSE(self), nullptr);
147  return self->result;
148 }

◆ fl_method_success_response_get_type()

G_MODULE_EXPORT GType fl_method_success_response_get_type ( )

◆ fl_method_success_response_init()

static void fl_method_success_response_init ( FlMethodSuccessResponse *  self)
static

Definition at line 63 of file fl_method_response.cc.

63 {}

◆ fl_method_success_response_new()

G_MODULE_EXPORT FlMethodSuccessResponse* fl_method_success_response_new ( FlValue result)

fl_method_success_response_new:

Returns
: (allow-none): the FlValue returned by the method call or NULL.

Creates a response to a method call when that method has successfully completed.

Returns: a new #FlMethodResponse.

Definition at line 132 of file fl_method_response.cc.

References fl_method_success_response_get_type(), and fl_value_ref().

Referenced by activate_system_cursor(), clear_client(), clipboard_set_data(), clipboard_text_cb(), clipboard_text_has_strings_cb(), fl_json_method_codec_decode_response(), fl_method_call_respond_success(), fl_standard_method_codec_decode_response(), fl_test_codec_decode_response(), hide(), set_client(), set_editable_size_and_transform(), set_editing_state(), set_marked_text_rect(), show(), system_navigator_pop(), and TEST().

133  {
134  FlMethodSuccessResponse* self = FL_METHOD_SUCCESS_RESPONSE(
135  g_object_new(fl_method_success_response_get_type(), nullptr));
136 
137  if (result != nullptr) {
138  self->result = fl_value_ref(result);
139  }
140 
141  return self;
142 }
G_MODULE_EXPORT GType fl_method_success_response_get_type()
G_MODULE_EXPORT FlValue * fl_value_ref(FlValue *self)
Definition: fl_value.cc:335

◆ G_DEFINE_TYPE()

G_DEFINE_TYPE ( FlMethodSuccessResponse  ,
fl_method_success_response  ,
fl_method_response_get_type()   
)

Variable Documentation

◆ fl_method_error_response

fl_method_error_response

Definition at line 40 of file fl_method_response.cc.

◆ fl_method_not_implemented_response

fl_method_not_implemented_response

Definition at line 43 of file fl_method_response.cc.