[Spice-devel] [PATCH spice-gtk 5/5] Add GDBus version of dbus-glib code

Marc-André Lureau marcandre.lureau at gmail.com
Thu Feb 6 04:55:55 PST 2014


From: Marc-André Lureau <marcandre.lureau at redhat.com>

---
 gtk/desktop-integration.c | 34 +++++++++++++++++++++++++++++++++-
 1 file changed, 33 insertions(+), 1 deletion(-)

diff --git a/gtk/desktop-integration.c b/gtk/desktop-integration.c
index 064994d..d764e56 100644
--- a/gtk/desktop-integration.c
+++ b/gtk/desktop-integration.c
@@ -90,6 +90,16 @@ static gboolean gnome_integration_init(SpiceDesktopIntegration *self)
                                             "org.gnome.SessionManager",
                                             &error);
 end:
+#elif defined(USE_GDBUS)
+    priv->gnome_session_proxy =
+        g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SESSION,
+                                      G_DBUS_PROXY_FLAGS_NONE,
+                                      NULL,
+                                      "org.gnome.SessionManager",
+                                      "/org/gnome/SessionManager",
+                                      "org.gnome.SessionManager",
+                                      NULL,
+                                      &error);
 #else
     success = FALSE;
 #endif
@@ -108,6 +118,8 @@ static void gnome_integration_inhibit_automount(SpiceDesktopIntegration *self)
 {
     SpiceDesktopIntegrationPrivate *priv = self->priv;
     GError *error = NULL;
+    G_GNUC_UNUSED const gchar *reason =
+        _("Automounting has been inhibited for USB auto-redirecting");
 
     if (!priv->gnome_session_proxy)
         return;
@@ -120,11 +132,24 @@ static void gnome_integration_inhibit_automount(SpiceDesktopIntegration *self)
                 G_TYPE_STRING, g_get_prgname(),
                 G_TYPE_UINT, 0,
                 G_TYPE_STRING,
-                 _("Automounting has been inhibited for USB auto-redirecting"),
+                reason,
                 G_TYPE_UINT, GNOME_SESSION_INHIBIT_AUTOMOUNT,
                 G_TYPE_INVALID,
                 G_TYPE_UINT, &priv->gnome_automount_inhibit_cookie,
                 G_TYPE_INVALID);
+#elif defined(USE_GDBUS)
+    GVariant *v = g_dbus_proxy_call_sync(priv->gnome_session_proxy,
+                "Inhibit",
+                g_variant_new("(susu)",
+                              g_get_prgname(),
+                              0,
+                              reason,
+                              GNOME_SESSION_INHIBIT_AUTOMOUNT),
+                G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
+    if (v)
+        g_variant_get(v, "(u)", &priv->gnome_automount_inhibit_cookie);
+
+    g_clear_pointer(&v, g_variant_unref);
 #endif
     if (error)
         handle_dbus_call_error("org.gnome.SessionManager.Inhibit", &error);
@@ -148,6 +173,13 @@ static void gnome_integration_uninhibit_automount(SpiceDesktopIntegration *self)
                 G_TYPE_UINT, priv->gnome_automount_inhibit_cookie,
                 G_TYPE_INVALID,
                 G_TYPE_INVALID);
+#elif defined(USE_GDBUS)
+    GVariant *v = g_dbus_proxy_call_sync(priv->gnome_session_proxy,
+                "Uninhibit",
+                g_variant_new("(u)",
+                              priv->gnome_automount_inhibit_cookie),
+                G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
+    g_clear_pointer(&v, g_variant_unref);
 #endif
     if (error)
         handle_dbus_call_error("org.gnome.SessionManager.Uninhibit", &error);
-- 
1.8.4.2



More information about the Spice-devel mailing list