2001-12-11 Michael Meeks <michael@ximian.com>
authormichael <michael@e2bd861d-eb25-0410-b326-f6ed22b6b98c>
Tue, 11 Dec 2001 17:58:28 +0000 (17:58 +0000)
committermichael <michael@e2bd861d-eb25-0410-b326-f6ed22b6b98c>
Tue, 11 Dec 2001 17:58:28 +0000 (17:58 +0000)
* libspi/libspi.h: remove registry.h and
desktop.h, deviceeventcontroller.h

* libspi/Makefile.am: remove registry.[ch],
desktop.[ch], deviceeventcontroller.[ch]

* registryd/Makefile.am: add registry.[ch],
desktop.[ch], rename registryd.c to registry-main.c.
add deviceeventcontroller.[ch]

git-svn-id: http://svn.gnome.org/svn/at-spi/trunk@179 e2bd861d-eb25-0410-b326-f6ed22b6b98c

18 files changed:
ChangeLog
TODO
configure.in
libspi/Makefile.am
libspi/desktop.c [deleted file]
libspi/desktop.h [deleted file]
libspi/deviceeventcontroller.c [deleted file]
libspi/deviceeventcontroller.h [deleted file]
libspi/libspi.h
libspi/registry.c [deleted file]
libspi/registry.h [deleted file]
registryd/Makefile.am
registryd/desktop.c
registryd/deviceeventcontroller.c
registryd/deviceeventcontroller.h
registryd/registry.c
registryd/registry.h
test/at.c

index 26e0c11..f115827 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2001-12-11  Michael Meeks  <michael@ximian.com>
+
+       * libspi/libspi.h: remove registry.h and
+       desktop.h, deviceeventcontroller.h
+
+       * libspi/Makefile.am: remove registry.[ch],
+       desktop.[ch], deviceeventcontroller.[ch]
+
+       * registryd/Makefile.am: add registry.[ch],
+       desktop.[ch], rename registryd.c to registry-main.c.
+       add deviceeventcontroller.[ch]
+
 2001-12-11  Bill Haneman <bill.haneman@sun.com>
 
        * test/simple-at.c:
diff --git a/TODO b/TODO
index e0ca69d..5f3729c 100644 (file)
--- a/TODO
+++ b/TODO
@@ -9,15 +9,14 @@ idl:
 
 cspi: 
        + API change required if above IDL change is made. [Bill]
-       + move bonobo bits into cspi/bonobo
        + ensure spi-listener-impl's list notification methods don't
-         have a re-enterancy hazard.
+         have a re-enterancy hazard. [Michael]
        + namespace all methods missing a prepending Acessible
          or SPI_ prefix.
        + Put LGPL headers everywhere.
 
 registry:
-       + move code into here from libspi
+       + 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
index e4fffef..25fabb1 100644 (file)
@@ -1,4 +1,4 @@
-AC_INIT(idl/Accessible.idl)
+AC_INIT(idl/Accessibility.idl)
 
 AT_SPI_MAJOR_VERSION=0
 AT_SPI_MINOR_VERSION=0
@@ -93,6 +93,7 @@ AC_SUBST(LIBSPI_CFLAGS)
 
 PKG_CHECK_MODULES(REGISTRYD, \
        libbonobo-2.0 >= 1.107.0 \
+       gtk+-2.0 \
        atk >= 0.2)
 AC_SUBST(REGISTRYD_LIBS)
 AC_SUBST(REGISTRYD_CFLAGS)
index c2342d0..a7e9df9 100644 (file)
@@ -19,7 +19,6 @@ libspiinclude_HEADERS = Accessibility.h \
                         application.h \
                        base.h \
                        component.h \
-                       deviceeventcontroller.h \
                        editabletext.h\
                        hyperlink.h\
                        hypertext.h\
@@ -72,10 +71,6 @@ libspi_la_SOURCES = accessible.c         \
                    base.c               \
                    component.c          \
                    component.h          \
-                    desktop.c            \
-                    desktop.h            \
-                   deviceeventcontroller.c \
-                   deviceeventcontroller.h \
                    editabletext.c\
                    editabletext.h\
                    hyperlink.c\
@@ -99,8 +94,6 @@ libspi_la_SOURCES = accessible.c         \
                     listener.c           \
                     listener.h           \
                    eventlistener.c      \
-                    registry.c           \
-                    registry.h           \
                    keymasks.h          \
                     $(IDL_OUT)
 
diff --git a/libspi/desktop.c b/libspi/desktop.c
deleted file mode 100644 (file)
index dec8487..0000000
+++ /dev/null
@@ -1,207 +0,0 @@
-/*
- * AT-SPI - Assistive Technology Service Provider Interface
- * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
- *
- * Copyright 2001 Sun Microsystems Inc., Ximian Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/* desktop.c: implements SpiDesktop.idl */
-
-#include <config.h>
-#include <stdio.h>
-#include <libbonobo.h>
-#include <libspi/desktop.h>
-
-/* Our parent Gtk object type */
-#define PARENT_TYPE SPI_ACCESSIBLE_TYPE
-
-typedef struct {
-       SpiDesktop *desktop;
-       Accessibility_Application ref;
-} Application;
-
-/* A pointer to our parent object class */
-static SpiAccessibleClass *parent_class;
-
-static void
-spi_desktop_init (SpiDesktop *desktop)
-{
-  spi_base_construct_default (SPI_BASE (desktop));
-
-  desktop->applications = NULL;
-
-  atk_object_set_name (SPI_BASE (desktop)->atko, "main");
-}
-
-static void
-spi_desktop_dispose (GObject *object)
-{
-  SpiDesktop *desktop = (SpiDesktop *) object;
-
-  while (desktop->applications)
-    {
-      Application *app = (Application *) desktop->applications;
-      spi_desktop_remove_application (desktop, app->ref);
-    }
-
-  G_OBJECT_CLASS (parent_class)->dispose (object); 
-}
-
-static CORBA_long
-impl_desktop_get_child_count (PortableServer_Servant servant,
-                              CORBA_Environment     *ev)
-{
-  SpiDesktop *desktop = SPI_DESKTOP (bonobo_object_from_servant (servant));
-
-  if (desktop->applications)
-    {
-      return g_list_length (desktop->applications);
-    }
-  else
-    {
-      return 0;
-    }
-}
-
-static Accessibility_Accessible
-impl_desktop_get_child_at_index (PortableServer_Servant servant,
-                                 const CORBA_long       index,
-                                 CORBA_Environment     *ev)
-{
-  SpiDesktop  *desktop = SPI_DESKTOP (bonobo_object_from_servant (servant));
-  CORBA_Object retval;
-  Application *app;
-
-  app = g_list_nth_data (desktop->applications, index);
-
-  if (app)
-    {
-      retval = bonobo_object_dup_ref (app->ref, ev);
-      if (BONOBO_EX (ev))
-        {
-         retval = CORBA_OBJECT_NIL;
-       }
-    }
-  else
-    {
-      retval = CORBA_OBJECT_NIL;
-    }
-
-  return (Accessibility_Accessible) retval;
-}
-
-static void
-spi_desktop_class_init (SpiDesktopClass *klass)
-{
-  GObjectClass * object_class = (GObjectClass *) klass;
-  SpiAccessibleClass * spi_accessible_class = (SpiAccessibleClass *) klass;
-  POA_Accessibility_Accessible__epv *epv = &spi_accessible_class->epv;
-
-  object_class->dispose = spi_desktop_dispose;
-  
-  parent_class = g_type_class_ref (SPI_ACCESSIBLE_TYPE);
-
-  epv->_get_childCount = impl_desktop_get_child_count;
-  epv->getChildAtIndex = impl_desktop_get_child_at_index;
-}
-
-BONOBO_TYPE_FUNC_FULL (SpiDesktop,
-                      Accessibility_Desktop,
-                      PARENT_TYPE,
-                      spi_desktop);
-
-SpiDesktop *
-spi_desktop_new (void)
-{
-  SpiDesktop *retval = g_object_new (SPI_DESKTOP_TYPE, NULL);
-
-  return retval;
-}
-
-static void
-abnormal_application_termination (gpointer object, Application *app)
-{
-  g_return_if_fail (SPI_IS_DESKTOP (app->desktop));
-
-  spi_desktop_remove_application (app->desktop, app->ref);
-}
-
-void
-spi_desktop_add_application (SpiDesktop *desktop,
-                            const Accessibility_Application application)
-{
-  CORBA_Environment ev;
-  Application       *app;
-  Accessibility_Application ref;
-
-  g_return_if_fail (SPI_IS_DESKTOP (desktop));
-
-  spi_desktop_remove_application (desktop, application);
-
-  CORBA_exception_init (&ev);
-
-  ref = bonobo_object_dup_ref (application, &ev);
-
-  if (!BONOBO_EX (&ev))
-    {
-      app = g_new (Application, 1);
-      app->desktop = desktop;
-      app->ref = ref;
-
-      desktop->applications = g_list_append (desktop->applications, app);
-
-      ORBit_small_listen_for_broken (app->ref, G_CALLBACK (abnormal_application_termination), app);
-    }
-
-  CORBA_exception_free (&ev);
-}
-
-void
-spi_desktop_remove_application (SpiDesktop *desktop,
-                               const Accessibility_Application app_ref)
-{
-  GList *l;
-  CORBA_Environment ev;
-
-  g_return_if_fail (SPI_IS_DESKTOP (desktop));
-
-  CORBA_exception_init (&ev);
-
-  for (l = desktop->applications; l; l = l->next)
-    {
-      Application *app = (Application *) l->data;
-
-      if (CORBA_Object_is_equivalent (app->ref, app_ref, &ev))
-        {
-         break;
-       }
-    }
-
-  CORBA_exception_free (&ev);
-
-  if (l)
-    {
-      Application *app = (Application *) l->data;
-
-      desktop->applications = g_list_delete_link (desktop->applications, l);
-
-      ORBit_small_unlisten_for_broken (app->ref, G_CALLBACK (abnormal_application_termination));
-      bonobo_object_release_unref (app->ref, NULL);
-      g_free (app);
-    }
-}
diff --git a/libspi/desktop.h b/libspi/desktop.h
deleted file mode 100644 (file)
index 8c60834..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * AT-SPI - Assistive Technology Service Provider Interface
- * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
- *
- * Copyright 2001 Sun Microsystems Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef SPI_DESKTOP_H_
-#define SPI_DESKTOP_H_
-
-#include <libspi/accessible.h>
-
-G_BEGIN_DECLS
-
-#define SPI_DESKTOP_TYPE        (spi_desktop_get_type ())
-#define SPI_DESKTOP(o)          (G_TYPE_CHECK_INSTANCE_CAST ((o), SPI_DESKTOP_TYPE, SpiDesktop))
-#define SPI_DESKTOP_CLASS(k)    (G_TYPE_CHECK_CLASS_CAST((k), SPI_DESKTOP_TYPE, SpiDesktopClass))
-#define SPI_IS_DESKTOP(o)       (G_TYPE_CHECK_INSTANCE_TYPE ((o), SPI_DESKTOP_TYPE))
-#define SPI_IS_DESKTOP_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), SPI_DESKTOP_TYPE))
-
-typedef struct {
-        SpiAccessible parent;
-        GList        *applications;
-} SpiDesktop;
-
-typedef struct {
-        SpiAccessibleClass parent_class;
-        POA_Accessibility_Desktop__epv epv;
-} SpiDesktopClass;
-
-GType       spi_desktop_get_type           (void);
-SpiDesktop *spi_desktop_new                (void);
-void        spi_desktop_add_application    (SpiDesktop *desktop,
-                                           const Accessibility_Application application);
-void        spi_desktop_remove_application (SpiDesktop *desktop,
-                                           const Accessibility_Application application);
-
-G_END_DECLS
-
-#endif /* SPI_DESKTOP_H_ */
diff --git a/libspi/deviceeventcontroller.c b/libspi/deviceeventcontroller.c
deleted file mode 100644 (file)
index 785f4a0..0000000
+++ /dev/null
@@ -1,722 +0,0 @@
-/*
- * AT-SPI - Assistive Technology Service Provider Interface
- * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
- *
- * Copyright 2001 Sun Microsystems Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/* deviceeventcontroler.c: implement the DeviceEventController interface */
-
-#include <config.h>
-
-#ifdef SPI_DEBUG
-#  include <stdio.h>
-#endif
-
-#include <X11/Xlib.h>
-#include <X11/extensions/XTest.h>
-#include <gdk/gdkx.h> /* TODO: hide dependency (wrap in single porting file) */
-#include <gdk/gdkwindow.h>
-
-#include <libspi/deviceeventcontroller.h>
-
-/* Our parent Gtk object type */
-#define PARENT_TYPE BONOBO_TYPE_OBJECT
-
-/* A pointer to our parent object class */
-static GObjectClass *spi_device_event_controller_parent_class;
-
-static gboolean kbd_registered = FALSE;
-
-static Display *display;
-
-static Window root_window;
-
-typedef enum {
-       SPI_DEVICE_TYPE_KBD,
-       SPI_DEVICE_TYPE_MOUSE,
-       SPI_DEVICE_TYPE_LAST_DEFINED
-} SpiDeviceTypeCategory;
-
-struct _DEControllerListener {
-       CORBA_Object          object;
-       SpiDeviceTypeCategory type;
-};
-
-typedef struct _DEControllerListener DEControllerListener;
-
-struct _DEControllerKeyListener {
-       DEControllerListener listener;
-       Accessibility_KeySet *keys;
-       Accessibility_ControllerEventMask *mask;
-       Accessibility_KeyEventTypeSeq *typeseq;
-       gboolean is_system_global;      
-};
-
-typedef struct _DEControllerKeyListener DEControllerKeyListener;
-
-static gboolean _controller_register_with_devices (SpiDeviceEventController *controller);
-static gboolean _controller_grab_keyboard (SpiDeviceEventController *controller);
-
-static void controller_register_device_listener (SpiDeviceEventController *controller,
-                                                DEControllerListener *l,
-                                                CORBA_Environment *ev);
-
-/*
- * Private methods
- */
-
-static gint
-_compare_corba_objects (gconstpointer p1, gconstpointer p2)
-{
-  CORBA_Environment ev;
-  gint retval;
-  retval = !CORBA_Object_is_equivalent ((CORBA_Object) p1, (CORBA_Object) p2, &ev);
-
-#ifdef SPI_DEBUG
-  fprintf (stderr, "comparing %p to %p; result %d\n",
-          p1, p2,
-          retval);
-#endif
-  return retval;  
-}
-
-static gint
-_compare_listeners (gconstpointer p1, gconstpointer p2)
-{
-  DEControllerListener *l1 = (DEControllerListener *) p1;      
-  DEControllerListener *l2 = (DEControllerListener *) p2;      
-  return _compare_corba_objects (l1->object, l2->object);
-}
-
-static gint
-_eventmask_compare_value (gconstpointer p1, gconstpointer p2)
-{
-    long d;
-    if (!p1 || !p2)
-       return (gint) (p1?1:(p2?-1:0));
-    else
-       d = ((long)((Accessibility_ControllerEventMask*)p2)->value) -
-               ((long)((Accessibility_ControllerEventMask*)p1)->value);
-    return (gint) d;
-}
-
-static DEControllerKeyListener *
-dec_key_listener_new (CORBA_Object l,
-                     const Accessibility_KeySet *keys,
-                     const Accessibility_ControllerEventMask *mask,
-                     const Accessibility_KeyEventTypeSeq *typeseq,
-                     const CORBA_boolean is_system_global,
-                     CORBA_Environment *ev)
-{
-  DEControllerKeyListener *key_listener = g_new0 (DEControllerKeyListener, 1);
-  key_listener->listener.object = bonobo_object_dup_ref (l, ev);
-  key_listener->listener.type = SPI_DEVICE_TYPE_KBD;
-  key_listener->keys = ORBit_copy_value (keys, TC_Accessibility_KeySet);
-  key_listener->mask = ORBit_copy_value (mask, TC_Accessibility_ControllerEventMask);
-  key_listener->typeseq = ORBit_copy_value (typeseq, TC_Accessibility_KeyEventTypeSeq);
-  key_listener->is_system_global = is_system_global;
-
-#ifdef SPI_DEBUG
-  g_print ("new listener, with mask %x, is_global %d, keys %p\n",
-          (unsigned int) key_listener->mask->value,
-           (int) key_listener->is_system_global,
-          (void *) key_listener->keys);
-#endif
-  return key_listener; 
-}
-
-static void
-dec_key_listener_free (DEControllerKeyListener *key_listener, CORBA_Environment *ev)
-{
-  bonobo_object_release_unref (key_listener->listener.object, ev);
-  CORBA_free (key_listener->typeseq);
-  CORBA_free (key_listener->mask);
-  CORBA_free (key_listener->keys);
-  g_free (key_listener);
-}
-
-static void
-controller_register_device_listener (SpiDeviceEventController *controller,
-                                    DEControllerListener *listener,
-                                    CORBA_Environment *ev)
-{
-  Accessibility_ControllerEventMask *mask_ptr = NULL;
-  DEControllerKeyListener *key_listener;
-  
-  switch (listener->type) {
-  case SPI_DEVICE_TYPE_KBD:
-      key_listener = (DEControllerKeyListener *) listener;       
-      controller->key_listeners = g_list_prepend (controller->key_listeners, key_listener);
-      if (key_listener->is_system_global)
-        {
-          mask_ptr = (Accessibility_ControllerEventMask *)
-             g_list_find_custom (controller->keymask_list, (gpointer) key_listener->mask,
-                                 _eventmask_compare_value);
-          if (mask_ptr)
-             ++(mask_ptr->refcount);
-          else
-           {
-             if (key_listener->mask->refcount != (CORBA_unsigned_short) 1)
-                     fprintf (stderr, "mask initial refcount is not 1!\n");
-             if (key_listener->mask->value > (CORBA_unsigned_long) 2048)
-                     fprintf (stderr, "mask value looks invalid (%lu)\n",
-                              (unsigned long) key_listener->mask->value);
-             else
-                     fprintf (stderr, "appending mask with val=%lu\n",
-                              (unsigned long) key_listener->mask->value);
-             mask_ptr = Accessibility_ControllerEventMask__alloc();
-             mask_ptr->value = key_listener->mask->value;
-             mask_ptr->refcount = (CORBA_unsigned_short) 1;
-             controller->keymask_list = g_list_append (controller->keymask_list,
-                                                       (gpointer) mask_ptr);
-          }
-       }
-      break;
-  case SPI_DEVICE_TYPE_MOUSE:
-/*    controller->mouse_listeners = g_list_append (controller->mouse_listeners,
-                                                   CORBA_Object_duplicate (l, ev));*/
-
-/* possibly this interface should NOT be used for mouse events ? */
-      break;
-  }
-}
-
-static void
-controller_deregister_device_listener (SpiDeviceEventController *controller,
-                                      DEControllerListener *listener,
-                                      CORBA_Environment *ev)
-{
-  Accessibility_ControllerEventMask *mask_ptr;
-  DEControllerKeyListener *key_listener;
-  DEControllerListener *dec_listener;
-  GList *list_ptr;
-  switch (listener->type) {
-  case SPI_DEVICE_TYPE_KBD:
-      key_listener = (DEControllerKeyListener *) listener;
-      /* first, deref matching event mask, if any */
-      list_ptr = (GList *)
-                 g_list_find_custom (controller->keymask_list, (gpointer) key_listener->mask,
-                                    _eventmask_compare_value);
-      if (list_ptr)
-        {
-         mask_ptr = (Accessibility_ControllerEventMask *) list_ptr->data;
-          if (mask_ptr)
-             --mask_ptr->refcount;
-          if (!mask_ptr->refcount)
-            {
-             controller->keymask_list =
-                     g_list_remove_link (controller->keymask_list, list_ptr);
-             ;  /* TODO: release any key grabs that are in place for this key mask */
-           }
-       }
-      /* now, remove this listener from the keylistener list */
-      list_ptr = g_list_find_custom (controller->key_listeners, listener, _compare_listeners);
-      if (list_ptr)
-        {
-         dec_listener = (DEControllerListener *) list_ptr->data;
-#ifdef SPI_DEBUG         
-         g_print ("removing keylistener %p\n", dec_listener->object);
-#endif
-         controller->key_listeners = g_list_remove_link (controller->key_listeners,
-                                                         list_ptr);
-         dec_key_listener_free ((DEControllerKeyListener *) dec_listener, ev);
-       }
-      break;
-  case SPI_DEVICE_TYPE_MOUSE:
-/*    controller->mouse_listeners = g_list_append (controller->mouse_listeners,
-                                                   CORBA_Object_duplicate (l, ev));*/
-
-/* possibly this interface should NOT be used for mouse events ? */
-      break;
-  }
-}
-
-static gboolean
-_controller_register_with_devices (SpiDeviceEventController *controller)
-{
-  gboolean retval = FALSE;
-
-  /* calls to device-specific implementations and routines go here */
-  /* register with: keyboard hardware code handler */
-  /* register with: (translated) keystroke handler */
-#ifdef SPI_DEBUG
-  fprintf (stderr, "About to request events on window %ld of display %p\n",
-          (unsigned long) GDK_ROOT_WINDOW(), GDK_DISPLAY());
-#endif
-  /* We must open a new connection to the server to avoid clashing with the GDK event loop */
-  display = XOpenDisplay (g_getenv ("DISPLAY"));
-  root_window = DefaultRootWindow (display);           
-  XSelectInput (display,
-               root_window,
-               KeyPressMask | KeyReleaseMask);
-  /* register with: mouse hardware device handler? */
-  /* register with: mouse event handler */
-  return retval;
-}
-
-static gboolean
-key_set_contains_key (Accessibility_KeySet *key_set, Accessibility_KeyStroke *key_event)
-{
-  gint i;
-  gint len;
-
-  /* g_assert (key_set); */
-  if (!key_set) { g_print ("null key set!"); return TRUE; }
-
-  len = key_set->_length;
-  
-  if (len == 0) /* special case, means "all keys/any key" */
-    {
-      return TRUE;
-    }
-
-  for (i=0; i<len; ++i)
-    {
-#ifdef SPI_KEYEVENT_DEBUG          
-      g_print ("key_set[%d] = %d; key_event %d, code %d\n",
-               i,
-              (int) key_set->_buffer[i],
-              (int) key_event->keyID,
-              (int) key_event->keycode); 
-#endif
-      if (key_set->_buffer[i] == (CORBA_long) key_event->keyID) return TRUE;
-      if (key_set->_buffer[i] == (CORBA_long) -key_event->keycode) return TRUE;
-    }
-  
-  return FALSE;
-}
-
-static gboolean
-key_eventtype_seq_contains_event (Accessibility_KeyEventTypeSeq *type_seq,
-                                 Accessibility_KeyStroke *key_event)
-{
-  gint i;
-  gint len;
-
-  /* g_assert (type_seq); */
-  if (!type_seq) { g_print ("null type seq!"); return TRUE; }
-
-  len = type_seq->_length;
-  
-  if (len == 0) /* special case, means "all events/any event" */
-    {
-      return TRUE;
-    }
-
-  for (i=0; i<len; ++i)
-    {
-/*      g_print ("type_seq[%d] = %d\n", i, (int) type_seq->_buffer[i]); */
-      if (type_seq->_buffer[i] == (CORBA_long) key_event->type) return TRUE;       
-    }
-  
-  return TRUE;
-}
-
-static gboolean
-key_event_matches_listener (Accessibility_KeyStroke *key_event,
-                           DEControllerKeyListener *listener,
-                           CORBA_boolean is_system_global)
-{
-  if ((key_event->modifiers == (CORBA_unsigned_short) (listener->mask->value & 0xFFFF)) &&
-       key_set_contains_key (listener->keys, key_event) &&
-       key_eventtype_seq_contains_event (listener->typeseq, key_event) && 
-      (is_system_global == listener->is_system_global))
-    {
-      return TRUE;
-    }
-  else
-    return FALSE;
-}
-
-static gboolean
-notify_keylisteners (GList *key_listeners,
-                    Accessibility_KeyStroke *key_event,
-                    CORBA_boolean is_system_global,
-                    CORBA_Environment *ev)
-{
-  int i, n_listeners = g_list_length (key_listeners);
-  gboolean is_consumed = FALSE;
-
-  for (i=0; i<n_listeners && !is_consumed; ++i)
-    {
-      Accessibility_KeystrokeListener ls;
-      DEControllerKeyListener *key_listener = (DEControllerKeyListener *)
-           g_list_nth_data (key_listeners, i);
-      ls = (Accessibility_KeystrokeListener) key_listener->listener.object;
-      if (key_event_matches_listener (key_event, key_listener, is_system_global))
-        {
-          if (!CORBA_Object_is_nil(ls, ev))
-            {
-             is_consumed = Accessibility_KeystrokeListener_keyEvent (ls, key_event, ev);
-            }          
-        }
-      else
-        {
-#ifdef SPI_KEYEVENT_DEBUG
-             g_print ("no match for listener %d\n", i);
-#endif
-             ;
-       }
-    }
-  return is_consumed;
-}
-
-static gboolean
-_check_key_event (SpiDeviceEventController *controller)
-{
-       static gboolean initialized = FALSE;
-       XEvent *x_event = g_new0 (XEvent, 1);
-       XKeyEvent *x_key_event;
-       KeySym keysym;
-       gboolean is_consumed = FALSE;
-       Accessibility_KeyStroke key_event;
-       static CORBA_Environment ev;
-
-       if (!initialized)
-       {
-         initialized = TRUE;
-         CORBA_exception_init (&ev);
-       }
-
-       while (XPending(display))
-         {
-           XNextEvent (display, x_event);
-           if (XFilterEvent (x_event, None)) continue;   
-           if (x_event->type == KeyPress)
-             {
-               x_key_event = (XKeyEvent *)x_event;
-               keysym = XLookupKeysym (x_key_event, 0);
-               key_event.keyID = (CORBA_long)(keysym);
-               key_event.keycode = (CORBA_short) x_key_event->keycode;
-               key_event.type = Accessibility_KEY_PRESSED;
-               key_event.modifiers = (CORBA_unsigned_short)(x_key_event->state);
-#ifdef SPI_KEYEVENT_DEBUG
-           fprintf (stderr,
-                    "Key %lu pressed (%c), modifiers %d\n",
-                    (unsigned long) keysym,
-                    keysym ? (int) keysym : '*',
-                    (int) x_key_event->state);
-#endif
-#ifdef SPI_DEBUG
-           fprintf (stderr, "%s%c",
-                    (x_key_event->state & Mod1Mask)?"Alt-":"",
-                    ((x_key_event->state & ShiftMask)^(x_key_event->state & LockMask))?
-                    g_ascii_toupper (keysym) : g_ascii_tolower (keysym));
-#endif /* SPI_DEBUG */
-             }
-           else
-           {
-#ifdef SPI_KEYEVENT_DEBUG
-                   fprintf (stderr, "other event, type %d\n", (int) x_event->type);
-#endif
-           }
-           /* relay to listeners, and decide whether to consume it or not */
-           is_consumed = notify_keylisteners (controller->key_listeners, &key_event, CORBA_TRUE, &ev);
-
-           if (is_consumed)
-           {
-             XAllowEvents (display, AsyncKeyboard, CurrentTime);
-           }
-           else
-           {
-             XAllowEvents (display, ReplayKeyboard, CurrentTime);
-           }
-         }
-       XUngrabKey (display, AnyKey, AnyModifier, root_window);
-       return _controller_grab_keyboard (controller);
-}
-
-static gboolean
-_controller_grab_keyboard (SpiDeviceEventController *controller)
-{
-       GList *maskList = controller->keymask_list;
-       int i;
-       int last_mask;
-       last_mask = g_list_length (maskList);
-
-/*
- * masks known to work with default RH 7.1: 
- * 0 (no mods), LockMask, Mod1Mask, Mod2Mask, ShiftMask,
- * ShiftMask|LockMask, Mod1Mask|LockMask, Mod2Mask|LockMask,
- * ShiftMask|Mod1Mask, ShiftMask|Mod2Mask, Mod1Mask|Mod2Mask,
- * ShiftMask|LockMask|Mod1Mask, ShiftMask|LockMask|Mod2Mask,
- *
- * ControlMask grabs are broken, must be in use already
- */
-       
-       for (i=0; i < last_mask; ++i)
-       {
-               Accessibility_ControllerEventMask *mask
-                       = (Accessibility_ControllerEventMask *)g_list_nth_data (maskList, i);
-               unsigned long maskVal = 0xFFFFFFFF;
-               if (mask) maskVal = (unsigned long) mask->value;
-#ifdef SPI_KEYEVENT_DEBUG
-               fprintf (stderr, "mask=%lx\n", maskVal);
-#endif
-               if (!(maskVal & ControlMask))
-               {
-                       XGrabKey (display,
-                                 AnyKey,
-                                 maskVal,
-                                 root_window,
-                                 True,
-                                 GrabModeAsync,
-                                 GrabModeAsync);
-                       /* TODO: check call for errors and return FALSE if error occurs */
-               } else {
-                       return FALSE; /* can't do control key yet */
-               }
-       }
-       return TRUE;
-}
-
-/*
- * Implemented GObject::finalize
- */
-static void
-spi_device_event_controller_object_finalize (GObject *object)
-{
-
-#ifdef SPI_DEBUG
-        fprintf(stderr, "spi_device_event_controller_object_finalize called\n");
-#endif
-       /* disconnect any special listeners, get rid of outstanding keygrabs */
-       
-        spi_device_event_controller_parent_class->finalize (object);
-}
-
-/*
- * CORBA Accessibility::DeviceEventController::registerKeystrokeListener
- *     method implementation
- */
-static void
-impl_register_keystroke_listener (PortableServer_Servant     servant,
-                                 const Accessibility_KeystrokeListener l,
-                                 const Accessibility_KeySet *keys,
-                                 const Accessibility_ControllerEventMask *mask,
-                                 const Accessibility_KeyEventTypeSeq *type,
-                                 const CORBA_boolean is_system_global,
-                                 CORBA_Environment         *ev)
-{
-       SpiDeviceEventController *controller = SPI_DEVICE_EVENT_CONTROLLER (
-               bonobo_object_from_servant (servant));
-       DEControllerKeyListener *dec_listener;
-#ifdef SPI_DEBUG
-       fprintf (stderr, "registering keystroke listener %p with maskVal %lu\n",
-                (void *) l, (unsigned long) mask->value);
-#endif
-       dec_listener = dec_key_listener_new (l, keys, mask, type, is_system_global, ev);
-       controller_register_device_listener (controller, (DEControllerListener *) dec_listener, ev);
-}
-
-/*
- * CORBA Accessibility::DeviceEventController::deregisterKeystrokeListener
- *     method implementation
- */
-static void
-impl_deregister_keystroke_listener (PortableServer_Servant     servant,
-                                   const Accessibility_KeystrokeListener l,
-                                   const Accessibility_KeySet *keys,
-                                   const Accessibility_ControllerEventMask *mask,
-                                   const Accessibility_KeyEventTypeSeq *type,
-                                   const CORBA_boolean is_system_global,
-                                   CORBA_Environment         *ev)
-{
-       SpiDeviceEventController *controller = SPI_DEVICE_EVENT_CONTROLLER (
-               bonobo_object_from_servant (servant));
-       DEControllerKeyListener *key_listener = dec_key_listener_new (l,
-                                                                     keys,
-                                                                     mask,
-                                                                     type,
-                                                                     is_system_global,
-                                                                     ev);
-#ifdef SPI_DEREGISTER_DEBUG
-       fprintf (stderr, "deregistering keystroke listener %p with maskVal %lu\n",
-                (void *) l, (unsigned long) mask->value);
-#endif
-       controller_deregister_device_listener(controller,
-                                             (DEControllerListener *) key_listener,
-                                             ev);
-       dec_key_listener_free (key_listener, ev);
-}
-
-/*
- * CORBA Accessibility::DeviceEventController::registerMouseListener
- *     method implementation
- */
-/*
-static void
-impl_register_mouse_listener (PortableServer_Servant     servant,
-                             const Accessibility_MouseListener *l,
-                             CORBA_Environment         *ev)
-{
-       SpiDeviceEventController *controller = SPI_DEVICE_EVENT_CONTROLLER (
-               bonobo_object_from_servant (servant));
-#ifdef SPI_DEBUG
-       fprintf (stderr, "registering mouse listener %p\n", l);
-#endif
-       controller_register_device_listener(controller, DEVICE_TYPE_MOUSE, l, keys, mask, ev);
-}
-*/
-
-static KeyCode
-keycode_for_keysym (long keysym)
-{
-  return XKeysymToKeycode (display, (KeySym) keysym);
-}
-
-/*
- * CORBA Accessibility::DeviceEventController::registerKeystrokeListener
- *     method implementation
- */
-static void
-impl_generate_key_event (PortableServer_Servant     servant,
-                        const CORBA_long           keycode,
-                        const Accessibility_KeySynthType synth_type,
-                        CORBA_Environment          *ev)
-{
-       long key_synth_code;
-#ifdef SPI_DEBUG
-       fprintf (stderr, "synthesizing keystroke %ld\n", (long) keycode);
-#endif
-       /* TODO: hide/wrap/remove X dependency */
-
-       /* TODO: be accessX-savvy so that keyrelease occurs after sufficient timeout */
-       
-       /*
-        * TODO: when initializing, query for XTest extension before using,
-        * and fall back to XSendEvent() if XTest is not available.
-        */
-       
-       switch (synth_type)
-       {
-       case Accessibility_KEY_PRESS:
-               XTestFakeKeyEvent (GDK_DISPLAY(), (unsigned int) keycode, True, CurrentTime);
-               break;
-       case Accessibility_KEY_PRESSRELEASE:
-               XTestFakeKeyEvent (GDK_DISPLAY(), (unsigned int) keycode, True, CurrentTime);
-       case Accessibility_KEY_RELEASE:
-               XTestFakeKeyEvent (GDK_DISPLAY(), (unsigned int) keycode, False, CurrentTime);
-               break;
-       case Accessibility_KEY_SYM:
-               key_synth_code = keycode_for_keysym (keycode);
-               XTestFakeKeyEvent (GDK_DISPLAY(), (unsigned int) key_synth_code, True, CurrentTime);
-               XTestFakeKeyEvent (GDK_DISPLAY(), (unsigned int) key_synth_code, False, CurrentTime);
-               break;
-       }
-}
-
-/* Accessibility::DeviceEventController::generateMouseEvent */
-static void
-impl_generate_mouse_event (PortableServer_Servant servant,
-                          const CORBA_long       x,
-                          const CORBA_long       y,
-                          const CORBA_char      *eventName,
-                          CORBA_Environment     *ev)
-{
-#ifdef SPI_DEBUG
-  fprintf (stderr, "generating mouse %s event at %ld, %ld\n", eventName, x, y);
-#endif
-}
-
-/* Accessibility::DeviceEventController::notifyListenersSync */
-static CORBA_boolean
-impl_notify_listeners_sync(PortableServer_Servant     servant,
-                          const Accessibility_DeviceEvent *event,
-                          CORBA_Environment         *ev)
-{
-  SpiDeviceEventController *controller = SPI_DEVICE_EVENT_CONTROLLER (
-                                         bonobo_object_from_servant (servant));
-  Accessibility_KeyStroke *key_event = (Accessibility_KeyStroke *) event;      
-#ifdef SPI_DEBUG
-  g_print ("notifying listeners synchronously: controller %x, event id %d\n",
-          (void *) controller, (int) event->eventID);
-#endif
-  return (notify_keylisteners (controller->key_listeners, key_event, CORBA_FALSE, ev) ?
-         CORBA_TRUE : CORBA_FALSE); 
-}
-
-/* Accessibility::DeviceEventController::notifyListenersAsync */
-static void
-impl_notify_listeners_async (PortableServer_Servant     servant,
-                            const Accessibility_DeviceEvent *event,
-                            CORBA_Environment         *ev)
-{
-  SpiDeviceEventController *controller = SPI_DEVICE_EVENT_CONTROLLER(
-                                        bonobo_object_from_servant (servant));
-  Accessibility_KeyStroke *key_event = (Accessibility_KeyStroke *) event;      
-#ifdef SPI_DEBUG
-  fprintf (stderr, "notifying listeners asynchronously\n");
-#endif
-  notify_keylisteners (controller->key_listeners, key_event, CORBA_FALSE, ev); 
-}
-
-static void
-spi_device_event_controller_class_init (SpiDeviceEventControllerClass *klass)
-{
-        GObjectClass * object_class = (GObjectClass *) klass;
-        POA_Accessibility_DeviceEventController__epv *epv = &klass->epv;
-        spi_device_event_controller_parent_class = g_type_class_peek_parent (klass);
-
-        object_class->finalize = spi_device_event_controller_object_finalize;
-
-        epv->registerKeystrokeListener = impl_register_keystroke_listener;
-        epv->deregisterKeystrokeListener = impl_deregister_keystroke_listener;
-/*        epv->registerMouseListener = impl_register_mouse_listener; */
-        epv->generateKeyEvent = impl_generate_key_event;
-        epv->generateMouseEvent = impl_generate_mouse_event;
-       epv->notifyListenersSync = impl_notify_listeners_sync;
-       epv->notifyListenersAsync = impl_notify_listeners_async;
-       klass->check_key_event = _check_key_event;
-}
-
-static void
-spi_device_event_controller_init (SpiDeviceEventController *device_event_controller)
-{
-  device_event_controller->key_listeners = NULL;
-  device_event_controller->mouse_listeners = NULL;
-  device_event_controller->keymask_list = NULL;
-  kbd_registered = _controller_register_with_devices (device_event_controller);
-}
-
-gboolean
-spi_device_event_controller_check_key_event (SpiDeviceEventController *controller)
-{
-       SpiDeviceEventControllerClass *klass = SPI_DEVICE_EVENT_CONTROLLER_GET_CLASS (controller);
-       if (klass->check_key_event)
-               return (klass->check_key_event) (controller);
-       return FALSE;
-}
-
-SpiDeviceEventController *
-spi_device_event_controller_new (void *registryp)
-{
-  BonoboObject *registry = (BonoboObject *) registryp; 
-  SpiDeviceEventController *retval = g_object_new (
-         SPI_DEVICE_EVENT_CONTROLLER_TYPE, NULL);
-  retval->registry = registry;
-  bonobo_object_ref (registry);
-  return retval;
-}
-
-BONOBO_TYPE_FUNC_FULL (SpiDeviceEventController,
-                      Accessibility_DeviceEventController,
-                      PARENT_TYPE,
-                      spi_device_event_controller);
-
diff --git a/libspi/deviceeventcontroller.h b/libspi/deviceeventcontroller.h
deleted file mode 100644 (file)
index 8b9ba60..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * AT-SPI - Assistive Technology Service Provider Interface
- * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
- *
- * Copyright 2001 Sun Microsystems Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef SPI_DEVICE_EVENT_CONTROLLER_H_
-#define SPI_DEVICE_EVENT_CONTROLLER_H_
-
-#include <bonobo/bonobo-object.h>
-#include <libspi/Accessibility.h>
-#include <libspi/keystrokelistener.h>
-#include <libspi/registry.h>
-
-G_BEGIN_DECLS
-
-#define SPI_DEVICE_EVENT_CONTROLLER_TYPE        (spi_device_event_controller_get_type ())
-#define SPI_DEVICE_EVENT_CONTROLLER(o)          (G_TYPE_CHECK_INSTANCE_CAST ((o), SPI_DEVICE_EVENT_CONTROLLER_TYPE, SpiDeviceEventController))
-#define SPI_DEVICE_EVENT_CONTROLLER_CLASS(k)    (G_TYPE_CHECK_CLASS_CAST((k), SPI_DEVICE_EVENT_CONTROLLER_TYPE, SpiDeviceEventControllerClass))
-#define SPI_IS_DEVICE_EVENT_CONTROLLER(o)       (G_TYPE_CHECK_INSTANCE_TYPE ((o), SPI_DEVICE_EVENT_CONTROLLER_TYPE))
-#define SPI_IS_DEVICE_EVENT_CONTROLLER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), SPI_DEVICE_EVENT_CONTROLLER_TYPE))
-#define SPI_DEVICE_EVENT_CONTROLLER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SPI_DEVICE_EVENT_CONTROLLER_TYPE, SpiDeviceEventControllerClass))
-
-typedef struct {
-        BonoboObject parent;
-       void  *registry;
-        GList *key_listeners;
-        GList *mouse_listeners;
-       GList *keymask_list;
-} SpiDeviceEventController;
-
-typedef struct {
-        BonoboObjectClass parent_class;
-        POA_Accessibility_DeviceEventController__epv epv;
-       gboolean (*check_key_event) (SpiDeviceEventController *controller);
-} SpiDeviceEventControllerClass;
-
-GType                     spi_device_event_controller_get_type        (void);
-SpiDeviceEventController *spi_device_event_controller_new             (void *registry);
-gboolean                  spi_device_event_controller_check_key_event (SpiDeviceEventController *controller);
-
-G_END_DECLS
-
-#endif /* DEVICEEVENTCONTROLLER_H_ */
index d3f18dd..1d07ad6 100644 (file)
@@ -26,7 +26,6 @@
 #include <libspi/action.h>
 #include <libspi/application.h>
 #include <libspi/component.h>
-#include <libspi/desktop.h>
 #include <libspi/editabletext.h>
 #include <libspi/hyperlink.h>
 #include <libspi/hypertext.h>
@@ -39,8 +38,6 @@
 #include <libspi/listener.h>
 #include <libspi/eventlistener.h>
 #include <libspi/keystrokelistener.h>
-#include <libspi/deviceeventcontroller.h>
-#include <libspi/registry.h>
 #include <libspi/keymasks.h>
 
 #endif /* LIBSPI_H_ */
diff --git a/libspi/registry.c b/libspi/registry.c
deleted file mode 100644 (file)
index 13fe752..0000000
+++ /dev/null
@@ -1,622 +0,0 @@
-/*
- * AT-SPI - Assistive Technology Service Provider Interface
- * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
- *
- * Copyright 2001 Sun Microsystems Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/* registry.c: the main accessibility service registry implementation */
-
-#include <config.h>
-#ifdef SPI_DEBUG
-#  include <stdio.h>
-#endif
-
-#include <libspi/registry.h>
-
-/* Our parent GObject type  */
-#define PARENT_TYPE SPI_LISTENER_TYPE
-
-/* A pointer to our parent object class */
-static SpiListenerClass *spi_registry_parent_class;
-
-typedef enum {
-  ETYPE_FOCUS,
-  ETYPE_OBJECT,
-  ETYPE_PROPERTY,
-  ETYPE_WINDOW,
-  ETYPE_TOOLKIT,
-  ETYPE_KEYBOARD,
-  
-  ETYPE_LAST_DEFINED
-} EventTypeCategory;
-
-typedef struct {
-  char *event_name;
-  EventTypeCategory type_cat;
-  char * major;
-  char * minor;
-  char * detail;
-  guint hash;
-} EventTypeStruct;
-
-typedef struct {
-  Accessibility_EventListener listener;
-  guint event_type_hash;
-  EventTypeCategory event_type_cat;
-} SpiListenerStruct;
-
-/* static function prototypes */
-static void _registry_notify_listeners (GList *listeners,
-                                        const Accessibility_Event *e,
-                                        CORBA_Environment *ev);
-
-static long _get_unique_id();
-
-static gboolean _device_event_controller_hook (gpointer source);
-
-SpiListenerStruct *
-spi_listener_struct_new (Accessibility_EventListener listener, CORBA_Environment *ev)
-{
-  SpiListenerStruct *retval = g_malloc (sizeof (SpiListenerStruct));
-  retval->listener = bonobo_object_dup_ref (listener, ev);
-  return retval;
-}
-
-void
-spi_listener_struct_free (SpiListenerStruct *ls, CORBA_Environment *ev)
-{
-  bonobo_object_release_unref (ls->listener, ev);
-  g_free (ls);
-}
-
-/* GObject::finalize */
-static void
-spi_registry_object_finalize (GObject *object)
-{
-        SpiRegistry *registry = SPI_REGISTRY (object);
-
-        printf("spi_registry_object_finalize called\n");
-       /* TODO: unref deviceeventcontroller, which disconnects key listener */
-        G_OBJECT_CLASS (spi_registry_parent_class)->finalize (object);
-}
-
-/**
- * registerApplication:
- * @application: a reference to the requesting @Application
- * return values: void
- *
- * Register a new application with the accessibility broker.
- *
- **/
-static void
-impl_accessibility_registry_register_application (PortableServer_Servant servant,
-                                                  const Accessibility_Application application,
-                                                  CORBA_Environment * ev)
-{
-  SpiRegistry *registry = SPI_REGISTRY (bonobo_object_from_servant (servant));
-
-#ifdef SPI_DEBUG
-  fprintf (stderr, "registering app %p\n", application);
-#endif
-  spi_desktop_add_application (registry->desktop, application);
-
-  Accessibility_Application__set_id (application, _get_unique_id(), ev);
-
-  /*
-   * TODO: change the implementation below to a WM-aware one;
-   * e.g. don't add all apps to the SpiDesktop
-   */
-}
-
-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)
-{
-  gchar **split_string;
-  gchar *s;
-
-  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 = g_strdup (split_string[1]);
-      if (split_string[2])
-        {
-          etype->minor = g_strdup (split_string[2]);
-          if (split_string[3])
-            {
-              etype->detail = g_strdup (split_string[3]);
-             s = g_strconcat (split_string[1], split_string[2], split_string[3], NULL);
-              etype->hash = g_str_hash (s);
-             g_free (s);
-            }
-          else
-            {
-              etype->detail = g_strdup ("");
-             s = g_strconcat (split_string[1], split_string[2], NULL);
-             etype->hash = g_str_hash (s);
-             g_free (s);
-            }
-        }
-      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 ("");
-    }
-
-  g_strfreev (split_string);
-}
-
-/**
- * deregisterApplication:
- * @application: a reference to the @Application
- * to be deregistered.
- * return values: void
- *
- * De-register an application previously registered with the broker.
- *
- **/
-static void
-impl_accessibility_registry_deregister_application (PortableServer_Servant servant,
-                                                    const Accessibility_Application application,
-                                                    CORBA_Environment * ev)
-{
-  SpiRegistry *registry = SPI_REGISTRY (bonobo_object_from_servant (servant));
-
-  spi_desktop_remove_application (registry->desktop, application);
-
-#ifdef SPI_DEBUG
-  fprintf (stderr, "de-registered app %p\n", application);
-#endif
-}
-
-/*
- * CORBA Accessibility::Registry::registerGlobalEventListener method implementation
- */
-static void
-impl_accessibility_registry_register_global_event_listener (
-                                            PortableServer_Servant  servant,
-                                             Accessibility_EventListener listener,
-                                             const CORBA_char *event_name,
-                                             CORBA_Environment      *ev)
-{
-  SpiRegistry *registry = SPI_REGISTRY (bonobo_object_from_servant (servant));
-  SpiListenerStruct *ls = spi_listener_struct_new (listener, ev);
-  EventTypeStruct etype;
-
-  fprintf(stderr, "registering for events of type %s\n", event_name);
-
-  /* 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_cat = etype.type_cat;
-
-  switch (etype.type_cat)
-    {
-    case (ETYPE_FOCUS) :
-    case (ETYPE_OBJECT) :
-    case (ETYPE_PROPERTY) :
-      registry->object_listeners =
-        g_list_append (registry->object_listeners, ls);
-      break;
-    case (ETYPE_WINDOW) :
-      /* Support for Window Manager Events is not yet implemented */
-      spi_listener_struct_free (ls, ev);
-      break;
-    case (ETYPE_TOOLKIT) :
-      registry->toolkit_listeners =
-        g_list_append (registry->toolkit_listeners, ls);
-      register_with_toolkits (registry, &etype, ev);
-      break;
-    default:
-      spi_listener_struct_free (ls, ev);
-      break;
-    }
-}
-
-/*
- * CORBA Accessibility::Registry::deregisterGlobalEventListenerAll method implementation
- */
-static void
-impl_accessibility_registry_deregister_global_event_listener_all (
-                                                    PortableServer_Servant  servant,
-                                                    Accessibility_EventListener listener,
-                                                    CORBA_Environment      *ev)
-{
-  SpiRegistry *registry = SPI_REGISTRY (bonobo_object_from_servant (servant));
-  SpiListenerStruct *ls = spi_listener_struct_new (listener, ev);
-  GList *list;
-  list = g_list_find_custom (registry->object_listeners, ls,
-                            compare_listener_corbaref);
-
-  /*
-   * TODO : de-register with toolkit if the last instance of a listener
-   *        to a particular toolkit event type has been deregistered.
-   */
-
-  while (list)
-    {
-      spi_listener_struct_free ((SpiListenerStruct *) list->data, ev);
-      registry->object_listeners = g_list_delete_link (registry->object_listeners, list);
-      list = g_list_find_custom (registry->object_listeners, ls, compare_listener_corbaref);
-    }
-  list = g_list_find_custom (registry->toolkit_listeners, ls, compare_listener_corbaref);
-  while (list)
-    {
-      spi_listener_struct_free ((SpiListenerStruct *) list->data, ev);
-      registry->toolkit_listeners = g_list_delete_link (registry->toolkit_listeners, list);
-      list = g_list_find_custom (registry->toolkit_listeners, ls, compare_listener_corbaref);
-    }
-  spi_listener_struct_free (ls, ev);
-}
-
-/*
- * CORBA Accessibility::Registry::deregisterGlobalEventListener method implementation
- */
-static void
-impl_accessibility_registry_deregister_global_event_listener (
-                                                    PortableServer_Servant  servant,
-                                                    Accessibility_EventListener listener,
-                                                    const CORBA_char * event_name,
-                                                    CORBA_Environment      *ev)
-{
-  SpiRegistry *registry = SPI_REGISTRY (bonobo_object_from_servant (servant));
-  SpiListenerStruct ls;
-  EventTypeStruct etype;
-  GList *list;
-  GList **listeners;
-
-  parse_event_type (&etype, (char *) event_name);
-  switch (etype.type_cat)
-    {
-    case (ETYPE_OBJECT) :
-    case (ETYPE_PROPERTY) :
-    case (ETYPE_FOCUS) :
-      listeners = &registry->object_listeners;
-      break;
-    case (ETYPE_WINDOW) :
-      /* Support for Window Manager Events is not yet implemented */
-      listeners = NULL;
-      break;
-    case (ETYPE_TOOLKIT) :
-      listeners = &registry->toolkit_listeners;
-      break;
-    default:
-      listeners = NULL;
-      break;
-    }
-
-  if (!listeners)
-         return;
-
-  ls.event_type_hash = etype.hash;
-  list = g_list_find_custom (*listeners, &ls, compare_listener_hash);
-
-  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);
-    }
-}
-
-
-/**
- * getDesktopCount:
- * return values: a short integer indicating the current number of
- * @Desktops.
- *
- * Get the current number of desktops.
- *
- **/
-static short
-impl_accessibility_registry_get_desktop_count (PortableServer_Servant servant,
-                                               CORBA_Environment * ev)
-{
-  /* TODO: implement support for multiple virtual desktops */
-  CORBA_short n_desktops;
-  n_desktops = (CORBA_short) 1;
-  return n_desktops;
-}
-
-/**
- * getDesktop:
- * @n: the index of the requested @Desktop.
- * return values: a reference to the requested @Desktop.
- *
- * Get the nth accessible desktop.
- *
- **/
-static Accessibility_Desktop
-impl_accessibility_registry_get_desktop (PortableServer_Servant servant,
-                                         const CORBA_short n,
-                                         CORBA_Environment * ev)
-{
-  SpiRegistry *registry = SPI_REGISTRY (bonobo_object_from_servant (servant));
-
-  /* TODO: implement support for multiple virtual desktops */
-  if (n == 0)
-    {
-      return (Accessibility_Desktop)
-        bonobo_object_dup_ref (BONOBO_OBJREF (registry->desktop), ev);
-    }
-  else
-    {
-      return (Accessibility_Desktop) CORBA_OBJECT_NIL;
-    }
-}
-
-/**
- * getDesktopList:
- * return values: a sequence containing references to
- * the @Desktops.
- *
- * Get a list of accessible desktops.
- *
- **/
-static Accessibility_DesktopSeq *
-impl_accessibility_registry_get_desktop_list (PortableServer_Servant servant,
-                                              CORBA_Environment * ev)
-{
-  /* TODO: implement support for multiple virtual desktops */
-  return (Accessibility_DesktopSeq *) NULL;
-}
-
-static Accessibility_DeviceEventController
-impl_accessibility_registry_get_device_event_controller (PortableServer_Servant servant,
-                                                         CORBA_Environment * ev)
-{
-  SpiRegistry *registry = SPI_REGISTRY (bonobo_object_from_servant (servant));
-  if (!registry->device_event_controller)
-    registry->device_event_controller = spi_device_event_controller_new (registry);
-
-  return bonobo_object_dup_ref (BONOBO_OBJREF (registry->device_event_controller), ev);
-}
-
-static void
-impl_registry_notify_event (PortableServer_Servant servant,
-                            const Accessibility_Event *e,
-                            CORBA_Environment *ev)
-{
-  SpiRegistry *registry = SPI_REGISTRY (bonobo_object_from_servant (servant));
-  EventTypeStruct etype;
-
-  parse_event_type (&etype, e->type);
-
-  switch (etype.type_cat)
-    {
-    case (ETYPE_OBJECT) :
-    case (ETYPE_PROPERTY) :
-    case (ETYPE_FOCUS) :
-      _registry_notify_listeners (registry->object_listeners, e, ev); 
-      break;
-    case (ETYPE_WINDOW) :
-      _registry_notify_listeners (registry->window_listeners, e, ev);
-      break;
-    case (ETYPE_TOOLKIT) :
-      _registry_notify_listeners (registry->toolkit_listeners, e, ev); 
-      break;
-    case (ETYPE_KEYBOARD) :
-    default:
-      break;
-    }
-  if (e->source != CORBA_OBJECT_NIL)
-    {
-      Accessibility_Accessible_unref (e->source, ev);
-    }
-}
-
-static long
-_get_unique_id ()
-{
-  static long id = 0;
-  return ++id;
-}
-
-static void
-_registry_notify_listeners (GList *listeners,
-                            const Accessibility_Event *e_in,
-                            CORBA_Environment *ev)
-{
-  GList              *l;
-  Accessibility_Event e_out;
-  SpiListenerStruct  *ls;
-  EventTypeStruct     etype;
-  guint               minor_hash;
-  CORBA_string        s;
-
-  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);
-      fprintf (stderr, "event name: %s\n", etype.event_name);
-#endif
-
-      if ((ls->event_type_hash == etype.hash) || (ls->event_type_hash == minor_hash))
-        {
-#ifdef SPI_DEBUG
-          fprintf (stderr, "notifying listener %d\n", g_list_index (listeners, l->data));
-          s = Accessibility_Accessible__get_name (e_in->source, ev);
-         fprintf (stderr, "event source name %s\n", s);
-         CORBA_free (s);
-#endif
-         e_out.source = bonobo_object_dup_ref (e_in->source, ev);
-          Accessibility_EventListener_notifyEvent ((Accessibility_EventListener) ls->listener,
-                                                   &e_out,
-                                                   ev);
-          if (ev->_major != CORBA_NO_EXCEPTION)
-            {
-              g_warning ("Accessibility app error: exception during event notification: %s\n",
-                      CORBA_exception_id (ev));
-           }
-        }
-    }
-}
-
-static gboolean
-_device_event_controller_hook (gpointer p)
-{
-    SpiRegistry *registry = (SpiRegistry *)p;
-    SpiDeviceEventController *controller = registry->device_event_controller;
-    if (controller)
-       spi_device_event_controller_check_key_event (controller);
-    return TRUE;
-}
-
-static void
-spi_registry_class_init (SpiRegistryClass *klass)
-{
-        GObjectClass * object_class = (GObjectClass *) klass;
-        POA_Accessibility_Registry__epv *epv = &klass->epv;
-
-        spi_registry_parent_class = g_type_class_ref (SPI_LISTENER_TYPE);
-
-        object_class->finalize = spi_registry_object_finalize;
-
-        epv->registerApplication = impl_accessibility_registry_register_application;
-        epv->deregisterApplication = impl_accessibility_registry_deregister_application;
-        epv->registerGlobalEventListener = impl_accessibility_registry_register_global_event_listener;
-        epv->deregisterGlobalEventListener = impl_accessibility_registry_deregister_global_event_listener;
-        epv->deregisterGlobalEventListenerAll = impl_accessibility_registry_deregister_global_event_listener_all;
-        epv->getDeviceEventController = impl_accessibility_registry_get_device_event_controller;
-        epv->getDesktopCount = impl_accessibility_registry_get_desktop_count;
-        epv->getDesktop = impl_accessibility_registry_get_desktop;
-        epv->getDesktopList = impl_accessibility_registry_get_desktop_list;
-
-        ((SpiListenerClass *) klass)->epv.notifyEvent = impl_registry_notify_event;
-}
-
-static void
-spi_registry_init (SpiRegistry *registry)
-{
-  registry->object_listeners = NULL;
-  registry->window_listeners = NULL;
-  registry->toolkit_listeners = NULL;
-  registry->desktop = spi_desktop_new();
-  registry->device_event_controller = NULL;
-  registry->kbd_event_hook = _device_event_controller_hook;
-}
-
-BONOBO_TYPE_FUNC_FULL (SpiRegistry,
-                      Accessibility_Registry,
-                      PARENT_TYPE,
-                      spi_registry);
-
-SpiRegistry *
-spi_registry_new (void)
-{
-    SpiRegistry *retval = g_object_new (SPI_REGISTRY_TYPE, NULL);
-    bonobo_object_set_immortal (BONOBO_OBJECT (retval), TRUE);
-    return retval;
-}
diff --git a/libspi/registry.h b/libspi/registry.h
deleted file mode 100644 (file)
index dbb7a81..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * AT-SPI - Assistive Technology Service Provider Interface
- * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
- *
- * Copyright 2001 Sun Microsystems Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef SPI_REGISTRY_H_
-#define SPI_REGISTRY_H_
-
-#include <glib/gmain.h>
-#include <libspi/listener.h>
-#include <libspi/desktop.h>
-#include <libspi/deviceeventcontroller.h>
-
-G_BEGIN_DECLS
-
-#define SPI_REGISTRY_TYPE        (spi_registry_get_type ())
-#define SPI_REGISTRY(o)          (G_TYPE_CHECK_INSTANCE_CAST ((o), SPI_REGISTRY_TYPE, SpiRegistry))
-#define SPI_REGISTRY_CLASS(k)    (G_TYPE_CHECK_CLASS_CAST((k), SPI_REGISTRY_TYPE, SpiRegistryClass))
-#define SPI_IS_REGISTRY(o)       (G_TYPE_CHECK__INSTANCE_TYPE ((o), SPI_REGISTRY_TYPE))
-#define SPI_IS_REGISTRY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), SPI_REGISTRY_TYPE))
-
-typedef struct {
-  SpiListener parent;
-  GList *object_listeners;
-  GList *window_listeners;
-  GList *toolkit_listeners;
-  struct SpiDeviceEventController *device_event_controller;
-  SpiDesktop *desktop;
-  gboolean (*kbd_event_hook) (gpointer source);
-} SpiRegistry;
-
-typedef struct {
-        SpiListenerClass parent_class;
-        POA_Accessibility_Registry__epv epv;
-} SpiRegistryClass;
-
-GType        spi_registry_get_type (void);
-SpiRegistry *spi_registry_new      (void);
-
-G_END_DECLS
-
-#endif /* SPI_REGISTRY_H_ */
index 403397e..2ec4a12 100644 (file)
@@ -6,7 +6,14 @@ INCLUDES = -I$(top_srcdir)          \
            -I$(top_srcdir)/libspi   \
            $(REGISTRYD_CFLAGS)
 
-registryd_SOURCES = registryd.c
+registryd_SOURCES =            \
+       desktop.c               \
+       desktop.h               \
+       deviceeventcontroller.c \
+       deviceeventcontroller.h \
+       registry-main.c         \
+       registry.c              \
+       registry.h
 
 LDADD = ../libspi/libspi.la -lXtst $(REGISTRYD_LIBS) 
 
index dec8487..35063b4 100644 (file)
@@ -25,7 +25,7 @@
 #include <config.h>
 #include <stdio.h>
 #include <libbonobo.h>
-#include <libspi/desktop.h>
+#include "desktop.h"
 
 /* Our parent Gtk object type */
 #define PARENT_TYPE SPI_ACCESSIBLE_TYPE
index 785f4a0..964fb90 100644 (file)
@@ -33,7 +33,7 @@
 #include <gdk/gdkx.h> /* TODO: hide dependency (wrap in single porting file) */
 #include <gdk/gdkwindow.h>
 
-#include <libspi/deviceeventcontroller.h>
+#include "deviceeventcontroller.h"
 
 /* Our parent Gtk object type */
 #define PARENT_TYPE BONOBO_TYPE_OBJECT
index 8b9ba60..700c84a 100644 (file)
@@ -26,7 +26,6 @@
 #include <bonobo/bonobo-object.h>
 #include <libspi/Accessibility.h>
 #include <libspi/keystrokelistener.h>
-#include <libspi/registry.h>
 
 G_BEGIN_DECLS
 
index 13fe752..a12880e 100644 (file)
@@ -27,7 +27,7 @@
 #  include <stdio.h>
 #endif
 
-#include <libspi/registry.h>
+#include "registry.h"
 
 /* Our parent GObject type  */
 #define PARENT_TYPE SPI_LISTENER_TYPE
index dbb7a81..79589a8 100644 (file)
@@ -25,8 +25,9 @@
 
 #include <glib/gmain.h>
 #include <libspi/listener.h>
-#include <libspi/desktop.h>
-#include <libspi/deviceeventcontroller.h>
+
+#include "desktop.h"
+#include "deviceeventcontroller.h"
 
 G_BEGIN_DECLS
 
index f65bc8c..1c2c185 100644 (file)
--- a/test/at.c
+++ b/test/at.c
@@ -26,7 +26,6 @@
 #include <libspi/Accessibility.h>
 #include "accessible.h"
 #include "listener.h"
-#include "desktop.h"
 
 void
 check_ev (CORBA_Environment *ev, char *desc)