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.
8 * Copyright 2008, 2009 Codethink Ltd.
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Library General Public
12 * License as published by the Free Software Foundation; either
13 * version 2 of the License, or (at your option) any later version.
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Library General Public License for more details.
20 * You should have received a copy of the GNU Library General Public
21 * License along with this library; if not, write to the
22 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 * Boston, MA 02111-1307, USA.
29 #include <droute/droute.h>
32 #include "accessible-register.h"
33 #include "accessible-marshaller.h"
34 #include "spi-common/spi-dbus.h"
36 /*---------------------------------------------------------------------------*/
38 /* For use as a GHFunc */
40 append_accessible_hf (gpointer key, gpointer obj_data, gpointer iter)
42 spi_atk_append_accessible (ATK_OBJECT(obj_data), iter);
45 /* For use as a GFunc */
47 append_accessible_lf (gpointer obj_data, gpointer iter)
49 spi_atk_append_accessible (ATK_OBJECT(obj_data), iter);
52 /*---------------------------------------------------------------------------*/
55 spi_emit_cache_removal (guint ref, DBusConnection *bus)
61 message = dbus_message_new_signal ("/org/freedesktop/atspi/tree", SPI_DBUS_INTERFACE_TREE, "removeAccessible");
63 dbus_message_iter_init_append (message, &iter);
65 path = atk_dbus_ref_to_path (ref);
66 dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &path);
68 dbus_connection_send(bus, message, NULL);
72 spi_emit_cache_update (const GList *accessibles, DBusConnection *bus)
76 DBusMessageIter iter_array;
77 message = dbus_message_new_signal ("/org/freedesktop/atspi/tree", SPI_DBUS_INTERFACE_TREE, "updateAccessible");
79 dbus_message_iter_init_append (message, &iter);
80 dbus_message_iter_open_container (&iter, DBUS_TYPE_ARRAY, "(ooaoassusau)", &iter_array);
81 g_list_foreach ((GList *)accessibles, append_accessible_lf, &iter_array);
82 dbus_message_iter_close_container(&iter, &iter_array);
84 dbus_connection_send(bus, message, NULL);
88 /*---------------------------------------------------------------------------*/
91 impl_getRoot (DBusConnection *bus, DBusMessage *message, void *user_data)
93 AtkObject *root = atk_get_root();
98 return spi_dbus_general_error (message);
99 path = atk_dbus_object_to_path (root);
101 return spi_dbus_general_error (message);
102 reply = dbus_message_new_method_return (message);
103 dbus_message_append_args (reply, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID);
108 /*---------------------------------------------------------------------------*/
111 impl_getTree (DBusConnection *bus, DBusMessage *message, void *user_data)
114 DBusMessageIter iter, iter_array;
116 reply = dbus_message_new_method_return (message);
118 dbus_message_iter_init_append (reply, &iter);
119 dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "(ooaoassusau)", &iter_array);
120 atk_dbus_foreach_registered(append_accessible_hf, &iter_array);
121 dbus_message_iter_close_container(&iter, &iter_array);
125 /*---------------------------------------------------------------------------*/
127 static DRouteMethod methods[] = {
128 {impl_getRoot, "getRoot"},
129 {impl_getTree, "getTree"},
134 spi_initialize_tree (DRoutePath *path)
136 droute_path_add_interface (path,
137 SPI_DBUS_INTERFACE_TREE,
142 /*END------------------------------------------------------------------------*/