From 6e86378ec9de4ca1610e1a47a099e8f772cdb3b5 Mon Sep 17 00:00:00 2001
From: Pavel Grunt <pgrunt@redhat.com>
Date: Wed, 28 Jan 2015 12:47:32 +0100
Subject: [spice-gtk] desktop-integration: check owner of bus name
It avoids calling D-Bus methods when the bus name
"org.gnome.SessionManager" does not exist.
Silences:
GSpice-WARNING **: Error calling 'org.gnome.SessionManager.Inhibit': GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.gnome.SessionManager was not provided by any .service files
---
gtk/desktop-integration.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/gtk/desktop-integration.c b/gtk/desktop-integration.c
index c366fd0..5868d48 100644
--- a/gtk/desktop-integration.c
+++ b/gtk/desktop-integration.c
@@ -67,6 +67,7 @@ static gboolean gnome_integration_init(SpiceDesktopIntegration *self)
gboolean success = TRUE;
#if defined(USE_GDBUS)
+ gchar *name_owner = NULL;
priv->gnome_session_proxy =
g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SESSION,
G_DBUS_PROXY_FLAGS_NONE,
@@ -76,6 +77,12 @@ static gboolean gnome_integration_init(SpiceDesktopIntegration *self)
"org.gnome.SessionManager",
NULL,
&error);
+ if (!error &&
+ (name_owner = g_dbus_proxy_get_name_owner(priv->gnome_session_proxy)) == NULL) {
+ g_clear_object(&priv->gnome_session_proxy);
+ success = FALSE;
+ }
+ g_free(name_owner);
#else
success = FALSE;
#endif