[gdm/wip/slave-connection: 7/27] common: Use GDBus for GdmSettings



commit 6699cab9902dfa906f910156ac914ec06d7c2acc
Author: Giovanni Campagna <gcampagna src gnome org>
Date:   Thu May 3 17:54:59 2012 +0200

    common: Use GDBus for GdmSettings
    
    GdmSettings is a system bus service provided by
    GDM so that greeters can read custom.conf without
    parsing the file themselves.
    
    This commit changes GdmSettings to use gdbus instead
    of dbus-glib.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=622888

 .gitignore                        |    1 +
 common/Makefile.am                |   14 ++++-
 common/gdm-settings-client.c      |  108 ++++++++++++-----------------------
 common/gdm-settings.c             |   87 +++++++++++++++++++++++-----
 common/test-settings-server.c     |  114 ++++++++-----------------------------
 configure.ac                      |    1 +
 daemon/factory-slave-main.c       |   20 +++----
 daemon/simple-slave-main.c        |   20 +++----
 daemon/xdmcp-chooser-slave-main.c |   20 +++----
 9 files changed, 171 insertions(+), 214 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index eb217ef..f0d8d41 100644
--- a/.gitignore
+++ b/.gitignore
@@ -36,6 +36,7 @@ gdm-safe-restart
 gdm.schemas
 gdm-session-direct-glue.h
 gdm-settings-glue.h
+gdm-settings-glue.c
 gdm-simple-greeter.desktop.in
 gdm-simple-greeter.schemas
 gdm-simple-slave-glue.h
diff --git a/common/Makefile.am b/common/Makefile.am
index 3492041..11cd473 100644
--- a/common/Makefile.am
+++ b/common/Makefile.am
@@ -49,8 +49,12 @@ gdm_crash_logger_CPPFLAGS = \
 	$(NULL)
 gdm_crash_logger_LDADD = $(GTHREAD_LIBS)
 
-gdm-settings-glue.h: gdm-settings.xml Makefile.am
-	dbus-binding-tool --prefix=gdm_settings --mode=glib-server --output=gdm-settings-glue.h $(srcdir)/gdm-settings.xml
+gdm-settings-glue.c gdm-settings-glue.h : gdm-settings.xml Makefile.am
+	$(AM_V_GEN)gdbus-codegen 				\
+		--c-namespace=GdmDBus				\
+		--interface-prefix=org.gnome.DisplayManager	\
+		--generate-c-code=gdm-settings-glue		\
+		$(srcdir)/gdm-settings.xml
 
 if MKDTEMP_MISSING
 MKDTEMP_FILES = mkdtemp.c mkdtemp.h
@@ -89,6 +93,11 @@ libgdmcommon_la_SOURCES =	\
 	$(MKDTEMP_FILES) 	\
 	$(NULL)
 
+nodist_libgdmcommon_la_SOURCES = 	\
+	gdm-settings-glue.h		\
+	gdm-settings-glue.c		\
+	$(NULL)
+
 libgdmcommon_la_CPPFLAGS = 		\
 	$(AM_CPPFLAGS)			\
 	$(DISABLE_DEPRECATED_CFLAGS)	\
@@ -139,6 +148,7 @@ test_settings_client_LDADD =		\
 	$(NULL)
 
 CLEANFILES =			\
+	gdm-settings-glue.c	\
 	$(BUILT_SOURCES)	\
 	$(NULL)
 
diff --git a/common/gdm-settings-client.c b/common/gdm-settings-client.c
index 0b6b1cc..22fb2f4 100644
--- a/common/gdm-settings-client.c
+++ b/common/gdm-settings-client.c
@@ -29,17 +29,15 @@
 #include <sys/stat.h>
 #include <sys/types.h>
 
-#define DBUS_API_SUBJECT_TO_CHANGE
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
-
 #include <glib.h>
 #include <glib/gi18n.h>
 #include <glib/gstdio.h>
 #include <glib-object.h>
+#include <gio/gio.h>
 
 #include "gdm-settings-client.h"
 #include "gdm-settings-utils.h"
+#include "gdm-settings-glue.h"
 
 #define SETTINGS_DBUS_NAME      "org.gnome.DisplayManager"
 #define SETTINGS_DBUS_PATH      "/org/gnome/DisplayManager/Settings"
@@ -47,8 +45,7 @@
 
 static GHashTable      *notifiers      = NULL;
 static GHashTable      *schemas        = NULL;
-static DBusGProxy      *settings_proxy = NULL;
-static DBusGConnection *connection     = NULL;
+static GdmDBusSettings *settings_proxy = NULL;
 static guint32          id_serial      = 0;
 
 typedef struct {
@@ -94,27 +91,19 @@ set_value (const char *key,
 
         /* FIXME: check cache */
 
-        g_debug ("Setting %s=%s", key, value);
         error = NULL;
-        res = dbus_g_proxy_call (settings_proxy,
-                                 "SetValue",
-                                 &error,
-                                 G_TYPE_STRING, key,
-                                 G_TYPE_STRING, value,
-                                 G_TYPE_INVALID,
-                                 G_TYPE_INVALID);
-        if (! res) {
-                if (error != NULL) {
-                        /*g_debug ("Failed to get value for %s: %s", key, error->message);*/
-                        g_error_free (error);
-                } else {
-                        /*g_debug ("Failed to get value for %s", key);*/
-                }
 
-                return FALSE;
+        res = gdm_dbus_settings_call_set_value_sync (settings_proxy,
+                                                     key,
+                                                     value,
+                                                     NULL,
+                                                     &error);
+        if (! res) {
+                g_debug ("Failed to set value for %s: %s", key, error->message);
+                g_error_free (error);
         }
 
-        return TRUE;
+        return res;
 }
 
 static gboolean
@@ -122,37 +111,23 @@ get_value (const char *key,
            char      **value)
 {
         GError  *error;
-        char    *str;
         gboolean res;
 
         /* FIXME: check cache */
 
         error = NULL;
-        res = dbus_g_proxy_call (settings_proxy,
-                                 "GetValue",
-                                 &error,
-                                 G_TYPE_STRING, key,
-                                 G_TYPE_INVALID,
-                                 G_TYPE_STRING, &str,
-                                 G_TYPE_INVALID);
-        if (! res) {
-                if (error != NULL) {
-                        /*g_debug ("Failed to get value for %s: %s", key, error->message);*/
-                        g_error_free (error);
-                } else {
-                        /*g_debug ("Failed to get value for %s", key);*/
-                }
-
-                return FALSE;
-        }
 
-        if (value != NULL) {
-                *value = g_strdup (str);
+        res = gdm_dbus_settings_call_get_value_sync (settings_proxy,
+                                                     key,
+                                                     value,
+                                                     NULL,
+                                                     &error);
+        if (! res) {
+                g_debug ("Failed to get value for %s: %s", key, error->message);
+                g_error_free (error);
         }
 
-        g_free (str);
-
-        return TRUE;
+        return res;
 }
 
 static void
@@ -467,11 +442,11 @@ send_notification (gpointer                 key,
 }
 
 static void
-on_value_changed (DBusGProxy *proxy,
-                  const char *key,
-                  const char *old_value,
-                  const char *new_value,
-                  gpointer    data)
+on_value_changed (GdmDBusSettings *proxy,
+                  const char      *key,
+                  const char      *old_value,
+                  const char      *new_value,
+                  gpointer         data)
 {
         GdmSettingsEntry *entry;
 
@@ -502,27 +477,23 @@ gdm_settings_client_init (const char *file,
         g_assert (schemas == NULL);
 
         error = NULL;
-        connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
-        if (connection == NULL) {
-                if (error != NULL) {
-                        g_warning ("error getting system bus: %s", error->message);
-                        g_error_free (error);
-                }
-                return FALSE;
-        }
 
-        settings_proxy = dbus_g_proxy_new_for_name (connection,
-                                                    SETTINGS_DBUS_NAME,
-                                                    SETTINGS_DBUS_PATH,
-                                                    SETTINGS_DBUS_INTERFACE);
+        settings_proxy = GDM_DBUS_SETTINGS (gdm_dbus_settings_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
+                                                                                      G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
+                                                                                      SETTINGS_DBUS_NAME,
+                                                                                      SETTINGS_DBUS_PATH,
+                                                                                      NULL,
+                                                                                      &error));
         if (settings_proxy == NULL) {
-                g_warning ("Unable to connect to settings server");
+                g_warning ("Unable to connect to settings server: %s", error->message);
+                g_error_free (error);
                 return FALSE;
         }
 
         list = NULL;
         if (! gdm_settings_parse_schemas (file, root, &list)) {
                 g_warning ("Unable to parse schemas");
+                g_clear_object (&settings_proxy);
                 return FALSE;
         }
 
@@ -531,14 +502,7 @@ gdm_settings_client_init (const char *file,
         schemas = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify)gdm_settings_entry_free);
         g_slist_foreach (list, (GFunc)hashify_list, NULL);
 
-        dbus_g_proxy_add_signal (settings_proxy, "ValueChanged", G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
-        dbus_g_proxy_connect_signal (settings_proxy,
-                                     "ValueChanged",
-                                     G_CALLBACK (on_value_changed),
-                                     NULL,
-                                     NULL);
-
-
+        g_signal_connect (settings_proxy, "value-changed", G_CALLBACK (on_value_changed), NULL);
         return TRUE;
 }
 
diff --git a/common/gdm-settings.c b/common/gdm-settings.c
index 0395681..e6a658b 100644
--- a/common/gdm-settings.c
+++ b/common/gdm-settings.c
@@ -33,9 +33,7 @@
 #include <glib/gi18n.h>
 #include <glib/gstdio.h>
 #include <glib-object.h>
-#define DBUS_API_SUBJECT_TO_CHANGE
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
+#include <gio/gio.h>
 
 #include "gdm-settings.h"
 #include "gdm-settings-glue.h"
@@ -50,7 +48,8 @@
 
 struct GdmSettingsPrivate
 {
-        DBusGConnection    *connection;
+        GDBusConnection    *connection;
+        GdmDBusSettings    *skeleton;
         GdmSettingsBackend *backend;
 };
 
@@ -139,12 +138,58 @@ gdm_settings_set_value (GdmSettings *settings,
 }
 
 static gboolean
+handle_get_value (GdmDBusSettings       *settings,
+                  GDBusMethodInvocation *invocation,
+                  const char            *key,
+                  gpointer               user_data)
+{
+        GdmSettings *self = GDM_SETTINGS (user_data);
+        GError *error = NULL;
+        char *value = NULL;
+
+        gdm_settings_get_value (self, key, &value, &error);
+        if (error) {
+                g_dbus_method_invocation_return_gerror (invocation, error);
+                g_error_free (error);
+                return TRUE;
+        }
+
+        gdm_dbus_settings_complete_get_value (settings, invocation,
+                                              value);
+        g_free (value);
+
+        return TRUE;
+}
+
+static gboolean
+handle_set_value (GdmDBusSettings       *settings,
+                  GDBusMethodInvocation *invocation,
+                  const char            *key,
+                  const char            *value,
+                  gpointer               user_data)
+{
+        GdmSettings *self = GDM_SETTINGS (user_data);
+        GError *error = NULL;
+
+        gdm_settings_set_value (self, key, value, &error);
+        if (error) {
+                g_dbus_method_invocation_return_gerror (invocation, error);
+                g_error_free (error);
+                return TRUE;
+        }
+
+        gdm_dbus_settings_complete_set_value (settings, invocation);
+
+        return TRUE;
+}
+
+static gboolean
 register_settings (GdmSettings *settings)
 {
         GError *error = NULL;
 
         error = NULL;
-        settings->priv->connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
+        settings->priv->connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
         if (settings->priv->connection == NULL) {
                 if (error != NULL) {
                         g_critical ("error getting system bus: %s", error->message);
@@ -153,7 +198,22 @@ register_settings (GdmSettings *settings)
                 exit (1);
         }
 
-        dbus_g_connection_register_g_object (settings->priv->connection, GDM_SETTINGS_DBUS_PATH, G_OBJECT (settings));
+        settings->priv->skeleton = GDM_DBUS_SETTINGS (gdm_dbus_settings_skeleton_new ());
+        g_signal_connect_object (settings->priv->skeleton,
+                                 "handle-get-value",
+                                 G_CALLBACK (handle_get_value),
+                                 settings,
+                                 0);
+        g_signal_connect_object (settings->priv->skeleton,
+                                 "handle-set-value",
+                                 G_CALLBACK (handle_set_value),
+                                 settings,
+                                 0);
+
+        g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (settings->priv->skeleton),
+                                          settings->priv->connection,
+                                          GDM_SETTINGS_DBUS_PATH,
+                                          NULL);
 
         return TRUE;
 }
@@ -184,8 +244,6 @@ gdm_settings_class_init (GdmSettingsClass *klass)
                               G_TYPE_STRING);
 
         g_type_class_add_private (klass, sizeof (GdmSettingsPrivate));
-
-        dbus_g_object_type_install_info (GDM_TYPE_SETTINGS, &dbus_glib_gdm_settings_object_info);
 }
 
 static void
@@ -196,13 +254,12 @@ backend_value_changed (GdmSettingsBackend *backend,
                        GdmSettings        *settings)
 {
         g_debug ("Emitting value-changed %s %s %s", key, old_value, new_value);
-        /* just proxy it */
-        g_signal_emit (settings,
-                       signals [VALUE_CHANGED],
-                       0,
-                       key,
-                       old_value,
-                       new_value);
+
+        /* proxy it to internal listeners */
+        g_signal_emit (settings, signals [VALUE_CHANGED], 0, key, old_value, new_value);
+
+        /* and to dbus */
+        gdm_dbus_settings_emit_value_changed (settings->priv->skeleton, key, old_value, new_value);
 }
 
 static void
diff --git a/common/test-settings-server.c b/common/test-settings-server.c
index a7fe791..bf7ab0e 100644
--- a/common/test-settings-server.c
+++ b/common/test-settings-server.c
@@ -30,10 +30,7 @@
 #include <locale.h>
 
 #include <glib.h>
-
-#define DBUS_API_SUBJECT_TO_CHANGE
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
+#include <gio/gio.h>
 
 #include "gdm-settings.h"
 
@@ -41,76 +38,14 @@
 
 static GdmSettings     *settings      = NULL;
 
-static gboolean
-acquire_name_on_proxy (DBusGProxy *bus_proxy)
-{
-        GError     *error;
-        guint       result;
-        gboolean    res;
-        gboolean    ret;
-
-        ret = FALSE;
-
-        if (bus_proxy == NULL) {
-                goto out;
-        }
-
-        error = NULL;
-        res = dbus_g_proxy_call (bus_proxy,
-                                 "RequestName",
-                                 &error,
-                                 G_TYPE_STRING, GDM_DBUS_NAME,
-                                 G_TYPE_UINT, 0,
-                                 G_TYPE_INVALID,
-                                 G_TYPE_UINT, &result,
-                                 G_TYPE_INVALID);
-        if (! res) {
-                if (error != NULL) {
-                        g_warning ("Failed to acquire %s: %s", GDM_DBUS_NAME, error->message);
-                        g_error_free (error);
-                } else {
-                        g_warning ("Failed to acquire %s", GDM_DBUS_NAME);
-                }
-                goto out;
-        }
-
-        if (result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
-                if (error != NULL) {
-                        g_warning ("Failed to acquire %s: %s", GDM_DBUS_NAME, error->message);
-                        g_error_free (error);
-                } else {
-                        g_warning ("Failed to acquire %s", GDM_DBUS_NAME);
-                }
-                goto out;
-        }
-
-        ret = TRUE;
-
- out:
-        return ret;
-}
-
-static DBusGProxy *
-get_bus_proxy (DBusGConnection *connection)
-{
-        DBusGProxy *bus_proxy;
-
-        bus_proxy = dbus_g_proxy_new_for_name (connection,
-                                               DBUS_SERVICE_DBUS,
-                                               DBUS_PATH_DBUS,
-                                               DBUS_INTERFACE_DBUS);
-        return bus_proxy;
-}
-
-static DBusGConnection *
+static GDBusConnection *
 get_system_bus (void)
 {
         GError          *error;
-        DBusGConnection *bus;
-        DBusConnection  *connection;
+        GDBusConnection *bus;
 
         error = NULL;
-        bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
+        bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
         if (bus == NULL) {
                 g_warning ("Couldn't connect to system bus: %s",
                            error->message);
@@ -118,19 +53,29 @@ get_system_bus (void)
                 goto out;
         }
 
-        connection = dbus_g_connection_get_connection (bus);
-        dbus_connection_set_exit_on_disconnect (connection, FALSE);
+        g_dbus_connection_set_exit_on_close (bus, FALSE);
 
  out:
         return bus;
 }
 
+static void
+on_name_acquired (GDBusConnection *connection,
+                  const char      *name,
+                  gpointer         user_data)
+{
+        settings = gdm_settings_new ();
+        if (settings == NULL) {
+                g_warning ("Unable to initialize settings");
+                exit (1);
+        }
+}
+
 int
 main (int argc, char **argv)
 {
         GMainLoop          *main_loop;
-        DBusGConnection    *connection;
-        DBusGProxy         *bus_proxy;
+        GDBusConnection    *connection;
 
         g_type_init ();
 
@@ -139,22 +84,13 @@ main (int argc, char **argv)
                 goto out;
         }
 
-        bus_proxy = get_bus_proxy (connection);
-        if (bus_proxy == NULL) {
-                g_warning ("Could not construct bus_proxy object; bailing out");
-                goto out;
-        }
-
-        if (! acquire_name_on_proxy (bus_proxy) ) {
-                g_warning ("Could not acquire name; bailing out");
-                goto out;
-        }
-
-        settings = gdm_settings_new ();
-        if (settings == NULL) {
-                g_warning ("Unable to initialize settings");
-                exit (1);
-        }
+        g_bus_own_name (G_BUS_TYPE_SYSTEM,
+                        GDM_DBUS_NAME,
+                        G_BUS_NAME_OWNER_FLAGS_NONE,
+                        NULL, /* bus acquired */
+                        on_name_acquired,
+                        NULL, /* name lost */
+                        NULL, NULL);
 
         main_loop = g_main_loop_new (NULL, FALSE);
         g_main_loop_run (main_loop);
diff --git a/configure.ac b/configure.ac
index b747e7a..8cd7577 100644
--- a/configure.ac
+++ b/configure.ac
@@ -83,6 +83,7 @@ PKG_CHECK_MODULES(COMMON,
         dbus-glib-1 >= $DBUS_GLIB_REQUIRED_VERSION
         gobject-2.0 >= $GLIB_REQUIRED_VERSION
         gio-2.0 >= $GLIB_REQUIRED_VERSION
+        gio-unix-2.0 >= $GLIB_REQUIRED_VERSION
 )
 AC_SUBST(COMMON_CFLAGS)
 AC_SUBST(COMMON_LIBS)
diff --git a/daemon/factory-slave-main.c b/daemon/factory-slave-main.c
index 2441260..6d3b133 100644
--- a/daemon/factory-slave-main.c
+++ b/daemon/factory-slave-main.c
@@ -34,10 +34,7 @@
 #include <glib.h>
 #include <glib/gi18n.h>
 #include <glib-object.h>
-
-#define DBUS_API_SUBJECT_TO_CHANGE
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
+#include <gio/gio.h>
 
 #include "gdm-xerrors.h"
 #include "gdm-signal-handler.h"
@@ -52,15 +49,14 @@
 static GdmSettings     *settings        = NULL;
 static int              gdm_return_code = 0;
 
-static DBusGConnection *
+static GDBusConnection *
 get_system_bus (void)
 {
         GError          *error;
-        DBusGConnection *bus;
-        DBusConnection  *connection;
+        GDBusConnection *bus;
 
         error = NULL;
-        bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
+        bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
         if (bus == NULL) {
                 g_warning ("Couldn't connect to system bus: %s",
                            error->message);
@@ -68,8 +64,7 @@ get_system_bus (void)
                 goto out;
         }
 
-        connection = dbus_g_connection_get_connection (bus);
-        dbus_connection_set_exit_on_disconnect (connection, FALSE);
+        g_dbus_connection_set_exit_on_close (bus, FALSE);
 
  out:
         return bus;
@@ -170,7 +165,7 @@ main (int    argc,
 {
         GMainLoop        *main_loop;
         GOptionContext   *context;
-        DBusGConnection  *connection;
+        GDBusConnection  *connection;
         GdmSlave         *slave;
         static char      *display_id = NULL;
         GdmSignalHandler *signal_handler;
@@ -259,8 +254,9 @@ main (int    argc,
         }
 
  out:
-
         g_debug ("Slave finished");
 
+        g_object_unref (connection);
+
         return gdm_return_code;
 }
diff --git a/daemon/simple-slave-main.c b/daemon/simple-slave-main.c
index 057492b..a1f5626 100644
--- a/daemon/simple-slave-main.c
+++ b/daemon/simple-slave-main.c
@@ -34,10 +34,7 @@
 #include <glib.h>
 #include <glib/gi18n.h>
 #include <glib-object.h>
-
-#define DBUS_API_SUBJECT_TO_CHANGE
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
+#include <gio/gio.h>
 
 #include "gdm-xerrors.h"
 #include "gdm-signal-handler.h"
@@ -52,15 +49,14 @@
 static GdmSettings     *settings        = NULL;
 static int              gdm_return_code = 0;
 
-static DBusGConnection *
+static GDBusConnection *
 get_system_bus (void)
 {
         GError          *error;
-        DBusGConnection *bus;
-        DBusConnection  *connection;
+        GDBusConnection *bus;
 
         error = NULL;
-        bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
+        bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
         if (bus == NULL) {
                 g_warning ("Couldn't connect to system bus: %s",
                            error->message);
@@ -68,8 +64,7 @@ get_system_bus (void)
                 goto out;
         }
 
-        connection = dbus_g_connection_get_connection (bus);
-        dbus_connection_set_exit_on_disconnect (connection, FALSE);
+        g_dbus_connection_set_exit_on_close (bus, FALSE);
 
  out:
         return bus;
@@ -174,7 +169,7 @@ main (int    argc,
 {
         GMainLoop        *main_loop;
         GOptionContext   *context;
-        DBusGConnection  *connection;
+        GDBusConnection  *connection;
         GdmSlave         *slave;
         static char      *display_id = NULL;
         GdmSignalHandler *signal_handler;
@@ -269,8 +264,9 @@ main (int    argc,
         g_main_loop_unref (main_loop);
 
  out:
-
         g_debug ("Slave finished");
 
+        g_object_unref (connection);
+
         return gdm_return_code;
 }
diff --git a/daemon/xdmcp-chooser-slave-main.c b/daemon/xdmcp-chooser-slave-main.c
index ea54210..135e38c 100644
--- a/daemon/xdmcp-chooser-slave-main.c
+++ b/daemon/xdmcp-chooser-slave-main.c
@@ -34,10 +34,7 @@
 #include <glib.h>
 #include <glib/gi18n.h>
 #include <glib-object.h>
-
-#define DBUS_API_SUBJECT_TO_CHANGE
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
+#include <gio/gio.h>
 
 #include "gdm-xerrors.h"
 #include "gdm-signal-handler.h"
@@ -52,15 +49,14 @@
 static GdmSettings     *settings        = NULL;
 static int              gdm_return_code = 0;
 
-static DBusGConnection *
+static GDBusConnection *
 get_system_bus (void)
 {
         GError          *error;
-        DBusGConnection *bus;
-        DBusConnection  *connection;
+        GDBusConnection *bus;
 
         error = NULL;
-        bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
+        bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
         if (bus == NULL) {
                 g_warning ("Couldn't connect to system bus: %s",
                            error->message);
@@ -68,8 +64,7 @@ get_system_bus (void)
                 goto out;
         }
 
-        connection = dbus_g_connection_get_connection (bus);
-        dbus_connection_set_exit_on_disconnect (connection, FALSE);
+        g_dbus_connection_set_exit_on_close (bus, FALSE);
 
  out:
         return bus;
@@ -176,7 +171,7 @@ main (int    argc,
 {
         GMainLoop        *main_loop;
         GOptionContext   *context;
-        DBusGConnection  *connection;
+        GDBusConnection  *connection;
         GdmSlave         *slave;
         static char      *display_id = NULL;
         GdmSignalHandler *signal_handler;
@@ -263,8 +258,9 @@ main (int    argc,
         g_main_loop_unref (main_loop);
 
  out:
-
         g_debug ("Slave finished");
 
+        g_object_unref (connection);
+
         return gdm_return_code;
 }



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