| Flutter Linux Embedder |

fl_binary_messenger.cc
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "flutter/shell/platform/linux/public/flutter_linux/fl_binary_messenger.h"
6 #include "flutter/shell/platform/linux/fl_binary_messenger_private.h"
7
8 #include "flutter/fml/logging.h"
9 #include "flutter/shell/platform/linux/fl_engine_private.h"
10 #include "flutter/shell/platform/linux/fl_method_codec_private.h"
11 #include "flutter/shell/platform/linux/public/flutter_linux/fl_engine.h"
12 #include "flutter/shell/platform/linux/public/flutter_linux/fl_method_channel.h"
13 #include "flutter/shell/platform/linux/public/flutter_linux/fl_method_codec.h"
14 #include "flutter/shell/platform/linux/public/flutter_linux/fl_standard_method_codec.h"
15
16 #include <gmodule.h>
17
18 static constexpr char kControlChannelName[] = "dev.flutter/channel-buffers";
19 static constexpr char kResizeMethod[] = "resize";
20 static constexpr char kOverflowMethod[] = "overflow";
21
22 G_DEFINE_QUARK(fl_binary_messenger_codec_error_quark,
23 fl_binary_messenger_codec_error)
24
25 G_DECLARE_FINAL_TYPE(FlBinaryMessengerImpl,
26 fl_binary_messenger_impl,
27 FL,
28 BINARY_MESSENGER_IMPL,
29 GObject)
30
31 G_DECLARE_FINAL_TYPE(FlBinaryMessengerResponseHandleImpl,
32 fl_binary_messenger_response_handle_impl,
33 FL,
34 BINARY_MESSENGER_RESPONSE_HANDLE_IMPL,
35 FlBinaryMessengerResponseHandle)
36
37 G_DEFINE_INTERFACE(FlBinaryMessenger, fl_binary_messenger, G_TYPE_OBJECT)
38
39 struct _FlBinaryMessengerImpl {
40 GObject parent_instance;
41
42 GWeakRef engine;
43
44 // PlatformMessageHandler keyed by channel name.
45 GHashTable* platform_message_handlers;
46 };
47
48 static void fl_binary_messenger_impl_iface_init(
49 FlBinaryMessengerInterface* iface);
50
51 G_DEFINE_TYPE_WITH_CODE(
52 FlBinaryMessengerImpl,
53 fl_binary_messenger_impl,
54 G_TYPE_OBJECT,
55 G_IMPLEMENT_INTERFACE(fl_binary_messenger_get_type(),
56 fl_binary_messenger_impl_iface_init))
57
58 static void fl_binary_messenger_response_handle_class_init(
59 FlBinaryMessengerResponseHandleClass* klass) {}
60
61 G_DEFINE_TYPE(FlBinaryMessengerResponseHandle,
62 fl_binary_messenger_response_handle,
63 G_TYPE_OBJECT)
64
65 static void fl_binary_messenger_response_handle_init(
66 FlBinaryMessengerResponseHandle* self) {}
67
68 struct _FlBinaryMessengerResponseHandleImpl {
69 FlBinaryMessengerResponseHandle parent_instance;
70
71 // Messenger sending response on.
72 FlBinaryMessengerImpl* messenger;
73
74 // Handle to send the response with. This is cleared to nullptr when it is
75 // used.
76 const FlutterPlatformMessageResponseHandle* response_handle;
77 };
78
79 G_DEFINE_TYPE(FlBinaryMessengerResponseHandleImpl,
80 fl_binary_messenger_response_handle_impl,
81 fl_binary_messenger_response_handle_get_type())
82
83 static void fl_binary_messenger_default_init(
84 FlBinaryMessengerInterface* iface) {}
85
86 static void fl_binary_messenger_response_handle_impl_dispose(GObject* object) {
87 FlBinaryMessengerResponseHandleImpl* self =
88 FL_BINARY_MESSENGER_RESPONSE_HANDLE_IMPL(object);
89
90 g_autoptr(FlEngine) engine =
91 FL_ENGINE(g_weak_ref_get(&self->messenger->engine));
92 if (self->response_handle != nullptr && engine != nullptr) {
93 g_critical("FlBinaryMessengerResponseHandle was not responded to");
94 }
95
96 g_clear_object(&self->messenger);
97 self->response_handle = nullptr;
98
99 G_OBJECT_CLASS(fl_binary_messenger_response_handle_impl_parent_class)
100 ->dispose(object);
101 }
102
103 static void fl_binary_messenger_response_handle_impl_class_init(
104 FlBinaryMessengerResponseHandleImplClass* klass) {
105 G_OBJECT_CLASS(klass)->dispose =
106 fl_binary_messenger_response_handle_impl_dispose;
107 }
108
109 static void fl_binary_messenger_response_handle_impl_init(
110 FlBinaryMessengerResponseHandleImpl* self) {}
111
112 static FlBinaryMessengerResponseHandleImpl*
113 fl_binary_messenger_response_handle_impl_new(
114 FlBinaryMessengerImpl* messenger,
115 const FlutterPlatformMessageResponseHandle* response_handle) {
116 FlBinaryMessengerResponseHandleImpl* self =
117 FL_BINARY_MESSENGER_RESPONSE_HANDLE_IMPL(g_object_new(
118 fl_binary_messenger_response_handle_impl_get_type(), nullptr));
119
120 self->messenger = FL_BINARY_MESSENGER_IMPL(g_object_ref(messenger));
121 self->response_handle = response_handle;
122
123 return self;
124 }
125
126 typedef struct {
127 FlBinaryMessengerMessageHandler message_handler;
128 gpointer message_handler_data;
129 GDestroyNotify message_handler_destroy_notify;
130 } PlatformMessageHandler;
131
132 static PlatformMessageHandler* platform_message_handler_new(
133 FlBinaryMessengerMessageHandler handler,
134 gpointer user_data,
135 GDestroyNotify destroy_notify) {
136 PlatformMessageHandler* self = static_cast<PlatformMessageHandler*>(
137 g_malloc0(sizeof(PlatformMessageHandler)));
138 self->message_handler = handler;
139 self->message_handler_data = user_data;
140 self->message_handler_destroy_notify = destroy_notify;
141 return self;
142 }
143
144 static void platform_message_handler_free(gpointer data) {
145 PlatformMessageHandler* self = static_cast<PlatformMessageHandler*>(data);
146 if (self->message_handler_destroy_notify) {
147 self->message_handler_destroy_notify(self->message_handler_data);
148 }
149 g_free(self);
150 }
151
152 static gboolean fl_binary_messenger_platform_message_cb(
153 FlEngine* engine,
154 const gchar* channel,
155 GBytes* message,
156 const FlutterPlatformMessageResponseHandle* response_handle,
157 void* user_data) {
158 FlBinaryMessengerImpl* self = FL_BINARY_MESSENGER_IMPL(user_data);
159
160 PlatformMessageHandler* handler = static_cast<PlatformMessageHandler*>(
161 g_hash_table_lookup(self->platform_message_handlers, channel));
162 if (handler == nullptr) {
163 return FALSE;
164 }
165
166 g_autoptr(FlBinaryMessengerResponseHandleImpl) handle =
167 fl_binary_messenger_response_handle_impl_new(self, response_handle);
168 handler->message_handler(FL_BINARY_MESSENGER(self), channel, message,
169 FL_BINARY_MESSENGER_RESPONSE_HANDLE(handle),
170 handler->message_handler_data);
171
172 return TRUE;
173 }
174
175 static void fl_binary_messenger_impl_dispose(GObject* object) {
176 FlBinaryMessengerImpl* self = FL_BINARY_MESSENGER_IMPL(object);
177
178 g_weak_ref_clear(&self->engine);
179
180 g_clear_pointer(&self->platform_message_handlers, g_hash_table_unref);
181
182 G_OBJECT_CLASS(fl_binary_messenger_impl_parent_class)->dispose(object);
183 }
184
185 static void set_message_handler_on_channel(
186 FlBinaryMessenger* messenger,
187 const gchar* channel,
188 FlBinaryMessengerMessageHandler handler,
189 gpointer user_data,
190 GDestroyNotify destroy_notify) {
191 FlBinaryMessengerImpl* self = FL_BINARY_MESSENGER_IMPL(messenger);
192
193 // Don't set handlers if engine already gone.
194 g_autoptr(FlEngine) engine = FL_ENGINE(g_weak_ref_get(&self->engine));
195 if (engine == nullptr) {
196 if (handler != nullptr) {
197 g_warning(
198 "Attempted to set message handler on an FlBinaryMessenger without an "
199 "engine");
200 }
201 if (destroy_notify != nullptr) {
202 destroy_notify(user_data);
203 }
204 return;
205 }
206
207 if (handler != nullptr) {
208 g_hash_table_replace(
209 self->platform_message_handlers, g_strdup(channel),
210 platform_message_handler_new(handler, user_data, destroy_notify));
211 } else {
212 g_hash_table_remove(self->platform_message_handlers, channel);
213 }
214 }
215
216 static gboolean do_unref(gpointer value) {
217 g_object_unref(value);
218 return G_SOURCE_REMOVE;
219 }
220
221 // Note: This function can be called from any thread.
222 static gboolean send_response(FlBinaryMessenger* messenger,
223 FlBinaryMessengerResponseHandle* response_handle_,
224 GBytes* response,
225 GError** error) {
226 FlBinaryMessengerImpl* self = FL_BINARY_MESSENGER_IMPL(messenger);
227 g_return_val_if_fail(
228 FL_IS_BINARY_MESSENGER_RESPONSE_HANDLE_IMPL(response_handle_), FALSE);
229 FlBinaryMessengerResponseHandleImpl* response_handle =
230 FL_BINARY_MESSENGER_RESPONSE_HANDLE_IMPL(response_handle_);
231
232 g_return_val_if_fail(response_handle->messenger == self, FALSE);
233 g_return_val_if_fail(response_handle->response_handle != nullptr, FALSE);
234
235 FlEngine* engine = FL_ENGINE(g_weak_ref_get(&self->engine));
236 if (engine == nullptr) {
237 return TRUE;
238 }
239
240 gboolean result = false;
241 if (response_handle->response_handle == nullptr) {
242 g_set_error(
243 error, FL_BINARY_MESSENGER_ERROR,
244 FL_BINARY_MESSENGER_ERROR_ALREADY_RESPONDED,
245 "Attempted to respond to a message that is already responded to");
246 result = FALSE;
247 } else {
248 result = fl_engine_send_platform_message_response(
249 engine, response_handle->response_handle, response, error);
250 response_handle->response_handle = nullptr;
251 }
252
253 // This guarantees that the dispose method for the engine is executed
254 // on the platform thread in the rare chance this is the last ref.
255 g_idle_add(do_unref, engine);
256
257 return result;
258 }
259
260 static void platform_message_ready_cb(GObject* object,
261 GAsyncResult* result,
262 gpointer user_data) {
263 GTask* task = G_TASK(user_data);
264 g_task_return_pointer(task, result, g_object_unref);
265 }
266
267 static void send_on_channel(FlBinaryMessenger* messenger,
268 const gchar* channel,
269 GBytes* message,
270 GCancellable* cancellable,
271 GAsyncReadyCallback callback,
272 gpointer user_data) {
273 FlBinaryMessengerImpl* self = FL_BINARY_MESSENGER_IMPL(messenger);
274
275 g_autoptr(FlEngine) engine = FL_ENGINE(g_weak_ref_get(&self->engine));
276 if (engine == nullptr) {
277 return;
278 }
279
280 fl_engine_send_platform_message(
281 engine, channel, message, cancellable,
282 callback != nullptr ? platform_message_ready_cb : nullptr,
283 callback != nullptr ? g_task_new(self, cancellable, callback, user_data)
284 : nullptr);
285 }
286
287 static GBytes* send_on_channel_finish(FlBinaryMessenger* messenger,
288 GAsyncResult* result,
289 GError** error) {
290 FlBinaryMessengerImpl* self = FL_BINARY_MESSENGER_IMPL(messenger);
291 g_return_val_if_fail(g_task_is_valid(result, self), FALSE);
292
293 g_autoptr(GTask) task = G_TASK(result);
294 GAsyncResult* r = G_ASYNC_RESULT(g_task_propagate_pointer(task, nullptr));
295
296 g_autoptr(FlEngine) engine = FL_ENGINE(g_weak_ref_get(&self->engine));
297 if (engine == nullptr) {
298 return nullptr;
299 }
300
301 return fl_engine_send_platform_message_finish(engine, r, error);
302 }
303
304 // Completes method call and returns TRUE if the call was successful.
305 static gboolean finish_method(GObject* object,
306 GAsyncResult* result,
307 GError** error) {
308 g_autoptr(GBytes) response = fl_binary_messenger_send_on_channel_finish(
309 FL_BINARY_MESSENGER(object), result, error);
310 if (response == nullptr) {
311 return FALSE;
312 }
313 g_autoptr(FlStandardMethodCodec) codec = fl_standard_method_codec_new();
314 return fl_method_codec_decode_response(FL_METHOD_CODEC(codec), response,
315 error) != nullptr;
316 }
317
318 // Called when a response is received for the resize channel message.
319 static void resize_channel_response_cb(GObject* object,
320 GAsyncResult* result,
321 gpointer user_data) {
322 g_autoptr(GError) error = nullptr;
323 if (!finish_method(object, result, &error)) {
324 g_warning("Failed to resize channel: %s", error->message);
325 }
326 }
327
328 static void resize_channel(FlBinaryMessenger* messenger,
329 const gchar* channel,
330 int64_t new_size) {
331 FML_DCHECK(new_size >= 0);
332 g_autoptr(FlStandardMethodCodec) codec = fl_standard_method_codec_new();
333 g_autoptr(FlValue) args = fl_value_new_list();
334 fl_value_append_take(args, fl_value_new_string(channel));
335 fl_value_append_take(args, fl_value_new_int(new_size));
336 g_autoptr(GBytes) message = fl_method_codec_encode_method_call(
337 FL_METHOD_CODEC(codec), kResizeMethod, args, nullptr);
338 fl_binary_messenger_send_on_channel(messenger, kControlChannelName, message,
339 nullptr, resize_channel_response_cb,
340 nullptr);
341 }
342
343 // Called when a response is received for the warns on overflow message.
344 static void set_warns_on_channel_overflow_response_cb(GObject* object,
345 GAsyncResult* result,
346 gpointer user_data) {
347 g_autoptr(GError) error = nullptr;
348 if (!finish_method(object, result, &error)) {
349 g_warning("Failed to set warns on channel overflow: %s", error->message);
350 }
351 }
352
353 static void set_warns_on_channel_overflow(FlBinaryMessenger* messenger,
354 const gchar* channel,
355 bool warns) {
356 g_autoptr(FlStandardMethodCodec) codec = fl_standard_method_codec_new();
357 g_autoptr(FlValue) args = fl_value_new_list();
358 fl_value_append_take(args, fl_value_new_string(channel));
359 fl_value_append_take(args, fl_value_new_bool(!warns));
360 g_autoptr(GBytes) message = fl_method_codec_encode_method_call(
361 FL_METHOD_CODEC(codec), kOverflowMethod, args, nullptr);
362 fl_binary_messenger_send_on_channel(
363 messenger, kControlChannelName, message, nullptr,
364 set_warns_on_channel_overflow_response_cb, nullptr);
365 }
366
367 static void shutdown(FlBinaryMessenger* messenger) {
368 FlBinaryMessengerImpl* self = FL_BINARY_MESSENGER_IMPL(messenger);
369
370 // Disconnect any handlers.
371 // Take the reference in case a handler tries to modify this table.
372 g_autoptr(GHashTable) handlers = self->platform_message_handlers;
373 self->platform_message_handlers = g_hash_table_new_full(
374 g_str_hash, g_str_equal, g_free, platform_message_handler_free);
375 g_hash_table_remove_all(handlers);
376 }
377
378 static void fl_binary_messenger_impl_class_init(
379 FlBinaryMessengerImplClass* klass) {
380 G_OBJECT_CLASS(klass)->dispose = fl_binary_messenger_impl_dispose;
381 }
382
383 static void fl_binary_messenger_impl_iface_init(
384 FlBinaryMessengerInterface* iface) {
385 iface->set_message_handler_on_channel = set_message_handler_on_channel;
386 iface->send_response = send_response;
387 iface->send_on_channel = send_on_channel;
388 iface->send_on_channel_finish = send_on_channel_finish;
389 iface->resize_channel = resize_channel;
390 iface->set_warns_on_channel_overflow = set_warns_on_channel_overflow;
391 iface->shutdown = shutdown;
392 }
393
394 static void fl_binary_messenger_impl_init(FlBinaryMessengerImpl* self) {
395 self->platform_message_handlers = g_hash_table_new_full(
396 g_str_hash, g_str_equal, g_free, platform_message_handler_free);
397 }
398
399 FlBinaryMessenger* fl_binary_messenger_new(FlEngine* engine) {
400 g_return_val_if_fail(FL_IS_ENGINE(engine), nullptr);
401
402 FlBinaryMessengerImpl* self = FL_BINARY_MESSENGER_IMPL(
403 g_object_new(fl_binary_messenger_impl_get_type(), nullptr));
404
405 // Added to stop compiler complaining about an unused function.
406 FL_IS_BINARY_MESSENGER_IMPL(self);
407
408 g_weak_ref_init(&self->engine, G_OBJECT(engine));
409
410 fl_engine_set_platform_message_handler(
411 engine, fl_binary_messenger_platform_message_cb, self, NULL);
412
413 return FL_BINARY_MESSENGER(self);
414 }
415
416 G_MODULE_EXPORT void fl_binary_messenger_set_message_handler_on_channel(
417 FlBinaryMessenger* self,
418 const gchar* channel,
419 FlBinaryMessengerMessageHandler handler,
420 gpointer user_data,
421 GDestroyNotify destroy_notify) {
422 g_return_if_fail(FL_IS_BINARY_MESSENGER(self));
423 g_return_if_fail(channel != nullptr);
424
425 FL_BINARY_MESSENGER_GET_IFACE(self)->set_message_handler_on_channel(
426 self, channel, handler, user_data, destroy_notify);
427 }
428
429 // Note: This function can be called from any thread.
430 G_MODULE_EXPORT gboolean fl_binary_messenger_send_response(
431 FlBinaryMessenger* self,
432 FlBinaryMessengerResponseHandle* response_handle,
433 GBytes* response,
434 GError** error) {
435 g_return_val_if_fail(FL_IS_BINARY_MESSENGER(self), FALSE);
436 g_return_val_if_fail(FL_IS_BINARY_MESSENGER_RESPONSE_HANDLE(response_handle),
437 FALSE);
438
439 return FL_BINARY_MESSENGER_GET_IFACE(self)->send_response(
440 self, response_handle, response, error);
441 }
442
443 G_MODULE_EXPORT void fl_binary_messenger_send_on_channel(
444 FlBinaryMessenger* self,
445 const gchar* channel,
446 GBytes* message,
447 GCancellable* cancellable,
448 GAsyncReadyCallback callback,
449 gpointer user_data) {
450 g_return_if_fail(FL_IS_BINARY_MESSENGER(self));
451 g_return_if_fail(channel != nullptr);
452
453 FL_BINARY_MESSENGER_GET_IFACE(self)->send_on_channel(
454 self, channel, message, cancellable, callback, user_data);
455 }
456
457 G_MODULE_EXPORT GBytes* fl_binary_messenger_send_on_channel_finish(
458 FlBinaryMessenger* self,
459 GAsyncResult* result,
460 GError** error) {
461 g_return_val_if_fail(FL_IS_BINARY_MESSENGER(self), FALSE);
462
463 return FL_BINARY_MESSENGER_GET_IFACE(self)->send_on_channel_finish(
464 self, result, error);
465 }
466
467 G_MODULE_EXPORT void fl_binary_messenger_resize_channel(FlBinaryMessenger* self,
468 const gchar* channel,
469 int64_t new_size) {
470 g_return_if_fail(FL_IS_BINARY_MESSENGER(self));
471
472 return FL_BINARY_MESSENGER_GET_IFACE(self)->resize_channel(self, channel,
473 new_size);
474 }
475
476 G_MODULE_EXPORT void fl_binary_messenger_set_warns_on_channel_overflow(
477 FlBinaryMessenger* self,
478 const gchar* channel,
479 bool warns) {
480 g_return_if_fail(FL_IS_BINARY_MESSENGER(self));
481
482 return FL_BINARY_MESSENGER_GET_IFACE(self)->set_warns_on_channel_overflow(
483 self, channel, warns);
484 }
485
486 void fl_binary_messenger_shutdown(FlBinaryMessenger* self) {
487 g_return_if_fail(FL_IS_BINARY_MESSENGER(self));
488
489 return FL_BINARY_MESSENGER_GET_IFACE(self)->shutdown(self);
490 }
fl_engine_set_platform_message_handler
void fl_engine_set_platform_message_handler(FlEngine *self, FlEnginePlatformMessageHandler handler, gpointer user_data, GDestroyNotify destroy_notify)
Definition: fl_engine.cc:718
fl_binary_messenger_response_handle_impl_dispose
static void fl_binary_messenger_response_handle_impl_dispose(GObject *object)
Definition: fl_binary_messenger.cc:86
fl_binary_messenger_impl_iface_init
static void fl_binary_messenger_impl_iface_init(FlBinaryMessengerInterface *iface)
Definition: fl_binary_messenger.cc:383
fl_binary_messenger_shutdown
void fl_binary_messenger_shutdown(FlBinaryMessenger *self)
Definition: fl_binary_messenger.cc:486
set_warns_on_channel_overflow_response_cb
static void set_warns_on_channel_overflow_response_cb(GObject *object, GAsyncResult *result, gpointer user_data)
Definition: fl_binary_messenger.cc:344
fl_method_codec_encode_method_call
GBytes * fl_method_codec_encode_method_call(FlMethodCodec *self, const gchar *name, FlValue *args, GError **error)
Definition: fl_method_codec.cc:16
finish_method
static gboolean finish_method(GObject *object, GAsyncResult *result, GError **error)
Definition: fl_binary_messenger.cc:305
G_DEFINE_TYPE_WITH_CODE
G_DEFINE_TYPE_WITH_CODE(FlBinaryMessengerImpl, fl_binary_messenger_impl, G_TYPE_OBJECT, G_IMPLEMENT_INTERFACE(fl_binary_messenger_get_type(), fl_binary_messenger_impl_iface_init)) static void fl_binary_messenger_response_handle_class_init(FlBinaryMessengerResponseHandleClass *klass)
Definition: fl_binary_messenger.cc:51
platform_message_ready_cb
static void platform_message_ready_cb(GObject *object, GAsyncResult *result, gpointer user_data)
Definition: fl_binary_messenger.cc:260
_FlBinaryMessengerResponseHandleImpl
Definition: fl_binary_messenger.cc:68
kResizeMethod
static constexpr char kResizeMethod[]
Definition: fl_binary_messenger.cc:19
fl_standard_method_codec_new
G_MODULE_EXPORT FlStandardMethodCodec * fl_standard_method_codec_new()
Definition: fl_standard_method_codec.cc:291
send_response
static gboolean send_response(FlBinaryMessenger *messenger, FlBinaryMessengerResponseHandle *response_handle_, GBytes *response, GError **error)
Definition: fl_binary_messenger.cc:222
fl_value_new_list
G_MODULE_EXPORT FlValue * fl_value_new_list()
Definition: fl_value.cc:349
fl_binary_messenger_impl
fl_binary_messenger_impl
Definition: fl_binary_messenger.cc:26
fl_method_channel.h
fl_value_new_bool
G_MODULE_EXPORT FlValue * fl_value_new_bool(bool value)
Definition: fl_value.cc:255
FlValue
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition: fl_value.h:42
shutdown
static void shutdown(FlBinaryMessenger *messenger)
Definition: fl_binary_messenger.cc:367
PlatformMessageHandler
Definition: fl_binary_messenger.cc:126
user_data
FlKeyEvent uint64_t FlKeyResponderAsyncCallback gpointer user_data
Definition: fl_key_channel_responder.cc:121
send_on_channel_finish
static GBytes * send_on_channel_finish(FlBinaryMessenger *messenger, GAsyncResult *result, GError **error)
Definition: fl_binary_messenger.cc:287
_FlBinaryMessengerResponseHandleImpl::messenger
FlBinaryMessengerImpl * messenger
Definition: fl_binary_messenger.cc:72
_FlBinaryMessengerResponseHandleImpl::parent_instance
FlBinaryMessengerResponseHandle parent_instance
Definition: fl_binary_messenger.cc:69
platform_message_handler_free
static void platform_message_handler_free(gpointer data)
Definition: fl_binary_messenger.cc:144
FL_BINARY_MESSENGER_ERROR
#define FL_BINARY_MESSENGER_ERROR
Definition: fl_binary_messenger.h:27
G_DECLARE_FINAL_TYPE
GObject G_DECLARE_FINAL_TYPE(FlBinaryMessengerResponseHandleImpl, fl_binary_messenger_response_handle_impl, FL, BINARY_MESSENGER_RESPONSE_HANDLE_IMPL, FlBinaryMessengerResponseHandle) struct _FlBinaryMessengerImpl
Definition: fl_binary_messenger.cc:31
fl_value_new_int
G_MODULE_EXPORT FlValue * fl_value_new_int(int64_t value)
Definition: fl_value.cc:262
send_on_channel
static void send_on_channel(FlBinaryMessenger *messenger, const gchar *channel, GBytes *message, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data)
Definition: fl_binary_messenger.cc:267
fl_binary_messenger_new
FlBinaryMessenger * fl_binary_messenger_new(FlEngine *engine)
Definition: fl_binary_messenger.cc:399
G_DEFINE_INTERFACE
G_DEFINE_INTERFACE(FlKeyboardViewDelegate, fl_keyboard_view_delegate, G_TYPE_OBJECT) static void fl_keyboard_view_delegate_default_init(FlKeyboardViewDelegateInterface *iface)
Definition: fl_keyboard_view_delegate.cc:7
fl_binary_messenger_response_handle_impl_new
static FlBinaryMessengerResponseHandleImpl * fl_binary_messenger_response_handle_impl_new(FlBinaryMessengerImpl *messenger, const FlutterPlatformMessageResponseHandle *response_handle)
Definition: fl_binary_messenger.cc:113
kOverflowMethod
static constexpr char kOverflowMethod[]
Definition: fl_binary_messenger.cc:20
fl_binary_messenger_impl_init
static void fl_binary_messenger_impl_init(FlBinaryMessengerImpl *self)
Definition: fl_binary_messenger.cc:394
G_DEFINE_QUARK
G_DEFINE_QUARK(fl_binary_messenger_codec_error_quark, fl_binary_messenger_codec_error) G_DECLARE_FINAL_TYPE(FlBinaryMessengerImpl
PlatformMessageHandler::message_handler
FlBinaryMessengerMessageHandler message_handler
Definition: fl_binary_messenger.cc:127
fl_binary_messenger_response_handle_impl_init
static void fl_binary_messenger_response_handle_impl_init(FlBinaryMessengerResponseHandleImpl *self)
Definition: fl_binary_messenger.cc:109
fl_binary_messenger_set_warns_on_channel_overflow
G_MODULE_EXPORT void fl_binary_messenger_set_warns_on_channel_overflow(FlBinaryMessenger *self, const gchar *channel, bool warns)
Definition: fl_binary_messenger.cc:476
fl_binary_messenger.h
PlatformMessageHandler::message_handler_data
gpointer message_handler_data
Definition: fl_binary_messenger.cc:128
fl_binary_messenger_impl_class_init
static void fl_binary_messenger_impl_class_init(FlBinaryMessengerImplClass *klass)
Definition: fl_binary_messenger.cc:378
fl_binary_messenger_response_handle_impl_class_init
static void fl_binary_messenger_response_handle_impl_class_init(FlBinaryMessengerResponseHandleImplClass *klass)
Definition: fl_binary_messenger.cc:103
fl_binary_messenger_platform_message_cb
static gboolean fl_binary_messenger_platform_message_cb(FlEngine *engine, const gchar *channel, GBytes *message, const FlutterPlatformMessageResponseHandle *response_handle, void *user_data)
Definition: fl_binary_messenger.cc:152
fl_engine_private.h
fl_binary_messenger_set_message_handler_on_channel
G_MODULE_EXPORT void fl_binary_messenger_set_message_handler_on_channel(FlBinaryMessenger *self, const gchar *channel, FlBinaryMessengerMessageHandler handler, gpointer user_data, GDestroyNotify destroy_notify)
Definition: fl_binary_messenger.cc:416
do_unref
static gboolean do_unref(gpointer value)
Definition: fl_binary_messenger.cc:216
resize_channel
static void resize_channel(FlBinaryMessenger *messenger, const gchar *channel, int64_t new_size)
Definition: fl_binary_messenger.cc:328
TRUE
return TRUE
Definition: fl_pixel_buffer_texture_test.cc:53
FlBinaryMessengerMessageHandler
G_MODULE_EXPORT GObject typedef void(* FlBinaryMessengerMessageHandler)(FlBinaryMessenger *messenger, const gchar *channel, GBytes *message, FlBinaryMessengerResponseHandle *response_handle, gpointer user_data)
Definition: fl_binary_messenger.h:67
fl_value_append_take
G_MODULE_EXPORT void fl_value_append_take(FlValue *self, FlValue *value)
Definition: fl_value.cc:600
fl_engine_send_platform_message_finish
GBytes * fl_engine_send_platform_message_finish(FlEngine *self, GAsyncResult *result, GError **error)
Definition: fl_engine.cc:845
fl_method_codec_decode_response
FlMethodResponse * fl_method_codec_decode_response(FlMethodCodec *self, GBytes *message, GError **error)
Definition: fl_method_codec.cc:62
fl_binary_messenger_send_on_channel_finish
G_MODULE_EXPORT GBytes * fl_binary_messenger_send_on_channel_finish(FlBinaryMessenger *self, GAsyncResult *result, GError **error)
Definition: fl_binary_messenger.cc:457
fl_method_codec.h
FL
FL
Definition: fl_binary_messenger.cc:27
fl_standard_method_codec.h
kControlChannelName
static constexpr char kControlChannelName[]
Definition: fl_binary_messenger.cc:18
result
GAsyncResult * result
Definition: fl_text_input_handler.cc:106
fl_binary_messenger_private.h
fl_binary_messenger_codec_error_quark
G_MODULE_EXPORT GQuark fl_binary_messenger_codec_error_quark(void) G_GNUC_CONST
FL_BINARY_MESSENGER_ERROR_ALREADY_RESPONDED
@ FL_BINARY_MESSENGER_ERROR_ALREADY_RESPONDED
Definition: fl_binary_messenger.h:32
platform_message_handler_new
static PlatformMessageHandler * platform_message_handler_new(FlBinaryMessengerMessageHandler handler, gpointer user_data, GDestroyNotify destroy_notify)
Definition: fl_binary_messenger.cc:132
G_DEFINE_TYPE
G_DEFINE_TYPE(FlBinaryMessengerResponseHandle, fl_binary_messenger_response_handle, G_TYPE_OBJECT) static void fl_binary_messenger_response_handle_init(FlBinaryMessengerResponseHandle *self)
Definition: fl_binary_messenger.cc:61
args
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
Definition: fl_event_channel.h:89
fl_engine.h
error
const uint8_t uint32_t uint32_t GError ** error
Definition: fl_pixel_buffer_texture_test.cc:40
fl_engine_send_platform_message
void fl_engine_send_platform_message(FlEngine *self, const gchar *channel, GBytes *message, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data)
Definition: fl_engine.cc:786
PlatformMessageHandler::message_handler_destroy_notify
GDestroyNotify message_handler_destroy_notify
Definition: fl_binary_messenger.cc:129
fl_binary_messenger_impl_dispose
static void fl_binary_messenger_impl_dispose(GObject *object)
Definition: fl_binary_messenger.cc:175
fl_binary_messenger_response_handle
G_MODULE_EXPORT fl_binary_messenger_response_handle
Definition: fl_binary_messenger.h:47
BINARY_MESSENGER_IMPL
BINARY_MESSENGER_IMPL
Definition: fl_binary_messenger.cc:28
callback
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
Definition: fl_key_channel_responder.cc:120
resize_channel_response_cb
static void resize_channel_response_cb(GObject *object, GAsyncResult *result, gpointer user_data)
Definition: fl_binary_messenger.cc:319
set_message_handler_on_channel
static void set_message_handler_on_channel(FlBinaryMessenger *messenger, const gchar *channel, FlBinaryMessengerMessageHandler handler, gpointer user_data, GDestroyNotify destroy_notify)
Definition: fl_binary_messenger.cc:185
fl_binary_messenger_resize_channel
G_MODULE_EXPORT void fl_binary_messenger_resize_channel(FlBinaryMessenger *self, const gchar *channel, int64_t new_size)
Definition: fl_binary_messenger.cc:467
fl_binary_messenger_send_response
G_MODULE_EXPORT gboolean fl_binary_messenger_send_response(FlBinaryMessenger *self, FlBinaryMessengerResponseHandle *response_handle, GBytes *response, GError **error)
Definition: fl_binary_messenger.cc:430
set_warns_on_channel_overflow
static void set_warns_on_channel_overflow(FlBinaryMessenger *messenger, const gchar *channel, bool warns)
Definition: fl_binary_messenger.cc:353
fl_method_codec_private.h
value
uint8_t value
Definition: fl_standard_message_codec.cc:36
fl_engine_send_platform_message_response
gboolean fl_engine_send_platform_message_response(FlEngine *self, const FlutterPlatformMessageResponseHandle *handle, GBytes *response, GError **error)
Definition: fl_engine.cc:754
fl_binary_messenger_send_on_channel
G_MODULE_EXPORT void fl_binary_messenger_send_on_channel(FlBinaryMessenger *self, const gchar *channel, GBytes *message, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data)
Definition: fl_binary_messenger.cc:443
fl_value_new_string
G_MODULE_EXPORT FlValue * fl_value_new_string(const gchar *value)
Definition: fl_value.cc:276
_FlBinaryMessengerResponseHandleImpl::response_handle
const FlutterPlatformMessageResponseHandle * response_handle
Definition: fl_binary_messenger.cc:76