6e9cc4
From b0895e1998ebc83ab030ec0f17c0685439f5b404 Mon Sep 17 00:00:00 2001
6e9cc4
From: Ray Strode <rstrode@redhat.com>
6e9cc4
Date: Mon, 15 Apr 2013 09:57:34 -0400
6e9cc4
Subject: [PATCH] dbus: Don't spew to console when unable to connect to dbus
6e9cc4
 daemon
6e9cc4
6e9cc4
Instead pass the error up for the caller to decide what to do.
6e9cc4
6e9cc4
This prevent untrappable warning messages from showing up at the
6e9cc4
console if gconftool --makefile-install-rule is called.
6e9cc4
---
6e9cc4
 gconf/gconf-dbus.c | 24 ++++++++++++------------
6e9cc4
 1 file changed, 12 insertions(+), 12 deletions(-)
6e9cc4
6e9cc4
diff --git a/gconf/gconf-dbus.c b/gconf/gconf-dbus.c
6e9cc4
index 5610fcf..048e3ea 100644
6e9cc4
--- a/gconf/gconf-dbus.c
6e9cc4
+++ b/gconf/gconf-dbus.c
6e9cc4
@@ -104,9 +104,9 @@ static GConfEngine    *default_engine = NULL;
6e9cc4
 static GHashTable     *engines_by_db = NULL;
6e9cc4
 static GHashTable     *engines_by_address = NULL;
6e9cc4
 static gboolean        dbus_disconnected = FALSE;
6e9cc4
 
6e9cc4
-static gboolean     ensure_dbus_connection      (void);
6e9cc4
+static gboolean     ensure_dbus_connection      (GError **error);
6e9cc4
 static gboolean     ensure_service              (gboolean          start_if_not_found,
6e9cc4
 						 GError          **err);
6e9cc4
 static gboolean     ensure_database             (GConfEngine      *conf,
6e9cc4
 						 gboolean          start_if_not_found,
6e9cc4
@@ -382,18 +382,20 @@ gconf_engine_detach (GConfEngine *conf)
6e9cc4
     }
6e9cc4
 }
6e9cc4
 
6e9cc4
 static gboolean
6e9cc4
-ensure_dbus_connection (void)
6e9cc4
+ensure_dbus_connection (GError **err)
6e9cc4
 {
6e9cc4
   DBusError error;
6e9cc4
 
6e9cc4
   if (global_conn != NULL)
6e9cc4
     return TRUE;
6e9cc4
 
6e9cc4
   if (dbus_disconnected)
6e9cc4
     {
6e9cc4
-      g_warning ("The connection to DBus was broken. Can't reinitialize it.");
6e9cc4
+      g_set_error (err, GCONF_ERROR,
6e9cc4
+                   GCONF_ERROR_NO_SERVER,
6e9cc4
+                   "The connection to DBus was broken. Can't reinitialize it.");
6e9cc4
       return FALSE;
6e9cc4
     }
6e9cc4
 
6e9cc4
   dbus_error_init (&error);
6e9cc4
@@ -401,9 +403,12 @@ ensure_dbus_connection (void)
6e9cc4
   global_conn = dbus_bus_get_private (DBUS_BUS_SESSION, &error);
6e9cc4
   
6e9cc4
   if (!global_conn) 
6e9cc4
     {
6e9cc4
-      g_warning ("Client failed to connect to the D-BUS daemon:\n%s", error.message);
6e9cc4
+      g_set_error (err, GCONF_ERROR,
6e9cc4
+                   GCONF_ERROR_NO_SERVER,
6e9cc4
+                   "Client failed to connect to the D-BUS daemon:\n%s",
6e9cc4
+                   error.message);
6e9cc4
       
6e9cc4
       dbus_error_free (&error);
6e9cc4
       return FALSE;
6e9cc4
     }
6e9cc4
@@ -430,15 +435,10 @@ ensure_service (gboolean  start_if_not_found,
6e9cc4
   DBusError error;
6e9cc4
 
6e9cc4
   if (global_conn == NULL)
6e9cc4
     {
6e9cc4
-      if (!ensure_dbus_connection ())
6e9cc4
-	{
6e9cc4
-	  g_set_error (err, GCONF_ERROR,
6e9cc4
-		       GCONF_ERROR_NO_SERVER,
6e9cc4
-		       _("No D-BUS daemon running\n"));
6e9cc4
-	  return FALSE;
6e9cc4
-	}
6e9cc4
+      if (!ensure_dbus_connection (err))
6e9cc4
+        return FALSE;
6e9cc4
 
6e9cc4
       g_assert (global_conn != NULL);
6e9cc4
     }
6e9cc4
 
6e9cc4
@@ -2511,9 +2511,9 @@ gboolean
6e9cc4
 gconf_ping_daemon (void)
6e9cc4
 {
6e9cc4
   if (global_conn == NULL)
6e9cc4
   {
6e9cc4
-    if (!ensure_dbus_connection ())
6e9cc4
+    if (!ensure_dbus_connection (NULL))
6e9cc4
     {
6e9cc4
       return FALSE;
6e9cc4
     }
6e9cc4
     g_assert (global_conn != NULL);
6e9cc4
-- 
6e9cc4
1.8.1.4
6e9cc4