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