From 6ab39e3ffb5df102bc78db9a26fadc68270edbeb Mon Sep 17 00:00:00 2001 From: lars Date: Tue, 14 Nov 2006 12:32:25 +0000 Subject: [PATCH] added new plugin: automount --- plugins/volume_automount/lang/en.hdf | 38 ++++++++++++++ plugins/volume_automount/unittests.py | 11 ++++ plugins/volume_automount/volume_automount.cs | 21 ++++++++ plugins/volume_automount/volume_automount.py | 55 ++++++++++++++++++++ 4 files changed, 125 insertions(+) create mode 100644 plugins/volume_automount/lang/en.hdf create mode 100644 plugins/volume_automount/unittests.py create mode 100644 plugins/volume_automount/volume_automount.cs create mode 100644 plugins/volume_automount/volume_automount.py diff --git a/plugins/volume_automount/lang/en.hdf b/plugins/volume_automount/lang/en.hdf new file mode 100644 index 0000000..7efa192 --- /dev/null +++ b/plugins/volume_automount/lang/en.hdf @@ -0,0 +1,38 @@ +Name = Automatic activation +Link = Automatic activation + +Title { + AutoMountVolume = Activate during startup +} + + +Button { + AutoMountOn = Enable automatic activation + AutoMountOff = Disable automatic activation +} + + +Text { + AutoIsOn = Currently automatic activation is enabled + AutoIsOff = Currently automatic activation is disabled +} + + +SuccessMessage { + AutoMountEnabled { + Title = Automatic activation enabled + Text = This volume will get activated during startup + } + + AutoMountDisabled { + Title = Automatic activation disabled + Text = This volume will not get activated during startup + } +} + +AdviceMessage { + NoAutoMountForEncryptedVolumes { + Text = Automatic activation is not possible for encrypted volumes. + } +} + diff --git a/plugins/volume_automount/unittests.py b/plugins/volume_automount/unittests.py new file mode 100644 index 0000000..5483807 --- /dev/null +++ b/plugins/volume_automount/unittests.py @@ -0,0 +1,11 @@ +import WebInterfaceTestClass + +class unittests(WebInterfaceTestClass.WebInterfaceTestClass): + + def test_read_form(self): + url = self.URL + "volume_automount?weblang=en&device=%2Fdev%2Floop1" + self.register_auth(url) + self.cmd.go(url) + self.cmd.find('automatic') + self.cmd.find('startup') + diff --git a/plugins/volume_automount/volume_automount.cs b/plugins/volume_automount/volume_automount.cs new file mode 100644 index 0000000..5c57ca9 --- /dev/null +++ b/plugins/volume_automount/volume_automount.cs @@ -0,0 +1,21 @@ + + +

+ + +

+ + + + + + + + + + +

+ + + + diff --git a/plugins/volume_automount/volume_automount.py b/plugins/volume_automount/volume_automount.py new file mode 100644 index 0000000..104ec8d --- /dev/null +++ b/plugins/volume_automount/volume_automount.py @@ -0,0 +1,55 @@ +import CryptoBoxPlugin +from CryptoBoxExceptions import * + + +class volume_automount(CryptoBoxPlugin.CryptoBoxPlugin): + + pluginCapabilities = [ "volume" ] + pluginVisibility = [ "properties" ] + requestAuth = False + rank = 80 + + trueString = "yes" + falseString = "no" + + + def doAction(self, action=None): + container = self.cbox.getContainer(self.device) + if action is None: + pass + elif action == "enable": + container.attributes["automount"] = self.trueString + self.hdf["Data.Success"] = "Plugins.volume_automount.AutoMountEnabled" + self.cbox.log.info("volume_automount: enabled for device '%s'" % self.device) + self.cbox.prefs.volumesDB.write() + elif action == "disable": + container.attributes["automount"] = self.falseString + self.hdf["Data.Success"] = "Plugins.volume_automount.AutoMountDisabled" + self.cbox.log.info("volume_automount: disabled for device '%s'" % self.device) + self.cbox.prefs.volumesDB.write() + else: + self.cbox.log.info("volume_automount: invalid action (%s)" % str(action)) + self.__prepareHDF() + return "volume_automount" + + + def getStatus(self): + return str(self.__isAutoMount()) + + + def __prepareHDF(self): + if self.__isAutoMount(): + self.hdf[self.hdf_prefix + "automount_setting"] = "1" + else: + self.hdf[self.hdf_prefix + "automount_setting"] = "0" + + + def __isAutoMount(self): + container = self.cbox.getContainer(self.device) + if not container: + return False + if container.attributes.has_key("automount"): + return container.attributes["automount"] == self.trueString + else: + return False +