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_document (DBusMessage * message)
30 AtkObject *obj = spi_dbus_get_object (dbus_message_get_path (message));
33 return ATK_DOCUMENT (obj);
37 get_document_from_path (const char *path, void *user_data)
39 AtkObject *obj = spi_dbus_get_object (path);
40 if (!obj || !ATK_IS_DOCUMENT(obj))
42 return ATK_DOCUMENT (obj);
46 impl_getLocale (DBusConnection * bus, DBusMessage * message, void *user_data)
48 AtkDocument *document = get_document (message);
53 return spi_dbus_general_error (message);
54 lc = atk_document_get_locale (document);
57 reply = dbus_message_new_method_return (message);
60 dbus_message_append_args (reply, DBUS_TYPE_STRING, &lc,
67 impl_getAttributeValue (DBusConnection * bus, DBusMessage * message,
70 AtkDocument *document = get_document (message);
77 return spi_dbus_general_error (message);
78 dbus_error_init (&error);
79 if (!dbus_message_get_args
80 (message, &error, DBUS_TYPE_STRING, &attributename, DBUS_TYPE_INVALID))
82 return SPI_DBUS_RETURN_ERROR (message, &error);
84 atr = atk_document_get_attribute_value (document, attributename);
87 reply = dbus_message_new_method_return (message);
90 dbus_message_append_args (reply, DBUS_TYPE_STRING, &atr,
97 impl_getAttributes (DBusConnection * bus, DBusMessage * message,
100 AtkDocument *document = get_document (message);
102 AtkAttributeSet *attributes;
103 AtkAttribute *attr = NULL;
105 gint n_attributes = 0;
109 return spi_dbus_general_error (message);
111 attributes = atk_document_get_attributes (document);
113 n_attributes = g_slist_length (attributes);
115 retval = (char **) g_malloc (n_attributes * sizeof (char *));
117 for (i = 0; i < n_attributes; ++i)
119 attr = g_slist_nth_data (attributes, i);
120 retval[i] = g_strconcat (attr->name, ":", attr->value, NULL);
123 atk_attribute_set_free (attributes);
124 reply = dbus_message_new_method_return (message);
127 dbus_message_append_args (reply, DBUS_TYPE_ARRAY, DBUS_TYPE_STRING,
128 &retval, n_attributes, DBUS_TYPE_INVALID);
130 for (i = 0; i < n_attributes; i++)
136 static DRouteMethod methods[] = {
137 {impl_getLocale, "getLocale"},
138 {impl_getAttributeValue, "getAttributeValue"},
139 {impl_getAttributes, "getAttributes"},
144 spi_initialize_document (DRouteData * data)
146 droute_add_interface (data, "org.freedesktop.atspi.Document",
148 (DRouteGetDatumFunction) get_document_from_path,