26 fl_standard_method_codec,
27 fl_method_codec_get_type())
29 static
void fl_standard_method_codec_dispose(GObject*
object) {
30 FlStandardMethodCodec*
self = FL_STANDARD_METHOD_CODEC(
object);
32 g_clear_object(&
self->codec);
34 G_OBJECT_CLASS(fl_standard_method_codec_parent_class)->dispose(
object);
42 FlStandardMethodCodec*
self = FL_STANDARD_METHOD_CODEC(codec);
44 g_autoptr(GByteArray)
buffer = g_byte_array_new();
55 return g_byte_array_free_to_bytes(
56 static_cast<GByteArray*
>(g_steal_pointer(&
buffer)));
66 FlStandardMethodCodec*
self = FL_STANDARD_METHOD_CODEC(codec);
71 if (name_value ==
nullptr) {
76 "Method call name wrong type");
82 if (args_value ==
nullptr) {
86 if (offset != g_bytes_get_size(message)) {
88 "Unexpected extra data");
100 FlMethodCodec* codec,
103 FlStandardMethodCodec*
self = FL_STANDARD_METHOD_CODEC(codec);
105 g_autoptr(GByteArray)
buffer = g_byte_array_new();
107 g_byte_array_append(
buffer, &type, 1);
113 return g_byte_array_free_to_bytes(
114 static_cast<GByteArray*
>(g_steal_pointer(&
buffer)));
119 FlMethodCodec* codec,
121 const gchar* message,
124 FlStandardMethodCodec*
self = FL_STANDARD_METHOD_CODEC(codec);
126 g_autoptr(GByteArray)
buffer = g_byte_array_new();
128 g_byte_array_append(
buffer, &type, 1);
134 g_autoptr(
FlValue) message_value =
145 return g_byte_array_free_to_bytes(
146 static_cast<GByteArray*
>(g_steal_pointer(&
buffer)));
151 FlMethodCodec* codec,
154 FlStandardMethodCodec*
self = FL_STANDARD_METHOD_CODEC(codec);
156 if (g_bytes_get_size(message) == 0) {
164 static_cast<const guint8*
>(g_bytes_get_data(message,
nullptr));
165 guint8 type = data[0];
168 g_autoptr(FlMethodResponse) response =
nullptr;
172 if (code ==
nullptr) {
177 "Error code wrong type");
183 if (error_message ==
nullptr) {
189 "Error message wrong type");
195 if (details ==
nullptr) {
216 "Unknown envelope type %02x", type);
220 if (offset != g_bytes_get_size(message)) {
222 "Unexpected extra data");
226 return FL_METHOD_RESPONSE(g_object_ref(response));
230 FlStandardMethodCodecClass* klass) {
231 G_OBJECT_CLASS(klass)->dispose = fl_standard_method_codec_dispose;
232 FL_METHOD_CODEC_CLASS(klass)->encode_method_call =
234 FL_METHOD_CODEC_CLASS(klass)->decode_method_call =
236 FL_METHOD_CODEC_CLASS(klass)->encode_success_envelope =
238 FL_METHOD_CODEC_CLASS(klass)->encode_error_envelope =
240 FL_METHOD_CODEC_CLASS(klass)->decode_response =
249 return FL_STANDARD_METHOD_CODEC(
250 g_object_new(fl_standard_method_codec_get_type(),
nullptr));