DBusMessage *message, *reply;
DBusError error;
- message = dbus_message_new_method_call (SPI_DBUS_NAME_REGISTRY, SPI_DBUS_PATH_REGISTRY, SPI_DBUS_INTERFACE_REGISTRY, "registerApplication");
+ message = dbus_message_new_signal (SPI_DBUS_PATH_REGISTRY, SPI_DBUS_INTERFACE_TREE, "registerApplication");
dbus_error_init (&error);
- reply = dbus_connection_send_with_reply_and_block(this_app->droute.bus, message, 1000, &error);
+ dbus_connection_send (this_app->droute.bus, message, NULL);
if (error.message) g_print (error.message);
- if (reply) dbus_message_unref (reply);
if (message) dbus_message_unref (message);
}
typedef struct
{
CSpiEventListener *listener;
- char *event;
+ char *category;
+ char *name;
char *detail;
} CSpiEventListenerEntry;
}
static gboolean
-parse_eventType (const char *eventType, char **type, char **detail, char **matchrule)
+parse_eventType (const char *eventType, char **categoryp, char **namep, char **detailp, char **matchrule)
{
- char *p, *q;
- char *t, *d;
-
- p = strchr (eventType, ':');
- if (p) p = strchr (p + 1, ':');
- if (!p) p = eventType + strlen (eventType);
- t = g_malloc (p - eventType + 1);
- if (t)
- {
- memcpy (t, eventType, p - eventType);
- t[p - eventType] = '\0';
- if (!strchr (t, ':'))
- {
- char *q = g_strconcat (t, ":", NULL);
- if (1)
- {
- g_free (t);
- t = q;
- }
- }
- }
- else return FALSE;
- if (*p == ':')
+ char *tmp = g_strdup (eventType);
+ char *category = NULL, *name = NULL, *detail = NULL;
+ char *saveptr = NULL;
+ char *p;
+
+ if (tmp == NULL) return FALSE;
+ while ((p = strchr (tmp, '-'))) *p = '_';
+ category = strtok_r (tmp, ":", &saveptr);
+ if (category) category = g_strdup (category);
+ if (!category) goto oom;
+ name = strtok_r (NULL, ":", &saveptr);
+ if (name)
{
- d = g_strdup (p + 1);
- if (!d)
- {
- g_free (t);
- return FALSE;
- }
+ name = g_strdup (name);
+ if (!name) goto oom;
+ detail = strtok_r (NULL, ":", &saveptr);
+ if (detail) detail = g_strdup (detail);
}
- else d = NULL;
- if ((p = strchr (t, ':')))
+ else
{
- *p = (p[1] == '\0'? '\0': '_');
+ name = g_strdup (category);
+ if (!name) goto oom;
}
- while ((p = strchr (t, '-'))) *p = '_';
if (matchrule)
{
- *matchrule = g_strdup_printf ("type='signal',interface='%s',member='%s'", spi_interface_accessible, t);
- if (!*matchrule)
- {
- g_free (t);
- if (d) g_free (d);
- return FALSE;
- }
+ *matchrule = g_strdup_printf ("type='signal',interface='org.freedesktop.atspi.event.%c%s',member='%s'", toupper(category[0]), category + 1, name);
+ if (!*matchrule) goto oom;
}
- if (type) *type = t;
- if (detail) *detail = d;
+ if (categoryp) *categoryp = category;
+ else g_free (category);
+ if (namep) *namep = name;
+ else if (name) g_free (name);
+ if (detailp) *detailp = detail;
+ else if (detail) g_free (detail);
+ g_free (tmp);
return TRUE;
+oom:
+ if (tmp) g_free (tmp);
+ if (category) g_free (category);
+ if (name) g_free (name);
+ if (detail) g_free (detail);
+ return FALSE;
}
static void listener_data_free (CSpiEventListenerEntry *e)
{
- g_free (e->event);
+ g_free (e->category);
+ g_free (e->name);
if (e->detail) g_free (e->detail);
g_free (e);
}
e = g_new (CSpiEventListenerEntry, 1);
if (!e) return FALSE;
e->listener = listener;
- if (!parse_eventType (eventType, &e->event, &e->detail, &matchrule))
+ if (!parse_eventType (eventType, &e->category, &e->name, &e->detail, &matchrule))
{
g_free (e);
return FALSE;
SPI_deregisterGlobalEventListener (AccessibleEventListener *listener,
const char *eventType)
{
- char *type, *detail, *matchrule;
+ char *category, *name, *detail, *matchrule;
GList *l;
- if (!parse_eventType (eventType, &type, &detail, &matchrule))
+ if (!parse_eventType (eventType, &category, &name, &detail, &matchrule))
{
return FALSE;
}
for (l = event_listeners; l;)
{
CSpiEventListenerEntry *e = l->data;
- if (e->listener == listener && !strcmp (e->event, type) && (e->detail == detail || !strcmp (e->detail, detail)))
+ if (e->listener == listener && !strcmp (e->category, category) && !strcmp (e->name, name) && (e->detail == detail || !strcmp (e->detail, detail)))
{
DBusError error;
listener_data_free (e);
}
else l = g_list_next (l);
}
- g_free (type);
+ g_free (category);
+ g_free (name);
if (detail) g_free (detail);
g_free (matchrule);
return TRUE;
void
cspi_dispatch_event (AccessibleEvent *e)
{
- char *event, *detail;
+ char *category, *name, *detail;
GList *l;
- if (!parse_eventType (e->type, &event, &detail, NULL))
+ if (!parse_eventType (e->type, &category, &name, &detail, NULL))
{
g_warning ("Couldn't parse event: %s\n", e->type);
return;
for (l = event_listeners; l; l = g_list_next (l))
{
CSpiEventListenerEntry *entry = l->data;
- if (!strcmp (event, entry->event) &&
+ if (!strcmp (category, entry->category) &&
+ (entry->name == NULL || !strcmp (name, entry->name)) &&
(entry->detail == NULL || !strcmp (detail, entry->detail)))
{
CSpiEventListenerClass *klass = CSPI_EVENT_LISTENER_GET_CLASS (entry->listener);
}
}
if (detail) g_free (detail);
- g_free (event);
+ g_free (name);
+ g_free (category);
}
DBusHandlerResult
cspi_dbus_handle_event (DBusConnection *bus, DBusMessage *message, void *data)
{
char *detail = NULL;
- const char *event = dbus_message_get_member (message);
+ const char *category = dbus_message_get_interface (message);
+ const char *name = dbus_message_get_member (message);
DBusMessageIter iter, iter_variant;
dbus_message_iter_init (message, &iter);
AccessibleEvent e;
dbus_int32_t detail1, detail2;
char *p;
+ if (category)
+ {
+ category = strrchr (category, '.');
+ if (category == NULL)
+ {
+ // TODO: Error
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+ }
+ category++;
+ }
g_return_if_fail (dbus_message_iter_get_arg_type (&iter) == DBUS_TYPE_STRING);
dbus_message_iter_get_basic (&iter, &detail);
dbus_message_iter_next (&iter);
dbus_message_iter_get_basic (&iter, &detail2);
e.detail2 = detail2;
dbus_message_iter_next (&iter);
- e.type = g_strdup (event);
- p = strchr (e.type, '_');
- if (p) *p = ':';
+ e.type = g_strdup_printf ("%c%s:", tolower (category[0]), category + 1);
+ if (strcasecmp (category, name) != 0)
+ {
+ p = g_strconcat (e.type, ":", name, NULL);
+ if (p)
+ {
+ g_free (e.type);
+ e.type = p;
+ }
+ }
if (detail[0] != '\0')
{
p = g_strconcat (e.type, ":", detail, NULL);
return TRUE;
}
+static Accessible *desktop;
+
static Accessible *
-ref_accessible_desktop (CSpiApplication *app, const char *path)
+ref_accessible_desktop (CSpiApplication *app)
{
- char *path_dup;
DBusError error;
GArray *apps = NULL;
GArray *additions;
gint i;
- Accessible *a = g_hash_table_lookup (app->hash, path);
- if (a)
+ if (desktop)
{
- cspi_object_ref (a);
- return a;
+ cspi_object_ref (desktop);
+ return desktop;
}
- path_dup = g_strdup (path);
- if (!path_dup) return NULL;
- a = g_new0 (Accessible, 1);
- if (!a)
+ desktop = g_new0 (Accessible, 1);
+ if (!desktop)
{
- g_free (path_dup);
return NULL;
}
- g_hash_table_insert (app->hash, path_dup, a);
- a->app = app;
- a->v.path = path_dup;
- a->ref_count = 2; /* one for the caller, one for the hash */
- cspi_dbus_get_property (a, SPI_DBUS_INTERFACE_ACCESSIBLE, "name", NULL, "s", &a->name);
+ g_hash_table_insert (app->hash, "", desktop);
+ desktop->app = app;
+ desktop->ref_count = 2; /* one for the caller, one for the hash */
+ desktop->name = g_strdup ("");
dbus_error_init (&error);
- if (!dbind_connection_method_call (bus, spi_bus_registry, a->v.path, spi_interface_desktop, "getChildren", &error, "=>as", &apps))
+ if (!dbind_connection_method_call (bus, spi_bus_registry, spi_path_registry, spi_interface_registry, "getApplications", &error, "=>as", &apps))
{
- g_error ("Couldn't get desktop children: %s", error.message);
+ g_error ("Couldn't get application list: %s", error.message);
}
for (i = 0; i < apps->len; i++)
{
g_warning ("getTree (%s): %s", app_name, error.message);
}
handle_additions (app, additions);
- add_app_to_desktop (a, app_name);
+ add_app_to_desktop (desktop, app_name);
}
g_array_free (apps, TRUE);
- return a;
+ return desktop;
}
Accessible *
if (!a) return NULL;
if ( APP_IS_REGISTRY(a))
{
- return ref_accessible_desktop (a, path);
+ return ref_accessible_desktop (a);
}
return ref_accessible (a, path);
}
}
static DBusHandlerResult
-cspi_dbus_handle_add_application (DBusConnection *bus, DBusMessage *message, void *user_data)
+cspi_dbus_handle_register_application (DBusConnection *bus, DBusMessage *message, void *user_data)
{
DBusError error;
dbus_uint32_t v;
char *bus_name;
dbus_error_init (&error);
- if (!dbus_message_get_args (message, NULL, DBUS_TYPE_UINT32, &v, DBUS_TYPE_STRING, &bus_name, DBUS_TYPE_INVALID))
- {
- g_warning ("Error processing %s: %s\n", dbus_message_get_member(message), error.message);
- dbus_error_free (&error);
- return DBUS_HANDLER_RESULT_HANDLED;
- }
- a = cspi_ref_accessible (spi_bus_registry, dbus_message_get_path(message));
- if (add_app_to_desktop (a, bus_name))
+ a = cspi_ref_accessible (spi_bus_registry, spi_path_registry);
+ if (add_app_to_desktop (a, dbus_message_get_sender (message)))
{
send_children_changed (a, g_list_last (a->children)->data, TRUE);
}
}
static DBusHandlerResult
-cspi_dbus_handle_remove_application (DBusConnection *bus, DBusMessage *message, void *user_data)
+cspi_dbus_handle_deregister_application (DBusConnection *bus, DBusMessage *message, void *user_data)
{
- DBusError error;
- dbus_uint32_t v;
Accessible *a;
+ DBusError error;
char *bus_name;
-
+
dbus_error_init (&error);
- if (!dbus_message_get_args (message, NULL, DBUS_TYPE_UINT32, &v, DBUS_TYPE_STRING, &bus_name, DBUS_TYPE_INVALID))
+ if (!dbus_message_get_args (message, &error, DBUS_TYPE_STRING, &bus_name, DBUS_TYPE_INVALID))
{
g_warning ("Error processing %s: %s\n", dbus_message_get_member(message), error.message);
dbus_error_free (&error);
return DBUS_HANDLER_RESULT_HANDLED;
}
- a = cspi_ref_accessible (spi_bus_registry, dbus_message_get_path(message));
+
+ a = cspi_ref_accessible (spi_bus_registry, spi_path_registry);
remove_app_from_desktop (a, bus_name);
cspi_object_unref (a);
return DBUS_HANDLER_RESULT_HANDLED;
{
return cspi_dbus_handle_update_tree (bus, message, data);
}
- if (dbus_message_is_signal (message, spi_interface_registry, "applicationAdd"))
+ if (dbus_message_is_signal (message, spi_interface_tree, "registerApplication"))
{
- return cspi_dbus_handle_add_application (bus, message, data);
+ return cspi_dbus_handle_register_application (bus, message, data);
}
- if (dbus_message_is_signal (message, spi_interface_registry, "applicationRemove"))
+ if (dbus_message_is_signal (message, spi_interface_registry, "deregisterApplication"))
{
- return cspi_dbus_handle_remove_application (bus, message, data);
+ return cspi_dbus_handle_deregister_application (bus, message, data);
}
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
dbus_error_init (&error);
dbus_bus_add_match (bus, match, &error);
g_free (match);
- match = g_strdup_printf ("type='signal',sender='%s'", spi_bus_registry);
+ match = g_strdup_printf ("type='signal',interface='%s'", spi_interface_tree);
dbus_bus_add_match (bus, match, &error);
g_free (match);
return 0;
{
if (APP_IS_REGISTRY (obj->app))
{
- return g_strdup_printf (SPI_DBUS_PATH_DESKTOP);
+ return g_strdup_printf (SPI_DBUS_PATH_REGISTRY);
}
return g_strdup_printf ("/org/freedesktop/atspi/accessible/%d", obj->v.id);
}
int
SPI_getDesktopCount ()
{
- if (!desktops) SPI_getDesktopList (NULL);
- if (!desktops) return -1;
- return desktops->len;
+ return 1;
}
/**
Accessible*
SPI_getDesktop (int i)
{
- if (!desktops) SPI_getDesktopList (NULL);
- if (!desktops) return NULL;
- return cspi_ref_accessible (spi_bus_registry, g_array_index (desktops, char *, i));
+ if (i != 0) return NULL;
+ return cspi_ref_accessible (spi_bus_registry, NULL);
}
/**
int
SPI_getDesktopList (Accessible ***desktop_list)
{
- int i;
Accessible **list;
- if (desktop_list) *desktop_list = NULL;
+ list = g_new0 (Accessible *, 2);
- if (!desktops)
- {
- dbind_connection_method_call (SPI_bus(), spi_bus_registry, spi_path_registry, spi_interface_registry, "getDesktopList", NULL, "=>ao", &desktops);
- if (!desktops) return 0;
- }
-
- list = g_new0 (Accessible *, desktops->len + 1);
-
- if (!desktop_list) return desktops->len;
- for (i = 0; i < desktops->len; i++)
- {
- list [i] = cspi_ref_accessible (spi_bus_registry, g_array_index (desktops, char *, i));
- }
- list [i] = NULL;
+ if (!desktop_list) return 1;
+ list [0] = cspi_ref_accessible (spi_bus_registry, NULL);
*desktop_list = list;
- return i;
+ return 1;
}
/**
</tp:struct>
<interface name="org.freedesktop.atspi.Event.Object">
- <signal name="property-change"><arg direction="out" type="suuv" tp:type="Event"/></signal>
- <signal name="bounds-changed"><arg direction="out" type="suuv" tp:type="Event"/></signal>
- <signal name="link-selected"><arg direction="out" type="suuv" tp:type="Event"/></signal>
- <signal name="state-changed"><arg direction="out" type="suuv" tp:type="Event"/></signal>
- <signal name="children-changed"><arg direction="out" type="suuv" tp:type="Event"/></signal>
- <signal name="visible-data-changed"><arg direction="out" type="suuv" tp:type="Event"/></signal>
- <signal name="selection-changed"><arg direction="out" type="suuv" tp:type="Event"/></signal>
- <signal name="model-changed"><arg direction="out" type="suuv" tp:type="Event"/></signal>
- <signal name="active-descendant-changed"><arg direction="out" type="suuv" tp:type="Event"/></signal>
- <signal name="row-inserted"><arg direction="out" type="suuv" tp:type="Event"/></signal>
- <signal name="row-reordered"><arg direction="out" type="suuv" tp:type="Event"/></signal>
- <signal name="row-deleted"><arg direction="out" type="suuv" tp:type="Event"/></signal>
- <signal name="column-inserted"><arg direction="out" type="suuv" tp:type="Event"/></signal>
- <signal name="column-reordered"><arg direction="out" type="suuv" tp:type="Event"/></signal>
- <signal name="column-deleted"><arg direction="out" type="suuv" tp:type="Event"/></signal>
- <signal name="text-bounds-changed"><arg direction="out" type="suuv" tp:type="Event"/></signal>
- <signal name="text-selection-changed"><arg direction="out" type="suuv" tp:type="Event"/></signal>
- <signal name="text-changed'"><arg direction="out" type="suuv" tp:type="Event"/></signal>
- <signal name="text-attributes-changed"><arg direction="out" type="suuv" tp:type="Event"/></signal>
- <signal name="text-caret-moved"><arg direction="out" type="suuv" tp:type="Event"/></signal>
- <signal name="attributes-changed"><arg direction="out" type="suuv" tp:type="Event"/></signal>
- <signal name="text-changed"><arg direction="out" type="suuv" tp:type="Event"/></signal>
+ <signal name="property_change"><arg direction="out" type="suuv" tp:type="Event"/></signal>
+ <signal name="bounds_changed"><arg direction="out" type="suuv" tp:type="Event"/></signal>
+ <signal name="link_selected"><arg direction="out" type="suuv" tp:type="Event"/></signal>
+ <signal name="state_changed"><arg direction="out" type="suuv" tp:type="Event"/></signal>
+ <signal name="children_changed"><arg direction="out" type="suuv" tp:type="Event"/></signal>
+ <signal name="visible_data_changed"><arg direction="out" type="suuv" tp:type="Event"/></signal>
+ <signal name="selection_changed"><arg direction="out" type="suuv" tp:type="Event"/></signal>
+ <signal name="model_changed"><arg direction="out" type="suuv" tp:type="Event"/></signal>
+ <signal name="active_descendant_changed"><arg direction="out" type="suuv" tp:type="Event"/></signal>
+ <signal name="row_inserted"><arg direction="out" type="suuv" tp:type="Event"/></signal>
+ <signal name="row_reordered"><arg direction="out" type="suuv" tp:type="Event"/></signal>
+ <signal name="row_deleted"><arg direction="out" type="suuv" tp:type="Event"/></signal>
+ <signal name="column_inserted"><arg direction="out" type="suuv" tp:type="Event"/></signal>
+ <signal name="column_reordered"><arg direction="out" type="suuv" tp:type="Event"/></signal>
+ <signal name="column_deleted"><arg direction="out" type="suuv" tp:type="Event"/></signal>
+ <signal name="text_bounds_changed"><arg direction="out" type="suuv" tp:type="Event"/></signal>
+ <signal name="text_selection_changed"><arg direction="out" type="suuv" tp:type="Event"/></signal>
+ <signal name="text_changed"><arg direction="out" type="suuv" tp:type="Event"/></signal>
+ <signal name="text_attributes_changed"><arg direction="out" type="suuv" tp:type="Event"/></signal>
+ <signal name="text_caret_moved"><arg direction="out" type="suuv" tp:type="Event"/></signal>
+ <signal name="attributes_changed"><arg direction="out" type="suuv" tp:type="Event"/></signal>
+ <signal name="text_changed"><arg direction="out" type="suuv" tp:type="Event"/></signal>
</interface>
<interface name="org.freedesktop.atspi.Event.Window">
- <signal name="property-change"><arg direction="out" type="suuv" tp:type="Event"/></signal>
+ <signal name="property_change"><arg direction="out" type="suuv" tp:type="Event"/></signal>
<signal name="minimize"><arg direction="out" type="suuv" tp:type="Event"/></signal>
<signal name="maximize"><arg direction="out" type="suuv" tp:type="Event"/></signal>
<signal name="restore"><arg direction="out" type="suuv" tp:type="Event"/></signal>
<signal name="close"><arg direction="out" type="suuv" tp:type="Event"/></signal>
<signal name="create"><arg direction="out" type="suuv" tp:type="Event"/></signal>
<signal name="reparent"><arg direction="out" type="suuv" tp:type="Event"/></signal>
- <signal name="desktop-create"><arg direction="out" type="suuv" tp:type="Event"/></signal>
- <signal name="desktop-destroy"><arg direction="out" type="suuv" tp:type="Event"/></signal>
+ <signal name="desktop_create"><arg direction="out" type="suuv" tp:type="Event"/></signal>
+ <signal name="desktop_destroy"><arg direction="out" type="suuv" tp:type="Event"/></signal>
<signal name="destroy"><arg direction="out" type="suuv" tp:type="Event"/></signal>
<signal name="activate"><arg direction="out" type="suuv" tp:type="Event"/></signal>
<signal name="deactivate"><arg direction="out" type="suuv" tp:type="Event"/></signal>
</interface>
<interface name="org.freedesktop.atspi.Event.Terminal">
- <signal name="line-changed"><arg direction="out" type="suuv" tp:type="Event"/></signal>
- <signal name="comumncount-changed"><arg direction="out" type="suuv" tp:type="Event"/></signal>
- <signal name="linecount-changed"><arg direction="out" type="suuv" tp:type="Event"/></signal>
- <signal name="application-changed"><arg direction="out" type="suuv" tp:type="Event"/></signal>
- <signal name="charwidth-changed"><arg direction="out" type="suuv" tp:type="Event"/></signal>
+ <signal name="line_changed"><arg direction="out" type="suuv" tp:type="Event"/></signal>
+ <signal name="comumncount_changed"><arg direction="out" type="suuv" tp:type="Event"/></signal>
+ <signal name="linecount_changed"><arg direction="out" type="suuv" tp:type="Event"/></signal>
+ <signal name="application_changed"><arg direction="out" type="suuv" tp:type="Event"/></signal>
+ <signal name="charwidth_changed"><arg direction="out" type="suuv" tp:type="Event"/></signal>
</interface>
<interface name="org.freedesktop.atspi.Event.Document">
- <signal name="load-complete"><arg direction="out" type="suuv" tp:type="Event"/></signal>
+ <signal name="load_complete"><arg direction="out" type="suuv" tp:type="Event"/></signal>
<signal name="reload"><arg direction="out" type="suuv" tp:type="Event"/></signal>
- <signal name="load-stopped"><arg direction="out" type="suuv" tp:type="Event"/></signal>
- <signal name="content-changed"><arg direction="out" type="suuv" tp:type="Event"/></signal>
- <signal name="attributes-changed"><arg direction="out" type="suuv" tp:type="Event"/></signal>
+ <signal name="load_stopped"><arg direction="out" type="suuv" tp:type="Event"/></signal>
+ <signal name="content_changed"><arg direction="out" type="suuv" tp:type="Event"/></signal>
+ <signal name="attributes_changed"><arg direction="out" type="suuv" tp:type="Event"/></signal>
</interface>
<interface name="org.freedesktop.atspi.Event.Focus">
<p>Extended description of the object.</p>
</tp:docstring>
</tp:member>
+
+ <tp:member type="au" tp:name="states">
+ <tp:docstring xmlns="http://www.w3.org/1999/xhtml">
+ <p>The object's states. Each integer contains a bitmask of 32 states (the first item contains states 0-31, and the second item contains states 32-63).</p>
+ </tp:docstring>
+ </tp:member>
</tp:struct>
<interface name="org.freedesktop.atspi.Tree">
application. This should be used to create
a mirror of the tree of Accessibles within the AT.</p>
</tp:docstring>
- <arg name="nodes" type="a(ooaoassus)" direction="out" tp:type="AccessibleProxy[]">
+ <arg name="nodes" type="a(ooaoassusau)" direction="out" tp:type="AccessibleProxy[]">
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>Array of Accessible Object proxy structures.</p>
</tp:docstring>
accessible objects that have changed since the last
updateTree signal was send</p>
</tp:docstring>
- <arg name="nodesAdded" type="a(ooaoassus)" tp:type="AccessibleProxy[]">
+ <arg name="nodesAdded" type="a(ooaoassusau)" tp:type="AccessibleProxy[]">
<tp:docstring xmlns="http://www.w3.org/1999/xhtml">
<p>Array of Accessible Object proxy structures to be added.</p>
</tp:docstring>