[gnome-shell/hotplug: 7/13] automount: only autorun volumes marked as allowed
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/hotplug: 7/13] automount: only autorun volumes marked as allowed
- Date: Tue, 12 Jul 2011 19:05:14 +0000 (UTC)
commit cbe20c007f0290a689363a95fe3a8d9a83b5f91f
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.
https://bugzilla.gnome.org/show_bug.cgi?id=653520
js/ui/automountManager.js | 36 +++++++++++++++++++++++++++++-------
js/ui/autorunManager.js | 2 +-
2 files changed, 30 insertions(+), 8 deletions(-)
---
diff --git a/js/ui/automountManager.js b/js/ui/automountManager.js
index c6678d1..7954161 100644
--- a/js/ui/automountManager.js
+++ b/js/ui/automountManager.js
@@ -12,6 +12,8 @@ const ScreenSaver = imports.misc.screenSaver;
const SETTINGS_SCHEMA = 'org.gnome.desktop.media-handling';
const SETTING_ENABLE_AUTOMOUNT = 'automount';
+const AUTORUN_EXPIRE_TIMEOUT_SECS = 10;
+
const ConsoleKitSessionIface = {
name: 'org.freedesktop.ConsoleKit.Session',
methods: [{ name: 'IsActive',
@@ -126,13 +128,6 @@ AutomountManager.prototype = {
},
_checkAndMountVolume: function(volume, checkSession, useMountOp) {
- if (!this._settings.get_boolean(SETTING_ENABLE_AUTOMOUNT))
- return;
-
- if (!volume.should_automount() ||
- !volume.can_mount())
- return;
-
if (checkSession) {
// if we're not in the current ConsoleKit session,
// don't attempt automount
@@ -147,16 +142,32 @@ AutomountManager.prototype = {
}
}
+ 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);
+
+ return;
+ }
+
// TODO: mount op
this._mountVolume(volume, null);
},
_mountVolume: function(volume, operation) {
+ this._allowAutorun(volume);
volume.mount(0, operation, null,
Lang.bind(this, this._onVolumeMounted));
},
_onVolumeMounted: function(volume, res) {
+ this._allowAutorunExpire(volume);
+
try {
volume.mount_finish(res);
} catch (e) {
@@ -170,5 +181,16 @@ AutomountManager.prototype = {
this._volumeQueue.filter(function(element) {
return (element != volume);
});
+ },
+
+ _allowAutorun: function(volume) {
+ volume.allowAutorun = true;
+ },
+
+ _allowAutorunExpire: function(volume) {
+ Mainloop.timeout_add_seconds(AUTORUN_EXPIRE_TIMEOUT_SECS, function() {
+ volume.allowAutorun = false;
+ return false;
+ });
}
}
diff --git a/js/ui/autorunManager.js b/js/ui/autorunManager.js
index 9b755b2..f2e3964 100644
--- a/js/ui/autorunManager.js
+++ b/js/ui/autorunManager.js
@@ -30,7 +30,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]