From e81873e25716e40b852dbca09c47ee256e904717 Mon Sep 17 00:00:00 2001 From: billh Date: Wed, 12 Dec 2001 16:08:46 +0000 Subject: [PATCH] Changed event matching to use GQuark instead of string hashes. Fixed compile-time warning. git-svn-id: http://svn.gnome.org/svn/at-spi/trunk@182 e2bd861d-eb25-0410-b326-f6ed22b6b98c --- ChangeLog | 10 +++++++++ TODO | 13 +++--------- registryd/registry.c | 60 +++++++++++++++++++++++++--------------------------- registryd/registry.h | 2 +- 4 files changed, 43 insertions(+), 42 deletions(-) diff --git a/ChangeLog b/ChangeLog index f60d21b..1a664d7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,15 @@ 2001-12-12 Bill Haneman + * registryd/registry.c: + Changed use of strings and string hashes in listener event + matching and parse_event_string to use GQuark, which is guaranteed + unique. + + * registryd/registry.h: + Squashed annoying warning. + +2001-12-12 Bill Haneman + * idl/Accessibility_Value.idl: Revert use of union back to CORBA_double, since the double type is more efficient and can contain the other types without loss of diff --git a/TODO b/TODO index 5f3729c..e0c179d 100644 --- a/TODO +++ b/TODO @@ -3,24 +3,19 @@ TODO: idl: + audit IDL for conformance with bonobo/doc/FAQ's [Java] naming practice [Michael] - + possibly change Value.idl interface to return a value - union. [Bill] *DONE* - + rename all IDL prepending Accessibility_ to each IDL filename cspi: - + API change required if above IDL change is made. [Bill] + ensure spi-listener-impl's list notification methods don't have a re-enterancy hazard. [Michael] - + namespace all methods missing a prepending Acessible + + namespace all methods missing a prepending Accessible or SPI_ prefix. + Put LGPL headers everywhere. registry: + move code into here from libspi [Michael] - + kill the getDeviceWhatnot - and use queryInterface, - don't inherit from the Listener interface - use aggregation + fire an event on dead application & re-factor the listen for broken code. + + consider use of GHashTable instead of GList for listeners [Bill] bridge: + move code into here from libspi @@ -29,8 +24,6 @@ libspi: + remove redundant casts throughout + determine if there are other headers we don't need to install + consider moving the non-impl. parts into registryd/ bridge/ etc. - + change the weird string-hash event matching to something sane, - using GQuark. [Bill] + merge the DeviceEvent and KeyEvent structs to avoid the bogus casting of these back and forth. + complete implementation of support for RelationSet and @@ -40,6 +33,6 @@ libspi: test: + update test-simple to do complete API tests - + Add tests for AtkTable, and add table elements to the test window. + + Expand tests for AtkTable + remove comment from test_value; ensure that it works. diff --git a/registryd/registry.c b/registryd/registry.c index a12880e..b482255 100644 --- a/registryd/registry.c +++ b/registryd/registry.c @@ -22,6 +22,8 @@ /* registry.c: the main accessibility service registry implementation */ +#undef SPI_LISTENER_DEBUG + #include #ifdef SPI_DEBUG # include @@ -49,15 +51,14 @@ typedef enum { typedef struct { char *event_name; EventTypeCategory type_cat; - char * major; - char * minor; - char * detail; - guint hash; + GQuark major; /* from string segment[1] */ + GQuark minor; /* from string segment[1]+segment[2] */ + GQuark detail; /* from string segment[3] (not concatenated) */ } EventTypeStruct; typedef struct { Accessibility_EventListener listener; - guint event_type_hash; + GQuark event_type_quark; EventTypeCategory event_type_cat; } SpiListenerStruct; @@ -173,9 +174,9 @@ register_with_toolkits (SpiRegistry *spi_registry_bonobo_object, EventTypeStruct } static gint -compare_listener_hash (gconstpointer p1, gconstpointer p2) +compare_listener_quarks (gconstpointer p1, gconstpointer p2) { - return (((SpiListenerStruct *)p2)->event_type_hash - ((SpiListenerStruct *)p1)->event_type_hash); + return (!((SpiListenerStruct *)p2)->event_type_quark == ((SpiListenerStruct *)p1)->event_type_quark); } static gint @@ -213,37 +214,37 @@ parse_event_type (EventTypeStruct *etype, char *event_name) if (split_string[1]) { - etype->major = g_strdup (split_string[1]); if (split_string[2]) { - etype->minor = g_strdup (split_string[2]); + etype->minor = g_quark_from_string (s = g_strconcat (split_string[1], split_string[2], NULL)); + g_free (s); if (split_string[3]) { - etype->detail = g_strdup (split_string[3]); + etype->detail = g_quark_from_string (split_string[3]); s = g_strconcat (split_string[1], split_string[2], split_string[3], NULL); - etype->hash = g_str_hash (s); + etype->major = g_quark_from_string (s); g_free (s); } else { - etype->detail = g_strdup (""); + etype->detail = g_quark_from_static_string (""); s = g_strconcat (split_string[1], split_string[2], NULL); - etype->hash = g_str_hash (s); + etype->major = g_quark_from_string (s); g_free (s); } } else { - etype->minor = g_strdup (""); - etype->hash = g_str_hash ( split_string[1]); + etype->major = g_quark_from_string (split_string[1]); + etype->minor = etype->major; + etype->detail = etype->major; } } else { - etype->major = g_strdup (""); - etype->minor = g_strdup (""); - etype->detail = g_strdup (""); - etype->hash = g_str_hash (""); + etype->major = g_quark_from_static_string (""); + etype->minor = etype->major; + etype->detail = etype->major; } g_strfreev (split_string); @@ -290,7 +291,7 @@ impl_accessibility_registry_register_global_event_listener ( /* parse, check major event type and add listener accordingly */ parse_event_type (&etype, (char*) event_name); - ls->event_type_hash = etype.hash; + ls->event_type_quark = etype.major; ls->event_type_cat = etype.type_cat; switch (etype.type_cat) @@ -391,14 +392,14 @@ impl_accessibility_registry_deregister_global_event_listener ( if (!listeners) return; - ls.event_type_hash = etype.hash; - list = g_list_find_custom (*listeners, &ls, compare_listener_hash); + ls.event_type_quark = etype.major; + list = g_list_find_custom (*listeners, &ls, compare_listener_quarks); while (list) { spi_listener_struct_free ((SpiListenerStruct *) list->data, ev); *listeners = g_list_delete_link (*listeners, list); - list = g_list_find_custom (*listeners, &ls, compare_listener_hash); + list = g_list_find_custom (*listeners, &ls, compare_listener_quarks); } } @@ -524,26 +525,23 @@ _registry_notify_listeners (GList *listeners, Accessibility_Event e_out; SpiListenerStruct *ls; EventTypeStruct etype; - guint minor_hash; +#ifdef SPI_DEBUG CORBA_string s; +#endif e_out = *e_in; parse_event_type (&etype, e_in->type); - s = g_strconcat (etype.major, etype.minor, NULL); - minor_hash = g_str_hash (s); - g_free (s); - for (l = listeners; l; l = l->next) { ls = (SpiListenerStruct *) l->data; -#ifdef SPI_SPI_LISTENER_DEBUG - fprintf (stderr, "event hashes: %lx %lx %lx\n", ls->event_type_hash, etype.hash, minor_hash); +#ifdef SPI_LISTENER_DEBUG + fprintf (stderr, "event quarks: %lx %lx %lx\n", ls->event_type_quark, etype.major, etype.minor); fprintf (stderr, "event name: %s\n", etype.event_name); #endif - if ((ls->event_type_hash == etype.hash) || (ls->event_type_hash == minor_hash)) + if ((ls->event_type_quark == etype.major) || (ls->event_type_quark == etype.minor)) { #ifdef SPI_DEBUG fprintf (stderr, "notifying listener %d\n", g_list_index (listeners, l->data)); diff --git a/registryd/registry.h b/registryd/registry.h index 79589a8..e9789ee 100644 --- a/registryd/registry.h +++ b/registryd/registry.h @@ -42,7 +42,7 @@ typedef struct { GList *object_listeners; GList *window_listeners; GList *toolkit_listeners; - struct SpiDeviceEventController *device_event_controller; + SpiDeviceEventController *device_event_controller; SpiDesktop *desktop; gboolean (*kbd_event_hook) (gpointer source); } SpiRegistry; -- 2.7.4