2001-12-08 Michael Meeks <michael@ximian.com>
authormichael <michael@e2bd861d-eb25-0410-b326-f6ed22b6b98c>
Sat, 8 Dec 2001 19:17:17 +0000 (19:17 +0000)
committermichael <michael@e2bd861d-eb25-0410-b326-f6ed22b6b98c>
Sat, 8 Dec 2001 19:17:17 +0000 (19:17 +0000)
* at-bridge/bridge.c (bridge_focus_tracker),
(emit_eventv): fix the same ref. leak.
(register_atk_event_listeners): don't leak.

* cspi/spi-listener-impl.c (cspi_event): more
protection from client code.

* test/test-simple.c (test_desktop): unref the app.

* test/Makefile.am: upd. TESTS.

* at-bridge/bridge.c (bridge_exit_func): release the registry.

* test/keysynth-demo.c (keysynth_exit): unref the listeners.

* cspi/spi_accessible.c (Accessible_queryInterface): constify.

* cspi/spi_registry.c: constify in strings.
(deregisterGlobalEventListenerAll): don't release the ref.

* cspi/spi.h: start removing redundant / conflicting
gtkdoc comments, making the API readable at a glance :-)

* cspi/spi_event.c (AccessibleEventListener_unref): impl.

* test/keysynth-demo.c (keysynth_exit, main): upd.

* test/simple-at.c (main, simple_at_exit): upd.

* test/test-simple.c (unutterable_horror): kill.
(utterable_normal_derefs): kill.
(main): upd & do a setenv before gtk_init, so that we
can use memprof - and to save the pain of remembering
this, if we're running under memprof - don't exit.

* cspi/spi_main.c (SPI_exit): return exit status
for cspi.
(SPI_event_quit): impl.
(SPI_event_main): simplify.
(cspi_is_gnome_app): kill.
(SPI_init): kill isGNOMEapp arg.

* at-bridge/bridge.c (register_atk_event_listeners):
re-instate the unref.
(bridge_exit_func): don't re-activate the registry,
protect vs. theoretical re-entry, use the
AT_BRIDGE_SHUTDOWN env. var to determine whether to
assert a clean shutdown - for regression tests.

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

16 files changed:
ChangeLog
at-bridge/bridge.c
atk-bridge/bridge.c
cspi/bonobo/cspi-bonobo-listener.c
cspi/spi-listener-impl.c
cspi/spi.h
cspi/spi_accessible.c
cspi/spi_event.c
cspi/spi_main.c
cspi/spi_registry.c
libspi/base.c
test/Makefile.am
test/keysynth-demo.c
test/simple-at.c
test/test-simple.c
util/magnifier.c

index 8167b08..53126ce 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,54 @@
+2001-12-08  Michael Meeks  <michael@ximian.com>
+
+       * at-bridge/bridge.c (bridge_focus_tracker),
+       (emit_eventv): fix the same ref. leak.
+       (register_atk_event_listeners): don't leak.
+
+       * cspi/spi-listener-impl.c (cspi_event): more 
+       protection from client code.
+
+       * test/test-simple.c (test_desktop): unref the app.
+
+       * test/Makefile.am: upd. TESTS.
+
+       * at-bridge/bridge.c (bridge_exit_func): release the registry.
+
+       * test/keysynth-demo.c (keysynth_exit): unref the listeners.
+
+       * cspi/spi_accessible.c (Accessible_queryInterface): constify.
+
+       * cspi/spi_registry.c: constify in strings.
+       (deregisterGlobalEventListenerAll): don't release the ref.
+
+       * cspi/spi.h: start removing redundant / conflicting
+       gtkdoc comments, making the API readable at a glance :-)
+       
+       * cspi/spi_event.c (AccessibleEventListener_unref): impl.
+
+       * test/keysynth-demo.c (keysynth_exit, main): upd.
+
+       * test/simple-at.c (main, simple_at_exit): upd.
+
+       * test/test-simple.c (unutterable_horror): kill.
+       (utterable_normal_derefs): kill.
+       (main): upd & do a setenv before gtk_init, so that we
+       can use memprof - and to save the pain of remembering
+       this, if we're running under memprof - don't exit.
+
+       * cspi/spi_main.c (SPI_exit): return exit status
+       for cspi.
+       (SPI_event_quit): impl.
+       (SPI_event_main): simplify.
+       (cspi_is_gnome_app): kill.
+       (SPI_init): kill isGNOMEapp arg.
+
+       * at-bridge/bridge.c (register_atk_event_listeners):
+       re-instate the unref.
+       (bridge_exit_func): don't re-activate the registry,
+       protect vs. theoretical re-entry, use the
+       AT_BRIDGE_SHUTDOWN env. var to determine whether to
+       assert a clean shutdown - for regression tests.
+
 2001-12-08  Abel Cheung  <maddog@linux.org.hk>
 
        * configure.in: Comment out dummy i18n support for now,
@@ -7,6 +58,8 @@
 
 2001-12-07  Michael Meeks  <michael@ximian.com>
 
+       * util/magnifier.c: kill bonobo activation reg. race.
+
        * libspi/component.c
        (impl_accessibility_component_get_extents): make it match
        it's sig.
index 937e964..e4e8f7e 100644 (file)
@@ -122,8 +122,8 @@ register_atk_event_listeners (void)
    * kludge to make sure the Atk interface types are registered, otherwise
    * the AtkText signal handlers below won't get registered
    */
-
-  AtkObject *o = atk_no_op_object_new (g_object_new (ATK_TYPE_OBJECT, NULL));
+  GObject   *ao = g_object_new (ATK_TYPE_OBJECT, NULL);
+  AtkObject *bo = atk_no_op_object_new (ao);
   
   /* Register for focus event notifications, and register app with central registry  */
 
@@ -144,38 +144,48 @@ register_atk_event_listeners (void)
   atk_add_global_event_listener (bridge_signal_listener, "Gtk:AtkTable:model-changed");
   atk_add_key_event_listener    (bridge_key_listener, NULL);
 
-/*  g_object_unref (o); */
+  g_object_unref (G_OBJECT (bo));
+  g_object_unref (ao);
 }
 
 static void
 bridge_exit_func (void)
 {
+  BonoboObject *app = (BonoboObject *) this_app;
+
   fprintf (stderr, "exiting bridge\n");
 
-/*
-  FIXME: this may be incorrect for apps that do their own bonobo shutdown,
-  until we can explicitly shutdown to get the ordering right. */
+  if (!app)
+    {
+      return;
+    }
+  this_app = NULL;
 
+  /*
+   *  FIXME: this may be incorrect for apps that do their own bonobo
+   *  shutdown, until we can explicitly shutdown to get the ordering
+   *  right.
+   */
   if (!bonobo_is_initialized ())
     {
-      g_warning ("Re-initializing bonobo\n");
+      fprintf (stderr, "Re-initializing bonobo\n");
       g_assert (bonobo_init (0, NULL));
       g_assert (bonobo_activate ());
-      registry = bonobo_activation_activate_from_id (
-         "OAFIID:Accessibility_Registry:proto0.1", 0, NULL, &ev);
-      g_assert (registry);
-      g_assert (this_app);
     }
   
-  Accessibility_Registry_deregisterApplication (registry,
-                                               BONOBO_OBJREF (this_app),
-                                               &ev);
+  Accessibility_Registry_deregisterApplication (
+         registry, BONOBO_OBJREF (app), &ev);
+
+  bonobo_object_release_unref (registry, &ev);
   
-  bonobo_object_unref (BONOBO_OBJECT (this_app));
+  bonobo_object_unref (app);
   
   fprintf (stderr, "bridge exit func complete.\n");
 
-  bonobo_debug_shutdown ();
+  if (g_getenv ("AT_BRIDGE_SHUTDOWN"))
+    {
+      g_assert (!bonobo_debug_shutdown ());
+    }
 }
 
 static void
@@ -187,7 +197,7 @@ bridge_focus_tracker (AtkObject *object)
   source = spi_accessible_new (object);
 
   e.type = "focus:";
-  e.source = CORBA_Object_duplicate (BONOBO_OBJREF (source), &ev);
+  e.source = BONOBO_OBJREF (source);
   e.detail1 = 0;
   e.detail2 = 0;
 
@@ -230,7 +240,7 @@ emit_eventv (GObject      *gobject,
   if (source != NULL)
     {
       e.type = g_strdup_vprintf (format, args);
-      e.source = CORBA_Object_duplicate (BONOBO_OBJREF (source), &ev);
+      e.source = BONOBO_OBJREF (source);
       e.detail1 = detail1;
       e.detail2 = detail2;
 
index 937e964..e4e8f7e 100644 (file)
@@ -122,8 +122,8 @@ register_atk_event_listeners (void)
    * kludge to make sure the Atk interface types are registered, otherwise
    * the AtkText signal handlers below won't get registered
    */
-
-  AtkObject *o = atk_no_op_object_new (g_object_new (ATK_TYPE_OBJECT, NULL));
+  GObject   *ao = g_object_new (ATK_TYPE_OBJECT, NULL);
+  AtkObject *bo = atk_no_op_object_new (ao);
   
   /* Register for focus event notifications, and register app with central registry  */
 
@@ -144,38 +144,48 @@ register_atk_event_listeners (void)
   atk_add_global_event_listener (bridge_signal_listener, "Gtk:AtkTable:model-changed");
   atk_add_key_event_listener    (bridge_key_listener, NULL);
 
-/*  g_object_unref (o); */
+  g_object_unref (G_OBJECT (bo));
+  g_object_unref (ao);
 }
 
 static void
 bridge_exit_func (void)
 {
+  BonoboObject *app = (BonoboObject *) this_app;
+
   fprintf (stderr, "exiting bridge\n");
 
-/*
-  FIXME: this may be incorrect for apps that do their own bonobo shutdown,
-  until we can explicitly shutdown to get the ordering right. */
+  if (!app)
+    {
+      return;
+    }
+  this_app = NULL;
 
+  /*
+   *  FIXME: this may be incorrect for apps that do their own bonobo
+   *  shutdown, until we can explicitly shutdown to get the ordering
+   *  right.
+   */
   if (!bonobo_is_initialized ())
     {
-      g_warning ("Re-initializing bonobo\n");
+      fprintf (stderr, "Re-initializing bonobo\n");
       g_assert (bonobo_init (0, NULL));
       g_assert (bonobo_activate ());
-      registry = bonobo_activation_activate_from_id (
-         "OAFIID:Accessibility_Registry:proto0.1", 0, NULL, &ev);
-      g_assert (registry);
-      g_assert (this_app);
     }
   
-  Accessibility_Registry_deregisterApplication (registry,
-                                               BONOBO_OBJREF (this_app),
-                                               &ev);
+  Accessibility_Registry_deregisterApplication (
+         registry, BONOBO_OBJREF (app), &ev);
+
+  bonobo_object_release_unref (registry, &ev);
   
-  bonobo_object_unref (BONOBO_OBJECT (this_app));
+  bonobo_object_unref (app);
   
   fprintf (stderr, "bridge exit func complete.\n");
 
-  bonobo_debug_shutdown ();
+  if (g_getenv ("AT_BRIDGE_SHUTDOWN"))
+    {
+      g_assert (!bonobo_debug_shutdown ());
+    }
 }
 
 static void
@@ -187,7 +197,7 @@ bridge_focus_tracker (AtkObject *object)
   source = spi_accessible_new (object);
 
   e.type = "focus:";
-  e.source = CORBA_Object_duplicate (BONOBO_OBJREF (source), &ev);
+  e.source = BONOBO_OBJREF (source);
   e.detail1 = 0;
   e.detail2 = 0;
 
@@ -230,7 +240,7 @@ emit_eventv (GObject      *gobject,
   if (source != NULL)
     {
       e.type = g_strdup_vprintf (format, args);
-      e.source = CORBA_Object_duplicate (BONOBO_OBJREF (source), &ev);
+      e.source = BONOBO_OBJREF (source);
       e.detail1 = detail1;
       e.detail2 = detail2;
 
index d4bd31b..912bb26 100644 (file)
@@ -67,10 +67,13 @@ cspi_event (SpiEventListener    *listener,
 {
   GList *l;
   CSpiEventListener *clistener = (CSpiEventListener *) listener;
-  AccessibleEvent aevent;
+  AccessibleEvent    aevent;
+  Accessible        *source;
+
+  source = cspi_object_add_check (bonobo_object_dup_ref (event->source, cspi_ev ()));
 
   aevent.type    = event->type;
-  aevent.source  = cspi_object_add_check (bonobo_object_dup_ref (event->source, cspi_ev ()));
+  aevent.source  = source;
   aevent.detail1 = event->detail1;
   aevent.detail2 = event->detail2;
 
@@ -82,7 +85,7 @@ cspi_event (SpiEventListener    *listener,
       eh->cb.event (&aevent, eh->user_data);
     }
 
-  cspi_object_unref (aevent.source);
+  cspi_object_unref (source);
 }
 
 static void
index d4bd31b..912bb26 100644 (file)
@@ -67,10 +67,13 @@ cspi_event (SpiEventListener    *listener,
 {
   GList *l;
   CSpiEventListener *clistener = (CSpiEventListener *) listener;
-  AccessibleEvent aevent;
+  AccessibleEvent    aevent;
+  Accessible        *source;
+
+  source = cspi_object_add_check (bonobo_object_dup_ref (event->source, cspi_ev ()));
 
   aevent.type    = event->type;
-  aevent.source  = cspi_object_add_check (bonobo_object_dup_ref (event->source, cspi_ev ()));
+  aevent.source  = source;
   aevent.detail1 = event->detail1;
   aevent.detail2 = event->detail2;
 
@@ -82,7 +85,7 @@ cspi_event (SpiEventListener    *listener,
       eh->cb.event (&aevent, eh->user_data);
     }
 
-  cspi_object_unref (aevent.source);
+  cspi_object_unref (source);
 }
 
 static void
index ebe6119..a0ca6c8 100644 (file)
@@ -125,654 +125,109 @@ typedef struct _AccessibleKeySet
 
 typedef unsigned long AccessibleKeyMaskType;
 
-/*
- *
- * Basic SPI initialization and event loop function prototypes
- *
- */
-
-int
-SPI_init (SPIBoolean isGNOMEApp);
-
-/**
- * SPI_event_main:
- *
- * Starts/enters the main event loop for the SPI services.
- *
- * (NOTE: This method does not return control, it is exited via a call to exit()
- * from within an event handler).
- *
- **/
-void
-SPI_event_main (void);
-
-/**
- * SPI_event_is_ready:
- *
- * Checks to see if an SPI event is waiting in the event queue.
- * Used by clients that don't wish to use SPI_event_main().
- * Not Yet Implemented.
- *
- * Returns: #TRUE if an event is waiting, otherwise #FALSE.
- *
- **/
-SPIBoolean
-SPI_eventIsReady ();
 
-/**
- * SPI_nextEvent:
- *
- * Gets the next event in the SPI event queue; blocks if no event
- * is pending.
- * Used by clients that don't wish to use SPI_event_main().
- * Not Yet Implemented.
- *
- * Returns: the next #AccessibleEvent in the SPI event queue.
- *
- **/
-AccessibleEvent *
-SPI_nextEvent (SPIBoolean waitForEvent);
+/* Basic SPI initialization and event loop function prototypes */
 
-/**
- * SPI_exit:
- *
- * Disconnects from the Accessibility Registry and releases resources.
- *
- **/
-void
-SPI_exit (void);
+int              SPI_init         (void);
+void             SPI_event_main   (void);
+void             SPI_event_quit   (void);
+SPIBoolean       SPI_eventIsReady (void);
+AccessibleEvent *SPI_nextEvent    (SPIBoolean waitForEvent);
+int              SPI_exit         (void);
 
-/*
- * Event Listener creation and support.
- */
+/* Event Listener creation and support.  */
 
-/**
- * createAccessibleEventListener:
- * @callback : an #AccessibleEventListenerCB callback function, or NULL.
- *
- * Create a new #AccessibleEventListener with a specified callback function.
- *
- * Returns: a pointer to a newly-created #AccessibleEventListener.
- *
- **/
 AccessibleEventListener *
-createAccessibleEventListener (AccessibleEventListenerCB callback,
-                              void                     *user_data);
-
-/**
- * AccessibleEventListener_addCallback:
- * @listener: the #AccessibleEventListener instance to modify.
- * @callback: an #AccessibleEventListenerCB function pointer.
- *
- * Add an in-process callback function to an existing AccessibleEventListener.
- *
- * Returns: #TRUE if successful, otherwise #FALSE.
- *
- **/
-SPIBoolean
-AccessibleEventListener_addCallback (AccessibleEventListener  *listener,
-                                    AccessibleEventListenerCB callback,
-                                    void                     *user_data);
+           createAccessibleEventListener          (AccessibleEventListenerCB callback,
+                                                  void                     *user_data);
+SPIBoolean AccessibleEventListener_addCallback    (AccessibleEventListener  *listener,
+                                                  AccessibleEventListenerCB callback,
+                                                  void                     *user_data);
+SPIBoolean AccessibleEventListener_removeCallback (AccessibleEventListener  *listener,
+                                                  AccessibleEventListenerCB callback);
+void       AccessibleEventListener_unref          (AccessibleEventListener  *listener);
 
-/**
- * AccessibleEventListener_removeCallback:
- * @listener: the #AccessibleEventListener instance to modify.
- * @callback: an #AccessibleEventListenerCB function pointer.
- *
- * Remove an in-process callback function from an existing AccessibleEventListener.
- *
- * Returns: #TRUE if successful, otherwise #FALSE.
- *
- **/
-SPIBoolean
-AccessibleEventListener_removeCallback (AccessibleEventListener  *listener,
-                                       AccessibleEventListenerCB callback);
+/* Keystroke Listener creation and support.  */
 
-/**
- * createAccessibleKeystrokeListener:
- * @callback : an #AccessibleKeystrokeListenerCB callback function, or NULL.
- *
- * Create a new #AccessibleKeystrokeListener with a specified callback function.
- *
- * Returns: a pointer to a newly-created #AccessibleKeystrokeListener.
- *
- **/
 AccessibleKeystrokeListener *
-createAccessibleKeystrokeListener (AccessibleKeystrokeListenerCB callback,
-                                  void                         *user_data);
-
-/**
- * KeystrokeListener_addCallback:
- * @listener: the #KeystrokeListener instance to modify.
- * @callback: an #KeystrokeListenerCB function pointer.
- *
- * Add an in-process callback function to an existing #KeystrokeListener.
- *
- * Returns: #TRUE if successful, otherwise #FALSE.
- *
- **/
-SPIBoolean
-AccessibleKeystrokeListener_addCallback (AccessibleKeystrokeListener  *listener,
-                                        AccessibleKeystrokeListenerCB callback,
-                                        void                         *user_data);
-
-/**
- * AccessibleKeystrokeListener_removeCallback:
- * @listener: the #AccessibleKeystrokeListener instance to modify.
- * @callback: an #AccessibleKeystrokeListenerCB function pointer.
- *
- * Remove an in-process callback function from an existing #AccessibleKeystrokeListener.
- *
- * Returns: #TRUE if successful, otherwise #FALSE.
- *
- **/
-SPIBoolean
-AccessibleKeystrokeListener_removeCallback (AccessibleKeystrokeListener *listener,
-                                           AccessibleKeystrokeListenerCB callback);
-
-void AccessibleKeystrokeListener_unref (AccessibleKeystrokeListener *listener);
-
-/*
- *
- * Global functions serviced by the registry
- *
- */
-
-/**
- * registerGlobalEventListener:
- * @listener: the #AccessibleEventListener to be registered against an event type.
- * @callback: a character string indicating the type of events for which
- *            notification is requested.  Format is
- *            EventClass:major_type:minor_type:detail
- *            where all subfields other than EventClass are optional.
- *            EventClasses include "Focus", "Window", "Mouse",
- *            and toolkit events (e.g. "Gtk", "AWT").
- *            Examples: "focus:", "Gtk:GtkWidget:button_press_event".
- *
- * NOTE: this string may be UTF-8, but should not contain byte value 56 (ascii ':'),
- *            except as a delimiter, since non-UTF-8 string delimiting
- *            functions are used internally.  In general, listening to
- *            toolkit-specific events is not recommended.
- *
- * Add an in-process callback function to an existing AccessibleEventListener.
- *
- * Returns: #TRUE if successful, otherwise #FALSE.
- *
- **/
-SPIBoolean
-registerGlobalEventListener (AccessibleEventListener *listener,
-                             char *eventType);
-SPIBoolean
-deregisterGlobalEventListener (AccessibleEventListener *listener,
-                               char *eventType);
-SPIBoolean
-deregisterGlobalEventListenerAll (AccessibleEventListener *listener);
-
-
-/**
- * getDesktopCount:
- *
- * Get the number of virtual desktops.
- * NOTE: currently multiple virtual desktops are not implemented, this
- *       function always returns '1'.
- *
- * Returns: an integer indicating the number of active virtual desktops.
- *
- **/
-int
-getDesktopCount ();
-
-/**
- * getDesktop:
- * @i: an integer indicating which of the accessible desktops is to be returned.
- *
- * Get the virtual desktop indicated by index @i.
- * NOTE: currently multiple virtual desktops are not implemented, this
- *       function always returns '1'.
- *
- * Returns: a pointer to the 'i-th' virtual desktop's #Accessible representation.
- *
- **/
-Accessible*
-getDesktop (int i);
-
-/**
- * getDesktopList:
- * @list: a pointer to an array of #Accessible objects.
- *
- * Get the list of virtual desktops.  On return, @list will point
- *     to a newly-created array of virtual desktop pointers.
- *     It is the responsibility of the caller to free this array when
- *     it is no longer needed.
- *
- * Not Yet Implemented.
- *
- * Returns: an integer indicating how many virtual desktops have been
- *          placed in the list pointed to by parameter @list.
- **/
-int
-getDesktopList (Accessible **list);
-
-/**
- * registerAccessibleKeystrokeListener:
- * @listener: a pointer to the #AccessibleKeystrokeListener for which
- *            keystroke events are requested.
- *
- * [Partially Implemented.]
- *
- **/
-void
-registerAccessibleKeystrokeListener (AccessibleKeystrokeListener *listener,
-                                    AccessibleKeySet *keys,
-                                    AccessibleKeyMaskType modmask,
-                                    AccessibleKeyEventMask eventmask,
-                                    AccessibleKeyListenerSyncType sync_type);
-
-void
-deregisterAccessibleKeystrokeListener (AccessibleKeystrokeListener *listener,
-                                      AccessibleKeyMaskType modmask);
-
-/**
- * generateKeyEvent:
- * @keyval: a #long integer indicating the keycode or keysym of the key event
- *           being synthesized.
- * @synth_type: a #AccessibleKeySynthType flag indicating whether @keyval
- *           is to be interpreted as a keysym rather than a keycode
- *           (SPI_KEYSYM) and whether to synthesize
- *           SPI_KEY_PRESS, SPI_KEY_RELEASE, or both (SPI_KEY_PRESSRELEASE).
- *
- * Synthesize a keyboard event (as if a hardware keyboard event occurred in the
- * current UI context).
- *
- **/
-void
-generateKeyEvent (long int keyval, AccessibleKeySynthType synth_type);
-
-/**
- * generateMouseEvent:
- * @x: a #long int indicating the screen x coordinate of the mouse event.
- * @y: a #long int indicating the screen y coordinate of the mouse event.
- * @name: a string indicating which mouse event to be synthesized
- *        (e.g. "button1", "button2", "mousemove").
- *
- * Synthesize a mouse event at a specific screen coordinate.
- * Not Yet Implemented.
- *
- **/
-void
-generateMouseEvent (long int x, long int y, char *name);
-
-/*
- *
- * Accessible function prototypes
- *
- */
-
-/**
- * Accessible_ref:
- * @obj: a pointer to the #Accessible object on which to operate.
- *
- * Increment the reference count for an #Accessible object.
- *
- * Returns: (no return code implemented yet).
- *
- **/
-int
-Accessible_ref (Accessible *obj);
-
-/**
- * Accessible_unref:
- * @obj: a pointer to the #Accessible object on which to operate.
- *
- * Decrement the reference count for an #Accessible object.
- *
- * Returns: (no return code implemented yet).
- *
- **/
-int
-Accessible_unref (Accessible *obj);
-
-/**
- * Accessible_getName:
- * @obj: a pointer to the #Accessible object on which to operate.
- *
- * Get the name of an #Accessible object.
- *
- * Returns: a UTF-8 string indicating the name of the #Accessible object.
- *
- **/
-char *
-Accessible_getName (Accessible *obj);
-
-/**
- * Accessible_getDescription:
- * @obj: a pointer to the #Accessible object on which to operate.
- *
- * Get the description of an #Accessible object.
- *
- * Returns: a UTF-8 string describing the #Accessible object.
- *
- **/
-char *
-Accessible_getDescription (Accessible *obj);
-
-/**
- * Accessible_getParent:
- * @obj: a pointer to the #Accessible object to query.
- *
- * Get an #Accessible object's parent container.
- *
- * Returns: a pointer to the #Accessible object which contains the given
- *          #Accessible instance, or NULL if the @obj has no parent container.
- *
- **/
-Accessible *
-Accessible_getParent (Accessible *obj);
-
-/**
- * Accessible_getChildCount:
- * @obj: a pointer to the #Accessible object on which to operate.
- *
- * Get the number of children contained by an #Accessible object.
- *
- * Returns: a #long indicating the number of #Accessible children
- *          contained by an #Accessible object.
- *
- **/
-long
-Accessible_getChildCount (Accessible *obj);
-
-/**
- * Accessible_getChildAtIndex:
- *
- * @obj: a pointer to the #Accessible object on which to operate.
- * @childIndex: a #long indicating which child is specified.
- *
- * Get the #Accessible child of an #Accessible object at a given index.
- *
- * Returns: a pointer to the #Accessible child object at index
- *          @childIndex.
- *
- **/
-Accessible *
-Accessible_getChildAtIndex (Accessible *obj,
-                            long int childIndex);
-
-/**
- * Accessible_getIndexInParent:
- *
- * @obj: a pointer to the #Accessible object on which to operate.
- *
- * Get the index of an #Accessible object in its containing #Accessible.
- *
- * Returns: a #long indicating the index of the #Accessible object
- *          in its parent (i.e. containing) #Accessible instance,
- *          or -1 if @obj has no containing parent.
- *
- **/
-long
-Accessible_getIndexInParent (Accessible *obj);
-
-/**
- * Accessible_getRelationSet:
- * @obj: a pointer to the #Accessible object on which to operate.
- *
- * Not Yet Implemented.
- *
- * Returns: a pointer to an array of #AccessibleRelations.
- *
- **/
-AccessibleRelation **
-Accessible_getRelationSet (Accessible *obj);
-
-/**
- * Accessible_getRole:
- * @obj: a pointer to the #Accessible object on which to operate.
- *
- * Get the UI role of an #Accessible object.
- *
- * Returns: a UTF-8 string indicating the UI role of the #Accessible object.
- *
- **/
-const char *
-Accessible_getRole (Accessible *obj);
-
-/**
- * Accessible_getStateSet:
- * @obj: a pointer to the #Accessible object on which to operate.
- *
- * Not Yet Implemented.
- *
- * Returns: a pointer to an #AccessibleStateSet representing the object's current state.
- *
- **/
-AccessibleStateSet *
-Accessible_getStateSet (Accessible *obj);
+           createAccessibleKeystrokeListener          (AccessibleKeystrokeListenerCB callback,
+                                                      void                         *user_data);
+SPIBoolean AccessibleKeystrokeListener_addCallback    (AccessibleKeystrokeListener  *listener,
+                                                      AccessibleKeystrokeListenerCB callback,
+                                                      void                         *user_data);
+SPIBoolean AccessibleKeystrokeListener_removeCallback (AccessibleKeystrokeListener *listener,
+                                                      AccessibleKeystrokeListenerCB callback);
+void       AccessibleKeystrokeListener_unref         (AccessibleKeystrokeListener *listener);
+
+/* Global functions serviced by the registry */
+
+SPIBoolean  registerGlobalEventListener      (AccessibleEventListener *listener,
+                                             const char              *eventType);
+SPIBoolean  deregisterGlobalEventListener    (AccessibleEventListener *listener,
+                                             const char              *eventType);
+SPIBoolean  deregisterGlobalEventListenerAll (AccessibleEventListener *listener);
+
+void        registerAccessibleKeystrokeListener (
+                                              AccessibleKeystrokeListener *listener,
+                                             AccessibleKeySet             *keys,
+                                             AccessibleKeyMaskType         modmask,
+                                             AccessibleKeyEventMask        eventmask,
+                                             AccessibleKeyListenerSyncType sync_type);
+void        deregisterAccessibleKeystrokeListener (
+                                              AccessibleKeystrokeListener *listener,
+                                             AccessibleKeyMaskType        modmask);
+
+int         getDesktopCount                  (void);
+Accessible *getDesktop                       (int i);
+int         getDesktopList                   (Accessible **list);
+
+void        generateKeyEvent                 (long int                    keyval,
+                                             AccessibleKeySynthType      synth_type);
+void        generateMouseEvent               (long int x, long int y, char *name);
+
+/* Accessible function prototypes  */
+
+int                  Accessible_ref              (Accessible *obj);
+int                  Accessible_unref            (Accessible *obj);
+char *               Accessible_getName          (Accessible *obj);
+char *               Accessible_getDescription   (Accessible *obj);
+Accessible *         Accessible_getParent        (Accessible *obj);
+long                 Accessible_getChildCount    (Accessible *obj);
+Accessible *         Accessible_getChildAtIndex  (Accessible *obj,
+                                                 long int    childIndex);
+long                 Accessible_getIndexInParent (Accessible *obj);
+AccessibleRelation **Accessible_getRelationSet   (Accessible *obj);
+const char *         Accessible_getRole          (Accessible *obj);
+AccessibleStateSet * Accessible_getStateSet      (Accessible *obj);
 
 /* Interface query methods */
 
-/**
- * Accessible_isAction:
- * @obj: a pointer to the #Accessible instance to query.
- *
- * Query whether the specified #Accessible implements #AccessibleAction.
- *
- * Returns: #TRUE if @obj implements the #AccessibleAction interface,
- *          #FALSE otherwise.
- **/
-SPIBoolean
-Accessible_isAction (Accessible *obj);
-
-/**
- * Accessible_isApplication:
- * @obj: a pointer to the #Accessible instance to query.
- *
- * Query whether the specified #Accessible implements #AccessibleApplication.
- *
- * Returns: #TRUE if @obj implements the #AccessibleApplication interface,
- *          #FALSE otherwise.
- **/
-SPIBoolean
-Accessible_isApplication (Accessible *obj);
-
-/**
- * Accessible_isComponent:
- * @obj: a pointer to the #Accessible instance to query.
- *
- * Query whether the specified #Accessible implements #AccessibleComponent.
- *
- * Returns: #TRUE if @obj implements the #AccessibleComponent interface,
- *          #FALSE otherwise.
- **/
-SPIBoolean
-Accessible_isComponent (Accessible *obj);
-
-/**
- * Accessible_isEditableText:
- * @obj: a pointer to the #Accessible instance to query.
- *
- * Query whether the specified #Accessible implements #AccessibleEditableText.
- *
- * Returns: #TRUE if @obj implements the #AccessibleEditableText interface,
- *          #FALSE otherwise.
- **/
-SPIBoolean
-Accessible_isEditableText (Accessible *obj);
-
-/**
- * Accessible_isHypertext:
- * @obj: a pointer to the #Accessible instance to query.
- *
- * Query whether the specified #Accessible implements #AccessibleHypertext.
- *
- * Returns: #TRUE if @obj implements the #AccessibleHypertext interface,
- *          #FALSE otherwise.
- **/
-SPIBoolean
-Accessible_isHypertext (Accessible *obj);
-
-/**
- * Accessible_isImage:
- * @obj: a pointer to the #Accessible instance to query.
- *
- * Query whether the specified #Accessible implements #AccessibleImage.
- *
- * Returns: #TRUE if @obj implements the #AccessibleImage interface,
- *          #FALSE otherwise.
-**/
-SPIBoolean
-Accessible_isImage (Accessible *obj);
-
-/**
-  * Accessible_isSelection:
- * @obj: a pointer to the #Accessible instance to query.
- *
- * Query whether the specified #Accessible implements #AccessibleSelection.
- *
- * Returns: #TRUE if @obj implements the #AccessibleSelection interface,
- *          #FALSE otherwise.
-**/
-SPIBoolean
-Accessible_isSelection (Accessible *obj);
-
-/**
- * Accessible_isTable:
- * @obj: a pointer to the #Accessible instance to query.
- *
- * Query whether the specified #Accessible implements #AccessibleTable.
- *
- * Returns: #TRUE if @obj implements the #AccessibleTable interface,
- *          #FALSE otherwise.
-**/
-SPIBoolean
-Accessible_isTable (Accessible *obj);
-
-/**
- * Accessible_isText:
- * @obj: a pointer to the #Accessible instance to query.
- *
- * Query whether the specified #Accessible implements #AccessibleText.
- *
- * Returns: #TRUE if @obj implements the #AccessibleText interface,
- *          #FALSE otherwise.
-**/
-SPIBoolean
-Accessible_isText (Accessible *obj);
-
-SPIBoolean
-Accessible_isValue (Accessible *obj);
-
-/**
- * Accessible_getAction:
- * @obj: a pointer to the #Accessible instance to query.
- *
- * Get the #AccessibleAction interface for an #Accessible.
- *
- * Returns: a pointer to an #AccessibleAction interface instance, or
- *          NULL if @obj does not implement #AccessibleAction.
- **/
-AccessibleAction *
-Accessible_getAction (Accessible *obj);
-
-/**
- * Accessible_getApplication:
- * @obj: a pointer to the #Accessible instance to query.
- *
- * Get the #AccessibleApplication interface for an #Accessible.
- *
- * Returns: a pointer to an #AccessibleApplication interface instance, or
- *          NULL if @obj does not implement #AccessibleApplication.
- **/
-AccessibleApplication *
-Accessible_getApplication (Accessible *obj);
-
-/**
- * Accessible_getComponent:
- * @obj: a pointer to the #Accessible instance to query.
- *
- * Get the #AccessibleComponent interface for an #Accessible.
- *
- * Returns: a pointer to an #AccessibleComponent interface instance, or
- *          NULL if @obj does not implement #AccessibleComponent.
- **/
-AccessibleComponent *
-Accessible_getComponent (Accessible *obj);
-
-/**
- * Accessible_getEditableText:
- *
- * Not Yet Implemented.
- *
- **/
-AccessibleEditableText *
-Accessible_getEditableText (Accessible *obj);
-
-/**
- * Accessible_getHypertext:
- *
- * Not Yet Implemented.
- *
- **/
-AccessibleHypertext *
-Accessible_getHypertext (Accessible *obj);
-
-/**
- * Accessible_getImage:
- *
- * Not Yet Implemented.
- *
- **/
-AccessibleImage *
-Accessible_getImage (Accessible *obj);
-
-/**
- * Accessible_getSelection:
- *
- * Not Yet Implemented.
- *
- **/
-AccessibleSelection *
-Accessible_getSelection (Accessible *obj);
-
-/**
- * Accessible_getTable:
- *
- * Not Yet Implemented.
- *
- **/
-AccessibleTable *
-Accessible_getTable (Accessible *obj);
-
-/**
- * Accessible_getText:
- *
- * Not Yet Implemented.
- *
- **/
-AccessibleText *
-Accessible_getText (Accessible *obj);
-
-AccessibleValue *
-Accessible_getValue (Accessible *obj);
-
-/**
- * Accessible_queryInterface:
- * @obj: a pointer to the #Accessible instance to query.
- * @interface_name: a UTF-8 character string specifiying the requested interface.
- *
- * Query an #Accessible object to for a named interface.
- *
- * Returns: an instance of the named interface object, if it is implemented
- *          by @obj, or NULL otherwise.
- *
- **/
-GenericInterface *
-Accessible_queryInterface (Accessible *obj, char *interface_name);
+SPIBoolean Accessible_isAction       (Accessible *obj);
+SPIBoolean Accessible_isApplication  (Accessible *obj);
+SPIBoolean Accessible_isComponent    (Accessible *obj);
+SPIBoolean Accessible_isEditableText (Accessible *obj);
+SPIBoolean Accessible_isHypertext    (Accessible *obj);
+SPIBoolean Accessible_isImage        (Accessible *obj);
+SPIBoolean Accessible_isSelection    (Accessible *obj);
+SPIBoolean Accessible_isTable        (Accessible *obj);
+SPIBoolean Accessible_isText         (Accessible *obj);
+SPIBoolean Accessible_isValue        (Accessible *obj);
+
+AccessibleAction *       Accessible_getAction       (Accessible *obj);
+AccessibleApplication *  Accessible_getApplication  (Accessible *obj);
+AccessibleComponent *    Accessible_getComponent    (Accessible *obj);
+AccessibleEditableText * Accessible_getEditableText (Accessible *obj);
+AccessibleHypertext *    Accessible_getHypertext    (Accessible *obj);
+AccessibleImage *        Accessible_getImage        (Accessible *obj);
+AccessibleSelection *    Accessible_getSelection    (Accessible *obj);
+AccessibleTable *        Accessible_getTable        (Accessible *obj);
+AccessibleText *         Accessible_getText         (Accessible *obj);
+AccessibleValue *        Accessible_getValue        (Accessible *obj);
+GenericInterface *       Accessible_queryInterface  (Accessible *obj,
+                                                    const char *interface_name);
 
 /*
- *
  * AccessibleAction function prototypes
- *
  */
 
 int
index d753ca6..973af99 100644 (file)
@@ -658,7 +658,8 @@ Accessible_getValue (Accessible *obj)
  *
  **/
 GenericInterface *
-Accessible_queryInterface (Accessible *obj, char *interface_name)
+Accessible_queryInterface (Accessible *obj,
+                          const char *interface_name)
 {
   Bonobo_Unknown iface;
   
index d9c543b..7fbe0ee 100644 (file)
@@ -69,6 +69,19 @@ AccessibleEventListener_addCallback (AccessibleEventListener *listener,
 }
 
 /**
+ * AccessibleEventListener_unref:
+ * @listener: a pointer to the #AccessibleEventListener being operated on.
+ *
+ * Decrements an #AccessibleEventListener's reference count.
+ **/
+void
+AccessibleEventListener_unref (AccessibleEventListener *listener)
+{
+  /* Would prefer this not to be bonobo api */
+  bonobo_object_unref (BONOBO_OBJECT (listener));
+}
+
+/**
  * AccessibleEventListener_removeCallback:
  * @listener: the #AccessibleEventListener instance to modify.
  * @callback: an #AccessibleEventListenerCB function pointer.
index 864dc14..19c7420 100644 (file)
@@ -11,7 +11,6 @@
 
 static CORBA_Environment ev = { 0 };
 static Accessibility_Registry registry = CORBA_OBJECT_NIL;
-static SPIBoolean is_gnome_app = TRUE;
 static GHashTable *live_refs = NULL;
 
 static guint
@@ -119,12 +118,6 @@ cspi_registry (void)
 }
 
 SPIBoolean
-cspi_is_gnome_app (void)
-{
-  return is_gnome_app; 
-}
-
-SPIBoolean
 cspi_exception (void)
 {
   SPIBoolean retval;
@@ -250,21 +243,16 @@ static gboolean SPI_inited = FALSE;
 
 /**
  * SPI_init:
- * @isGNOMEApp: a #SPIBoolean indicating whether the client of the SPI
- *              will use the Gnome event loop or not.  Clients that have
- *              their own GUIS will usually specify #TRUE here, and must
- *              do so if they use Gnome GUI components.
  *
  * Connects to the accessibility registry and initializes the SPI.
  *
  * Returns: 0 on success, otherwise an integer error code.
  **/
 int
-SPI_init (SPIBoolean isGNOMEApp)
+SPI_init (void)
 {
   int argc = 0;
   char *obj_id;
-  is_gnome_app = isGNOMEApp;
 
   if (SPI_inited)
     {
@@ -298,10 +286,7 @@ SPI_init (SPIBoolean isGNOMEApp)
 
   bonobo_activate ();
 
-  if (isGNOMEApp)
-    {
-      g_atexit (cspi_cleanup);
-    }
+  g_atexit (cspi_cleanup);
   
   return 0;
 }
@@ -311,23 +296,26 @@ SPI_init (SPIBoolean isGNOMEApp)
  *
  * Starts/enters the main event loop for the SPI services.
  *
- * (NOTE: This method does not return control, it is exited via a call
- * to SPI_exit() from within an event handler).
+ * (NOTE: This method does not return control, it is exited via a call to
+ *  SPI_event_quit () from within an event handler).
  *
  **/
 void
-SPI_event_main ()
+SPI_event_main (void)
 {
-  if (cspi_is_gnome_app ())
-    {
-      bonobo_main ();
-    }
-  else
-    {
-      /* TODO: install signal handlers to do cleanup */
-      CORBA_ORB_run (bonobo_orb (), cspi_ev ());
-      fprintf (stderr, "orb loop exited...\n");
-    }
+  bonobo_main ();
+}
+
+/**
+ * SPI_event_quit:
+ *
+ * Quits the last main event loop for the SPI services,
+ * see SPI_event_main
+ **/
+void
+SPI_event_quit (void)
+{
+  bonobo_main_quit ();
 }
 
 /**
@@ -369,28 +357,41 @@ SPI_nextEvent (SPIBoolean waitForEvent)
  * SPI_exit:
  *
  * Disconnects from the Accessibility Registry and releases 
- * any floating resources.
+ * any floating resources. Call only once at exit.
+ *
+ * Returns: 0 if there were no leaks, otherwise non zero.
  **/
-void
+int
 SPI_exit (void)
 {
+  int leaked;
+
   if (!SPI_inited)
     {
-      return;
+      return 0;
     }
 
   SPI_inited = FALSE;
 
-  cspi_cleanup ();
-
-  if (cspi_is_gnome_app ())
+  if (live_refs)
     {
-      bonobo_main_quit ();
+      leaked = g_hash_table_size (live_refs);
     }
   else
     {
-      CORBA_ORB_shutdown (bonobo_orb (), TRUE, cspi_ev ());        
+      leaked = 0;
     }
+
+#ifdef DEBUG_OBJECTS
+  if (leaked)
+    {
+      fprintf (stderr, "Leaked %d SPI handles\n", leaked);
+    }
+#endif
+
+  cspi_cleanup ();
+
   fprintf (stderr, "bye-bye!\n");
-}
 
+  return leaked;
+}
index 3fa2929..b7005a2 100644 (file)
  * Boston, MA 02111-1307, USA.
  */
 
-#include <cspi/spi-private.h>
+/* spi_registry.c: Global functions wrapping the registry */
 
-/*
- *
- * Global functions serviced by the registry
- *
- */
-
-#if 0
-/* static stuff used only by registry C bindings */
-static GList *key_listeners = NULL;
-static Display *display = NULL;
-#endif
+#include <cspi/spi-private.h>
 
 /**
  * registerGlobalEventListener:
@@ -93,7 +83,7 @@ static Display *display = NULL;
  **/
 SPIBoolean
 registerGlobalEventListener (AccessibleEventListener *listener,
-                             char *eventType)
+                             const char              *eventType)
 {
   SPIBoolean retval;
 
@@ -115,8 +105,9 @@ registerGlobalEventListener (AccessibleEventListener *listener,
  *            an event type.
  *
  * deregisters an AccessibleEventListener from the registry, for all
- *            event types it may be listening to.  Also unrefs the listener.
- *            The listener cannot subsequently be reused.
+ *            event types it may be listening to. Use
+ *            AccessibleEventListener_unref to release the
+ *            listener reference.
  *
  * Returns: #TRUE if successful, otherwise #FALSE.
  *
@@ -128,10 +119,6 @@ deregisterGlobalEventListenerAll (AccessibleEventListener *listener)
                          cspi_registry (),
                         (Accessibility_EventListener) BONOBO_OBJREF (listener),
                         cspi_ev ());
-  if (!cspi_exception ())
-    {
-      bonobo_object_unref (BONOBO_OBJECT (listener));      
-    }
 
   return !cspi_exception ();
 }
@@ -149,7 +136,7 @@ deregisterGlobalEventListenerAll (AccessibleEventListener *listener)
  **/
 SPIBoolean
 deregisterGlobalEventListener (AccessibleEventListener *listener,
-                              char *eventType)
+                              const char              *eventType)
 {
   Accessibility_Registry_deregisterGlobalEventListener (
          cspi_registry (),
index b4d19f8..46abe00 100644 (file)
@@ -20,7 +20,7 @@
  * Boston, MA 02111-1307, USA.
  */
 
-/* object.c: the base object managing an AtkObject proxy */
+/* base.c: the base object managing an AtkObject proxy */
 
 #include <config.h>
 #include <stdio.h>
index 61f3c31..c7385be 100644 (file)
@@ -28,4 +28,4 @@ CFLAGS += $(TESTS_CFLAGS) $(DEBUG_CFLAGS)
 
 LDADD = ../util/libat-util.la ../libspi/libspi.la ../cspi/libcspi.la $(TESTS_LIBS)
 
-TESTS = test.sh
\ No newline at end of file
+TESTS = test-simple
\ No newline at end of file
index 79b6f41..c2df9ca 100644 (file)
@@ -278,11 +278,15 @@ toggle_shift_latch (GtkButton *button)
 }
 
 static void
-keysynth_exit()
+keysynth_exit (void)
 {
-  deregisterAccessibleKeystrokeListener (key_listener, SPI_KEYMASK_ALT );
-  deregisterAccessibleKeystrokeListener (switch_listener, SPI_KEYMASK_UNMODIFIED );
-  SPI_exit ();
+  deregisterAccessibleKeystrokeListener (key_listener, SPI_KEYMASK_ALT);
+  AccessibleKeystrokeListener_unref     (key_listener);
+
+  deregisterAccessibleKeystrokeListener (switch_listener, SPI_KEYMASK_UNMODIFIED);
+  AccessibleKeystrokeListener_unref     (switch_listener);
+
+  SPI_event_quit ();
 }
 
 static void
@@ -309,9 +313,9 @@ keysynth_realize (GtkWidget *widget)
 }
 
 static void
-button_exit(GtkButton *notused, void *alsonotused)
+button_exit (GtkButton *notused, void *alsonotused)
 {
-  keysynth_exit();
+  keysynth_exit ();
 }
 
 static SPIBoolean
@@ -321,7 +325,7 @@ is_command_key (AccessibleKeystroke *key, void *user_data)
     {
     case 'Q':
     case 'q':
-           keysynth_exit(); 
+           keysynth_exit (); 
            return TRUE; /* not reached */
     }
   return FALSE;
@@ -456,11 +460,11 @@ create_vkbd()
 }
 
 int
-main(int argc, char **argv)
+main (int argc, char **argv)
 {
   AccessibleKeySet switch_set;
   
-  if ((argc > 1) && (!strncmp(argv[1],"-h",2)))
+  if ((argc > 1) && (!strncmp (argv[1], "-h", 2)))
     {
       printf ("Usage: keysynth-demo\n");
       exit (1);
@@ -468,7 +472,7 @@ main(int argc, char **argv)
 
   gtk_init (&argc, &argv); /* must call, because this program uses GTK+ */
 
-  SPI_init (TRUE);
+  SPI_init ();
 
   key_listener = createAccessibleKeystrokeListener (is_command_key, NULL);
   /* will listen only to Alt-key combinations */
@@ -499,5 +503,5 @@ main(int argc, char **argv)
   
   SPI_event_main ();
 
-  return 0;
+  return SPI_exit ();
 }
index b603f24..1e66ef1 100644 (file)
@@ -60,14 +60,14 @@ main (int argc, char **argv)
   Accessible *application;
   char *s;
 
-  if ((argc > 1) && (!strncmp(argv[1],"-h",2)))
+  if ((argc > 1) && (!strncmp (argv[1], "-h", 2)))
   {
     printf ("Usage: simple-at\n");
     printf ("\tEnvironment variables used:\n\t\tFESTIVAL\n\t\tMAGNIFIER\n\t\tFESTIVAL_CHATTY\n");
-    exit(0);
+    exit (0);
   }
 
-  SPI_init(TRUE);
+  SPI_init ();
 
   focus_listener = createAccessibleEventListener (report_focus_event, NULL);
   property_listener = createAccessibleEventListener (check_property_change, NULL); 
@@ -120,9 +120,13 @@ main (int argc, char **argv)
                                      (unsigned long) ( KeyPress | KeyRelease),
                                      SPI_KEYLISTENER_NOSYNC);
 
-  get_environment_vars();
+  get_environment_vars ();
 
-  SPI_event_main();
+  SPI_event_main ();
+
+  setenv ("AT_BRIDGE_SHUTDOWN", "1", TRUE);
+
+  return SPI_exit ();
 }
 
 static void
@@ -265,16 +269,21 @@ static void
 simple_at_exit ()
 {
   deregisterGlobalEventListenerAll (focus_listener);
+  AccessibleEventListener_unref    (focus_listener);
+
   deregisterGlobalEventListenerAll (property_listener);
+  AccessibleEventListener_unref    (property_listener);
+
   deregisterGlobalEventListenerAll (button_listener);
+  AccessibleEventListener_unref    (button_listener);
 
-  deregisterAccessibleKeystrokeListener (command_key_listener, SPI_KEYMASK_ALT );
-  deregisterAccessibleKeystrokeListener (ordinary_key_listener, SPI_KEYMASK_UNMODIFIED );
-  deregisterAccessibleKeystrokeListener (ordinary_key_listener, SPI_KEYMASK_SHIFT );
+  deregisterAccessibleKeystrokeListener (command_key_listener, SPI_KEYMASK_ALT);
+  deregisterAccessibleKeystrokeListener (ordinary_key_listener, SPI_KEYMASK_UNMODIFIED);
+  deregisterAccessibleKeystrokeListener (ordinary_key_listener, SPI_KEYMASK_SHIFT);
   AccessibleKeystrokeListener_unref (command_key_listener);
   AccessibleKeystrokeListener_unref (ordinary_key_listener);
   
-  SPI_exit ();
+  SPI_event_quit ();
 }
 
 static SPIBoolean
index 24957af..b74e37e 100644 (file)
  * ******** Do not copy this code as an example *********
  */
 
-/* UGLY HACK for (unutterable_horror) */
-#include <libspi/libspi.h>
-
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 #include <gtk/gtk.h>
 #include <cspi/spi.h>
@@ -132,6 +130,7 @@ test_desktop (void)
 
        application = Accessible_getChildAtIndex (desktop, 0);
        g_assert (application != NULL);
+       AccessibleApplication_unref (application);
 
        Accessible_unref (desktop);
 }
@@ -430,65 +429,6 @@ test_misc (void)
        SPI_freeString (NULL);
 }
 
-#ifdef UNUTTERABLY_HORRIFIC
-static void
-unutterable_horror (void)
-{
-       /* Brutal ugliness to de-register ourself and exit cleanly */
-       CORBA_Environment ev;
-       Accessible        *desktop;
-       Accessible        *app_access;
-       Accessibility_Accessible app;
-       Accessibility_Registry   registry;
-
-       fprintf (stderr, "Unutterable horror ...\n");
-
-       /* First get the application ! - gack */
-       desktop = getDesktop (0);
-       app_access = Accessible_getChildAtIndex (desktop, 0);
-
-       /* Good grief */
-       app = *(Accessibility_Accessible *) app_access;
-
-       CORBA_exception_init (&ev);
-
-       registry = bonobo_activation_activate_from_id (
-               "OAFIID:Accessibility_Registry:proto0.1", 0, NULL, &ev);
-
-       Accessibility_Registry_deregisterApplication (
-               registry, app, &ev);
-
-       bonobo_object_release_unref (registry, &ev); /* the original ref */
-       bonobo_object_release_unref (registry, &ev); /* taken by the bridge */
-       bonobo_object_release_unref (registry, &ev); /* taken by spi_main.c */
-
-       Accessible_unref (desktop);
-       Accessible_unref (app_access);
-
-       /* Urgh ! - get a pointer to app */
-       bonobo_object_unref (bonobo_object (ORBit_small_get_servant (app)));
-}
-#endif
-
-static void
-utterable_normal_derefs (void)
-{
-        /* Normal cleanup to exit cleanly */
-        CORBA_Environment ev;
-        Accessibility_Registry   registry;
-
-        CORBA_exception_init (&ev);
-
-        registry = bonobo_activation_activate_from_id (
-                "OAFIID:Accessibility_Registry:proto0.1", 0, NULL, &ev);
-
-        bonobo_object_release_unref (registry, &ev); /* the ref above */
-        bonobo_object_release_unref (registry, &ev); /* taken by spi_main.c */
-
-        /* Yes, it would be nicer to have both SPI_main_quit and SPI_shutdown,
-           then the above code could be dispensed with */
-}
-
 static void
 global_listener_cb (AccessibleEvent     *event,
                    void                *user_data)
@@ -502,8 +442,6 @@ global_listener_cb (AccessibleEvent     *event,
 
        fprintf (stderr, "Fielded focus event ...\n");
 
-       /* The application is now registered - this happens idly */
-
        desktop = getDesktop (0);
        application = Accessible_getChildAtIndex (desktop, 0);
        g_assert (application != NULL);
@@ -524,18 +462,16 @@ global_listener_cb (AccessibleEvent     *event,
 int
 main (int argc, char **argv)
 {
+       int leaked;
        TestWindow *win;
        AccessibleEventListener *global_listener;
 
-       gtk_init (&argc, &argv);
+       setenv ("GTK_MODULES", "gail:at-bridge", FALSE);
 
-       if (!g_getenv ("GTK_MODULES") ||
-           !strstr (g_getenv ("GTK_MODULES"), "gail:at-bridge")) {
-               g_error ("You need to export GTK_MODULES='gail:at-bridge'");
-       }
+       gtk_init (&argc, &argv);
 
-       g_assert (!SPI_init (TRUE));
-       g_assert (SPI_init (TRUE));
+       g_assert (!SPI_init ());
+       g_assert (SPI_init ());
        g_assert (getDesktopCount () == 1);
 
        test_roles ();
@@ -550,18 +486,24 @@ main (int argc, char **argv)
        fprintf (stderr, "Waiting for focus event ...\n");
        gtk_main ();
 
-       /* First de-register myself - we only want the toplevel of ourself */
        g_assert (deregisterGlobalEventListenerAll (global_listener));
+       AccessibleEventListener_unref (global_listener);
 
        test_window_destroy (win);
 
-/* FIXME: we need to resolve the exit / quit mainloop function */
-/*     SPI_exit ();
-       SPI_exit (); */
-/*     unutterable_horror ();  ! */
-       utterable_normal_derefs ();
+       if ((leaked = SPI_exit ()))
+               g_error ("Leaked %d SPI handles", leaked);
+
+       g_assert (!SPI_exit ());
 
        fprintf (stderr, "All tests passed\n");
 
-       return bonobo_debug_shutdown ();
+       if (g_getenv ("_MEMPROF_SOCKET")) {
+               fprintf (stderr, "Waiting for memprof\n");
+               gtk_main ();
+       }
+
+       setenv ("AT_BRIDGE_SHUTDOWN", "1", TRUE);
+
+       return 0;
 }
index b9bb3f5..31acb01 100644 (file)
@@ -257,11 +257,13 @@ int main (int argc, char** argv){
 
   if (! global_options.no_bonobo)
     {    
-      bonobo_activation_active_server_register (
-         obj_id,
-         bonobo_object_corba_objref (bonobo_object (magnifier)));
+      int ret = bonobo_activation_active_server_register (
+       obj_id, BONOBO_OBJREF (magnifier));
 
-      bonobo_main ();
+      if (ret == Bonobo_ACTIVATION_REG_SUCCESS)
+        {
+          bonobo_main ();
+       }
     }
   else
     {
@@ -527,7 +529,7 @@ magnifier_get_type (void)
 }
 
 Magnifier *
-magnifier_new(int argc, char **argv)
+magnifier_new (int argc, char **argv)
 {
   poptContext ctx;     
   Magnifier *magnifier =
@@ -543,20 +545,3 @@ magnifier_new(int argc, char **argv)
 
   return magnifier;
 }
-
-
-
-
-
-
-
-
-
-
-
-
-
-    
-
-
-