added new plugin: automount

This commit is contained in:
lars 2006-11-14 12:32:25 +00:00
parent f1f1c05226
commit 6ab39e3ffb
4 changed files with 125 additions and 0 deletions

View File

@ -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.
}
}

View File

@ -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')

View File

@ -0,0 +1,21 @@
<?cs # $Id$ ?>
<h3><?cs var:html_escape(Lang.Plugins.volume_automount.Title.AutoMountVolume) ?></h3>
<?cs if:!Data.CurrentDisk.encryption ?>
<p><?cs call:print_form_header("automount", "volume_automount") ?>
<input type="hidden" name="device" value="<?cs var:html_escape(Data.CurrentDisk.device) ?>" />
<?cs if:Data.Plugins.volume_automount.automount_setting ?>
<?cs var:html_escape(Lang.Plugins.volume_automount.Text.AutoIsOn) ?>
<input type="hidden" name="action" value="disable" />
<button type="submit"><?cs var:html_escape(Lang.Plugins.volume_automount.Button.AutoMountOff) ?></button>
<?cs else ?>
<?cs var:html_escape(Lang.Plugins.volume_automount.Text.AutoIsOff) ?>
<input type="hidden" name="action" value="enable" />
<button type="submit"><?cs var:html_escape(Lang.Plugins.volume_automount.Button.AutoMountOn) ?></button>
<?cs /if ?>
</form></p>
<?cs else ?>
<?cs call:hint("Plugins.volume_automount.NoAutoMountForEncryptedVolumes") ?>
<?cs /if ?>

View File

@ -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