+static void
+handle_get_bus_address (DBusPendingCall *pending, void *user_data)
+{
+ AtspiApplication *app = user_data;
+ DBusMessage *reply = dbus_pending_call_steal_reply (pending);
+ DBusMessage *message;
+ const char *address;
+ DBusPendingCall *new_pending;
+
+ if (dbus_message_get_type (reply) == DBUS_MESSAGE_TYPE_METHOD_RETURN)
+ {
+ if (dbus_message_get_args (reply, NULL, DBUS_TYPE_STRING, &address,
+ DBUS_TYPE_INVALID))
+ {
+ DBusError error;
+ dbus_error_init (&error);
+ DBusConnection *bus = dbus_connection_open (address, &error);
+ if (bus)
+ {
+ if (app->bus)
+ dbus_connection_unref (app->bus);
+ app->bus = bus;
+ }
+ }
+ }
+ dbus_message_unref (reply);
+ dbus_pending_call_unref (pending);
+
+ message = dbus_message_new_method_call (app->bus_name,
+ "/org/a11y/atspi/cache",
+ atspi_interface_cache, "GetItems");
+
+ dbus_connection_send_with_reply (app->bus, message, &new_pending, 2000);
+ dbus_pending_call_set_notify (new_pending, handle_get_items, app, NULL);
+ dbus_message_unref (message);
+}
+