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;
73 g_return_val_if_fail (ATK_IS_COMPONENT (user_data),
74 droute_not_yet_handled_error (message));
76 dbus_error_init (&error);
77 if (!dbus_message_get_args
78 (message, &error, DBUS_TYPE_INT32, &x, DBUS_TYPE_INT32, &y,
79 DBUS_TYPE_UINT32, &coord_type, DBUS_TYPE_INVALID))
81 return droute_invalid_arguments_error (message);
84 atk_component_ref_accessible_at_point (component, x, y,
85 (AtkCoordType) coord_type);
86 return spi_object_return_reference (message, child, TRUE);
90 impl_GetExtents (DBusConnection * bus, DBusMessage * message, void *user_data)
92 AtkComponent *component = (AtkComponent *) user_data;
94 dbus_uint32_t coord_type;
95 gint ix, iy, iwidth, iheight;
97 g_return_val_if_fail (ATK_IS_COMPONENT (user_data),
98 droute_not_yet_handled_error (message));
100 dbus_error_init (&error);
101 if (!dbus_message_get_args
102 (message, &error, 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;
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 dbus_error_init (&error);
126 if (!dbus_message_get_args
127 (message, &error, DBUS_TYPE_UINT32, &coord_type, DBUS_TYPE_INVALID))
129 return droute_invalid_arguments_error (message);
131 atk_component_get_position (component, &ix, &iy, (AtkCoordType) coord_type);
134 reply = dbus_message_new_method_return (message);
137 dbus_message_append_args (reply, DBUS_TYPE_INT32, &x, DBUS_TYPE_INT32,
138 &y, DBUS_TYPE_INVALID);
144 impl_GetSize (DBusConnection * bus, DBusMessage * message, void *user_data)
146 AtkComponent *component = (AtkComponent *) user_data;
147 gint iwidth = 0, iheight = 0;
148 dbus_int32_t width, height;
151 g_return_val_if_fail (ATK_IS_COMPONENT (user_data),
152 droute_not_yet_handled_error (message));
154 atk_component_get_size (component, &iwidth, &iheight);
157 reply = dbus_message_new_method_return (message);
160 dbus_message_append_args (reply, DBUS_TYPE_INT32, &width,
161 DBUS_TYPE_INT32, &height, DBUS_TYPE_INVALID);
167 impl_GetLayer (DBusConnection * bus, DBusMessage * message, void *user_data)
169 AtkComponent *component = (AtkComponent *) user_data;
174 g_return_val_if_fail (ATK_IS_COMPONENT (user_data),
175 droute_not_yet_handled_error (message));
177 atklayer = atk_component_get_layer (component);
181 case ATK_LAYER_BACKGROUND:
182 rv = Accessibility_LAYER_BACKGROUND;
184 case ATK_LAYER_CANVAS:
185 rv = Accessibility_LAYER_CANVAS;
187 case ATK_LAYER_WIDGET:
188 rv = Accessibility_LAYER_WIDGET;
191 rv = Accessibility_LAYER_MDI;
193 case ATK_LAYER_POPUP:
194 rv = Accessibility_LAYER_POPUP;
196 case ATK_LAYER_OVERLAY:
197 rv = Accessibility_LAYER_OVERLAY;
199 case ATK_LAYER_WINDOW:
200 rv = Accessibility_LAYER_WINDOW;
203 rv = Accessibility_LAYER_INVALID;
206 reply = dbus_message_new_method_return (message);
209 dbus_message_append_args (reply, DBUS_TYPE_UINT32, &rv,
216 impl_GetMDIZOrder (DBusConnection * bus, DBusMessage * message,
219 AtkComponent *component = (AtkComponent *) user_data;
223 g_return_val_if_fail (ATK_IS_COMPONENT (user_data),
224 droute_not_yet_handled_error (message));
226 rv = atk_component_get_mdi_zorder (component);
227 reply = dbus_message_new_method_return (message);
230 dbus_message_append_args (reply, DBUS_TYPE_INT16, &rv,
237 impl_GrabFocus (DBusConnection * bus, DBusMessage * message, void *user_data)
239 AtkComponent *component = (AtkComponent *) user_data;
243 g_return_val_if_fail (ATK_IS_COMPONENT (user_data),
244 droute_not_yet_handled_error (message));
246 rv = atk_component_grab_focus (component);
247 reply = dbus_message_new_method_return (message);
250 dbus_message_append_args (reply, DBUS_TYPE_UINT32, &rv,
258 impl_registerFocusHandler (DBusConnection * bus, DBusMessage * message,
264 impl_deregisterFocusHandler (DBusConnection * bus, DBusMessage * message,
271 impl_GetAlpha (DBusConnection * bus, DBusMessage * message, void *user_data)
273 AtkComponent *component = (AtkComponent *) user_data;
277 g_return_val_if_fail (ATK_IS_COMPONENT (user_data),
278 droute_not_yet_handled_error (message));
280 rv = atk_component_get_alpha (component);
281 reply = dbus_message_new_method_return (message);
284 dbus_message_append_args (reply, DBUS_TYPE_DOUBLE, &rv,
290 static DRouteMethod methods[] = {
291 {impl_contains, "contains"},
292 {impl_GetAccessibleAtPoint, "GetAccessibleAtPoint"},
293 {impl_GetExtents, "GetExtents"},
294 {impl_GetPosition, "GetPosition"},
295 {impl_GetSize, "GetSize"},
296 {impl_GetLayer, "GetLayer"},
297 {impl_GetMDIZOrder, "GetMDIZOrder"},
298 {impl_GrabFocus, "GrabFocus"},
299 //{impl_registerFocusHandler, "registerFocusHandler"},
300 //{impl_deregisterFocusHandler, "deregisterFocusHandler"},
301 {impl_GetAlpha, "GetAlpha"},
306 spi_initialize_component (DRoutePath * path)
308 droute_path_add_interface (path,
309 SPI_DBUS_INTERFACE_COMPONENT, spi_org_a11y_atspi_Component, methods, NULL);