const char *name, *desc;
int i;
dbus_uint32_t role;
+ AtkObject *parent = NULL;
gint childcount;
GSList *l;
g_assert(data != NULL);
+ parent = atk_object_get_parent(obj);
+ if (parent == NULL)
+ {
+ path_parent = g_strdup("/");
+ }
+ else
+ {
+ path_parent = spi_dbus_get_path (parent);
+ }
+
dbus_message_iter_open_container (iter_array, DBUS_TYPE_STRUCT, NULL,
&iter_struct);
path = spi_dbus_get_path (obj);
dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_OBJECT_PATH, &path);
- path_parent = spi_dbus_get_path (atk_object_get_parent(obj));
- if (!path_parent) path_parent = g_strdup("/");
dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_OBJECT_PATH, &path_parent);
g_free(path_parent);
dbus_message_iter_open_container (&iter_struct, DBUS_TYPE_ARRAY, "o",
g_string_append_printf(output, spi_introspection_node_element, path);
- spi_append_interface(output, "org.freedesktop.atspi.Tree");
+ spi_append_interface(output, SPI_DBUS_INTERFACE_TREE);
g_string_append(output, spi_introspection_footer);
final = g_string_free(output, FALSE);
return reply;
}
-static DRouteMethod methods[] = {
- {impl_getRoot, "getRoot"},
- {impl_getTree, "getTree", TRUE},
- {NULL, NULL}
+static DBusHandlerResult
+message_handler (DBusConnection *bus, DBusMessage *message, void *user_data)
+{
+ const char *iface = dbus_message_get_interface (message);
+ const char *member = dbus_message_get_member (message);
+
+ DBusMessage *reply = NULL;
+
+ g_return_val_if_fail(iface != NULL, DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
+
+ if (!strcmp(iface, SPI_DBUS_INTERFACE_TREE))
+ {
+ if (!strcmp(member, "getRoot"))
+ {
+ reply = impl_getRoot(bus, message, user_data);
+ }
+
+ if (!strcmp(member, "getTree"))
+ {
+ reply = impl_getTree(bus, message, user_data);
+ }
+ }
+
+ if (!strcmp(iface, "org.freedesktop.DBus.Introspectable"))
+ {
+ if (!strcmp(member, "Introspect"))
+ {
+ reply = impl_introspect(bus, message, user_data);
+ }
+ }
+
+ if (reply)
+ {
+ dbus_connection_send (bus, reply, NULL);
+ dbus_message_unref (reply);
+ }
+
+ return DBUS_HANDLER_RESULT_HANDLED;
+}
+
+static DBusObjectPathVTable tree_vtable =
+{
+ NULL,
+ &message_handler,
+ NULL, NULL, NULL, NULL
};
void
-spi_initialize_tree (DRouteData * data)
+spi_register_tree_object(DBusConnection *bus,
+ DRouteData *data,
+ const char *path)
{
- droute_add_interface (data, "org.freedesktop.atspi.Tree", methods,
- NULL, NULL, NULL);
-};
+ dbus_bool_t mem = FALSE;
+ mem = dbus_connection_register_object_path(bus, path, &tree_vtable, data);
+ g_assert(mem == TRUE);
+}
+
static GHashTable *cache_list;
#define UPDATE_NEW 1
g_hash_table_remove(cache_list, path);
}
-gboolean spi_dbus_update_cache(DRouteData *data)
+gboolean
+spi_dbus_update_cache(DRouteData *data)
{
DBusMessage *message;
DBusMessageIter iter;
CacheIterData d;
+ static gboolean in_update_cache = FALSE;
+ if (in_update_cache) return TRUE;
g_assert(data != NULL);
if (update_pending == 0) return FALSE;
//printf("Sending cache\n");
- message = dbus_message_new_signal("/org/freedesktop/atspi/tree", "org.freedesktop.atspi.Tree", "UpdateTree");
+ message = dbus_message_new_signal ("/org/freedesktop/atspi/tree", SPI_DBUS_INTERFACE_TREE, "updateTree");
if (!message) goto done;
dbus_message_iter_init_append (message, &iter);
dbus_message_iter_open_container (&iter, DBUS_TYPE_ARRAY, "(ooaoassus)",
&d.iter);
d.droute = data;
d.removing = FALSE;
+ in_update_cache = TRUE;
do
{
/* This loop is needed because appending an item may cause new children
dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "o", &d.iter);
d.removing = TRUE;
g_hash_table_foreach(cache_list, (GHFunc)handle_cache_item, &d);
+ in_update_cache = FALSE;
dbus_message_iter_close_container(&iter, &d.iter);
dbus_connection_send(data->bus, message, NULL);
done: