summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukasz Stanislawski <lukasz.stanislawski@gmail.com>2017-12-05 18:23:33 +0100
committerLukasz Stanislawski <lukasz.stanislawski@gmail.com>2017-12-06 00:25:52 +0100
commite18d49f128c9d31f3aba3eecf63003b2c3f962c9 (patch)
tree14bdfcdee9e83f32861acb8000965a84177897c7
parent3541b1305ef8337cfee3f3b8c2b9768a8d93b944 (diff)
Implement elm_atspi_adaptordevs/stanluk/split
Summary: Change-Id: I72a39275926d1d67b610efe2bb3e5368ace858b1 Subscribers: cedric, jpeg Differential Revision: https://phab.enlightenment.org/D5590
-rw-r--r--src/Makefile_Elementary.am2
-rw-r--r--src/lib/elementary/Elementary.h1
-rw-r--r--src/lib/elementary/a11y/elm_atspi_access_component_adaptor.c155
-rw-r--r--src/lib/elementary/a11y/elm_atspi_access_component_adaptor.eo2
-rw-r--r--src/lib/elementary/a11y/elm_atspi_adaptor.c152
-rw-r--r--src/lib/elementary/a11y/elm_atspi_adaptor.eo96
6 files changed, 331 insertions, 77 deletions
diff --git a/src/Makefile_Elementary.am b/src/Makefile_Elementary.am
index e34f47353b..a07fc0f79e 100644
--- a/src/Makefile_Elementary.am
+++ b/src/Makefile_Elementary.am
@@ -731,6 +731,8 @@ lib_elementary_libelementary_la_SOURCES = \
731 lib/elementary/a11y/elm_bus_watcher.c \ 731 lib/elementary/a11y/elm_bus_watcher.c \
732 lib/elementary/a11y/elm_atspi_bus_watcher.c \ 732 lib/elementary/a11y/elm_atspi_bus_watcher.c \
733 lib/elementary/a11y/efl_access_cache.c \ 733 lib/elementary/a11y/efl_access_cache.c \
734 lib/elementary/a11y/elm_atspi_adaptor.c \
735 lib/elementary/a11y/elm_atspi_access_component_adaptor.c \
734 $(NULL) 736 $(NULL)
735 737
736 738
diff --git a/src/lib/elementary/Elementary.h b/src/lib/elementary/Elementary.h
index 6513a5d7f6..b9301d85bb 100644
--- a/src/lib/elementary/Elementary.h
+++ b/src/lib/elementary/Elementary.h
@@ -310,6 +310,7 @@ EAPI extern Elm_Version *elm_version;
310# include <a11y/elm_bus_watcher.eo.h> 310# include <a11y/elm_bus_watcher.eo.h>
311# include <a11y/elm_atspi_bus_watcher.eo.h> 311# include <a11y/elm_atspi_bus_watcher.eo.h>
312# include <a11y/efl_access_cache.eo.h> 312# include <a11y/efl_access_cache.eo.h>
313# include <a11y/elm_atspi_adaptor.eo.h>
313#endif 314#endif
314 315
315/* include deprecated calls last of all */ 316/* include deprecated calls last of all */
diff --git a/src/lib/elementary/a11y/elm_atspi_access_component_adaptor.c b/src/lib/elementary/a11y/elm_atspi_access_component_adaptor.c
new file mode 100644
index 0000000000..3048bb53c8
--- /dev/null
+++ b/src/lib/elementary/a11y/elm_atspi_access_component_adaptor.c
@@ -0,0 +1,155 @@
1#ifdef HAVE_CONFIG_H
2 #include "elementary_config.h"
3#endif
4
5#define ELM_ATSPI_ADAPTOR_PROTECTED
6#define EFL_ACCESS_COMPONENT_PROTECTED
7
8#include "atspi/atspi-constants.h"
9#include <Elementary.h>
10#include "elm_priv.h"
11#include "elm_atspi_access_component_adaptor.eo.h"
12
13typedef struct _Elm_Atspi_Access_Component_Adaptor_Data
14{
15} Elm_Atspi_Access_Component_Adaptor_Data;
16
17static Eldbus_Message*
18_handle_contains(Eo *obj, Efl_Access *access, const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbus_Message *msg)
19{
20 int x, y;
21 Eina_Bool contains = EINA_FALSE;
22 AtspiCoordType coord_type;
23 Eldbus_Message *ret;
24
25 if (!eldbus_message_arguments_get(msg, "iiu", &x, &y, &coord_type))
26 return eldbus_message_error_new(msg, "org.freedesktop.DBus.Error.InvalidArgs", "Invalid index type.");
27
28 Eina_Bool type = coord_type == ATSPI_COORD_TYPE_SCREEN ? EINA_TRUE : EINA_FALSE;
29 contains = efl_access_component_contains(access, type, x, y);
30
31 ret = eldbus_message_method_return_new(msg);
32 EINA_SAFETY_ON_NULL_RETURN_VAL(ret, NULL);
33
34 eldbus_message_arguments_append(ret, "b", contains);
35
36 return ret;
37}
38
39static Eldbus_Message*
40_handle_get_accessible_at_point(Eo *obj, Efl_Access *access, const Eldbus_Service_Interface *service EINA_UNUSED, const Eldbus_Message *msg)
41{
42 return NULL;
43}
44
45static Eldbus_Message*
46_handle_get_extents(Eo *obj, Efl_Access *access, const Eldbus_Service_Interface *service EINA_UNUSED, const Eldbus_Message *msg)
47{
48 return NULL;
49}
50
51static Eldbus_Message*
52_handle_get_size(Eo *obj, Efl_Access *access, const Eldbus_Service_Interface *service EINA_UNUSED, const Eldbus_Message *msg)
53{
54 return NULL;
55}
56
57static Eldbus_Message*
58_handle_get_layer(Eo *obj, Efl_Access *access, const Eldbus_Service_Interface *service EINA_UNUSED, const Eldbus_Message *msg)
59{
60 return NULL;
61}
62
63static Eldbus_Message*
64_handle_grab_focus(Eo *obj, Efl_Access *access, const Eldbus_Service_Interface *service EINA_UNUSED, const Eldbus_Message *msg)
65{
66 return NULL;
67}
68
69static Eldbus_Message*
70_handle_get_alpha(Eo *obj, Efl_Access *access, const Eldbus_Service_Interface *service EINA_UNUSED, const Eldbus_Message *msg)
71{
72 return NULL;
73}
74
75static Eldbus_Message*
76_handle_set_extents(Eo *obj, Efl_Access *access, const Eldbus_Service_Interface *service EINA_UNUSED, const Eldbus_Message *msg)
77{
78 return NULL;
79}
80
81static Eldbus_Message*
82_handle_set_position(Eo *obj, Efl_Access *access, const Eldbus_Service_Interface *service EINA_UNUSED, const Eldbus_Message *msg)
83{
84 return NULL;
85}
86
87static Eldbus_Message*
88_handle_set_size(Eo *obj, Efl_Access *access, const Eldbus_Service_Interface *service EINA_UNUSED, const Eldbus_Message *msg)
89{
90 return NULL;
91}
92
93static Eldbus_Message*
94_component_msg_handle(const Eldbus_Service_Interface *iface, const Eldbus_Message *msg)
95{
96 Elm_Atspi_Access_Component_Adaptor *obj = elm_atspi_adaptor_instance_get(ELM_ATSPI_ADAPTOR_CLASS, iface);
97 Efl_Access *access = elm_atspi_adaptor_object_get(obj, eldbus_message_path_get(msg));
98
99 if (!access || !efl_isa(access, EFL_ACCESS_COMPONENT_MIXIN))
100 return eldbus_message_error_new(msg, "org.freedesktop.DBus.Error.InvalidArgs", "Invalid object reference.");
101
102 const char *method = eldbus_message_member_get(msg);
103 if (!method)
104 return eldbus_message_error_new(msg, "org.freedesktop.DBus.Error.InvalidArgs", "Invalid method name.");
105
106 if (!strcmp(method, "Contains"))
107 return _handle_contains(obj, access, iface, msg);
108 else if (!strcmp(method, "GetAccessibleAtPoint"))
109 return _handle_get_accessible_at_point(obj, access, iface, msg);
110 else if (!strcmp(method, "GetExtents"))
111 return _handle_get_extents(obj, access, iface, msg);
112 else if (!strcmp(method, "GetSize"))
113 return _handle_get_size(obj, access, iface, msg);
114 else if (!strcmp(method, "GetLayer"))
115 return _handle_get_layer(obj, access, iface, msg);
116 else if (!strcmp(method, "GrabFocus"))
117 return _handle_grab_focus(obj, access, iface, msg);
118 else if (!strcmp(method, "GetAlpha"))
119 return _handle_get_alpha(obj, access, iface, msg);
120 else if (!strcmp(method, "SetExtents"))
121 return _handle_set_extents(obj, access, iface, msg);
122 else if (!strcmp(method, "SetPosition"))
123 return _handle_set_position(obj, access, iface, msg);
124 else if (!strcmp(method, "SetSize"))
125 return _handle_set_size(obj, access, iface, msg);
126
127 return eldbus_message_error_new(msg, "org.freedesktop.DBus.Error.NotSupported", "Method not supported.");
128}
129
130static const Eldbus_Method component_methods[] = {
131 { "Contains", ELDBUS_ARGS({"i", "x"}, {"i", "y"}, {"u", "coord_type"}), ELDBUS_ARGS({"b", "contains"}), _component_msg_handle, 0 },
132 { "GetAccessibleAtPoint", ELDBUS_ARGS({"i", "x"}, {"i", "y"}, {"u", "coord_type"}), ELDBUS_ARGS({"(so)", "accessible"}), _component_msg_handle, 0 },
133 { "GetExtents", ELDBUS_ARGS({"u", "coord_type"}), ELDBUS_ARGS({"(iiii)", "extents"}), _component_msg_handle, 0 },
134 { "GetPosition", ELDBUS_ARGS({"u", "coord_type"}), ELDBUS_ARGS({"i", "x"}, {"i","y"}), _component_msg_handle, 0 },
135 { "GetSize", NULL, ELDBUS_ARGS({"i", "w"}, {"i", "h"}), _component_msg_handle, 0 },
136 { "GetLayer", NULL, ELDBUS_ARGS({"u", "layer"}), _component_msg_handle, 0 },
137 { "GetMDIZOrder", NULL, ELDBUS_ARGS({"n", "MDIZOrder"}), _component_msg_handle, 0 },
138 { "GrabFocus", NULL, ELDBUS_ARGS({"b", "focus"}), _component_msg_handle, 0 },
139 { "GetAlpha", NULL, ELDBUS_ARGS({"d", "alpha"}), _component_msg_handle, 0 },
140 { "SetExtents", ELDBUS_ARGS({"i", "x"}, {"i", "y"}, {"i", "width"}, {"i", "height"}, {"u", "coord_type"}), ELDBUS_ARGS({"b", "result"}), _component_msg_handle, 0 },
141 { "SetPosition", ELDBUS_ARGS({"i", "x"}, {"i", "y"}, {"u", "coord_type"}), ELDBUS_ARGS({"b", "result"}), _component_msg_handle, 0 },
142 { "SetSize", ELDBUS_ARGS({"i", "width"}, {"i", "height"}), ELDBUS_ARGS({"b", "result"}), _component_msg_handle, 0 },
143 { NULL, NULL, NULL, NULL, 0 }
144};
145
146EOLIAN static const Eldbus_Service_Interface_Desc*
147_elm_atspi_access_component_interface_get(Eo *obj, Elm_Atspi_Access_Component_Adaptor_Data *pd)
148{
149 static const Eldbus_Service_Interface_Desc component_iface_desc = {
150 ATSPI_DBUS_INTERFACE_COMPONENT, component_methods, NULL, NULL, NULL, NULL
151 };
152 return &component_iface_desc;
153}
154
155#include "elm_atspi_access_component_adaptor.eo.c"
diff --git a/src/lib/elementary/a11y/elm_atspi_access_component_adaptor.eo b/src/lib/elementary/a11y/elm_atspi_access_component_adaptor.eo
index 0df46e2a34..051677ffe0 100644
--- a/src/lib/elementary/a11y/elm_atspi_access_component_adaptor.eo
+++ b/src/lib/elementary/a11y/elm_atspi_access_component_adaptor.eo
@@ -1,6 +1,6 @@
1class Elm.Atspi.Access.Component.Adaptor (Elm.Atspi.Adaptor) 1class Elm.Atspi.Access.Component.Adaptor (Elm.Atspi.Adaptor)
2{ 2{
3 implements 3 implements
4 { 4 {
5 Elm.Atspi.Adaptor.interface { get; } 5 Elm.Atspi.Adaptor.interface { get; }
6 } 6 }
diff --git a/src/lib/elementary/a11y/elm_atspi_adaptor.c b/src/lib/elementary/a11y/elm_atspi_adaptor.c
new file mode 100644
index 0000000000..59f55a1fe5
--- /dev/null
+++ b/src/lib/elementary/a11y/elm_atspi_adaptor.c
@@ -0,0 +1,152 @@
1#ifdef HAVE_CONFIG_H
2 #include "elementary_config.h"
3#endif
4
5#define ELM_ATSPI_ADAPTOR_PROTECTED
6
7#include <Elementary.h>
8#include "elm_priv.h"
9#include "elm_atspi_adaptor.eo.h"
10
11#define ELM_ACCESS_OBJECT_PATH_PREFIX "/org/a11y/atspi/accessible/"
12#define ELM_ACCESS_OBJECT_PATH_ROOT "root"
13
14typedef struct _Elm_Atspi_Adaptor_Data
15{
16 Efl_Access_Cache *cache;
17 Eldbus_Service_Interface *service;
18} Elm_Atspi_Adaptor_Data;
19
20EOLIAN static Eo*
21_elm_atspi_adaptor_efl_object_constructor(Eo *obj, Elm_Atspi_Adaptor_Data *pd)
22{
23 return efl_constructor(efl_super(obj, ELM_ATSPI_ADAPTOR_CLASS));
24}
25
26EOLIAN static void
27_elm_atspi_adaptor_efl_object_destructor(Eo *obj, Elm_Atspi_Adaptor_Data *pd EINA_UNUSED)
28{
29 elm_atspi_adaptor_unregister(obj);
30 efl_destructor(efl_super(obj, ELM_ATSPI_ADAPTOR_CLASS));
31}
32
33EOLIAN static Efl_Access_Cache*
34_elm_atspi_adaptor_cache_get(Eo *obj, Elm_Atspi_Adaptor_Data *pd)
35{
36 return pd->cache;
37}
38
39EOLIAN static void
40_elm_atspi_adaptor_cache_set(Eo *obj, Elm_Atspi_Adaptor_Data *pd, Efl_Access_Cache *cache)
41{
42 EINA_SAFETY_ON_NULL_RETURN(cache);
43 pd->cache = cache;
44}
45
46EOLIAN static void
47_elm_atspi_adaptor_register(Eo *obj, Elm_Atspi_Adaptor_Data *pd, Eldbus_Connection *conn, const char *path)
48{
49 EINA_SAFETY_ON_NULL_RETURN(conn);
50 EINA_SAFETY_ON_NULL_RETURN(path);
51
52 pd->service = eldbus_service_interface_fallback_register2(conn, path, elm_atspi_adaptor_interface_get(obj));
53}
54
55EOLIAN static void
56_elm_atspi_adaptor_unregister(Eo *obj, Elm_Atspi_Adaptor_Data *pd)
57{
58 if (pd->service)
59 eldbus_service_interface_unregister(pd->service);
60}
61
62EOLIAN static const Eldbus_Service_Interface_Desc2*
63_elm_atspi_adaptor_interface_get(Eo *obj, Elm_Atspi_Adaptor_Data *pd)
64{
65 return NULL;
66}
67
68static const char*
69_object_path_encode(const char *prefix, intptr_t access_ptr, Eina_Bool is_root)
70{
71#if 0
72 char buf[DBUS_MAX_PATH];
73
74 if (is_root)
75 snprintf(buf, sizeof(buf), "%s/%ld", prefix, access_ptr);
76#endif
77}
78
79static void
80_root_reference_print(char *buf, size_t buf_size)
81{
82}
83
84static void
85_object_reference_print(char *buf, size_t buf_size, const char *prefix, intptr_t obj_ptr)
86{
87}
88
89static intptr_t
90_object_reference_scan(const char *prefix, const char *path)
91{
92}
93
94static intptr_t
95_object_decode_from_path(Eo *obj, Elm_Atspi_Adaptor_Data *pd, const char *path)
96{
97 intptr_t access;
98
99#if 0
100 if (_root_path_is(path))
101 access = (intptr_t)efl_access_cache_root_get(pd->cache);
102 else
103 access = _object_reference_scan(eldbus_service_object_path_get(pd->service, );
104
105#endif
106 return access;
107}
108
109static Eina_Bool
110_root_path_is(const char *full_path)
111{
112 if (!full_path) return EINA_FALSE;
113 return strcmp(full_path, ELM_ACCESS_OBJECT_PATH_ROOT) == 0;
114}
115
116EOLIAN static Elm_Atspi_Dbus_Reference
117_elm_atspi_adaptor_reference_from_object(Eo *obj, Elm_Atspi_Adaptor_Data *pd, Efl_Access *access)
118{
119 Elm_Atspi_Dbus_Reference ref = { 0, 0 };
120
121 EINA_SAFETY_ON_NULL_RETURN_VAL(access, ref);
122 EINA_SAFETY_ON_NULL_RETURN_VAL(pd->service, ref);
123 EINA_SAFETY_ON_NULL_RETURN_VAL(pd->cache, ref);
124
125 if (!efl_access_cache_contains(pd->cache, access))
126 return ref;
127
128 ref.bus = eldbus_connection_unique_name_get(eldbus_service_connection_get(pd->service));
129 ref.path = _object_path_encode(eldbus_service_object_path_get(pd->service), (intptr_t)access, efl_access_cache_root_get(pd->cache) == access);
130
131 return ref;
132}
133
134EOLIAN static Efl_Access*
135_elm_atspi_adaptor_object_from_reference(Eo *obj, Elm_Atspi_Adaptor_Data *pd, Elm_Atspi_Dbus_Reference ref)
136{
137 EINA_SAFETY_ON_NULL_RETURN_VAL(pd->cache, NULL);
138 EINA_SAFETY_ON_NULL_RETURN_VAL(ref.bus, NULL);
139 EINA_SAFETY_ON_NULL_RETURN_VAL(ref.path, NULL);
140
141#if 0
142 if (_root_path_is(ref.path))
143 intptr_t access = _object_decode_from_path(obj, pd, ref.path);
144
145 if (efl_access_cache_contains(pd->cache, (Efl_Access*)access))
146 return (Efl_Access*)access;
147#endif
148
149 return NULL;
150}
151
152#include "elm_atspi_adaptor.eo.c"
diff --git a/src/lib/elementary/a11y/elm_atspi_adaptor.eo b/src/lib/elementary/a11y/elm_atspi_adaptor.eo
index 06849bfe4a..f8d0dfda5b 100644
--- a/src/lib/elementary/a11y/elm_atspi_adaptor.eo
+++ b/src/lib/elementary/a11y/elm_atspi_adaptor.eo
@@ -1,107 +1,51 @@
1import eldbus_types; 1import eldbus_types;
2 2
3struct Eldbus.Message;
4struct Eldbus.Message.Iter;
5struct Eldbus.Service.Interface; 3struct Eldbus.Service.Interface;
6struct Eldbus.Arg.Info; 4struct Eldbus.Message;
7 5struct Eldbus.Service.Interface.Desc2;
8struct Elm.Atspi.Dbus.Reference
9{
10 bus: string;
11 path: string;
12}
13
14function Elm.Atspi.Method
15{
16 params {
17 @in subject: Efl.Access;
18 @in msg: ptr(Eldbus.Message);
19 }
20 return: ptr(Eldbus.Message);
21};
22
23function Elm.Atspi.Property.Set
24{
25 params {
26 @in subject: Efl.Access;
27 @in property_name: string;
28 @in iter: ptr(Eldbus.Message.Iter);
29 @in request: ptr(Eldbus.Message);
30 }
31 return: ptr(Eldbus.Message);
32};
33
34function Elm.Atspi.Property.Get
35{
36 params {
37 @in subject: Efl.Access;
38 @in property_name: string;
39 @in iter: ptr(Eldbus.Message.Iter);
40 @in request: ptr(Eldbus.Message);
41 @in error: ptr(ptr(Eldbus.Message));
42 }
43 return: bool;
44};
45
46struct Elm.Atspi.Method.Desc
47{
48 name: string;
49 in: const(ptr(Eldbus.Arg.Info));
50 out: const(ptr(Eldbus.Arg.Info));
51 func: Elm.Atspi.Method;
52}
53
54struct Elm.Atspi.Property.Desc
55{
56 name: string;
57 type: string;
58 set: Elm.Atspi.Property.Set;
59 get: Elm.Atspi.Property.Get;
60}
61
62struct Elm.Atspi.Interface.Desc
63{
64 name: string;
65 methods: const(ptr(Elm.Atspi.Method.Desc));
66 properties: const(ptr(Elm.Atspi.Property.Desc));
67}
68 6
69abstract Elm.Atspi.Adaptor (Efl.Object) 7abstract Elm.Atspi.Adaptor (Efl.Object)
70{ 8{
71 [[Base class for accessibility adaptors]] 9 [[Base class for accessibility adaptors]]
72 methods { 10 methods {
73 address_from_object @protected { 11 object_get {
74 params {
75 @in obj: Efl.Access;
76 }
77 return: Elm.Atspi.Dbus.Reference;
78 }
79 object_from_address @protected {
80 params { 12 params {
81 @in obj: Elm.Atspi.Dbus.Reference; 13 @in conn: ptr(Eldbus.Connection);
14 @in path: string;
82 } 15 }
83 return: Efl.Access; 16 return: Efl.Access;
84 } 17 }
85 @property cache { 18 @property cache {
19 get {
20 }
21 set {
22 }
86 values { 23 values {
87 cache: Efl.Access.Cache; 24 cache: Efl.Access.Cache;
88 } 25 }
89 } 26 }
90 @property interface @protected { 27 @property interface @protected @pure_virtual {
91 get { 28 get @protected {
92 } 29 }
93 values { 30 values {
94 desc: const(ptr(Elm.Atspi.Interface.Desc)); 31 desc: const(ptr(Eldbus.Service.Interface.Desc2));
95 } 32 }
96 } 33 }
97 register { 34 register {
98 params { 35 params {
99 @in desc: ptr(Eldbus.Connection); 36 @in conn: ptr(Eldbus.Connection);
100 @in path_prefix: string; 37 @in path_prefix: string;
101 } 38 }
102 } 39 }
40 unregister {
41 }
42 }
43 implements {
44 Efl.Object.constructor;
45 Efl.Object.destructor;
103 } 46 }
104 constructors { 47 constructors {
105 .cache; 48 .cache;
49 .interface;
106 } 50 }
107} 51}