+}
+
+static gint
+compare_corba_objects (gconstpointer p1, gconstpointer p2)
+{
+ CORBA_Environment ev;
+ gint retval;
+
+#ifdef SPI_DEBUG
+ fprintf (stderr, "comparing %p to %p\n",
+ p1, p2);
+#endif
+
+ retval = !CORBA_Object_is_equivalent ((CORBA_Object) p1, (CORBA_Object) p2, &ev);
+ return retval;
+}
+
+static void
+register_with_toolkits (SpiRegistry *spi_registry_bonobo_object, EventTypeStruct *etype, CORBA_Environment *ev)
+{
+ gint n_desktops;
+ gint n_apps;
+ gint i, j;
+ Accessibility_Desktop desktop;
+ Accessibility_Application app;
+ Accessibility_Registry registry;
+ registry = BONOBO_OBJREF (spi_registry_bonobo_object);
+
+ /* for each app in each desktop, call ...Application_registerToolkitEventListener */
+
+ n_desktops = Accessibility_Registry_getDesktopCount (registry, ev);
+
+ for (i=0; i<n_desktops; ++i)
+ {
+ desktop = Accessibility_Registry_getDesktop (registry, i, ev);
+ n_apps = Accessibility_Desktop__get_childCount (desktop, ev);
+ for (j=0; j<n_apps; ++j)
+ {
+ app = (Accessibility_Application) Accessibility_Desktop_getChildAtIndex (desktop,
+ j,
+ ev);
+ Accessibility_Application_registerToolkitEventListener (app,
+ registry,
+ CORBA_string_dup (etype->event_name),
+
+ ev);
+ }
+ }
+}
+
+static gint
+compare_listener_hash (gconstpointer p1, gconstpointer p2)
+{
+ return (((SpiListenerStruct *)p2)->event_type_hash - ((SpiListenerStruct *)p1)->event_type_hash);
+}
+
+static gint
+compare_listener_corbaref (gconstpointer p1, gconstpointer p2)
+{
+ return compare_corba_objects (((SpiListenerStruct *)p2)->listener,
+ ((SpiListenerStruct *)p1)->listener);
+}
+
+static void
+parse_event_type (EventTypeStruct *etype, char *event_name)
+{
+ guint nbytes = 0;
+ gchar **split_string;
+
+ split_string = g_strsplit(event_name, ":", 4);
+ etype->event_name = g_strndup(event_name, 255);
+
+ if (!g_ascii_strncasecmp (event_name, "focus:", 6))
+ {
+ etype->type_cat = ETYPE_FOCUS;
+ }
+ else if (!g_ascii_strncasecmp (event_name, "object:", 7))
+ {
+ etype->type_cat = ETYPE_OBJECT;
+ }
+ else if (!g_ascii_strncasecmp (event_name, "window:", 7))
+ {
+ etype->type_cat = ETYPE_WINDOW;
+ }
+ else
+ {
+ etype->type_cat = ETYPE_TOOLKIT;
+ }
+
+ if (split_string[1])
+ {
+ etype->major = split_string[1];
+ if (split_string[2])
+ {
+ etype->minor = split_string[2];
+ if (split_string[3])
+ {
+ etype->detail = split_string[3];
+ etype->hash = g_str_hash ( g_strconcat (split_string[1], split_string[2], split_string[3], NULL));
+ }
+ else
+ {
+ etype->detail = g_strdup ("");
+ etype->hash = g_str_hash ( g_strconcat (split_string[1], split_string[2], NULL));
+ }
+ }
+ else
+ {
+ etype->minor = g_strdup ("");
+ etype->hash = g_str_hash ( split_string[1]);
+ }
+ }
+ else
+ {
+ etype->major = g_strdup ("");
+ etype->minor = g_strdup ("");
+ etype->detail = g_strdup ("");
+ etype->hash = g_str_hash ("");
+ }
+
+ /* TODO: don't forget to free the strings from caller when done ! */