[libbonobo] Port to GDBus



commit fc806a338a8407e1ced2cd25974e093870dc8a7f
Author: Christian Persch <chpe gnome org>
Date:   Sat May 15 23:20:05 2010 +0200

    Port to GDBus
    
    Bug #618744.

 activation-server/activation-server-main.c         |   50 +++++++-------------
 bonobo-activation/bonobo-activation-base-service.c |    7 +--
 configure.in                                       |    8 ++--
 3 files changed, 24 insertions(+), 41 deletions(-)
---
diff --git a/activation-server/activation-server-main.c b/activation-server/activation-server-main.c
index 9763e63..f3b4bf9 100644
--- a/activation-server/activation-server-main.c
+++ b/activation-server/activation-server-main.c
@@ -54,9 +54,7 @@
 
 #include <glib/gstdio.h>
 
-#ifdef HAVE_DBUS
-#include <dbus/dbus-glib-lowlevel.h>
-#endif
+#include <gio/gio.h>
 
 #ifdef G_OS_WIN32
 #include <io.h>
@@ -421,19 +419,16 @@ cleanup_ior_and_lock_files (void)
 
 #ifdef HAVE_DBUS
 
-static DBusHandlerResult
-bus_message_handler (DBusConnection *connection,
-                     DBusMessage    *message,
-                     GMainLoop      *loop)
+static void
+session_bus_closed_cb (GDBusConnection *conection,
+                       gboolean         remote_peer_vanished,
+                       GError          *error,
+                       gpointer         user_data)
 {
-        if (dbus_message_is_signal (message,
-                                    DBUS_INTERFACE_LOCAL,
-                                    "Disconnected")) {
-                g_main_loop_quit (loop);
-                return DBUS_HANDLER_RESULT_HANDLED;
-        }
+        GMainLoop *loop = (GMainLoop *) user_data;
 
-        return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+        if (g_main_loop_is_running (loop))
+                g_main_loop_quit (loop);
 }
 
 #endif
@@ -500,8 +495,7 @@ main (int argc, char *argv[])
 #endif
 	GError                       *error = NULL;
 #ifdef HAVE_DBUS
-        DBusConnection               *connection;
-        DBusError                     bus_error;
+        GDBusConnection              *connection;
 #endif
 
 #ifdef HAVE_SETSID
@@ -647,25 +641,15 @@ main (int argc, char *argv[])
 	od_finished_internal_registration (); 
 
 #ifdef HAVE_DBUS
-        dbus_error_init (&bus_error);
-        connection = dbus_bus_get (DBUS_BUS_SESSION, &bus_error);
-
-        if (dbus_error_is_set (&bus_error)) {
+        connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
+        if (connection == NULL) {
                 g_warning ("could not associate with desktop session: %s",
-                           bus_error.message);
-                connection = NULL;
+                           error->message);
+                g_error_free (error);
         } else {
-                GMainContext *main_context;
-
-                main_context = g_main_loop_get_context (main_loop);
-                dbus_connection_setup_with_g_main (connection, main_context);
-
-                if (dbus_connection_add_filter (connection,
-                                                (DBusHandleMessageFunction)
-                                                bus_message_handler, main_loop,
-                                                NULL)) {
-                        dbus_connection_set_exit_on_disconnect (connection, FALSE);
-                }
+                g_signal_connect (connection, "closed",
+                                  G_CALLBACK (session_bus_closed_cb), main_loop);
+                g_dbus_connection_set_exit_on_close (connection, FALSE);
         }
 #endif
         if (getenv ("BONOBO_ACTIVATION_DEBUG") == NULL)
diff --git a/bonobo-activation/bonobo-activation-base-service.c b/bonobo-activation/bonobo-activation-base-service.c
index a90e673..d274378 100644
--- a/bonobo-activation/bonobo-activation-base-service.c
+++ b/bonobo-activation/bonobo-activation-base-service.c
@@ -30,6 +30,8 @@
 
 #include <glib/gi18n-lib.h>
 
+#include <gio/gio.h>
+
 #include <bonobo-activation/bonobo-activation-init.h>
 #include <bonobo-activation/bonobo-activation-base-service.h>
 #include <bonobo-activation/bonobo-activation-private.h>
@@ -505,10 +507,7 @@ get_session_guid (void)
         const char *session_bus_address;
         const char *guid;
 
-        /* FIXME: we may want to use dbus-address.h functions here
-         */
-        session_bus_address = g_getenv ("DBUS_SESSION_BUS_ADDRESS");
-
+        session_bus_address = g_dbus_address_get_for_bus_sync (G_BUS_TYPE_SESSION, NULL, NULL);
         if (session_bus_address == NULL)
                 return NULL;
 
diff --git a/configure.in b/configure.in
index 01dacb0..494b10c 100644
--- a/configure.in
+++ b/configure.in
@@ -47,7 +47,6 @@ case "$host" in
     SOPREFIX=lib
     SEARCHPATHSEP=":"
     AC_DEFINE(HAVE_DBUS, 1, [whether we have dbus])
-    dbus_requirement="dbus-1 >= 1.0.0 dbus-glib-1 >= 0.74"
     ;;
 esac
 
@@ -110,7 +109,7 @@ AC_CHECK_HEADERS(sys/wait.h syslog.h)
 # Start of pkg-config checks
 #
 ORBIT_VERSION=2.11.2
-GLIB_VERSION=2.14.0
+GLIB_VERSION=2.25.7
 
 PKG_CHECK_MODULES(LIBBONOBO, \
 	ORBit-2.0 >= $ORBIT_VERSION \
@@ -118,15 +117,16 @@ PKG_CHECK_MODULES(LIBBONOBO, \
 	gmodule-2.0 >= 2.0.1 \
 	glib-2.0 >= $GLIB_VERSION \
 	gobject-2.0 >= $GLIB_VERSION \
-	gthread-2.0 >= $GLIB_VERSION)
+	gthread-2.0 >= $GLIB_VERSION \
+        gio-2.0 >= $GLIB_VERSION)
 AC_SUBST(LIBBONOBO_CFLAGS)
 AC_SUBST(LIBBONOBO_LIBS)
 
 PKG_CHECK_MODULES(SERVER, \
 	gmodule-2.0 >= 2.0.1 \
+	gio-2.0 >= 2.25.5 \
 	ORBit-2.0 >= 2.4.0 \
 	ORBit-CosNaming-2.0 >= 2.4.0 \
-	$dbus_requirement \
 	libxml-2.0 >= 2.4.20)
 AC_SUBST(SERVER_LIBS)
 AC_SUBST(SERVER_CFLAGS)



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