add option for DHCP and possibility to disable configElements
authorStefan Pluecken <stefan.pluecken@multimedia-labs.de>
Fri, 2 Sep 2005 22:39:40 +0000 (22:39 +0000)
committerStefan Pluecken <stefan.pluecken@multimedia-labs.de>
Fri, 2 Sep 2005 22:39:40 +0000 (22:39 +0000)
data/setup.xml
lib/python/Components/Network.py
lib/python/Components/config.py
lib/python/Screens/Setup.py

index 3b92ec61f10b1de49be51523d770d3f37f91ecc6..ee6549ba0caf2a32e54cea2808e0f8eda8d4b8a6 100644 (file)
@@ -16,6 +16,7 @@
                        <item text="VCR Switch">config.av.vcrswitch</item>
                </setup>
                <setup key="network" title="Networksetup">
+                       <item text="Use DHCP">config.network.dhcp</item>
                        <item text="IP Address">config.network.ip</item>
                        <item text="Gateway">config.network.gateway</item>
                        <item text="Nameserver">config.network.dns</item>
index 3740e51b1593298503b3e339be529e94be0fdcdb..d53bf00e74a61ba5fe55e2c1d4dbe3a7f5ce9b74 100644 (file)
@@ -6,6 +6,18 @@ class Network:
        def __init__(self):
                pass
                
+       def setDHCP(self, useDHCP):
+               if (useDHCP):
+                       print "Using DHCP"
+                       config.network.ip.enabled = False
+                       config.network.gateway.enabled = False
+                       config.network.dns.enabled = False
+               else:
+                       print "NOT using DHCP"
+                       config.network.ip.enabled = True
+                       config.network.gateway.enabled = True
+                       config.network.dns.enabled = True
+                                       
        def setIPAddress(self, ip):
                print ip
                os.system("echo ifconfig eth0 %d.%d.%d.%d" % (ip[0], ip[1], ip[2], ip[3]))
@@ -19,10 +31,11 @@ class Network:
                resolvconf.close()
                
        def setMACAddress(self, mac):
-               os.system("echo ifconfig eth0 %02x:%02x:%02x:%02x:%02x:%02x" % (mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]))
+               os.system("echo ifconfig eth0 ether %02x:%02x:%02x:%02x:%02x:%02x" % (mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]))
                
 def InitNetwork():
        config.network = ConfigSubsection()
+       config.network.dhcp = configElement("config.network.dhcp", configBoolean, 0, ("no", "yes"))
        config.network.ip = configElement("config.network.ip", configSequence, [192,168,1,45], (("."), 3))
        config.network.gateway = configElement("config.network.gateway", configSequence, [192,168,1,3], (("."), 3))
        config.network.dns = configElement("config.network.dns", configSequence, [192,168,1,3], (("."), 3))
@@ -30,6 +43,9 @@ def InitNetwork():
 
        iNetwork = Network()
 
+       def setDHCP(configElement):
+               iNetwork.setDHCP(configElement.value)
+
        def setIPAddress(configElement):
                iNetwork.setIPAddress(configElement.value)
 
@@ -43,6 +59,7 @@ def InitNetwork():
                iNetwork.setMACAddress(configElement.value)
 
        # this will call the "setup-val" initial
+       config.network.dhcp.addNotifier(setDHCP)
        config.network.ip.addNotifier(setIPAddress)
        config.network.gateway.addNotifier(setIPGateway)
        config.network.dns.addNotifier(setIPNameserver)
index e8376385a691d5d5a16b8f5aa29599b50f3cf6ec..c7434e4dc263150bbd00ff7935570c5b2a56a771 100644 (file)
@@ -233,6 +233,7 @@ class configElement:
                self.controlType = control
                self.vals = vals
                self.notifierList = [ ]
+               self.enabled = True
                self.loadData()         
        def addNotifier(self, notifier):
                self.notifierList.append(notifier);
index e2e55974bf524b967f72a2261adf1f0cf4965e83..36b64c1c1ba96574a7bfead4e711094bd01b741f 100644 (file)
@@ -51,11 +51,14 @@ class Setup(Screen):
                                list.append( (ItemText, item) )
 
        def keyOk(self):
-               self["config"].handleKey(config.choseElement)
+               if (self["config"].getCurrent()[1].parent.enabled == True):
+                       self["config"].handleKey(config.choseElement)
        def keyLeft(self):
-               self["config"].handleKey(config.prevElement)
+               if (self["config"].getCurrent()[1].parent.enabled == True):
+                       self["config"].handleKey(config.prevElement)
        def keyRight(self):
-               self["config"].handleKey(config.nextElement)
+               if (self["config"].getCurrent()[1].parent.enabled == True):
+                       self["config"].handleKey(config.nextElement)
 
        def keySave(self):
                print "save requested"