improved detection of 'active' plugin for marking in the main menu
plugin plugin_manager: prevent browser from caching repeatitive actions plugin plugin_manager: add support for properties/volume visibility plugins: moved message handling to central header file (templates/header.cs) splitted 'volume_props' into 'volume_rename' and 'volume_chpasswd' volume_props: turned into a container for small property changes renamed 'format_fs' to 'volume_format_fs' moved inclusion of 'show_volume_[header|footer].cs' to central header file
This commit is contained in:
parent
fc67727692
commit
405f6b90fa
|
@ -2,8 +2,6 @@
|
|||
|
||||
<h1><?cs var:html_escape(Lang.Plugins.date.Title.ConfigDate) ?></h1>
|
||||
|
||||
<?cs call:handle_messages() ?>
|
||||
|
||||
<?cs call:print_form_header("set_date", "date") ?>
|
||||
|
||||
<p><label for="date"><?cs var:html_escape(Lang.Plugins.date.Text.Date) ?>: </label><br/>
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
<h1><?cs var:html_escape(Lang.Plugins.disks.Title.Disks) ?></h1>
|
||||
|
||||
<?cs call:handle_messages() ?>
|
||||
|
||||
<?cs # TODO: add no-disks-available warning ?>
|
||||
|
||||
<?cs if:subcount(Data.Disks) == 0 ?>
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
<?cs # $Id$ ?>
|
||||
|
||||
<?cs include:Settings.TemplateDir + "/show_volume_header.cs" ?>
|
||||
|
||||
<h2><?cs var:html_escape(Lang.Plugins.format_fs.Title.Format) ?></h2>
|
||||
|
||||
<?cs call:handle_messages() ?>
|
||||
|
||||
<?cs if:Data.CurrentDisk.active ?>
|
||||
<?cs call:hint("Plugins.format_fs.UnmountBeforeInit") ?>
|
||||
<?cs else ?>
|
||||
|
||||
<?cs call:hint("Plugins.format_fs.FormatWarning") ?>
|
||||
|
||||
<?cs call:print_form_header("set_type", "format_fs") ?>
|
||||
<p><label for="fs_type"><?cs var:html_escape(Lang.Plugins.format_fs.Text.FSType)
|
||||
?>: </label><select name="fs_type" id="fs_type" size="0">
|
||||
<?cs each:x = Data.Plugins.format_fs.fs_types ?>
|
||||
<option <?cs if:x == "windows" ?>selected="selected"<?cs /if ?>><?cs var:html_escape(x) ?></option><?cs /each ?>
|
||||
</select></p>
|
||||
|
||||
<p><label for="container_type"><?cs var:html_escape(Lang.Plugins.format_fs.Text.IsEncrypted)
|
||||
?>: </label><select name="container_type" id="container_type">
|
||||
<option value="luks" <?cs if:Data.Plugins.format_fs.container_type != "plain" ?>selected="selected"<?cs /if ?>><?cs var:html_escape(Lang.Plugins.format_fs.Text.Yes) ?></option>
|
||||
<option value="plain" <?cs if:Data.Plugins.format_fs.container_type == "plain" ?>selected="selected"<?cs /if ?>><?cs var:html_escape(Lang.Plugins.format_fs.Text.No) ?></option>
|
||||
</select></p>
|
||||
|
||||
<p><input type="checkbox" name="confirm" value="1" id="confirm" /><label for="confirm"><?cs var:html_escape(Lang.Plugins.format_fs.Text.Confirm) ?></label></p>
|
||||
|
||||
<p><input type="hidden" name="device" value="<?cs var:Data.CurrentDisk.device ?>" />
|
||||
<input type="hidden" name="store" value="step1" />
|
||||
<button type="submit"><?cs var:html_escape(Lang.Plugins.format_fs.Button.Format) ?></button></p>
|
||||
</form>
|
||||
|
||||
<?cs /if ?>
|
||||
|
||||
<?cs include:Settings.TemplateDir + "/show_volume_footer.cs" ?>
|
|
@ -1,32 +0,0 @@
|
|||
<?cs # $Id$ ?>
|
||||
|
||||
<?cs include:Settings.TemplateDir + "/show_volume_header.cs" ?>
|
||||
|
||||
<h2><?cs var:html_escape(Lang.Plugins.format_fs.Title.Format) ?></h2>
|
||||
|
||||
<?cs call:handle_messages() ?>
|
||||
|
||||
<?cs if:Data.CurrentDisk.active ?>
|
||||
<?cs call:hint("Plugins.format_fs.UnmountBeforeInit") ?>
|
||||
<?cs else ?>
|
||||
|
||||
<?cs call:hint("Plugins.format_fs.FormatWarning") ?>
|
||||
|
||||
<?cs call:print_form_header("set_luks", "format_fs") ?>
|
||||
<p><?cs var:html_escape(Lang.Plugins.format_fs.Text.FSType) ?>: <?cs var:html_escape(Data.Plugins.format_fs.fs_type) ?></p>
|
||||
<p><?cs var:html_escape(Lang.Plugins.format_fs.Text.IsEncrypted) ?>: <?cs if:Data.Plugins.format_fs.container_type == "luks" ?><?cs
|
||||
var:html_escape(Lang.Plugins.format_fs.Text.Yes) ?><?cs else ?><?cs
|
||||
var:html_escape(Lang.Plugins.format_fs.Text.No) ?><?cs /if ?></p>
|
||||
|
||||
<p><label for="crypto_password"><?cs var:html_escape(Lang.Text.EnterNewPassword) ?>: </label> <input type="password" id="crypto_password" name="crypto_password" /></p>
|
||||
<p><label for="crypto_password2"><?cs var:html_escape(Lang.Text.EnterSamePassword) ?>: </label> <input type="password" id="crypto_password2" name="crypto_password2" /></p>
|
||||
<p><input type="hidden" name="device" value="<?cs var:Data.CurrentDisk.device ?>" />
|
||||
<input type="hidden" name="fs_type" value="<?cs var:html_escape(Data.Plugins.format_fs.fs_type) ?>" />
|
||||
<input type="hidden" name="container_type" value="<?cs var:html_escape(Data.Plugins.format_fs.container_type) ?>" />
|
||||
<input type="hidden" name="store" value="step2" />
|
||||
<button type="submit"><?cs var:html_escape(Lang.Plugins.format_fs.Button.Format) ?></button></p>
|
||||
</form>
|
||||
|
||||
<?cs /if ?>
|
||||
|
||||
<?cs include:Settings.TemplateDir + "/show_volume_footer.cs" ?>
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
<div id="doc">
|
||||
|
||||
<?cs call:handle_messages() ?>
|
||||
|
||||
<?cs include:Settings.DocDir + '/' + Settings.Language + '/' + Data.Plugins.help.Page + '.html' ?>
|
||||
|
||||
</div>
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
<h1><?cs var:html_escape(Lang.Plugins.language_selection.Title.Language) ?></h1>
|
||||
|
||||
<?cs call:handle_messages() ?>
|
||||
|
||||
<div id="lang">
|
||||
<ul>
|
||||
<?cs loop:index = #0, subcount(Data.Languages)-1, #1 ?>
|
||||
|
|
|
@ -6,8 +6,6 @@
|
|||
|
||||
<h1><?cs var:html_escape(Lang.Plugins.network.Title.Network) ?></h1>
|
||||
|
||||
<?cs call:handle_messages() ?>
|
||||
|
||||
<?cs call:print_form_header("set_ip", "network") ?>
|
||||
|
||||
<p><label for="ip"><?cs var:html_escape(Lang.Plugins.network.Text.IP) ?>: </label>
|
||||
|
|
|
@ -4,8 +4,6 @@
|
|||
|
||||
<h1><?cs var:html_escape(Lang.Plugins.partition.Title.Partition) ?></h1>
|
||||
|
||||
<?cs call:handle_messages() ?>
|
||||
|
||||
<?cs if:subcount(Data.Plugins.partition.BlockDevices) > 0 ?>
|
||||
|
||||
<?cs call:print_form_header("select_device", "partition") ?>
|
||||
|
|
|
@ -4,8 +4,6 @@
|
|||
|
||||
<h1><?cs var:html_escape(Lang.Plugins.partition.Title.Partition) ?></h1>
|
||||
|
||||
<?cs call:handle_messages() ?>
|
||||
|
||||
<div align="center">
|
||||
<table class="partition">
|
||||
<?cs if:(Data.Plugins.partition.availSize > 0) || (subcount(Data.Plugins.partition.Parts) > 0) ?>
|
||||
|
|
|
@ -4,8 +4,6 @@
|
|||
|
||||
<h1><?cs var:html_escape(Lang.Plugins.partition.Title.Partition) ?></h1>
|
||||
|
||||
<?cs call:handle_messages() ?>
|
||||
|
||||
<p><?cs var:html_escape(Lang.Plugins.partition.Text.ProgressInfo) ?>
|
||||
<ul>
|
||||
<?cs loop: x = #0, subcount(Data.Plugins.partition.Parts)-1, #1 ?>
|
||||
|
|
|
@ -57,9 +57,8 @@ Language file structure:
|
|||
|
||||
|
||||
Clearsilver template:
|
||||
- should start with a "<h1>" tag (volume plugins: "h2")
|
||||
- should start with a "<h1>" tag (volume plugins: "h3")
|
||||
- links to the plugin (e.g. in form headers) could look like the following:
|
||||
<?cs call:link("PLUGINNAME",'','','','') ?>
|
||||
- volume plugins must include "show_volume_[header|footer]" (see examples)
|
||||
|
||||
|
||||
|
|
|
@ -16,9 +16,10 @@ Button {
|
|||
Text {
|
||||
PluginName = Plugin
|
||||
PluginRank = Order
|
||||
PluginEnabled = Enabled?
|
||||
RequestsAuth = Requires admin?
|
||||
InMenu = Main menu
|
||||
InPreferences = Preferences
|
||||
InVolumeRegister = Register
|
||||
InVolumeProperties = Properties
|
||||
WhereVisible = Where visible?
|
||||
}
|
||||
|
|
|
@ -23,17 +23,26 @@
|
|||
|
||||
<h1><?cs var:html_escape(Lang.Plugins.plugin_manager.Title.PluginManager) ?></h1>
|
||||
|
||||
<?cs call:handle_messages() ?>
|
||||
|
||||
<?cs # just as a sidenote: we add the strange 'x' argument below to prevent the browser
|
||||
from thinking, that it can use the cached page again, if a user calls the "down" or
|
||||
"up" action twice for the same plugin ?>
|
||||
|
||||
<h2><a name="volume_plugins"/><?cs var:html_escape(Lang.Plugins.plugin_manager.Title.VolumePlugins) ?></h2>
|
||||
|
||||
<?cs call:print_form_header("manage_plugins", "plugin_manager") ?>
|
||||
|
||||
<table class="plugin_list">
|
||||
<tr>
|
||||
<th></th>
|
||||
<th colspan="2"><?cs var:html_escape(Lang.Plugins.plugin_manager.Text.WhereVisible) ?></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?cs var:html_escape(Lang.Plugins.plugin_manager.Text.PluginName) ?></th>
|
||||
<th><?cs var:html_escape(Lang.Plugins.plugin_manager.Text.PluginEnabled) ?></th>
|
||||
<th><?cs var:html_escape(Lang.Plugins.plugin_manager.Text.InVolumeRegister) ?></th>
|
||||
<th><?cs var:html_escape(Lang.Plugins.plugin_manager.Text.InVolumeProperties) ?></th>
|
||||
<th><?cs var:html_escape(Lang.Plugins.plugin_manager.Text.RequestsAuth) ?></th>
|
||||
<th><?cs var:html_escape(Lang.Plugins.plugin_manager.Text.PluginRank) ?></th>
|
||||
</tr>
|
||||
|
@ -46,11 +55,12 @@ each:x = Settings.PluginList ?><?cs if:(x.Rank == index) && x.Types.volume
|
|||
?><?cs set: run_counter = run_counter + 1 ?><tr>
|
||||
<td style="text-align:left"><a name="<?cs var:html_escape(name(x)) ?>"><?cs var:html_escape(x.Name) ?></a></td>
|
||||
<td><input type="checkbox" name="<?cs var:name(x) ?>_visible_volume" <?cs if:x.Visible.volume ?>checked="checked"<?cs /if ?> /></td>
|
||||
<td><input type="checkbox" name="<?cs var:name(x) ?>_visible_properties" <?cs if:x.Visible.properties ?>checked="checked"<?cs /if ?> /></td>
|
||||
<td><input type="checkbox" name="<?cs var:name(x) ?>_auth" <?cs if:x.RequestAuth ?>checked="checked"<?cs /if ?> /></td>
|
||||
<td>
|
||||
<?cs if:run_counter != all_count ?><a href="<?cs call:link("plugin_manager", "plugin_name", name(x), "action", "down") ?>#volume_plugins">
|
||||
<?cs if:run_counter != all_count ?><a href="<?cs call:link("plugin_manager", "plugin_name", name(x), "action", "down") ?>&x=<?cs var:run_counter ?>#volume_plugins">
|
||||
<img src="icons/plugin_manager?image=tango-go-down.png" alt="<?cs var:html_escape(Lang.Plugins.plugin_manager.Button.Down) ?>" title="<?cs var:html_escape(Lang.Plugins.plugin_manager.Button.Down) ?>" /></a><?cs /if ?>
|
||||
<?cs if:run_counter != 1 ?><a href="<?cs call:link("plugin_manager", "plugin_name", name(x), "action", "up") ?>#volume_plugins" >
|
||||
<?cs if:run_counter != 1 ?><a href="<?cs call:link("plugin_manager", "plugin_name", name(x), "action", "up") ?>&x=<?cs var:run_counter ?>#volume_plugins" >
|
||||
<img src="icons/plugin_manager?image=tango-go-up.png" alt="<?cs var:html_escape(Lang.Plugins.plugin_manager.Button.Up) ?>" title="<?cs var:html_escape(Lang.Plugins.plugin_manager.Button.Up) ?>" /></a><?cs /if ?>
|
||||
<input type="hidden" name="<?cs var:html_escape(name(x)) ?>_rank" value="<?cs var:html_escape(x.Rank) ?>" />
|
||||
<input type="hidden" name="<?cs var:name(x) ?>_listed" value="1" /></td>
|
||||
|
@ -87,9 +97,9 @@ each:x = Settings.PluginList ?><?cs if:(x.Rank == index) && !x.Types.volume
|
|||
<td><input type="checkbox" name="<?cs var:name(x) ?>_visible_preferences" <?cs if:x.Visible.preferences ?>checked="checked"<?cs /if ?> /></td>
|
||||
<td><input type="checkbox" name="<?cs var:name(x) ?>_auth" <?cs if:x.RequestAuth ?>checked="checked"<?cs /if ?> /></td>
|
||||
<td>
|
||||
<?cs if:run_counter != all_count ?><a href="<?cs call:link("plugin_manager", "plugin_name", name(x), "action", "down") ?>#system_plugins">
|
||||
<?cs if:run_counter != all_count ?><a href="<?cs call:link("plugin_manager", "plugin_name", name(x), "action", "down") ?>&x=<?cs var:run_counter ?>#system_plugins">
|
||||
<img src="icons/plugin_manager?image=tango-go-down.png" alt="<?cs var:html_escape(Lang.Plugins.plugin_manager.Button.Down) ?>" title="<?cs var:html_escape(Lang.Plugins.plugin_manager.Button.Down) ?>" /></a><?cs /if ?>
|
||||
<?cs if:run_counter != 1 ?><a href="<?cs call:link("plugin_manager", "plugin_name", name(x), "action", "up") ?>#<?cs var:html_escape(name(x)) ?>" >
|
||||
<?cs if:run_counter != 1 ?><a href="<?cs call:link("plugin_manager", "plugin_name", name(x), "action", "up") ?>&x=<?cs var:run_counter ?>#<?cs var:html_escape(name(x)) ?>" >
|
||||
<img src="icons/plugin_manager?image=tango-go-up.png" alt="<?cs var:html_escape(Lang.Plugins.plugin_manager.Button.Up) ?>" title="<?cs var:html_escape(Lang.Plugins.plugin_manager.Button.Up) ?>" /></a><?cs /if ?>
|
||||
<input type="hidden" name="<?cs var:html_escape(name(x)) ?>_rank" value="<?cs var:html_escape(x.Rank) ?>" />
|
||||
<input type="hidden" name="<?cs var:name(x) ?>_listed" value="1" /></td>
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
<h1><?cs var:html_escape(Lang.Plugins.shutdown.Title.Shutdown) ?></h1>
|
||||
|
||||
<?cs call:handle_messages() ?>
|
||||
|
||||
<div class="plugin_system">
|
||||
<a href="<?cs call:link('shutdown','type','shutdown','','') ?>">
|
||||
<img src="<?cs call:link('icons/shutdown','image','gnome-shutdown.png','','')
|
||||
|
|
|
@ -2,5 +2,3 @@
|
|||
|
||||
<h1><?cs var:html_escape(Lang.Plugins.shutdown.Title.ProgressReboot) ?></h1>
|
||||
|
||||
<?cs call:handle_messages() ?>
|
||||
|
||||
|
|
|
@ -2,5 +2,3 @@
|
|||
|
||||
<h1><?cs var:html_escape(Lang.Plugins.shutdown.Title.ProgressShutdown) ?></h1>
|
||||
|
||||
<?cs call:handle_messages() ?>
|
||||
|
||||
|
|
|
@ -2,13 +2,17 @@
|
|||
|
||||
<h1><?cs var:html_escape(Lang.Plugins.system_preferences.Title.Preferences) ?></h1>
|
||||
|
||||
<?cs call:handle_messages() ?>
|
||||
|
||||
<?cs # sort the Plugins - using the most stupid way :) ?>
|
||||
<?cs loop: order = #0, #100, #1
|
||||
?><?cs # plugins ?><?cs each:x = Settings.PluginList
|
||||
?><?cs if:x.Types.system && x.Visible.preferences && x.Rank == order ?>
|
||||
<?cs call:show_plugin(name(x), 'system') ?><?cs /if ?><?cs
|
||||
<div class="plugin_system ?>"><a href="<?cs
|
||||
call:link(name(x),'','','','') ?>" title="<?cs
|
||||
var:html_escape(x.Link) ?>"><img src="<?cs
|
||||
call:link('icons/' + name(x), '','','','') ?>" alt="<?cs
|
||||
var:html_escape('icon: ' + x.Name) ?>" /><br/><?cs
|
||||
var:html_escape(x.Link) ?></a></div><?cs
|
||||
/if ?><?cs
|
||||
/each ?><?cs
|
||||
/loop ?>
|
||||
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
|
||||
<h1><?cs var:html_escape(Lang.Plugins.user_manager.Title.UserManager) ?></h1>
|
||||
|
||||
<?cs call:handle_messages() ?>
|
||||
|
||||
|
||||
|
||||
<h2><?cs var:html_escape(Lang.Plugins.user_manager.Title.AddUser) ?></h2>
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
Name = Change volume password
|
||||
Link = Password
|
||||
|
||||
Title {
|
||||
ChangePassword = Change the password of this volume
|
||||
}
|
||||
|
||||
|
||||
Button {
|
||||
ChangePassword = Change password
|
||||
FormatContainer = Format volume
|
||||
}
|
||||
|
||||
|
||||
AdviceMessage {
|
||||
FormatForEncryptionSupport {
|
||||
Text = This volume is not encrypted. If you want to turn on encryption, then you have to format the volume. Beware: this will destroy all data of this container.
|
||||
Link.Text = Format this volume
|
||||
Link.Rel = volume_format_fs
|
||||
}
|
||||
|
||||
|
||||
SuccessMessage {
|
||||
PasswordChange {
|
||||
Title = Password changed
|
||||
Text = The password of this volume was changed successfully.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
WarningMessage {
|
||||
PasswordChange {
|
||||
Title = Could not change password
|
||||
Text = The password of this volume could not be changed - sorry!
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
import WebInterfaceTestClass
|
||||
|
||||
class unittests(WebInterfaceTestClass.WebInterfaceTestClass):
|
||||
|
||||
def test_read_form(self):
|
||||
url = self.URL + "volume_chpasswd?weblang=en&device=%2Fdev%2Floop1"
|
||||
self.register_auth(url)
|
||||
self.cmd.go(url)
|
||||
self.cmd.find('hange')
|
||||
self.cmd.find('password')
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
<?cs # $Id$ ?>
|
||||
|
||||
<h3><?cs var:html_escape(Lang.Plugins.volume_chpasswd.Title.ChangePassword) ?></h3>
|
||||
|
||||
<?cs # show password change form only for encrypted volumes ?>
|
||||
<?cs if:Data.CurrentDisk.encryption ?>
|
||||
<?cs call:print_form_header("set_password", "volume_chpasswd") ?>
|
||||
<table>
|
||||
<tr>
|
||||
<td align="right"><label for="old_pw"><?cs var:html_escape(Lang.Text.EnterCurrentPassword) ?>: </label></td>
|
||||
<td><input type="password" name="old_pw" tabindex="20" size="15" id="old_pw" /></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right"><label for="new_pw"><?cs var:html_escape(Lang.Text.EnterNewPassword) ?>: </label></td>
|
||||
<td><input type="password" name="new_pw" tabindex="21" size="15" id="new_pw" /></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right"><label for="new_pw2"><?cs var:html_escape(Lang.Text.EnterSamePassword) ?>: </label></td>
|
||||
<td><input type="password" name="new_pw2" tabindex="22" size="15" id="new_pw2" /></td>
|
||||
<td>
|
||||
<input type="hidden" name="device" value="<?cs var:html_escape(Data.CurrentDisk.device) ?>" />
|
||||
<input type="hidden" name="store" value="change_pw" />
|
||||
<button type="submit" tabindex="23"><?cs var:html_escape(Lang.Plugins.volume_chpasswd.Button.ChangePassword) ?></button>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
<?cs else ?>
|
||||
<?cs call:hint("Plugins.volume_chpasswd.FormatForEncryptionSupport") ?>
|
||||
<?cs /if ?>
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
import CryptoBoxPlugin
|
||||
from CryptoBoxExceptions import *
|
||||
|
||||
|
||||
class volume_chpasswd(CryptoBoxPlugin.CryptoBoxPlugin):
|
||||
|
||||
pluginCapabilities = [ "volume" ]
|
||||
pluginVisibility = [ "properties" ]
|
||||
requestAuth = False
|
||||
rank = 70
|
||||
|
||||
|
||||
def doAction(self, store=None, old_pw=None, new_pw=None, new_pw2=None):
|
||||
self.container = self.cbox.getContainer(self.device)
|
||||
if not self.container:
|
||||
return None
|
||||
elif store == "change_pw":
|
||||
return self.__changePassword(old_pw, new_pw, new_pw2)
|
||||
elif not store:
|
||||
return "volume_chpasswd"
|
||||
else:
|
||||
self.cbox.log.info("plugin 'volume_chpasswd' - unknown action: %s" % store)
|
||||
return "volume_chpasswd"
|
||||
|
||||
|
||||
def getStatus(self):
|
||||
return "TODO"
|
||||
|
||||
|
||||
def __changePassword(self, old_pw, new_pw, new_pw2):
|
||||
if not old_pw:
|
||||
self.hdf["Data.Warning"] = "EmptyPassword"
|
||||
elif not new_pw:
|
||||
self.hdf["Data.Warning"] = "EmptyNewPassword"
|
||||
elif new_pw != new_pw2:
|
||||
self.hdf["Data.Warning"] = "DifferentPasswords"
|
||||
elif old_pw == new_pw:
|
||||
## do nothing
|
||||
pass
|
||||
else:
|
||||
try:
|
||||
self.container.changePassword(old_pw, new_pw)
|
||||
except CBInvalidType, errMsg:
|
||||
self.cbox.log.info("plugin 'volume_chpasswd' - cannot change passphrase for non-encrypted container (%s): %s" % (self.device, errMsg))
|
||||
except CBVolumeIsActive:
|
||||
self.hdf["Data.Warning"] = "VolumeMayNotBeMounted"
|
||||
except CBChangePasswordError, errMsg:
|
||||
self.cbox.log.warn("plugin 'volume_chpasswd' - cannot change password for device (%s): %s" % (self.device, errMsg))
|
||||
self.hdf["Data.Warning"] = "Plugins.volume_chpasswd.PasswordChange"
|
||||
else:
|
||||
self.hdf["Data.Success"] = "Plugins.volume_chpasswd.PasswordChange"
|
||||
return "volume_chpasswd"
|
||||
|
|
@ -1,10 +1,6 @@
|
|||
<?cs # $Id$ ?>
|
||||
|
||||
<?cs include:Settings.TemplateDir + "/show_volume_header.cs" ?>
|
||||
|
||||
<h2><?cs var:html_escape(Lang.Plugins.volume_details.Title.Details) ?></h2>
|
||||
|
||||
<?cs call:handle_messages() ?>
|
||||
<h3><?cs var:html_escape(Lang.Plugins.volume_details.Title.Details) ?></h3>
|
||||
|
||||
<ul>
|
||||
<li><?cs var:html_escape(Lang.Text.ContainerName) ?>: <?cs var:html_escape(Data.CurrentDisk.name) ?></li>
|
||||
|
@ -18,4 +14,3 @@
|
|||
<?cs /if ?>
|
||||
</ul>
|
||||
|
||||
<?cs include:Settings.TemplateDir + "/show_volume_footer.cs" ?>
|
||||
|
|
|
@ -25,7 +25,7 @@ AdviceMessage {
|
|||
Link.Attr1.name = action
|
||||
Link.Attr1.value = umount
|
||||
Link.Attr2.name = redirect
|
||||
Link.Attr2.value = format_fs
|
||||
Link.Attr2.value = volume_format_fs
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 4.8 KiB After Width: | Height: | Size: 4.8 KiB |
Before Width: | Height: | Size: 6.2 KiB After Width: | Height: | Size: 6.2 KiB |
|
@ -3,7 +3,7 @@ import WebInterfaceTestClass
|
|||
class unittests(WebInterfaceTestClass.WebInterfaceTestClass):
|
||||
|
||||
def test_read_form(self):
|
||||
url = self.URL + "format_fs?weblang=en&device=%2Fdev%2Floop1"
|
||||
url = self.URL + "volume_format_fs?weblang=en&device=%2Fdev%2Floop1"
|
||||
self.register_auth(url)
|
||||
self.cmd.go(url)
|
||||
self.cmd.find('Initializing filesystem')
|
|
@ -0,0 +1,32 @@
|
|||
<?cs # $Id$ ?>
|
||||
|
||||
<h3><?cs var:html_escape(Lang.Plugins.volume_format_fs.Title.Format) ?></h3>
|
||||
|
||||
<?cs if:Data.CurrentDisk.active ?>
|
||||
<?cs call:hint("Plugins.volume_format_fs.UnmountBeforeInit") ?>
|
||||
<?cs else ?>
|
||||
|
||||
<?cs call:hint("Plugins.volume_format_fs.FormatWarning") ?>
|
||||
|
||||
<?cs call:print_form_header("set_type", "volume_format_fs") ?>
|
||||
<p><label for="fs_type"><?cs var:html_escape(Lang.Plugins.volume_format_fs.Text.FSType)
|
||||
?>: </label><select name="fs_type" id="fs_type" size="0">
|
||||
<?cs each:x = Data.Plugins.volume_format_fs.fs_types ?>
|
||||
<option <?cs if:x == "windows" ?>selected="selected"<?cs /if ?>><?cs var:html_escape(x) ?></option><?cs /each ?>
|
||||
</select></p>
|
||||
|
||||
<p><label for="container_type"><?cs var:html_escape(Lang.Plugins.volume_format_fs.Text.IsEncrypted)
|
||||
?>: </label><select name="container_type" id="container_type">
|
||||
<option value="luks" <?cs if:Data.Plugins.volume_format_fs.container_type != "plain" ?>selected="selected"<?cs /if ?>><?cs var:html_escape(Lang.Plugins.volume_format_fs.Text.Yes) ?></option>
|
||||
<option value="plain" <?cs if:Data.Plugins.volume_format_fs.container_type == "plain" ?>selected="selected"<?cs /if ?>><?cs var:html_escape(Lang.Plugins.volume_format_fs.Text.No) ?></option>
|
||||
</select></p>
|
||||
|
||||
<p><input type="checkbox" name="confirm" value="1" id="confirm" /><label for="confirm"><?cs var:html_escape(Lang.Plugins.volume_format_fs.Text.Confirm) ?></label></p>
|
||||
|
||||
<p><input type="hidden" name="device" value="<?cs var:Data.CurrentDisk.device ?>" />
|
||||
<input type="hidden" name="store" value="step1" />
|
||||
<button type="submit"><?cs var:html_escape(Lang.Plugins.volume_format_fs.Button.Format) ?></button></p>
|
||||
</form>
|
||||
|
||||
<?cs /if ?>
|
||||
|
|
@ -0,0 +1,96 @@
|
|||
import CryptoBoxPlugin
|
||||
from CryptoBoxExceptions import *
|
||||
|
||||
class volume_format_fs(CryptoBoxPlugin.CryptoBoxPlugin):
|
||||
|
||||
pluginCapabilities = [ "volume" ]
|
||||
pluginVisibility = [ "volume" ]
|
||||
requestAuth = True
|
||||
rank = 60
|
||||
|
||||
## map filesystem types to the appropriate arguments for 'mkfs'
|
||||
fsTypes = {
|
||||
"windows": "vfat",
|
||||
"linux": "ext3" }
|
||||
|
||||
containerTypes = [ "luks", "plain" ]
|
||||
|
||||
|
||||
def doAction(self, store=None, fs_type="windows", container_type="luks", crypto_password=None, crypto_password2=None, confirm=None):
|
||||
if not fs_type in self.fsTypes.keys():
|
||||
self.cbox.info
|
||||
return "format_volume"
|
||||
self.hdf[self.hdf_prefix + "fs_type"] = fs_type
|
||||
self.hdf[self.hdf_prefix + "container_type"] = container_type
|
||||
for t in self.fsTypes.keys():
|
||||
self.hdf[self.hdf_prefix + "fs_types." + t] = t
|
||||
if store == "step1":
|
||||
if not confirm:
|
||||
self.cbox.log.warn("missing confirmation for formatting of filesystem: %s" % self.device)
|
||||
self.hdf["Data.Warning"] = "Plugins.volume_format_fs.FormatNotConfirmed"
|
||||
return "volume_format"
|
||||
if container_type == "luks":
|
||||
return "volume_format_luks"
|
||||
elif container_type == "plain":
|
||||
return self.__format_plain(fs_type)
|
||||
elif store == "step2":
|
||||
if container_type == "luks":
|
||||
return self.__format_luks(fs_type, crypto_password, crypto_password2)
|
||||
else:
|
||||
self.cbox.log.info("invalid input value for 'container_type': %s" % container_type)
|
||||
return "volume_format"
|
||||
elif store:
|
||||
self.cbox.log.info("invalid input value for 'store': %s" % store)
|
||||
return "volume_format"
|
||||
else:
|
||||
return "volume_format"
|
||||
|
||||
|
||||
def getStatus(self):
|
||||
return "no status"
|
||||
|
||||
|
||||
def __format_plain(self, fsType):
|
||||
try:
|
||||
container = self.cbox.getContainer(self.device)
|
||||
container.create(container.Types["plain"])
|
||||
except CBVolumeIsActive:
|
||||
self.hdf["Data.Warning"] = "VolumeMayNotBeMounted"
|
||||
self.cbox.log.info("initialization is not possible as long as the device (%s) is mounted" % self.device)
|
||||
return None
|
||||
except CBContainerError, errMsg:
|
||||
self.hdf["Data.Warning"] = "Plugins.volume_format_fs.FormatFailed"
|
||||
self.cbox.log.warn("initialization of device '%s' failed" % self.device)
|
||||
self.cbox.log.warn("reason: %s" % errMsg)
|
||||
return "volume_format"
|
||||
else:
|
||||
self.cbox.log.info("successfully initialized device '%s'" % self.device)
|
||||
return None
|
||||
|
||||
|
||||
def __format_luks(self, fsType, pw, pw2):
|
||||
if not pw:
|
||||
self.hdf["Data.Warning"] = "EmptyPassword"
|
||||
self.cbox.log.warn("no crypto password was supplied for initialization of device '%s'" % self.device)
|
||||
return "volume_format"
|
||||
if pw != pw2:
|
||||
self.hdf["Data.Warning"] = "DifferentPasswords"
|
||||
self.cbox.log.warn("the crypto password was not repeated correctly for initialization of device '%s'" % self.device)
|
||||
return "volume_format"
|
||||
container = self.cbox.getContainer(self.device)
|
||||
try:
|
||||
container.create(container.Types["luks"], pw)
|
||||
except CBVolumeIsActive:
|
||||
self.hdf["Data.Warning"] = "VolumeMayNotBeMounted"
|
||||
self.cbox.log.info("initialization is not possible as long as the device (%s) is mounted" % self.device)
|
||||
return None
|
||||
except CBContainerError, errMsg:
|
||||
self.hdf["Data.Warning"] = "Plugins.volume_format_fs.FormatFailed"
|
||||
self.cbox.log.warn("initialization of device '%s' failed" % self.device)
|
||||
self.cbox.log.warn("reason: %s" % errMsg)
|
||||
return "volume_format"
|
||||
else:
|
||||
self.hdf["Data.Success"] = "Plugins.volume_format_fs.FormatSuccess"
|
||||
self.cbox.log.info("successfully initialized device '%s'" % self.device)
|
||||
return None
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
<?cs # $Id$ ?>
|
||||
|
||||
<h3><?cs var:html_escape(Lang.Plugins.volume_format_fs.Title.Format) ?></h3>
|
||||
|
||||
<?cs if:Data.CurrentDisk.active ?>
|
||||
<?cs call:hint("Plugins.volume_format_fs.UnmountBeforeInit") ?>
|
||||
<?cs else ?>
|
||||
|
||||
<?cs call:hint("Plugins.volume_format_fs.FormatWarning") ?>
|
||||
|
||||
<?cs call:print_form_header("set_luks", "volume_format_fs") ?>
|
||||
<p><?cs var:html_escape(Lang.Plugins.volume_format_fs.Text.FSType) ?>: <?cs var:html_escape(Data.Plugins.volume_format_fs.fs_type) ?></p>
|
||||
<p><?cs var:html_escape(Lang.Plugins.volume_format_fs.Text.IsEncrypted) ?>: <?cs if:Data.Plugins.volume_format_fs.container_type == "luks" ?><?cs
|
||||
var:html_escape(Lang.Plugins.volume_format_fs.Text.Yes) ?><?cs else ?><?cs
|
||||
var:html_escape(Lang.Plugins.volume_format_fs.Text.No) ?><?cs /if ?></p>
|
||||
|
||||
<p><label for="crypto_password"><?cs var:html_escape(Lang.Text.EnterNewPassword) ?>: </label> <input type="password" id="crypto_password" name="crypto_password" /></p>
|
||||
<p><label for="crypto_password2"><?cs var:html_escape(Lang.Text.EnterSamePassword) ?>: </label> <input type="password" id="crypto_password2" name="crypto_password2" /></p>
|
||||
<p><input type="hidden" name="device" value="<?cs var:Data.CurrentDisk.device ?>" />
|
||||
<input type="hidden" name="fs_type" value="<?cs var:html_escape(Data.Plugins.volume_format_fs.fs_type) ?>" />
|
||||
<input type="hidden" name="container_type" value="<?cs var:html_escape(Data.Plugins.volume_format_fs.container_type) ?>" />
|
||||
<input type="hidden" name="store" value="step2" />
|
||||
<button type="submit"><?cs var:html_escape(Lang.Plugins.volume_format_fs.Button.Format) ?></button></p>
|
||||
</form>
|
||||
|
||||
<?cs /if ?>
|
||||
|
|
@ -42,7 +42,7 @@ WarningMessage {
|
|||
Title = Unknown format
|
||||
Text = The type of this volume ist not known. Maybe you want to initialize itfirst?
|
||||
Link.Text = Format volume
|
||||
Link.Rel = format_fs
|
||||
Link.Rel = volume_format_fs
|
||||
}
|
||||
|
||||
UmountFailed {
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
<h2><?cs var:html_escape(Lang.Plugins.volume_mount.Title.Mount) ?></h2>
|
||||
|
||||
<?cs call:handle_messages() ?>
|
||||
<h3><?cs var:html_escape(Lang.Plugins.volume_mount.Title.Mount) ?></h3>
|
||||
|
||||
<?cs call:print_form_header("mount", "volume_mount") ?><p>
|
||||
<input type="hidden" name="device" value="<?cs var:html_escape(Data.CurrentDisk.device) ?>" />
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
<?cs include:Settings.TemplateDir + "/show_volume_header.cs" ?>
|
||||
|
||||
<?cs if:Data.CurrentDisk.active ?>
|
||||
<?cs include:Settings.PluginDir + "/volume_mount/volume_umount.cs" ?>
|
||||
<?cs else ?>
|
||||
<?cs include:Settings.PluginDir + "/volume_mount/volume_mount.cs" ?>
|
||||
<?cs /if ?>
|
||||
|
||||
<?cs include:Settings.TemplateDir + "/show_volume_footer.cs" ?>
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
<h2><?cs var:html_escape(Lang.Plugins.volume_mount.Title.Umount) ?></h2>
|
||||
|
||||
<?cs call:handle_messages() ?>
|
||||
<h3><?cs var:html_escape(Lang.Plugins.volume_mount.Title.Umount) ?></h3>
|
||||
|
||||
<?cs call:print_form_header("umount", "volume_mount") ?>
|
||||
<p><input type="hidden" name="device" value="<?cs var:html_escape(Data.CurrentDisk.device) ?>" />
|
||||
|
|
|
@ -3,61 +3,11 @@ Link = Properties
|
|||
|
||||
Title {
|
||||
Properties = Properties
|
||||
ChangeVolumeName = Change the name of this volume
|
||||
ChangePassword = Change the password of this volume
|
||||
Encryption = Encryption
|
||||
}
|
||||
|
||||
|
||||
Button {
|
||||
ContainerNameSet = Change name
|
||||
ChangePassword = Change password
|
||||
FormatContainer = Format volume
|
||||
}
|
||||
|
||||
|
||||
Text.FormatForEncryptionSupport = This volume is not encrypted. If you want to turn on encryption, then you have to format the volume. Beware: this will destroy all data of this container.
|
||||
|
||||
|
||||
AdviceMessage {
|
||||
UmountBeforeProps {
|
||||
Text = You must deactivate a volume, if you want to change its properties.
|
||||
Link.Text = Deactive volume now
|
||||
Link.Rel = volume_mount
|
||||
Link.Attr1.name = action
|
||||
Link.Attr1.value = umount
|
||||
Link.Attr2.name = redirect
|
||||
Link.Attr2.value = volume_props
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SuccessMessage {
|
||||
PasswordChange {
|
||||
Title = Password changed
|
||||
Text = The password of this volume was changed successfully.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
WarningMessage {
|
||||
InvalidVolumeName {
|
||||
Title = Changing of container's name failed
|
||||
Text = The supplied new name of the container was invalid. Please try again!
|
||||
}
|
||||
|
||||
SetVolumeNameFailed {
|
||||
Title = Changing of container's name failed
|
||||
Text = Could not change the name of the container. Take a look at the log files for details.
|
||||
}
|
||||
|
||||
VolumeNameIsInUse {
|
||||
Title = Volume name is in use
|
||||
Text = Another volume with the same name is active.
|
||||
}
|
||||
|
||||
PasswordChange {
|
||||
Title = Could not change password
|
||||
Text = The password of this volume could not be changed - sorry!
|
||||
NoPropertyPlugins {
|
||||
Text = No volume property plugins are available.
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,74 +1,11 @@
|
|||
<?cs # $Id$ ?>
|
||||
|
||||
<?cs include:Settings.TemplateDir + "/show_volume_header.cs" ?>
|
||||
|
||||
<h2><?cs var:html_escape(Lang.Plugins.volume_props.Title.Properties) ?></h2>
|
||||
|
||||
<?cs call:handle_messages() ?>
|
||||
|
||||
<?cs if:Data.CurrentDisk.active ?>
|
||||
|
||||
<?cs call:hint("Plugins.volume_props.UmountBeforeProps") ?>
|
||||
|
||||
<?cs if:Data.Plugins.volume_props.includePlugins ?>
|
||||
<?cs # we use 'evar', as we expect 'include' commands inside the variable ?>
|
||||
<?cs evar:Data.Plugins.volume_props.includePlugins ?>
|
||||
<?cs else ?>
|
||||
<table>
|
||||
|
||||
<?cs # name change is only possible if the volume is not mounted ?>
|
||||
<tr><td colspan="3">
|
||||
<h3><?cs var:html_escape(Lang.Plugins.volume_props.Title.ChangeVolumeName) ?></h3>
|
||||
</td></tr>
|
||||
<tr><td align="right"><?cs call:print_form_header("set_name", "volume_props") ?>
|
||||
<label for="vol_name"><?cs var:html_escape(Lang.Text.ContainerName) ?>: </label></td>
|
||||
<td><input type="text" name="vol_name" tabindex="10" size="15" id="vol_name" value="<?cs var:html_escape(Data.CurrentDisk.name) ?>" /></td>
|
||||
<td>
|
||||
<input type="hidden" name="device" value="<?cs var:html_escape(Data.CurrentDisk.device) ?>" />
|
||||
<input type="hidden" name="store" value="set_name" />
|
||||
<button type="submit" tabindex="11"><?cs var:html_escape(Lang.Plugins.volume_props.Button.ContainerNameSet) ?></button>
|
||||
</form></td></tr>
|
||||
<tr><td></td><td></td><td></td></tr>
|
||||
|
||||
|
||||
<?cs # show password change form only for encrypted volumes ?>
|
||||
<?cs if:Data.CurrentDisk.encryption ?>
|
||||
<?cs # password change is only possible if the volume is not mounted ?>
|
||||
<tr><td colspan="3">
|
||||
<h3><?cs var:html_escape(Lang.Plugins.volume_props.Title.ChangePassword) ?></h3>
|
||||
</td></tr>
|
||||
<?cs call:print_form_header("set_password", "volume_props") ?>
|
||||
<tr>
|
||||
<td align="right"><label for="old_pw"><?cs var:html_escape(Lang.Text.EnterCurrentPassword) ?>: </label></td>
|
||||
<td><input type="password" name="old_pw" tabindex="20" size="15" id="old_pw" /></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right"><label for="new_pw"><?cs var:html_escape(Lang.Text.EnterNewPassword) ?>: </label></td>
|
||||
<td><input type="password" name="new_pw" tabindex="21" size="15" id="new_pw" /></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right"><label for="new_pw2"><?cs var:html_escape(Lang.Text.EnterSamePassword) ?>: </label></td>
|
||||
<td><input type="password" name="new_pw2" tabindex="22" size="15" id="new_pw2" /></td>
|
||||
<td>
|
||||
<input type="hidden" name="device" value="<?cs var:html_escape(Data.CurrentDisk.device) ?>" />
|
||||
<input type="hidden" name="store" value="change_pw" />
|
||||
<button type="submit" tabindex="23"><?cs var:html_escape(Lang.Plugins.volume_props.Button.ChangePassword) ?></button>
|
||||
</td>
|
||||
</tr>
|
||||
</form>
|
||||
<?cs else ?>
|
||||
<tr><td colspan="3">
|
||||
<h3><?cs var:html_escape(Lang.Plugins.volume_props.Title.Encryption) ?></h3>
|
||||
</td></tr>
|
||||
<tr><td colspan="2" align="left"><?cs var:html_escape(Lang.Plugins.volume_props.Text.FormatForEncryptionSupport) ?></td>
|
||||
<td>
|
||||
<?cs call:print_form_header("enable_encryption", "format_fs") ?>
|
||||
<p><button type="submit" tabindex="30"><?cs var:html_escape(Lang.Plugins.volume_props.Button.FormatContainer) ?></button></p></form>
|
||||
</td></tr>
|
||||
|
||||
<?cs /if ?>
|
||||
|
||||
</table>
|
||||
|
||||
<?cs call:hint("Plugins.volume_props.NoPropertyPlugins") ?>
|
||||
<?cs /if ?>
|
||||
|
||||
<?cs include:Settings.TemplateDir + "/show_volume_footer.cs" ?>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import CryptoBoxPlugin
|
||||
import Plugins
|
||||
from CryptoBoxExceptions import *
|
||||
|
||||
|
||||
|
@ -7,76 +8,48 @@ class volume_props(CryptoBoxPlugin.CryptoBoxPlugin):
|
|||
pluginCapabilities = [ "volume" ]
|
||||
pluginVisibility = [ "volume" ]
|
||||
requestAuth = False
|
||||
rank = 40
|
||||
rank = 30
|
||||
|
||||
|
||||
def doAction(self, store=None, vol_name=None, old_pw=None, new_pw=None, new_pw2=None):
|
||||
self.container = self.cbox.getContainer(self.device)
|
||||
if not self.container:
|
||||
return None
|
||||
self.__prepareHDF()
|
||||
if store == "set_name":
|
||||
return self.__setVolumeName(vol_name)
|
||||
elif store == "change_pw":
|
||||
return self.__changePassword(old_pw, new_pw, new_pw2)
|
||||
elif not store:
|
||||
return "volume_properties"
|
||||
else:
|
||||
self.cbox.log.info("plugin 'volume_props' - unknown action: %s" % store)
|
||||
return "volume_properties"
|
||||
def doAction(self, **args):
|
||||
import os
|
||||
self.props_plugins = [e for e in Plugins.PluginManager(self.cbox, self.cbox.prefs["Locations"]["PluginDir"]).getPlugins() if "properties" in e.getVisibility()]
|
||||
## sort plugins by rank
|
||||
self.props_plugins.sort(cmp = self.__cmpPluginsRank)
|
||||
## set the name of the templates for every plugin
|
||||
loadString = ""
|
||||
for p in self.props_plugins:
|
||||
p.device = self.device
|
||||
plfname = os.path.join(p.pluginDir, str(p.doAction(**args)) + ".cs")
|
||||
loadString += "<?cs include:'%s' ?>" % plfname
|
||||
## this is a little bit ugly: as it is not possible, to load cs files via
|
||||
## 'linclude' (see clearsilver doc) if they use previously defined macros (see
|
||||
## clearsilver mailing list thread 'linclude file which calls a macro' - 27th
|
||||
## December 02005)
|
||||
## our workaround: define the appropriate "include" (not 'linclude') commands
|
||||
## as a hdf variable - then we can include it via 'evar'
|
||||
self.hdf[self.hdf_prefix + 'includePlugins'] = loadString
|
||||
return "volume_properties"
|
||||
|
||||
|
||||
def getStatus(self):
|
||||
self.container = self.cbox.getContainer(self.device)
|
||||
if not self.container:
|
||||
return "invalid device"
|
||||
return "name=%s" % self.container.getName()
|
||||
return "TODO"
|
||||
|
||||
|
||||
def __prepareHDF(self):
|
||||
self.hdf[self.hdf_prefix + "vol_name"] = self.container.getName()
|
||||
|
||||
|
||||
def __setVolumeName(self, vol_name):
|
||||
if not vol_name:
|
||||
self.hdf["Data.Warning"] = "Plugins.volume_props.InvalidVolumeName"
|
||||
return "volume_properties"
|
||||
if vol_name == self.container.getName():
|
||||
## nothing has to be done
|
||||
return "volume_properties"
|
||||
try:
|
||||
self.container.setName(vol_name)
|
||||
except CBInvalidName:
|
||||
self.hdf["Data.Warning"] = "Plugins.volume_props.InvalidVolumeName"
|
||||
except CBNameActivelyUsed:
|
||||
self.hdf["Data.Warning"] = "Plugins.volume_props.VolumeNameIsInUse"
|
||||
except CBContainerError:
|
||||
self.hdf["Data.Warning"] = "Plugins.volume_props.SetVolumeNameFailed"
|
||||
## reread the volume name
|
||||
self.__prepareHDF()
|
||||
return "volume_properties"
|
||||
def loadDataSet(self, hdf):
|
||||
"""override the parent's function
|
||||
we have to get the data from all included plugins"""
|
||||
for p in self.props_plugins:
|
||||
p.loadDataSet(hdf)
|
||||
## call our parent's method
|
||||
CryptoBoxPlugin.CryptoBoxPlugin.loadDataSet(self, hdf)
|
||||
|
||||
|
||||
def __changePassword(self, old_pw, new_pw, new_pw2):
|
||||
if not old_pw:
|
||||
self.hdf["Data.Warning"] = "EmptyPassword"
|
||||
elif not new_pw:
|
||||
self.hdf["Data.Warning"] = "EmptyNewPassword"
|
||||
elif new_pw != new_pw2:
|
||||
self.hdf["Data.Warning"] = "DifferentPasswords"
|
||||
elif old_pw == new_pw:
|
||||
## do nothing
|
||||
pass
|
||||
def __cmpPluginsRank(self, p1, p2):
|
||||
order = p1.getRank() - p2.getRank()
|
||||
if order < 0:
|
||||
return -1
|
||||
elif order == 0:
|
||||
return 0
|
||||
else:
|
||||
try:
|
||||
self.container.changePassword(old_pw, new_pw)
|
||||
except CBInvalidType, errMsg:
|
||||
self.cbox.log.info("plugin 'volume_props' - cannot change passphrase for non-encrypted container (%s): %s" % (self.device, errMsg))
|
||||
except CBVolumeIsActive:
|
||||
self.hdf["Data.Warning"] = "VolumeMayNotBeMounted"
|
||||
except CBChangePasswordError, errMsg:
|
||||
self.cbox.log.warn("plugin 'volume_props' - cannot change password for device (%s): %s" % (self.device, errMsg))
|
||||
self.hdf["Data.Warning"] = "Plugins.volume_props.PasswordChange"
|
||||
else:
|
||||
self.hdf["Data.Success"] = "Plugins.volume_props.PasswordChange"
|
||||
return "volume_properties"
|
||||
return 1
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
Name = Rename volume
|
||||
Link = Rename
|
||||
|
||||
Title {
|
||||
ChangeVolumeName = Change the name of this volume
|
||||
}
|
||||
|
||||
|
||||
Button {
|
||||
ContainerNameSet = Change name
|
||||
}
|
||||
|
||||
|
||||
SuccessMessage {
|
||||
VolumeNameChanged {
|
||||
Title = Name changed
|
||||
Text = The name of this volume was changed successfully.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
WarningMessage {
|
||||
InvalidVolumeName {
|
||||
Title = Changing of container's name failed
|
||||
Text = The supplied new name of the container was invalid. Please try again!
|
||||
}
|
||||
|
||||
SetVolumeNameFailed {
|
||||
Title = Changing of container's name failed
|
||||
Text = Could not change the name of the container. Take a look at the log files for details.
|
||||
}
|
||||
|
||||
VolumeNameIsInUse {
|
||||
Title = Volume name is in use
|
||||
Text = Another volume with the same name is active.
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
import WebInterfaceTestClass
|
||||
|
||||
class unittests(WebInterfaceTestClass.WebInterfaceTestClass):
|
||||
|
||||
def test_read_form(self):
|
||||
url = self.URL + "volume_rename?weblang=en&device=%2Fdev%2Floop1"
|
||||
self.register_auth(url)
|
||||
self.cmd.go(url)
|
||||
self.cmd.find('name')
|
||||
self.cmd.find('hange')
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
<?cs # $Id$ ?>
|
||||
|
||||
<h3><?cs var:html_escape(Lang.Plugins.volume_rename.Title.ChangeVolumeName) ?></h3>
|
||||
|
||||
<p>
|
||||
<?cs call:print_form_header("set_name", "volume_rename") ?>
|
||||
<label for="vol_name"><?cs var:html_escape(Lang.Text.ContainerName) ?>: </label>
|
||||
<input type="text" name="vol_name" tabindex="10" size="15" id="vol_name" value="<?cs var:html_escape(Data.CurrentDisk.name) ?>" />
|
||||
<input type="hidden" name="device" value="<?cs var:html_escape(Data.CurrentDisk.device) ?>" />
|
||||
<input type="hidden" name="store" value="set_name" />
|
||||
<button type="submit" tabindex="11"><?cs var:html_escape(Lang.Plugins.volume_rename.Button.ContainerNameSet) ?></button>
|
||||
</form>
|
||||
</p>
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
import CryptoBoxPlugin
|
||||
from CryptoBoxExceptions import *
|
||||
|
||||
|
||||
class volume_rename(CryptoBoxPlugin.CryptoBoxPlugin):
|
||||
|
||||
pluginCapabilities = [ "volume" ]
|
||||
pluginVisibility = [ "properties" ]
|
||||
requestAuth = False
|
||||
rank = 60
|
||||
|
||||
|
||||
def doAction(self, store=None, vol_name=None):
|
||||
self.container = self.cbox.getContainer(self.device)
|
||||
if not self.container:
|
||||
return None
|
||||
self.__prepareHDF()
|
||||
if store and vol_name:
|
||||
return self.__setVolumeName(vol_name)
|
||||
else:
|
||||
return "volume_rename"
|
||||
|
||||
|
||||
def getStatus(self):
|
||||
self.container = self.cbox.getContainer(self.device)
|
||||
if not self.container:
|
||||
return "invalid device"
|
||||
return "name=%s" % self.container.getName()
|
||||
|
||||
|
||||
def __prepareHDF(self):
|
||||
self.hdf[self.hdf_prefix + "vol_name"] = self.container.getName()
|
||||
|
||||
|
||||
def __setVolumeName(self, vol_name):
|
||||
if not vol_name:
|
||||
self.hdf["Data.Warning"] = "Plugins.volume_rename.InvalidVolumeName"
|
||||
return "volume_rename"
|
||||
if vol_name == self.container.getName():
|
||||
## nothing has to be done
|
||||
return "volume_rename"
|
||||
try:
|
||||
self.container.setName(vol_name)
|
||||
self.hdf["Data.Success"] = "Plugins.volume_rename.VolumeNameChanged"
|
||||
except CBInvalidName:
|
||||
self.hdf["Data.Warning"] = "Plugins.volume_rename.InvalidVolumeName"
|
||||
except CBNameActivelyUsed:
|
||||
self.hdf["Data.Warning"] = "Plugins.volume_rename.VolumeNameIsInUse"
|
||||
except CBContainerError:
|
||||
self.hdf["Data.Warning"] = "Plugins.volume_rename.SetVolumeNameFailed"
|
||||
## reread the volume name
|
||||
self.__prepareHDF()
|
||||
return "volume_rename"
|
||||
|
Loading…
Reference in New Issue