| Flutter Linux Embedder |

Classes | Enumerations | Functions
fl_platform_channel.h File Reference
`#include "flutter/shell/platform/linux/public/flutter_linux/fl_binary_messenger.h"`
`#include "flutter/shell/platform/linux/public/flutter_linux/fl_method_call.h"`

Go to the source code of this file.

## Classes
struct | FlPlatformChannelVTable

## Enumerations
enum | FlPlatformChannelExitType { FL_PLATFORM_CHANNEL_EXIT_TYPE_CANCELABLE , FL_PLATFORM_CHANNEL_EXIT_TYPE_REQUIRED }
enum | FlPlatformChannelExitResponse { FL_PLATFORM_CHANNEL_EXIT_RESPONSE_CANCEL , FL_PLATFORM_CHANNEL_EXIT_RESPONSE_EXIT }

## Functions
| G_DECLARE_FINAL_TYPE (FlPlatformChannel, fl_platform_channel, FL, PLATFORM_CHANNEL, GObject)
FlPlatformChannel * | fl_platform_channel_new (FlBinaryMessenger *messenger, FlPlatformChannelVTable *vtable, gpointer user_data)
void | fl_platform_channel_system_request_app_exit (FlPlatformChannel *channel, FlPlatformChannelExitType type, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data)
gboolean | fl_platform_channel_system_request_app_exit_finish (GObject *object, GAsyncResult *result, FlPlatformChannelExitResponse *exit_response, GError **error)
void | fl_platform_channel_respond_system_exit_application (FlMethodCall *method_call, FlPlatformChannelExitResponse exit_response)
void | fl_platform_channel_respond_clipboard_get_data (FlMethodCall *method_call, const gchar *text)
void | fl_platform_channel_respond_clipboard_has_strings (FlMethodCall *method_call, gboolean has_strings)
FlMethodResponse * | fl_platform_channel_make_system_request_app_exit_response (FlPlatformChannelExitResponse exit_response)

## Enumeration Type Documentation

## ◆ FlPlatformChannelExitResponse

enum FlPlatformChannelExitResponse

Enumerator
FL_PLATFORM_CHANNEL_EXIT_RESPONSE_CANCEL |
FL_PLATFORM_CHANNEL_EXIT_RESPONSE_EXIT |

Definition at line 18 of file fl_platform_channel.h.

18 {
19 FL_PLATFORM_CHANNEL_EXIT_RESPONSE_CANCEL,
20 FL_PLATFORM_CHANNEL_EXIT_RESPONSE_EXIT,
21 } FlPlatformChannelExitResponse;
FlPlatformChannelExitResponse
FlPlatformChannelExitResponse
Definition: fl_platform_channel.h:18
FL_PLATFORM_CHANNEL_EXIT_RESPONSE_EXIT
@ FL_PLATFORM_CHANNEL_EXIT_RESPONSE_EXIT
Definition: fl_platform_channel.h:20
FL_PLATFORM_CHANNEL_EXIT_RESPONSE_CANCEL
@ FL_PLATFORM_CHANNEL_EXIT_RESPONSE_CANCEL
Definition: fl_platform_channel.h:19

## ◆ FlPlatformChannelExitType

enum FlPlatformChannelExitType

Enumerator
FL_PLATFORM_CHANNEL_EXIT_TYPE_CANCELABLE |
FL_PLATFORM_CHANNEL_EXIT_TYPE_REQUIRED |

Definition at line 13 of file fl_platform_channel.h.

13 {
14 FL_PLATFORM_CHANNEL_EXIT_TYPE_CANCELABLE,
15 FL_PLATFORM_CHANNEL_EXIT_TYPE_REQUIRED,
16 } FlPlatformChannelExitType;
FlPlatformChannelExitType
FlPlatformChannelExitType
Definition: fl_platform_channel.h:13
FL_PLATFORM_CHANNEL_EXIT_TYPE_CANCELABLE
@ FL_PLATFORM_CHANNEL_EXIT_TYPE_CANCELABLE
Definition: fl_platform_channel.h:14
FL_PLATFORM_CHANNEL_EXIT_TYPE_REQUIRED
@ FL_PLATFORM_CHANNEL_EXIT_TYPE_REQUIRED
Definition: fl_platform_channel.h:15

## Function Documentation

## ◆ fl_platform_channel_make_system_request_app_exit_response()

FlMethodResponse* fl_platform_channel_make_system_request_app_exit_response | ( | FlPlatformChannelExitResponse | exit_response | ) |

Definition at line 330 of file fl_platform_channel.cc.

331 {
332 g_autoptr(FlValue) exit_result = fl_value_new_map();
333 const gchar* exit_response_string;
334 switch (exit_response) {
335 case FL_PLATFORM_CHANNEL_EXIT_RESPONSE_CANCEL:
336 exit_response_string = kExitResponseCancel;
337 break;
338 case FL_PLATFORM_CHANNEL_EXIT_RESPONSE_EXIT:
339 exit_response_string = kExitResponseExit;
340 break;
341 default:
342 g_assert_not_reached();
343 }
344 fl_value_set_string_take(exit_result, kExitResponseKey,
345 fl_value_new_string(exit_response_string));
346 return FL_METHOD_RESPONSE(fl_method_success_response_new(exit_result));
347 }
g_autoptr
g_autoptr(GMutexLocker) locker
fl_method_success_response_new
G_MODULE_EXPORT FlMethodSuccessResponse * fl_method_success_response_new(FlValue *result)
Definition: fl_method_response.cc:126
kExitResponseExit
static constexpr char kExitResponseExit[]
Definition: fl_platform_channel.cc:32
kExitResponseKey
static constexpr char kExitResponseKey[]
Definition: fl_platform_channel.cc:30
kExitResponseCancel
static constexpr char kExitResponseCancel[]
Definition: fl_platform_channel.cc:31
fl_value_set_string_take
G_MODULE_EXPORT void fl_value_set_string_take(FlValue *self, const gchar *key, FlValue *value)
Definition: fl_value.cc:650
fl_value_new_string
G_MODULE_EXPORT FlValue * fl_value_new_string(const gchar *value)
Definition: fl_value.cc:276
fl_value_new_map
G_MODULE_EXPORT FlValue * fl_value_new_map()
Definition: fl_value.cc:366
FlValue
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition: fl_value.h:42

References fl_method_success_response_new(), FL_PLATFORM_CHANNEL_EXIT_RESPONSE_CANCEL, FL_PLATFORM_CHANNEL_EXIT_RESPONSE_EXIT, fl_value_new_map(), fl_value_new_string(), fl_value_set_string_take(), g_autoptr(), kExitResponseCancel, kExitResponseExit, and kExitResponseKey.

Referenced by fl_platform_channel_respond_system_exit_application(), and system_exit_application().

## ◆ fl_platform_channel_new()

FlPlatformChannel* fl_platform_channel_new | ( | FlBinaryMessenger * | messenger,
|  | FlPlatformChannelVTable * | vtable,
|  | gpointer | user_data
| ) |  |

fl_platform_channel_new: @messenger: an #FlBinaryMessenger @vtable: callbacks for incoming method calls. @user_data: data to pass in callbacks.

Creates a new channel that implements SystemChannels.platform from the Flutter services library.

Returns: a new #FlPlatformChannel

Definition at line 222 of file fl_platform_channel.cc.

224 {
225 g_return_val_if_fail(FL_IS_BINARY_MESSENGER(messenger), nullptr);
226 g_return_val_if_fail(vtable != nullptr, nullptr);
227
228 FlPlatformChannel* self = FL_PLATFORM_CHANNEL(
229 g_object_new(fl_platform_channel_get_type(), nullptr));
230
231 self->vtable = vtable;
232 self->user_data = user_data;
233
234 g_autoptr(FlJsonMethodCodec) codec = fl_json_method_codec_new();
235 self->channel =
236 fl_method_channel_new(messenger, kChannelName, FL_METHOD_CODEC(codec));
237 fl_method_channel_set_method_call_handler(self->channel, method_call_cb, self,
238 nullptr);
239
240 return self;
241 }
self
g_cond_signal & self
Definition: fl_compositor_software.cc:67
user_data
G_BEGIN_DECLS G_MODULE_EXPORT FlValue gpointer user_data
Definition: fl_event_channel.h:90
fl_json_method_codec_new
G_MODULE_EXPORT FlJsonMethodCodec * fl_json_method_codec_new()
Definition: fl_json_method_codec.cc:205
fl_method_channel_new
G_MODULE_EXPORT FlMethodChannel * fl_method_channel_new(FlBinaryMessenger *messenger, const gchar *name, FlMethodCodec *codec)
Definition: fl_method_channel.cc:112
fl_method_channel_set_method_call_handler
G_MODULE_EXPORT void fl_method_channel_set_method_call_handler(FlMethodChannel *self, FlMethodChannelMethodCallHandler handler, gpointer user_data, GDestroyNotify destroy_notify)
Definition: fl_method_channel.cc:134
method_call_cb
static void method_call_cb(FlMethodChannel *channel, FlMethodCall *method_call, gpointer user_data)
Definition: fl_platform_channel.cc:173
kChannelName
static constexpr char kChannelName[]
Definition: fl_platform_channel.cc:12

References fl_json_method_codec_new(), fl_method_channel_new(), fl_method_channel_set_method_call_handler(), g_autoptr(), kChannelName, method_call_cb(), self, and user_data.

Referenced by fl_platform_handler_new(), and TEST().

## ◆ fl_platform_channel_respond_clipboard_get_data()

void fl_platform_channel_respond_clipboard_get_data | ( | FlMethodCall * | method_call,
|  | const gchar * | text
| ) |  |

Definition at line 284 of file fl_platform_channel.cc.

285 {
286 g_autoptr(FlValue) result = nullptr;
287 if (text != nullptr) {
288 result = fl_value_new_map();
289 fl_value_set_string_take(result, kTextKey, fl_value_new_string(text));
290 }
291
292 g_autoptr(FlMethodResponse) response =
293 FL_METHOD_RESPONSE(fl_method_success_response_new(result));
294
295 g_autoptr(GError) error = nullptr;
296 if (!fl_method_call_respond(method_call, response, &error)) {
297 g_warning("Failed to send response to %s: %s", kGetClipboardDataMethod,
298 error->message);
299 }
300 }
fl_method_call_respond
G_MODULE_EXPORT gboolean fl_method_call_respond(FlMethodCall *self, FlMethodResponse *response, GError **error)
Definition: fl_method_call.cc:77
method_call
G_BEGIN_DECLS G_MODULE_EXPORT FlMethodCall * method_call
Definition: fl_method_channel.h:120
error
const uint8_t uint32_t uint32_t GError ** error
Definition: fl_pixel_buffer_texture_test.cc:40
kGetClipboardDataMethod
static constexpr char kGetClipboardDataMethod[]
Definition: fl_platform_channel.cc:14
kTextKey
static constexpr char kTextKey[]
Definition: fl_platform_channel.cc:23

References error, fl_method_call_respond(), fl_method_success_response_new(), fl_value_new_map(), fl_value_new_string(), fl_value_set_string_take(), g_autoptr(), kGetClipboardDataMethod, kTextKey, and method_call.

Referenced by clipboard_text_cb().

## ◆ fl_platform_channel_respond_clipboard_has_strings()

void fl_platform_channel_respond_clipboard_has_strings | ( | FlMethodCall * | method_call,
|  | gboolean | has_strings
| ) |  |

Definition at line 302 of file fl_platform_channel.cc.

304 {
305 g_autoptr(FlValue) result = fl_value_new_map();
306 fl_value_set_string_take(result, kValueKey, fl_value_new_bool(has_strings));
307
308 g_autoptr(FlMethodResponse) response =
309 FL_METHOD_RESPONSE(fl_method_success_response_new(result));
310
311 g_autoptr(GError) error = nullptr;
312 if (!fl_method_call_respond(method_call, response, &error)) {
313 g_warning("Failed to send response to %s: %s", kClipboardHasStringsMethod,
314 error->message);
315 }
316 }
kValueKey
static constexpr char kValueKey[]
Definition: fl_platform_channel.cc:24
kClipboardHasStringsMethod
static constexpr char kClipboardHasStringsMethod[]
Definition: fl_platform_channel.cc:16
fl_value_new_bool
G_MODULE_EXPORT FlValue * fl_value_new_bool(bool value)
Definition: fl_value.cc:255

References error, fl_method_call_respond(), fl_method_success_response_new(), fl_value_new_bool(), fl_value_new_map(), fl_value_set_string_take(), g_autoptr(), kClipboardHasStringsMethod, kValueKey, and method_call.

Referenced by clipboard_text_has_strings_cb().

## ◆ fl_platform_channel_respond_system_exit_application()

void fl_platform_channel_respond_system_exit_application | ( | FlMethodCall * | method_call,
|  | FlPlatformChannelExitResponse | exit_response
| ) |  |

Definition at line 318 of file fl_platform_channel.cc.

320 {
321 g_autoptr(FlMethodResponse) response =
322 fl_platform_channel_make_system_request_app_exit_response(exit_response);
323 g_autoptr(GError) error = nullptr;
324 if (!fl_method_call_respond(method_call, response, &error)) {
325 g_warning("Failed to send response to System.exitApplication: %s",
326 error->message);
327 }
328 }
fl_platform_channel_make_system_request_app_exit_response
FlMethodResponse * fl_platform_channel_make_system_request_app_exit_response(FlPlatformChannelExitResponse exit_response)
Definition: fl_platform_channel.cc:330

References error, fl_method_call_respond(), fl_platform_channel_make_system_request_app_exit_response(), g_autoptr(), and method_call.

Referenced by request_app_exit_response_cb().

## ◆ fl_platform_channel_system_request_app_exit()

void fl_platform_channel_system_request_app_exit | ( | FlPlatformChannel * | channel,
|  | FlPlatformChannelExitType | type,
|  | GCancellable * | cancellable,
|  | GAsyncReadyCallback | callback,
|  | gpointer | user_data
| ) |  |

fl_platform_channel_system_request_app_exit: @channel: an #FlPlatformChannel

Request the application exits (i.e. due to the window being requested to be closed).

Calling this will only send an exit request to the framework if the framework has already indicated that it is ready to receive requests by sending a "System.initializationComplete" method call on the platform channel. Calls before initialization is complete will result in an immediate exit.

Definition at line 243 of file fl_platform_channel.cc.

247 {
248 g_return_if_fail(FL_IS_PLATFORM_CHANNEL(self));
249
250 g_autoptr(FlValue) args = fl_value_new_map();
251 const gchar* type_string;
252 switch (type) {
253 case FL_PLATFORM_CHANNEL_EXIT_TYPE_CANCELABLE:
254 type_string = kExitTypeCancelable;
255 break;
256 case FL_PLATFORM_CHANNEL_EXIT_TYPE_REQUIRED:
257 type_string = kExitTypeRequired;
258 break;
259 default:
260 g_assert_not_reached();
261 }
262 fl_value_set_string_take(args, kExitTypeKey,
263 fl_value_new_string(type_string));
264 fl_method_channel_invoke_method(self->channel, kRequestAppExitMethod, args,
265 cancellable, callback, user_data);
266 }
args
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
Definition: fl_event_channel.h:89
fl_method_channel_invoke_method
G_MODULE_EXPORT void fl_method_channel_invoke_method(FlMethodChannel *self, const gchar *method, FlValue *args, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data)
Definition: fl_method_channel.cc:162
kExitTypeCancelable
static constexpr char kExitTypeCancelable[]
Definition: fl_platform_channel.cc:27
kRequestAppExitMethod
static constexpr char kRequestAppExitMethod[]
Definition: fl_platform_channel.cc:18
kExitTypeRequired
static constexpr char kExitTypeRequired[]
Definition: fl_platform_channel.cc:28
kExitTypeKey
static constexpr char kExitTypeKey[]
Definition: fl_platform_channel.cc:26
type
uint8_t type
Definition: fl_standard_message_codec_test.cc:1117

References args, fl_method_channel_invoke_method(), FL_PLATFORM_CHANNEL_EXIT_TYPE_CANCELABLE, FL_PLATFORM_CHANNEL_EXIT_TYPE_REQUIRED, fl_value_new_map(), fl_value_new_string(), fl_value_set_string_take(), g_autoptr(), kExitTypeCancelable, kExitTypeKey, kExitTypeRequired, kRequestAppExitMethod, self, type, and user_data.

Referenced by request_app_exit(), and TEST().

## ◆ fl_platform_channel_system_request_app_exit_finish()

gboolean fl_platform_channel_system_request_app_exit_finish | ( | GObject * | object,
|  | GAsyncResult * | result,
|  | FlPlatformChannelExitResponse * | exit_response,
|  | GError ** | error
| ) |  |

Definition at line 268 of file fl_platform_channel.cc.

272 {
273 g_autoptr(FlMethodResponse) response = fl_method_channel_invoke_method_finish(
274 FL_METHOD_CHANNEL(object), result, error);
275 if (response == nullptr) {
276 return FALSE;
277 }
278
279 *exit_response = get_exit_response(response);
280
281 return TRUE;
282 }
TRUE
return TRUE
Definition: fl_compositor_software.cc:69
fl_method_channel_invoke_method_finish
G_MODULE_EXPORT FlMethodResponse * fl_method_channel_invoke_method_finish(FlMethodChannel *self, GAsyncResult *result, GError **error)
Definition: fl_method_channel.cc:192
get_exit_response
FlPlatformChannelExitResponse get_exit_response(FlMethodResponse *response)
Definition: fl_platform_channel.cc:87

References error, fl_method_channel_invoke_method_finish(), g_autoptr(), get_exit_response(), and TRUE.

Referenced by request_app_exit_response_cb(), and TEST().

## ◆ G_DECLARE_FINAL_TYPE()

G_DECLARE_FINAL_TYPE | ( | FlPlatformChannel | ,
|  | fl_platform_channel | ,
|  | FL | ,
|  | PLATFORM_CHANNEL | ,
|  | GObject |
| ) |  |