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>
29 #include "accessible-stateset.h"
31 #include "introspection.h"
35 new_socket_call_message (AtkComponent *component, const char *member)
37 char *id = g_object_get_data (G_OBJECT (component), "dbus-plug-parent");
43 g_warning ("new_socket_call_message: no id");
46 bus_parent = g_strdup (id);
47 if (bus_parent && (path_parent = g_utf8_strchr (bus_parent + 1, -1, ':')))
50 *(path_parent++) = '\0';
51 message = dbus_message_new_method_call (bus_parent, path_parent,
52 ATSPI_DBUS_INTERFACE_COMPONENT,
61 atspi_plug_component_get_extents (AtkComponent *component, gint *x, gint *y,
62 gint *width, gint *height,
63 AtkCoordType coord_type)
65 DBusMessage *message = new_socket_call_message (component, "GetExtents");
67 dbus_uint32_t coord_type_dbus = coord_type;
69 const char *signature;
70 DBusMessageIter iter, iter_struct;
73 dbus_error_init (&error);
74 dbus_message_append_args (message, DBUS_TYPE_UINT32, &coord_type_dbus, DBUS_TYPE_INVALID);
75 reply = dbus_connection_send_with_reply_and_block (spi_global_app_data->bus,
77 dbus_message_unref (message);
80 signature = dbus_message_get_signature (reply);
81 if (g_strcmp0 (signature, "(iiii)") != 0)
83 g_warning ("Got unexpected signature %s from GetExtents\n", signature);
84 dbus_message_unref (reply);
87 dbus_message_iter_init (reply, &iter);
88 dbus_message_iter_recurse (&iter, &iter_struct);
89 dbus_message_iter_get_basic (&iter_struct, &tmp);
91 dbus_message_iter_next (&iter_struct);
92 dbus_message_iter_get_basic (&iter_struct, &tmp);
94 dbus_message_iter_next (&iter_struct);
95 dbus_message_iter_get_basic (&iter_struct, &tmp);
97 dbus_message_iter_next (&iter_struct);
98 dbus_message_iter_get_basic (&iter_struct, &tmp);
100 dbus_message_unref (reply);
104 atspi_plug_component_get_position (AtkComponent *component, gint *x, gint *y,
105 AtkCoordType coord_type)
107 DBusMessage *message = new_socket_call_message (component, "GetPosition");
109 dbus_uint32_t coord_type_dbus = coord_type;
111 dbus_int32_t x_dbus, y_dbus;
113 dbus_error_init (&error);
114 dbus_message_append_args (message, DBUS_TYPE_UINT32, &coord_type_dbus, DBUS_TYPE_INVALID);
115 reply = dbus_connection_send_with_reply_and_block (spi_global_app_data->bus,
116 message, -1, &error);
117 dbus_message_unref (message);
120 if (!dbus_message_get_args (reply, NULL, DBUS_TYPE_INT32, &x_dbus,
121 DBUS_TYPE_INT32, &y_dbus, DBUS_TYPE_INVALID))
123 g_warning ("GetPosition failed: %s", error.message);
124 dbus_error_free (&error);
131 dbus_message_unref (reply);
135 atspi_plug_component_get_size (AtkComponent *component,
136 gint *width, gint *height)
138 DBusMessage *message = new_socket_call_message (component, "GetSize");
141 dbus_uint32_t width_dbus, height_dbus;
143 dbus_error_init (&error);
144 reply = dbus_connection_send_with_reply_and_block (spi_global_app_data->bus,
145 message, -1, &error);
146 dbus_message_unref (message);
149 if (!dbus_message_get_args (reply, NULL, DBUS_TYPE_INT32, &width_dbus,
150 DBUS_TYPE_INT32, &height_dbus, DBUS_TYPE_INVALID))
152 g_warning ("GetSize failed: %s", error.message);
153 dbus_error_free (&error);
158 *height = height_dbus;
160 dbus_message_unref (reply);
164 impl_Embedded (DBusConnection *bus,
165 DBusMessage *message,
168 AtkObject *object = (AtkObject *) user_data;
172 if (!dbus_message_get_args (message, NULL, DBUS_TYPE_STRING, &path, DBUS_TYPE_INVALID))
174 return droute_invalid_arguments_error (message);
176 id = g_strconcat (dbus_message_get_sender (message), ":", path, NULL);
177 g_object_set_data_full (G_OBJECT (object), "dbus-plug-parent", id, (GDestroyNotify)g_free);
179 if (ATK_IS_COMPONENT (object))
181 AtkComponent *component = ATK_COMPONENT (object);
182 AtkComponentIface *iface = ATK_COMPONENT_GET_IFACE (component);
183 iface->get_extents = atspi_plug_component_get_extents;
184 iface->get_size = atspi_plug_component_get_size;
185 iface->get_position = atspi_plug_component_get_position;
188 /* Retrieve some info about the children, if they exist, when
189 embedding the plug to ensure the a11y subtree is generated.
190 https://bugzilla.gnome.org/show_bug.cgi?id=663876 */
191 atk_object_get_n_accessible_children (object);
193 return dbus_message_new_method_return (message);
196 static DRouteMethod methods[] = {
197 {impl_Embedded, "Embedded"},
202 spi_initialize_socket (DRoutePath * path)
204 droute_path_add_interface (path,
205 ATSPI_DBUS_INTERFACE_SOCKET,
206 NULL, /* spi_org_a11y_atspi_Socket, */