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