From: Mike Gorse Date: Tue, 24 Jun 2008 22:24:51 +0000 (-0400) Subject: Allow simple event names (ie, "focus") X-Git-Tag: AT_SPI2_ATK_0_1_3~194 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3966a59c3dd7ecdf3176573171697ebef68ef5da;p=platform%2Fupstream%2Fat-spi2-atk.git Allow simple event names (ie, "focus") Remove some debugging printfs Add check for parse_event failing children-change -> children-changed --- diff --git a/cspi/spi_event.c b/cspi/spi_event.c index 32719b7..d20161a 100644 --- a/cspi/spi_event.c +++ b/cspi/spi_event.c @@ -889,14 +889,22 @@ parse_eventType (const char *eventType, char **type, char **detail, char **match char *t, *d; p = strchr (eventType, ':'); - if (!p) return FALSE; - p = strchr (p + 1, ':'); + 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 == ':') @@ -1042,7 +1050,11 @@ SPI_registerGlobalEventListener (AccessibleEventListener *listener, e = g_new (CSpiEventListenerEntry, 1); if (!e) return FALSE; e->listener = listener; - parse_eventType (eventType, &e->event, &e->detail, &matchrule); + if (!parse_eventType (eventType, &e->event, &e->detail, &matchrule)) + { + g_free (e); + return FALSE; + } new_list = g_list_prepend (event_listeners, e); if (!new_list) { @@ -1146,7 +1158,11 @@ cspi_dispatch_event (AccessibleEvent *e) char *event, *detail; GList *l; - parse_eventType (e->type, &event, &detail, NULL); + if (!parse_eventType (e->type, &event, &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; @@ -1183,24 +1199,25 @@ cspi_dbus_handle_event (DBusConnection *bus, DBusMessage *message, void *data) dbus_message_iter_get_basic (&iter, &detail2); e.detail2 = detail2; dbus_message_iter_next (&iter); -printf("event: %s %s\n", event, detail); e.type = g_strdup (event); p = strchr (e.type, '_'); if (p) *p = ':'; - p = g_strconcat (e.type, ":", detail, NULL); - if (p) + if (detail[0] != '\0') { - g_free (e.type); - e.type = p; + p = g_strconcat (e.type, ":", detail, NULL); + if (p) + { + g_free (e.type); + e.type = p; + } } - while ((p = strchr (p, '_'))) *p = '-'; + while ((p = strchr (e.type, '_'))) *p = '-'; e.source = cspi_ref_accessible (dbus_message_get_sender(message), dbus_message_get_path(message)); dbus_message_iter_recurse (&iter, &iter_variant); switch (dbus_message_iter_get_arg_type (&iter_variant)) { case DBUS_TYPE_OBJECT_PATH: { - char *p; dbus_message_iter_get_basic (&iter_variant, &p); e.v_type = EVENT_DATA_OBJECT; e.v.accessible = cspi_ref_accessible (dbus_message_get_sender(message), p); @@ -1208,7 +1225,6 @@ printf("event: %s %s\n", event, detail); } case DBUS_TYPE_STRING: { - char *p; dbus_message_iter_get_basic (&iter_variant, &p); e.v_type = EVENT_DATA_STRING; e.v.text = g_strdup (p); diff --git a/cspi/spi_main.c b/cspi/spi_main.c index 17c394e..64d9b15 100644 --- a/cspi/spi_main.c +++ b/cspi/spi_main.c @@ -181,7 +181,6 @@ cspi_object_ref (Accessible *accessible) { g_return_if_fail (accessible != NULL); -printf("ref: %p (%d)\n", accessible, accessible->ref_count);fflush(stdout); accessible->ref_count++; g_hash_table_insert (live_refs, accessible, accessible); } @@ -198,7 +197,6 @@ cspi_object_unref_internal (Accessible *accessible, gboolean defunct) return; } -printf("unref: %p (%d)\n", accessible, accessible->ref_count - 1);fflush(stdout); if (--accessible->ref_count == 0 || (accessible->ref_count == 1 && !defunct) && g_hash_table_lookup (live_refs, accessible)) { AccessibleEvent e; @@ -258,7 +256,6 @@ ref_accessible (CSpiApplication *app, const char *path) if (a) { cspi_object_ref (a); -printf("Got %p from %p for %d\n", a, app->hash, id);fflush(stdout); return a; } id_val = g_new (guint, 1); @@ -270,7 +267,6 @@ printf("Got %p from %p for %d\n", a, app->hash, id);fflush(stdout); g_free (id_val); return NULL; } -printf("Inserting %p into %p for %d\n", a, app->hash, *id_val); g_hash_table_insert (app->hash, id_val, a); a->app = app; a->v.id = id; @@ -428,12 +424,12 @@ add_app_to_desktop (Accessible *a, const char *bus_name) } static void -send_children_change (Accessible *parent, Accessible *child, gboolean add) +send_children_changed (Accessible *parent, Accessible *child, gboolean add) { AccessibleEvent e; memset (&e, 0, sizeof(e)); - e.type = (add? "object:children-change:add": "object:children-change:remove"); + e.type = (add? "object:children-changed:add": "object:children-changed:remove"); e.source = parent; e.detail1 = g_list_index (parent->children, child); cspi_dispatch_event (&e); @@ -467,7 +463,7 @@ remove_app_from_desktop (Accessible *a, const char *bus_name) g_warning ("Removing unregistered app %s; doing nothing\n", bus_name); return FALSE; } - send_children_change (a, child, FALSE); + send_children_changed (a, child, FALSE); a->children = g_list_remove (a->children, child); unref_object_and_children (child); return TRUE; @@ -483,7 +479,6 @@ ref_accessible_desktop (CSpiApplication *app, const char *path) gint i; Accessible *a = g_hash_table_lookup (app->hash, path); -printf("got %p from %p for %s\n", a, app_hash, path); if (a) { cspi_object_ref (a); @@ -497,7 +492,6 @@ printf("got %p from %p for %s\n", a, app_hash, path); g_free (path_dup); return NULL; } -printf("Inserting %p into %p for %s\n", a, app->hash, path_dup); g_hash_table_insert (app->hash, path_dup, a); a->app = app; a->v.path = path_dup; @@ -567,7 +561,6 @@ cspi_dbus_handle_update_tree (DBusConnection *bus, DBusMessage *message, void *u CSpiApplication *app = cspi_get_application (sender); const char *type = cacheSignalType; -printf("update tree: %p\n", app); if (!app) { g_warning ("UpdateTree from unknown app. Should we add it?", sender); @@ -597,10 +590,9 @@ cspi_dbus_handle_add_application (DBusConnection *bus, DBusMessage *message, voi return DBUS_HANDLER_RESULT_HANDLED; } a = cspi_ref_accessible ("org.freedesktop.atspi.registry", dbus_message_get_path(message)); -printf("Adding %s to %p\n", bus_name, a); if (add_app_to_desktop (a, bus_name)) { - send_children_change (a, g_list_last (a->children)->data, TRUE); + send_children_changed (a, g_list_last (a->children)->data, TRUE); } cspi_object_unref (a); return DBUS_HANDLER_RESULT_HANDLED; @@ -622,7 +614,6 @@ cspi_dbus_handle_remove_application (DBusConnection *bus, DBusMessage *message, return DBUS_HANDLER_RESULT_HANDLED; } a = cspi_ref_accessible ("org.freedesktop.atspi.registry", dbus_message_get_path(message)); -printf("Removing %s from %p\n", bus_name, a); remove_app_from_desktop (a, bus_name); cspi_object_unref (a); return DBUS_HANDLER_RESULT_HANDLED;