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.
29 #include <X11/Xatom.h>
38 #include <droute/droute.h>
40 #include <atspi/atspi.h>
46 #include "accessible-stateset.h"
48 #include "accessible-register.h"
49 #include "accessible-leasing.h"
50 #include "accessible-cache.h"
54 /*---------------------------------------------------------------------------*/
56 static DBusHandlerResult
57 signal_filter (DBusConnection *bus, DBusMessage *message, void *user_data);
59 SpiBridge *spi_global_app_data = NULL;
61 /*---------------------------------------------------------------------------*/
64 add_event (const char *bus_name, const char *event)
70 spi_atk_add_client (bus_name);
71 evdata = (event_data *) g_malloc (sizeof (*evdata));
74 data = g_strsplit (event, ":", 3);
80 evdata->bus_name = g_strdup (bus_name);
82 new_list = g_list_append (spi_global_app_data->events, evdata);
84 spi_global_app_data->events = new_list;
87 static GSList *clients = NULL;
92 static int replies_received = 0;
95 if (replies_received == 3)
98 spi_atk_deregister_event_listeners ();
99 spi_global_app_data->events_initialized = TRUE;
104 get_events_reply (DBusPendingCall *pending, void *user_data)
106 DBusMessage *reply = dbus_pending_call_steal_reply (pending);
107 DBusMessageIter iter, iter_array, iter_struct;
112 if (strcmp (dbus_message_get_signature (reply), "a(ss)") != 0)
114 g_warning ("atk-bridge: GetRegisteredEvents returned message with unknown signature");
118 dbus_message_iter_init (reply, &iter);
119 dbus_message_iter_recurse (&iter, &iter_array);
120 while (dbus_message_iter_get_arg_type (&iter_array) != DBUS_TYPE_INVALID)
122 char *bus_name, *event;
123 dbus_message_iter_recurse (&iter_array, &iter_struct);
124 dbus_message_iter_get_basic (&iter_struct, &bus_name);
125 dbus_message_iter_next (&iter_struct);
126 dbus_message_iter_get_basic (&iter_struct, &event);
127 add_event (bus_name, event);
128 dbus_message_iter_next (&iter_array);
133 dbus_message_unref (reply);
135 dbus_pending_call_unref (pending);
137 tally_event_reply ();
141 get_device_events_reply (DBusPendingCall *pending, void *user_data)
143 DBusMessage *reply = dbus_pending_call_steal_reply (pending);
144 DBusMessageIter iter, iter_array, iter_struct;
149 if (strncmp (dbus_message_get_signature (reply), "a(s", 3) != 0)
151 g_warning ("atk-bridge: get_device_events_reply: unknown signature");
155 dbus_message_iter_init (reply, &iter);
156 dbus_message_iter_recurse (&iter, &iter_array);
157 while (dbus_message_iter_get_arg_type (&iter_array) != DBUS_TYPE_INVALID)
160 dbus_message_iter_recurse (&iter_array, &iter_struct);
161 dbus_message_iter_get_basic (&iter_struct, &bus_name);
162 spi_atk_add_client (bus_name);
163 dbus_message_iter_next (&iter_array);
168 dbus_message_unref (reply);
170 dbus_pending_call_unref (pending);
172 tally_event_reply ();
176 get_registered_event_listeners (SpiBridge *app)
178 DBusMessage *message;
179 DBusPendingCall *pending = NULL;
181 message = dbus_message_new_method_call (SPI_DBUS_NAME_REGISTRY,
182 ATSPI_DBUS_PATH_REGISTRY,
183 ATSPI_DBUS_INTERFACE_REGISTRY,
184 "GetRegisteredEvents");
188 dbus_connection_send_with_reply (app->bus, message, &pending, -1);
189 dbus_message_unref (message);
192 spi_global_app_data->events_initialized = TRUE;
195 dbus_pending_call_set_notify (pending, get_events_reply, NULL, NULL);
197 message = dbus_message_new_method_call (SPI_DBUS_NAME_REGISTRY,
199 ATSPI_DBUS_INTERFACE_DEC,
200 "GetKeystrokeListeners");
204 dbus_connection_send_with_reply (app->bus, message, &pending, -1);
205 dbus_message_unref (message);
208 spi_global_app_data->events_initialized = TRUE;
211 dbus_pending_call_set_notify (pending, get_device_events_reply, NULL, NULL);
213 message = dbus_message_new_method_call (SPI_DBUS_NAME_REGISTRY,
215 ATSPI_DBUS_INTERFACE_DEC,
216 "GetDeviceEventListeners");
220 dbus_connection_send_with_reply (app->bus, message, &pending, -1);
221 dbus_message_unref (message);
224 spi_global_app_data->events_initialized = TRUE;
227 dbus_pending_call_set_notify (pending, get_device_events_reply, NULL, NULL);
231 register_reply (DBusPendingCall *pending, void *user_data)
234 SpiBridge *app = user_data;
235 DBusMessage *message;
237 reply = dbus_pending_call_steal_reply (pending);
238 dbus_pending_call_unref (pending);
241 gchar *app_name, *obj_path;
243 if (strcmp (dbus_message_get_signature (reply), "(so)") != 0)
245 g_warning ("AT-SPI: Could not obtain desktop path or name\n");
249 DBusMessageIter iter, iter_struct;
250 dbus_message_iter_init (reply, &iter);
251 dbus_message_iter_recurse (&iter, &iter_struct);
252 dbus_message_iter_get_basic (&iter_struct, &app_name);
253 dbus_message_iter_next (&iter_struct);
254 dbus_message_iter_get_basic (&iter_struct, &obj_path);
256 app->desktop_name = g_strdup (app_name);
257 app->desktop_path = g_strdup (obj_path);
262 g_warning ("AT-SPI: Could not embed inside desktop");
265 dbus_message_unref (reply);
267 get_registered_event_listeners (spi_global_app_data);
271 register_application (SpiBridge * app)
273 DBusMessage *message, *reply;
274 DBusMessageIter iter;
276 DBusPendingCall *pending;
277 const int max_addr_length = 128; /* should be long enough */
279 dbus_error_init (&error);
281 /* These will be overridden when we get a reply, but in practice these
282 defaults should always be correct */
283 app->desktop_name = ATSPI_DBUS_NAME_REGISTRY;
284 app->desktop_path = ATSPI_DBUS_PATH_ROOT;
286 message = dbus_message_new_method_call (SPI_DBUS_NAME_REGISTRY,
287 ATSPI_DBUS_PATH_ROOT,
288 ATSPI_DBUS_INTERFACE_SOCKET,
291 dbus_message_iter_init_append (message, &iter);
292 spi_object_append_reference (&iter, app->root);
294 if (!dbus_connection_send_with_reply (app->bus, message, &pending, -1)
300 dbus_pending_call_set_notify (pending, register_reply, app, NULL);
303 dbus_message_unref (message);
305 /* could this be better, we accept some amount of race in getting the temp name*/
306 /* make sure the directory exists */
307 mkdir ("/tmp/at-spi2/", S_IRWXU|S_IRWXG|S_IRWXO|S_ISVTX);
308 chmod ("/tmp/at-spi2/", S_IRWXU|S_IRWXG|S_IRWXO|S_ISVTX);
309 app->app_bus_addr = g_malloc(max_addr_length * sizeof(char));
311 sprintf (app->app_bus_addr, "unix:path=/tmp/at-spi2/socket-%d-%d", getpid(),
314 app->app_bus_addr [0] = '\0';
320 /*---------------------------------------------------------------------------*/
323 deregister_application (SpiBridge * app)
325 DBusMessage *message;
326 DBusMessageIter iter;
330 dbus_error_init (&error);
332 message = dbus_message_new_method_call (SPI_DBUS_NAME_REGISTRY,
333 ATSPI_DBUS_PATH_REGISTRY,
334 ATSPI_DBUS_INTERFACE_REGISTRY,
335 "DeregisterApplication");
336 dbus_message_set_no_reply (message, TRUE);
338 uname = dbus_bus_get_unique_name (app->bus);
340 dbus_message_iter_init_append (message, &iter);
341 dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &uname);
342 dbus_connection_send (app->bus, message, NULL);
344 dbus_message_unref (message);
347 /*---------------------------------------------------------------------------*/
349 /*---------------------------------------------------------------------------*/
351 static AtkPlugClass *plug_class;
352 static AtkSocketClass *socket_class;
355 get_plug_id (AtkPlug * plug)
357 const char *uname = dbus_bus_get_unique_name (spi_global_app_data->bus);
359 GString *str = g_string_new (NULL);
361 path = spi_register_object_to_path (spi_global_register, G_OBJECT (plug));
362 g_string_printf (str, "%s:%s", uname, path);
364 return g_string_free (str, FALSE);
368 socket_ref_state_set (AtkObject *accessible)
370 char *child_name, *child_path;
371 AtkSocket *socket = ATK_SOCKET (accessible);
375 DBusMessage *message, *reply;
376 DBusMessageIter iter, iter_array;
379 set = atk_state_set_new ();
381 if (!socket->embedded_plug_id)
384 child_name = g_strdup (socket->embedded_plug_id);
387 child_path = g_utf8_strchr (child_name + 1, -1, ':');
393 *(child_path++) = '\0';
394 message = dbus_message_new_method_call (child_name, child_path, ATSPI_DBUS_INTERFACE_ACCESSIBLE, "GetState");
396 reply = dbus_connection_send_with_reply_and_block (spi_global_app_data->bus, message, 1, NULL);
397 dbus_message_unref (message);
400 if (strcmp (dbus_message_get_signature (reply), "au") != 0)
402 dbus_message_unref (reply);
406 dbus_message_iter_init (reply, &iter);
407 dbus_message_iter_recurse (&iter, &iter_array);
410 dbus_message_iter_get_basic (&iter_array, &v);
411 for (j = 0; j < 32; j++)
415 AtkState state = spi_atk_state_from_spi_state ((count << 5) + j);
416 atk_state_set_add_state (set, state);
421 while (dbus_message_iter_next (&iter_array));
422 dbus_message_unref (reply);
427 socket_embed_hook (AtkSocket * socket, gchar * plug_id)
429 AtkObject *accessible = ATK_OBJECT(socket);
430 gchar *plug_name, *plug_path;
431 AtkObjectClass *klass;
433 /* Force registration */
434 gchar *path = spi_register_object_to_path (spi_global_register, G_OBJECT (accessible));
435 /* Let the plug know that it has been embedded */
436 plug_name = g_strdup (plug_id);
442 plug_path = g_utf8_strchr (plug_name + 1, -1, ':');
445 DBusMessage *message;
446 *(plug_path++) = '\0';
447 message = dbus_message_new_method_call (plug_name, plug_path, ATSPI_DBUS_INTERFACE_SOCKET, "Embedded");
448 dbus_message_append_args (message, DBUS_TYPE_STRING, &path, DBUS_TYPE_INVALID);
449 dbus_connection_send (spi_global_app_data->bus, message, NULL);
454 klass = ATK_OBJECT_GET_CLASS (accessible);
455 klass->ref_state_set = socket_ref_state_set;
459 install_plug_hooks ()
463 data = g_type_class_ref (ATK_TYPE_PLUG);
464 plug_class = ATK_PLUG_CLASS (data);
465 data = g_type_class_ref (ATK_TYPE_SOCKET);
466 socket_class = ATK_SOCKET_CLASS (data);
467 plug_class->get_object_id = get_plug_id;
468 socket_class->embed = socket_embed_hook;
472 get_ancestral_uid (uint pid)
478 gboolean got_ppid = 0;
479 gboolean got_uid = 0;
481 sprintf (buf, "/proc/%d/status", pid);
482 fp = fopen (buf, "r");
485 while ((!got_ppid || !got_uid) && fgets (buf, sizeof (buf), fp))
487 if (sscanf (buf, "PPid:\t%d", &ppid) == 1)
489 else if (sscanf (buf, "Uid:\t%d", &uid) == 1)
494 if (!got_ppid || !got_uid)
498 if (ppid == 0 || ppid == 1)
500 return get_ancestral_uid (ppid);
504 user_check (DBusConnection *bus, unsigned long uid, void *data)
506 if (uid == getuid () || uid == geteuid ())
509 return get_ancestral_uid (getpid ()) == uid;
514 new_connection_cb (DBusServer *server, DBusConnection *con, void *data)
518 dbus_connection_set_unix_user_function (con, user_check, NULL, NULL);
519 dbus_connection_ref(con);
520 atspi_dbus_connection_setup_with_g_main(con, NULL);
521 droute_intercept_dbus (con);
522 droute_context_register (spi_global_app_data->droute, con);
524 spi_global_app_data->direct_connections = g_list_append (spi_global_app_data->direct_connections, con);
534 dbus_error_init(&err);
535 server = dbus_server_listen(spi_global_app_data->app_bus_addr, &err);
538 g_warning ("atk-bridge: Couldn't listen on dbus server: %s", err.message);
539 dbus_error_init (&err);
540 spi_global_app_data->app_bus_addr [0] = '\0';
541 g_main_context_unref (spi_global_app_data->main_context);
542 spi_global_app_data->main_context = NULL;
546 atspi_dbus_server_setup_with_g_main(server, NULL);
547 dbus_server_set_new_connection_function(server, new_connection_cb, NULL, NULL);
549 spi_global_app_data->server = server;
556 gchar *atspi_dbus_name = NULL;
557 static gboolean atspi_no_register = FALSE;
559 static GOptionEntry atspi_option_entries[] = {
560 {"atspi-dbus-name", 0, 0, G_OPTION_ARG_STRING, &atspi_dbus_name,
561 "D-Bus bus name to register as", NULL},
562 {"atspi-no-register", 0, 0, G_OPTION_ARG_NONE, &atspi_no_register,
563 "Do not register with Registry Daemon", NULL},
568 introspect_children_cb (const char *path, void *data)
570 if (!strcmp (path, "/org/a11y/atspi/accessible"))
572 return g_strdup ("<node name=\"root\"/>\n");
573 /* TODO: Should we place the whole hierarchy here? */
579 handle_event_listener_registered (DBusConnection *bus, DBusMessage *message,
585 if (!dbus_message_get_args (message, NULL, DBUS_TYPE_STRING, &sender,
586 DBUS_TYPE_STRING, &name, DBUS_TYPE_INVALID))
589 add_event (sender, name);
593 remove_events (const char *bus_name, const char *event)
599 remove_data = g_strsplit (event, ":", 3);
605 for (list = spi_global_app_data->events; list;)
607 event_data *evdata = list->data;
608 if (!g_strcmp0 (evdata->bus_name, bus_name) &&
609 spi_event_is_subtype (evdata->data, remove_data))
611 GList *events = spi_global_app_data->events;
613 g_strfreev (evdata->data);
614 g_free (evdata->bus_name);
616 spi_global_app_data->events = g_list_remove (events, evdata);
624 g_strfreev (remove_data);
628 handle_event_listener_deregistered (DBusConnection *bus, DBusMessage *message,
631 const char *orig_name;
635 if (!dbus_message_get_args (message, NULL, DBUS_TYPE_STRING, &sender,
636 DBUS_TYPE_STRING, &name, DBUS_TYPE_INVALID))
639 remove_events (sender, name);
643 handle_device_listener_registered (DBusConnection *bus, DBusMessage *message,
647 DBusMessageIter iter, iter_struct;
649 if (strncmp (dbus_message_get_signature (message), "(s", 2) != 0)
651 g_warning ("atk-bridge: handle_device_listener_register: unknown signature");
655 dbus_message_iter_init (message, &iter);
656 dbus_message_iter_recurse (&iter, &iter_struct);
657 dbus_message_iter_get_basic (&iter_struct, &sender);
658 spi_atk_add_client (sender);
661 static DBusHandlerResult
662 signal_filter (DBusConnection *bus, DBusMessage *message, void *user_data)
664 const char *interface = dbus_message_get_interface (message);
665 const char *member = dbus_message_get_member (message);
666 DBusHandlerResult result = DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
668 if (dbus_message_get_type (message) != DBUS_MESSAGE_TYPE_SIGNAL)
669 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
671 if (!strcmp (interface, ATSPI_DBUS_INTERFACE_REGISTRY))
673 result = DBUS_HANDLER_RESULT_HANDLED;
674 if (!strcmp (member, "EventListenerRegistered"))
675 handle_event_listener_registered (bus, message, user_data);
676 else if (!strcmp (member, "EventListenerDeregistered"))
677 handle_event_listener_deregistered (bus, message, user_data);
679 result = DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
681 else if (!strcmp (interface, ATSPI_DBUS_INTERFACE_DEVICE_EVENT_LISTENER))
683 result = DBUS_HANDLER_RESULT_HANDLED;
684 if (!strcmp (member, "KeystrokeListenerRegistered"))
685 handle_device_listener_registered (bus, message, user_data);
686 else if (!strcmp (member, "DeviceListenerRegistered"))
687 handle_device_listener_registered (bus, message, user_data);
689 result = DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
692 if (!g_strcmp0(interface, DBUS_INTERFACE_DBUS) &&
693 !g_strcmp0(member, "NameOwnerChanged"))
695 char *name, *old, *new;
696 result = DBUS_HANDLER_RESULT_HANDLED;
697 if (dbus_message_get_args (message, NULL,
698 DBUS_TYPE_STRING, &name,
699 DBUS_TYPE_STRING, &old,
700 DBUS_TYPE_STRING, &new,
703 if (*old != '\0' && *new == '\0')
704 spi_atk_remove_client (old);
714 * The following needs to be initialized.
716 * - DRoute for routing message to their accessible objects.
717 * - Event handlers for emmitting signals on specific ATK events.
718 * - setup the bus for p2p communication
719 * - Application registration with the AT-SPI registry.
723 adaptor_init (gint * argc, gchar ** argv[])
729 gchar *introspection_directory;
730 static gboolean inited = FALSE;
737 DRoutePath *treepath, *accpath;
739 root = atk_get_root ();
740 g_warn_if_fail (root);
747 /* Parse command line options */
748 opt = g_option_context_new (NULL);
749 g_option_context_add_main_entries (opt, atspi_option_entries, NULL);
750 g_option_context_set_ignore_unknown_options (opt, TRUE);
751 if (!g_option_context_parse (opt, argc, argv, &err))
752 g_warning ("AT-SPI Option parsing failed: %s\n", err->message);
753 g_option_context_free (opt);
755 /* Allocate global data and do ATK initializations */
756 spi_global_app_data = g_new0 (SpiBridge, 1);
757 spi_global_app_data->root = g_object_ref (root);
759 /* Set up D-Bus connection and register bus name */
760 dbus_error_init (&error);
761 spi_global_app_data->bus = atspi_get_a11y_bus ();
762 if (!spi_global_app_data->bus)
764 g_free (spi_global_app_data);
765 spi_global_app_data = NULL;
770 if (atspi_dbus_name != NULL)
772 if (dbus_bus_request_name
773 (spi_global_app_data->bus, atspi_dbus_name, 0, &error))
775 g_print ("AT-SPI Recieved D-Bus name - %s\n", atspi_dbus_name);
780 ("AT-SPI D-Bus name requested but could not be allocated - %s\n",
785 spi_global_app_data->main_context = g_main_context_new ();
787 atspi_dbus_connection_setup_with_g_main (spi_global_app_data->bus, NULL);
789 /* Hook our plug-and socket functions */
790 install_plug_hooks ();
793 * Create the leasing, register and cache objects.
794 * The order is important here, the cache depends on the
797 spi_global_register = g_object_new (SPI_REGISTER_TYPE, NULL);
798 spi_global_leasing = g_object_new (SPI_LEASING_TYPE, NULL);
799 spi_global_cache = g_object_new (SPI_CACHE_TYPE, NULL);
801 /* Register droute for routing AT-SPI messages */
802 spi_global_app_data->droute =
805 treepath = droute_add_one (spi_global_app_data->droute,
806 "/org/a11y/atspi/cache", spi_global_cache);
810 g_warning ("atk-bridge: Error in droute_add_one(). Already running?");
814 accpath = droute_add_many (spi_global_app_data->droute,
815 "/org/a11y/atspi/accessible",
817 introspect_children_cb,
819 (DRouteGetDatumFunction)
820 spi_global_register_path_to_object);
823 /* Register all interfaces with droute and set up application accessible db */
824 spi_initialize_cache (treepath);
825 spi_initialize_accessible (accpath);
826 spi_initialize_application (accpath);
827 spi_initialize_action (accpath);
828 spi_initialize_collection (accpath);
829 spi_initialize_component (accpath);
830 spi_initialize_document (accpath);
831 spi_initialize_editabletext (accpath);
832 spi_initialize_hyperlink (accpath);
833 spi_initialize_hypertext (accpath);
834 spi_initialize_image (accpath);
835 spi_initialize_selection (accpath);
836 spi_initialize_socket (accpath);
837 spi_initialize_table (accpath);
838 spi_initialize_text (accpath);
839 spi_initialize_value (accpath);
841 droute_context_register (spi_global_app_data->droute,
842 spi_global_app_data->bus);
844 /* Register methods to send D-Bus signals on certain ATK events */
845 spi_atk_register_event_listeners ();
847 /* Set up filter and match rules to catch signals */
848 dbus_bus_add_match (spi_global_app_data->bus, "type='signal', interface='org.a11y.atspi.Registry', sender='org.a11y.atspi.Registry'", NULL);
849 dbus_bus_add_match (spi_global_app_data->bus, "type='signal', interface='org.a11y.atspi.DeviceEventListener', sender='org.a11y.atspi.Registry'", NULL);
850 dbus_connection_add_filter (spi_global_app_data->bus, signal_filter, NULL,
853 /* Register this app by sending a signal out to AT-SPI registry daemon */
854 if (!atspi_no_register && (!root || !ATK_IS_PLUG (root)))
855 register_application (spi_global_app_data);
857 get_registered_event_listeners (spi_global_app_data);
865 adaptor_cleanup (void)
870 if (!spi_global_app_data)
873 spi_atk_tidy_windows ();
874 spi_atk_deregister_event_listeners ();
876 deregister_application (spi_global_app_data);
878 if (spi_global_app_data->bus)
880 dbus_connection_remove_filter (spi_global_app_data->bus, signal_filter, NULL);
881 droute_context_unregister (spi_global_app_data->droute, spi_global_app_data->bus);
882 dbus_connection_unref (spi_global_app_data->bus);
885 for (l = spi_global_app_data->direct_connections; l; l = l->next)
887 DBusConnection *connection;
889 connection = l->data;
891 droute_context_unregister (spi_global_app_data->droute, connection);
892 droute_unintercept_dbus (connection);
893 dbus_connection_unref (connection);
895 g_list_free (spi_global_app_data->direct_connections);
897 for (ls = clients; ls; ls = ls->next)
899 g_slist_free (clients);
902 g_object_unref (spi_global_cache);
903 g_object_unref (spi_global_leasing);
904 g_object_unref (spi_global_register);
906 if (spi_global_app_data->main_context)
907 g_main_context_unref (spi_global_app_data->main_context);
909 droute_free (spi_global_app_data->droute);
911 g_free (spi_global_app_data);
912 spi_global_app_data = NULL;
915 /*---------------------------------------------------------------------------*/
918 gtk_module_init (gint * argc, gchar ** argv[])
920 const gchar *load_bridge = g_getenv ("NO_AT_BRIDGE");
922 if (!load_bridge || g_ascii_strtod (load_bridge, NULL) == 0)
924 return adaptor_init (argc, argv);
930 g_module_check_init (GModule *module)
932 g_module_make_resident (module);
938 gnome_accessibility_module_init (void)
940 const gchar *load_bridge = g_getenv ("NO_AT_BRIDGE");
942 if (!load_bridge || g_ascii_strtod (load_bridge, NULL) == 0)
944 adaptor_init (NULL, NULL);
946 if (g_getenv ("AT_SPI_DEBUG"))
948 g_print ("Atk Accessibility bridge initialized\n");
954 gnome_accessibility_module_shutdown (void)
959 /*---------------------------------------------------------------------------*/
961 static gchar *name_match_tmpl =
962 "type='signal', interface='org.freedesktop.DBus', member='NameOwnerChanged', arg0='%s'";
965 spi_atk_add_client (const char *bus_name)
970 for (l = clients; l; l = l->next)
972 if (!g_strcmp0 (l->data, bus_name))
975 if (!clients && spi_global_app_data->events_initialized)
976 spi_atk_register_event_listeners ();
977 clients = g_slist_append (clients, g_strdup (bus_name));
978 match = g_strdup_printf (name_match_tmpl, bus_name);
979 dbus_bus_add_match (spi_global_app_data->bus, match, NULL);
984 spi_atk_remove_client (const char *bus_name)
994 if (!g_strcmp0 (l->data, bus_name))
996 gchar *match = g_strdup_printf (name_match_tmpl, l->data);
997 dbus_bus_remove_match (spi_global_app_data->bus, match, NULL);
1000 clients = g_slist_delete_link (clients, l);
1002 spi_atk_deregister_event_listeners ();
1009 /*END------------------------------------------------------------------------*/