2 * AT-SPI - Assistive Technology Service Provider Interface
3 * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
5 * Copyright 2008 Novell, Inc.
6 * Copyright 2001, 2002 Sun Microsystems Inc.,
7 * Copyright 2001, 2002 Ximian, Inc.
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public
11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Library General Public License for more details.
19 * You should have received a copy of the GNU Library General Public
20 * License along with this library; if not, write to the
21 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 * Boston, MA 02111-1307, USA.
26 #include <droute/droute.h>
28 #include "common/spi-dbus.h"
30 #include "introspection.h"
33 impl_contains (DBusConnection * bus, DBusMessage * message, void *user_data)
35 AtkComponent *component = (AtkComponent *) user_data;
37 dbus_uint32_t coord_type;
42 g_return_val_if_fail (ATK_IS_COMPONENT (user_data),
43 droute_not_yet_handled_error (message));
45 dbus_error_init (&error);
46 if (!dbus_message_get_args
47 (message, &error, DBUS_TYPE_INT32, &x, DBUS_TYPE_INT32, &y,
48 DBUS_TYPE_UINT32, &coord_type, DBUS_TYPE_INVALID))
50 return droute_invalid_arguments_error (message);
53 atk_component_contains (component, x, y, (AtkCoordType) coord_type);
54 reply = dbus_message_new_method_return (message);
57 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &retval,
64 impl_GetAccessibleAtPoint (DBusConnection * bus, DBusMessage * message,
67 AtkComponent *component = (AtkComponent *) user_data;
69 dbus_uint32_t coord_type;
74 g_return_val_if_fail (ATK_IS_COMPONENT (user_data),
75 droute_not_yet_handled_error (message));
77 dbus_error_init (&error);
78 if (!dbus_message_get_args
79 (message, &error, DBUS_TYPE_INT32, &x, DBUS_TYPE_INT32, &y,
80 DBUS_TYPE_UINT32, &coord_type, DBUS_TYPE_INVALID))
82 return droute_invalid_arguments_error (message);
85 atk_component_ref_accessible_at_point (component, x, y,
86 (AtkCoordType) coord_type);
87 reply = spi_object_return_reference (message, child);
88 g_object_unref (child);
94 impl_GetExtents (DBusConnection * bus, DBusMessage * message, void *user_data)
96 AtkComponent *component = (AtkComponent *) user_data;
98 dbus_uint32_t coord_type;
99 gint ix, iy, iwidth, iheight;
101 g_return_val_if_fail (ATK_IS_COMPONENT (user_data),
102 droute_not_yet_handled_error (message));
104 dbus_error_init (&error);
105 if (!dbus_message_get_args
106 (message, &error, DBUS_TYPE_UINT32, &coord_type, DBUS_TYPE_INVALID))
108 return droute_invalid_arguments_error (message);
110 atk_component_get_extents (component, &ix, &iy, &iwidth, &iheight,
111 (AtkCoordType) coord_type);
112 return spi_dbus_return_rect (message, ix, iy, iwidth, iheight);
116 impl_GetPosition (DBusConnection * bus, DBusMessage * message,
119 AtkComponent *component = (AtkComponent *) user_data;
121 dbus_uint32_t coord_type;
126 g_return_val_if_fail (ATK_IS_COMPONENT (user_data),
127 droute_not_yet_handled_error (message));
129 dbus_error_init (&error);
130 if (!dbus_message_get_args
131 (message, &error, DBUS_TYPE_UINT32, &coord_type, DBUS_TYPE_INVALID))
133 return droute_invalid_arguments_error (message);
135 atk_component_get_position (component, &ix, &iy, (AtkCoordType) coord_type);
138 reply = dbus_message_new_method_return (message);
141 dbus_message_append_args (reply, DBUS_TYPE_INT32, &x, DBUS_TYPE_INT32,
142 &y, DBUS_TYPE_INVALID);
148 impl_GetSize (DBusConnection * bus, DBusMessage * message, void *user_data)
150 AtkComponent *component = (AtkComponent *) user_data;
151 gint iwidth = 0, iheight = 0;
152 dbus_int32_t width, height;
155 g_return_val_if_fail (ATK_IS_COMPONENT (user_data),
156 droute_not_yet_handled_error (message));
158 atk_component_get_size (component, &iwidth, &iheight);
161 reply = dbus_message_new_method_return (message);
164 dbus_message_append_args (reply, DBUS_TYPE_INT32, &width,
165 DBUS_TYPE_INT32, &height, DBUS_TYPE_INVALID);
171 impl_GetLayer (DBusConnection * bus, DBusMessage * message, void *user_data)
173 AtkComponent *component = (AtkComponent *) user_data;
178 g_return_val_if_fail (ATK_IS_COMPONENT (user_data),
179 droute_not_yet_handled_error (message));
181 atklayer = atk_component_get_layer (component);
185 case ATK_LAYER_BACKGROUND:
186 rv = Accessibility_LAYER_BACKGROUND;
188 case ATK_LAYER_CANVAS:
189 rv = Accessibility_LAYER_CANVAS;
191 case ATK_LAYER_WIDGET:
192 rv = Accessibility_LAYER_WIDGET;
195 rv = Accessibility_LAYER_MDI;
197 case ATK_LAYER_POPUP:
198 rv = Accessibility_LAYER_POPUP;
200 case ATK_LAYER_OVERLAY:
201 rv = Accessibility_LAYER_OVERLAY;
203 case ATK_LAYER_WINDOW:
204 rv = Accessibility_LAYER_WINDOW;
207 rv = Accessibility_LAYER_INVALID;
210 reply = dbus_message_new_method_return (message);
213 dbus_message_append_args (reply, DBUS_TYPE_UINT32, &rv,
220 impl_GetMDIZOrder (DBusConnection * bus, DBusMessage * message,
223 AtkComponent *component = (AtkComponent *) user_data;
227 g_return_val_if_fail (ATK_IS_COMPONENT (user_data),
228 droute_not_yet_handled_error (message));
230 rv = atk_component_get_mdi_zorder (component);
231 reply = dbus_message_new_method_return (message);
234 dbus_message_append_args (reply, DBUS_TYPE_INT16, &rv,
241 impl_GrabFocus (DBusConnection * bus, DBusMessage * message, void *user_data)
243 AtkComponent *component = (AtkComponent *) user_data;
247 g_return_val_if_fail (ATK_IS_COMPONENT (user_data),
248 droute_not_yet_handled_error (message));
250 rv = atk_component_grab_focus (component);
251 reply = dbus_message_new_method_return (message);
254 dbus_message_append_args (reply, DBUS_TYPE_UINT32, &rv,
262 impl_registerFocusHandler (DBusConnection * bus, DBusMessage * message,
268 impl_deregisterFocusHandler (DBusConnection * bus, DBusMessage * message,
275 impl_GetAlpha (DBusConnection * bus, DBusMessage * message, void *user_data)
277 AtkComponent *component = (AtkComponent *) user_data;
281 g_return_val_if_fail (ATK_IS_COMPONENT (user_data),
282 droute_not_yet_handled_error (message));
284 rv = atk_component_get_alpha (component);
285 reply = dbus_message_new_method_return (message);
288 dbus_message_append_args (reply, DBUS_TYPE_DOUBLE, &rv,
295 impl_SetExtents (DBusConnection * bus, DBusMessage * message, void *user_data)
297 AtkComponent *component = (AtkComponent *) user_data;
298 DBusMessageIter iter, iter_struct;
299 dbus_uint32_t coord_type;
300 dbus_int32_t x, y, width, height;
304 g_return_val_if_fail (ATK_IS_COMPONENT (user_data),
305 droute_not_yet_handled_error (message));
307 if (strcmp (dbus_message_get_signature (message), "(iiii)u") != 0)
309 return droute_invalid_arguments_error (message);
312 dbus_message_iter_init (message, &iter);
313 dbus_message_iter_recurse (&iter, &iter_struct);
314 dbus_message_iter_get_basic (&iter_struct, &x);
315 dbus_message_iter_next (&iter_struct);
316 dbus_message_iter_get_basic (&iter_struct, &y);
317 dbus_message_iter_next (&iter_struct);
318 dbus_message_iter_get_basic (&iter_struct, &width);
319 dbus_message_iter_next (&iter_struct);
320 dbus_message_iter_get_basic (&iter_struct, &height);
321 dbus_message_iter_next (&iter_struct);
322 dbus_message_iter_next (&iter);
323 dbus_message_iter_get_basic (&iter, &coord_type);
325 ret = atk_component_set_extents (component, x, y, width, height, coord_type);
327 reply = dbus_message_new_method_return (message);
330 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
338 impl_SetPosition (DBusConnection * bus, DBusMessage * message, void *user_data)
340 AtkComponent *component = (AtkComponent *) user_data;
341 dbus_uint32_t coord_type;
346 g_return_val_if_fail (ATK_IS_COMPONENT (user_data),
347 droute_not_yet_handled_error (message));
349 if (!dbus_message_get_args
350 (message, NULL, DBUS_TYPE_INT32, &x, DBUS_TYPE_INT32, &y,
351 DBUS_TYPE_UINT32, &coord_type, DBUS_TYPE_INVALID))
353 return droute_invalid_arguments_error (message);
356 ret = atk_component_set_position (component, x, y, coord_type);
358 reply = dbus_message_new_method_return (message);
361 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
369 impl_SetSize (DBusConnection * bus, DBusMessage * message, void *user_data)
371 AtkComponent *component = (AtkComponent *) user_data;
372 dbus_int32_t width, height;
376 g_return_val_if_fail (ATK_IS_COMPONENT (user_data),
377 droute_not_yet_handled_error (message));
379 if (!dbus_message_get_args
380 (message, NULL, DBUS_TYPE_INT32, &width, DBUS_TYPE_INT32, &height,
383 return droute_invalid_arguments_error (message);
386 ret = atk_component_set_size (component, width, height);
388 reply = dbus_message_new_method_return (message);
391 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
398 static DRouteMethod methods[] = {
399 {impl_contains, "contains"},
400 {impl_GetAccessibleAtPoint, "GetAccessibleAtPoint"},
401 {impl_GetExtents, "GetExtents"},
402 {impl_GetPosition, "GetPosition"},
403 {impl_GetSize, "GetSize"},
404 {impl_GetLayer, "GetLayer"},
405 {impl_GetMDIZOrder, "GetMDIZOrder"},
406 {impl_GrabFocus, "GrabFocus"},
407 //{impl_registerFocusHandler, "registerFocusHandler"},
408 //{impl_deregisterFocusHandler, "deregisterFocusHandler"},
409 {impl_GetAlpha, "GetAlpha"},
410 {impl_SetExtents, "SetExtents"},
411 {impl_SetPosition, "SetPosition"},
412 {impl_SetSize, "SetSize"},
417 spi_initialize_component (DRoutePath * path)
419 droute_path_add_interface (path,
420 SPI_DBUS_INTERFACE_COMPONENT, spi_org_a11y_atspi_Component, methods, NULL);