[Spice-devel] [PATCH spice-gtk 5/6] spice-gtk-session: hookup automount inhibiting

Hans de Goede hdegoede at redhat.com
Tue Jun 26 01:32:38 PDT 2012


Inhibit automounting when usb-autoredirection is active.

Signed-off-by: Hans de Goede <hdegoede at redhat.com>
---
 gtk/spice-gtk-session-priv.h |    2 +-
 gtk/spice-gtk-session.c      |   23 ++++++++++++++++++++++-
 gtk/spice-widget.c           |    4 ++--
 3 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/gtk/spice-gtk-session-priv.h b/gtk/spice-gtk-session-priv.h
index fa4f002..aba6fe9 100644
--- a/gtk/spice-gtk-session-priv.h
+++ b/gtk/spice-gtk-session-priv.h
@@ -22,7 +22,7 @@
 
 G_BEGIN_DECLS
 
-void spice_gtk_session_request_usb_autoredir(SpiceGtkSession *self,
+void spice_gtk_session_request_auto_usbredir(SpiceGtkSession *self,
                                              gboolean state);
 gboolean spice_gtk_session_get_read_only(SpiceGtkSession *self);
 
diff --git a/gtk/spice-gtk-session.c b/gtk/spice-gtk-session.c
index 1df63f5..0a2c4a1 100644
--- a/gtk/spice-gtk-session.c
+++ b/gtk/spice-gtk-session.c
@@ -18,6 +18,7 @@
 
 #include <gtk/gtk.h>
 #include <spice/vd_agent.h>
+#include "desktop-integration.h"
 #include "spice-common.h"
 #include "spice-gtk-session.h"
 #include "spice-gtk-session-priv.h"
@@ -233,8 +234,14 @@ static void spice_gtk_session_set_property(GObject      *gobject,
     case PROP_AUTO_CLIPBOARD:
         s->auto_clipboard_enable = g_value_get_boolean(value);
         break;
-    case PROP_AUTO_USBREDIR:
+    case PROP_AUTO_USBREDIR: {
+        SpiceDesktopIntegration *desktop_int;
+        gboolean orig_value = s->auto_usbredir_enable;
+
         s->auto_usbredir_enable = g_value_get_boolean(value);
+        if (s->auto_usbredir_enable == orig_value)
+            break;
+
         if (s->auto_usbredir_reqs) {
             SpiceUsbDeviceManager *manager =
                 spice_usb_device_manager_get(s->session, NULL);
@@ -244,8 +251,15 @@ static void spice_gtk_session_set_property(GObject      *gobject,
 
             g_object_set(manager, "auto-connect", s->auto_usbredir_enable,
                          NULL);
+
+            desktop_int = spice_desktop_integration_get(s->session);
+            if (s->auto_usbredir_enable)
+                spice_desktop_integration_inhibit_automount(desktop_int);
+            else
+                spice_desktop_integration_uninhibit_automount(desktop_int);
         }
         break;
+    }
     default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, prop_id, pspec);
         break;
@@ -843,6 +857,7 @@ void spice_gtk_session_request_auto_usbredir(SpiceGtkSession *self,
     g_return_if_fail(SPICE_IS_GTK_SESSION(self));
 
     SpiceGtkSessionPrivate *s = self->priv;
+    SpiceDesktopIntegration *desktop_int;
     SpiceUsbDeviceManager *manager;
 
     if (state) {
@@ -864,6 +879,12 @@ void spice_gtk_session_request_auto_usbredir(SpiceGtkSession *self,
         return;
 
     g_object_set(manager, "auto-connect", state, NULL);
+
+    desktop_int = spice_desktop_integration_get(s->session);
+    if (state)
+        spice_desktop_integration_inhibit_automount(desktop_int);
+    else
+        spice_desktop_integration_uninhibit_automount(desktop_int);
 }
 
 /* ------------------------------------------------------------------ */
diff --git a/gtk/spice-widget.c b/gtk/spice-widget.c
index 8d13d4c..2ce8b1a 100644
--- a/gtk/spice-widget.c
+++ b/gtk/spice-widget.c
@@ -1097,7 +1097,7 @@ static gboolean focus_in_event(GtkWidget *widget, GdkEventFocus *focus G_GNUC_UN
     sync_keyboard_lock_modifiers(display);
     d->keyboard_have_focus = true;
     try_keyboard_grab(display);
-    spice_gtk_session_request_usb_autoredir(d->gtk_session,
+    spice_gtk_session_request_auto_usbredir(d->gtk_session,
                                             d->keyboard_have_focus);
 #ifdef WIN32
     focus_window = GDK_WINDOW_HWND(gtk_widget_get_window(widget));
@@ -1122,7 +1122,7 @@ static gboolean focus_out_event(GtkWidget *widget, GdkEventFocus *focus G_GNUC_U
 
     release_keys(display);
     d->keyboard_have_focus = false;
-    spice_gtk_session_request_usb_autoredir(d->gtk_session,
+    spice_gtk_session_request_auto_usbredir(d->gtk_session,
                                             d->keyboard_have_focus);
     return true;
 }
-- 
1.7.10.4



More information about the Spice-devel mailing list