[gconf/gdbus: 3/3] Port gconf-defaults-mechanism to GDBus



commit 4cc6c280fe07fd89dfc0edfbd31f2fc3343bed5e
Author: Christian Persch <chpe gnome org>
Date:   Wed May 12 23:27:56 2010 +0200

    Port gconf-defaults-mechanism to GDBus
    
    untested

 configure.in                   |    7 +-
 defaults/Makefile.am           |   13 +-
 defaults/gconf-defaults-main.c |  198 +++++-----------
 defaults/gconf-defaults.c      |  521 ++++++++++++++++++++++++++--------------
 defaults/gconf-defaults.h      |   19 +-
 defaults/gconf-defaults.xml    |  110 ---------
 6 files changed, 413 insertions(+), 455 deletions(-)
---
diff --git a/configure.in b/configure.in
index 8460bec..7801af3 100644
--- a/configure.in
+++ b/configure.in
@@ -148,7 +148,6 @@ PKGCONFIG_MODULES='glib-2.0 > 2.14.0 gio-2.0 >= 2.25.4 gthread-2.0 gmodule-2.0 >
 PKGCONFIG_MODULES_WITH_XML="$PKGCONFIG_MODULES libxml-2.0"
 PKGCONFIG_MODULES_WITH_GTK=" $PKGCONFIG_MODULES gtk+-2.0 >= 2.14.0"
 PKGCONFIG_MODULES_WITH_XML_AND_GTK=" $PKGCONFIG_MODULES gtk+-2.0 libxml-2.0"
-PKGCONFIG_MODULES_DBUS=" dbus-1 >= 1.0.0 dbus-glib-1 >= 0.74"
 
 PKG_CHECK_MODULES(DEPENDENT, $PKGCONFIG_MODULES)
 PKG_CHECK_MODULES(DEPENDENT_WITH_XML, $PKGCONFIG_MODULES_WITH_XML)
@@ -168,8 +167,6 @@ else
   DEPENDENT_WITH_XML_AND_GTK_LIBS=$DEPENDENT_WITH_XML_LIBS
 fi
 
-PKG_CHECK_MODULES([DEPENDENT_DBUS],[$PKGCONFIG_MODULES_DBUS])
-
 AM_CONDITIONAL(GTK, [test "x$HAVE_GTK" != "xno"])
 
 AC_SUBST(DEPENDENT_LIBS)
@@ -180,8 +177,6 @@ AC_SUBST(DEPENDENT_WITH_GTK_LIBS)
 AC_SUBST(DEPENDENT_WITH_GTK_CFLAGS)
 AC_SUBST(DEPENDENT_WITH_XML_AND_GTK_LIBS)
 AC_SUBST(DEPENDENT_WITH_XML_AND_GTK_CFLAGS)
-AC_SUBST([DEPENDENT_DBUS_CFLAGS])
-AC_SUBST([DEPENDENT_DBUS_LIBS])
 
 HAVE_POLKIT=no
 AC_ARG_ENABLE(defaults_service,
@@ -190,7 +185,7 @@ AC_ARG_ENABLE(defaults_service,
   , enable_defaults_service=auto)
 
 if test "x$enable_defaults_service" != "xno" ; then
-  PKG_CHECK_MODULES(DEFAULTS, glib-2.0 gthread-2.0 gobject-2.0 dbus-1 dbus-glib-1 polkit-gobject-1, HAVE_POLKIT=yes, HAVE_POLKIT=no)
+  PKG_CHECK_MODULES(DEFAULTS, glib-2.0 gio-2.0 gthread-2.0 gobject-2.0 polkit-gobject-1, HAVE_POLKIT=yes, HAVE_POLKIT=no)
   if test "x$HAVE_POLKIT" = "xno"; then
     if test "x$enable_defaults_service" = "xyes" ; then
       AC_MSG_ERROR([[
diff --git a/defaults/Makefile.am b/defaults/Makefile.am
index f1db711..6a9563a 100644
--- a/defaults/Makefile.am
+++ b/defaults/Makefile.am
@@ -1,15 +1,8 @@
 libexec_PROGRAMS = gconf-defaults-mechanism
 
-gconf-defaults-glue.h: $(srcdir)/gconf-defaults.xml
-	dbus-binding-tool --prefix=gconf_defaults --mode=glib-server      \
-			  --output=gconf-defaults-glue.h                  \
-			  $(srcdir)/gconf-defaults.xml
-
-
 gconf_defaults_mechanism_SOURCES = \
 	gconf-defaults.h \
 	gconf-defaults.c \
-	gconf-defaults-glue.h \
 	gconf-defaults-main.c
 
 INCLUDES = \
@@ -22,8 +15,6 @@ gconf_defaults_mechanism_LDADD = \
 	$(top_builddir)/gconf/libgconf-2.la \
 	$(DEFAULTS_LIBS)
 
-BUILT_SOURCES = gconf-defaults-glue.h
-
 dbus_servicesdir = $(datadir)/dbus-1/system-services
 dbus_confdir = $(sysconfdir)/dbus-1/system.d
 polkitdir = $(datadir)/polkit-1/actions
@@ -44,8 +35,7 @@ polkit_DATA = $(polkit_in_files:.policy.in=.policy)
 EXTRA_DIST =					\
 	$(dbus_services_in_files)		\
 	org.gnome.GConf.Defaults.conf		\
-	$(polkit_in_files)			\
-	gconf-defaults.xml
+	$(polkit_in_files)
 
 CLEANFILES =			\
 	$(BUILT_SOURCES)	\
@@ -53,4 +43,3 @@ CLEANFILES =			\
 	$(dbus_services_DATA)
 
 DISTCLEANFILES = org.gnome.gconf.defaults.policy
-
diff --git a/defaults/gconf-defaults-main.c b/defaults/gconf-defaults-main.c
index 7ed7700..b09711e 100644
--- a/defaults/gconf-defaults-main.c
+++ b/defaults/gconf-defaults-main.c
@@ -1,6 +1,7 @@
 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
  *
  * Copyright (C) 2008 Matthias Clasen <mclasen redhat com>
+ * Copyright © 2010 Christian Persch
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -15,117 +16,23 @@
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
  */
 
 #include <config.h>
 
 #include <stdlib.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <signal.h>
-#include <errno.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
 
 #include <glib.h>
-#include <glib-object.h>
-
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
-
+#include <gio/gio.h>
 
 #include "gconf-defaults.h"
 
-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;
-}
-
 #define BUS_NAME "org.gnome.GConf.Defaults"
 
-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, BUS_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", BUS_NAME, error->message);
-                        g_error_free (error);
-                } else {
-                        g_warning ("Failed to acquire %s", BUS_NAME);
-                }
-                goto out;
-	}
-
- 	if (result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
-                if (error != NULL) {
-                        g_warning ("Failed to acquire %s: %s", BUS_NAME, error->message);
-                        g_error_free (error);
-                } else {
-                        g_warning ("Failed to acquire %s", BUS_NAME);
-                }
-                goto out;
-        }
-
-        ret = TRUE;
-
- out:
-        return ret;
-}
-
-static DBusGConnection *
-get_system_bus (void)
-{
-        GError          *error;
-        DBusGConnection *bus;
-        DBusConnection  *connection;
-
-        error = NULL;
-        bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
-        if (bus == NULL) {
-                g_warning ("Couldn't connect to system bus: %s", error->message);
-                g_error_free (error);
-                goto out;
-        }
-
-        connection = dbus_g_connection_get_connection (bus);
- out:
-        return bus;
-}
-
 extern gboolean disable_killtimer;
-gboolean debug = FALSE;
+static gboolean debug = FALSE;
 
-GOptionEntry entries [] = {
+static const GOptionEntry entries [] = {
 	{ "debug", 0, 0, G_OPTION_ARG_NONE, &debug, "Emit debug output", NULL },
 	{ "no-kill", 0, 0, G_OPTION_ARG_NONE, &disable_killtimer, "Don't exit when idle", NULL },
 	{ NULL, }
@@ -133,7 +40,7 @@ GOptionEntry entries [] = {
 
 static gint log_levels = (G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING);
 
-void
+static void
 log_default_handler (const gchar   *log_domain,
                      GLogLevelFlags log_level,
                      const gchar   *message,
@@ -144,31 +51,59 @@ log_default_handler (const gchar   *log_domain,
 	}
 }
 
+static GMainLoop *loop = NULL;
+static GConfDefaults *mechanism = NULL;
+
+static void
+bus_acquired_cb (GDBusConnection *connection,
+                 const gchar     *name,
+                 gpointer         user_data)
+{
+        mechanism = gconf_defaults_new (connection);
+        if (mechanism == NULL && g_main_loop_is_running (loop))
+                g_main_loop_quit (loop);
+}
+
+static void
+name_acquired_cb (GDBusConnection *connection,
+                  const gchar     *name,
+                  gpointer         user_data)
+{
+        g_debug ("Name '%s' acquired\n", name);
+}
+
+static void
+name_lost_cb (GDBusConnection *connection,
+              const gchar     *name,
+              gpointer         user_data)
+{
+        g_debug ("Name '%s' lost \n", name);
+
+        if (mechanism) {
+                g_object_unref (mechanism);
+                mechanism = NULL;
+        }
+
+        if (g_main_loop_is_running (loop))
+                g_main_loop_quit (loop);
+}
 
 int
 main (int argc, char **argv)
 {
-        GMainLoop           *loop;
-        GConfDefaults       *mechanism;
-        DBusGProxy          *bus_proxy;
-        DBusGConnection     *connection;
-        int                  ret;
-	GOptionContext      *options;
-	GError              *error = NULL;
-
-        ret = 1;
-
-        if (! g_thread_supported ()) {
-                g_thread_init (NULL);
-        }
-        dbus_g_thread_init ();
+        GOptionContext *options;
+        guint           owner_id;
+        GError         *error = NULL;
+
         g_type_init ();
 
 	options = g_option_context_new (NULL);
 	g_option_context_add_main_entries (options, entries, NULL);
 	if (!g_option_context_parse (options, &argc, &argv, &error)) {
-		g_warning ("Failed to parse options: %s\n", error->message);
+		g_printerr ("Failed to parse options: %s\n", error->message);
 		g_error_free (error);
+                g_option_context_free (options);
+                return 1;
 	}
 	g_option_context_free (options);
 
@@ -177,37 +112,20 @@ main (int argc, char **argv)
 		log_levels = log_levels | G_LOG_LEVEL_DEBUG;
 	}
 
-        connection = get_system_bus ();
-        if (connection == NULL) {
-                g_warning ("Could not get system bus connection; bailing out");
-                goto out;
-        }
-
-        bus_proxy = get_bus_proxy (connection);
-        if (bus_proxy == NULL) {
-                g_warning ("Could not construct bus_proxy object; bailing out");
-                goto out;
-        }
-
-        mechanism = gconf_defaults_new ();
-
-        if (mechanism == NULL) {
-                goto out;
-        }
-
-        if (!acquire_name_on_proxy (bus_proxy)) {
-                g_warning ("Could not acquire name; bailing out");
-                goto out;
-        }
-
         loop = g_main_loop_new (NULL, FALSE);
 
+        owner_id = g_bus_own_name (G_BUS_TYPE_STARTER,
+                                   BUS_NAME,
+                                   G_BUS_NAME_OWNER_FLAGS_NONE,
+                                   bus_acquired_cb,
+                                   name_acquired_cb,
+                                   name_lost_cb,
+                                   NULL, NULL);
+
         g_main_loop_run (loop);
 
-        g_object_unref (mechanism);
+        g_bus_unown_name (owner_id);
         g_main_loop_unref (loop);
-        ret = 0;
 
-out:
-        return ret;
+        return 0;
 }
diff --git a/defaults/gconf-defaults.c b/defaults/gconf-defaults.c
index b84c632..4faf6e7 100644
--- a/defaults/gconf-defaults.c
+++ b/defaults/gconf-defaults.c
@@ -1,6 +1,7 @@
 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
  *
  * Copyright (C) 2008, 2009 Matthias Clasen <mclasen redhat com>
+ * Copyright © 2010 Christian Persch
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -32,10 +33,7 @@
 #include <pwd.h>
 
 #include <glib.h>
-#include <glib-object.h>
-
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
+#include <gio/gio.h>
 
 #include <polkit/polkit.h>
 
@@ -44,7 +42,113 @@
 #include <gconf/gconf-engine.h>
 
 #include "gconf-defaults.h"
-#include "gconf-defaults-glue.h"
+
+static const char introspection_xml[] =
+  "<node name='/'>"
+    "<interface name='org.gnome.GConf.Defaults'>"
+#if 0
+      "<!--"
+        "includes: an array of GConf paths to copy from the"
+        "callers GConf database to the system database"
+        "excludes: an array of GConf paths to omit"
+
+        "Copies values from the callers GConf database to the system-wide"
+        "database. The subtree below each included path is copied recursively,"
+        "skipping the excluded subtrees."
+        "To decide which PolicyKit privilege to require for the copying of"
+        "each path in includes, the mechanism looks for a privilege with an"
+        "annotation with key org.gnome.gconf.defaults.set-system.prefix whose"
+        "value is a prefix of the path. If no privilege is found this way, the"
+        "org.gnome.gconf.defaults.set-system privilege is required."
+        "-->"
+#endif
+      "<method name='SetSystem'>"
+        "<arg name='includes' direction='in' type='as'/>"
+        "<arg name='excludes' direction='in' type='as'/>"
+      "</method>"
+#if 0
+      "<!--"
+        "path: a path to a gconf key"
+        "value: a value, as encoded by gconf_value_encode"
+
+        "Sets the key at path to value in the system-wide database."
+        "To decide which PolicyKit privilege to require for the copying of"
+        "each path in includes, the mechanism looks for a privilege with an"
+        "annotation with key org.gnome.gconf.defaults.set-system.prefix whose"
+        "value is a prefix of the path. If no privilege is found this way, the"
+        "org.gnome.gconf.defaults.set-system privilege is required."
+        "-->"
+#endif
+      "<method name='SetSystemValue'>"
+        "<arg name='path'  direction='in' type='s'/>"
+        "<arg name='value' direction='in' type='s'/>"
+      "</method>"
+      "<method name='CanSetSystem'>"
+        "<arg name='includes' direction='in' type='as'/>"
+        "<arg name='result' direction='out' type='u'/>"
+      "</method>"
+      "<signal name='SystemSet'>"
+        "<arg name='keys' type='as'/>"
+      "</signal>"
+#if 0
+      "<!--"
+        "includes: an array of GConf paths to copy from the"
+        "callers GConf database to the mandatory database"
+        "excludes: an array of GConf paths to omit"
+
+        "Copies values from the callers GConf database to the system-wide"
+        "mandatory database. The subtree below each included path is copied"
+        "recursively, skipping the excluded subtrees."
+        "To decide which PolicyKit privilege to require for the copying of"
+        "each path in includes, the mechanism looks for a privilege with an"
+        "annotation with key org.gnome.gconf.defaults.set-mandatory.prefix whose"
+        "value is a prefix of the path. If no privilege is found this way, the"
+        "org.gnome.gconf.defaults.set-mandatory privilege is required."
+        "-->"
+#endif
+      "<method name='SetMandatory'>"
+        "<arg name='includes' direction='in' type='as'/>"
+        "<arg name='excludes' direction='in' type='as'/>"
+      "</method>"
+#if 0
+      "<!--"
+        "path: a path to a gconf key"
+        "value: a value, as encoded by gconf_value_encode"
+
+        "Sets the key at path to value in the system-wide mandatory database."
+        "To decide which PolicyKit privilege to require for the copying of"
+        "each path in includes, the mechanism looks for a privilege with an"
+        "annotation with key org.gnome.gconf.defaults.set-mandatory.prefix whose"
+        "value is a prefix of the path. If no privilege is found this way, the"
+        "org.gnome.gconf.defaults.set-mandatory privilege is required."
+        "-->"
+#endif
+      "<method name='SetMandatoryValue'>"
+        "<arg name='path'  direction='in' type='s'/>"
+        "<arg name='value' direction='in' type='s'/>"
+      "</method>"
+#if 0
+      "<!--"
+        "Unsets keys in the system-wide mandatory GConf database, making the"
+        "keys writable again. The subtree below each included path is copied"
+        "recursively, skipping the excluded subtrees."
+        "To decide which PolicyKit privilege to require for the copying of"
+        "each path in includes, the mechanism looks for a privilege with an"
+        "annotation with key org.gnome.gconf.defaults.set-mandatory.prefix whose"
+        "value is a prefix of the path. If no privilege is found this way, the"
+        "org.gnome.gconf.defaults.set-mandatory privilege is required."
+        "-->"
+#endif
+      "<method name='UnsetMandatory'>"
+        "<arg name='includes' direction='in' type='as'/>"
+        "<arg name='excludes' direction='in' type='as'/>"
+      "</method>"
+      "<method name='CanSetMandatory'>"
+        "<arg name='includes' direction='in' type='as'/>"
+        "<arg name='result' direction='out' type='u'/>"
+      "</method>"
+    "</interface>"
+  "</node>";
 
 static gboolean
 do_exit (gpointer user_data)
@@ -101,9 +205,9 @@ stop_operation (void)
 
 struct GConfDefaultsPrivate
 {
-        DBusGConnection *system_bus_connection;
-        DBusGProxy      *system_bus_proxy;
+        GDBusConnection  *system_bus_connection;
         PolkitAuthority *auth;
+        guint registration_id;
 };
 
 static void gconf_defaults_finalize (GObject *object);
@@ -115,16 +219,24 @@ G_DEFINE_TYPE (GConfDefaults, gconf_defaults, G_TYPE_OBJECT)
 GQuark
 gconf_defaults_error_quark (void)
 {
-        static GQuark ret = 0;
-
-        if (ret == 0) {
-                ret = g_quark_from_static_string ("gconf_defaults_error");
+        static volatile gsize quark_volatile = 0;
+
+        if (quark_volatile == 0) {
+                static const GDBusErrorEntry error_entries[] =
+                {
+                        { GCONF_DEFAULTS_ERROR_GENERAL,        "org.gnome.GConf.Defaults.Error.GeneralError"  },
+                        { GCONF_DEFAULTS_ERROR_NOT_PRIVILEGED, "org.gnome.GConf.Defaults.Error.NotPrivileged" }
+                };
+           
+                g_dbus_error_register_error_domain ("gconf-defaults-error-quark",
+                                                    &quark_volatile,
+                                                    error_entries,
+                                                    G_N_ELEMENTS (error_entries));
         }
 
-        return ret;
+        return (GQuark) quark_volatile;
 }
 
-
 #define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC }
 
 GType
@@ -168,12 +280,72 @@ gconf_defaults_constructor (GType                  type,
         return G_OBJECT (mechanism);
 }
 
-enum {
-	SYSTEM_SET,
-	LAST_SIGNAL
-};
+static void
+method_call_cb (GDBusConnection       *connection,
+                const gchar           *sender,
+                const gchar           *object_path,
+                const gchar           *interface_name,
+                const gchar           *method_name,
+                GVariant              *parameters,
+                GDBusMethodInvocation *invocation,
+                gpointer               user_data)
+{
+        GConfDefaults *mechanism = GCONF_DEFAULTS (user_data);
+
+        if (g_strcmp0 (interface_name, "org.gnome.GConf.Defaults") != 0)
+                return;
+
+        if (g_strcmp0 (method_name, "SetSystem") == 0) {
+                char **includes, **excludes;
+
+                g_variant_get (parameters, "(^a&s^a&s)", &includes, &excludes);
+                gconf_defaults_set_system (mechanism, (const char **) includes, (const char**) excludes, invocation);
+                g_free (includes);
+                g_free (excludes);
+        } else if (g_strcmp0 (method_name, "SetSystemValue") == 0) {
+                const char *path, *value;
+
+                g_variant_get (parameters, "(&s&s)", &path, &value);
+                gconf_defaults_set_system_value (mechanism, path, value, invocation);
+        } else if (g_strcmp0 (method_name, "CanSetSystem") == 0) {
+                char **includes;
+
+                g_variant_get (parameters, "(^a&s)", &includes);
+                gconf_defaults_can_set_system (mechanism, (const char **) includes, invocation);
+                g_free (includes);
+        } else if (g_strcmp0 (method_name, "SetMandatory") == 0) {
+                char **includes, **excludes;
+
+                g_variant_get (parameters, "(^a&s^a&s)", &includes, &excludes);
+                gconf_defaults_set_mandatory (mechanism, (const char **) includes, (const char**) excludes, invocation);
+                g_free (includes);
+                g_free (excludes);
+        } else if (g_strcmp0 (method_name, "UnsetMandatory") == 0) {
+                char **includes, **excludes;
+
+                g_variant_get (parameters, "(^a&s^a&s)", &includes, &excludes);
+                gconf_defaults_unset_mandatory (mechanism, (const char **) includes, (const char**) excludes, invocation);
+                g_free (includes);
+                g_free (excludes);
+        } else if (g_strcmp0 (method_name, "SetMandatoryValue") == 0) {
+                const char *path, *value;
+
+                g_variant_get (parameters, "(&s&s)", &path, &value);
+                gconf_defaults_set_mandatory_value (mechanism, path, value, invocation);
+        } else if (g_strcmp0 (method_name, "CanSetMandatory") == 0) {
+                char **includes;
+
+                g_variant_get (parameters, "(^a&s)", &includes);
+                gconf_defaults_can_set_mandatory (mechanism, (const char **) includes, invocation);
+                g_free (includes);
+        }
+}
 
-static guint signals[LAST_SIGNAL] = { 0 };
+static const GDBusInterfaceVTable interface_vtable = {
+        method_call_cb,
+        NULL,
+        NULL
+};
 
 static void
 gconf_defaults_class_init (GConfDefaultsClass *klass)
@@ -183,20 +355,7 @@ gconf_defaults_class_init (GConfDefaultsClass *klass)
         object_class->constructor = gconf_defaults_constructor;
         object_class->finalize = gconf_defaults_finalize;
 
-	signals[SYSTEM_SET] = g_signal_new ("system-set",
-					    G_OBJECT_CLASS_TYPE (object_class),
-					    G_SIGNAL_RUN_FIRST,
-					    G_STRUCT_OFFSET (GConfDefaultsClass, system_set),
-					    NULL, NULL,
-					    g_cclosure_marshal_VOID__BOXED,
-					    G_TYPE_NONE, 1, G_TYPE_STRV);
- 
         g_type_class_add_private (klass, sizeof (GConfDefaultsPrivate));
-
-        dbus_g_object_type_install_info (GCONF_TYPE_DEFAULTS, &dbus_glib_gconf_defaults_object_info);
-
-        dbus_g_error_domain_register (GCONF_DEFAULTS_ERROR, NULL, GCONF_DEFAULTS_TYPE_ERROR);
-
 }
 
 static void
@@ -208,64 +367,63 @@ gconf_defaults_init (GConfDefaults *mechanism)
 static void
 gconf_defaults_finalize (GObject *object)
 {
-        GConfDefaults *mechanism;
-
-        g_return_if_fail (object != NULL);
-        g_return_if_fail (GCONF_IS_DEFAULTS (object));
-
-        mechanism = GCONF_DEFAULTS (object);
+        GConfDefaults *mechanism = GCONF_DEFAULTS (object);
+        GConfDefaultsPrivate *priv = mechanism->priv;
 
-        g_return_if_fail (mechanism->priv != NULL);
+        if (priv->registration_id != 0) {
+                g_dbus_connection_unregister_object (priv->system_bus_connection, priv->registration_id);
+        }
 
-	g_object_unref (mechanism->priv->auth);
-        g_object_unref (mechanism->priv->system_bus_proxy);
+	g_object_unref (priv->auth);
+        g_object_unref (priv->system_bus_connection);
 
         G_OBJECT_CLASS (gconf_defaults_parent_class)->finalize (object);
 }
 
 static gboolean
-register_mechanism (GConfDefaults *mechanism)
+register_mechanism (GConfDefaults *mechanism,
+                    GDBusConnection *connection)
 {
+        GConfDefaultsPrivate *priv = mechanism->priv;
+        GDBusNodeInfo *introspection_data;
+        guint registration_id;
         GError *error = NULL;
 
-        mechanism->priv->auth = polkit_authority_get ();
-
-        error = NULL;
-        mechanism->priv->system_bus_connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
-        if (mechanism->priv->system_bus_connection == NULL) {
-                if (error != NULL) {
-                        g_critical ("error getting system bus: %s", error->message);
-                        g_error_free (error);
-                }
-                goto error;
+        priv->auth = polkit_authority_get ();
+        priv->system_bus_connection = g_object_ref (connection);
+
+        introspection_data = g_dbus_node_info_new_for_xml (introspection_xml, NULL);
+        g_assert (introspection_data != NULL);
+
+        priv->registration_id = g_dbus_connection_register_object
+                                    (connection,
+                                     "/",
+                                     "org.gnome.GConf.Defaults",
+                                     introspection_data->interfaces[0],
+                                     &interface_vtable,
+                                     mechanism,
+                                     (GDestroyNotify) g_object_unref,
+                                     &error);
+        if (priv->registration_id == 0) {
+                g_warning ("Failed to register object: %s", error->message);
+                g_error_free (error);
+                return FALSE;
         }
 
-        dbus_g_connection_register_g_object (mechanism->priv->system_bus_connection, "/",
-                                             G_OBJECT (mechanism));
-
-        mechanism->priv->system_bus_proxy = dbus_g_proxy_new_for_name (mechanism->priv->system_bus_connection,
-                                                                      DBUS_SERVICE_DBUS,
-                                                                      DBUS_PATH_DBUS,
-                                                                      DBUS_INTERFACE_DBUS);
-
         start_killtimer ();
 
         return TRUE;
-
-error:
-        return FALSE;
 }
 
-
 GConfDefaults *
-gconf_defaults_new (void)
+gconf_defaults_new (GDBusConnection *connection)
 {
         GObject *object;
         gboolean res;
 
         object = g_object_new (GCONF_TYPE_DEFAULTS, NULL);
 
-        res = register_mechanism (GCONF_DEFAULTS (object));
+        res = register_mechanism (GCONF_DEFAULTS (object), connection);
         if (! res) {
                 g_object_unref (object);
                 return NULL;
@@ -316,36 +474,14 @@ polkit_action_for_gconf_path (GConfDefaults *mechanism,
 	return action;
 }
 
-static void
-throw_error (DBusGMethodInvocation *context,
-             gint                   error_code,
-             const gchar           *format,
-             ...)
-{
-	GError *error;
-	va_list args;
-	gchar *message;
-
-	va_start (args, format);
-	message = g_strdup_vprintf (format, args);
-	va_end (args);
-
-	error = g_error_new (GCONF_DEFAULTS_ERROR,
-			     error_code,
-			     "%s", message);
-	dbus_g_method_return_error (context, error);
-	g_error_free (error);
-	g_free (message);
-}
-
 typedef void (*AuthObtainedCallback) (GConfDefaults          *mechanism,
-                                      DBusGMethodInvocation  *context,
+                                      GDBusMethodInvocation  *context,
                                       gpointer                user_data);
 
 typedef struct
 {
 	GConfDefaults                   *mechanism;
-	DBusGMethodInvocation           *context;
+	GDBusMethodInvocation           *context;
 	gchar                          **actions;
 	gint				 id;
 	gint				 flags;
@@ -365,6 +501,7 @@ check_auth_data_free (CheckAuthData *data)
 	if (data->destroy)
 		data->destroy (data->user_data);
         g_object_unref (data->subject);
+        g_object_unref (data->context);
 	g_free (data);
 }
 
@@ -388,9 +525,10 @@ check_authorization_callback (PolkitAuthority *authority,
 							      &error);
 	if (error != NULL) {
 		g_debug ("error checking action '%s'\n", error->message);
-		throw_error (data->context,
-                             GCONF_DEFAULTS_ERROR_NOT_PRIVILEGED,
-                             "Not Authorized: %s", error->message);
+                g_dbus_method_invocation_return_error (data->context,
+                                                       GCONF_DEFAULTS_ERROR,
+                                                       GCONF_DEFAULTS_ERROR_NOT_PRIVILEGED,
+                                                       "Not Authorized: %s", error->message);
 		g_error_free (error);
 	}
 	else {
@@ -402,16 +540,18 @@ check_authorization_callback (PolkitAuthority *authority,
 		else if (polkit_authorization_result_get_is_challenge (result)) {
 			g_debug ("result for '%s': challenge\n",
 				 data->actions[data->id]);
-			throw_error (data->context,
-                                     GCONF_DEFAULTS_ERROR_NOT_PRIVILEGED,
-                                     "Authorization is required");
+                        g_dbus_method_invocation_return_error_literal (data->context,
+                                                                       GCONF_DEFAULTS_ERROR,
+                                                                       GCONF_DEFAULTS_ERROR_NOT_PRIVILEGED,
+                                                                       "Authorization is required");
 		}
 		else {
 			g_debug ("result for '%s': not authorized\n",
 				 data->actions[data->id]);
-			throw_error (data->context,
-                                     GCONF_DEFAULTS_ERROR_NOT_PRIVILEGED,
-                                     "Not Authorized");
+                        g_dbus_method_invocation_return_error_literal (data->context,
+                                                                       GCONF_DEFAULTS_ERROR,
+                                                                       GCONF_DEFAULTS_ERROR_NOT_PRIVILEGED,
+                                                                       "Not Authorized");
 		}
 	}
 
@@ -448,7 +588,7 @@ check_next_action (CheckAuthData *data)
 
 static void
 check_polkit_for_actions (GConfDefaults                   *mechanism,
-                          DBusGMethodInvocation           *context,
+                          GDBusMethodInvocation           *context,
                           gchar                          **actions,
                           AuthObtainedCallback             auth_obtained_callback,
                           gpointer                         user_data,
@@ -458,7 +598,7 @@ check_polkit_for_actions (GConfDefaults                   *mechanism,
 
 	data = g_new0 (CheckAuthData, 1);
 	data->mechanism = g_object_ref (mechanism);
-	data->context = context;
+	data->context = g_object_ref (context);
 	data->actions = actions;
         data->flags = POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION;
 	data->id = 0;
@@ -466,7 +606,7 @@ check_polkit_for_actions (GConfDefaults                   *mechanism,
 	data->check_auth_callback = (GAsyncReadyCallback)check_authorization_callback;
 	data->user_data = user_data;
 	data->destroy = destroy;
-	data->subject = polkit_system_bus_name_new (dbus_g_method_get_sender (context));
+	data->subject = polkit_system_bus_name_new (g_dbus_method_invocation_get_sender (context));
 	data->challenge = FALSE;
 
 	check_next_action (data);
@@ -474,33 +614,39 @@ check_polkit_for_actions (GConfDefaults                   *mechanism,
 
 static char *
 gconf_address_for_caller (GConfDefaults          *mechanism,
-			  DBusGMethodInvocation  *context,
-			  GError                **gerror)
+			  GDBusMethodInvocation  *context)
 {
-        char *sender;
-	DBusConnection *conn;
+        GDBusConnection *connection;
+        GCredentials *credentials;
 	uid_t uid;
 	struct passwd *pwd;
 	char *result;
-	DBusError error;
+        GError *error = NULL;
 
-	conn = dbus_g_connection_get_connection (mechanism->priv->system_bus_connection);
-        sender = dbus_g_method_get_sender (context);
+        connection = g_dbus_method_invocation_get_connection (context);
+        credentials = g_dbus_connection_get_peer_credentials (connection);
+        if (credentials == NULL) {
+                g_dbus_method_invocation_return_error_literal (context,
+                                                               GCONF_DEFAULTS_ERROR,
+                                                               GCONF_DEFAULTS_ERROR_GENERAL,
+                                                               "Failed to get credentials");
+                return NULL;
+        }
 
-	dbus_error_init (&error);
-	uid = dbus_bus_get_unix_user (conn, sender, &error);
-	g_free (sender);
-	if (uid == (unsigned)-1) {
-		dbus_set_g_error (gerror, &error);
-		dbus_error_free (&error);
-		return NULL;
-	}
+        uid = g_credentials_get_unix_user (credentials, &error);
+        g_object_unref (credentials);
+        if (error) {
+                g_dbus_method_invocation_return_gerror (context, error);
+                g_error_free (error);
+                return NULL;
+        }
 
 	pwd = getpwuid (uid);
 	if (pwd == NULL) {
-		g_set_error (gerror,
-			     0, 0,
-			     "Failed to get passwd information for uid %d", uid);
+                g_dbus_method_invocation_return_error (context,
+                                                       GCONF_DEFAULTS_ERROR,
+                                                       GCONF_DEFAULTS_ERROR_GENERAL,
+                                                       "Failed to get passwd information for uid %d", (int) uid);
 		return NULL;
 	}
 
@@ -575,7 +721,7 @@ typedef void (*ChangeSetCallback) (GConfDefaults  *mechanism,
 typedef struct
 {
 	GConfDefaults                   *mechanism;
-	DBusGMethodInvocation           *context;
+	GDBusMethodInvocation           *context;
 	const char 			*dest_address;
 	char 			       **actions;
 	char            	       **includes;
@@ -599,12 +745,13 @@ copy_data_free (gpointer user_data)
 		gconf_value_free (data->value);
 	if (data->destroy)
 		data->destroy (data->user_data);
+        g_object_unref (data->context);
 	g_free (data);
 }
 
 static void
 do_copy_authorized (GConfDefaults          *mechanism,
-                    DBusGMethodInvocation  *context,
+                    GDBusMethodInvocation  *context,
 		    gpointer                user_data)
 {
         CopyData    *data = user_data;
@@ -616,6 +763,11 @@ do_copy_authorized (GConfDefaults          *mechanism,
         gint i;
 	GError *error;
 
+	/* find the address to from the caller id */
+        address = gconf_address_for_caller (data->mechanism, data->context);
+        if (address == NULL)
+                return;
+
 	error = NULL;
 	engine = gconf_engine_get_local (data->dest_address, &error);
 	if (error)
@@ -624,11 +776,6 @@ do_copy_authorized (GConfDefaults          *mechanism,
 	dest = gconf_client_get_for_engine (engine);
 	gconf_engine_unref (engine);
 
-	/* find the address to from the caller id */
-        address = gconf_address_for_caller (data->mechanism, data->context, &error);
-	if (error)
-		goto cleanup;
-
 	engine = gconf_engine_get_local (address, &error);
 	if (error)
 		goto cleanup;
@@ -671,17 +818,18 @@ cleanup:
 		g_object_unref (source);
 
 	if (error) {
-		throw_error (data->context,
-			     GCONF_DEFAULTS_ERROR_GENERAL,
-			     "%s", error->message);
+                g_dbus_method_invocation_return_error_literal (data->context,
+                                                               GCONF_DEFAULTS_ERROR,
+                                                               GCONF_DEFAULTS_ERROR_GENERAL,
+                                                               error->message);
 		g_error_free (error);
 	}
 	else
-        	dbus_g_method_return (data->context);
+        	g_dbus_method_invocation_return_value (data->context, NULL);
 }
 
 typedef void (*ActionsReadyCallback) (GConfDefaults          *mechanism,
-				      DBusGMethodInvocation  *context,
+				      GDBusMethodInvocation  *context,
 				      gchar                 **actions,
                           	      AuthObtainedCallback    auth_obtained_callback,
 				      gpointer                data,
@@ -690,7 +838,7 @@ typedef void (*ActionsReadyCallback) (GConfDefaults          *mechanism,
 typedef struct
 {
 	GConfDefaults 			*mechanism;
-	DBusGMethodInvocation           *context;
+	GDBusMethodInvocation           *context;
 	char                           **includes;
 	const char			*default_action;
 	const char			*annotation_key;
@@ -707,6 +855,7 @@ action_data_free (ActionData *data)
 	g_strfreev (data->includes);
 	if (data->destroy)
 		data->destroy (data->data);
+        g_object_unref (data->context);
 	g_free (data);
 }
 
@@ -728,9 +877,10 @@ actions_ready_cb (GObject      *source,
 	action_descriptions = polkit_authority_enumerate_actions_finish (data->mechanism->priv->auth, res, &error);
 
 	if (error) {
-		throw_error (data->context,
-                             GCONF_DEFAULTS_ERROR_GENERAL,
-                             "Failed to get action descriptions: %s", error->message);
+                g_dbus_method_invocation_return_error (data->context,
+                                                       GCONF_DEFAULTS_ERROR,
+                                                       GCONF_DEFAULTS_ERROR_GENERAL,
+                                                       "Failed to get action descriptions: %s", error->message);
 		g_error_free (error);
 		action_data_free (data);
 		stop_operation ();
@@ -772,7 +922,7 @@ do_copy (GConfDefaults          *mechanism,
 	 const gchar           **includes,
 	 const gchar           **excludes,
 	 GConfValue             *value,
-	 DBusGMethodInvocation  *context,
+	 GDBusMethodInvocation  *context,
 	 ChangeSetCallback       changeset_callback,
 	 gpointer                user_data,
          GDestroyNotify          destroy)
@@ -784,7 +934,7 @@ do_copy (GConfDefaults          *mechanism,
 
 	cdata = g_new0 (CopyData, 1);
 	cdata->mechanism = g_object_ref (mechanism);
-	cdata->context = context;
+	cdata->context = g_object_ref (context);
 	cdata->includes = g_strdupv ((gchar **)includes);
 	cdata->excludes = g_strdupv ((gchar **)excludes);
         cdata->value = value;
@@ -795,7 +945,7 @@ do_copy (GConfDefaults          *mechanism,
 
 	adata = g_new0 (ActionData, 1);
 	adata->mechanism = g_object_ref (mechanism);
-	adata->context = context;
+	adata->context = g_object_ref (context);
 	adata->includes = g_strdupv ((gchar **)includes);
 	adata->actions_ready_callback = check_polkit_for_actions;
 	adata->auth_obtained_callback = do_copy_authorized;
@@ -826,9 +976,9 @@ append_key (GConfChangeSet *cs,
 	    GConfValue *value,
 	    gpointer user_data)
 {
-	GPtrArray *keys = (GPtrArray *) user_data;
+	GVariantBuilder *builder = (GVariantBuilder *) user_data;
 
-	g_ptr_array_add (keys, (gpointer) key);
+        g_variant_builder_add (builder, "s", key);
 }
 
 static void
@@ -836,22 +986,26 @@ set_system_changes (GConfDefaults  *mechanism,
 		    GConfChangeSet *changes,
                     gpointer        data)
 {
-	GPtrArray *keys;
-
-	keys = g_ptr_array_new ();
-	gconf_change_set_foreach (changes, append_key, keys);
-	g_ptr_array_add (keys, NULL);
-
-	g_signal_emit (mechanism, signals[SYSTEM_SET], 0, keys->pdata);
-
-	g_ptr_array_free (keys, TRUE);
+        GConfDefaultsPrivate *priv = mechanism->priv;
+	GVariantBuilder builder;
+
+	g_variant_builder_init (&builder, G_VARIANT_TYPE ("as"));
+	gconf_change_set_foreach (changes, append_key, &builder);
+
+        g_dbus_connection_emit_signal (priv->system_bus_connection,
+                                       NULL /* FIXME? */,
+                                       "/",
+                                       "org.gnome.GConf.Defaults",
+                                       "SystemSet",
+                                       g_variant_builder_end (&builder),
+                                       NULL);
 }
 
 void
 gconf_defaults_set_system (GConfDefaults          *mechanism,
 			   const char            **includes,
 			   const char            **excludes,
-			   DBusGMethodInvocation  *context)
+			   GDBusMethodInvocation  *context)
 {
 	do_copy (mechanism, FALSE, includes, excludes, NULL, context, set_system_changes, NULL, NULL);
 }
@@ -860,7 +1014,7 @@ void
 gconf_defaults_set_mandatory (GConfDefaults          *mechanism,
                               const char            **includes,
                               const char            **excludes,
-                              DBusGMethodInvocation  *context)
+                              GDBusMethodInvocation  *context)
 {
 	do_copy (mechanism, TRUE, includes, excludes, NULL, context, NULL, NULL, NULL);
 }
@@ -947,7 +1101,7 @@ out:
 typedef struct
 {
 	GConfDefaults          *mechanism;
-        DBusGMethodInvocation  *context;
+        GDBusMethodInvocation  *context;
         char                  **includes;
         char                  **excludes;
 } UnsetData;
@@ -960,12 +1114,13 @@ unset_data_free (gpointer user_data)
 	g_object_unref (data->mechanism);
 	g_strfreev (data->includes);
 	g_strfreev (data->excludes);
+        g_object_unref (data->context);
 	g_free (data);
 }
 
 static void
 do_unset_authorized (GConfDefaults          *mechanism,
-                     DBusGMethodInvocation  *context,
+                     GDBusMethodInvocation  *context,
 		     gpointer 		     user_data)
 {
         UnsetData *data = user_data;
@@ -977,21 +1132,21 @@ do_unset_authorized (GConfDefaults          *mechanism,
 		     (const gchar **)data->excludes, &error);
 
 	if (error) {
-		throw_error (data->context,
-			     GCONF_DEFAULTS_ERROR,
-			     GCONF_DEFAULTS_ERROR_GENERAL,
-			     "%s", error->message);
+                g_dbus_method_invocation_return_error_literal (data->context,
+                                                               GCONF_DEFAULTS_ERROR,
+                                                               GCONF_DEFAULTS_ERROR_GENERAL,
+                                                               error->message);
 		g_error_free (error);
 	}
 	else
-        	dbus_g_method_return (data->context);
+        	g_dbus_method_invocation_return_value (data->context, NULL);
 }
 
 void
 gconf_defaults_unset_mandatory (GConfDefaults          *mechanism,
                                 const char            **includes,
                                 const char            **excludes,
-                                DBusGMethodInvocation  *context)
+                                GDBusMethodInvocation  *context)
 {
 	UnsetData *udata;
 	ActionData *adata;
@@ -1000,13 +1155,13 @@ gconf_defaults_unset_mandatory (GConfDefaults          *mechanism,
 
 	udata = g_new0 (UnsetData, 1);
 	udata->mechanism = g_object_ref (mechanism);
-	udata->context = context;
+	udata->context = g_object_ref (context);
 	udata->includes = g_strdupv ((gchar **)includes);
 	udata->excludes = g_strdupv ((gchar **)excludes);
 
 	adata = g_new0 (ActionData, 1);
 	adata->mechanism = g_object_ref (mechanism);
-	adata->context = context;
+	adata->context = g_object_ref (context);
 	adata->includes = g_strdupv ((gchar **)includes);
 	adata->auth_obtained_callback = do_unset_authorized;
 	adata->data = udata;
@@ -1039,9 +1194,10 @@ check_authorization_only_callback (PolkitAuthority *authority,
 							      &error);
 	if (error != NULL) {
 		g_debug ("error checking action '%s'\n", error->message);
-		throw_error (data->context,
-                             GCONF_DEFAULTS_ERROR_NOT_PRIVILEGED,
-                             "Not Authorized: %s", error->message);
+		g_dbus_method_invocation_return_error (data->context,
+                                                       GCONF_DEFAULTS_ERROR,
+                                                       GCONF_DEFAULTS_ERROR_NOT_PRIVILEGED,
+                                                       "Not Authorized: %s", error->message);
 		g_error_free (error);
 		goto out;
 	}
@@ -1071,7 +1227,7 @@ check_authorization_only_callback (PolkitAuthority *authority,
 
 			result = data->challenge ? 1 : 2;
 			g_debug ("return %d\n", result);
-			dbus_g_method_return (data->context, result);
+			g_dbus_method_invocation_return_value (data->context, g_variant_new ("(u)", (guint32) result));
 		}
 		else {
 			check_next_action (data);
@@ -1080,7 +1236,7 @@ check_authorization_only_callback (PolkitAuthority *authority,
 	}
 	else {
 		g_debug ("return 0\n");
-		dbus_g_method_return (data->context, 0);
+		g_dbus_method_invocation_return_value (data->context, g_variant_new ("(u)", 0));
 	}
 
 out:
@@ -1091,7 +1247,7 @@ out:
 
 static void
 check_permissions_only (GConfDefaults                   *mechanism,
-                        DBusGMethodInvocation           *context,
+                        GDBusMethodInvocation           *context,
                         gchar                          **actions,
                         AuthObtainedCallback             auth_obtained_callback,
                         gpointer                         user_data,
@@ -1101,7 +1257,7 @@ check_permissions_only (GConfDefaults                   *mechanism,
 
 	data = g_new0 (CheckAuthData, 1);
 	data->mechanism = g_object_ref (mechanism);
-	data->context = context;
+	data->context = g_object_ref (context);
 	data->actions = actions;
 	data->flags = 0;
 	data->id = 0;
@@ -1109,7 +1265,7 @@ check_permissions_only (GConfDefaults                   *mechanism,
 	data->auth_obtained_callback = NULL;
 	data->user_data = NULL;
 	data->destroy = NULL;
-	data->subject = polkit_system_bus_name_new (dbus_g_method_get_sender (context));
+	data->subject = polkit_system_bus_name_new (g_dbus_method_invocation_get_sender (context));
 	data->challenge = FALSE;
 
 	check_next_action (data);
@@ -1119,7 +1275,7 @@ static void
 do_check (GConfDefaults          *mechanism,
           gboolean                mandatory,
           const gchar           **includes,
-          DBusGMethodInvocation  *context)
+          GDBusMethodInvocation  *context)
 {
 	ActionData *adata;
 
@@ -1127,7 +1283,7 @@ do_check (GConfDefaults          *mechanism,
 
 	adata = g_new0 (ActionData, 1);
 	adata->mechanism = g_object_ref (mechanism);
-	adata->context = context;
+	adata->context = g_object_ref (context);
 	adata->includes = g_strdupv ((gchar **)includes);
 	adata->actions_ready_callback = check_permissions_only;
 	adata->auth_obtained_callback = NULL;
@@ -1152,7 +1308,7 @@ do_check (GConfDefaults          *mechanism,
 void
 gconf_defaults_can_set_system (GConfDefaults          *mechanism,
 			       const char            **includes,
-			       DBusGMethodInvocation  *context)
+			       GDBusMethodInvocation  *context)
 {
 	do_check (mechanism, FALSE, includes, context);
 }
@@ -1160,7 +1316,7 @@ gconf_defaults_can_set_system (GConfDefaults          *mechanism,
 void
 gconf_defaults_can_set_mandatory (GConfDefaults          *mechanism,
 			          const char            **includes,
-			          DBusGMethodInvocation  *context)
+			          GDBusMethodInvocation  *context)
 {
 	do_check (mechanism, TRUE, includes, context);
 }
@@ -1169,7 +1325,7 @@ void
 gconf_defaults_set_system_value (GConfDefaults         *mechanism,
                                  const char            *path,
                                  const char            *value,
-                                 DBusGMethodInvocation *context)
+                                 GDBusMethodInvocation *context)
 {
 	GConfValue *gvalue;
  	const char *includes[] = { NULL, NULL };
@@ -1178,14 +1334,19 @@ gconf_defaults_set_system_value (GConfDefaults         *mechanism,
 	if (gvalue) {
 		includes[0] = path;
 		do_copy (mechanism, FALSE, includes, NULL, gvalue, context, set_system_changes, NULL, NULL);
-	}
+	} else {
+                g_dbus_method_invocation_return_error_literal (context,
+                                                               GCONF_DEFAULTS_ERROR,
+                                                               GCONF_DEFAULTS_ERROR_GENERAL,
+                                                               "Failed to parse value as GConf value");
+        }
 }
 
 void
 gconf_defaults_set_mandatory_value (GConfDefaults         *mechanism,
                                     const char            *path,
                                     const char            *value,
-                                    DBusGMethodInvocation *context)
+                                    GDBusMethodInvocation *context)
 {
 	GConfValue *gvalue;
  	const char *includes[] = { NULL, NULL };
@@ -1194,6 +1355,10 @@ gconf_defaults_set_mandatory_value (GConfDefaults         *mechanism,
 	if (gvalue) {
 		includes[0] = path;
 		do_copy (mechanism, TRUE, includes, NULL, gvalue, context, NULL, NULL, NULL);
-	}
+	} else {
+                g_dbus_method_invocation_return_error_literal (context,
+                                                               GCONF_DEFAULTS_ERROR,
+                                                               GCONF_DEFAULTS_ERROR_GENERAL,
+                                                               "Failed to parse value as GConf value");
+        }
 }
-
diff --git a/defaults/gconf-defaults.h b/defaults/gconf-defaults.h
index 6f71814..e758d78 100644
--- a/defaults/gconf-defaults.h
+++ b/defaults/gconf-defaults.h
@@ -22,7 +22,7 @@
 #define GCONF_DEFAULTS_H
 
 #include <glib-object.h>
-#include <dbus/dbus-glib.h>
+#include <gio/gio.h>
 
 G_BEGIN_DECLS
 
@@ -65,41 +65,42 @@ GType gconf_defaults_error_get_type (void);
 
 GQuark         gconf_defaults_error_quark    (void);
 GType          gconf_defaults_get_type       (void);
-GConfDefaults *gconf_defaults_new            (void);
+
+GConfDefaults *gconf_defaults_new            (GDBusConnection *connection);
 
 /* exported methods */
 void           gconf_defaults_set_system          (GConfDefaults          *mechanism,
                                                    const char            **includes,
                                                    const char            **excludes,
-                                                   DBusGMethodInvocation  *context);
+                                                   GDBusMethodInvocation  *context);
 
 void           gconf_defaults_set_system_value    (GConfDefaults          *mechanism,
                                                    const char             *path,
                                                    const char             *value,
-                                                   DBusGMethodInvocation  *context);
+                                                   GDBusMethodInvocation  *context);
 
 void           gconf_defaults_set_mandatory       (GConfDefaults          *mechanism,
                                                    const char            **includes,
                                                    const char            **excludes,
-                                                   DBusGMethodInvocation  *context);
+                                                   GDBusMethodInvocation  *context);
 
 void           gconf_defaults_set_mandatory_value (GConfDefaults          *mechanism,
                                                    const char             *path,
                                                    const char             *value,
-                                                   DBusGMethodInvocation  *context);
+                                                   GDBusMethodInvocation  *context);
 
 void           gconf_defaults_unset_mandatory     (GConfDefaults          *mechanism,
                                                    const char            **includes,
                                                    const char            **excludes,
-                                                   DBusGMethodInvocation  *context);
+                                                   GDBusMethodInvocation  *context);
 
 void		gconf_defaults_can_set_system    (GConfDefaults         *mechanism,
 						  const char	       **includes,
-                                                  DBusGMethodInvocation  *context);
+                                                  GDBusMethodInvocation  *context);
 
 void		gconf_defaults_can_set_mandatory (GConfDefaults         *mechanism,
 						  const char	       **includes,
-                                                  DBusGMethodInvocation  *context);
+                                                  GDBusMethodInvocation  *context);
 
 G_END_DECLS
 



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