[gnome-control-center] printers: Port to GDBus



commit 7dd5ae6b94d1b294032d0f0fae18df12322eb1c2
Author: Robert Ancell <robert ancell canonical com>
Date:   Sat Feb 25 14:29:51 2012 +1100

    printers: Port to GDBus

 configure.ac                            |    2 +-
 panels/printers/cc-printers-panel.c     |   96 +++--
 panels/printers/pp-new-printer-dialog.c |  285 +++++++-----
 panels/printers/pp-utils.c              |  744 +++++++++++++++++-------------
 panels/printers/pp-utils.h              |    6 -
 5 files changed, 646 insertions(+), 487 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 7d33013..be03786 100644
--- a/configure.ac
+++ b/configure.ac
@@ -110,7 +110,7 @@ PKG_CHECK_MODULES(ONLINE_ACCOUNTS_PANEL, $COMMON_MODULES goa-1.0 goa-backend-1.0
 PKG_CHECK_MODULES(POWER_PANEL, $COMMON_MODULES upower-glib >= 0.9.1
                   gnome-settings-daemon >= $GSD_REQUIRED_VERSION)
 PKG_CHECK_MODULES(COLOR_PANEL, $COMMON_MODULES colord >= 0.1.8)
-PKG_CHECK_MODULES(PRINTERS_PANEL, $COMMON_MODULES dbus-glib-1
+PKG_CHECK_MODULES(PRINTERS_PANEL, $COMMON_MODULES
                   polkit-gobject-1 >= $POLKIT_REQUIRED_VERSION)
 PKG_CHECK_MODULES(REGION_PANEL, $COMMON_MODULES libgnomekbd >= 2.91.91
                   polkit-gobject-1 >= $POLKIT_REQUIRED_VERSION
diff --git a/panels/printers/cc-printers-panel.c b/panels/printers/cc-printers-panel.c
index c3ea547..194830f 100644
--- a/panels/printers/cc-printers-panel.c
+++ b/panels/printers/cc-printers-panel.c
@@ -25,7 +25,6 @@
 #include <glib/gi18n-lib.h>
 #include <glib/gstdio.h>
 #include <polkit/polkit.h>
-#include <dbus/dbus-glib.h>
 #include <gdesktop-enums.h>
 
 #include <cups/cups.h>
@@ -1563,11 +1562,10 @@ job_process_cb (GtkButton *button,
 {
   CcPrintersPanelPrivate *priv;
   CcPrintersPanel        *self = (CcPrintersPanel*) user_data;
-  DBusGProxy             *proxy;
+  GDBusConnection        *bus;
   GtkWidget              *widget;
-  gboolean                result = TRUE;
   GError                 *error = NULL;
-  char                   *ret_error = NULL;
+  GVariant               *output = NULL;
   int                     id = -1;
 
   priv = PRINTERS_PANEL_PRIVATE (self);
@@ -1579,57 +1577,75 @@ job_process_cb (GtkButton *button,
 
   if (id >= 0)
     {
-      proxy = get_dbus_proxy (MECHANISM_BUS,
-                              "/",
-                              MECHANISM_BUS,
-                              TRUE);
-
-      if (!proxy)
-        return;
+      bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
+      if (!bus)
+        {
+          g_warning ("Failed to get system bus: %s", error->message);
+          g_error_free (error);
+          return;
+        }
 
       if ((GtkButton*) gtk_builder_get_object (priv->builder,
                                                "job-cancel-button") ==
           button)
-        result = dbus_g_proxy_call (proxy, "JobCancelPurge", &error,
-                                    G_TYPE_INT, id,
-                                    G_TYPE_BOOLEAN, FALSE,
-                                    G_TYPE_INVALID,
-                                    G_TYPE_STRING, &ret_error,
-                                    G_TYPE_INVALID);
+        output = g_dbus_connection_call_sync (bus,
+                                              MECHANISM_BUS,
+                                              "/",
+                                              MECHANISM_BUS,
+                                              "JobCancelPurge",
+                                              g_variant_new ("(ib)", id, FALSE),
+                                              G_VARIANT_TYPE ("(s)"),
+                                              G_DBUS_CALL_FLAGS_NONE,
+                                              -1,
+                                              NULL,
+                                              &error);
       else if ((GtkButton*) gtk_builder_get_object (priv->builder,
                                                         "job-hold-button") ==
                button)
-        result = dbus_g_proxy_call (proxy, "JobSetHoldUntil", &error,
-                                    G_TYPE_INT, id,
-                                    G_TYPE_STRING, "indefinite",
-                                    G_TYPE_INVALID,
-                                    G_TYPE_STRING, &ret_error,
-                                    G_TYPE_INVALID);
+        output = g_dbus_connection_call_sync (bus,
+                                              MECHANISM_BUS,
+                                              "/",
+                                              MECHANISM_BUS,
+                                              "JobSetHoldUntil",
+                                              g_variant_new ("(is)", id, "indefinite"),
+                                              G_VARIANT_TYPE ("(s)"),
+                                              G_DBUS_CALL_FLAGS_NONE,
+                                              -1,
+                                              NULL,
+                                              &error);
       else if ((GtkButton*) gtk_builder_get_object (priv->builder,
                                                         "job-release-button") ==
                button)
-        result = dbus_g_proxy_call (proxy, "JobSetHoldUntil", &error,
-                                    G_TYPE_INT, id,
-                                    G_TYPE_STRING, "no-hold",
-                                    G_TYPE_INVALID,
-                                    G_TYPE_STRING, &ret_error,
-                                    G_TYPE_INVALID);
-
-      g_object_unref (proxy);
-
-      if (!result || (ret_error && ret_error[0] != '\0'))
+        output = g_dbus_connection_call_sync (bus,
+                                              MECHANISM_BUS,
+                                              "/",
+                                              MECHANISM_BUS,
+                                              "JobSetHoldUntil",
+                                              g_variant_new ("(is)", id, "no-hold"),
+                                              G_VARIANT_TYPE ("(s)"),
+                                              G_DBUS_CALL_FLAGS_NONE,
+                                              -1,
+                                              NULL,
+                                              &error);
+      g_object_unref (bus);
+
+      if (output)
         {
-          if (!result)
-            {
-              g_warning ("%s", error->message);
-              g_error_free (error);
-            }
+          const gchar *ret_error;
 
-          if (ret_error && ret_error[0] != '\0')
+          g_variant_get (output, "(&s)", &ret_error);
+          if (ret_error[0] != '\0')
             g_warning ("%s", ret_error);
+          else
+            actualize_jobs_list (self);
+
+          g_variant_unref (output);
         }
       else
-        actualize_jobs_list (self);
+        {
+          g_warning ("%s", error->message);
+          g_error_free (error);
+        }
   }
 
   widget = (GtkWidget*)
diff --git a/panels/printers/pp-new-printer-dialog.c b/panels/printers/pp-new-printer-dialog.c
index d620d07..122f101 100644
--- a/panels/printers/pp-new-printer-dialog.c
+++ b/panels/printers/pp-new-printer-dialog.c
@@ -36,7 +36,6 @@
 #include "pp-new-printer-dialog.h"
 #include "pp-utils.h"
 
-#include <dbus/dbus-glib.h>
 #include <libnotify/notify.h>
 
 #ifdef GDK_WINDOWING_X11
@@ -1554,44 +1553,58 @@ new_printer_add_button_cb (GtkButton *button,
 
               if (ppd_file_name)
                 {
-                  DBusGProxy *proxy;
-                  gboolean    result;
+                  GDBusConnection *bus;
                   GError     *error = NULL;
-                  char       *ret_error = NULL;
 
-                  proxy = get_dbus_proxy (MECHANISM_BUS,
-                                          "/",
-                                          MECHANISM_BUS,
-                                          TRUE);
-                  if (proxy)
+                  bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
+                  if (!bus)
+                    {
+                      g_warning ("Failed to get system bus: %s", error->message);
+                      g_error_free (error);
+                    }
+                  else
                     {
-                      result = dbus_g_proxy_call (proxy, "PrinterAddWithPpdFile", &error,
-                                                  G_TYPE_STRING, pp->devices[device_id].display_name,
-                                                  G_TYPE_STRING, pp->devices[device_id].device_uri,
-                                                  G_TYPE_STRING, ppd_file_name,
-                                                  G_TYPE_STRING, pp->devices[device_id].device_info,
-                                                  G_TYPE_STRING, pp->devices[device_id].device_location,
-                                                  G_TYPE_INVALID,
-                                                  G_TYPE_STRING, &ret_error,
-                                                  G_TYPE_INVALID);
-
-                      if (!result)
+                      GVariant *output;
+
+                      output = g_dbus_connection_call_sync (bus,
+                                                            MECHANISM_BUS,
+                                                            "/",
+                                                            MECHANISM_BUS,
+                                                            "PrinterAddWithPpdFile",
+                                                            g_variant_new ("(sssss)",
+                                                                           pp->devices[device_id].display_name,
+                                                                           pp->devices[device_id].device_uri,
+                                                                           ppd_file_name,
+                                                                           pp->devices[device_id].device_info,
+                                                                           pp->devices[device_id].device_location ? pp->devices[device_id].device_location : ""),
+                                                            G_VARIANT_TYPE ("(s)"),
+                                                            G_DBUS_CALL_FLAGS_NONE,
+                                                            -1,
+                                                            NULL,
+                                                            &error);
+                      g_object_unref (bus);
+
+                      if (output)
                         {
-                          g_warning ("%s", error->message);
-                          g_error_free (error);
-                          dialog_response = GTK_RESPONSE_REJECT;
-                        }
+                          const gchar *ret_error;
+
+                          g_variant_get (output, "(&s)", &ret_error);
+                          if (ret_error[0] != '\0')
+                            {
+                              g_warning ("%s", ret_error);
+                              dialog_response = GTK_RESPONSE_REJECT;
+                            }
+                          else
+                            success = TRUE;
 
-                      if (ret_error && ret_error[0] != '\0')
+                          g_variant_unref (output);
+                        }
+                      else
                         {
-                          g_warning ("%s", ret_error);
+                          g_warning ("%s", error->message);
+                          g_error_free (error);
                           dialog_response = GTK_RESPONSE_REJECT;
                         }
-
-                      if (result && (!ret_error || ret_error[0] == '\0'))
-                        success = TRUE;
-
-                      g_object_unref (proxy);
                     }
 
                   g_unlink (ppd_file_name);
@@ -1616,40 +1629,47 @@ new_printer_add_button_cb (GtkButton *button,
           if (ppd_name == NULL || ppd_name->ppd_match_level < PPD_EXACT_MATCH)
             {
               /* Try PackageKit to install printer driver */
-              DBusGProxy *proxy;
-              gboolean    result;
+              GDBusConnection *bus;
               GError     *error = NULL;
 
-              proxy = get_dbus_proxy (PACKAGE_KIT_BUS,
-                                      PACKAGE_KIT_PATH,
-                                      PACKAGE_KIT_MODIFY_IFACE,
-                                      FALSE);
-
-              if (proxy)
+              bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
+              if (!bus)
+                {
+                  g_warning ("Failed to get session bus: %s", error->message);
+                  g_error_free (error);
+                }
+              else
                 {
-                  gchar **device_ids = NULL;
+                  GVariantBuilder array_builder;
+                  GVariant *output;
+                  guint window_id = 0;
 
-                  device_ids = g_new (gchar *, 2);
-                  device_ids[0] = pp->devices[device_id].device_id;
-                  device_ids[1] = NULL;
+                  g_variant_builder_init (&array_builder, G_VARIANT_TYPE ("as"));
+                  g_variant_builder_add (&array_builder, "s", pp->devices[device_id].device_id);
 
-                  result = dbus_g_proxy_call_with_timeout (proxy,
-                    "InstallPrinterDrivers",
-                    3600000,
-                    &error,
 #ifdef GDK_WINDOWING_X11
-                    G_TYPE_UINT, GDK_WINDOW_XID (gtk_widget_get_window (GTK_WIDGET (pp->dialog))),
-#else
-                    G_TYPE_UINT, 0,
+                  window_id = GDK_WINDOW_XID (gtk_widget_get_window (GTK_WIDGET (pp->dialog)));
 #endif
-                    G_TYPE_STRV, device_ids,
-                    G_TYPE_STRING, "hide-finished",
-                    G_TYPE_INVALID,
-                    G_TYPE_INVALID);
 
-                  g_object_unref (proxy);
+                  output = g_dbus_connection_call_sync (bus,
+                                                        PACKAGE_KIT_BUS,
+                                                        PACKAGE_KIT_PATH,
+                                                        PACKAGE_KIT_MODIFY_IFACE,
+                                                        "InstallPrinterDrivers",
+                                                        g_variant_new ("(uass)",
+                                                                       window_id,
+                                                                       &array_builder,
+                                                                       "hide-finished"),
+                                                        G_VARIANT_TYPE ("()"),
+                                                        G_DBUS_CALL_FLAGS_NONE,
+                                                        3600000,
+                                                        NULL,
+                                                        &error);
+                  g_object_unref (bus);
 
-                  if (!result)
+                  if (output)
+                    g_variant_unref (output);
+                  else
                     {
                       g_warning ("%s", error->message);
                       g_error_free (error);
@@ -1665,49 +1685,61 @@ new_printer_add_button_cb (GtkButton *button,
                   ppd_name = get_ppd_name (pp->devices[device_id].device_id,
                                pp->devices[device_id].device_make_and_model,
                                pp->devices[device_id].device_uri);
-
-                  g_free (device_ids);
                 }
             }
 
           /* Add the new printer */
           if (ppd_name && ppd_name->ppd_name)
             {
-              DBusGProxy *proxy;
-              gboolean    result;
+              GDBusConnection *bus;
               GError     *error = NULL;
-              char       *ret_error = NULL;
+              GVariant   *output;
 
-              proxy = get_dbus_proxy (MECHANISM_BUS,
-                                      "/",
-                                      MECHANISM_BUS,
-                                      TRUE);
-              if (proxy)
+              bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
+              if (!bus)
+                {
+                  g_warning ("Failed to get system bus: %s", error->message);
+                  g_error_free (error);
+                }
+              else
                 {
-                  result = dbus_g_proxy_call (proxy, "PrinterAdd", &error,
-                             G_TYPE_STRING, pp->devices[device_id].display_name,
-                             G_TYPE_STRING, pp->devices[device_id].device_uri,
-                             G_TYPE_STRING, ppd_name->ppd_name,
-                             G_TYPE_STRING, pp->devices[device_id].device_info,
-                             G_TYPE_STRING, pp->devices[device_id].device_location,
-                             G_TYPE_INVALID,
-                             G_TYPE_STRING, &ret_error,
-                             G_TYPE_INVALID);
-
-                  if (!result)
+                  output = g_dbus_connection_call_sync (bus,
+                                                        MECHANISM_BUS,
+                                                        "/",
+                                                        MECHANISM_BUS,
+                                                        "PrinterAdd",
+                                                        g_variant_new ("(sssss)",
+                                                                       pp->devices[device_id].display_name,
+                                                                       pp->devices[device_id].device_uri,
+                                                                       ppd_name->ppd_name,
+                                                                       pp->devices[device_id].device_info,
+                                                                       pp->devices[device_id].device_location ? pp->devices[device_id].device_location : ""),
+                                                        G_VARIANT_TYPE ("(s)"),
+                                                        G_DBUS_CALL_FLAGS_NONE,
+                                                        -1,
+                                                        NULL,
+                                                        &error);
+                  g_object_unref (bus);
+
+                  if (output)
                     {
-                      g_warning ("%s", error->message);
-                      g_error_free (error);
-                      dialog_response = GTK_RESPONSE_REJECT;
-                    }
+                      const gchar *ret_error;
+
+                      g_variant_get (output, "(&s)", &ret_error);
+                      if (ret_error[0] != '\0')
+                        {
+                          g_warning ("%s", ret_error);
+                          dialog_response = GTK_RESPONSE_REJECT;
+                        }
 
-                  if (ret_error && ret_error[0] != '\0')
+                      g_variant_unref (output);
+                    }
+                  else
                     {
-                      g_warning ("%s", ret_error);
+                      g_warning ("%s", error->message);
+                      g_error_free (error);
                       dialog_response = GTK_RESPONSE_REJECT;
                     }
-
-                  g_object_unref (proxy);
                 }
 
               g_free (ppd_name->ppd_name);
@@ -1725,22 +1757,22 @@ new_printer_add_button_cb (GtkButton *button,
       if (success)
         {
           const char *ppd_file_name = NULL;
-          DBusGProxy *proxy;
-          gboolean    result;
+          GDBusConnection *bus;
           GError     *error = NULL;
-          char       *ret_error = NULL;
+          GVariant   *output;
           ppd_file_t  *ppd_file = NULL;
-          gchar      **value = NULL;
+          gchar       *value = NULL;
           const gchar *paper_size;
 
           ppd_file_name = cupsGetPPD (pp->devices[device_id].display_name);
 
-          proxy = get_dbus_proxy (MECHANISM_BUS,
-                                  "/",
-                                  MECHANISM_BUS,
-                                  TRUE);
-
-          if (proxy)
+          bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
+          if (!bus)
+            {
+              g_warning ("Failed to get system bus: %s", error->message);
+              g_error_free (error);
+            }
+          else
             {
               printer_set_accepting_jobs (pp->devices[device_id].display_name, TRUE, NULL);
               printer_set_enabled (pp->devices[device_id].display_name, TRUE);
@@ -1793,8 +1825,7 @@ new_printer_add_button_cb (GtkButton *button,
                                                            strlen (paper_size)) == 0 &&
                                       !ppd_file->groups[i].options[j].choices[k].marked)
                                     {
-                                      value = g_new0 (gchar *, 2);
-                                      value[0] = g_strdup (ppd_file->groups[i].options[j].choices[k].choice);
+                                      value = g_strdup (ppd_file->groups[i].options[j].choices[k].choice);
                                       break;
                                     }
                                 }
@@ -1806,28 +1837,45 @@ new_printer_add_button_cb (GtkButton *button,
 
               if (value)
                 {
-                  result = dbus_g_proxy_call (proxy, "PrinterAddOptionDefault", &error,
-                             G_TYPE_STRING, pp->devices[device_id].display_name,
-                             G_TYPE_STRING, "PageSize",
-                             G_TYPE_STRV, value,
-                             G_TYPE_INVALID,
-                             G_TYPE_STRING, &ret_error,
-                             G_TYPE_INVALID);
-
-                  if (!result)
+                  GVariantBuilder array_builder;
+
+                  g_variant_builder_init (&array_builder, G_VARIANT_TYPE ("as"));
+                  g_variant_builder_add (&array_builder, "s", value);
+
+                  output = g_dbus_connection_call_sync (bus,
+                                                        MECHANISM_BUS,
+                                                        "/",
+                                                        MECHANISM_BUS,
+                                                        "PrinterAddOptionDefault",
+                                                        g_variant_new ("(ssas)",
+                                                                       pp->devices[device_id].display_name,
+                                                                       "PageSize",
+                                                                       &array_builder),
+                                                        G_VARIANT_TYPE ("(s)"),
+                                                        G_DBUS_CALL_FLAGS_NONE,
+                                                        -1,
+                                                        NULL,
+                                                        &error);
+                  g_object_unref (bus);
+
+                  if (output)
                     {
-                      g_warning ("%s", error->message);
-                      g_error_free (error);
-                    }
+                      const gchar *ret_error;
 
-                  if (ret_error && ret_error[0] != '\0')
+                      g_variant_get (output, "(&s)", &ret_error);
+                      if (ret_error[0] != '\0')
+                        g_warning ("%s", ret_error);
+
+                      g_variant_unref (output);
+                    }
+                  else
                     {
-                      g_warning ("%s", ret_error);
+                      g_warning ("%s", error->message);
+                      g_error_free (error);
                     }
 
-                  g_strfreev (value);
+                  g_free (value);
                 }
-              g_object_unref (proxy);
             }
 
           if (pp->devices[device_id].device_uri &&
@@ -2008,6 +2056,7 @@ DBus method \"MissingExecutables\" to find missing executables and filters.");
                     {
                       GVariantBuilder  array_builder;
                       GList           *pkg_iter;
+                      guint            window_id = 0;
 
                       g_variant_builder_init (&array_builder, G_VARIANT_TYPE ("as"));
 
@@ -2016,14 +2065,14 @@ DBus method \"MissingExecutables\" to find missing executables and filters.");
                                                "s",
                                                (gchar *) pkg_iter->data);
 
+#ifdef GDK_WINDOWING_X11
+                      window_id = GDK_WINDOW_XID (gtk_widget_get_window (GTK_WIDGET (pp->dialog))),
+#endif
+
                       output = g_dbus_proxy_call_sync (proxy,
                                                        "InstallPackageNames",
                                                        g_variant_new ("(uass)",
-#ifdef GDK_WINDOWING_X11
-                                                                      GDK_WINDOW_XID (gtk_widget_get_window (GTK_WIDGET (pp->dialog))),
-#else
-                                                                      0,
-#endif
+                                                                      window_id,
                                                                       &array_builder,
                                                                       "hide-finished"),
                                                        G_DBUS_CALL_FLAGS_NONE,
diff --git a/panels/printers/pp-utils.c b/panels/printers/pp-utils.c
index 0846fc5..24e1859 100644
--- a/panels/printers/pp-utils.c
+++ b/panels/printers/pp-utils.c
@@ -26,7 +26,6 @@
 #include <gtk/gtk.h>
 #include <cups/cups.h>
 #include <cups/ppd.h>
-#include <dbus/dbus-glib.h>
 
 #include "pp-utils.h"
 
@@ -36,38 +35,6 @@
 #define SCP_PATH  "/org/fedoraproject/Config/Printing"
 #define SCP_IFACE "org.fedoraproject.Config.Printing"
 
-DBusGProxy *
-get_dbus_proxy (const gchar *name,
-                const gchar *path,
-                const gchar *iface,
-                const gboolean system_bus)
-{
-  DBusGConnection *bus;
-  DBusGProxy      *proxy;
-  GError          *error = NULL;
-
-  if (system_bus)
-    bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
-  else
-    bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
-
-  if (!bus)
-    {
-      if (system_bus)
-        /* Translators: Program cannot connect to DBus' system bus */
-        g_warning ("Could not connect to system bus: %s", error->message);
-      else
-        /* Translators: Program cannot connect to DBus' session bus */
-        g_warning ("Could not connect to session bus: %s", error->message);
-      g_error_free (error);
-      return NULL;
-    }
-
-  proxy = dbus_g_proxy_new_for_name (bus, name, path, iface);
-
-  return proxy;
-}
-
 gchar *
 get_tag_value (const gchar *tag_string, const gchar *tag_name)
 {
@@ -1576,7 +1543,7 @@ printer_rename (const gchar *old_name,
   cups_dest_t      *dests = NULL;
   cups_dest_t      *dest = NULL;
   cups_job_t       *jobs = NULL;
-  DBusGProxy       *proxy;
+  GDBusConnection  *bus;
   const char       *printer_location = NULL;
   const char       *ppd_filename = NULL;
   const char       *printer_info = NULL;
@@ -1588,7 +1555,6 @@ printer_rename (const gchar *old_name,
   gboolean          printer_paused = FALSE;
   gboolean          default_printer = FALSE;
   gboolean          printer_shared = FALSE;
-  gboolean          call_result;
   GError           *error = NULL;
   http_t           *http;
   gchar           **sheets = NULL;
@@ -1601,7 +1567,6 @@ printer_rename (const gchar *old_name,
   gchar            *op_policy = NULL;
   ipp_t            *request;
   ipp_t            *response;
-  char             *ret_error = NULL;
   gint              i;
   int               num_dests = 0;
   int               num_jobs = 0;
@@ -1749,12 +1714,13 @@ printer_rename (const gchar *old_name,
 
   ppd_filename = cupsGetPPD (old_name);
 
-  proxy = get_dbus_proxy (MECHANISM_BUS,
-                          "/",
-                          MECHANISM_BUS,
-                          TRUE);
-
-  if (proxy)
+  bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
+  if (!bus)
+   {
+     g_warning ("Failed to get system bus: %s", error->message);
+     g_error_free (error);
+   }
+  else
     {
       if (printer_type & CUPS_PRINTER_CLASS)
         {
@@ -1764,27 +1730,42 @@ printer_rename (const gchar *old_name,
         }
       else
         {
-          call_result = dbus_g_proxy_call (proxy, "PrinterAddWithPpdFile", &error,
-                                           G_TYPE_STRING, new_name,
-                                           G_TYPE_STRING, device_uri,
-                                           G_TYPE_STRING, ppd_filename,
-                                           G_TYPE_STRING, printer_info,
-                                           G_TYPE_STRING, printer_location,
-                                           G_TYPE_INVALID,
-                                           G_TYPE_STRING, &ret_error,
-                                           G_TYPE_INVALID);
-
-          if (!call_result)
+          GVariant *output;
+
+          output = g_dbus_connection_call_sync (bus,
+                                                MECHANISM_BUS,
+                                                "/",
+                                                MECHANISM_BUS,
+                                                "PrinterAddWithPpdFile",
+                                                g_variant_new ("(sssss)",
+                                                               new_name,
+                                                               device_uri ? device_uri : "",
+                                                               ppd_filename ? ppd_filename : "",
+                                                               printer_info ? printer_info : "",
+                                                               printer_location ? printer_location : ""),
+                                                G_VARIANT_TYPE ("(s)"),
+                                                G_DBUS_CALL_FLAGS_NONE,
+                                                -1,
+                                                NULL,
+                                                &error);
+          g_object_unref (bus);
+
+          if (output)
+            {
+              const gchar *ret_error;
+
+              g_variant_get (output, "(&s)", &ret_error);
+              if (ret_error[0] != '\0')
+                g_warning ("%s", ret_error);
+
+              g_variant_unref (output);
+            }
+          else
             {
               g_warning ("%s", error->message);
               g_error_free (error);
             }
-
-          if (ret_error && ret_error[0] != '\0')
-            g_warning ("%s", ret_error);
         }
-
-      g_object_unref (proxy);
     }
 
   if (ppd_filename)
@@ -1829,43 +1810,53 @@ gboolean
 printer_set_location (const gchar *printer_name,
                       const gchar *location)
 {
-  DBusGProxy *proxy;
-  gboolean    result;
+  GDBusConnection *bus;
+  GVariant   *output;
+  gboolean    result = FALSE;
   GError     *error = NULL;
-  char       *ret_error = NULL;
 
   if (!printer_name || !location)
     return TRUE;
 
-  proxy = get_dbus_proxy (MECHANISM_BUS,
-                          "/",
-                          MECHANISM_BUS,
-                          TRUE);
-
-  if (!proxy)
-    return TRUE;
+  bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
+  if (!bus)
+   {
+     g_warning ("Failed to get system bus: %s", error->message);
+     g_error_free (error);
+     return TRUE;
+   }
+
+  output = g_dbus_connection_call_sync (bus,
+                                        MECHANISM_BUS,
+                                        "/",
+                                        MECHANISM_BUS,
+                                        "PrinterSetLocation",
+                                        g_variant_new ("(ss)", printer_name, location),
+                                        G_VARIANT_TYPE ("(s)"),
+                                        G_DBUS_CALL_FLAGS_NONE,
+                                        -1,
+                                        NULL,
+                                        &error);
+  g_object_unref (bus);
+
+  if (output)
+    {
+      const gchar *ret_error;
 
-  result = dbus_g_proxy_call (proxy, "PrinterSetLocation", &error,
-                              G_TYPE_STRING, printer_name,
-                              G_TYPE_STRING, location,
-                              G_TYPE_INVALID,
-                              G_TYPE_STRING, &ret_error,
-                              G_TYPE_INVALID);
+      g_variant_get (output, "(&s)", &ret_error);
+      if (ret_error[0] != '\0')
+        g_warning ("%s", ret_error);
+      else
+        result = TRUE;
 
-  if (!result)
+      g_variant_unref (output);
+    }
+  else
     {
       g_warning ("%s", error->message);
       g_error_free (error);
     }
 
-  if (ret_error && ret_error[0] != '\0')
-    {
-      g_warning ("%s", ret_error);
-      result = FALSE;
-    }
-
-  g_object_unref (proxy);
-
   return result;
 }
 
@@ -1874,44 +1865,55 @@ printer_set_accepting_jobs (const gchar *printer_name,
                             gboolean     accepting_jobs,
                             const gchar *reason)
 {
-  DBusGProxy *proxy;
-  gboolean    result;
+  GDBusConnection *bus;
+  GVariant   *output;
+  gboolean    result = FALSE;
   GError     *error = NULL;
-  char       *ret_error = NULL;
 
   if (!printer_name)
     return TRUE;
 
-  proxy = get_dbus_proxy (MECHANISM_BUS,
-                          "/",
-                          MECHANISM_BUS,
-                          TRUE);
-
-  if (!proxy)
-    return TRUE;
-
-  result = dbus_g_proxy_call (proxy, "PrinterSetAcceptJobs", &error,
-                              G_TYPE_STRING, printer_name,
-                              G_TYPE_BOOLEAN, accepting_jobs,
-                              G_TYPE_STRING, reason,
-                              G_TYPE_INVALID,
-                              G_TYPE_STRING, &ret_error,
-                              G_TYPE_INVALID);
+  bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
+  if (!bus)
+   {
+     g_warning ("Failed to get system bus: %s", error->message);
+     g_error_free (error);
+     return TRUE;
+   }
+
+  output = g_dbus_connection_call_sync (bus,
+                                        MECHANISM_BUS,
+                                        "/",
+                                        MECHANISM_BUS,
+                                        "PrinterSetAcceptJobs",
+                                        g_variant_new ("(sbs)",
+                                                       printer_name,
+                                                       accepting_jobs,
+                                                       reason ? reason : ""),
+                                        G_VARIANT_TYPE ("(s)"),
+                                        G_DBUS_CALL_FLAGS_NONE,
+                                        -1,
+                                        NULL,
+                                        &error);
+  g_object_unref (bus);
+
+  if (output)
+    {
+      const gchar *ret_error;
 
-  if (!result)
+      g_variant_get (output, "(&s)", &ret_error);
+      if (ret_error[0] != '\0')
+        g_warning ("%s", ret_error);
+      else
+        result = TRUE;
+      g_variant_unref (output);
+    }
+  else
     {
       g_warning ("%s", error->message);
       g_error_free (error);
     }
 
-  if (ret_error && ret_error[0] != '\0')
-    {
-      g_warning ("%s", ret_error);
-      result = FALSE;
-    }
-
-  g_object_unref (proxy);
-
   return result;
 }
 
@@ -1919,96 +1921,117 @@ gboolean
 printer_set_enabled (const gchar *printer_name,
                      gboolean     enabled)
 {
-  DBusGProxy *proxy;
-  gboolean    result;
+  GDBusConnection *bus;
+  GVariant   *output;
+  gboolean    result = FALSE;
   GError     *error = NULL;
-  char       *ret_error = NULL;
 
   if (!printer_name)
     return TRUE;
 
-  proxy = get_dbus_proxy (MECHANISM_BUS,
-                          "/",
-                          MECHANISM_BUS,
-                          TRUE);
-
-  if (!proxy)
-    return TRUE;
+  bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
+  if (!bus)
+   {
+     g_warning ("Failed to get system bus: %s", error->message);
+     g_error_free (error);
+     return TRUE;
+   }
+
+  output = g_dbus_connection_call_sync (bus,
+                                        MECHANISM_BUS,
+                                        "/",
+                                        MECHANISM_BUS,
+                                        "PrinterSetEnabled",
+                                        g_variant_new ("(sb)", printer_name, enabled),
+                                        G_VARIANT_TYPE ("(s)"),
+                                        G_DBUS_CALL_FLAGS_NONE,
+                                        -1,
+                                        NULL,
+                                        &error);
+  g_object_unref (bus);
+
+  if (output)
+    {
+      const gchar *ret_error;
 
-  result = dbus_g_proxy_call (proxy, "PrinterSetEnabled", &error,
-                              G_TYPE_STRING, printer_name,
-                              G_TYPE_BOOLEAN, enabled,
-                              G_TYPE_INVALID,
-                              G_TYPE_STRING, &ret_error,
-                              G_TYPE_INVALID);
+      g_variant_get (output, "(&s)", &ret_error);
+      if (ret_error[0] != '\0')
+        g_warning ("%s", ret_error);
+      else
+        result = TRUE;
 
-  if (!result)
+      g_variant_unref (output);
+    }
+  else
     {
       g_warning ("%s", error->message);
       g_error_free (error);
     }
 
-  if (ret_error && ret_error[0] != '\0')
-    {
-      g_warning ("%s", ret_error);
-      result = FALSE;
-    }
-
-  g_object_unref (proxy);
-
   return result;
 }
 
 gboolean
 printer_delete (const gchar *printer_name)
 {
-  DBusGProxy *proxy;
-  gboolean    result;
+  GDBusConnection *bus;
+  GVariant   *output;
+  gboolean    result = FALSE;
   GError     *error = NULL;
-  char       *ret_error = NULL;
 
   if (!printer_name)
     return TRUE;
 
-  proxy = get_dbus_proxy (MECHANISM_BUS,
-                          "/",
-                          MECHANISM_BUS,
-                          TRUE);
-
-  if (!proxy)
-    return TRUE;
+  bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
+  if (!bus)
+   {
+     g_warning ("Failed to get system bus: %s", error->message);
+     g_error_free (error);
+     return TRUE;
+   }
+
+  output = g_dbus_connection_call_sync (bus,
+                                        MECHANISM_BUS,
+                                        "/",
+                                        MECHANISM_BUS,
+                                        "PrinterDelete",
+                                        g_variant_new ("(s)", printer_name),
+                                        G_VARIANT_TYPE ("(s)"),
+                                        G_DBUS_CALL_FLAGS_NONE,
+                                        -1,
+                                        NULL,
+                                        &error);
+  g_object_unref (bus);
+
+  if (output)
+    {
+      const gchar *ret_error;
 
-  result = dbus_g_proxy_call (proxy, "PrinterDelete", &error,
-                              G_TYPE_STRING, printer_name,
-                              G_TYPE_INVALID,
-                              G_TYPE_STRING, &ret_error,
-                              G_TYPE_INVALID);
+      g_variant_get (output, "(&s)", &ret_error);
+      if (ret_error[0] != '\0')
+        g_warning ("%s", ret_error);
+      else
+        result = TRUE;
 
-  if (!result)
+      g_variant_unref (output);
+    }
+  else
     {
       g_warning ("%s", error->message);
       g_error_free (error);
     }
 
-  if (ret_error && ret_error[0] != '\0')
-    {
-      g_warning ("%s", ret_error);
-      result = FALSE;
-    }
-
-  g_object_unref (proxy);
-
   return result;
 }
 
 gboolean
 printer_set_default (const gchar *printer_name)
 {
-  DBusGProxy *proxy;
+  GDBusConnection *bus;
   const char *cups_server;
-  gboolean    result = TRUE;
+  GVariant   *output;
+  gboolean    result = FALSE;
   GError     *error = NULL;
-  char       *ret_error = NULL;
 
   if (!printer_name)
     return TRUE;
@@ -2024,32 +2047,44 @@ printer_set_default (const gchar *printer_name)
        */
       set_local_default_printer (NULL);
 
-      proxy = get_dbus_proxy (MECHANISM_BUS,
-                              "/",
-                              MECHANISM_BUS,
-                              TRUE);
-
-      if (proxy)
+      bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
+      if (!bus)
         {
-          result = dbus_g_proxy_call (proxy, "PrinterSetDefault", &error,
-                                      G_TYPE_STRING, printer_name,
-                                      G_TYPE_INVALID,
-                                      G_TYPE_STRING, &ret_error,
-                                      G_TYPE_INVALID);
+          g_warning ("Failed to get system bus: %s", error->message);
+          g_error_free (error);
+        }
+      else
+        {
+          output = g_dbus_connection_call_sync (bus,
+                                                MECHANISM_BUS,
+                                                "/",
+                                                MECHANISM_BUS,
+                                                "PrinterSetDefault",
+                                                g_variant_new ("(s)", printer_name),
+                                                G_VARIANT_TYPE ("(s)"),
+                                                G_DBUS_CALL_FLAGS_NONE,
+                                                -1,
+                                                NULL,
+                                                &error);
+          g_object_unref (bus);
+
+          if (output)
+            {
+              const gchar *ret_error;
+
+              g_variant_get (output, "(&s)", &ret_error);
+              if (ret_error[0] != '\0')
+                g_warning ("%s", ret_error);
+              else
+                result = TRUE;
 
-          if (!result)
+              g_variant_unref (output);
+            }
+          else
             {
               g_warning ("%s", error->message);
               g_error_free (error);
             }
-
-          if (ret_error && ret_error[0] != '\0')
-            {
-              g_warning ("%s", ret_error);
-              result = FALSE;
-            }
-
-          g_object_unref (proxy);
         }
     }
   else
@@ -2067,43 +2102,53 @@ gboolean
 printer_set_shared (const gchar *printer_name,
                     gboolean     shared)
 {
-  DBusGProxy *proxy;
-  gboolean    result;
+  GDBusConnection *bus;
+  GVariant   *output;
+  gboolean    result = FALSE;
   GError     *error = NULL;
-  char       *ret_error = NULL;
 
   if (!printer_name)
     return TRUE;
 
-  proxy = get_dbus_proxy (MECHANISM_BUS,
-                          "/",
-                          MECHANISM_BUS,
-                          TRUE);
-
-  if (!proxy)
-    return TRUE;
+  bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
+  if (!bus)
+   {
+     g_warning ("Failed to get system bus: %s", error->message);
+     g_error_free (error);
+     return TRUE;
+   }
+
+  output = g_dbus_connection_call_sync (bus,
+                                        MECHANISM_BUS,
+                                        "/",
+                                        MECHANISM_BUS,
+                                        "PrinterSetShared",
+                                        g_variant_new ("(sb)", printer_name, shared),
+                                        G_VARIANT_TYPE ("(s)"),
+                                        G_DBUS_CALL_FLAGS_NONE,
+                                        -1,
+                                        NULL,
+                                        &error);
+  g_object_unref (bus);
+
+  if (output)
+    {
+      const gchar *ret_error;
 
-  result = dbus_g_proxy_call (proxy, "PrinterSetShared", &error,
-                              G_TYPE_STRING, printer_name,
-                              G_TYPE_BOOLEAN, shared,
-                              G_TYPE_INVALID,
-                              G_TYPE_STRING, &ret_error,
-                              G_TYPE_INVALID);
+      g_variant_get (output, "(&s)", &ret_error);
+      if (ret_error[0] != '\0')
+        g_warning ("%s", ret_error);
+      else
+        result = TRUE;
 
-  if (!result)
+      g_variant_unref (output);
+    }
+  else
     {
       g_warning ("%s", error->message);
       g_error_free (error);
     }
 
-  if (ret_error && ret_error[0] != '\0')
-    {
-      g_warning ("%s", ret_error);
-      result = FALSE;
-    }
-
-  g_object_unref (proxy);
-
   return result;
 }
 
@@ -2112,44 +2157,53 @@ printer_set_job_sheets (const gchar *printer_name,
                         const gchar *start_sheet,
                         const gchar *end_sheet)
 {
-  DBusGProxy *proxy;
-  gboolean    result;
+  GDBusConnection *bus;
+  GVariant   *output;
   GError     *error = NULL;
-  char       *ret_error = NULL;
+  gboolean    result = FALSE;
 
   if (!printer_name || !start_sheet || !end_sheet)
     return TRUE;
 
-  proxy = get_dbus_proxy (MECHANISM_BUS,
-                          "/",
-                          MECHANISM_BUS,
-                          TRUE);
-
-  if (!proxy)
-    return TRUE;
+  bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
+  if (!bus)
+   {
+     g_warning ("Failed to get system bus: %s", error->message);
+     g_error_free (error);
+     return TRUE;
+   }
+
+  output = g_dbus_connection_call_sync (bus,
+                                        MECHANISM_BUS,
+                                        "/",
+                                        MECHANISM_BUS,
+                                        "PrinterSetJobSheets",
+                                        g_variant_new ("(sss)", printer_name, start_sheet, end_sheet),
+                                        G_VARIANT_TYPE ("(s)"),
+                                        G_DBUS_CALL_FLAGS_NONE,
+                                        -1,
+                                        NULL,
+                                        &error);
+  g_object_unref (bus);
+
+  if (output)
+    {
+      const gchar *ret_error;
 
-  result = dbus_g_proxy_call (proxy, "PrinterSetJobSheets", &error,
-                              G_TYPE_STRING, printer_name,
-                              G_TYPE_STRING, start_sheet,
-                              G_TYPE_STRING, end_sheet,
-                              G_TYPE_INVALID,
-                              G_TYPE_STRING, &ret_error,
-                              G_TYPE_INVALID);
+      g_variant_get (output, "(&s)", &ret_error);
+      if (ret_error[0] != '\0')
+        g_warning ("%s", ret_error);
+      else
+        result = TRUE;
 
-  if (!result)
+      g_variant_unref (output);
+    }
+  else
     {
       g_warning ("%s", error->message);
       g_error_free (error);
     }
 
-  if (ret_error && ret_error[0] != '\0')
-    {
-      g_warning ("%s", ret_error);
-      result = FALSE;
-    }
-
-  g_object_unref (proxy);
-
   return result;
 }
 
@@ -2158,51 +2212,66 @@ printer_set_policy (const gchar *printer_name,
                     const gchar *policy,
                     gboolean     error_policy)
 {
-  DBusGProxy *proxy;
-  gboolean    result;
+  GDBusConnection *bus;
+  GVariant   *output;
+  gboolean   result = FALSE;
   GError     *error = NULL;
-  char       *ret_error = NULL;
 
   if (!printer_name || !policy)
     return TRUE;
 
-  proxy = get_dbus_proxy (MECHANISM_BUS,
-                          "/",
-                          MECHANISM_BUS,
-                          TRUE);
-
-  if (!proxy)
-    return TRUE;
+  bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
+  if (!bus)
+   {
+     g_warning ("Failed to get system bus: %s", error->message);
+     g_error_free (error);
+     return TRUE;
+   }
 
   if (error_policy)
-    result = dbus_g_proxy_call (proxy, "PrinterSetErrorPolicy", &error,
-                                G_TYPE_STRING, printer_name,
-                                G_TYPE_STRING, policy,
-                                G_TYPE_INVALID,
-                                G_TYPE_STRING, &ret_error,
-                                G_TYPE_INVALID);
+    output = g_dbus_connection_call_sync (bus,
+                                          MECHANISM_BUS,
+                                          "/",
+                                          MECHANISM_BUS,
+                                          "PrinterSetErrorPolicy",
+                                          g_variant_new ("(ss)", printer_name, policy),
+                                          G_VARIANT_TYPE ("(s)"),
+                                          G_DBUS_CALL_FLAGS_NONE,
+                                          -1,
+                                          NULL,
+                                          &error);
   else
-    result = dbus_g_proxy_call (proxy, "PrinterSetOpPolicy", &error,
-                                G_TYPE_STRING, printer_name,
-                                G_TYPE_STRING, policy,
-                                G_TYPE_INVALID,
-                                G_TYPE_STRING, &ret_error,
-                                G_TYPE_INVALID);
-
-  if (!result)
+    output = g_dbus_connection_call_sync (bus,
+                                          MECHANISM_BUS,
+                                          "/",
+                                          MECHANISM_BUS,
+                                          "PrinterSetOpPolicy",
+                                          g_variant_new ("(ss)", printer_name, policy),
+                                          G_VARIANT_TYPE ("(s)"),
+                                          G_DBUS_CALL_FLAGS_NONE,
+                                          -1,
+                                          NULL,
+                                          &error);
+  g_object_unref (bus);
+
+  if (output)
     {
-      g_warning ("%s", error->message);
-      g_error_free (error);
-    }
+      const gchar *ret_error;
 
-  if (ret_error && ret_error[0] != '\0')
+      g_variant_get (output, "(&s)", &ret_error);
+      if (ret_error[0] != '\0')
+        g_warning ("%s", ret_error);
+      else
+        result = TRUE;
+
+      g_variant_unref (output);
+    }
+  else
     {
-      g_warning ("%s", ret_error);
-      result = FALSE;
+      g_warning ("%s", error->message);
+      g_error_free (error);
     }
 
-  g_object_unref (proxy);
-
   return result;
 }
 
@@ -2211,51 +2280,72 @@ printer_set_users (const gchar  *printer_name,
                    gchar       **users,
                    gboolean      allowed)
 {
-  DBusGProxy *proxy;
-  gboolean    result;
+  GDBusConnection *bus;
+  GVariantBuilder array_builder;
+  gint        i;
+  GVariant   *output;
+  gboolean    result = FALSE;
   GError     *error = NULL;
-  char       *ret_error = NULL;
 
   if (!printer_name || !users)
     return TRUE;
+  
+  bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
+  if (!bus)
+   {
+     g_warning ("Failed to get system bus: %s", error->message);
+     g_error_free (error);
+     return TRUE;
+   }
 
-  proxy = get_dbus_proxy (MECHANISM_BUS,
-                          "/",
-                          MECHANISM_BUS,
-                          TRUE);
-
-  if (!proxy)
-    return TRUE;
+  g_variant_builder_init (&array_builder, G_VARIANT_TYPE ("as"));
+  for (i = 0; users[i]; i++)
+    g_variant_builder_add (&array_builder, "s", users[i]);
 
   if (allowed)
-    result = dbus_g_proxy_call (proxy, "PrinterSetUsersAllowed", &error,
-                                G_TYPE_STRING, printer_name,
-                                G_TYPE_STRV, users,
-                                G_TYPE_INVALID,
-                                G_TYPE_STRING, &ret_error,
-                                G_TYPE_INVALID);
+    output = g_dbus_connection_call_sync (bus,
+                                          MECHANISM_BUS,
+                                          "/",
+                                          MECHANISM_BUS,
+                                          "PrinterSetUsersAllowed",
+                                          g_variant_new ("(sas)", printer_name, &array_builder),
+                                          G_VARIANT_TYPE ("(s)"),
+                                          G_DBUS_CALL_FLAGS_NONE,
+                                          -1,
+                                          NULL,
+                                          &error);
   else
-    result = dbus_g_proxy_call (proxy, "PrinterSetUsersDenied", &error,
-                                G_TYPE_STRING, printer_name,
-                                G_TYPE_STRV, users,
-                                G_TYPE_INVALID,
-                                G_TYPE_STRING, &ret_error,
-                                G_TYPE_INVALID);
-
-  if (!result)
+    output = g_dbus_connection_call_sync (bus,
+                                          MECHANISM_BUS,
+                                          "/",
+                                          MECHANISM_BUS,
+                                          "PrinterSetUsersDenied",
+                                          g_variant_new ("(sas)", printer_name, &array_builder),
+                                          G_VARIANT_TYPE ("(s)"),
+                                          G_DBUS_CALL_FLAGS_NONE,
+                                          -1,
+                                          NULL,
+                                          &error);
+  g_object_unref (bus);
+
+  if (output)
     {
-      g_warning ("%s", error->message);
-      g_error_free (error);
-    }
+      const gchar *ret_error;
 
-  if (ret_error && ret_error[0] != '\0')
+      g_variant_get (output, "(&s)", &ret_error);
+      if (ret_error[0] != '\0')
+        g_warning ("%s", ret_error);
+      else
+        result = TRUE;
+
+      g_variant_unref (output);
+    }
+  else
     {
-      g_warning ("%s", ret_error);
-      result = FALSE;
+      g_warning ("%s", error->message);
+      g_error_free (error);
     }
 
-  g_object_unref (proxy);
-
   return result;
 }
 
@@ -2263,43 +2353,53 @@ gboolean
 class_add_printer (const gchar *class_name,
                    const gchar *printer_name)
 {
-  DBusGProxy *proxy;
-  gboolean    result;
+  GDBusConnection *bus;
+  GVariant   *output;
+  gboolean    result = FALSE;
   GError     *error = NULL;
-  char       *ret_error = NULL;
 
   if (!class_name || !printer_name)
     return TRUE;
 
-  proxy = get_dbus_proxy (MECHANISM_BUS,
-                          "/",
-                          MECHANISM_BUS,
-                          TRUE);
-
-  if (!proxy)
-    return TRUE;
+  bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
+  if (!bus)
+   {
+     g_warning ("Failed to get system bus: %s", error->message);
+     g_error_free (error);
+     return TRUE;
+   }
+
+  output = g_dbus_connection_call_sync (bus,
+                                        MECHANISM_BUS,
+                                        "/",
+                                        MECHANISM_BUS,
+                                        "ClassAddPrinter",
+                                        g_variant_new ("(ss)", class_name, printer_name),
+                                        G_VARIANT_TYPE ("(s)"),
+                                        G_DBUS_CALL_FLAGS_NONE,
+                                        -1,
+                                        NULL,
+                                        &error);
+  g_object_unref (bus);
+
+  if (output)
+    {
+      const gchar *ret_error;
 
-  result = dbus_g_proxy_call (proxy, "ClassAddPrinter", &error,
-                              G_TYPE_STRING, class_name,
-                              G_TYPE_STRING, printer_name,
-                              G_TYPE_INVALID,
-                              G_TYPE_STRING, &ret_error,
-                              G_TYPE_INVALID);
+      g_variant_get (output, "(&s)", &ret_error);
+      if (ret_error[0] != '\0')
+        g_warning ("%s", ret_error);
+      else
+        result = TRUE;
 
-  if (!result)
+      g_variant_unref (output);
+    }
+  else
     {
       g_warning ("%s", error->message);
       g_error_free (error);
     }
 
-  if (ret_error && ret_error[0] != '\0')
-    {
-      g_warning ("%s", ret_error);
-      result = FALSE;
-    }
-
-  g_object_unref (proxy);
-
   return result;
 }
 
diff --git a/panels/printers/pp-utils.h b/panels/printers/pp-utils.h
index 53de8ab..44a12e2 100644
--- a/panels/printers/pp-utils.h
+++ b/panels/printers/pp-utils.h
@@ -22,7 +22,6 @@
 #define __PP_UTILS_H__
 
 #include <gtk/gtk.h>
-#include <dbus/dbus-glib.h>
 
 G_BEGIN_DECLS
 
@@ -44,11 +43,6 @@ typedef struct
   gint   ppd_match_level;
 } PPDName;
 
-DBusGProxy *get_dbus_proxy (const gchar *name,
-                            const gchar *path,
-                            const gchar *iface,
-                            const gboolean system_bus);
-
 gchar      *get_tag_value (const gchar *tag_string,
                            const gchar *tag_name);
 



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