2006-11-30 15:36:53 +01:00
|
|
|
#
|
|
|
|
# Copyright 2006 sense.lab e.V.
|
|
|
|
#
|
|
|
|
# This file is part of the CryptoBox.
|
|
|
|
#
|
|
|
|
# The CryptoBox is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# The CryptoBox is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with the CryptoBox; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
#
|
|
|
|
|
2006-12-05 13:24:47 +01:00
|
|
|
__revision__ = "$Id"
|
|
|
|
|
2006-11-23 20:13:08 +01:00
|
|
|
import cryptobox.plugins.base
|
|
|
|
import cryptobox.plugins.manage
|
|
|
|
from cryptobox.core.exceptions import *
|
2006-11-06 17:05:00 +01:00
|
|
|
|
|
|
|
|
2006-11-23 20:13:08 +01:00
|
|
|
class volume_props(cryptobox.plugins.base.CryptoBoxPlugin):
|
2006-11-06 17:05:00 +01:00
|
|
|
|
2006-12-05 13:24:47 +01:00
|
|
|
plugin_capabilities = [ "volume" ]
|
|
|
|
plugin_visibility = [ "volume" ]
|
|
|
|
request_auth = False
|
2006-11-13 17:11:07 +01:00
|
|
|
rank = 30
|
|
|
|
|
|
|
|
|
2006-12-05 13:24:47 +01:00
|
|
|
def do_action(self, **args):
|
2006-11-13 17:11:07 +01:00
|
|
|
import os
|
2006-12-05 13:24:47 +01:00
|
|
|
self.props_plugins = [e for e in cryptobox.plugins.manage.PluginManager(self.cbox,
|
|
|
|
self.cbox.prefs["Locations"]["PluginDir"]).get_plugins()
|
|
|
|
if "properties" in e.get_visibility()]
|
2006-11-13 17:11:07 +01:00
|
|
|
## sort plugins by rank
|
2006-12-05 13:24:47 +01:00
|
|
|
self.props_plugins.sort(cmp = self.__cmp_plugins_rank)
|
2006-11-13 17:11:07 +01:00
|
|
|
## set the name of the templates for every plugin
|
2006-12-05 13:24:47 +01:00
|
|
|
load_string = ""
|
2006-11-13 17:11:07 +01:00
|
|
|
for p in self.props_plugins:
|
2006-12-13 11:01:58 +01:00
|
|
|
## skip all volume plugins that are not suitable
|
|
|
|
## (e.g. chpasswd for plain containers)
|
|
|
|
if not p.is_useful(self.device):
|
|
|
|
continue
|
2007-01-17 23:15:35 +01:00
|
|
|
## prevent recursion
|
|
|
|
if p.get_name() == self.get_name():
|
|
|
|
continue
|
2006-11-13 17:11:07 +01:00
|
|
|
p.device = self.device
|
2006-12-05 13:24:47 +01:00
|
|
|
plfname = os.path.join(p.plugin_dir, str(p.do_action(**args)) + ".cs")
|
2006-12-13 11:01:58 +01:00
|
|
|
#load_string += "<fieldset><legend><?cs var:html_escape(Lang.Plugins.%s.Link) ?></legend><?cs include:'%s' ?></fieldset>" \
|
2007-01-26 10:44:00 +01:00
|
|
|
#load_string += "<fieldset><?cs include:'%s' ?></fieldset>" \
|
|
|
|
load_string += "<?cs include:'%s' ?>" \
|
2006-12-13 11:01:58 +01:00
|
|
|
% plfname
|
2006-11-13 17:11:07 +01:00
|
|
|
## this is a little bit ugly: as it is not possible, to load cs files via
|
2006-12-13 11:01:58 +01:00
|
|
|
## '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')
|
|
|
|
## command as a hdf variable - then we can include it via 'evar'
|
2006-12-05 13:24:47 +01:00
|
|
|
self.hdf[self.hdf_prefix + 'includePlugins'] = load_string
|
2006-11-13 17:11:07 +01:00
|
|
|
return "volume_properties"
|
2006-11-06 17:05:00 +01:00
|
|
|
|
|
|
|
|
2006-12-05 13:24:47 +01:00
|
|
|
def get_status(self):
|
2006-11-13 17:11:07 +01:00
|
|
|
return "TODO"
|
2006-11-06 17:05:00 +01:00
|
|
|
|
|
|
|
|
2006-12-05 13:24:47 +01:00
|
|
|
def load_dataset(self, hdf):
|
2006-11-13 17:11:07 +01:00
|
|
|
"""override the parent's function
|
|
|
|
we have to get the data from all included plugins"""
|
2006-12-05 13:24:47 +01:00
|
|
|
for plugin in self.props_plugins:
|
2007-01-28 23:27:04 +01:00
|
|
|
## TODO: this leads to strange behaviour if volume_props
|
|
|
|
## is configured to show itself inside itself.
|
|
|
|
## As volume_props works without this, I commented this
|
|
|
|
## out. If it is really needed, there should be a check if
|
|
|
|
## this plugin is trying to load the dataset of itself.
|
|
|
|
#plugin.load_dataset(hdf)
|
2007-01-28 23:28:42 +01:00
|
|
|
pass
|
2006-11-13 17:11:07 +01:00
|
|
|
## call our parent's method
|
2006-12-05 13:24:47 +01:00
|
|
|
cryptobox.plugins.base.CryptoBoxPlugin.load_dataset(self, hdf)
|
2006-11-13 17:11:07 +01:00
|
|
|
|
|
|
|
|
2006-12-05 13:24:47 +01:00
|
|
|
def __cmp_plugins_rank(self, p1, p2):
|
|
|
|
order = p1.get_rank() - p2.get_rank()
|
2006-11-13 17:11:07 +01:00
|
|
|
if order < 0:
|
|
|
|
return -1
|
|
|
|
elif order == 0:
|
|
|
|
return 0
|
2006-11-06 17:05:00 +01:00
|
|
|
else:
|
2006-11-13 17:11:07 +01:00
|
|
|
return 1
|
2006-12-05 13:24:47 +01:00
|
|
|
|