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.
25 #include "accessible.h"
28 get_component (DBusMessage * message)
30 AtkObject *obj = spi_dbus_get_object (dbus_message_get_path (message));
33 return ATK_COMPONENT (obj);
37 get_component_from_path (const char *path, void *user_data)
39 AtkObject *obj = spi_dbus_get_object (path);
40 if (!obj || !ATK_IS_COMPONENT(obj))
42 return ATK_COMPONENT (obj);
46 impl_contains (DBusConnection * bus, DBusMessage * message, void *user_data)
48 AtkComponent *component = get_component (message);
50 dbus_uint32_t coord_type;
56 return spi_dbus_general_error (message);
57 dbus_error_init (&error);
58 if (!dbus_message_get_args
59 (message, &error, DBUS_TYPE_INT32, &x, DBUS_TYPE_UINT32, &y,
60 DBUS_TYPE_INT32, &coord_type, DBUS_TYPE_INVALID))
62 return SPI_DBUS_RETURN_ERROR (message, &error);
65 atk_component_contains (component, x, y, (AtkCoordType) coord_type);
66 reply = dbus_message_new_method_return (message);
69 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &retval,
76 impl_getAccessibleAtPoint (DBusConnection * bus, DBusMessage * message,
79 AtkComponent *component = get_component (message);
81 dbus_uint32_t coord_type;
86 return spi_dbus_general_error (message);
87 dbus_error_init (&error);
88 if (!dbus_message_get_args
89 (message, &error, DBUS_TYPE_INT32, &x, DBUS_TYPE_INT32, &y,
90 DBUS_TYPE_UINT32, &coord_type, DBUS_TYPE_INVALID))
92 return SPI_DBUS_RETURN_ERROR (message, &error);
95 atk_component_ref_accessible_at_point (component, x, y,
96 (AtkCoordType) coord_type);
97 return spi_dbus_return_object (message, child, TRUE);
101 impl_getExtents (DBusConnection * bus, DBusMessage * message, void *user_data)
103 AtkComponent *component = get_component (message);
105 dbus_uint32_t coord_type;
106 gint ix, iy, iwidth, iheight;
109 return spi_dbus_general_error (message);
110 dbus_error_init (&error);
111 if (!dbus_message_get_args
112 (message, &error, DBUS_TYPE_UINT32, &coord_type, DBUS_TYPE_INVALID))
114 return SPI_DBUS_RETURN_ERROR (message, &error);
116 atk_component_get_extents (component, &ix, &iy, &iwidth, &iheight,
117 (AtkCoordType) coord_type);
118 return spi_dbus_return_rect (message, ix, iy, iwidth, iheight);
122 impl_getPosition (DBusConnection * bus, DBusMessage * message,
125 AtkComponent *component = get_component (message);
127 dbus_uint32_t coord_type;
133 return spi_dbus_general_error (message);
134 dbus_error_init (&error);
135 if (!dbus_message_get_args
136 (message, &error, DBUS_TYPE_UINT32, &coord_type, DBUS_TYPE_INVALID))
138 return SPI_DBUS_RETURN_ERROR (message, &error);
140 atk_component_get_position (component, &ix, &iy, (AtkCoordType) coord_type);
143 reply = dbus_message_new_method_return (message);
146 dbus_message_append_args (reply, DBUS_TYPE_INT32, &x, DBUS_TYPE_INT32,
147 &y, DBUS_TYPE_INVALID);
153 impl_getSize (DBusConnection * bus, DBusMessage * message, void *user_data)
155 AtkComponent *component = get_component (message);
156 gint iwidth = 0, iheight = 0;
157 dbus_int32_t width, height;
161 return spi_dbus_general_error (message);
162 atk_component_get_size (component, &iwidth, &iheight);
165 reply = dbus_message_new_method_return (message);
168 dbus_message_append_args (reply, DBUS_TYPE_INT32, &width,
169 DBUS_TYPE_INT32, &height, DBUS_TYPE_INVALID);
175 impl_getLayer (DBusConnection * bus, DBusMessage * message, void *user_data)
177 AtkComponent *component = get_component (message);
183 return spi_dbus_general_error (message);
184 atklayer = atk_component_get_layer (component);
188 case ATK_LAYER_BACKGROUND:
189 rv = Accessibility_LAYER_BACKGROUND;
191 case ATK_LAYER_CANVAS:
192 rv = Accessibility_LAYER_CANVAS;
194 case ATK_LAYER_WIDGET:
195 rv = Accessibility_LAYER_WIDGET;
198 rv = Accessibility_LAYER_MDI;
200 case ATK_LAYER_POPUP:
201 rv = Accessibility_LAYER_POPUP;
203 case ATK_LAYER_OVERLAY:
204 rv = Accessibility_LAYER_OVERLAY;
206 case ATK_LAYER_WINDOW:
207 rv = Accessibility_LAYER_WINDOW;
210 rv = Accessibility_LAYER_INVALID;
213 reply = dbus_message_new_method_return (message);
216 dbus_message_append_args (reply, DBUS_TYPE_UINT32, &rv,
223 impl_getMDIZOrder (DBusConnection * bus, DBusMessage * message,
226 AtkComponent *component = get_component (message);
231 return spi_dbus_general_error (message);
232 rv = atk_component_get_mdi_zorder (component);
233 reply = dbus_message_new_method_return (message);
236 dbus_message_append_args (reply, DBUS_TYPE_UINT32, &rv,
243 impl_grabFocus (DBusConnection * bus, DBusMessage * message, void *user_data)
245 AtkComponent *component = get_component (message);
250 return spi_dbus_general_error (message);
251 rv = atk_component_grab_focus (component);
252 reply = dbus_message_new_method_return (message);
255 dbus_message_append_args (reply, DBUS_TYPE_UINT32, &rv,
263 impl_registerFocusHandler (DBusConnection * bus, DBusMessage * message,
269 impl_deregisterFocusHandler (DBusConnection * bus, DBusMessage * message,
276 impl_getAlpha (DBusConnection * bus, DBusMessage * message, void *user_data)
278 AtkComponent *component = get_component (message);
283 return spi_dbus_general_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 (DRouteData * data)
312 droute_add_interface (data, SPI_DBUS_INTERFACE_COMPONENT,
314 (DRouteGetDatumFunction) get_component_from_path,