2 * AT-SPI - Assistive Technology Service Provider Interface
3 * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
5 * Copyright 2001, 2002 Sun Microsystems Inc.,
6 * Copyright 2001, 2002 Ximian, Inc.
7 * Copyright 2010, 2011 Novell, 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.
27 * Basic SPI initialization and event loop function prototypes
31 #include "atspi-private.h"
35 #include "atspi-gmain.h"
39 static void handle_get_items (DBusPendingCall *pending, void *user_data);
41 static DBusConnection *bus = NULL;
42 static GHashTable *live_refs = NULL;
43 static gint method_call_timeout = 800;
44 static gint app_startup_time = 15000;
45 static gboolean allow_sync = TRUE;
47 GMainLoop *atspi_main_loop;
48 GMainContext *atspi_main_context;
49 gboolean atspi_no_cache;
51 const char *atspi_path_dec = ATSPI_DBUS_PATH_DEC;
52 const char *atspi_path_registry = ATSPI_DBUS_PATH_REGISTRY;
53 const char *atspi_path_root = ATSPI_DBUS_PATH_ROOT;
54 const char *atspi_bus_registry = ATSPI_DBUS_NAME_REGISTRY;
55 const char *atspi_interface_accessible = ATSPI_DBUS_INTERFACE_ACCESSIBLE;
56 const char *atspi_interface_action = ATSPI_DBUS_INTERFACE_ACTION;
57 const char *atspi_interface_application = ATSPI_DBUS_INTERFACE_APPLICATION;
58 const char *atspi_interface_collection = ATSPI_DBUS_INTERFACE_COLLECTION;
59 const char *atspi_interface_component = ATSPI_DBUS_INTERFACE_COMPONENT;
60 const char *atspi_interface_dec = ATSPI_DBUS_INTERFACE_DEC;
61 const char *atspi_interface_device_event_listener = ATSPI_DBUS_INTERFACE_DEVICE_EVENT_LISTENER;
62 const char *atspi_interface_document = ATSPI_DBUS_INTERFACE_DOCUMENT;
63 const char *atspi_interface_editable_text = ATSPI_DBUS_INTERFACE_EDITABLE_TEXT;
64 const char *atspi_interface_event_object = ATSPI_DBUS_INTERFACE_EVENT_OBJECT;
65 const char *atspi_interface_hyperlink = ATSPI_DBUS_INTERFACE_HYPERLINK;
66 const char *atspi_interface_hypertext = ATSPI_DBUS_INTERFACE_HYPERTEXT;
67 const char *atspi_interface_image = ATSPI_DBUS_INTERFACE_IMAGE;
68 const char *atspi_interface_registry = ATSPI_DBUS_INTERFACE_REGISTRY;
69 const char *atspi_interface_selection = ATSPI_DBUS_INTERFACE_SELECTION;
70 const char *atspi_interface_table = ATSPI_DBUS_INTERFACE_TABLE;
71 const char *atspi_interface_table_cell = ATSPI_DBUS_INTERFACE_TABLE_CELL;
72 const char *atspi_interface_text = ATSPI_DBUS_INTERFACE_TEXT;
73 const char *atspi_interface_cache = ATSPI_DBUS_INTERFACE_CACHE;
74 const char *atspi_interface_value = ATSPI_DBUS_INTERFACE_VALUE;
76 static const char *interfaces[] =
78 ATSPI_DBUS_INTERFACE_ACCESSIBLE,
79 ATSPI_DBUS_INTERFACE_ACTION,
80 ATSPI_DBUS_INTERFACE_APPLICATION,
81 ATSPI_DBUS_INTERFACE_COLLECTION,
82 ATSPI_DBUS_INTERFACE_COMPONENT,
83 ATSPI_DBUS_INTERFACE_DOCUMENT,
84 ATSPI_DBUS_INTERFACE_EDITABLE_TEXT,
85 ATSPI_DBUS_INTERFACE_HYPERLINK,
86 ATSPI_DBUS_INTERFACE_HYPERTEXT,
87 ATSPI_DBUS_INTERFACE_IMAGE,
88 "org.a11y.atspi.LoginHelper",
89 ATSPI_DBUS_INTERFACE_SELECTION,
90 ATSPI_DBUS_INTERFACE_TABLE,
91 ATSPI_DBUS_INTERFACE_TABLE_CELL,
92 ATSPI_DBUS_INTERFACE_TEXT,
93 ATSPI_DBUS_INTERFACE_VALUE,
98 _atspi_get_iface_num (const char *iface)
100 /* TODO: Use a binary search or hash to improve performance */
103 for (i = 0; interfaces[i]; i++)
105 if (!strcmp(iface, interfaces[i])) return i;
111 _atspi_get_live_refs (void)
115 live_refs = g_hash_table_new (g_direct_hash, g_direct_equal);
120 /* TODO: Add an application parameter */
127 g_error ("AT-SPI: Couldn't connect to accessibility bus. Is at-spi-bus-launcher running?");
131 #define APP_IS_REGISTRY(app) (!strcmp (app->bus_name, atspi_bus_registry))
133 static AtspiAccessible *desktop;
145 g_hash_table_destroy (refs);
150 dbus_connection_close (bus);
151 dbus_connection_unref (bus);
157 for (l = desktop->children; l;)
159 GList *next = l->next;
160 AtspiAccessible *child = l->data;
161 g_object_run_dispose (G_OBJECT (child->parent.app));
162 g_object_run_dispose (G_OBJECT (child));
165 g_object_run_dispose (G_OBJECT (desktop->parent.app));
166 g_object_unref (desktop);
170 static gboolean atspi_inited = FALSE;
172 static GHashTable *app_hash = NULL;
175 handle_get_bus_address (DBusPendingCall *pending, void *user_data)
177 AtspiApplication *app = user_data;
178 DBusMessage *reply = dbus_pending_call_steal_reply (pending);
179 DBusMessage *message;
181 DBusPendingCall *new_pending;
184 if (dbus_message_get_type (reply) == DBUS_MESSAGE_TYPE_METHOD_RETURN)
186 if (dbus_message_get_args (reply, NULL, DBUS_TYPE_STRING, &address,
187 DBUS_TYPE_INVALID) && address [0])
192 dbus_error_init (&error);
193 bus = dbus_connection_open_private (address, &error);
198 dbus_connection_unref (app->bus);
204 g_warning ("Unable to open bus connection: %s", error.message);
205 dbus_error_free (&error);
209 dbus_message_unref (reply);
210 dbus_pending_call_unref (pending);
213 return; /* application has gone away / been disposed */
215 message = dbus_message_new_method_call (app->bus_name,
216 "/org/a11y/atspi/cache",
217 atspi_interface_cache, "GetItems");
219 result = dbus_connection_send_with_reply (app->bus, message, &new_pending, 2000);
220 dbus_message_unref (message);
221 if (!result || !new_pending)
223 dbus_pending_call_set_notify (new_pending, handle_get_items, app, NULL);
226 static AtspiApplication *
227 get_application (const char *bus_name)
229 AtspiApplication *app = NULL;
231 DBusMessage *message;
232 DBusPendingCall *pending = NULL;
237 app_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify)g_object_unref);
238 if (!app_hash) return NULL;
240 app = g_hash_table_lookup (app_hash, bus_name);
242 bus_name_dup = g_strdup (bus_name);
243 if (!bus_name_dup) return NULL;
244 // TODO: change below to something that will send state-change:defunct notification if necessary */
245 app = _atspi_application_new (bus_name);
246 app->hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
247 app->bus = dbus_connection_ref (_atspi_bus ());
248 gettimeofday (&app->time_added, NULL);
249 app->cache = ATSPI_CACHE_UNDEFINED;
250 g_hash_table_insert (app_hash, bus_name_dup, app);
251 message = dbus_message_new_method_call (bus_name, atspi_path_root,
252 atspi_interface_application, "GetApplicationBusAddress");
254 result = dbus_connection_send_with_reply (app->bus, message, &pending, 2000);
255 dbus_message_unref (message);
256 if (!result || !pending)
258 g_hash_table_remove (app_hash, bus_name_dup);
261 dbus_pending_call_set_notify (pending, handle_get_bus_address, app, NULL);
266 ref_accessible (const char *app_name, const char *path)
268 AtspiApplication *app;
271 if (!strcmp (path, ATSPI_DBUS_PATH_NULL))
274 app = get_application (app_name);
276 if (!strcmp (path, "/org/a11y/atspi/accessible/root"))
280 app->root = _atspi_accessible_new (app, atspi_path_root);
281 app->root->accessible_parent = atspi_get_desktop (0);
282 app->root->accessible_parent->children = g_list_append (app->root->accessible_parent->children, g_object_ref (app->root));
284 return g_object_ref (app->root);
287 a = g_hash_table_lookup (app->hash, path);
290 return g_object_ref (a);
292 a = _atspi_accessible_new (app, path);
295 g_hash_table_insert (app->hash, g_strdup (a->parent.path), g_object_ref (a));
299 static AtspiHyperlink *
300 ref_hyperlink (const char *app_name, const char *path)
302 AtspiApplication *app = get_application (app_name);
303 AtspiHyperlink *hyperlink;
305 if (!strcmp (path, ATSPI_DBUS_PATH_NULL))
308 hyperlink = g_hash_table_lookup (app->hash, path);
311 return g_object_ref (hyperlink);
313 hyperlink = _atspi_hyperlink_new (app, path);
314 g_hash_table_insert (app->hash, g_strdup (hyperlink->parent.path), hyperlink);
315 /* TODO: This should be a weak ref */
316 g_object_ref (hyperlink); /* for the hash */
329 GArray *state_bitflags;
332 static DBusHandlerResult
333 handle_remove_accessible (DBusConnection *bus, DBusMessage *message, void *user_data)
335 const char *sender = dbus_message_get_sender (message);
336 AtspiApplication *app;
338 DBusMessageIter iter, iter_struct;
339 const char *signature = dbus_message_get_signature (message);
342 if (strcmp (signature, "(so)") != 0)
344 g_warning ("AT-SPI: Unknown signature %s for RemoveAccessible", signature);
345 return DBUS_HANDLER_RESULT_HANDLED;
348 dbus_message_iter_init (message, &iter);
349 dbus_message_iter_recurse (&iter, &iter_struct);
350 dbus_message_iter_get_basic (&iter_struct, &sender);
351 dbus_message_iter_next (&iter_struct);
352 dbus_message_iter_get_basic (&iter_struct, &path);
353 app = get_application (sender);
354 a = ref_accessible (sender, path);
356 return DBUS_HANDLER_RESULT_HANDLED;
357 g_object_run_dispose (G_OBJECT (a));
358 g_hash_table_remove (app->hash, a->parent.path);
359 g_object_unref (a); /* unref our own ref */
360 return DBUS_HANDLER_RESULT_HANDLED;
363 static DBusHandlerResult
364 handle_name_owner_changed (DBusConnection *bus, DBusMessage *message, void *user_data)
366 const char *name, *new, *old;
367 static gboolean registry_lost = FALSE;
369 if (!dbus_message_get_args (message, NULL,
370 DBUS_TYPE_STRING, &name,
371 DBUS_TYPE_STRING, &old,
372 DBUS_TYPE_STRING, &new,
375 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
378 if (!strcmp (name, "org.a11y.atspi.Registry"))
380 if (registry_lost && !old[0])
382 _atspi_reregister_event_listeners ();
383 _atspi_reregister_device_listeners ();
384 registry_lost = FALSE;
387 registry_lost = TRUE;
391 AtspiApplication *app = g_hash_table_lookup (app_hash, old);
392 if (app && app->bus_name && !strcmp(app->bus_name, name))
393 g_object_run_dispose (G_OBJECT (app));
395 return DBUS_HANDLER_RESULT_HANDLED;
399 add_app_to_desktop (AtspiAccessible *a, const char *bus_name)
401 AtspiAccessible *obj = ref_accessible (bus_name, atspi_path_root);
402 /* The app will be added to the desktop as a side-effect of calling
404 g_object_unref (obj);
405 return (obj != NULL);
409 get_reference_from_iter (DBusMessageIter *iter, const char **app_name, const char **path)
411 DBusMessageIter iter_struct;
413 dbus_message_iter_recurse (iter, &iter_struct);
414 dbus_message_iter_get_basic (&iter_struct, app_name);
415 dbus_message_iter_next (&iter_struct);
416 dbus_message_iter_get_basic (&iter_struct, path);
417 dbus_message_iter_next (iter);
421 add_accessible_from_iter (DBusMessageIter *iter)
423 DBusMessageIter iter_struct, iter_array;
424 const char *app_name, *path;
425 AtspiAccessible *accessible;
426 const char *name, *description;
429 dbus_message_iter_recurse (iter, &iter_struct);
432 get_reference_from_iter (&iter_struct, &app_name, &path);
433 accessible = ref_accessible (app_name, path);
437 /* Get application: TODO */
438 dbus_message_iter_next (&iter_struct);
441 get_reference_from_iter (&iter_struct, &app_name, &path);
442 if (accessible->accessible_parent)
443 g_object_unref (accessible->accessible_parent);
444 accessible->accessible_parent = ref_accessible (app_name, path);
447 while (accessible->children)
449 g_object_unref (accessible->children->data);
450 accessible->children = g_list_remove (accessible->children, accessible->children->data);
452 dbus_message_iter_recurse (&iter_struct, &iter_array);
453 while (dbus_message_iter_get_arg_type (&iter_array) != DBUS_TYPE_INVALID)
455 AtspiAccessible *child;
456 get_reference_from_iter (&iter_array, &app_name, &path);
457 child = ref_accessible (app_name, path);
458 accessible->children = g_list_append (accessible->children, child);
462 dbus_message_iter_next (&iter_struct);
463 _atspi_dbus_set_interfaces (accessible, &iter_struct);
464 dbus_message_iter_next (&iter_struct);
467 if (accessible->name)
468 g_free (accessible->name);
469 dbus_message_iter_get_basic (&iter_struct, &name);
470 accessible->name = g_strdup (name);
471 dbus_message_iter_next (&iter_struct);
474 dbus_message_iter_get_basic (&iter_struct, &role);
475 accessible->role = role;
476 dbus_message_iter_next (&iter_struct);
479 if (accessible->description)
480 g_free (accessible->description);
481 dbus_message_iter_get_basic (&iter_struct, &description);
482 accessible->description = g_strdup (description);
483 dbus_message_iter_next (&iter_struct);
485 _atspi_dbus_set_state (accessible, &iter_struct);
486 dbus_message_iter_next (&iter_struct);
488 _atspi_accessible_add_cache (accessible, ATSPI_CACHE_NAME | ATSPI_CACHE_ROLE |
489 ATSPI_CACHE_PARENT | ATSPI_CACHE_DESCRIPTION);
490 if (!atspi_state_set_contains (accessible->states,
491 ATSPI_STATE_MANAGES_DESCENDANTS))
492 _atspi_accessible_add_cache (accessible, ATSPI_CACHE_CHILDREN);
494 /* This is a bit of a hack since the cache holds a ref, so we don't need
495 * the one provided for us anymore */
496 g_object_unref (accessible);
500 handle_get_items (DBusPendingCall *pending, void *user_data)
502 DBusMessage *reply = dbus_pending_call_steal_reply (pending);
503 DBusMessageIter iter, iter_array;
505 if (dbus_message_get_type (reply) == DBUS_MESSAGE_TYPE_ERROR)
507 const char *sender = dbus_message_get_sender (reply);
508 const char *error = NULL;
509 dbus_message_get_args (reply, NULL, DBUS_TYPE_STRING, &error,
511 g_warning ("AT-SPI: Error in GetItems, sender=%s, error=%s", sender, error);
512 dbus_message_unref (reply);
513 dbus_pending_call_unref (pending);
517 dbus_message_iter_init (reply, &iter);
518 dbus_message_iter_recurse (&iter, &iter_array);
519 while (dbus_message_iter_get_arg_type (&iter_array) != DBUS_TYPE_INVALID)
521 add_accessible_from_iter (&iter_array);
522 dbus_message_iter_next (&iter_array);
524 dbus_message_unref (reply);
525 dbus_pending_call_unref (pending);
528 /* TODO: Do we stil need this function? */
529 static AtspiAccessible *
530 ref_accessible_desktop (AtspiApplication *app)
533 DBusMessage *message, *reply;
534 DBusMessageIter iter, iter_array;
539 g_object_ref (desktop);
542 desktop = _atspi_accessible_new (app, atspi_path_root);
547 g_hash_table_insert (app->hash, g_strdup (desktop->parent.path),
548 g_object_ref (desktop));
549 app->root = g_object_ref (desktop);
550 desktop->name = g_strdup ("main");
551 message = dbus_message_new_method_call (atspi_bus_registry,
553 atspi_interface_accessible,
558 reply = _atspi_dbus_send_with_reply_and_block (message, &error);
559 if (!reply || strcmp (dbus_message_get_signature (reply), "a(so)") != 0)
563 g_warning ("Couldn't get application list: %s", error->message);
564 g_clear_error (&error);
567 dbus_message_unref (reply);
570 dbus_message_iter_init (reply, &iter);
571 dbus_message_iter_recurse (&iter, &iter_array);
572 while (dbus_message_iter_get_arg_type (&iter_array) != DBUS_TYPE_INVALID)
574 const char *app_name, *path;
575 get_reference_from_iter (&iter_array, &app_name, &path);
576 add_app_to_desktop (desktop, app_name);
578 dbus_message_unref (reply);
580 /* Record the alternate name as an alias for org.a11y.atspi.Registry */
581 bus_name_dup = g_strdup (dbus_message_get_sender (reply));
583 g_hash_table_insert (app_hash, bus_name_dup, app);
585 return g_object_ref (desktop);
589 _atspi_ref_accessible (const char *app, const char *path)
591 AtspiApplication *a = get_application (app);
594 if ( APP_IS_REGISTRY(a))
597 g_object_unref (ref_accessible_desktop (a)); /* sets a->root */
598 return g_object_ref (a->root);
600 return ref_accessible (app, path);
604 _atspi_dbus_return_accessible_from_message (DBusMessage *message)
606 DBusMessageIter iter;
607 AtspiAccessible *retval = NULL;
608 const char *signature;
613 signature = dbus_message_get_signature (message);
614 if (!strcmp (signature, "(so)"))
616 dbus_message_iter_init (message, &iter);
617 retval = _atspi_dbus_return_accessible_from_iter (&iter);
621 g_warning ("AT-SPI: Called _atspi_dbus_return_accessible_from_message with strange signature %s", signature);
623 dbus_message_unref (message);
628 _atspi_dbus_return_accessible_from_iter (DBusMessageIter *iter)
630 const char *app_name, *path;
632 get_reference_from_iter (iter, &app_name, &path);
633 return ref_accessible (app_name, path);
637 _atspi_dbus_return_hyperlink_from_message (DBusMessage *message)
639 DBusMessageIter iter;
640 AtspiHyperlink *retval = NULL;
641 const char *signature;
646 signature = dbus_message_get_signature (message);
647 if (!strcmp (signature, "(so)"))
649 dbus_message_iter_init (message, &iter);
650 retval = _atspi_dbus_return_hyperlink_from_iter (&iter);
654 g_warning ("AT-SPI: Called _atspi_dbus_return_hyperlink_from_message with strange signature %s", signature);
656 dbus_message_unref (message);
661 _atspi_dbus_return_hyperlink_from_iter (DBusMessageIter *iter)
663 const char *app_name, *path;
665 get_reference_from_iter (iter, &app_name, &path);
666 return ref_hyperlink (app_name, path);
669 const char *cache_signal_type = "((so)(so)(so)a(so)assusau)";
671 static DBusHandlerResult
672 handle_add_accessible (DBusConnection *bus, DBusMessage *message, void *user_data)
674 DBusMessageIter iter;
676 if (strcmp (dbus_message_get_signature (message), cache_signal_type) != 0)
678 g_warning ("AT-SPI: AddAccessible with unknown signature %s\n",
679 dbus_message_get_signature (message));
680 return DBUS_HANDLER_RESULT_HANDLED;
683 dbus_message_iter_init (message, &iter);
684 add_accessible_from_iter (&iter);
685 return DBUS_HANDLER_RESULT_HANDLED;
691 DBusMessage *message;
695 static GSource *process_deferred_messages_source = NULL;
698 process_deferred_message (BusDataClosure *closure)
700 int type = dbus_message_get_type (closure->message);
701 const char *interface = dbus_message_get_interface (closure->message);
703 if (type == DBUS_MESSAGE_TYPE_SIGNAL &&
704 !strncmp (interface, "org.a11y.atspi.Event.", 21))
706 _atspi_dbus_handle_event (closure->bus, closure->message, closure->data);
708 if (dbus_message_is_method_call (closure->message, atspi_interface_device_event_listener, "NotifyEvent"))
710 _atspi_dbus_handle_DeviceEvent (closure->bus,
711 closure->message, closure->data);
713 if (dbus_message_is_signal (closure->message, atspi_interface_cache, "AddAccessible"))
715 handle_add_accessible (closure->bus, closure->message, closure->data);
717 if (dbus_message_is_signal (closure->message, atspi_interface_cache, "RemoveAccessible"))
719 handle_remove_accessible (closure->bus, closure->message, closure->data);
721 if (dbus_message_is_signal (closure->message, "org.freedesktop.DBus", "NameOwnerChanged"))
723 handle_name_owner_changed (closure->bus, closure->message, closure->data);
727 static GQueue *deferred_messages = NULL;
730 process_deferred_messages (void)
732 static int in_process_deferred_messages = 0;
733 BusDataClosure *closure;
735 if (in_process_deferred_messages)
737 in_process_deferred_messages = 1;
738 while ((closure = g_queue_pop_head (deferred_messages)))
740 process_deferred_message (closure);
741 dbus_message_unref (closure->message);
742 dbus_connection_unref (closure->bus);
745 in_process_deferred_messages = 0;
750 process_deferred_messages_callback (gpointer data)
752 if (process_deferred_messages ())
753 return G_SOURCE_CONTINUE;
755 process_deferred_messages_source = NULL;
756 return G_SOURCE_REMOVE;
759 static DBusHandlerResult
760 defer_message (DBusConnection *connection, DBusMessage *message, void *user_data)
762 BusDataClosure *closure = g_new (BusDataClosure, 1);
764 closure->bus = dbus_connection_ref (bus);
765 closure->message = dbus_message_ref (message);
766 closure->data = user_data;
768 g_queue_push_tail (deferred_messages, closure);
770 if (process_deferred_messages_source == NULL)
772 process_deferred_messages_source = g_idle_source_new ();
773 g_source_set_callback (process_deferred_messages_source,
774 process_deferred_messages_callback, NULL, NULL);
775 g_source_attach (process_deferred_messages_source, atspi_main_context);
776 g_source_unref (process_deferred_messages_source);
779 return DBUS_HANDLER_RESULT_HANDLED;
782 static DBusHandlerResult
783 atspi_dbus_filter (DBusConnection *bus, DBusMessage *message, void *data)
785 int type = dbus_message_get_type (message);
786 const char *interface = dbus_message_get_interface (message);
788 if (type == DBUS_MESSAGE_TYPE_SIGNAL &&
789 !strncmp (interface, "org.a11y.atspi.Event.", 21))
791 return defer_message (bus, message, data);
793 if (dbus_message_is_method_call (message, atspi_interface_device_event_listener, "NotifyEvent"))
795 return defer_message (bus, message, data);
797 if (dbus_message_is_signal (message, atspi_interface_cache, "AddAccessible"))
799 return defer_message (bus, message, data);
801 if (dbus_message_is_signal (message, atspi_interface_cache, "RemoveAccessible"))
803 return defer_message (bus, message, data);
805 if (dbus_message_is_signal (message, "org.freedesktop.DBus", "NameOwnerChanged"))
807 defer_message (bus, message, data);
808 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
810 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
814 * Returns a 'canonicalized' value for DISPLAY,
815 * with the screen number stripped off if present.
817 * TODO: Avoid having duplicate functions for this here and in at-spi2-atk
820 spi_display_name (void)
822 char *canonical_display_name = NULL;
823 const gchar *display_env = g_getenv ("AT_SPI_DISPLAY");
827 display_env = g_getenv ("DISPLAY");
828 if (!display_env || !display_env[0])
832 gchar *display_p, *screen_p;
833 canonical_display_name = g_strdup (display_env);
834 display_p = g_utf8_strrchr (canonical_display_name, -1, ':');
835 screen_p = g_utf8_strrchr (canonical_display_name, -1, '.');
836 if (screen_p && display_p && (screen_p > display_p))
844 canonical_display_name = g_strdup (display_env);
847 return canonical_display_name;
853 * Connects to the accessibility registry and initializes the SPI.
855 * Returns: 0 on success, 1 if already initialized, or an integer error code.
861 const gchar *no_cache;
870 _atspi_get_live_refs();
872 bus = atspi_get_a11y_bus ();
875 dbus_bus_register (bus, NULL);
876 atspi_dbus_connection_setup_with_g_main(bus, g_main_context_default());
877 dbus_connection_add_filter (bus, atspi_dbus_filter, NULL, NULL);
878 match = g_strdup_printf ("type='signal',interface='%s',member='AddAccessible'", atspi_interface_cache);
879 dbus_bus_add_match (bus, match, NULL);
881 match = g_strdup_printf ("type='signal',interface='%s',member='RemoveAccessible'", atspi_interface_cache);
882 dbus_bus_add_match (bus, match, NULL);
884 match = g_strdup_printf ("type='signal',interface='%s',member='ChildrenChanged'", atspi_interface_event_object);
885 dbus_bus_add_match (bus, match, NULL);
887 match = g_strdup_printf ("type='signal',interface='%s',member='PropertyChange'", atspi_interface_event_object);
888 dbus_bus_add_match (bus, match, NULL);
890 match = g_strdup_printf ("type='signal',interface='%s',member='StateChanged'", atspi_interface_event_object);
891 dbus_bus_add_match (bus, match, NULL);
894 dbus_bus_add_match (bus,
895 "type='signal', interface='org.freedesktop.DBus', member='NameOwnerChanged'",
898 no_cache = g_getenv ("ATSPI_NO_CACHE");
899 if (no_cache && g_strcmp0 (no_cache, "0") != 0)
900 atspi_no_cache = TRUE;
902 deferred_messages = g_queue_new ();
908 * atspi_is_initialized:
910 * Indicates whether AT-SPI has been initialized.
912 * Returns: %True if initialized; %False otherwise.
915 atspi_is_initialized ()
923 * Starts/enters the main event loop for the AT-SPI services.
925 * NOTE: This method does not return control; it is exited via a call to
926 * #atspi_event_quit from within an event handler.
930 atspi_event_main (void)
932 atspi_main_loop = g_main_loop_new (NULL, FALSE);
933 g_main_loop_run (atspi_main_loop);
934 atspi_main_loop = NULL;
940 * Quits the last main event loop for the AT-SPI services,
941 * See: #atspi_event_main
944 atspi_event_quit (void)
946 g_main_loop_quit (atspi_main_loop);
952 * Disconnects from #AtspiRegistry instances and releases
953 * any floating resources. Call only once at exit.
955 * Returns: 0 if there were no leaks, otherwise other integer values.
967 atspi_inited = FALSE;
971 leaked = g_hash_table_size (live_refs);
983 static GSList *hung_processes;
986 remove_hung_process (DBusPendingCall *pending, void *data)
989 hung_processes = g_slist_remove (hung_processes, data);
991 dbus_pending_call_unref (pending);
995 check_for_hang (DBusMessage *message, DBusError *error, DBusConnection *bus, const char *bus_name)
997 if (!message && error->name &&
998 !strcmp (error->name, "org.freedesktop.DBus.Error.NoReply"))
1001 DBusMessage *message;
1002 gchar *bus_name_dup;
1003 DBusPendingCall *pending = NULL;
1005 for (l = hung_processes; l; l = l->next)
1006 if (!strcmp (l->data, bus_name))
1008 message = dbus_message_new_method_call (bus_name, "/",
1009 "org.freedesktop.DBus.Peer",
1013 result = dbus_connection_send_with_reply (bus, message, &pending, -1);
1014 dbus_message_unref (message);
1015 if (!result || !pending)
1017 bus_name_dup = g_strdup (bus_name);
1018 hung_processes = g_slist_append (hung_processes, bus_name_dup);
1019 dbus_pending_call_set_notify (pending, remove_hung_process, bus_name_dup, NULL);
1024 connection_is_hung (const char *bus_name)
1028 for (l = hung_processes; l; l = l->next)
1029 if (!strcmp (l->data, bus_name))
1035 check_app (AtspiApplication *app, GError **error)
1037 if (!app || !app->bus)
1039 g_set_error_literal (error, ATSPI_ERROR, ATSPI_ERROR_APPLICATION_GONE,
1040 _("The application no longer exists"));
1044 if (atspi_main_loop && connection_is_hung (app->bus_name))
1046 g_set_error_literal (error, ATSPI_ERROR, ATSPI_ERROR_IPC,
1047 "The process appears to be hung.");
1055 set_timeout (AtspiApplication *app)
1060 if (app && app_startup_time > 0)
1062 gettimeofday (&tv, NULL);
1063 diff = (tv.tv_sec - app->time_added.tv_sec) * 1000 + (tv.tv_usec - app->time_added.tv_usec) / 1000;
1064 dbind_set_timeout (MAX(method_call_timeout, app_startup_time - diff));
1067 dbind_set_timeout (method_call_timeout);
1071 _atspi_dbus_call (gpointer obj, const char *interface, const char *method, GError **error, const char *type, ...)
1076 AtspiObject *aobj = ATSPI_OBJECT (obj);
1078 if (!check_app (aobj->app, error))
1083 _atspi_set_error_no_sync (error);
1087 va_start (args, type);
1088 dbus_error_init (&err);
1089 set_timeout (aobj->app);
1090 retval = dbind_method_call_reentrant_va (aobj->app->bus, aobj->app->bus_name,
1091 aobj->path, interface, method, &err,
1094 check_for_hang (NULL, &err, aobj->app->bus, aobj->app->bus_name);
1095 process_deferred_messages ();
1096 if (dbus_error_is_set (&err))
1098 g_set_error(error, ATSPI_ERROR, ATSPI_ERROR_IPC, "%s", err.message);
1099 dbus_error_free (&err);
1105 _atspi_dbus_call_partial (gpointer obj,
1106 const char *interface,
1109 const char *type, ...)
1112 DBusMessage * result;
1113 va_start (args, type);
1114 result = _atspi_dbus_call_partial_va (obj, interface, method, error, type, args);
1121 _atspi_dbus_call_partial_va (gpointer obj,
1122 const char *interface,
1128 AtspiObject *aobj = ATSPI_OBJECT (obj);
1130 DBusMessage *msg = NULL, *reply = NULL;
1131 DBusMessageIter iter;
1134 dbus_error_init (&err);
1136 if (!check_app (aobj->app, error))
1139 msg = dbus_message_new_method_call (aobj->app->bus_name, aobj->path, interface, method);
1144 dbus_message_iter_init_append (msg, &iter);
1145 dbind_any_marshal_va (&iter, &p, args);
1147 set_timeout (aobj->app);
1148 reply = dbind_send_and_allow_reentry (aobj->app->bus, msg, &err);
1149 check_for_hang (reply, &err, aobj->app->bus, aobj->app->bus_name);
1153 dbus_message_unref (msg);
1154 process_deferred_messages ();
1155 if (dbus_error_is_set (&err))
1157 g_set_error_literal(error, ATSPI_ERROR, ATSPI_ERROR_IPC, err.message);
1158 dbus_error_free (&err);
1160 dbus_message_unref(reply);
1163 else if (reply && dbus_message_get_type(reply) == DBUS_MESSAGE_TYPE_ERROR)
1165 const char *err_str = NULL;
1166 dbus_message_get_args (reply, NULL, DBUS_TYPE_STRING, &err_str, DBUS_TYPE_INVALID);
1168 g_set_error_literal (error, ATSPI_ERROR, ATSPI_ERROR_IPC, err_str);
1169 dbus_message_unref (reply);
1176 _atspi_dbus_get_property (gpointer obj, const char *interface, const char *name, GError **error, const char *type, void *data)
1178 DBusMessage *message, *reply;
1179 DBusMessageIter iter, iter_variant;
1181 dbus_bool_t retval = FALSE;
1182 AtspiObject *aobj = ATSPI_OBJECT (obj);
1183 char expected_type = (type [0] == '(' ? 'r' : type [0]);
1188 if (!check_app (aobj->app, error))
1193 _atspi_set_error_no_sync (error);
1197 message = dbus_message_new_method_call (aobj->app->bus_name,
1199 "org.freedesktop.DBus.Properties",
1203 // TODO: throw exception
1206 dbus_message_append_args (message, DBUS_TYPE_STRING, &interface, DBUS_TYPE_STRING, &name, DBUS_TYPE_INVALID);
1207 dbus_error_init (&err);
1208 set_timeout (aobj->app);
1209 reply = dbind_send_and_allow_reentry (aobj->app->bus, message, &err);
1210 check_for_hang (reply, &err, aobj->app->bus, aobj->app->bus_name);
1211 dbus_message_unref (message);
1212 process_deferred_messages ();
1215 // TODO: throw exception
1219 if (dbus_message_get_type (reply) == DBUS_MESSAGE_TYPE_ERROR)
1221 const char *err_str = NULL;
1222 dbus_message_get_args (reply, NULL, DBUS_TYPE_STRING, &err_str, DBUS_TYPE_INVALID);
1224 g_set_error_literal (error, ATSPI_ERROR, ATSPI_ERROR_IPC, err_str);
1228 dbus_message_iter_init (reply, &iter);
1229 if (dbus_message_iter_get_arg_type (&iter) != 'v')
1231 g_warning ("AT-SPI: expected a variant when fetching %s from interface %s; got %s\n", name, interface, dbus_message_get_signature (reply));
1234 dbus_message_iter_recurse (&iter, &iter_variant);
1235 if (dbus_message_iter_get_arg_type (&iter_variant) != expected_type)
1237 g_warning ("atspi_dbus_get_property: Wrong type: expected %s, got %c\n", type, dbus_message_iter_get_arg_type (&iter_variant));
1240 if (!strcmp (type, "(so)"))
1242 *((AtspiAccessible **)data) = _atspi_dbus_return_accessible_from_iter (&iter_variant);
1246 dbus_message_iter_get_basic (&iter_variant, data);
1247 if (type [0] == 's')
1248 *(char **)data = g_strdup (*(char **)data);
1252 dbus_error_free (&err);
1254 dbus_message_unref (reply);
1259 _atspi_dbus_send_with_reply_and_block (DBusMessage *message, GError **error)
1263 AtspiApplication *app;
1264 DBusConnection *bus;
1266 app = get_application (dbus_message_get_destination (message));
1268 if (app && !app->bus)
1269 return NULL; /* will fail anyway; app has been disposed */
1271 bus = (app ? app->bus : _atspi_bus());
1272 dbus_error_init (&err);
1274 reply = dbind_send_and_allow_reentry (bus, message, &err);
1275 process_deferred_messages ();
1276 dbus_message_unref (message);
1277 if (dbus_error_is_set (&err))
1280 g_set_error_literal (error, ATSPI_ERROR, ATSPI_ERROR_IPC, err.message);
1281 dbus_error_free (&err);
1287 _atspi_dbus_return_hash_from_message (DBusMessage *message)
1289 DBusMessageIter iter;
1295 _ATSPI_DBUS_CHECK_SIG (message, "a{ss}", NULL, NULL);
1297 dbus_message_iter_init (message, &iter);
1298 ret = _atspi_dbus_hash_from_iter (&iter);
1299 dbus_message_unref (message);
1304 _atspi_dbus_hash_from_iter (DBusMessageIter *iter)
1306 GHashTable *hash = g_hash_table_new_full (g_str_hash, g_str_equal,
1307 (GDestroyNotify) g_free,
1308 (GDestroyNotify) g_free);
1309 DBusMessageIter iter_array, iter_dict;
1311 dbus_message_iter_recurse (iter, &iter_array);
1312 while (dbus_message_iter_get_arg_type (&iter_array) != DBUS_TYPE_INVALID)
1314 const char *name, *value;
1315 dbus_message_iter_recurse (&iter_array, &iter_dict);
1316 dbus_message_iter_get_basic (&iter_dict, &name);
1317 dbus_message_iter_next (&iter_dict);
1318 dbus_message_iter_get_basic (&iter_dict, &value);
1319 g_hash_table_insert (hash, g_strdup (name), g_strdup (value));
1320 dbus_message_iter_next (&iter_array);
1326 _atspi_dbus_return_attribute_array_from_message (DBusMessage *message)
1328 DBusMessageIter iter;
1334 _ATSPI_DBUS_CHECK_SIG (message, "a{ss}", NULL, NULL);
1336 dbus_message_iter_init (message, &iter);
1338 ret = _atspi_dbus_attribute_array_from_iter (&iter);
1339 dbus_message_unref (message);
1344 _atspi_dbus_attribute_array_from_iter (DBusMessageIter *iter)
1346 DBusMessageIter iter_array, iter_dict;
1347 GArray *array = g_array_new (TRUE, TRUE, sizeof (gchar *));
1349 dbus_message_iter_recurse (iter, &iter_array);
1350 while (dbus_message_iter_get_arg_type (&iter_array) != DBUS_TYPE_INVALID)
1352 const char *name, *value;
1354 dbus_message_iter_recurse (&iter_array, &iter_dict);
1355 dbus_message_iter_get_basic (&iter_dict, &name);
1356 dbus_message_iter_next (&iter_dict);
1357 dbus_message_iter_get_basic (&iter_dict, &value);
1358 str = g_strdup_printf ("%s:%s", name, value);
1359 array = g_array_append_val (array, str);
1360 dbus_message_iter_next (&iter_array);;
1366 _atspi_dbus_set_interfaces (AtspiAccessible *accessible, DBusMessageIter *iter)
1368 DBusMessageIter iter_array;
1369 char *iter_sig = dbus_message_iter_get_signature (iter);
1371 accessible->interfaces = 0;
1372 if (strcmp (iter_sig, "as") != 0)
1374 g_warning ("_atspi_dbus_set_interfaces: Passed iterator with invalid signature %s", dbus_message_iter_get_signature (iter));
1375 dbus_free (iter_sig);
1378 dbus_free (iter_sig);
1379 dbus_message_iter_recurse (iter, &iter_array);
1380 while (dbus_message_iter_get_arg_type (&iter_array) != DBUS_TYPE_INVALID)
1384 dbus_message_iter_get_basic (&iter_array, &iface);
1385 if (!strcmp (iface, "org.freedesktop.DBus.Introspectable")) continue;
1386 n = _atspi_get_iface_num (iface);
1389 g_warning ("AT-SPI: Unknown interface %s", iface);
1392 accessible->interfaces |= (1 << n);
1393 dbus_message_iter_next (&iter_array);
1395 _atspi_accessible_add_cache (accessible, ATSPI_CACHE_INTERFACES);
1399 _atspi_dbus_set_state (AtspiAccessible *accessible, DBusMessageIter *iter)
1401 DBusMessageIter iter_array;
1403 dbus_uint32_t *states;
1405 dbus_message_iter_recurse (iter, &iter_array);
1406 dbus_message_iter_get_fixed_array (&iter_array, &states, &count);
1409 g_warning ("AT-SPI: expected 2 values in states array; got %d\n", count);
1410 if (!accessible->states)
1411 accessible->states = _atspi_state_set_new_internal (accessible, 0);
1415 guint64 val = ((guint64)states [1]) << 32;
1417 if (!accessible->states)
1418 accessible->states = _atspi_state_set_new_internal (accessible, val);
1420 accessible->states->states = val;
1422 _atspi_accessible_add_cache (accessible, ATSPI_CACHE_STATES);
1426 _atspi_error_quark (void)
1428 return g_quark_from_static_string ("atspi_error");
1432 * Gets the IOR from the XDisplay.
1436 get_accessibility_bus_address_x11 (void)
1440 Display *bridge_display = NULL;
1443 unsigned char *data_x11 = NULL;
1444 unsigned long nitems;
1445 unsigned long leftover;
1448 display_name = spi_display_name ();
1452 bridge_display = XOpenDisplay (display_name);
1453 g_free (display_name);
1455 if (!bridge_display)
1457 g_warning ("Could not open X display");
1461 AT_SPI_BUS = XInternAtom (bridge_display, "AT_SPI_BUS", False);
1462 XGetWindowProperty (bridge_display,
1463 XDefaultRootWindow (bridge_display),
1465 (long) BUFSIZ, False,
1466 (Atom) 31, &actual_type, &actual_format,
1467 &nitems, &leftover, &data_x11);
1468 XCloseDisplay (bridge_display);
1470 data = g_strdup ((gchar *)data_x11);
1477 get_accessibility_bus_address_dbus (void)
1479 DBusConnection *session_bus = NULL;
1480 DBusMessage *message;
1483 char *address = NULL;
1485 session_bus = dbus_bus_get (DBUS_BUS_SESSION, NULL);
1489 message = dbus_message_new_method_call ("org.a11y.Bus",
1494 dbus_error_init (&error);
1495 reply = dbus_connection_send_with_reply_and_block (session_bus,
1499 dbus_message_unref (message);
1503 g_warning ("Error retrieving accessibility bus address: %s: %s",
1504 error.name, error.message);
1505 dbus_error_free (&error);
1510 const char *tmp_address;
1511 if (!dbus_message_get_args (reply,
1517 dbus_message_unref (reply);
1520 address = g_strdup (tmp_address);
1521 dbus_message_unref (reply);
1525 dbus_connection_unref (session_bus);
1529 static DBusConnection *a11y_bus;
1530 static dbus_int32_t a11y_dbus_slot = -1;
1533 a11y_bus_free (void *data)
1535 if (data == a11y_bus)
1538 dbus_connection_free_data_slot (&a11y_dbus_slot);
1543 * atspi_get_a11y_bus: (skip)
1546 atspi_get_a11y_bus (void)
1549 char *address = NULL;
1551 if (a11y_bus && dbus_connection_get_is_connected (a11y_bus))
1554 if (a11y_dbus_slot == -1)
1555 if (!dbus_connection_allocate_data_slot (&a11y_dbus_slot))
1556 g_warning ("at-spi: Unable to allocate D-Bus slot");
1559 address = get_accessibility_bus_address_x11 ();
1562 address = get_accessibility_bus_address_dbus ();
1566 dbus_error_init (&error);
1567 a11y_bus = dbus_connection_open_private (address, &error);
1572 g_warning ("Couldn't connect to accessibility bus: %s", error.message);
1573 dbus_error_free (&error);
1578 if (!dbus_bus_register (a11y_bus, &error))
1580 g_warning ("Couldn't register with accessibility bus: %s", error.message);
1581 dbus_error_free (&error);
1582 dbus_connection_close (a11y_bus);
1583 dbus_connection_unref (a11y_bus);
1589 /* Simulate a weak ref on the bus */
1590 dbus_connection_set_data (a11y_bus, a11y_dbus_slot, a11y_bus, a11y_bus_free);
1596 * atspi_set_timeout:
1597 * @val: The timeout value, in milliseconds, or -1 to disable the timeout.
1598 * @startup_time: The amount of time, in milliseconds, to allow to pass
1599 * before enforcing timeouts on an application. Can be used to prevent
1600 * timeout exceptions if an application is likely to block for an extended
1601 * period of time on initialization. -1 can be passed to disable this
1604 * Set the timeout used for method calls. If this is not set explicitly,
1605 * a default of 0.8 ms is used.
1606 * Note that at-spi2-registryd currently uses a timeout of 3 seconds when
1607 * sending a keyboard event notification. This means that, if an AT makes
1608 * a call in response to the keyboard notification and the application
1609 * being called does not respond before the timeout is reached,
1610 * at-spi2-registryd will time out on the keyboard event notification and
1611 * pass the key onto the application (ie, reply to indicate that the key
1612 * was not consumed), so this may make it undesirable to set a timeout
1613 * larger than 3 seconds.
1615 * By default, the normal timeout is set to 800 ms, and the application startup
1616 * timeout is set to 15 seconds.
1619 atspi_set_timeout (gint val, gint startup_time)
1621 method_call_timeout = val;
1622 app_startup_time = startup_time;
1626 * atspi_set_main_context:
1627 * @cnx: The #GMainContext to use.
1629 * Sets the main loop context that AT-SPI should assume is in use when
1630 * setting an idle callback.
1631 * This function should be called by application-side implementors (ie,
1632 * at-spi2-atk) when it is desirable to re-enter the main loop.
1635 atspi_set_main_context (GMainContext *cnx)
1637 if (atspi_main_context == cnx)
1639 if (process_deferred_messages_source != NULL)
1641 g_source_destroy (process_deferred_messages_source);
1642 process_deferred_messages_source = g_idle_source_new ();
1643 g_source_set_callback (process_deferred_messages_source,
1644 process_deferred_messages_callback, NULL, NULL);
1645 g_source_attach (process_deferred_messages_source, cnx);
1646 g_source_unref (process_deferred_messages_source);
1648 atspi_main_context = cnx;
1649 atspi_dbus_connection_setup_with_g_main (atspi_get_a11y_bus (), cnx);
1652 #ifdef DEBUG_REF_COUNTS
1654 print_disposed (gpointer key, gpointer value, gpointer data)
1656 AtspiAccessible *accessible = key;
1657 if (accessible->parent.app)
1659 g_print ("disposed: %s %d\n", accessible->name, accessible->role);
1665 g_hash_table_foreach (live_refs, print_disposed, NULL);
1670 _atspi_name_compat (gchar *name)
1684 * atspi_role_get_name:
1685 * @role: an #AtspiRole object to query.
1687 * Gets a localizable string that indicates the name of an #AtspiRole.
1688 * <em>DEPRECATED.</em>
1690 * Returns: a localizable string name for an #AtspiRole enumerated type.
1693 atspi_role_get_name (AtspiRole role)
1695 gchar *retval = NULL;
1696 GTypeClass *type_class;
1699 type_class = g_type_class_ref (ATSPI_TYPE_ROLE);
1700 g_return_val_if_fail (G_IS_ENUM_CLASS (type_class), NULL);
1702 value = g_enum_get_value (G_ENUM_CLASS (type_class), role);
1706 retval = g_strdup (value->value_nick);
1709 g_type_class_unref (type_class);
1712 return _atspi_name_compat (retval);
1718 _atspi_dbus_update_cache_from_dict (AtspiAccessible *accessible, DBusMessageIter *iter)
1720 GHashTable *cache = _atspi_accessible_ref_cache (accessible);
1721 DBusMessageIter iter_dict, iter_dict_entry, iter_struct, iter_variant;
1723 dbus_message_iter_recurse (iter, &iter_dict);
1724 while (dbus_message_iter_get_arg_type (&iter_dict) != DBUS_TYPE_INVALID)
1728 dbus_message_iter_recurse (&iter_dict, &iter_dict_entry);
1729 dbus_message_iter_get_basic (&iter_dict_entry, &key);
1730 dbus_message_iter_next (&iter_dict_entry);
1731 dbus_message_iter_recurse (&iter_dict_entry, &iter_variant);
1732 if (!strcmp (key, "interfaces"))
1734 _atspi_dbus_set_interfaces (accessible, &iter_variant);
1736 else if (!strcmp (key, "Attributes"))
1738 char *iter_sig = dbus_message_iter_get_signature (&iter_variant);
1739 val = g_new0 (GValue, 1);;
1740 g_value_init (val, G_TYPE_HASH_TABLE);
1741 if (strcmp (iter_sig, "a{ss}") != 0)
1743 dbus_free (iter_sig);
1746 dbus_free (iter_sig);
1747 g_value_take_boxed (val, _atspi_dbus_hash_from_iter (&iter_variant));
1749 else if (!strcmp (key, "Component.ScreenExtents"))
1753 char *iter_sig = dbus_message_iter_get_signature (&iter_variant);
1754 val = g_new0 (GValue, 1);;
1755 g_value_init (val, ATSPI_TYPE_RECT);
1756 if (strcmp (iter_sig, "(iiii)") != 0)
1758 dbus_free (iter_sig);
1761 dbus_free (iter_sig);
1762 dbus_message_iter_recurse (&iter_variant, &iter_struct);
1763 dbus_message_iter_get_basic (&iter_struct, &d_int);
1765 dbus_message_iter_next (&iter_struct);
1766 dbus_message_iter_get_basic (&iter_struct, &d_int);
1768 dbus_message_iter_next (&iter_struct);
1769 dbus_message_iter_get_basic (&iter_struct, &d_int);
1770 extents.width = d_int;
1771 dbus_message_iter_next (&iter_struct);
1772 dbus_message_iter_get_basic (&iter_struct, &d_int);
1773 extents.height = d_int;
1774 g_value_set_boxed (val, &extents);
1777 g_hash_table_insert (cache, g_strdup (key), val);
1778 dbus_message_iter_next (&iter_dict);
1785 _atspi_get_allow_sync ()
1791 _atspi_set_allow_sync (gboolean val)
1793 gboolean ret = allow_sync;
1800 _atspi_set_error_no_sync (GError **error)
1802 g_set_error_literal (error, ATSPI_ERROR, ATSPI_ERROR_SYNC_NOT_ALLOWED,
1803 _("Attempted synchronous call where prohibited"));