2007-01-22 Li Yuan <li.yuan@sun.com>
authorliyuan <liyuan@e2bd861d-eb25-0410-b326-f6ed22b6b98c>
Mon, 22 Jan 2007 12:08:16 +0000 (12:08 +0000)
committerliyuan <liyuan@e2bd861d-eb25-0410-b326-f6ed22b6b98c>
Mon, 22 Jan 2007 12:08:16 +0000 (12:08 +0000)
        * cspi/bonobo/cspi-bonobo.c:
        (cspi_get_registry_ior), (cspi_init):
        Bug #393010. Use REGISTRY IOR XAtom to get registryd.

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

ChangeLog
cspi/bonobo/cspi-bonobo.c

index 6313a88..a3cbd0c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2007-01-22  Li Yuan  <li.yuan@sun.com>
+
+       * cspi/bonobo/cspi-bonobo.c:
+       (cspi_get_registry_ior), (cspi_init):
+       Bug #393010. Use REGISTRY IOR XAtom to get registryd.
+
 2007-01-19  Li Yuan  <li.yuan@sun.com>
 
        * atk-bridge/bridge.c:
index d4029f9..13b1aa3 100644 (file)
@@ -25,6 +25,8 @@
 #include <string.h>
 #include <libbonobo.h>
 #include "../cspi-lowlevel.h"
+#include <X11/Xlib.h>
+#include <X11/Xatom.h>
 
 CORBA_Object
 cspi_dup_ref (CORBA_Object object)
@@ -114,27 +116,53 @@ cspi_display_name (void)
     return canonical_display_name;
 }
 
+static gchar *
+cspi_get_registry_ior (void)
+{
+  Atom AT_SPI_IOR;
+  Atom actual_type;
+  int actual_format;
+  unsigned char *data = NULL;
+  unsigned long nitems;
+  unsigned long leftover;
+  static Display *display = NULL;
+  if (!display)
+    display = XOpenDisplay (cspi_display_name ());
+
+  AT_SPI_IOR = XInternAtom (display, "AT_SPI_IOR", False);
+  XGetWindowProperty(display,
+                     XDefaultRootWindow (display),
+                     AT_SPI_IOR, 0L,
+                     (long)BUFSIZ, False,
+                     (Atom) 31, &actual_type, &actual_format,
+                     &nitems, &leftover, &data);
+  if (data == NULL)
+    g_warning ("AT_SPI_REGISTRY was not started at session startup.");
+
+  return (gchar *) data;
+}
+
 CORBA_Object
 cspi_init (void)
 {
   char *obj_id;
   CORBA_Object registry;
   CORBA_Environment ev;
+  char *ior =  NULL;
 
   if (!bonobo_init (0, NULL))
     {
       g_error ("Could not initialize Bonobo");
     }
 
-  obj_id = "OAFIID:Accessibility_Registry:1.0";
-
   CORBA_exception_init (&ev);
 
-  bonobo_activation_set_activation_env_value ("AT_SPI_DISPLAY", 
-                                             cspi_display_name ());
-
-  registry = bonobo_activation_activate_from_id (
-    obj_id, 0, NULL, &ev);
+  ior = (char *) cspi_get_registry_ior ();
+  if (ior != NULL)
+    {
+      registry = CORBA_ORB_string_to_object (bonobo_activation_orb_get (),
+                                                ior, &ev);
+    }
 
   if (ev._major != CORBA_NO_EXCEPTION)
     {