[gnome-shell/hotplug: 9/21] automount: only autorun volumes marked as allowed



commit 9ec4c46d545243a2fe1aed1bfa272f2a789dfdaa
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Wed Jun 22 09:45:03 2011 -0400

    automount: only autorun volumes marked as allowed
    
    Port code from g-s-d to mark volumes as allowed for autorun, and check
    for it when running the notification.

 js/ui/automountManager.js |   27 +++++++++++++++++++++++----
 js/ui/autorunManager.js   |    2 +-
 2 files changed, 24 insertions(+), 5 deletions(-)
---
diff --git a/js/ui/automountManager.js b/js/ui/automountManager.js
index d6dcadc..0f31aff 100644
--- a/js/ui/automountManager.js
+++ b/js/ui/automountManager.js
@@ -200,12 +200,18 @@ AutomountManager.prototype = {
     },
 
     _checkAndMountVolume: function(volume) {
-        if (!this._settings.get_boolean(SETTING_ENABLE_AUTOMOUNT))
-            return;
+        if (!this._settings.get_boolean(SETTING_ENABLE_AUTOMOUNT) ||
+            !volume.should_automount() ||
+            !volume.can_mount()) {
+	    // allow the autorun to run anyway; this can happen if the
+            // mount gets added programmatically later, even if 
+            // should_automount() or can_mount() are false, like for
+            // blank optical media.
+            this._allowAutorun(volume);
+            this._allowAutorunExpire(volume);
 
-        if (!volume.should_automount() ||
-            !volume.can_mount())
             return;
+        }
 
         // if we're not in the current ConsoleKit session,
         // don't attempt automount
@@ -229,6 +235,8 @@ AutomountManager.prototype = {
     },
 
     _onVolumeMounted: function(volume, res) {
+        this._allowAutorunExpire(volume);
+
         try {
             volume.mount_finish(res);
         } catch (e) {
@@ -243,5 +251,16 @@ AutomountManager.prototype = {
             this._volumeQueue.filter(function(element) {
                 return (element != volume);
             });
+    },
+
+    _allowAutorun: function(volume) {
+        volume.allowAutorun = true;
+    },
+
+    _allowAutorunExpire: function(volume) {
+        Mainloop.timeout_add_seconds(10, function() {
+            volume.allowAutorun = false;
+            return false;
+        });
     }
 }
\ No newline at end of file
diff --git a/js/ui/autorunManager.js b/js/ui/autorunManager.js
index 39ac9f3..224a14d 100644
--- a/js/ui/autorunManager.js
+++ b/js/ui/autorunManager.js
@@ -23,7 +23,7 @@ function ignoreAutorunForMount(mount) {
     let volume = mount.get_volume();
 
     if ((root.is_native() && !isMountRootHidden(root)) ||
-        (volume && volume.should_automount()))
+        (volume && volume.allowAutorun && volume.should_automount()))
         return false;
 
     return true;



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