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,
294 static DRouteMethod methods[] = {
295 {impl_contains, "contains"},
296 {impl_GetAccessibleAtPoint, "GetAccessibleAtPoint"},
297 {impl_GetExtents, "GetExtents"},
298 {impl_GetPosition, "GetPosition"},
299 {impl_GetSize, "GetSize"},
300 {impl_GetLayer, "GetLayer"},
301 {impl_GetMDIZOrder, "GetMDIZOrder"},
302 {impl_GrabFocus, "GrabFocus"},
303 //{impl_registerFocusHandler, "registerFocusHandler"},
304 //{impl_deregisterFocusHandler, "deregisterFocusHandler"},
305 {impl_GetAlpha, "GetAlpha"},
310 spi_initialize_component (DRoutePath * path)
312 droute_path_add_interface (path,
313 SPI_DBUS_INTERFACE_COMPONENT, spi_org_a11y_atspi_Component, methods, NULL);