Fix for bug #163132 - allows multi-user/remote access to the
authorbillh <billh@e2bd861d-eb25-0410-b326-f6ed22b6b98c>
Tue, 7 Nov 2006 00:23:54 +0000 (00:23 +0000)
committerbillh <billh@e2bd861d-eb25-0410-b326-f6ed22b6b98c>
Tue, 7 Nov 2006 00:23:54 +0000 (00:23 +0000)
at-spi registry.  Yay!  Thanks to Ariel Rios for working on the patch.

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

ChangeLog
atk-bridge/bridge.c
configure.in
registryd/registry-main.c
registryd/registry.h

index 97307b8..9ae97d8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+2006-11-07  Bill Haneman <bill.haneman@sun.com>
+
+       * configure.in: Uprev/release 1.7.13 for gnome 2.17.2.
+       Don't require gtk+ and gail for building most of at-spi
+       including libspi.
+
+       * registryd/registry-main.c: 
+       (main): Call registry_set_ior.
+       (registry_set_ior): New, puts the registry's stringified IOR
+       on the root property as an XAtom, for discovery by all interested
+       X clients.  See bug #163132.
+
+       * registryd/registry.h: Remove unneeded #include of gdk.
+
+       * atk-bridge/bridge.c:
+       (spi_atk_bridge_get_registry_ior): New, use this to 
+       obtain the registry's IOR instead of using bonobo-activation.
+
+2006-10-01  Bill Haneman <bill.haneman@sun.com>
+
+       * configure.in: Uprev/release 1.7.12 for gnome 2.16.1.
+
 2006-09-25  Bill Haneman <bill.haneman@sun.com>
 
        * registryd/registry.c:
index 328e6bd..fd00be6 100644 (file)
@@ -23,6 +23,8 @@
 
 #include "config.h"
 
+#include <X11/Xlib.h>
+#include <X11/Xatom.h>
 #include <string.h>
 #include <stdio.h>
 #include <unistd.h>
@@ -72,7 +74,7 @@ static guint atk_signal_link_selected;
 static guint atk_signal_bounds_changed;
 
 static Accessibility_Registry spi_atk_bridge_get_registry (void);
-static void     spi_atk_bridge_do_registration         (void);
+static gboolean spi_atk_bridge_do_registration         (void);
 static void     spi_atk_bridge_toplevel_added          (AtkObject             *object,
                                                         guint                 index,
                                                         AtkObject             *child);
@@ -83,6 +85,7 @@ static void     spi_atk_bridge_toplevel_removed        (AtkObject             *o
 static void     spi_atk_bridge_exit_func               (void);
 static void     spi_atk_register_event_listeners       (void);
 static void     spi_atk_bridge_focus_tracker           (AtkObject             *object);
+static gchar   *spi_atk_bridge_get_registry_ior        (void);
 static void     spi_atk_bridge_register_application    (Accessibility_Registry registry);
 static gboolean spi_atk_bridge_property_event_listener (GSignalInvocationHint *signal_hint,
                                                        guint                  n_param_values,
@@ -172,6 +175,7 @@ atk_bridge_init (gint *argc, gchar **argv[])
 {
   const char *debug_env_string = g_getenv ("AT_SPI_DEBUG");
   gchar *fname;
+  gboolean success = FALSE;
 
   if (atk_bridge_initialized)
     {
@@ -219,16 +223,22 @@ atk_bridge_init (gint *argc, gchar **argv[])
     }
   else
     {
-      spi_atk_bridge_do_registration ();
+      success = spi_atk_bridge_do_registration ();
+    }
+  if (success) 
+    {
+      spi_atk_register_event_listeners ();
+      spi_atk_bridge_init_event_type_consts ();
+    }
+  else
+    {
+      atk_bridge_initialized = FALSE;
     }
-  spi_atk_register_event_listeners ();
-  spi_atk_bridge_init_event_type_consts ();
   return 0;
 }
 
 
-static void
+static gboolean
 spi_atk_bridge_do_registration (void)
 {
   CORBA_Environment ev;
@@ -238,6 +248,7 @@ spi_atk_bridge_do_registration (void)
   if (spi_atk_bridge_get_registry () == CORBA_OBJECT_NIL)
     {
       g_error ("Could not locate registry");
+      return FALSE;
     }
 
   bonobo_activate ();
@@ -253,7 +264,7 @@ spi_atk_bridge_do_registration (void)
   g_atexit (spi_atk_bridge_exit_func);
 
   DBG (1, g_message ("Application registered & listening\n"));
-
+  return TRUE;
 }
 
 static void
@@ -332,10 +343,41 @@ spi_display_name (void)
     return canonical_display_name;
 }
 
+static     Display *bridge_display = NULL;
+
+static gchar *
+spi_atk_bridge_get_registry_ior (void)
+{
+     
+     Atom AT_SPI_IOR;
+     Atom actual_type;
+     int actual_format;
+     unsigned char *data = NULL;  
+     unsigned long nitems;
+     unsigned long leftover;
+     if (!bridge_display) 
+       bridge_display = XOpenDisplay (spi_display_name ());
+
+     AT_SPI_IOR = XInternAtom (bridge_display, "AT_SPI_IOR", False); 
+     XGetWindowProperty(bridge_display, 
+                       XDefaultRootWindow (bridge_display),
+                       AT_SPI_IOR, 0L, 
+                       (long)BUFSIZ, False, 
+                       (Atom) 31, &actual_type, &actual_format,
+                       &nitems, &leftover, &data);
+     if (data == NULL)
+         g_critical (_("AT_SPI_REGISTRY was not started at session startup."));
+     
+     return (gchar *) data;
+     
+}
+
+
 static Accessibility_Registry
 spi_atk_bridge_get_registry (void)
 {
   CORBA_Environment ev;
+  char *ior =  NULL;
 
   if (registry_died || (registry == CORBA_OBJECT_NIL)) {
          CORBA_exception_init (&ev);
@@ -346,10 +388,17 @@ spi_atk_bridge_get_registry (void)
               else
                DBG (1, g_warning ("registry died! restarting..."));
             }
-         bonobo_activation_set_activation_env_value ("AT_SPI_DISPLAY", spi_display_name ());
 
-         registry = bonobo_activation_activate_from_id (
-                 "OAFIID:Accessibility_Registry:1.0", 0, NULL, &ev);
+         /* XXX: This presumes that the registry has successfully restarted itself already...*/
+         ior = (char *) spi_atk_bridge_get_registry_ior ();
+
+         if (ior != NULL)
+              registry = CORBA_ORB_string_to_object (bonobo_activation_orb_get (), 
+                                                     ior, &ev);
+         else {
+              g_warning ("IOR not set.");  
+              registry = CORBA_OBJECT_NIL;
+         }
          
          if (ev._major != CORBA_NO_EXCEPTION)
          {
@@ -555,6 +604,8 @@ spi_atk_bridge_exit_func (void)
     {
       g_assert (!bonobo_debug_shutdown ());
     }
+  if (bridge_display)
+    XCloseDisplay (bridge_display);
 }
 
 void
@@ -588,14 +639,16 @@ gnome_accessibility_module_shutdown (void)
     }
 
   listener_ids = NULL;
-  atk_remove_focus_tracker (atk_bridge_focus_tracker_id);
+  if (atk_bridge_focus_tracker_id)
+        atk_remove_focus_tracker (atk_bridge_focus_tracker_id);
   
   for (i = 0; ids && i < ids->len; i++)
   {
           atk_remove_global_event_listener (g_array_index (ids, guint, i));
   }
   
-  atk_remove_key_event_listener (atk_bridge_key_event_listener_id);
+  if (atk_bridge_key_event_listener_id)
+          atk_remove_key_event_listener (atk_bridge_key_event_listener_id);
 
   deregister_application (app);
 }
index 8fa4908..74e42bb 100644 (file)
@@ -2,7 +2,7 @@ AC_INIT(idl/Accessibility.idl)
 
 AT_SPI_MAJOR_VERSION=1
 AT_SPI_MINOR_VERSION=7
-AT_SPI_MICRO_VERSION=12
+AT_SPI_MICRO_VERSION=13
 AT_SPI_INTERFACE_AGE=0
 AT_SPI_BINARY_AGE=0
 AT_SPI_VERSION="$AT_SPI_MAJOR_VERSION.$AT_SPI_MINOR_VERSION.$AT_SPI_MICRO_VERSION"
@@ -27,9 +27,9 @@ AC_SUBST(LT_AGE)
 
 dnl required versions of other tools.
 m4_define([req_ver_atk],       [1.12.0])
+m4_define([req_ver_gtk],       [2.10.0])
+m4_define([req_ver_gail],      [1.9.0])
 m4_define([req_ver_libbonobo], [1.107.0])
-m4_define([req_ver_gail],      [1.3.0])
-m4_define([req_ver_gtk],       [2.0.0])
 
 dnl Specify a header configuration file
 AM_CONFIG_HEADER(config.h)
@@ -84,8 +84,6 @@ dnl Checks for libraries
 PKG_CHECK_MODULES(LIBSPI, [
        libbonobo-2.0   >= req_ver_libbonobo
        atk             >= req_ver_atk
-       gtk+-2.0        >= req_ver_gtk
-       gail            >= req_ver_gail
 ])
 AC_SUBST(LIBSPI_LIBS)
 AC_SUBST(LIBSPI_CFLAGS)
@@ -110,7 +108,7 @@ AC_SUBST(TESTS_CFLAGS)
 PKG_CHECK_MODULES(ATK_BRIDGE, [
        libbonobo-2.0   >= req_ver_libbonobo
        atk             >= req_ver_atk
-])
+])     
 AC_SUBST(ATK_BRIDGE_LIBS)
 AC_SUBST(ATK_BRIDGE_CFLAGS)
 
index dee55db..c43c6dc 100644 (file)
 
 #include <config.h>
 #include <string.h>
-#include <gdk/gdk.h>
+#include <gdk/gdkx.h>
 #include <libbonobo.h>
 #include <glib/gmain.h>
 #include "registry.h"
 
+#define spi_get_display() GDK_DISPLAY()
+
+static void registry_set_ior (SpiRegistry *registry);
+
 int
 main (int argc, char **argv)
 {
@@ -40,7 +44,6 @@ main (int argc, char **argv)
   const char  *display_name;
   char        *cp, *dp;
   SpiRegistry *registry;
-  GSList      *reg_env = NULL;
 
   if (!bonobo_init (&argc, argv))
     {
@@ -54,19 +57,18 @@ main (int argc, char **argv)
   display_name = g_getenv ("AT_SPI_DISPLAY");
   if (!display_name)
   {
-      display_name = g_strdup (gdk_display_get_name (gdk_display_get_default ()));
+      display_name = g_getenv ("DISPLAY");
       cp = strrchr (display_name, '.');
       dp = strrchr (display_name, ':');
       if (cp && dp && (cp > dp)) *cp = '\0';
   }
 
-  reg_env = bonobo_activation_registration_env_set ( reg_env, "AT_SPI_DISPLAY", 
-                                                    display_name);
   ret = bonobo_activation_register_active_server (
          obj_id,
          bonobo_object_corba_objref (bonobo_object (registry)),
-         reg_env);
-  bonobo_activation_registration_env_free (reg_env);
+         NULL);
+
+  registry_set_ior (registry);
 
   if (ret != Bonobo_ACTIVATION_REG_SUCCESS)
     {
@@ -85,3 +87,32 @@ main (int argc, char **argv)
   return 0;
 }
 
+static void
+registry_set_ior (SpiRegistry *registry){
+  CORBA_Environment ev;
+  Atom  AT_SPI_IOR = XInternAtom (spi_get_display (), "AT_SPI_IOR", FALSE);
+  char *iorstring = NULL;
+
+  CORBA_exception_init (&ev);
+
+  iorstring = CORBA_ORB_object_to_string (bonobo_activation_orb_get (),
+                                     bonobo_object_corba_objref (bonobo_object (registry)),
+                                     &ev);
+
+  XChangeProperty (spi_get_display(),
+                  XDefaultRootWindow (spi_get_display ()),
+                  AT_SPI_IOR, (Atom) 31, 8,
+                  PropModeReplace,
+                  (unsigned char *) iorstring,
+                  iorstring ? strlen (iorstring) : 0);
+
+  if (ev._major != CORBA_NO_EXCEPTION)
+         {
+                 g_error ("Error setting IOR %s",
+                          CORBA_exception_id (&ev));
+                  CORBA_exception_free (&ev);
+           }
+
+  CORBA_exception_free (&ev);
+
+}
index 166a0d0..679adeb 100644 (file)
@@ -25,7 +25,6 @@
 #define SPI_REGISTRY_H_
 
 #include <glib/gmain.h>
-#include <gdk/gdk.h>
 #include <libspi/listener.h>
 
 typedef struct _SpiRegistry SpiRegistry;