summaryrefslogtreecommitdiff
path: root/src/lib/elementary/a11y/elm_atspi_access_component_adaptor.c
blob: 3048bb53c85d42e681f44a7d4b497a3f71c3c00b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
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"