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>
31 #include "introspection.h"
34 impl_Contains (DBusConnection * bus, DBusMessage * message, void *user_data)
36 AtkComponent *component = (AtkComponent *) user_data;
38 dbus_uint32_t coord_type;
42 g_return_val_if_fail (ATK_IS_COMPONENT (user_data),
43 droute_not_yet_handled_error (message));
45 if (!dbus_message_get_args
46 (message, NULL, DBUS_TYPE_INT32, &x, DBUS_TYPE_INT32, &y,
47 DBUS_TYPE_UINT32, &coord_type, DBUS_TYPE_INVALID))
49 return droute_invalid_arguments_error (message);
52 atk_component_contains (component, x, y, (AtkCoordType) coord_type);
53 reply = dbus_message_new_method_return (message);
56 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &retval,
63 impl_GetAccessibleAtPoint (DBusConnection * bus, DBusMessage * message,
66 AtkComponent *component = (AtkComponent *) user_data;
68 dbus_uint32_t coord_type;
72 g_return_val_if_fail (ATK_IS_COMPONENT (user_data),
73 droute_not_yet_handled_error (message));
75 if (!dbus_message_get_args
76 (message, NULL, DBUS_TYPE_INT32, &x, DBUS_TYPE_INT32, &y,
77 DBUS_TYPE_UINT32, &coord_type, DBUS_TYPE_INVALID))
79 return droute_invalid_arguments_error (message);
82 atk_component_ref_accessible_at_point (component, x, y,
83 (AtkCoordType) coord_type);
84 reply = spi_object_return_reference (message, child);
86 g_object_unref (child);
92 impl_GetExtents (DBusConnection * bus, DBusMessage * message, void *user_data)
94 AtkComponent *component = (AtkComponent *) user_data;
95 dbus_uint32_t coord_type;
96 gint ix, iy, iwidth, iheight;
98 g_return_val_if_fail (ATK_IS_COMPONENT (user_data),
99 droute_not_yet_handled_error (message));
101 if (!dbus_message_get_args
102 (message, NULL, DBUS_TYPE_UINT32, &coord_type, DBUS_TYPE_INVALID))
104 return droute_invalid_arguments_error (message);
106 atk_component_get_extents (component, &ix, &iy, &iwidth, &iheight,
107 (AtkCoordType) coord_type);
108 return spi_dbus_return_rect (message, ix, iy, iwidth, iheight);
112 impl_GetPosition (DBusConnection * bus, DBusMessage * message,
115 AtkComponent *component = (AtkComponent *) user_data;
116 dbus_uint32_t coord_type;
121 g_return_val_if_fail (ATK_IS_COMPONENT (user_data),
122 droute_not_yet_handled_error (message));
124 if (!dbus_message_get_args
125 (message, NULL, DBUS_TYPE_UINT32, &coord_type, DBUS_TYPE_INVALID))
127 return droute_invalid_arguments_error (message);
129 atk_component_get_position (component, &ix, &iy, (AtkCoordType) coord_type);
132 reply = dbus_message_new_method_return (message);
135 dbus_message_append_args (reply, DBUS_TYPE_INT32, &x, DBUS_TYPE_INT32,
136 &y, DBUS_TYPE_INVALID);
142 impl_GetSize (DBusConnection * bus, DBusMessage * message, void *user_data)
144 AtkComponent *component = (AtkComponent *) user_data;
145 gint iwidth = 0, iheight = 0;
146 dbus_int32_t width, height;
149 g_return_val_if_fail (ATK_IS_COMPONENT (user_data),
150 droute_not_yet_handled_error (message));
152 atk_component_get_size (component, &iwidth, &iheight);
155 reply = dbus_message_new_method_return (message);
158 dbus_message_append_args (reply, DBUS_TYPE_INT32, &width,
159 DBUS_TYPE_INT32, &height, DBUS_TYPE_INVALID);
165 impl_GetLayer (DBusConnection * bus, DBusMessage * message, void *user_data)
167 AtkComponent *component = (AtkComponent *) user_data;
172 g_return_val_if_fail (ATK_IS_COMPONENT (user_data),
173 droute_not_yet_handled_error (message));
175 atklayer = atk_component_get_layer (component);
179 case ATK_LAYER_BACKGROUND:
180 rv = ATSPI_LAYER_BACKGROUND;
182 case ATK_LAYER_CANVAS:
183 rv = ATSPI_LAYER_CANVAS;
185 case ATK_LAYER_WIDGET:
186 rv = ATSPI_LAYER_WIDGET;
189 rv = ATSPI_LAYER_MDI;
191 case ATK_LAYER_POPUP:
192 rv = ATSPI_LAYER_POPUP;
194 case ATK_LAYER_OVERLAY:
195 rv = ATSPI_LAYER_OVERLAY;
197 case ATK_LAYER_WINDOW:
198 rv = ATSPI_LAYER_WINDOW;
201 rv = ATSPI_LAYER_INVALID;
204 reply = dbus_message_new_method_return (message);
207 dbus_message_append_args (reply, DBUS_TYPE_UINT32, &rv,
214 impl_GetMDIZOrder (DBusConnection * bus, DBusMessage * message,
217 AtkComponent *component = (AtkComponent *) user_data;
221 g_return_val_if_fail (ATK_IS_COMPONENT (user_data),
222 droute_not_yet_handled_error (message));
224 rv = atk_component_get_mdi_zorder (component);
225 reply = dbus_message_new_method_return (message);
228 dbus_message_append_args (reply, DBUS_TYPE_INT16, &rv,
235 impl_GrabFocus (DBusConnection * bus, DBusMessage * message, void *user_data)
237 AtkComponent *component = (AtkComponent *) user_data;
241 g_return_val_if_fail (ATK_IS_COMPONENT (user_data),
242 droute_not_yet_handled_error (message));
244 rv = atk_component_grab_focus (component);
245 reply = dbus_message_new_method_return (message);
248 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &rv,
256 impl_registerFocusHandler (DBusConnection * bus, DBusMessage * message,
262 impl_deregisterFocusHandler (DBusConnection * bus, DBusMessage * message,
269 impl_GetAlpha (DBusConnection * bus, DBusMessage * message, void *user_data)
271 AtkComponent *component = (AtkComponent *) user_data;
275 g_return_val_if_fail (ATK_IS_COMPONENT (user_data),
276 droute_not_yet_handled_error (message));
278 rv = atk_component_get_alpha (component);
279 reply = dbus_message_new_method_return (message);
282 dbus_message_append_args (reply, DBUS_TYPE_DOUBLE, &rv,
289 impl_SetExtents (DBusConnection * bus, DBusMessage * message, void *user_data)
291 AtkComponent *component = (AtkComponent *) user_data;
292 DBusMessageIter iter, iter_struct;
293 dbus_uint32_t coord_type;
294 dbus_int32_t x, y, width, height;
298 g_return_val_if_fail (ATK_IS_COMPONENT (user_data),
299 droute_not_yet_handled_error (message));
301 if (strcmp (dbus_message_get_signature (message), "(iiii)u") != 0)
303 return droute_invalid_arguments_error (message);
306 dbus_message_iter_init (message, &iter);
307 dbus_message_iter_recurse (&iter, &iter_struct);
308 dbus_message_iter_get_basic (&iter_struct, &x);
309 dbus_message_iter_next (&iter_struct);
310 dbus_message_iter_get_basic (&iter_struct, &y);
311 dbus_message_iter_next (&iter_struct);
312 dbus_message_iter_get_basic (&iter_struct, &width);
313 dbus_message_iter_next (&iter_struct);
314 dbus_message_iter_get_basic (&iter_struct, &height);
315 dbus_message_iter_next (&iter_struct);
316 dbus_message_iter_next (&iter);
317 dbus_message_iter_get_basic (&iter, &coord_type);
319 ret = atk_component_set_extents (component, x, y, width, height, coord_type);
321 reply = dbus_message_new_method_return (message);
324 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
332 impl_SetPosition (DBusConnection * bus, DBusMessage * message, void *user_data)
334 AtkComponent *component = (AtkComponent *) user_data;
335 dbus_uint32_t coord_type;
340 g_return_val_if_fail (ATK_IS_COMPONENT (user_data),
341 droute_not_yet_handled_error (message));
343 if (!dbus_message_get_args
344 (message, NULL, DBUS_TYPE_INT32, &x, DBUS_TYPE_INT32, &y,
345 DBUS_TYPE_UINT32, &coord_type, DBUS_TYPE_INVALID))
347 return droute_invalid_arguments_error (message);
350 ret = atk_component_set_position (component, x, y, coord_type);
352 reply = dbus_message_new_method_return (message);
355 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
363 impl_SetSize (DBusConnection * bus, DBusMessage * message, void *user_data)
365 AtkComponent *component = (AtkComponent *) user_data;
366 dbus_int32_t width, height;
370 g_return_val_if_fail (ATK_IS_COMPONENT (user_data),
371 droute_not_yet_handled_error (message));
373 if (!dbus_message_get_args
374 (message, NULL, DBUS_TYPE_INT32, &width, DBUS_TYPE_INT32, &height,
377 return droute_invalid_arguments_error (message);
380 ret = atk_component_set_size (component, width, height);
382 reply = dbus_message_new_method_return (message);
385 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &ret,
392 static DRouteMethod methods[] = {
393 {impl_Contains, "Contains"},
394 {impl_GetAccessibleAtPoint, "GetAccessibleAtPoint"},
395 {impl_GetExtents, "GetExtents"},
396 {impl_GetPosition, "GetPosition"},
397 {impl_GetSize, "GetSize"},
398 {impl_GetLayer, "GetLayer"},
399 {impl_GetMDIZOrder, "GetMDIZOrder"},
400 {impl_GrabFocus, "GrabFocus"},
401 //{impl_registerFocusHandler, "registerFocusHandler"},
402 //{impl_deregisterFocusHandler, "deregisterFocusHandler"},
403 {impl_GetAlpha, "GetAlpha"},
404 {impl_SetExtents, "SetExtents"},
405 {impl_SetPosition, "SetPosition"},
406 {impl_SetSize, "SetSize"},
411 spi_initialize_component (DRoutePath * path)
413 droute_path_add_interface (path,
414 ATSPI_DBUS_INTERFACE_COMPONENT, spi_org_a11y_atspi_Component, methods, NULL);