5#include "flutter/shell/platform/linux/public/flutter_linux/fl_standard_method_codec.h"
9#include "flutter/shell/platform/linux/public/flutter_linux/fl_standard_message_codec.h"
27 fl_standard_method_codec,
28 fl_method_codec_get_type())
30static
void fl_standard_method_codec_set_property(GObject*
object,
34 FlStandardMethodCodec*
self = FL_STANDARD_METHOD_CODEC(
object);
38 g_set_object(&
self->message_codec,
39 FL_STANDARD_MESSAGE_CODEC(g_value_get_object(
value)));
42 G_OBJECT_WARN_INVALID_PROPERTY_ID(
object,
prop_id,
pspec);
51 FlStandardMethodCodec*
self = FL_STANDARD_METHOD_CODEC(
object);
55 g_value_set_object(
value,
self->message_codec);
58 G_OBJECT_WARN_INVALID_PROPERTY_ID(
object,
prop_id,
pspec);
64 FlStandardMethodCodec*
self = FL_STANDARD_METHOD_CODEC(
object);
66 g_clear_object(&
self->message_codec);
68 G_OBJECT_CLASS(fl_standard_method_codec_parent_class)->dispose(
object);
76 FlStandardMethodCodec*
self = FL_STANDARD_METHOD_CODEC(codec);
78 g_autoptr(GByteArray)
buffer = g_byte_array_new();
89 return g_byte_array_free_to_bytes(
90 static_cast<GByteArray*
>(g_steal_pointer(&
buffer)));
100 FlStandardMethodCodec*
self = FL_STANDARD_METHOD_CODEC(codec);
105 if (name_value ==
nullptr) {
110 "Method call name wrong type");
116 if (args_value ==
nullptr) {
122 "Unexpected extra data");
134 FlMethodCodec* codec,
137 FlStandardMethodCodec*
self = FL_STANDARD_METHOD_CODEC(codec);
139 g_autoptr(GByteArray)
buffer = g_byte_array_new();
147 return g_byte_array_free_to_bytes(
148 static_cast<GByteArray*
>(g_steal_pointer(&
buffer)));
153 FlMethodCodec* codec,
158 FlStandardMethodCodec*
self = FL_STANDARD_METHOD_CODEC(codec);
160 g_autoptr(GByteArray)
buffer = g_byte_array_new();
165 code_value,
error)) {
168 g_autoptr(
FlValue) message_value =
171 message_value,
error)) {
179 return g_byte_array_free_to_bytes(
180 static_cast<GByteArray*
>(g_steal_pointer(&
buffer)));
185 FlMethodCodec* codec,
188 FlStandardMethodCodec*
self = FL_STANDARD_METHOD_CODEC(codec);
190 if (g_bytes_get_size(
message) == 0) {
198 static_cast<const guint8*
>(g_bytes_get_data(
message,
nullptr));
202 g_autoptr(FlMethodResponse) response =
nullptr;
206 if (
code ==
nullptr) {
211 "Error code wrong type");
217 if (error_message ==
nullptr) {
223 "Error message wrong type");
229 if (details ==
nullptr) {
250 "Unknown envelope type %02x",
type);
256 "Unexpected extra data");
260 return FL_METHOD_RESPONSE(g_object_ref(response));
264 FlStandardMethodCodecClass* klass) {
265 G_OBJECT_CLASS(klass)->set_property = fl_standard_method_codec_set_property;
269 FL_METHOD_CODEC_CLASS(klass)->encode_method_call =
271 FL_METHOD_CODEC_CLASS(klass)->decode_method_call =
273 FL_METHOD_CODEC_CLASS(klass)->encode_success_envelope =
275 FL_METHOD_CODEC_CLASS(klass)->encode_error_envelope =
277 FL_METHOD_CODEC_CLASS(klass)->decode_response =
280 g_object_class_install_property(
283 "message-codec",
"message-codec",
"Message codec to use",
284 fl_message_codec_get_type(),
285 static_cast<GParamFlags
>(G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
286 G_PARAM_STATIC_STRINGS)));
292 g_autoptr(FlStandardMessageCodec) message_codec =
297G_MODULE_EXPORT FlStandardMethodCodec*
299 FlStandardMessageCodec* message_codec) {
300 return FL_STANDARD_METHOD_CODEC(
301 g_object_new(fl_standard_method_codec_get_type(),
"message-codec",
302 message_codec,
nullptr));
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
@ FL_MESSAGE_CODEC_ERROR_OUT_OF_DATA
@ FL_MESSAGE_CODEC_ERROR_FAILED
#define FL_MESSAGE_CODEC_ERROR
G_MODULE_EXPORT FlMethodErrorResponse * fl_method_error_response_new(const gchar *code, const gchar *message, FlValue *details)
G_MODULE_EXPORT FlMethodSuccessResponse * fl_method_success_response_new(FlValue *result)
const uint8_t uint32_t uint32_t GError ** error
G_MODULE_EXPORT gboolean fl_standard_message_codec_write_value(FlStandardMessageCodec *self, GByteArray *buffer, FlValue *value, GError **error)
G_MODULE_EXPORT FlValue * fl_standard_message_codec_read_value(FlStandardMessageCodec *self, GBytes *buffer, size_t *offset, GError **error)
G_MODULE_EXPORT FlStandardMessageCodec * fl_standard_message_codec_new()
g_byte_array_append(buffer, &type, sizeof(uint8_t))
static constexpr guint8 kEnvelopeTypeError
static void fl_standard_method_codec_dispose(GObject *object)
G_MODULE_EXPORT FlStandardMethodCodec * fl_standard_method_codec_new_with_message_codec(FlStandardMessageCodec *message_codec)
static void fl_standard_method_codec_class_init(FlStandardMethodCodecClass *klass)
static void fl_standard_method_codec_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
static FlMethodResponse * fl_standard_method_codec_decode_response(FlMethodCodec *codec, GBytes *message, GError **error)
G_MODULE_EXPORT FlStandardMethodCodec * fl_standard_method_codec_new()
static gboolean fl_standard_method_codec_decode_method_call(FlMethodCodec *codec, GBytes *message, gchar **name, FlValue **args, GError **error)
static constexpr guint8 kEnvelopeTypeSuccess
guint const GValue * value
static GBytes * fl_standard_method_codec_encode_method_call(FlMethodCodec *codec, const gchar *name, FlValue *args, GError **error)
static void fl_standard_method_codec_init(FlStandardMethodCodec *self)
guint const GValue GParamSpec * pspec
static GBytes * fl_standard_method_codec_encode_success_envelope(FlMethodCodec *codec, FlValue *result, GError **error)
G_DEFINE_TYPE(FlStandardMethodCodec, fl_standard_method_codec, fl_method_codec_get_type()) static void fl_standard_method_codec_set_property(GObject *object
static GBytes * fl_standard_method_codec_encode_error_envelope(FlMethodCodec *codec, const gchar *code, const gchar *message, FlValue *details, GError **error)
G_MODULE_EXPORT FlValue * fl_value_ref(FlValue *self)
G_MODULE_EXPORT FlValueType fl_value_get_type(FlValue *self)
G_MODULE_EXPORT FlValue * fl_value_new_string(const gchar *value)
G_MODULE_EXPORT const gchar * fl_value_get_string(FlValue *self)
typedefG_BEGIN_DECLS struct _FlValue FlValue
DEF_SWITCHES_START aot vmservice shared library name
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
FlStandardMessageCodec * message_codec
FlMethodCodec parent_instance
std::shared_ptr< const fml::Mapping > data