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>
32 #include "introspection.h"
35 impl_Contains (DBusConnection * bus, DBusMessage * message, void *user_data)
37 AtkComponent *component = (AtkComponent *) user_data;
39 dbus_uint32_t coord_type;
43 g_return_val_if_fail (ATK_IS_COMPONENT (user_data),
44 droute_not_yet_handled_error (message));
46 if (!dbus_message_get_args
47 (message, NULL, 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;
73 g_return_val_if_fail (ATK_IS_COMPONENT (user_data),
74 droute_not_yet_handled_error (message));
76 if (!dbus_message_get_args
77 (message, NULL, DBUS_TYPE_INT32, &x, DBUS_TYPE_INT32, &y,
78 DBUS_TYPE_UINT32, &coord_type, DBUS_TYPE_INVALID))
80 return droute_invalid_arguments_error (message);
83 atk_component_ref_accessible_at_point (component, x, y,
84 (AtkCoordType) coord_type);
85 reply = spi_object_return_reference (message, child);
87 g_object_unref (child);
93 impl_GetExtents (DBusConnection * bus, DBusMessage * message, void *user_data)
95 AtkComponent *component = (AtkComponent *) user_data;
96 dbus_uint32_t coord_type;
97 gint ix, iy, iwidth, iheight;
99 g_return_val_if_fail (ATK_IS_COMPONENT (user_data),
100 droute_not_yet_handled_error (message));
102 if (!dbus_message_get_args
103 (message, NULL, DBUS_TYPE_UINT32, &coord_type, DBUS_TYPE_INVALID))
105 return droute_invalid_arguments_error (message);
107 atk_component_get_extents (component, &ix, &iy, &iwidth, &iheight,
108 (AtkCoordType) coord_type);
109 return spi_dbus_return_rect (message, ix, iy, iwidth, iheight);
113 impl_GetPosition (DBusConnection * bus, DBusMessage * message,
116 AtkComponent *component = (AtkComponent *) user_data;
117 dbus_uint32_t coord_type;
122 g_return_val_if_fail (ATK_IS_COMPONENT (user_data),
123 droute_not_yet_handled_error (message));
125 if (!dbus_message_get_args
126 (message, NULL, DBUS_TYPE_UINT32, &coord_type, DBUS_TYPE_INVALID))
128 return droute_invalid_arguments_error (message);
130 atk_component_get_position (component, &ix, &iy, (AtkCoordType) coord_type);
133 reply = dbus_message_new_method_return (message);
136 dbus_message_append_args (reply, DBUS_TYPE_INT32, &x, DBUS_TYPE_INT32,
137 &y, DBUS_TYPE_INVALID);
143 impl_GetSize (DBusConnection * bus, DBusMessage * message, void *user_data)
145 AtkComponent *component = (AtkComponent *) user_data;
146 gint iwidth = 0, iheight = 0;
147 dbus_int32_t width, height;
150 g_return_val_if_fail (ATK_IS_COMPONENT (user_data),
151 droute_not_yet_handled_error (message));
153 atk_component_get_size (component, &iwidth, &iheight);
156 reply = dbus_message_new_method_return (message);
159 dbus_message_append_args (reply, DBUS_TYPE_INT32, &width,
160 DBUS_TYPE_INT32, &height, DBUS_TYPE_INVALID);
166 impl_GetLayer (DBusConnection * bus, DBusMessage * message, void *user_data)
168 AtkComponent *component = (AtkComponent *) user_data;
173 g_return_val_if_fail (ATK_IS_COMPONENT (user_data),
174 droute_not_yet_handled_error (message));
176 atklayer = atk_component_get_layer (component);
180 case ATK_LAYER_BACKGROUND:
181 rv = ATSPI_LAYER_BACKGROUND;
183 case ATK_LAYER_CANVAS:
184 rv = ATSPI_LAYER_CANVAS;
186 case ATK_LAYER_WIDGET:
187 rv = ATSPI_LAYER_WIDGET;
190 rv = ATSPI_LAYER_MDI;
192 case ATK_LAYER_POPUP:
193 rv = ATSPI_LAYER_POPUP;
195 case ATK_LAYER_OVERLAY:
196 rv = ATSPI_LAYER_OVERLAY;
198 case ATK_LAYER_WINDOW:
199 rv = ATSPI_LAYER_WINDOW;
202 rv = ATSPI_LAYER_INVALID;
205 reply = dbus_message_new_method_return (message);
208 dbus_message_append_args (reply, DBUS_TYPE_UINT32, &rv,
215 impl_GetMDIZOrder (DBusConnection * bus, DBusMessage * message,
218 AtkComponent *component = (AtkComponent *) user_data;
222 g_return_val_if_fail (ATK_IS_COMPONENT (user_data),
223 droute_not_yet_handled_error (message));
225 rv = atk_component_get_mdi_zorder (component);
226 reply = dbus_message_new_method_return (message);
229 dbus_message_append_args (reply, DBUS_TYPE_INT16, &rv,
236 impl_GrabFocus (DBusConnection * bus, DBusMessage * message, void *user_data)
238 AtkComponent *component = (AtkComponent *) user_data;
242 g_return_val_if_fail (ATK_IS_COMPONENT (user_data),
243 droute_not_yet_handled_error (message));
245 rv = atk_component_grab_focus (component);
246 reply = dbus_message_new_method_return (message);
249 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &rv,
257 impl_registerFocusHandler (DBusConnection * bus, DBusMessage * message,
263 impl_deregisterFocusHandler (DBusConnection * bus, DBusMessage * message,
270 impl_GetAlpha (DBusConnection * bus, DBusMessage * message, void *user_data)
272 AtkComponent *component = (AtkComponent *) user_data;
276 g_return_val_if_fail (ATK_IS_COMPONENT (user_data),
277 droute_not_yet_handled_error (message));
279 rv = atk_component_get_alpha (component);
280 reply = dbus_message_new_method_return (message);
283 dbus_message_append_args (reply, DBUS_TYPE_DOUBLE, &rv,
290 impl_SetExtents (DBusConnection * bus, DBusMessage * message, void *user_data)
292 AtkComponent *component = (AtkComponent *) user_data;
293 DBusMessageIter iter, iter_struct;
294 dbus_uint32_t coord_type;
295 dbus_int32_t x, y, width, height;
299 g_return_val_if_fail (ATK_IS_COMPONENT (user_data),
300 droute_not_yet_handled_error (message));
302 if (strcmp (dbus_message_get_signature (message), "(iiii)u") != 0)
304 return droute_invalid_arguments_error (message);
307 dbus_message_iter_init (message, &iter);
308 dbus_message_iter_recurse (&iter, &iter_struct);
309 dbus_message_iter_get_basic (&iter_struct, &x);
310 dbus_message_iter_next (&iter_struct);
311 dbus_message_iter_get_basic (&iter_struct, &y);
312 dbus_message_iter_next (&iter_struct);
313 dbus_message_iter_get_basic (&iter_struct, &width);
314 dbus_message_iter_next (&iter_struct);
315 dbus_message_iter_get_basic (&iter_struct, &height);
316 dbus_message_iter_next (&iter_struct);
317 dbus_message_iter_next (&iter);
318 dbus_message_iter_get_basic (&iter, &coord_type);
320 ret = atk_component_set_extents (component, x, y, width, height, coord_type);
322 reply = dbus_message_new_method_return (message);
325 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
333 impl_SetPosition (DBusConnection * bus, DBusMessage * message, void *user_data)
335 AtkComponent *component = (AtkComponent *) user_data;
336 dbus_uint32_t coord_type;
341 g_return_val_if_fail (ATK_IS_COMPONENT (user_data),
342 droute_not_yet_handled_error (message));
344 if (!dbus_message_get_args
345 (message, NULL, DBUS_TYPE_INT32, &x, DBUS_TYPE_INT32, &y,
346 DBUS_TYPE_UINT32, &coord_type, DBUS_TYPE_INVALID))
348 return droute_invalid_arguments_error (message);
351 ret = atk_component_set_position (component, x, y, coord_type);
353 reply = dbus_message_new_method_return (message);
356 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
364 impl_get_ScreenExtents (DBusMessageIter * iter, void *user_data)
366 AtkComponent *component = (AtkComponent *) user_data;
367 DBusMessageIter iter_variant, iter_struct;
368 gint ix = -1, iy = -1, iwidth = -1, iheight = -1;
369 dbus_uint32_t x, y, width, height;
371 g_return_val_if_fail (ATK_IS_COMPONENT (user_data), FALSE);
373 atk_component_get_extents (component, &ix, &iy, &iwidth, &iheight, ATK_XY_SCREEN);
378 dbus_message_iter_open_container (iter, DBUS_TYPE_VARIANT, "(uuuu)",
380 dbus_message_iter_open_container (&iter_variant, DBUS_TYPE_STRUCT, NULL,
382 dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_UINT32, &x);
383 dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_UINT32, &y);
384 dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_UINT32, &width);
385 dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_UINT32, &height);
386 dbus_message_iter_close_container (&iter_variant, &iter_struct);
387 dbus_message_iter_close_container (iter, &iter_variant);
392 impl_SetSize (DBusConnection * bus, DBusMessage * message, void *user_data)
394 AtkComponent *component = (AtkComponent *) user_data;
395 dbus_int32_t width, height;
399 g_return_val_if_fail (ATK_IS_COMPONENT (user_data),
400 droute_not_yet_handled_error (message));
402 if (!dbus_message_get_args
403 (message, NULL, DBUS_TYPE_INT32, &width, DBUS_TYPE_INT32, &height,
406 return droute_invalid_arguments_error (message);
409 ret = atk_component_set_size (component, width, height);
411 reply = dbus_message_new_method_return (message);
414 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
421 static DRouteMethod methods[] = {
422 {impl_Contains, "Contains"},
423 {impl_GetAccessibleAtPoint, "GetAccessibleAtPoint"},
424 {impl_GetExtents, "GetExtents"},
425 {impl_GetPosition, "GetPosition"},
426 {impl_GetSize, "GetSize"},
427 {impl_GetLayer, "GetLayer"},
428 {impl_GetMDIZOrder, "GetMDIZOrder"},
429 {impl_GrabFocus, "GrabFocus"},
430 //{impl_registerFocusHandler, "registerFocusHandler"},
431 //{impl_deregisterFocusHandler, "deregisterFocusHandler"},
432 {impl_GetAlpha, "GetAlpha"},
433 {impl_SetExtents, "SetExtents"},
434 {impl_SetPosition, "SetPosition"},
435 {impl_SetSize, "SetSize"},
439 static DRouteProperty properties[] = {
440 {impl_get_ScreenExtents, NULL, "ScreenExtents"},
444 spi_initialize_component (DRoutePath * path)
446 spi_atk_add_interface (path,
447 ATSPI_DBUS_INTERFACE_COMPONENT, spi_org_a11y_atspi_Component, methods, properties);