| Flutter Linux Embedder |

Classes | Functions | Variables
fl_accessibility_channel.cc File Reference
`#include "flutter/shell/platform/linux/fl_accessibility_channel.h"`
`#include "flutter/shell/platform/linux/public/flutter_linux/fl_basic_message_channel.h"`
`#include "flutter/shell/platform/linux/public/flutter_linux/fl_standard_message_codec.h"`

Go to the source code of this file.

## Classes
struct | _FlAccessibilityChannel

## Functions
static FlTextDirection | parse_text_direction (int64_t value)
static FlAssertiveness | parse_assertiveness (int64_t value)
static void | process_announce (FlAccessibilityChannel *self, FlValue *data)
static void | process_message (FlAccessibilityChannel *self, FlValue *message)
static void | message_cb (FlBasicMessageChannel *channel, FlValue *message, FlBasicMessageChannelResponseHandle *response_handle, gpointer user_data)
static void | fl_accessibility_channel_dispose (GObject *object)
static void | fl_accessibility_channel_class_init (FlAccessibilityChannelClass *klass)
static void | fl_accessibility_channel_init (FlAccessibilityChannel *self)
FlAccessibilityChannel * | fl_accessibility_channel_new (FlBinaryMessenger *messenger, FlAccessibilityChannelVTable *vtable, gpointer user_data)

## Variables
static constexpr char | kChannelName [] = "flutter/accessibility"
static constexpr char | kTypeKey [] = "type"
static constexpr char | kDataKey [] = "data"
static constexpr char | kAnnounceType [] = "announce"
static constexpr char | kTooltipType [] = "tooltip"
static constexpr char | kLongPressType [] = "longPress"
static constexpr char | kTapType [] = "tap"
static constexpr char | kFocusType [] = "focus"
static constexpr char | kViewIdKey [] = "viewId"
static constexpr char | kMessageKey [] = "message"
static constexpr char | kTextDirectionKey [] = "textDirection"
static constexpr char | kAssertivenessKey [] = "assertiveness"

## Function Documentation

## ◆ fl_accessibility_channel_class_init()

static void fl_accessibility_channel_class_init | ( | FlAccessibilityChannelClass * | klass | ) |
| static

Definition at line 170 of file fl_accessibility_channel.cc.

171 {
172 G_OBJECT_CLASS(klass)->dispose = fl_accessibility_channel_dispose;
173 }
fl_accessibility_channel_dispose
static void fl_accessibility_channel_dispose(GObject *object)
Definition: fl_accessibility_channel.cc:162

References fl_accessibility_channel_dispose().

## ◆ fl_accessibility_channel_dispose()

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

Definition at line 162 of file fl_accessibility_channel.cc.

162 {
163 FlAccessibilityChannel* self = FL_ACCESSIBILITY_CHANNEL(object);
164
165 g_clear_object(&self->channel);
166
167 G_OBJECT_CLASS(fl_accessibility_channel_parent_class)->dispose(object);
168 }

Referenced by fl_accessibility_channel_class_init().

## ◆ fl_accessibility_channel_init()

static void fl_accessibility_channel_init | ( | FlAccessibilityChannel * | self | ) |
| static

Definition at line 175 of file fl_accessibility_channel.cc.

175 {}

## ◆ fl_accessibility_channel_new()

FlAccessibilityChannel* fl_accessibility_channel_new | ( | FlBinaryMessenger * | messenger,
|  | FlAccessibilityChannelVTable * | vtable,
|  | gpointer | user_data
| ) |  |

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

Creates a new channel that handles accessibility requests from Dart.

Returns: a new #FlAccessibilityChannel

Definition at line 177 of file fl_accessibility_channel.cc.

180 {
181 FlAccessibilityChannel* self = FL_ACCESSIBILITY_CHANNEL(
182 g_object_new(fl_accessibility_channel_get_type(), nullptr));
183
184 self->vtable = vtable;
185 self->user_data = user_data;
186
187 g_autoptr(FlStandardMessageCodec) codec = fl_standard_message_codec_new();
188 self->channel = fl_basic_message_channel_new(messenger, kChannelName,
189 FL_MESSAGE_CODEC(codec));
190 fl_basic_message_channel_set_message_handler(self->channel, message_cb, self,
191 nullptr);
192
193 return self;
194 }
message_cb
static void message_cb(FlBasicMessageChannel *channel, FlValue *message, FlBasicMessageChannelResponseHandle *response_handle, gpointer user_data)
Definition: fl_accessibility_channel.cc:147
kChannelName
static constexpr char kChannelName[]
Definition: fl_accessibility_channel.cc:9
g_autoptr
g_autoptr(FlEngine) engine
user_data
const char FlTextDirection FlAssertiveness gpointer user_data
Definition: fl_accessibility_handler.cc:24
fl_basic_message_channel_set_message_handler
G_MODULE_EXPORT void fl_basic_message_channel_set_message_handler(FlBasicMessageChannel *self, FlBasicMessageChannelMessageHandler handler, gpointer user_data, GDestroyNotify destroy_notify)
Definition: fl_basic_message_channel.cc:176
fl_basic_message_channel_new
G_MODULE_EXPORT FlBasicMessageChannel * fl_basic_message_channel_new(FlBinaryMessenger *messenger, const gchar *name, FlMessageCodec *codec)
Definition: fl_basic_message_channel.cc:154
fl_standard_message_codec_new
G_MODULE_EXPORT FlStandardMessageCodec * fl_standard_message_codec_new()
Definition: fl_standard_message_codec.cc:637

References fl_basic_message_channel_new(), fl_basic_message_channel_set_message_handler(), fl_standard_message_codec_new(), g_autoptr(), kChannelName, message_cb(), and user_data.

Referenced by fl_accessibility_handler_new().

## ◆ message_cb()

static void message_cb | ( | FlBasicMessageChannel * | channel,
|  | FlValue * | message,
|  | FlBasicMessageChannelResponseHandle * | response_handle,
|  | gpointer | user_data
| ) |  |
| static

Definition at line 147 of file fl_accessibility_channel.cc.

150 {
151 FlAccessibilityChannel* self = FL_ACCESSIBILITY_CHANNEL(user_data);
152
153 process_message(self, message);
154
155 g_autoptr(GError) error = nullptr;
156 if (!fl_basic_message_channel_respond(channel, response_handle, nullptr,
157 &error)) {
158 g_warning("Failed to send message response: %s", error->message);
159 }
160 }
process_message
static void process_message(FlAccessibilityChannel *self, FlValue *message)
Definition: fl_accessibility_channel.cc:106
message
const char * message
Definition: fl_accessibility_handler.cc:21
fl_basic_message_channel_respond
G_MODULE_EXPORT gboolean fl_basic_message_channel_respond(FlBasicMessageChannel *self, FlBasicMessageChannelResponseHandle *response_handle, FlValue *message, GError **error)
Definition: fl_basic_message_channel.cc:204
error
const uint8_t uint32_t uint32_t GError ** error
Definition: fl_pixel_buffer_texture_test.cc:40

References error, fl_basic_message_channel_respond(), g_autoptr(), message, process_message(), and user_data.

Referenced by fl_accessibility_channel_new().

## ◆ parse_assertiveness()

static FlAssertiveness parse_assertiveness | ( | int64_t | value | ) |
| static

Definition at line 51 of file fl_accessibility_channel.cc.

51 {
52 switch (value) {
53 case 0:
54 return FL_ASSERTIVENESS_POLITE;
55 case 1:
56 return FL_ASSERTIVENESS_ASSERTIVE;
57 default:
58 g_warning("Unknown assertiveness value %" G_GINT64_FORMAT, value);
59 return FL_ASSERTIVENESS_POLITE;
60 }
61 }
FL_ASSERTIVENESS_POLITE
@ FL_ASSERTIVENESS_POLITE
Definition: fl_accessibility_channel.h:26
FL_ASSERTIVENESS_ASSERTIVE
@ FL_ASSERTIVENESS_ASSERTIVE
Definition: fl_accessibility_channel.h:27
value
uint8_t value
Definition: fl_standard_message_codec.cc:36

References FL_ASSERTIVENESS_ASSERTIVE, FL_ASSERTIVENESS_POLITE, and value.

Referenced by process_announce().

## ◆ parse_text_direction()

static FlTextDirection parse_text_direction | ( | int64_t | value | ) |
| static

Definition at line 39 of file fl_accessibility_channel.cc.

39 {
40 switch (value) {
41 case 0:
42 return FL_TEXT_DIRECTION_RTL;
43 case 1:
44 return FL_TEXT_DIRECTION_LTR;
45 default:
46 g_warning("Unknown text direction value %" G_GINT64_FORMAT, value);
47 return FL_TEXT_DIRECTION_LTR;
48 }
49 }
FL_TEXT_DIRECTION_LTR
@ FL_TEXT_DIRECTION_LTR
Definition: fl_accessibility_channel.h:21
FL_TEXT_DIRECTION_RTL
@ FL_TEXT_DIRECTION_RTL
Definition: fl_accessibility_channel.h:20

References FL_TEXT_DIRECTION_LTR, FL_TEXT_DIRECTION_RTL, and value.

Referenced by process_announce().

## ◆ process_announce()

static void process_announce | ( | FlAccessibilityChannel * | self,
|  | FlValue * | data
| ) |  |
| static

Definition at line 63 of file fl_accessibility_channel.cc.

63 {
64 FlValue* view_id_value = fl_value_lookup_string(data, kViewIdKey);
65 if (view_id_value == nullptr ||
66 fl_value_get_type(view_id_value) != FL_VALUE_TYPE_INT) {
67 g_warning("Missing/invalid view ID in accessibility announce event");
68 return;
69 }
70 int64_t view_id = fl_value_get_int(view_id_value);
71
72 FlValue* message_value = fl_value_lookup_string(data, kMessageKey);
73 if (message_value == nullptr ||
74 fl_value_get_type(message_value) != FL_VALUE_TYPE_STRING) {
75 g_warning("Missing/invalid message in accessibility announce event");
76 return;
77 }
78 const char* message = fl_value_get_string(message_value);
79
80 FlValue* text_direction_value =
81 fl_value_lookup_string(data, kTextDirectionKey);
82 if (text_direction_value == nullptr ||
83 fl_value_get_type(text_direction_value) != FL_VALUE_TYPE_INT) {
84 g_warning("Missing/invalid text direction in accessibility announce event");
85 return;
86 }
87 FlTextDirection text_direction =
88 parse_text_direction(fl_value_get_int(text_direction_value));
89
90 FlValue* assertiveness_value =
91 fl_value_lookup_string(data, kAssertivenessKey);
92 FlAssertiveness assertiveness = FL_ASSERTIVENESS_POLITE;
93 if (assertiveness_value != nullptr) {
94 if (fl_value_get_type(assertiveness_value) != FL_VALUE_TYPE_INT) {
95 g_warning("Invalid assertiveness in accessibility announce event");
96 return;
97 }
98 assertiveness = parse_assertiveness(fl_value_get_int(assertiveness_value));
99 }
100
101 self->vtable->send_announcement(view_id, message, text_direction,
102 assertiveness, self->user_data);
103 }
kAssertivenessKey
static constexpr char kAssertivenessKey[]
Definition: fl_accessibility_channel.cc:23
kViewIdKey
static constexpr char kViewIdKey[]
Definition: fl_accessibility_channel.cc:20
parse_text_direction
static FlTextDirection parse_text_direction(int64_t value)
Definition: fl_accessibility_channel.cc:39
parse_assertiveness
static FlAssertiveness parse_assertiveness(int64_t value)
Definition: fl_accessibility_channel.cc:51
kTextDirectionKey
static constexpr char kTextDirectionKey[]
Definition: fl_accessibility_channel.cc:22
kMessageKey
static constexpr char kMessageKey[]
Definition: fl_accessibility_channel.cc:21
FlTextDirection
FlTextDirection
Definition: fl_accessibility_channel.h:19
FlAssertiveness
FlAssertiveness
Definition: fl_accessibility_channel.h:25
text_direction
const char FlTextDirection text_direction
Definition: fl_accessibility_handler.cc:22
assertiveness
const char FlTextDirection FlAssertiveness assertiveness
Definition: fl_accessibility_handler.cc:23
fl_value_lookup_string
G_MODULE_EXPORT FlValue * fl_value_lookup_string(FlValue *self, const gchar *key)
Definition: fl_value.cc:811
fl_value_get_int
G_MODULE_EXPORT int64_t fl_value_get_int(FlValue *self)
Definition: fl_value.cc:668
fl_value_get_type
G_MODULE_EXPORT FlValueType fl_value_get_type(FlValue *self)
Definition: fl_value.cc:466
fl_value_get_string
G_MODULE_EXPORT const gchar * fl_value_get_string(FlValue *self)
Definition: fl_value.cc:682
FlValue
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition: fl_value.h:42
FL_VALUE_TYPE_STRING
@ FL_VALUE_TYPE_STRING
Definition: fl_value.h:68
FL_VALUE_TYPE_INT
@ FL_VALUE_TYPE_INT
Definition: fl_value.h:66
view_id
G_BEGIN_DECLS FlutterViewId view_id
Definition: fl_view_accessible.h:49

References assertiveness, FL_ASSERTIVENESS_POLITE, fl_value_get_int(), fl_value_get_string(), fl_value_get_type(), fl_value_lookup_string(), FL_VALUE_TYPE_INT, FL_VALUE_TYPE_STRING, kAssertivenessKey, kMessageKey, kTextDirectionKey, kViewIdKey, message, parse_assertiveness(), parse_text_direction(), text_direction, and view_id.

Referenced by process_message().

## ◆ process_message()

static void process_message | ( | FlAccessibilityChannel * | self,
|  | FlValue * | message
| ) |  |
| static

Definition at line 106 of file fl_accessibility_channel.cc.

106 {
107 if (fl_value_get_type(message) != FL_VALUE_TYPE_MAP) {
108 g_warning("Got invalid accessibility event message type");
109 return;
110 }
111
112 FlValue* type_value = fl_value_lookup_string(message, kTypeKey);
113 if (type_value == nullptr) {
114 g_warning("Accessibility event missing type");
115 return;
116 }
117 if (fl_value_get_type(type_value) != FL_VALUE_TYPE_STRING) {
118 g_warning("Got invalid accessibility event type");
119 return;
120 }
121 const char* type = fl_value_get_string(type_value);
122
123 FlValue* data = fl_value_lookup_string(message, kDataKey);
124 if (data == nullptr) {
125 g_warning("Accessibility event missing data");
126 return;
127 }
128 if (fl_value_get_type(data) != FL_VALUE_TYPE_MAP) {
129 g_warning("Got invalid accessibility data type");
130 return;
131 }
132
133 if (strcmp(type, kAnnounceType) == 0) {
134 process_announce(self, data);
135 } else if (strcmp(type, kTooltipType) == 0) {
136 } else if (strcmp(type, kLongPressType) == 0) {
137 } else if (strcmp(type, kTapType) == 0) {
138 // Only used by Android
139 } else if (strcmp(type, kFocusType) == 0) {
140 // Only used by Android and iOS.
141 } else {
142 // Silently ignore unknown types.
143 }
144 }
kFocusType
static constexpr char kFocusType[]
Definition: fl_accessibility_channel.cc:18
kTapType
static constexpr char kTapType[]
Definition: fl_accessibility_channel.cc:17
kTooltipType
static constexpr char kTooltipType[]
Definition: fl_accessibility_channel.cc:15
kTypeKey
static constexpr char kTypeKey[]
Definition: fl_accessibility_channel.cc:11
process_announce
static void process_announce(FlAccessibilityChannel *self, FlValue *data)
Definition: fl_accessibility_channel.cc:63
kDataKey
static constexpr char kDataKey[]
Definition: fl_accessibility_channel.cc:12
kLongPressType
static constexpr char kLongPressType[]
Definition: fl_accessibility_channel.cc:16
kAnnounceType
static constexpr char kAnnounceType[]
Definition: fl_accessibility_channel.cc:14
type
uint8_t type
Definition: fl_standard_message_codec_test.cc:1117
FL_VALUE_TYPE_MAP
@ FL_VALUE_TYPE_MAP
Definition: fl_value.h:74

References fl_value_get_string(), fl_value_get_type(), fl_value_lookup_string(), FL_VALUE_TYPE_MAP, FL_VALUE_TYPE_STRING, kAnnounceType, kDataKey, kFocusType, kLongPressType, kTapType, kTooltipType, kTypeKey, message, process_announce(), and type.

Referenced by message_cb().

## Variable Documentation

## ◆ kAnnounceType

constexpr char kAnnounceType[] = "announce"
| static constexpr

Definition at line 14 of file fl_accessibility_channel.cc.

Referenced by process_message().

## ◆ kAssertivenessKey

constexpr char kAssertivenessKey[] = "assertiveness"
| static constexpr

Definition at line 23 of file fl_accessibility_channel.cc.

Referenced by process_announce().

## ◆ kChannelName

constexpr char kChannelName[] = "flutter/accessibility"
| static constexpr

Definition at line 9 of file fl_accessibility_channel.cc.

Referenced by fl_accessibility_channel_new().

## ◆ kDataKey

constexpr char kDataKey[] = "data"
| static constexpr

Definition at line 12 of file fl_accessibility_channel.cc.

Referenced by process_message().

## ◆ kFocusType

constexpr char kFocusType[] = "focus"
| static constexpr

Definition at line 18 of file fl_accessibility_channel.cc.

Referenced by process_message().

## ◆ kLongPressType

constexpr char kLongPressType[] = "longPress"
| static constexpr

Definition at line 16 of file fl_accessibility_channel.cc.

Referenced by process_message().

## ◆ kMessageKey

constexpr char kMessageKey[] = "message"
| static constexpr

Definition at line 21 of file fl_accessibility_channel.cc.

Referenced by process_announce().

## ◆ kTapType

constexpr char kTapType[] = "tap"
| static constexpr

Definition at line 17 of file fl_accessibility_channel.cc.

Referenced by process_message().

## ◆ kTextDirectionKey

constexpr char kTextDirectionKey[] = "textDirection"
| static constexpr

Definition at line 22 of file fl_accessibility_channel.cc.

Referenced by process_announce().

## ◆ kTooltipType

constexpr char kTooltipType[] = "tooltip"
| static constexpr

Definition at line 15 of file fl_accessibility_channel.cc.

Referenced by process_message().

## ◆ kTypeKey

constexpr char kTypeKey[] = "type"
| static constexpr

Definition at line 11 of file fl_accessibility_channel.cc.

Referenced by process_message().

## ◆ kViewIdKey

constexpr char kViewIdKey[] = "viewId"
| static constexpr

Definition at line 20 of file fl_accessibility_channel.cc.

Referenced by process_announce().