summaryrefslogtreecommitdiff
path: root/src/lib/elementary/elm_atspi_adaptor_common.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/elementary/elm_atspi_adaptor_common.c')
-rw-r--r--src/lib/elementary/elm_atspi_adaptor_common.c104
1 files changed, 104 insertions, 0 deletions
diff --git a/src/lib/elementary/elm_atspi_adaptor_common.c b/src/lib/elementary/elm_atspi_adaptor_common.c
new file mode 100644
index 0000000..a0dc2ed
--- /dev/null
+++ b/src/lib/elementary/elm_atspi_adaptor_common.c
@@ -0,0 +1,104 @@
1#ifdef HAVE_CONFIG_H
2# include "elementary_config.h"
3#endif
4
5#define EFL_ACCESS_PROTECTED
6
7#include <Elementary.h>
8#include "atspi/atspi-constants.h"
9#include "elm_priv.h"
10#include "elm_atspi_adaptor_common.h"
11
12#define ELM_ACCESS_OBJECT_PATH_PREFIX "/org/a11y/atspi/accessible/"
13#define ELM_ACCESS_OBJECT_REFERENCE_TEMPLATE ELM_ACCESS_OBJECT_PATH_PREFIX "%llu"
14#define ELM_ACCESS_OBJECT_PATH_ROOT "root"
15
16Efl_Access*
17efl_access_unmarshal(const Eldbus_Message *msg)
18{
19 return NULL;
20}
21
22void
23efl_access_marshal(Efl_Access *obj, Eldbus_Message_Iter *iter)
24{
25}
26
27static const char*
28_path_from_object(const Eo *eo)
29{
30 static char path[64];
31
32 if (!eo)
33 return ATSPI_DBUS_PATH_NULL;
34
35 if (eo == efl_access_root_get(EFL_ACCESS_MIXIN))
36 snprintf(path, sizeof(path), "%s%s", ELM_ACCESS_OBJECT_PATH_PREFIX, ELM_ACCESS_OBJECT_PATH_ROOT);
37 else
38 snprintf(path, sizeof(path), ELM_ACCESS_OBJECT_REFERENCE_TEMPLATE, (unsigned long long)(uintptr_t)eo);
39
40 return path;
41}
42
43void
44eldbus_message_iter_efl_access_reference_append(Eldbus_Message_Iter *iter, Eldbus_Connection *conn, Efl_Access *obj)
45{
46 EINA_SAFETY_ON_NULL_RETURN(iter);
47 EINA_SAFETY_ON_NULL_RETURN(conn);
48
49 Eldbus_Message_Iter *iter_struct = eldbus_message_iter_container_new(iter, 'r', NULL);
50 if (!iter_struct) return;
51
52 eldbus_message_iter_basic_append(iter_struct, 's', eldbus_connection_unique_name_get(conn));
53 eldbus_message_iter_basic_append(iter_struct, 'o', _path_from_object(obj));
54 eldbus_message_iter_container_close(iter, iter_struct);
55}
56
57void
58eldbus_message_iter_efl_access_reference_array_append(Eldbus_Message_Iter *iter, Eldbus_Connection *conn, Eina_List *obj_list)
59{
60 Eina_List *l;
61 Efl_Access *obj;
62
63 EINA_SAFETY_ON_NULL_RETURN(iter);
64 EINA_SAFETY_ON_NULL_RETURN(conn);
65
66 Eldbus_Message_Iter *iter_array = eldbus_message_iter_container_new(iter, 'a', "(so)");
67 if (!iter_array) return;
68
69 EINA_LIST_FOREACH(obj_list, l, obj)
70 eldbus_message_iter_efl_access_reference_append(iter_array, conn, obj);
71
72 eldbus_message_iter_container_close(iter, iter_array);
73}
74
75void
76eldbus_message_iter_efl_access_interfaces_append(Eldbus_Message_Iter *iter, Efl_Access *obj)
77{
78 Eldbus_Message_Iter *iter_array = eldbus_message_iter_container_new(iter, 'a', "s");
79 if (!iter_array) return;
80
81 if (efl_isa(obj, EFL_ACCESS_MIXIN))
82 {
83 eldbus_message_iter_basic_append(iter_array, 's', ATSPI_DBUS_INTERFACE_ACCESSIBLE);
84 eldbus_message_iter_basic_append(iter_array, 's', ATSPI_DBUS_INTERFACE_COLLECTION);
85 }
86 if (efl_isa(obj, EFL_ACCESS_ACTION_MIXIN))
87 eldbus_message_iter_basic_append(iter_array, 's', ATSPI_DBUS_INTERFACE_ACTION);
88 if (efl_isa(obj, ELM_ATSPI_APP_OBJECT_CLASS))
89 eldbus_message_iter_basic_append(iter_array, 's', ATSPI_DBUS_INTERFACE_APPLICATION);
90 if (efl_isa(obj, EFL_ACCESS_COMPONENT_MIXIN))
91 eldbus_message_iter_basic_append(iter_array, 's', ATSPI_DBUS_INTERFACE_COMPONENT);
92 if (efl_isa(obj, EFL_ACCESS_EDITABLE_TEXT_INTERFACE))
93 eldbus_message_iter_basic_append(iter_array, 's', ATSPI_DBUS_INTERFACE_EDITABLE_TEXT);
94 if (efl_isa(obj, EFL_ACCESS_IMAGE_MIXIN))
95 eldbus_message_iter_basic_append(iter_array, 's', ATSPI_DBUS_INTERFACE_IMAGE);
96 if (efl_isa(obj, EFL_ACCESS_SELECTION_INTERFACE))
97 eldbus_message_iter_basic_append(iter_array, 's', ATSPI_DBUS_INTERFACE_SELECTION);
98 if (efl_isa(obj, EFL_ACCESS_TEXT_INTERFACE))
99 eldbus_message_iter_basic_append(iter_array, 's', ATSPI_DBUS_INTERFACE_TEXT);
100 if (efl_isa(obj, EFL_ACCESS_VALUE_INTERFACE))
101 eldbus_message_iter_basic_append(iter_array, 's', ATSPI_DBUS_INTERFACE_VALUE);
102
103 eldbus_message_iter_container_close(iter, iter_array);
104}