[gnome-shell] Add support for inhibiting automount



commit 9745e97e14b49aca440b65d78b1683d6c06c56d0
Author: Hans de Goede <hdegoede redhat com>
Date:   Tue Jun 26 11:26:36 2012 +0200

    Add support for inhibiting automount
    
    When connecting to virtual machines with usb-device redirection, such as Spice
    enabled vms, automount may get in the way. Specifically if auto-usbredir is
    enabled in the vm-viewer, then the usbredir code and the automount code race
    for who gets to the device first.
    
    If the automount code wins the race this is a problem, since usbredir causes a
    device-disconnect (iow the usb mass storage driver sees an unplug), so in the
    end usbredir always wins, and we end up with a non clean potentially corrupt
    filesystem. Also see:
    https://bugzilla.redhat.com/show_bug.cgi?id=812972
    
    There for the need exists to be able to inhibit gnome-shell's automounting,
    since all other inhibits run through gnome-session, I've chosen to do the same
    for the automount-inhibiting. I've also submitted a patch to gnome-session to
    reserve flag value 16 for this, see bug 678595.
    
    This patch adds support to gnome-shell to honor this new inhibit flag.
    
    Signed-off-by: Hans de Goede <hdegoede redhat com>
    
    https://bugzilla.gnome.org/show_bug.cgi?id=678597

 js/misc/gnomeSession.js   |   10 ++++++++++
 js/ui/automountManager.js |   22 ++++++++++++++++++++++
 2 files changed, 32 insertions(+), 0 deletions(-)
---
diff --git a/js/misc/gnomeSession.js b/js/misc/gnomeSession.js
index 3428aab..dabd1b1 100644
--- a/js/misc/gnomeSession.js
+++ b/js/misc/gnomeSession.js
@@ -53,6 +53,16 @@ const SessionManagerIface = <interface name="org.gnome.SessionManager">
 <method name="CanShutdown">
     <arg type="b" direction="out" />
 </method>
+<method name="IsInhibited">
+    <arg type="u" direction="in" />
+    <arg type="b" direction="out" />
+</method>
+<signal name="InhibitorAdded">
+    <arg type="o" direction="out"/>
+</signal>
+<signal name="InhibitorRemoved">
+    <arg type="o" direction="out"/>
+</signal>
 </interface>;
 
 var SessionManagerProxy = Gio.DBusProxy.makeProxyWrapper(SessionManagerIface);
diff --git a/js/ui/automountManager.js b/js/ui/automountManager.js
index 12ba99c..9a6f7f6 100644
--- a/js/ui/automountManager.js
+++ b/js/ui/automountManager.js
@@ -10,6 +10,9 @@ const Shell = imports.gi.Shell;
 const Main = imports.ui.main;
 const ShellMountOperation = imports.ui.shellMountOperation;
 const ScreenSaver = imports.misc.screenSaver;
+const GnomeSession = imports.misc.gnomeSession;
+
+const GNOME_SESSION_AUTOMOUNT_INHIBIT = 16;
 
 // GSettings keys
 const SETTINGS_SCHEMA = 'org.gnome.desktop.media-handling';
@@ -79,6 +82,12 @@ const AutomountManager = new Lang.Class({
     _init: function() {
         this._settings = new Gio.Settings({ schema: SETTINGS_SCHEMA });
         this._volumeQueue = [];
+        this._session = new GnomeSession.SessionManager();
+        this._session.connectSignal('InhibitorAdded',
+                                    Lang.bind(this, this._InhibitorsChanged));
+        this._session.connectSignal('InhibitorRemoved',
+                                    Lang.bind(this, this._InhibitorsChanged));
+        this._inhibited = false;
 
         if (!haveSystemd())
             this.ckListener = new ConsoleKitManager();
@@ -108,6 +117,16 @@ const AutomountManager = new Lang.Class({
         Mainloop.idle_add(Lang.bind(this, this._startupMountAll));
     },
 
+    _InhibitorsChanged: function(object, senderName, [inhibtor]) {
+        this._session.IsInhibitedRemote(GNOME_SESSION_AUTOMOUNT_INHIBIT,
+            Lang.bind(this,
+                function(result, error) {
+                    if (!error) {
+                        this._inhibited = result[0];
+                    }
+                }));
+    },
+
     _screenSaverActiveChanged: function(object, senderName, [isActive]) {
         if (!isActive) {
             this._volumeQueue.forEach(Lang.bind(this, function(volume) {
@@ -219,6 +238,9 @@ const AutomountManager = new Lang.Class({
             }
         }
 
+        if (this._inhibited)
+            return;
+
         // Volume is already mounted, don't bother.
         if (volume.get_mount())
             return;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]