* simplified layout (removed pane), disk plugin is still todo

* gw change (atm breaks network plugin)
* maybe the unittests are broken now again :( will check this on tuesday
This commit is contained in:
age 2007-02-03 18:24:07 +00:00
parent 5ea8e7836d
commit 929cd5636c
17 changed files with 154 additions and 44 deletions

View file

@ -1,10 +1,12 @@
<?cs # $Id$ ?>
<?cs call:show_plugin_title() ?>
<?cs call:handle_messages() ?>
<fieldset>
<legend><?cs var:html_escape(Lang.Plugins.date.Title) ?></legend>
<legend>
<?cs call:show_plugin_icon() ?>
<?cs var:html_escape(Lang.Plugins.date.Title) ?>
</legend>
<?cs call:show_help(Lang.Plugins.date.Help.ChangeDate) ?>

View file

@ -1,8 +1,12 @@
<?cs # $Id$ ?>
<?cs call:show_plugin_title() ?>
<?cs call:handle_messages() ?>
<fieldset>
<legend>
<?cs call:show_plugin_icon() ?>
<?cs var:html_escape(Lang.Plugins.disks.Title) ?>
</legend>
<?cs if:subcount(Data.Disks) == 0 ?>
<?cs call:hint("Plugins.disks.NoDisksAvailable") ?>
<?cs else ?>
@ -11,4 +15,5 @@
<?cs call:show_volume(Data.Disks[index]) ?>
<?cs /loop ?>
<?cs /if ?>
</fieldset>

View file

@ -1,12 +1,15 @@
<?cs # $Id$ ?>
<?cs call:show_plugin_title() ?>
<?cs call:handle_messages() ?>
<fieldset>
<legend>
<?cs call:show_plugin_icon() ?>
<?cs var:html_escape(Lang.Plugins.language_selection.Title.Lang) ?>
</legend>
<?cs call:show_help(Lang.Plugins.language_selection.Help.Select) ?>
<fieldset>
<legend><?cs var:html_escape(Lang.Plugins.language_selection.Title.Lang) ?> </legend>
<ul class="lang">
<?cs loop:index = #0, subcount(Data.Languages)-1, #1 ?>
<li><a href="<?cs

View file

@ -1,8 +1,12 @@
<?cs # $Id$ ?>
<?cs call:show_plugin_title() ?>
<?cs call:handle_messages() ?>
<fieldset>
<legend>
<?cs call:show_plugin_icon() ?>
<?cs var:html_escape(Lang.Plugins.logs.Title) ?>
</legend>
<?cs call:show_help(Lang.Plugins.logs.Help.EventLog) ?>
<table border="0" align="center"><tr>
@ -65,4 +69,5 @@
<?cs /if ?>
</div>
</fieldset>

View file

@ -1,10 +1,12 @@
<?cs # $Id$ ?>
<?cs call:show_plugin_title() ?>
<?cs call:handle_messages() ?>
<fieldset>
<legend><?cs var:html_escape(Lang.Plugins.network.Title.IP) ?></legend>
<legend>
<?cs call:show_plugin_icon() ?>
<?cs var:html_escape(Lang.Plugins.network.Title.IP) ?>
</legend>
<?cs call:print_form_header("network_address", "network") ?>
<?cs call:show_help(Lang.Plugins.network.Help.Network) ?>
@ -52,7 +54,9 @@
<fieldset>
<legend><?cs var:html_escape(Lang.Plugins.network.Title.GW) ?></legend>
<legend>
<?cs call:show_plugin_icon() ?>
<?cs var:html_escape(Lang.Plugins.network.Title.GW) ?>
<?cs call:print_form_header("network_gateway", "network") ?>
<?cs call:show_help(Lang.Plugins.network.Help.Gateway) ?>

View file

@ -21,7 +21,7 @@ Button {
Help {
Network = Insert the network address of the CryptoBox server, the network mask and the default gateway. Be aware that you may lose your connection to the server under some circumstances. The actual values are visible in the form fields.
Gateway = If you have a gateway in your LAN and want to make use of it, type it's address in here. It will be added as default route.
Gateway = If you have a gateway in your LAN and want to make use of it, type it's address in here. It will be added as default route. A quadruple of zeros means, there is no gateway set.
DHCP = If you enable automatic network configuration make sure you have a well configured DHCP server running. All values will be overridden by the settings from the DHCP server. If you don't know what DHCP means leave this box unchecked.
}

View file

@ -37,7 +37,7 @@ REDIRECT_DELAY = 10
CHANGE_IP_DELAY = 5
## default network interface (may be overriden by the "interface" setting of the
## network plugin in cryptobox.conf
DEFAULT_INTERFACE = "eth0"
DEFAULT_INTERFACE = "eth2"
class network(cryptobox.plugins.base.CryptoBoxPlugin):
"""The network feature of the CryptoBox.
@ -96,13 +96,14 @@ class network(cryptobox.plugins.base.CryptoBoxPlugin):
return "form_network"
## request for default gateway change
elif store == "set_gateway":
old_ip = __get_current_gw()
if self.__IP_is_valid(ip1, ip2, ip3, ip4):
new_ip = "%d.%d.%d.%d" % (int(ip1), int(ip2), int(ip3), int(ip4))
else:
self.hdf["Data.Warning"] = "Plugins.network.InvalidGatewayIP"
self.__prepare_form_data()
return "form_network"
if self.__set_gw(new_ip):
if self.__set_gw(old_ip, new_ip):
self.cbox.log.info("the gateway IP was successfully changed: %s" % new_ip)
self.hdf["Data.Success"] = "Plugins.network.GWChanged"
@ -140,7 +141,7 @@ class network(cryptobox.plugins.base.CryptoBoxPlugin):
warnings = []
if not os.path.isfile(self.root_action.IFCONFIG_BIN):
warnings.append((55, "Plugins.%s.MissingProgramIfconfig" % self.get_name()))
if not os.path.isfile(self.root_action.GWCONFIG_BIN):
if not os.path.isfile(self.root_action.ROUTE_BIN):
warnings.append((52, "Plugins.%s.MissingProgramRoute" % self.get_name()))
return warnings
@ -160,6 +161,7 @@ class network(cryptobox.plugins.base.CryptoBoxPlugin):
def __prepare_form_data(self):
"""Set some hdf values.
"""
#TODO: the following looks nicer in a loop
(oc1, oc2, oc3, oc4) = self.__get_current_ip("ip")
self.hdf[self.hdf_prefix + "ip.oc1"] = oc1
self.hdf[self.hdf_prefix + "ip.oc2"] = oc2
@ -170,6 +172,11 @@ class network(cryptobox.plugins.base.CryptoBoxPlugin):
self.hdf[self.hdf_prefix + "nm.oc2"] = oc2
self.hdf[self.hdf_prefix + "nm.oc3"] = oc3
self.hdf[self.hdf_prefix + "nm.oc4"] = oc4
(oc1, oc2, oc3, oc4) = self.__get_current_ip("gw")
self.hdf[self.hdf_prefix + "gw.oc1"] = oc1
self.hdf[self.hdf_prefix + "gw.oc2"] = oc2
self.hdf[self.hdf_prefix + "gw.oc3"] = oc3
self.hdf[self.hdf_prefix + "gw.oc4"] = oc4
def __get_current_ip(self, type="ip"):
@ -186,8 +193,8 @@ class network(cryptobox.plugins.base.CryptoBoxPlugin):
(stdout, stderr) = proc.communicate()
if proc.returncode != 0:
return (0, 0, 0, 0)
## this regex matches the four numbers of the IP
if type == "ip":
## this regex matches the four numbers of the IP
match = re.search(r'inet [\w]+:(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\s', stdout)
if match:
## use the previously matched numbers
@ -195,14 +202,31 @@ class network(cryptobox.plugins.base.CryptoBoxPlugin):
else:
return (0, 0, 0, 0)
elif type == "nm":
##TODO: Lars please leave a regex note for fetching the
## netmask with ifconfig
## this greps the netmask
match = re.search(r'inet [\w]+:.*Mask:(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\s', stdout)
if match:
## use the previously matched numbers
return tuple([int(e) for e in match.groups()])
else:
return (0, 0, 0, 0)
elif type == "gw":
gw = self.__get_current_gw()
return gw
def __get_current_gw(self):
proc = subprocess.Popen(
shell = False,
stdout = subprocess.PIPE,
args = [
self.root_action.ROUTE_BIN,
"-n"])
(stdout, stderr) = proc.communicate()
if proc.returncode != 0:
self.cbox.log.warn(stderr)
return (0, 0, 0, 0)
#TODO: Lars, please do some regex voodoo here
gwIP = "192.168.0.123"
return gwIP
def __set_ip(self, new_ip, new_nm="255.255.255.0"):
@ -240,12 +264,35 @@ class network(cryptobox.plugins.base.CryptoBoxPlugin):
return True
def __set_gw(self, new_ip):
def __set_gw(self, old_ip, new_ip):
"""Change the gateway IP adress
"""
## TODO: route add default gw ...
## as soon as lazy age has implemented this return True
return False
import threading
def delayed_ip_change():
import time
time.sleep(CHANGE_IP_DELAY)
proc = subprocess.Popen(
shell = False,
stderr = subprocess.PIPE,
args = [
self.cbox.prefs["Programs"]["super"],
self.cbox.prefs["Programs"]["CryptoBoxRootActions"],
"plugin",
os.path.join(self.plugin_dir, "root_action.py"),
"change_gw",
old_ip,
new_ip])
proc.wait()
if proc.returncode != 0:
self.cbox.log.warn("failed to change IP address: %s" % new_ip)
self.cbox.log.warn("error output: %s" % str(proc.stderr.read()))
return
thread = threading.Thread()
thread.run = delayed_ip_change
thread.setDaemon(True)
thread.start()
# TODO: how could we guess, if it failed?
return True
def __get_interface(self):

View file

@ -28,7 +28,7 @@ __revision__ = "$Id"
PLUGIN_TYPE = "cryptobox"
IFCONFIG_BIN = "/sbin/ifconfig"
GWCONFIG_BIN = "/sbin/route"
ROUTE_BIN = "/sbin/route"
import subprocess
import re
@ -52,9 +52,22 @@ def __changeIP(interface, ipaddress, netmask="0"):
return proc.returncode == 0
def __changeGW(gwaddress):
##TODO
return False
def __changeGW(old_gw, gwaddress):
__check_address(old_gw)
__check_address(gwaddress)
if old_gw != "0.0.0.0":
"""assuming that a default route exists and deleting it
"""
proc = subprocess.Popen(
shell = False,
args = [ROUTE_BIN, "del", "default", "gw", old_gw])
proc.wait()
proc = subprocess.Popen(
shell = False,
args = [ROUTE_BIN, "add", "default", "gw", gwaddress])
proc.wait()
return proc.returncode == 0
def __check_address(address):
"""Check for correct numbers in given address
@ -81,8 +94,8 @@ if __name__ == "__main__":
if len(args) != 4: raise "InvalidArgNum"
result = __changeIP(args[1], args[2], args[3])
elif args[0] == "change_gw":
if len(args) != 2: raise "InvalidArgNum"
result = __changeGW(args[1])
if len(args) != 3: raise "InvalidArgNum"
result = __changeGW(args[1], args[2])
else:
sys.stderr.write("%s: invalid action (%s)\n" % (self_bin, args[0]))
sys.exit(1)

View file

@ -1,6 +1,5 @@
<?cs # $Id$ ?>
<?cs call:show_plugin_title() ?>
<?cs call:handle_messages() ?>
<?cs call:show_help(Lang.Plugins.plugin_manager.Help.PluginManager) ?>
@ -12,8 +11,11 @@
<?cs # <form> starts here ?>
<?cs call:print_form_header("manage_plugins", "plugin_manager") ?>
<fieldset id="volume_plugins">
<legend><?cs var:html_escape(Lang.Plugins.plugin_manager.Title.VolumePlugins) ?></legend>
<fieldset>
<legend>
<?cs call:show_plugin_icon() ?>
<?cs var:html_escape(Lang.Plugins.plugin_manager.Title.VolumePlugins) ?>
</legend>
<?cs call:show_help(Lang.Plugins.plugin_manager.Help.VolumePlugins) ?>
<table class="plugin_list">
@ -67,8 +69,11 @@
</table>
</fieldset>
<fieldset id="system_plugins">
<legend><?cs var:html_escape(Lang.Plugins.plugin_manager.Title.SystemPlugins) ?></legend>
<fieldset>
<legend>
<?cs call:show_plugin_icon() ?>
<?cs var:html_escape(Lang.Plugins.plugin_manager.Title.SystemPlugins) ?>
</legend>
<?cs call:show_help(Lang.Plugins.plugin_manager.Help.SystemPlugins) ?>
<table class="plugin_list">
<tr>

View file

@ -42,7 +42,8 @@ class plugin_manager(cryptobox.plugins.base.CryptoBoxPlugin):
if not plugin: return "plugin_list"
## take only plugins, that are of the same type as the choosen one
self.plugins = [e for e in plugin_manager.get_plugins()
if e.plugin_capabilities == plugin.plugin_capabilities]
if e.plugin_capabilities == plugin.plugin_capabilities and \
e != "volume_props" ]
if action == "up":
self.__move_up(plugin)
elif action == "down":

View file

@ -1,8 +1,13 @@
<?cs # $Id$ ?>
<?cs call:show_plugin_title() ?>
<?cs call:handle_messages() ?>
<fieldset>
<legend>
<?cs call:show_plugin_icon() ?>
<?cs var:html_escape(Lang.Plugins.shutdown.Title) ?>
</legend>
<?cs call:show_help(Lang.Plugins.shutdown.Help.Shutdown) ?>
<div class="plugin_system">
@ -15,3 +20,4 @@
<img src="<?cs call:link('icons/shutdown','image','gnome-reboot.gif','','')
?>" alt="icon: reboot" /><br/><?cs var:html_escape(Lang.Plugins.shutdown.Button.Reboot) ?></a></div>
</fieldset>

View file

@ -1,10 +1,12 @@
<?cs # $Id$ ?>
<?cs call:show_plugin_title() ?>
<?cs call:handle_messages() ?>
<fieldset>
<legend><?cs var:html_escape(Lang.Plugins.system_preferences.Title.Prefs) ?></legend>
<legend>
<?cs call:show_plugin_icon() ?>
<?cs var:html_escape(Lang.Plugins.system_preferences.Title.Prefs) ?>
</legend>
<?cs # sort the Plugins - using the most stupid way :) ?>
<?cs loop: order = #0, #100, #1

View file

@ -1,11 +1,12 @@
<?cs # $Id$ ?>
<?cs call:show_plugin_title() ?>
<?cs call:handle_messages() ?>
<?cs call:show_help(Lang.Plugins.user_manager.Help.UserManagement) ?>
<fieldset>
<legend><?cs var:html_escape(Lang.Plugins.user_manager.Title.AddUser) ?></legend>
<legend>
<?cs call:show_plugin_icon() ?>
<?cs var:html_escape(Lang.Plugins.user_manager.Title.AddUser) ?>
<?cs call:show_help(Lang.Plugins.user_manager.Help.AddUser) ?>
<?cs call:print_form_header("add_user", "user_manager") ?>
<table class="user_manager">
@ -29,7 +30,9 @@
<fieldset>
<legend><?cs var:html_escape(Lang.Plugins.user_manager.Title.ChangePassword) ?></legend>
<legend>
<?cs call:show_plugin_icon() ?>
<?cs var:html_escape(Lang.Plugins.user_manager.Title.ChangePassword) ?>
<?cs call:show_help(Lang.Plugins.user_manager.Help.ChangePassword) ?>
<?cs call:print_form_header("change_password", "user_manager") ?>
<table class="user_manager">

View file

@ -7,7 +7,9 @@
</div><!-- end of 'words' -->
<?cs # ugly way of getting a 'min-height' for IE6 ?>
</td><td id="pane_right"><p style="height:260px;" /></tr>
<!-- </td><td id="pane_right"><p style="height:260px;" /></tr> -->
</td><td><p style="height:260px;" /></tr>
<tr><td/><td><div id="footer">

View file

@ -98,10 +98,11 @@ if:subcount(Data.StylesheetFiles) > 0
<?cs /loop ?><?cs
/if ?>
<!--
<tr><td id="pane_left_top" /><td id="pane_top" /><td id="pane_right_top" /></tr>
<tr><td id="pane_left" />
<td id="pane_content">
-->
<tr><td><td id="pane_content">
<div id="words">

View file

@ -230,11 +230,15 @@ def:handle_messages() ?><?cs
?><?cs /if ?><?cs
/def ?><?cs
def:show_plugin_title() ?>
<div class="plugin_system_title">
<img alt="icon: <?cs var:html_escape(Data.ActivePlugin) ?>" src="icons/<?cs
var:html_escape(Data.ActivePlugin) ?>" />
<h1><?cs var:Lang.Plugins[Data.ActivePlugin].Title ?></h1>
</div><?cs
</div><?cs
/def ?><?cs
def:show_plugin_icon() ?>
<img alt="icon: <?cs var:html_escape(Data.ActivePlugin) ?>" src="icons/<?cs
var:html_escape(Data.ActivePlugin) ?>" /> <?cs
/def ?>

View file

@ -21,6 +21,13 @@ div#main {
margin-left: 140px;
}
legend img {
width: 32px;
height: 32px;
padding-right: 8px;
float: left;
}
#main h1, h2, h3, legend {
font-family: sans-serif, arial;
font-weight: normal;