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
|
|
|
|
|
|
|
pluginCapabilities = [ "volume" ]
|
2006-11-08 13:19:30 +01:00
|
|
|
pluginVisibility = [ "volume" ]
|
2006-11-06 17:05:00 +01:00
|
|
|
requestAuth = False
|
2006-11-13 17:11:07 +01:00
|
|
|
rank = 30
|
|
|
|
|
|
|
|
|
|
|
|
def doAction(self, **args):
|
|
|
|
import os
|
2006-11-23 20:13:08 +01:00
|
|
|
self.props_plugins = [e for e in cryptobox.plugins.manage.PluginManager(self.cbox, self.cbox.prefs["Locations"]["PluginDir"]).getPlugins() if "properties" in e.getVisibility()]
|
2006-11-13 17:11:07 +01:00
|
|
|
## 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"
|
2006-11-06 17:05:00 +01:00
|
|
|
|
|
|
|
|
|
|
|
def getStatus(self):
|
2006-11-13 17:11:07 +01:00
|
|
|
return "TODO"
|
2006-11-06 17:05:00 +01:00
|
|
|
|
|
|
|
|
2006-11-13 17:11:07 +01:00
|
|
|
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
|
2006-11-23 20:13:08 +01:00
|
|
|
cryptobox.plugins.base.CryptoBoxPlugin.loadDataSet(self, hdf)
|
2006-11-13 17:11:07 +01:00
|
|
|
|
|
|
|
|
|
|
|
def __cmpPluginsRank(self, p1, p2):
|
|
|
|
order = p1.getRank() - p2.getRank()
|
|
|
|
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
|