2 * AT-SPI - Assistive Technology Service Provider Interface
3 * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
5 * Copyright 2008, 2009 Codethink Ltd.
6 * Copyright 2001, 2002, 2003 Sun Microsystems Inc.,
7 * Copyright 2001, 2002, 2003 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.
36 #include <droute/droute.h>
37 #include <atspi/atspi.h>
38 #include <atk-bridge.h>
44 #include "accessible-stateset.h"
46 #include "accessible-register.h"
47 #include "accessible-leasing.h"
48 #include "accessible-cache.h"
52 /*---------------------------------------------------------------------------*/
54 static DBusHandlerResult
55 signal_filter (DBusConnection *bus, DBusMessage *message, void *user_data);
57 SpiBridge *spi_global_app_data = NULL;
59 static gboolean inited = FALSE;
61 /*---------------------------------------------------------------------------*/
64 add_event (const char *bus_name, const char *event)
69 spi_atk_add_client (bus_name);
70 evdata = (event_data *) g_malloc (sizeof (*evdata));
73 data = g_strsplit (event, ":", 3);
79 evdata->bus_name = g_strdup (bus_name);
81 spi_global_app_data->events = g_list_append (spi_global_app_data->events, evdata);
84 static GSList *clients = NULL;
89 static int replies_received = 0;
92 if (replies_received == 3)
95 spi_atk_deregister_event_listeners ();
96 spi_global_app_data->events_initialized = TRUE;
101 get_events_reply (DBusPendingCall *pending, void *user_data)
103 DBusMessage *reply = dbus_pending_call_steal_reply (pending);
104 DBusMessageIter iter, iter_array, iter_struct;
109 if (strcmp (dbus_message_get_signature (reply), "a(ss)") != 0)
111 g_warning ("atk-bridge: GetRegisteredEvents returned message with unknown signature");
115 dbus_message_iter_init (reply, &iter);
116 dbus_message_iter_recurse (&iter, &iter_array);
117 while (dbus_message_iter_get_arg_type (&iter_array) != DBUS_TYPE_INVALID)
119 char *bus_name, *event;
120 dbus_message_iter_recurse (&iter_array, &iter_struct);
121 dbus_message_iter_get_basic (&iter_struct, &bus_name);
122 dbus_message_iter_next (&iter_struct);
123 dbus_message_iter_get_basic (&iter_struct, &event);
124 add_event (bus_name, event);
125 dbus_message_iter_next (&iter_array);
130 dbus_message_unref (reply);
132 dbus_pending_call_unref (pending);
134 tally_event_reply ();
138 get_device_events_reply (DBusPendingCall *pending, void *user_data)
140 DBusMessage *reply = dbus_pending_call_steal_reply (pending);
141 DBusMessageIter iter, iter_array, iter_struct;
146 if (strncmp (dbus_message_get_signature (reply), "a(s", 3) != 0)
148 g_warning ("atk-bridge: get_device_events_reply: unknown signature");
152 dbus_message_iter_init (reply, &iter);
153 dbus_message_iter_recurse (&iter, &iter_array);
154 while (dbus_message_iter_get_arg_type (&iter_array) != DBUS_TYPE_INVALID)
157 dbus_message_iter_recurse (&iter_array, &iter_struct);
158 dbus_message_iter_get_basic (&iter_struct, &bus_name);
159 spi_atk_add_client (bus_name);
160 dbus_message_iter_next (&iter_array);
165 dbus_message_unref (reply);
167 dbus_pending_call_unref (pending);
169 tally_event_reply ();
173 get_registered_event_listeners (SpiBridge *app)
175 DBusMessage *message;
176 DBusPendingCall *pending = NULL;
178 message = dbus_message_new_method_call (SPI_DBUS_NAME_REGISTRY,
179 ATSPI_DBUS_PATH_REGISTRY,
180 ATSPI_DBUS_INTERFACE_REGISTRY,
181 "GetRegisteredEvents");
185 dbus_connection_send_with_reply (app->bus, message, &pending, -1);
186 dbus_message_unref (message);
189 spi_global_app_data->events_initialized = TRUE;
192 dbus_pending_call_set_notify (pending, get_events_reply, NULL, NULL);
194 message = dbus_message_new_method_call (SPI_DBUS_NAME_REGISTRY,
196 ATSPI_DBUS_INTERFACE_DEC,
197 "GetKeystrokeListeners");
201 dbus_connection_send_with_reply (app->bus, message, &pending, -1);
202 dbus_message_unref (message);
205 spi_global_app_data->events_initialized = TRUE;
208 dbus_pending_call_set_notify (pending, get_device_events_reply, NULL, NULL);
210 message = dbus_message_new_method_call (SPI_DBUS_NAME_REGISTRY,
212 ATSPI_DBUS_INTERFACE_DEC,
213 "GetDeviceEventListeners");
217 dbus_connection_send_with_reply (app->bus, message, &pending, -1);
218 dbus_message_unref (message);
221 spi_global_app_data->events_initialized = TRUE;
224 dbus_pending_call_set_notify (pending, get_device_events_reply, NULL, NULL);
228 register_reply (DBusPendingCall *pending, void *user_data)
231 SpiBridge *app = user_data;
233 reply = dbus_pending_call_steal_reply (pending);
234 dbus_pending_call_unref (pending);
237 gchar *app_name, *obj_path;
239 if (strcmp (dbus_message_get_signature (reply), "(so)") != 0)
241 g_warning ("AT-SPI: Could not obtain desktop path or name\n");
245 DBusMessageIter iter, iter_struct;
246 dbus_message_iter_init (reply, &iter);
247 dbus_message_iter_recurse (&iter, &iter_struct);
248 dbus_message_iter_get_basic (&iter_struct, &app_name);
249 dbus_message_iter_next (&iter_struct);
250 dbus_message_iter_get_basic (&iter_struct, &obj_path);
252 app->desktop_name = g_strdup (app_name);
253 app->desktop_path = g_strdup (obj_path);
258 g_warning ("AT-SPI: Could not embed inside desktop");
261 dbus_message_unref (reply);
263 get_registered_event_listeners (spi_global_app_data);
267 register_application (SpiBridge * app)
269 DBusMessage *message;
270 DBusMessageIter iter;
272 DBusPendingCall *pending;
274 dbus_error_init (&error);
276 /* These will be overridden when we get a reply, but in practice these
277 defaults should always be correct */
278 app->desktop_name = ATSPI_DBUS_NAME_REGISTRY;
279 app->desktop_path = ATSPI_DBUS_PATH_ROOT;
281 message = dbus_message_new_method_call (SPI_DBUS_NAME_REGISTRY,
282 ATSPI_DBUS_PATH_ROOT,
283 ATSPI_DBUS_INTERFACE_SOCKET,
286 dbus_message_iter_init_append (message, &iter);
287 spi_object_append_reference (&iter, app->root);
289 if (!dbus_connection_send_with_reply (app->bus, message, &pending, -1)
295 dbus_pending_call_set_notify (pending, register_reply, app, NULL);
298 dbus_message_unref (message);
303 /*---------------------------------------------------------------------------*/
306 deregister_application (SpiBridge * app)
308 DBusMessage *message;
309 DBusMessageIter iter;
313 dbus_error_init (&error);
315 message = dbus_message_new_method_call (SPI_DBUS_NAME_REGISTRY,
316 ATSPI_DBUS_PATH_REGISTRY,
317 ATSPI_DBUS_INTERFACE_REGISTRY,
318 "DeregisterApplication");
319 dbus_message_set_no_reply (message, TRUE);
321 uname = dbus_bus_get_unique_name (app->bus);
323 dbus_message_iter_init_append (message, &iter);
324 dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &uname);
325 dbus_connection_send (app->bus, message, NULL);
327 dbus_message_unref (message);
329 if (app->app_bus_addr)
331 unlink (app->app_bus_addr);
332 g_free (app->app_bus_addr);
333 app->app_bus_addr = NULL;
336 if (app->app_tmp_dir)
338 rmdir (app->app_tmp_dir);
339 g_free (app->app_tmp_dir);
340 app->app_tmp_dir = NULL;
344 /*---------------------------------------------------------------------------*/
346 /*---------------------------------------------------------------------------*/
348 static AtkPlugClass *plug_class;
349 static AtkSocketClass *socket_class;
352 get_plug_id (AtkPlug * plug)
354 const char *uname = dbus_bus_get_unique_name (spi_global_app_data->bus);
356 GString *str = g_string_new (NULL);
358 path = spi_register_object_to_path (spi_global_register, G_OBJECT (plug));
359 g_string_printf (str, "%s:%s", uname, path);
361 return g_string_free (str, FALSE);
365 socket_ref_state_set (AtkObject *accessible)
367 char *child_name, *child_path;
368 AtkSocket *socket = ATK_SOCKET (accessible);
372 DBusMessage *message, *reply;
373 DBusMessageIter iter, iter_array;
376 set = atk_state_set_new ();
378 if (!socket->embedded_plug_id)
381 child_name = g_strdup (socket->embedded_plug_id);
384 child_path = g_utf8_strchr (child_name + 1, -1, ':');
390 *(child_path++) = '\0';
391 message = dbus_message_new_method_call (child_name, child_path, ATSPI_DBUS_INTERFACE_ACCESSIBLE, "GetState");
393 reply = dbus_connection_send_with_reply_and_block (spi_global_app_data->bus, message, 1, NULL);
394 dbus_message_unref (message);
397 if (strcmp (dbus_message_get_signature (reply), "au") != 0)
399 dbus_message_unref (reply);
403 dbus_message_iter_init (reply, &iter);
404 dbus_message_iter_recurse (&iter, &iter_array);
407 dbus_message_iter_get_basic (&iter_array, &v);
408 for (j = 0; j < 32; j++)
412 AtkState state = spi_atk_state_from_spi_state ((count << 5) + j);
413 atk_state_set_add_state (set, state);
418 while (dbus_message_iter_next (&iter_array));
419 dbus_message_unref (reply);
424 socket_embed_hook (AtkSocket * socket, gchar * plug_id)
426 AtkObject *accessible = ATK_OBJECT(socket);
427 gchar *plug_name, *plug_path;
428 AtkObjectClass *klass;
430 /* Force registration */
431 gchar *path = spi_register_object_to_path (spi_global_register, G_OBJECT (accessible));
432 /* Let the plug know that it has been embedded */
433 plug_name = g_strdup (plug_id);
439 plug_path = g_utf8_strchr (plug_name + 1, -1, ':');
442 DBusMessage *message;
443 *(plug_path++) = '\0';
444 message = dbus_message_new_method_call (plug_name, plug_path, ATSPI_DBUS_INTERFACE_SOCKET, "Embedded");
445 dbus_message_append_args (message, DBUS_TYPE_STRING, &path, DBUS_TYPE_INVALID);
446 dbus_connection_send (spi_global_app_data->bus, message, NULL);
451 klass = ATK_OBJECT_GET_CLASS (accessible);
452 klass->ref_state_set = socket_ref_state_set;
456 install_plug_hooks ()
460 data = g_type_class_ref (ATK_TYPE_PLUG);
461 plug_class = ATK_PLUG_CLASS (data);
462 data = g_type_class_ref (ATK_TYPE_SOCKET);
463 socket_class = ATK_SOCKET_CLASS (data);
464 plug_class->get_object_id = get_plug_id;
465 socket_class->embed = socket_embed_hook;
469 get_ancestral_uid (guint pid)
475 gboolean got_ppid = 0;
476 gboolean got_uid = 0;
478 sprintf (buf, "/proc/%d/status", pid);
479 fp = fopen (buf, "r");
482 while ((!got_ppid || !got_uid) && fgets (buf, sizeof (buf), fp))
484 if (sscanf (buf, "PPid:\t%d", &ppid) == 1)
486 else if (sscanf (buf, "Uid:\t%d", &uid) == 1)
491 if (!got_ppid || !got_uid)
495 if (ppid == 0 || ppid == 1)
497 return get_ancestral_uid (ppid);
501 user_check (DBusConnection *bus, unsigned long uid, void *data)
503 if (uid == getuid () || uid == geteuid ())
506 return get_ancestral_uid (getpid ()) == uid;
511 new_connection_cb (DBusServer *server, DBusConnection *con, void *data)
513 dbus_connection_set_unix_user_function (con, user_check, NULL, NULL);
514 dbus_connection_ref(con);
515 atspi_dbus_connection_setup_with_g_main(con, NULL);
516 droute_intercept_dbus (con);
517 droute_context_register (spi_global_app_data->droute, con);
519 spi_global_app_data->direct_connections = g_list_append (spi_global_app_data->direct_connections, con);
523 gchar *atspi_dbus_name = NULL;
524 static gboolean atspi_no_register = FALSE;
526 static GOptionEntry atspi_option_entries[] = {
527 {"atspi-dbus-name", 0, 0, G_OPTION_ARG_STRING, &atspi_dbus_name,
528 "D-Bus bus name to register as", NULL},
529 {"atspi-no-register", 0, 0, G_OPTION_ARG_NONE, &atspi_no_register,
530 "Do not register with Registry Daemon", NULL},
535 introspect_children_cb (const char *path, void *data)
537 if (!strcmp (path, "/org/a11y/atspi/accessible"))
539 return g_strdup ("<node name=\"root\"/>\n");
540 /* TODO: Should we place the whole hierarchy here? */
546 handle_event_listener_registered (DBusConnection *bus, DBusMessage *message,
552 if (!dbus_message_get_args (message, NULL, DBUS_TYPE_STRING, &sender,
553 DBUS_TYPE_STRING, &name, DBUS_TYPE_INVALID))
556 add_event (sender, name);
560 remove_events (const char *bus_name, const char *event)
565 remove_data = g_strsplit (event, ":", 3);
571 for (list = spi_global_app_data->events; list;)
573 event_data *evdata = list->data;
574 if (!g_strcmp0 (evdata->bus_name, bus_name) &&
575 spi_event_is_subtype (evdata->data, remove_data))
577 GList *events = spi_global_app_data->events;
579 g_strfreev (evdata->data);
580 g_free (evdata->bus_name);
582 spi_global_app_data->events = g_list_remove (events, evdata);
590 g_strfreev (remove_data);
594 handle_event_listener_deregistered (DBusConnection *bus, DBusMessage *message,
600 if (!dbus_message_get_args (message, NULL, DBUS_TYPE_STRING, &sender,
601 DBUS_TYPE_STRING, &name, DBUS_TYPE_INVALID))
604 remove_events (sender, name);
608 handle_device_listener_registered (DBusConnection *bus, DBusMessage *message,
612 DBusMessageIter iter, iter_struct;
614 if (strncmp (dbus_message_get_signature (message), "(s", 2) != 0)
616 g_warning ("atk-bridge: handle_device_listener_register: unknown signature");
620 dbus_message_iter_init (message, &iter);
621 dbus_message_iter_recurse (&iter, &iter_struct);
622 dbus_message_iter_get_basic (&iter_struct, &sender);
623 spi_atk_add_client (sender);
626 static DBusHandlerResult
627 signal_filter (DBusConnection *bus, DBusMessage *message, void *user_data)
629 const char *interface = dbus_message_get_interface (message);
630 const char *member = dbus_message_get_member (message);
631 DBusHandlerResult result = DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
633 if (dbus_message_get_type (message) != DBUS_MESSAGE_TYPE_SIGNAL)
634 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
636 if (!strcmp (interface, ATSPI_DBUS_INTERFACE_REGISTRY))
638 result = DBUS_HANDLER_RESULT_HANDLED;
639 if (!strcmp (member, "EventListenerRegistered"))
640 handle_event_listener_registered (bus, message, user_data);
641 else if (!strcmp (member, "EventListenerDeregistered"))
642 handle_event_listener_deregistered (bus, message, user_data);
644 result = DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
646 else if (!strcmp (interface, ATSPI_DBUS_INTERFACE_DEVICE_EVENT_LISTENER))
648 result = DBUS_HANDLER_RESULT_HANDLED;
649 if (!strcmp (member, "KeystrokeListenerRegistered"))
650 handle_device_listener_registered (bus, message, user_data);
651 else if (!strcmp (member, "DeviceListenerRegistered"))
652 handle_device_listener_registered (bus, message, user_data);
654 result = DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
657 if (!g_strcmp0(interface, DBUS_INTERFACE_DBUS) &&
658 !g_strcmp0(member, "NameOwnerChanged"))
660 char *name, *old, *new;
661 result = DBUS_HANDLER_RESULT_HANDLED;
662 if (dbus_message_get_args (message, NULL,
663 DBUS_TYPE_STRING, &name,
664 DBUS_TYPE_STRING, &old,
665 DBUS_TYPE_STRING, &new,
668 if (*old != '\0' && *new == '\0')
669 spi_atk_remove_client (old);
677 spi_atk_create_socket (SpiBridge *app)
685 app->app_tmp_dir = g_build_filename (g_get_user_runtime_dir (),
686 "at-spi2-XXXXXX", NULL);
687 if (!g_mkdtemp (app->app_tmp_dir))
689 g_free (app->app_tmp_dir);
690 app->app_tmp_dir = NULL;
695 if (app->app_tmp_dir)
696 app->app_bus_addr = g_strdup_printf ("unix:path=%s/socket", app->app_tmp_dir);
698 app->app_bus_addr = g_strdup_printf ("unix:path=%s/at-spi2-socket-%d",
699 g_get_user_runtime_dir (), getpid ());
701 if (!spi_global_app_data->app_bus_addr)
704 dbus_error_init(&err);
705 server = dbus_server_listen(spi_global_app_data->app_bus_addr, &err);
708 g_warning ("atk-bridge: Couldn't listen on dbus server: %s", err.message);
709 dbus_error_init (&err);
710 spi_global_app_data->app_bus_addr [0] = '\0';
711 g_main_context_unref (spi_global_app_data->main_context);
712 spi_global_app_data->main_context = NULL;
716 atspi_dbus_server_setup_with_g_main(server, NULL);
717 dbus_server_set_new_connection_function(server, new_connection_cb, NULL, NULL);
719 spi_global_app_data->server = server;
726 * Checks the status of the environment variables
728 * At this moment it only checks NO_AT_BRIDGE
730 * Returns TRUE if there isn't anything on the environment preventing
731 * you to load the bridge, FALSE otherwise
738 envvar = g_getenv ("NO_AT_BRIDGE");
740 if (envvar && atoi (envvar) == 1)
749 * The following needs to be initialized.
751 * - DRoute for routing message to their accessible objects.
752 * - Event handlers for emmitting signals on specific ATK events.
753 * - setup the bus for p2p communication
754 * - Application registration with the AT-SPI registry.
758 atk_bridge_adaptor_init (gint * argc, gchar ** argv[])
764 gboolean load_bridge;
765 DRoutePath *treepath, *accpath;
767 load_bridge = check_envvar ();
768 if (inited && !load_bridge)
769 g_warning ("ATK Bridge is disabled but a11y has already been enabled.");
771 if (inited || !load_bridge)
776 root = atk_get_root ();
777 g_warn_if_fail (root);
784 /* Parse command line options */
785 opt = g_option_context_new (NULL);
786 g_option_context_add_main_entries (opt, atspi_option_entries, NULL);
787 g_option_context_set_ignore_unknown_options (opt, TRUE);
788 if (!g_option_context_parse (opt, argc, argv, &err))
789 g_warning ("AT-SPI Option parsing failed: %s\n", err->message);
790 g_option_context_free (opt);
792 /* Allocate global data and do ATK initializations */
793 spi_global_app_data = g_new0 (SpiBridge, 1);
794 spi_global_app_data->root = g_object_ref (root);
796 /* Set up D-Bus connection and register bus name */
797 dbus_error_init (&error);
798 spi_global_app_data->bus = atspi_get_a11y_bus ();
799 if (!spi_global_app_data->bus)
801 g_free (spi_global_app_data);
802 spi_global_app_data = NULL;
807 if (atspi_dbus_name != NULL)
809 if (dbus_bus_request_name
810 (spi_global_app_data->bus, atspi_dbus_name, 0, &error))
812 g_print ("AT-SPI Recieved D-Bus name - %s\n", atspi_dbus_name);
817 ("AT-SPI D-Bus name requested but could not be allocated - %s\n",
822 spi_global_app_data->main_context = g_main_context_new ();
824 atspi_dbus_connection_setup_with_g_main (spi_global_app_data->bus, NULL);
826 /* Hook our plug-and socket functions */
827 install_plug_hooks ();
830 * Create the leasing, register and cache objects.
831 * The order is important here, the cache depends on the
834 spi_global_register = g_object_new (SPI_REGISTER_TYPE, NULL);
835 spi_global_leasing = g_object_new (SPI_LEASING_TYPE, NULL);
836 spi_global_cache = g_object_new (SPI_CACHE_TYPE, NULL);
838 /* Register droute for routing AT-SPI messages */
839 spi_global_app_data->droute =
842 treepath = droute_add_one (spi_global_app_data->droute,
843 "/org/a11y/atspi/cache", spi_global_cache);
847 g_warning ("atk-bridge: Error in droute_add_one(). Already running?");
851 accpath = droute_add_many (spi_global_app_data->droute,
852 "/org/a11y/atspi/accessible",
854 introspect_children_cb,
856 (DRouteGetDatumFunction)
857 spi_global_register_path_to_object);
860 /* Register all interfaces with droute and set up application accessible db */
861 spi_initialize_cache (treepath);
862 spi_initialize_accessible (accpath);
863 spi_initialize_application (accpath);
864 spi_initialize_action (accpath);
865 spi_initialize_collection (accpath);
866 spi_initialize_component (accpath);
867 spi_initialize_document (accpath);
868 spi_initialize_editabletext (accpath);
869 spi_initialize_hyperlink (accpath);
870 spi_initialize_hypertext (accpath);
871 spi_initialize_image (accpath);
872 spi_initialize_selection (accpath);
873 spi_initialize_socket (accpath);
874 spi_initialize_table (accpath);
875 spi_initialize_text (accpath);
876 spi_initialize_value (accpath);
878 droute_context_register (spi_global_app_data->droute,
879 spi_global_app_data->bus);
881 /* Register methods to send D-Bus signals on certain ATK events */
883 spi_atk_register_event_listeners ();
885 /* Set up filter and match rules to catch signals */
886 dbus_bus_add_match (spi_global_app_data->bus, "type='signal', interface='org.a11y.atspi.Registry', sender='org.a11y.atspi.Registry'", NULL);
887 dbus_bus_add_match (spi_global_app_data->bus, "type='signal', interface='org.a11y.atspi.DeviceEventListener', sender='org.a11y.atspi.Registry'", NULL);
888 dbus_connection_add_filter (spi_global_app_data->bus, signal_filter, NULL,
891 /* Register this app by sending a signal out to AT-SPI registry daemon */
892 if (!atspi_no_register && (!root || !ATK_IS_PLUG (root)))
893 register_application (spi_global_app_data);
895 get_registered_event_listeners (spi_global_app_data);
901 atk_bridge_adaptor_cleanup (void)
906 g_return_if_fail (inited);
908 if (!spi_global_app_data)
911 spi_atk_tidy_windows ();
912 spi_atk_deregister_event_listeners ();
914 deregister_application (spi_global_app_data);
916 if (spi_global_app_data->bus)
918 dbus_connection_remove_filter (spi_global_app_data->bus, signal_filter, NULL);
919 droute_context_unregister (spi_global_app_data->droute, spi_global_app_data->bus);
920 dbus_connection_unref (spi_global_app_data->bus);
923 for (l = spi_global_app_data->direct_connections; l; l = l->next)
925 DBusConnection *connection;
927 connection = l->data;
929 droute_context_unregister (spi_global_app_data->droute, connection);
930 droute_unintercept_dbus (connection);
931 dbus_connection_unref (connection);
933 g_list_free (spi_global_app_data->direct_connections);
935 for (ls = clients; ls; ls = ls->next)
937 g_slist_free (clients);
940 g_object_unref (spi_global_cache);
941 g_object_unref (spi_global_leasing);
942 g_object_unref (spi_global_register);
944 if (spi_global_app_data->main_context)
945 g_main_context_unref (spi_global_app_data->main_context);
947 droute_free (spi_global_app_data->droute);
949 g_free (spi_global_app_data);
950 spi_global_app_data = NULL;
955 /*---------------------------------------------------------------------------*/
957 static gchar *name_match_tmpl =
958 "type='signal', interface='org.freedesktop.DBus', member='NameOwnerChanged', arg0='%s'";
961 spi_atk_add_client (const char *bus_name)
966 for (l = clients; l; l = l->next)
968 if (!g_strcmp0 (l->data, bus_name))
972 spi_atk_register_event_listeners ();
973 clients = g_slist_append (clients, g_strdup (bus_name));
974 match = g_strdup_printf (name_match_tmpl, bus_name);
975 dbus_bus_add_match (spi_global_app_data->bus, match, NULL);
980 spi_atk_remove_client (const char *bus_name)
990 if (!g_strcmp0 (l->data, bus_name))
992 gchar *match = g_strdup_printf (name_match_tmpl, l->data);
993 dbus_bus_remove_match (spi_global_app_data->bus, match, NULL);
996 clients = g_slist_delete_link (clients, l);
998 spi_atk_deregister_event_listeners ();
1005 /*END------------------------------------------------------------------------*/