aboutsummaryrefslogtreecommitdiffstats
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
parentelm: efl_access_cache implementation (diff)
downloadefl-devs/stanluk/split.tar.gz
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 = \
lib/elementary/a11y/elm_bus_watcher.c \
lib/elementary/a11y/elm_atspi_bus_watcher.c \
lib/elementary/a11y/efl_access_cache.c \
+ lib/elementary/a11y/elm_atspi_adaptor.c \
+ lib/elementary/a11y/elm_atspi_access_component_adaptor.c \
$(NULL)
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;
# include <a11y/elm_bus_watcher.eo.h>
# include <a11y/elm_atspi_bus_watcher.eo.h>
# include <a11y/efl_access_cache.eo.h>
+# include <a11y/elm_atspi_adaptor.eo.h>
#endif
/* 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 @@
+#ifdef HAVE_CONFIG_H
+ #include "elementary_config.h"
+#endif
+
+#define ELM_ATSPI_ADAPTOR_PROTECTED
+#define EFL_ACCESS_COMPONENT_PROTECTED
+
+#include "atspi/atspi-constants.h"
+#include <Elementary.h>
+#include "elm_priv.h"
+#include "elm_atspi_access_component_adaptor.eo.h"
+
+typedef struct _Elm_Atspi_Access_Component_Adaptor_Data
+{
+} Elm_Atspi_Access_Component_Adaptor_Data;
+
+static Eldbus_Message*
+_handle_contains(Eo *obj, Efl_Access *access, const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbus_Message *msg)
+{
+ int x, y;
+ Eina_Bool contains = EINA_FALSE;
+ AtspiCoordType coord_type;
+ Eldbus_Message *ret;
+
+ if (!eldbus_message_arguments_get(msg, "iiu", &x, &y, &coord_type))
+ return eldbus_message_error_new(msg, "org.freedesktop.DBus.Error.InvalidArgs", "Invalid index type.");
+
+ Eina_Bool type = coord_type == ATSPI_COORD_TYPE_SCREEN ? EINA_TRUE : EINA_FALSE;
+ contains = efl_access_component_contains(access, type, x, y);
+
+ ret = eldbus_message_method_return_new(msg);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(ret, NULL);
+
+ eldbus_message_arguments_append(ret, "b", contains);
+
+ return ret;
+}
+
+static Eldbus_Message*
+_handle_get_accessible_at_point(Eo *obj, Efl_Access *access, const Eldbus_Service_Interface *service EINA_UNUSED, const Eldbus_Message *msg)
+{
+ return NULL;
+}
+
+static Eldbus_Message*
+_handle_get_extents(Eo *obj, Efl_Access *access, const Eldbus_Service_Interface *service EINA_UNUSED, const Eldbus_Message *msg)
+{
+ return NULL;
+}
+
+static Eldbus_Message*
+_handle_get_size(Eo *obj, Efl_Access *access, const Eldbus_Service_Interface *service EINA_UNUSED, const Eldbus_Message *msg)
+{
+ return NULL;
+}
+
+static Eldbus_Message*
+_handle_get_layer(Eo *obj, Efl_Access *access, const Eldbus_Service_Interface *service EINA_UNUSED, const Eldbus_Message *msg)
+{
+ return NULL;
+}
+
+static Eldbus_Message*
+_handle_grab_focus(Eo *obj, Efl_Access *access, const Eldbus_Service_Interface *service EINA_UNUSED, const Eldbus_Message *msg)
+{
+ return NULL;
+}
+
+static Eldbus_Message*
+_handle_get_alpha(Eo *obj, Efl_Access *access, const Eldbus_Service_Interface *service EINA_UNUSED, const Eldbus_Message *msg)
+{
+ return NULL;
+}
+
+static Eldbus_Message*
+_handle_set_extents(Eo *obj, Efl_Access *access, const Eldbus_Service_Interface *service EINA_UNUSED, const Eldbus_Message *msg)
+{
+ return NULL;
+}
+
+static Eldbus_Message*
+_handle_set_position(Eo *obj, Efl_Access *access, const Eldbus_Service_Interface *service EINA_UNUSED, const Eldbus_Message *msg)
+{
+ return NULL;
+}
+
+static Eldbus_Message*
+_handle_set_size(Eo *obj, Efl_Access *access, const Eldbus_Service_Interface *service EINA_UNUSED, const Eldbus_Message *msg)
+{
+ return NULL;
+}
+
+static Eldbus_Message*
+_component_msg_handle(const Eldbus_Service_Interface *iface, const Eldbus_Message *msg)
+{
+ Elm_Atspi_Access_Component_Adaptor *obj = elm_atspi_adaptor_instance_get(ELM_ATSPI_ADAPTOR_CLASS, iface);
+ Efl_Access *access = elm_atspi_adaptor_object_get(obj, eldbus_message_path_get(msg));
+
+ if (!access || !efl_isa(access, EFL_ACCESS_COMPONENT_MIXIN))
+ return eldbus_message_error_new(msg, "org.freedesktop.DBus.Error.InvalidArgs", "Invalid object reference.");
+
+ const char *method = eldbus_message_member_get(msg);
+ if (!method)
+ return eldbus_message_error_new(msg, "org.freedesktop.DBus.Error.InvalidArgs", "Invalid method name.");
+
+ if (!strcmp(method, "Contains"))
+ return _handle_contains(obj, access, iface, msg);
+ else if (!strcmp(method, "GetAccessibleAtPoint"))
+ return _handle_get_accessible_at_point(obj, access, iface, msg);
+ else if (!strcmp(method, "GetExtents"))
+ return _handle_get_extents(obj, access, iface, msg);
+ else if (!strcmp(method, "GetSize"))
+ return _handle_get_size(obj, access, iface, msg);
+ else if (!strcmp(method, "GetLayer"))
+ return _handle_get_layer(obj, access, iface, msg);
+ else if (!strcmp(method, "GrabFocus"))
+ return _handle_grab_focus(obj, access, iface, msg);
+ else if (!strcmp(method, "GetAlpha"))
+ return _handle_get_alpha(obj, access, iface, msg);
+ else if (!strcmp(method, "SetExtents"))
+ return _handle_set_extents(obj, access, iface, msg);
+ else if (!strcmp(method, "SetPosition"))
+ return _handle_set_position(obj, access, iface, msg);
+ else if (!strcmp(method, "SetSize"))
+ return _handle_set_size(obj, access, iface, msg);
+
+ return eldbus_message_error_new(msg, "org.freedesktop.DBus.Error.NotSupported", "Method not supported.");
+}
+
+static const Eldbus_Method component_methods[] = {
+ { "Contains", ELDBUS_ARGS({"i", "x"}, {"i", "y"}, {"u", "coord_type"}), ELDBUS_ARGS({"b", "contains"}), _component_msg_handle, 0 },
+ { "GetAccessibleAtPoint", ELDBUS_ARGS({"i", "x"}, {"i", "y"}, {"u", "coord_type"}), ELDBUS_ARGS({"(so)", "accessible"}), _component_msg_handle, 0 },
+ { "GetExtents", ELDBUS_ARGS({"u", "coord_type"}), ELDBUS_ARGS({"(iiii)", "extents"}), _component_msg_handle, 0 },
+ { "GetPosition", ELDBUS_ARGS({"u", "coord_type"}), ELDBUS_ARGS({"i", "x"}, {"i","y"}), _component_msg_handle, 0 },
+ { "GetSize", NULL, ELDBUS_ARGS({"i", "w"}, {"i", "h"}), _component_msg_handle, 0 },
+ { "GetLayer", NULL, ELDBUS_ARGS({"u", "layer"}), _component_msg_handle, 0 },
+ { "GetMDIZOrder", NULL, ELDBUS_ARGS({"n", "MDIZOrder"}), _component_msg_handle, 0 },
+ { "GrabFocus", NULL, ELDBUS_ARGS({"b", "focus"}), _component_msg_handle, 0 },
+ { "GetAlpha", NULL, ELDBUS_ARGS({"d", "alpha"}), _component_msg_handle, 0 },
+ { "SetExtents", ELDBUS_ARGS({"i", "x"}, {"i", "y"}, {"i", "width"}, {"i", "height"}, {"u", "coord_type"}), ELDBUS_ARGS({"b", "result"}), _component_msg_handle, 0 },
+ { "SetPosition", ELDBUS_ARGS({"i", "x"}, {"i", "y"}, {"u", "coord_type"}), ELDBUS_ARGS({"b", "result"}), _component_msg_handle, 0 },
+ { "SetSize", ELDBUS_ARGS({"i", "width"}, {"i", "height"}), ELDBUS_ARGS({"b", "result"}), _component_msg_handle, 0 },
+ { NULL, NULL, NULL, NULL, 0 }
+};
+
+EOLIAN static const Eldbus_Service_Interface_Desc*
+_elm_atspi_access_component_interface_get(Eo *obj, Elm_Atspi_Access_Component_Adaptor_Data *pd)
+{
+ static const Eldbus_Service_Interface_Desc component_iface_desc = {
+ ATSPI_DBUS_INTERFACE_COMPONENT, component_methods, NULL, NULL, NULL, NULL
+ };
+ return &component_iface_desc;
+}
+
+#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 @@
class Elm.Atspi.Access.Component.Adaptor (Elm.Atspi.Adaptor)
{
- implements
+ implements
{
Elm.Atspi.Adaptor.interface { get; }
}
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 @@
+#ifdef HAVE_CONFIG_H
+ #include "elementary_config.h"
+#endif
+
+#define ELM_ATSPI_ADAPTOR_PROTECTED
+
+#include <Elementary.h>
+#include "elm_priv.h"
+#include "elm_atspi_adaptor.eo.h"
+
+#define ELM_ACCESS_OBJECT_PATH_PREFIX "/org/a11y/atspi/accessible/"
+#define ELM_ACCESS_OBJECT_PATH_ROOT "root"
+
+typedef struct _Elm_Atspi_Adaptor_Data
+{
+ Efl_Access_Cache *cache;
+ Eldbus_Service_Interface *service;
+} Elm_Atspi_Adaptor_Data;
+
+EOLIAN static Eo*
+_elm_atspi_adaptor_efl_object_constructor(Eo *obj, Elm_Atspi_Adaptor_Data *pd)
+{
+ return efl_constructor(efl_super(obj, ELM_ATSPI_ADAPTOR_CLASS));
+}
+
+EOLIAN static void
+_elm_atspi_adaptor_efl_object_destructor(Eo *obj, Elm_Atspi_Adaptor_Data *pd EINA_UNUSED)
+{
+ elm_atspi_adaptor_unregister(obj);
+ efl_destructor(efl_super(obj, ELM_ATSPI_ADAPTOR_CLASS));
+}
+
+EOLIAN static Efl_Access_Cache*
+_elm_atspi_adaptor_cache_get(Eo *obj, Elm_Atspi_Adaptor_Data *pd)
+{
+ return pd->cache;
+}
+
+EOLIAN static void
+_elm_atspi_adaptor_cache_set(Eo *obj, Elm_Atspi_Adaptor_Data *pd, Efl_Access_Cache *cache)
+{
+ EINA_SAFETY_ON_NULL_RETURN(cache);
+ pd->cache = cache;
+}
+
+EOLIAN static void
+_elm_atspi_adaptor_register(Eo *obj, Elm_Atspi_Adaptor_Data *pd, Eldbus_Connection *conn, const char *path)
+{
+ EINA_SAFETY_ON_NULL_RETURN(conn);
+ EINA_SAFETY_ON_NULL_RETURN(path);
+
+ pd->service = eldbus_service_interface_fallback_register2(conn, path, elm_atspi_adaptor_interface_get(obj));
+}
+
+EOLIAN static void
+_elm_atspi_adaptor_unregister(Eo *obj, Elm_Atspi_Adaptor_Data *pd)
+{
+ if (pd->service)
+ eldbus_service_interface_unregister(pd->service);
+}
+
+EOLIAN static const Eldbus_Service_Interface_Desc2*
+_elm_atspi_adaptor_interface_get(Eo *obj, Elm_Atspi_Adaptor_Data *pd)
+{
+ return NULL;
+}
+
+static const char*
+_object_path_encode(const char *prefix, intptr_t access_ptr, Eina_Bool is_root)
+{
+#if 0
+ char buf[DBUS_MAX_PATH];
+
+ if (is_root)
+ snprintf(buf, sizeof(buf), "%s/%ld", prefix, access_ptr);
+#endif
+}
+
+static void
+_root_reference_print(char *buf, size_t buf_size)
+{
+}
+
+static void
+_object_reference_print(char *buf, size_t buf_size, const char *prefix, intptr_t obj_ptr)
+{
+}
+
+static intptr_t
+_object_reference_scan(const char *prefix, const char *path)
+{
+}
+
+static intptr_t
+_object_decode_from_path(Eo *obj, Elm_Atspi_Adaptor_Data *pd, const char *path)
+{
+ intptr_t access;
+
+#if 0
+ if (_root_path_is(path))
+ access = (intptr_t)efl_access_cache_root_get(pd->cache);
+ else
+ access = _object_reference_scan(eldbus_service_object_path_get(pd->service, );
+
+#endif
+ return access;
+}
+
+static Eina_Bool
+_root_path_is(const char *full_path)
+{
+ if (!full_path) return EINA_FALSE;
+ return strcmp(full_path, ELM_ACCESS_OBJECT_PATH_ROOT) == 0;
+}
+
+EOLIAN static Elm_Atspi_Dbus_Reference
+_elm_atspi_adaptor_reference_from_object(Eo *obj, Elm_Atspi_Adaptor_Data *pd, Efl_Access *access)
+{
+ Elm_Atspi_Dbus_Reference ref = { 0, 0 };
+
+ EINA_SAFETY_ON_NULL_RETURN_VAL(access, ref);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(pd->service, ref);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(pd->cache, ref);
+
+ if (!efl_access_cache_contains(pd->cache, access))
+ return ref;
+
+ ref.bus = eldbus_connection_unique_name_get(eldbus_service_connection_get(pd->service));
+ ref.path = _object_path_encode(eldbus_service_object_path_get(pd->service), (intptr_t)access, efl_access_cache_root_get(pd->cache) == access);
+
+ return ref;
+}
+
+EOLIAN static Efl_Access*
+_elm_atspi_adaptor_object_from_reference(Eo *obj, Elm_Atspi_Adaptor_Data *pd, Elm_Atspi_Dbus_Reference ref)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(pd->cache, NULL);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(ref.bus, NULL);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(ref.path, NULL);
+
+#if 0
+ if (_root_path_is(ref.path))
+ intptr_t access = _object_decode_from_path(obj, pd, ref.path);
+
+ if (efl_access_cache_contains(pd->cache, (Efl_Access*)access))
+ return (Efl_Access*)access;
+#endif
+
+ return NULL;
+}
+
+#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 @@
import eldbus_types;
-struct Eldbus.Message;
-struct Eldbus.Message.Iter;
struct Eldbus.Service.Interface;
-struct Eldbus.Arg.Info;
-
-struct Elm.Atspi.Dbus.Reference
-{
- bus: string;
- path: string;
-}
-
-function Elm.Atspi.Method
-{
- params {
- @in subject: Efl.Access;
- @in msg: ptr(Eldbus.Message);
- }
- return: ptr(Eldbus.Message);
-};
-
-function Elm.Atspi.Property.Set
-{
- params {
- @in subject: Efl.Access;
- @in property_name: string;
- @in iter: ptr(Eldbus.Message.Iter);
- @in request: ptr(Eldbus.Message);
- }
- return: ptr(Eldbus.Message);
-};
-
-function Elm.Atspi.Property.Get
-{
- params {
- @in subject: Efl.Access;
- @in property_name: string;
- @in iter: ptr(Eldbus.Message.Iter);
- @in request: ptr(Eldbus.Message);
- @in error: ptr(ptr(Eldbus.Message));
- }
- return: bool;
-};
-
-struct Elm.Atspi.Method.Desc
-{
- name: string;
- in: const(ptr(Eldbus.Arg.Info));
- out: const(ptr(Eldbus.Arg.Info));
- func: Elm.Atspi.Method;
-}
-
-struct Elm.Atspi.Property.Desc
-{
- name: string;
- type: string;
- set: Elm.Atspi.Property.Set;
- get: Elm.Atspi.Property.Get;
-}
-
-struct Elm.Atspi.Interface.Desc
-{
- name: string;
- methods: const(ptr(Elm.Atspi.Method.Desc));
- properties: const(ptr(Elm.Atspi.Property.Desc));
-}
+struct Eldbus.Message;
+struct Eldbus.Service.Interface.Desc2;
abstract Elm.Atspi.Adaptor (Efl.Object)
{
[[Base class for accessibility adaptors]]
methods {
- address_from_object @protected {
- params {
- @in obj: Efl.Access;
- }
- return: Elm.Atspi.Dbus.Reference;
- }
- object_from_address @protected {
+ object_get {
params {
- @in obj: Elm.Atspi.Dbus.Reference;
+ @in conn: ptr(Eldbus.Connection);
+ @in path: string;
}
return: Efl.Access;
}
@property cache {
+ get {
+ }
+ set {
+ }
values {
cache: Efl.Access.Cache;
}
}
- @property interface @protected {
- get {
+ @property interface @protected @pure_virtual {
+ get @protected {
}
values {
- desc: const(ptr(Elm.Atspi.Interface.Desc));
+ desc: const(ptr(Eldbus.Service.Interface.Desc2));
}
}
register {
params {
- @in desc: ptr(Eldbus.Connection);
+ @in conn: ptr(Eldbus.Connection);
@in path_prefix: string;
}
}
+ unregister {
+ }
+ }
+ implements {
+ Efl.Object.constructor;
+ Efl.Object.destructor;
}
constructors {
.cache;
+ .interface;
}
}