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"
32 impl_contains (DBusConnection * bus, DBusMessage * message, void *user_data)
34 AtkComponent *component = (AtkComponent *) user_data;
36 dbus_uint32_t coord_type;
41 g_return_val_if_fail (ATK_IS_COMPONENT (user_data),
42 droute_not_yet_handled_error (message));
44 dbus_error_init (&error);
45 if (!dbus_message_get_args
46 (message, &error, 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 dbus_error_init (&error);
76 if (!dbus_message_get_args
77 (message, &error, 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 return spi_object_return_reference (message, child);
89 impl_GetExtents (DBusConnection * bus, DBusMessage * message, void *user_data)
91 AtkComponent *component = (AtkComponent *) user_data;
93 dbus_uint32_t coord_type;
94 gint ix, iy, iwidth, iheight;
96 g_return_val_if_fail (ATK_IS_COMPONENT (user_data),
97 droute_not_yet_handled_error (message));
99 dbus_error_init (&error);
100 if (!dbus_message_get_args
101 (message, &error, DBUS_TYPE_UINT32, &coord_type, DBUS_TYPE_INVALID))
103 return droute_invalid_arguments_error (message);
105 atk_component_get_extents (component, &ix, &iy, &iwidth, &iheight,
106 (AtkCoordType) coord_type);
107 return spi_dbus_return_rect (message, ix, iy, iwidth, iheight);
111 impl_GetPosition (DBusConnection * bus, DBusMessage * message,
114 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 dbus_error_init (&error);
125 if (!dbus_message_get_args
126 (message, &error, 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 = Accessibility_LAYER_BACKGROUND;
183 case ATK_LAYER_CANVAS:
184 rv = Accessibility_LAYER_CANVAS;
186 case ATK_LAYER_WIDGET:
187 rv = Accessibility_LAYER_WIDGET;
190 rv = Accessibility_LAYER_MDI;
192 case ATK_LAYER_POPUP:
193 rv = Accessibility_LAYER_POPUP;
195 case ATK_LAYER_OVERLAY:
196 rv = Accessibility_LAYER_OVERLAY;
198 case ATK_LAYER_WINDOW:
199 rv = Accessibility_LAYER_WINDOW;
202 rv = Accessibility_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_UINT32, &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,
289 static DRouteMethod methods[] = {
290 {impl_contains, "contains"},
291 {impl_GetAccessibleAtPoint, "GetAccessibleAtPoint"},
292 {impl_GetExtents, "GetExtents"},
293 {impl_GetPosition, "GetPosition"},
294 {impl_GetSize, "GetSize"},
295 {impl_GetLayer, "GetLayer"},
296 {impl_GetMDIZOrder, "GetMDIZOrder"},
297 {impl_GrabFocus, "GrabFocus"},
298 //{impl_registerFocusHandler, "registerFocusHandler"},
299 //{impl_deregisterFocusHandler, "deregisterFocusHandler"},
300 {impl_GetAlpha, "GetAlpha"},
305 spi_initialize_component (DRoutePath * path)
307 droute_path_add_interface (path,
308 SPI_DBUS_INTERFACE_COMPONENT, methods, NULL);