looping over the bus to entering a g_main_loop.
Modification to the 'Embed' method so that the address of
the desktop object (Application parent) is stored.
if (spi_cache_in (cache, gobj))
{
+#ifdef SPI_ATK_DEBUG
+ g_debug ("CACHE REM - %s - %d - %s\n", atk_object_get_name (ATK_OBJECT (gobj)),
+ atk_object_get_role (ATK_OBJECT (gobj)),
+ spi_register_object_to_path (spi_global_register, gobj));
+#endif
g_signal_emit (cache, cache_signals [OBJECT_REMOVED], 0, gobj);
g_hash_table_remove (cache->objects, gobj);
}
g_hash_table_insert (cache->objects, gobj, NULL);
#ifdef SPI_ATK_DEBUG
- g_debug ("CACHE - %s - %d - %s", atk_object_get_name (ATK_OBJECT (gobj)),
+ g_debug ("CACHE ADD - %s - %d - %s\n", atk_object_get_name (ATK_OBJECT (gobj)),
atk_object_get_role (ATK_OBJECT (gobj)),
spi_register_object_to_path (spi_global_register, gobj));
#endif
static void
register_application (SpiBridge * app)
{
- DBusMessage *message;
+ DBusMessage *message, *reply;
DBusMessageIter iter;
DBusError error;
SPI_DBUS_PATH_ROOT,
SPI_DBUS_INTERFACE_SOCKET,
"Embed");
- dbus_message_set_no_reply (message, TRUE);
dbus_message_iter_init_append (message, &iter);
spi_object_append_reference (&iter, app->root);
- dbus_connection_send (app->bus, message, NULL);
+
+ reply = dbus_connection_send_with_reply_and_block (app->bus, message, -1, &error);
+
if (message)
dbus_message_unref (message);
+
+ if (reply)
+ {
+ DBusMessageIter iter, iter_struct;
+ gchar *app_name, *obj_path;
+
+ dbus_message_iter_init (reply, &iter);
+ dbus_message_iter_recurse (&iter, &iter_struct);
+ if (!(dbus_message_iter_get_arg_type (&iter_struct) == DBUS_TYPE_STRING))
+ g_error ("AT-SPI: Could not obtain desktop path or name\n");
+ dbus_message_iter_get_basic (&iter_struct, &app_name);
+ if (!dbus_message_iter_next (&iter_struct))
+ g_error ("AT-SPI: Could not obtain desktop name");
+ if (!(dbus_message_iter_get_arg_type (&iter_struct) == DBUS_TYPE_OBJECT_PATH))
+ g_error ("AT-SPI: Could not obtain desktop path");
+ dbus_message_iter_get_basic (&iter_struct, &obj_path);
+
+ app->desktop_name = g_strdup (app_name);
+ app->desktop_path = g_strdup (obj_path);
+ }
+ else
+ {
+ g_error ("AT-SPI: Could not embed inside desktop: %s\n", error.message);
+ }
+
}
/*---------------------------------------------------------------------------*/
SpiCache *cache;
SpiLeasing *leasing;
*/
+ gchar *desktop_name;
+ gchar *desktop_path;
};
extern SpiBridge *spi_global_app_data;
/*---------------------------------------------------------------------------*/
+typedef struct _SpiReentrantCallClosure
+{
+ GMainLoop *loop;
+ DBusMessage *reply;
+} SpiReentrantCallClosure;
+
static void
set_reply (DBusPendingCall * pending, void *user_data)
{
- void **replyptr = (void **) user_data;
+ SpiReentrantCallClosure* closure = (SpiReentrantCallClosure *) user_data;
- *replyptr = dbus_pending_call_steal_reply (pending);
+ closure->reply = dbus_pending_call_steal_reply (pending);
+ g_main_loop_quit (closure->loop);
}
static DBusMessage *
send_and_allow_reentry (DBusConnection * bus, DBusMessage * message)
{
DBusPendingCall *pending;
- DBusMessage *reply = NULL;
+ SpiReentrantCallClosure closure;
if (!dbus_connection_send_with_reply (bus, message, &pending, -1))
- {
return NULL;
- }
- dbus_pending_call_set_notify (pending, set_reply, (void *) &reply, NULL);
- while (!reply)
- {
- if (!dbus_connection_read_write_dispatch (bus, -1))
- return NULL;
- }
- return reply;
+ dbus_pending_call_set_notify (pending, set_reply, (void *) &closure, NULL);
+ closure.loop = g_main_loop_new (NULL, FALSE);
+
+ g_main_loop_run (closure.loop);
+
+ g_main_loop_unref (closure.loop);
+ return closure.reply;
}
/*---------------------------------------------------------------------------*/
spi_object_append_desktop_reference (DBusMessageIter * iter)
{
DBusMessageIter iter_struct;
- const char *name = SPI_DBUS_NAME_REGISTRY;
- const char *path = SPI_DBUS_PATH_ROOT;
+ const char *name = spi_global_app_data->desktop_name;
+ const char *path = spi_global_app_data->desktop_path;
dbus_message_iter_open_container (iter, DBUS_TYPE_STRUCT, NULL,
&iter_struct);