| Flutter Linux Embedder |

Classes | Functions
fl_method_call.cc File Reference
`#include "flutter/shell/platform/linux/public/flutter_linux/fl_method_call.h"`
`#include "flutter/shell/platform/linux/fl_method_call_private.h"`
`#include "flutter/shell/platform/linux/fl_method_channel_private.h"`
`#include <gmodule.h>`

Go to the source code of this file.

## Classes
struct | _FlMethodCall

## Functions
static void | fl_method_call_dispose (GObject *object)
static void | fl_method_call_class_init (FlMethodCallClass *klass)
static void | fl_method_call_init (FlMethodCall *self)
FlMethodCall * | fl_method_call_new (const gchar *name, FlValue *args, FlMethodChannel *channel, FlBinaryMessengerResponseHandle *response_handle)
const G_MODULE_EXPORT gchar * | fl_method_call_get_name (FlMethodCall *self)
G_MODULE_EXPORT FlValue * | fl_method_call_get_args (FlMethodCall *self)
G_MODULE_EXPORT gboolean | fl_method_call_respond (FlMethodCall *self, FlMethodResponse *response, GError **error)
G_MODULE_EXPORT gboolean | fl_method_call_respond_success (FlMethodCall *self, FlValue *result, GError **error)
G_MODULE_EXPORT gboolean | fl_method_call_respond_error (FlMethodCall *self, const gchar *code, const gchar *message, FlValue *details, GError **error)
G_MODULE_EXPORT gboolean | fl_method_call_respond_not_implemented (FlMethodCall *self, GError **error)

## Function Documentation

## ◆ fl_method_call_class_init()

static void fl_method_call_class_init | ( | FlMethodCallClass * | klass | ) |
| static

Definition at line 38 of file fl_method_call.cc.

38 {
39 G_OBJECT_CLASS(klass)->dispose = fl_method_call_dispose;
40 }

References fl_method_call_dispose().

## ◆ fl_method_call_dispose()

static void fl_method_call_dispose | ( | GObject * | object | ) |
| static

Definition at line 27 of file fl_method_call.cc.

27 {
28 FlMethodCall* self = FL_METHOD_CALL(object);
29
30 g_clear_pointer(&self->name, g_free);
31 g_clear_pointer(&self->args, fl_value_unref);
32 g_clear_object(&self->channel);
33 g_clear_object(&self->response_handle);
34
35 G_OBJECT_CLASS(fl_method_call_parent_class)->dispose(object);
36 }

References fl_value_unref().

Referenced by fl_method_call_class_init().

## ◆ fl_method_call_get_args()

G_MODULE_EXPORT FlValue* fl_method_call_get_args | ( | FlMethodCall * | method_call | ) |

fl_method_call_get_args: @method_call: an #FlMethodCall.

Gets the arguments passed to the method.

Returns: an FlValue.

Definition at line 72 of file fl_method_call.cc.

72 {
73 g_return_val_if_fail(FL_IS_METHOD_CALL(self), nullptr);
74 return self->args;
75 }

Referenced by clipboard_get_data_async(), method_call_cb(), method_call_error_cb(), method_call_not_implemented_cb(), method_call_success_cb(), and system_exit_application().

## ◆ fl_method_call_get_name()

const G_MODULE_EXPORT gchar* fl_method_call_get_name | ( | FlMethodCall * | method_call | ) |

FlMethodCall:

#FlMethodCall represents and incoming method call as returned by an #FlMethodChannel. fl_method_call_get_name: @method_call: an #FlMethodCall.

Gets the name of the method call.

Returns: a method name.

Definition at line 67 of file fl_method_call.cc.

67 {
68 g_return_val_if_fail(FL_IS_METHOD_CALL(self), nullptr);
69 return self->name;
70 }

Referenced by method_call_cb(), method_call_error_cb(), method_call_handler(), method_call_not_implemented_cb(), and method_call_success_cb().

## ◆ fl_method_call_init()

static void fl_method_call_init | ( | FlMethodCall * | self | ) |
| static

Definition at line 42 of file fl_method_call.cc.

42 {}

## ◆ fl_method_call_new()

FlMethodCall* fl_method_call_new | ( | const gchar * | name,
|  | FlValue * | args,
|  | FlMethodChannel * | channel,
|  | FlBinaryMessengerResponseHandle * | response_handle
| ) |  |

Definition at line 44 of file fl_method_call.cc.

48 {
49 g_return_val_if_fail(name != nullptr, nullptr);
50 g_return_val_if_fail(args != nullptr, nullptr);
51 g_return_val_if_fail(FL_IS_METHOD_CHANNEL(channel), nullptr);
52 g_return_val_if_fail(FL_IS_BINARY_MESSENGER_RESPONSE_HANDLE(response_handle),
53 nullptr);
54
55 FlMethodCall* self =
56 FL_METHOD_CALL(g_object_new(fl_method_call_get_type(), nullptr));
57
58 self->name = g_strdup(name);
59 self->args = fl_value_ref(args);
60 self->channel = FL_METHOD_CHANNEL(g_object_ref(channel));
61 self->response_handle =
62 FL_BINARY_MESSENGER_RESPONSE_HANDLE(g_object_ref(response_handle));
63
64 return self;
65 }

References args, and fl_value_ref().

Referenced by message_cb().

## ◆ fl_method_call_respond()

G_MODULE_EXPORT gboolean fl_method_call_respond | ( | FlMethodCall * | method_call,
|  | FlMethodResponse * | response,
|  | GError ** | error
| ) |  |

fl_method_call_respond: @method_call: an #FlMethodCall. @response: an #FlMethodResponse. @error: (allow-none): #GError location to store the error occurring, or NULL to ignore.

Responds to a method call.

Returns: TRUE on success.

Definition at line 77 of file fl_method_call.cc.

79 {
80 g_return_val_if_fail(FL_IS_METHOD_CALL(self), FALSE);
81 g_return_val_if_fail(FL_IS_METHOD_RESPONSE(response), FALSE);
82
83 g_autoptr(GError) local_error = nullptr;
84 if (!fl_method_channel_respond(self->channel, self->response_handle, response,
85 &local_error)) {
86 // If the developer chose not to handle the error then log it so it's not
87 // missed.
88 if (error == nullptr) {
89 g_warning("Failed to send method call response: %s",
90 local_error->message);
91 }
92
93 g_propagate_error(error, local_error);
94 return FALSE;
95 }
96
97 return TRUE;
98 }

References error, fl_method_channel_respond(), and TRUE.

Referenced by method_call_cb(), method_call_handler(), request_app_exit_response_cb(), and send_response().

## ◆ fl_method_call_respond_error()

G_MODULE_EXPORT gboolean fl_method_call_respond_error | ( | FlMethodCall * | self,
|  | const gchar * | code,
|  | const gchar * | message,
|  | FlValue * | details,
|  | GError ** | error
| ) |  |

Definition at line 111 of file fl_method_call.cc.

115 {
116 g_return_val_if_fail(FL_IS_METHOD_CALL(self), FALSE);
117 g_return_val_if_fail(code != nullptr, FALSE);
118
119 g_autoptr(FlMethodResponse) response =
120 FL_METHOD_RESPONSE(fl_method_error_response_new(code, message, details));
121 return fl_method_channel_respond(self->channel, self->response_handle,
122 response, error);
123 }

References error, fl_method_channel_respond(), and fl_method_error_response_new().

Referenced by method_call_error_cb(), and method_call_error_error_cb().

## ◆ fl_method_call_respond_not_implemented()

G_MODULE_EXPORT gboolean fl_method_call_respond_not_implemented | ( | FlMethodCall * | self,
|  | GError ** | error
| ) |  |

Definition at line 125 of file fl_method_call.cc.

127 {
128 g_return_val_if_fail(FL_IS_METHOD_CALL(self), FALSE);
129
130 g_autoptr(FlMethodResponse) response =
131 FL_METHOD_RESPONSE(fl_method_not_implemented_response_new());
132 return fl_method_channel_respond(self->channel, self->response_handle,
133 response, error);
134 }

References error, fl_method_channel_respond(), and fl_method_not_implemented_response_new().

Referenced by method_call_error_error_cb(), method_call_not_implemented_cb(), and method_call_success_error_cb().

## ◆ fl_method_call_respond_success()

G_MODULE_EXPORT gboolean fl_method_call_respond_success | ( | FlMethodCall * | method_call,
|  | FlValue * | result,
|  | GError ** | error
| ) |  |

fl_method_call_respond_success: @method_call: an #FlMethodCall.

Returns
  : (allow-none): value to respond with, must match what the #FlMethodCodec supports. @error: (allow-none): #GError location to store the error occurring, or NULL to ignore.

Convenience method that responds to method call with #FlMethodSuccessResponse.

Returns: TRUE on success.

Definition at line 100 of file fl_method_call.cc.

102 {
103 g_return_val_if_fail(FL_IS_METHOD_CALL(self), FALSE);
104
105 g_autoptr(FlMethodResponse) response =
106 FL_METHOD_RESPONSE(fl_method_success_response_new(result));
107 return fl_method_channel_respond(self->channel, self->response_handle,
108 response, error);
109 }

References error, fl_method_channel_respond(), fl_method_success_response_new(), and result.

Referenced by method_call_success_cb(), method_call_success_error_cb(), and reassign_method_cb().

fl_method_error_response_new
G_MODULE_EXPORT FlMethodErrorResponse * fl_method_error_response_new(const gchar *code, const gchar *message, FlValue *details)
Definition: fl_method_response.cc:144
fl_method_not_implemented_response_new
G_MODULE_EXPORT FlMethodNotImplementedResponse * fl_method_not_implemented_response_new()
Definition: fl_method_response.cc:179
fl_method_call_dispose
static void fl_method_call_dispose(GObject *object)
Definition: fl_method_call.cc:27
fl_method_success_response_new
G_MODULE_EXPORT FlMethodSuccessResponse * fl_method_success_response_new(FlValue *result)
Definition: fl_method_response.cc:126
fl_value_unref
G_MODULE_EXPORT void fl_value_unref(FlValue *self)
Definition: fl_value.cc:400
fl_value_ref
G_MODULE_EXPORT FlValue * fl_value_ref(FlValue *self)
Definition: fl_value.cc:394
fl_method_channel_respond
gboolean fl_method_channel_respond(FlMethodChannel *self, FlBinaryMessengerResponseHandle *response_handle, FlMethodResponse *response, GError **error)
Definition: fl_method_channel.cc:211
TRUE
return TRUE
Definition: fl_pixel_buffer_texture_test.cc:53
result
GAsyncResult * result
Definition: fl_text_input_handler.cc:106
args
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
Definition: fl_event_channel.h:89
error
const uint8_t uint32_t uint32_t GError ** error
Definition: fl_pixel_buffer_texture_test.cc:40