+
+done:
+ if (reply)
+ dbus_message_unref (reply);
+ if (pending)
+ dbus_pending_call_unref (pending);
+
+ tally_event_reply ();
+}
+
+static void
+get_device_events_reply (DBusPendingCall *pending, void *user_data)
+{
+ DBusMessage *reply = dbus_pending_call_steal_reply (pending);
+ DBusMessageIter iter, iter_array, iter_struct;
+
+ if (!reply)
+ goto done;
+
+ if (strncmp (dbus_message_get_signature (reply), "a(s", 3) != 0)
+ {
+ g_warning ("atk-bridge: get_device_events_reply: unknown signature");
+ goto done;
+ }
+
+ dbus_message_iter_init (reply, &iter);
+ dbus_message_iter_recurse (&iter, &iter_array);
+ while (dbus_message_iter_get_arg_type (&iter_array) != DBUS_TYPE_INVALID)
+ {
+ char *bus_name;
+ dbus_message_iter_recurse (&iter_array, &iter_struct);
+ dbus_message_iter_get_basic (&iter_struct, &bus_name);
+ spi_atk_add_client (bus_name);
+ dbus_message_iter_next (&iter_array);
+ }
+
+done:
+ if (reply)
+ dbus_message_unref (reply);
+ if (pending)
+ dbus_pending_call_unref (pending);
+
+ tally_event_reply ();
+}
+
+static void
+get_registered_event_listeners (SpiBridge *app)
+{
+ DBusMessage *message;
+ DBusPendingCall *pending = NULL;
+
+ message = dbus_message_new_method_call (SPI_DBUS_NAME_REGISTRY,
+ ATSPI_DBUS_PATH_REGISTRY,
+ ATSPI_DBUS_INTERFACE_REGISTRY,
+ "GetRegisteredEvents");
+ if (!message)
+ return;
+
+ dbus_connection_send_with_reply (app->bus, message, &pending, -1);
+ dbus_message_unref (message);
+ if (!pending)
+ {
+ spi_global_app_data->events_initialized = TRUE;
+ return;
+ }
+ dbus_pending_call_set_notify (pending, get_events_reply, NULL, NULL);
+
+ message = dbus_message_new_method_call (SPI_DBUS_NAME_REGISTRY,
+ ATSPI_DBUS_PATH_DEC,
+ ATSPI_DBUS_INTERFACE_DEC,
+ "GetKeystrokeListeners");
+ if (!message)
+ return;
+ pending = NULL;
+ dbus_connection_send_with_reply (app->bus, message, &pending, -1);
+ dbus_message_unref (message);
+ if (!pending)
+ {
+ spi_global_app_data->events_initialized = TRUE;
+ return;
+ }
+ dbus_pending_call_set_notify (pending, get_device_events_reply, NULL, NULL);
+
+ message = dbus_message_new_method_call (SPI_DBUS_NAME_REGISTRY,
+ ATSPI_DBUS_PATH_DEC,
+ ATSPI_DBUS_INTERFACE_DEC,
+ "GetDeviceEventListeners");
+ if (!message)
+ return;
+ pending = NULL;
+ dbus_connection_send_with_reply (app->bus, message, &pending, -1);
+ dbus_message_unref (message);
+ if (!pending)
+ {
+ spi_global_app_data->events_initialized = TRUE;
+ return;
+ }
+ dbus_pending_call_set_notify (pending, get_device_events_reply, NULL, NULL);