[at-spi2-core] Quit if at-spi-dbus is disabled



commit 05dd2c6d8ab6ea4065a09a114cb74cfc38d6c407
Author: Mike Gorse <mgorse novell com>
Date:   Sun Mar 14 09:16:09 2010 -0400

    Quit if at-spi-dbus is disabled
    
    Quit if gconf is present and at-spi-dbus is disabled.  Add --disable-relocate
    to configure.ac.

 configure.ac              |    6 +++++
 registryd/registry-main.c |   53 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 59 insertions(+), 0 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index f8be1ab..b5a0550 100644
--- a/configure.ac
+++ b/configure.ac
@@ -128,6 +128,12 @@ AC_SUBST(DBUS_SERVICES_DIR)
 
 AC_SUBST(LIBTOOL_EXPORT_OPTIONS)
 
+AC_ARG_ENABLE(relocate, [  --enable-relocate  Relocate to coexist with CORBA [default=yes]], enable_relocate="$enableval", enable_relocate=yes)
+if test x$enable_relocate = xyes ; then
+	AC_DEFINE(RELOCATE, , [Relocate to coexist with CORBA])
+fi
+AM_CONDITIONAL(RELOCATE, test x$enable_relocate = xyes)
+
 AC_CONFIG_FILES([Makefile
 		 xml/Makefile
 		 registryd/Makefile])
diff --git a/registryd/registry-main.c b/registryd/registry-main.c
index 14130a1..b00389f 100644
--- a/registryd/registry-main.c
+++ b/registryd/registry-main.c
@@ -26,6 +26,7 @@
 #include <string.h>
 #include <glib.h>
 #include <stdio.h>
+#include <dlfcn.h>
 
 #include <dbus/dbus.h>
 #include <dbus/dbus-glib.h>
@@ -38,6 +39,14 @@
     #error "No introspection XML directory defined"
 #endif
 
+#ifdef RELOCATE
+#define DBUS_GCONF_KEY  "/desktop/gnome/interface/at-spi-dbus"
+#else
+#define CORBA_GCONF_KEY  "/desktop/gnome/interface/at-spi-corba"
+#endif
+
+static gboolean need_to_quit ();
+
 static GMainLoop *mainloop;
 static gchar *dbus_name = NULL;
 static gboolean use_gnome_session = FALSE;
@@ -275,6 +284,9 @@ spi_get_bus (void)
 
 /*---------------------------------------------------------------------------*/
 
+typedef GObject *(*gconf_client_get_default_t) ();
+typedef gboolean (*gconf_client_get_bool_t)(GObject *, const char *, void *);
+
 int
 main (int argc, char **argv)
 {
@@ -290,6 +302,9 @@ main (int argc, char **argv)
   DBusError error;
   int ret;
 
+  if (need_to_quit ())
+    return 0;
+
   g_type_init();
 
   /*Parse command options*/
@@ -343,3 +358,41 @@ main (int argc, char **argv)
   g_main_loop_run (mainloop);
   return 0;
 }
+
+static gboolean
+need_to_quit ()
+{
+  void *gconf = NULL;
+  gconf_client_get_default_t gconf_client_get_default = NULL;
+  gconf_client_get_bool_t gconf_client_get_bool = NULL;
+  GObject *gconf_client;	/* really a GConfClient */
+  gboolean ret;
+
+  gconf = dlopen ("libgconf-2.so", RTLD_LAZY);
+  if (gconf)
+    {
+      gconf_client_get_default = dlsym (gconf, "gconf_client_get_default");
+      gconf_client_get_bool = dlsym (gconf, "gconf_client_get_bool");
+  }
+
+  if (!gconf_client || !gconf_client_get_bool)
+    {
+      if (gconf)
+        dlclose (gconf);
+      return FALSE;
+    }
+
+  /* If we've been relocated, we will exit if the at-spi-corba gconf key
+ * has been set.  If we have not been relocated, we will only run if the
+ * at-spi-dbus gconf key has been set.
+   */
+  gconf_client = gconf_client_get_default ();
+#ifdef RELOCATE
+  ret = !gconf_client_get_bool (gconf_client, DBUS_GCONF_KEY, NULL);
+#else
+  ret = gconf_client_get_bool (gconf_client, CORBA_GCONF_KEY, NULL);
+#endif
+  g_object_unref (gconf_client);
+
+  return ret;
+}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]