disable debug output
[enigma2.git] / lib / python / Screens / NetworkSetup.py
index b4dbc639ac8e7b5c5fb3c4d7ad81aa9c30145e55..77c102f7827e9267da06ded38eeba3b77e58acde 100644 (file)
@@ -1,11 +1,11 @@
 from Screen import Screen
 from Components.ActionMap import ActionMap
-from Components.ConfigList import ConfigList, ConfigListScreen
+from Components.ConfigList import ConfigListScreen
 from Components.config import config, getConfigListEntry
 from Components.Network import iNetwork
 from Components.Label import Label
 from Components.MenuList import MenuList
-from Components.config import config, ConfigYesNo, ConfigIP, NoSave, ConfigSubsection, ConfigNothing
+from Components.config import config, ConfigYesNo, ConfigIP, NoSave, ConfigNothing
 from Components.PluginComponent import plugins
 from Plugins.Plugin import PluginDescriptor
 
@@ -13,32 +13,40 @@ from Plugins.Plugin import PluginDescriptor
 class NetworkAdapterSelection(Screen):
        def __init__(self, session):
                Screen.__init__(self, session)
-               
-               self["adapterlist"] = MenuList(iNetwork.getAdapterList())
-               
+
+               self["adapterlist"] = MenuList([(self.getFriendlyName(x),x) for x in iNetwork.getAdapterList()])
+
                self["actions"] = ActionMap(["OkCancelActions"],
                {
                        "ok": self.okbuttonClick ,
                        "cancel": self.close
                })
 
+       def getFriendlyName(self, x):
+               # maybe this needs to be replaced by an external list.
+               friendlyNames = {
+                       "eth0": _("Integrated Ethernet"),
+                       "wlan0": _("Wireless")
+               }
+
+               return friendlyNames.get(x, x) # when we have no friendly name, use adapter name
+
        def okbuttonClick(self):
                selection = self["adapterlist"].getCurrent()
-               print "selection:", selection
                if selection is not None:
-                       self.session.open(AdapterSetup, selection)
-                       
+                       self.session.open(AdapterSetup, selection[1])
+
 class NameserverSetup(Screen, ConfigListScreen):
        def __init__(self, session):
                Screen.__init__(self, session)
                self.backupNameserverList = iNetwork.getNameserverList()[:]
                print "backup-list:", self.backupNameserverList
-               
+
                self["red"] = Label(_("Delete"))
                self["green"] = Label(_("Add"))
-               
+
                self.createConfig()
-               
+
                self["actions"] = ActionMap(["OkCancelActions", "ColorActions"],
                {
                        "ok": self.ok,
@@ -50,21 +58,21 @@ class NameserverSetup(Screen, ConfigListScreen):
                self.list = []
                ConfigListScreen.__init__(self, self.list)
                self.createSetup()
-               
+
        def createConfig(self):
                self.nameservers = iNetwork.getNameserverList()
                self.nameserverEntries = []
-               
+
                for nameserver in self.nameservers:
                        self.nameserverEntries.append(NoSave(ConfigIP(default=nameserver)))
-                       
+
        def createSetup(self):
                self.list = []
 
                #self.nameserverConfigEntries = []
                for i in range(len(self.nameserverEntries)):
                        self.list.append(getConfigListEntry(_("Nameserver %d") % (i + 1), self.nameserverEntries[i]))
-               
+
                self["config"].list = self.list
                self["config"].l.setList(self.list)
 
@@ -74,33 +82,33 @@ class NameserverSetup(Screen, ConfigListScreen):
                        iNetwork.addNameserver(nameserver.value)
                iNetwork.writeNameserverConfig()
                self.close()
-       
+
        def cancel(self):
                iNetwork.clearNameservers()
                print "backup-list:", self.backupNameserverList
                for nameserver in self.backupNameserverList:
                        iNetwork.addNameserver(nameserver)
                self.close()
-       
+
        def add(self):
                iNetwork.addNameserver([0,0,0,0])
                self.createConfig()
                self.createSetup()
-       
+
        def remove(self):
                print "currentIndex:", self["config"].getCurrentIndex()
-               
+
                index = self["config"].getCurrentIndex()
                if index < len(self.nameservers):
                        iNetwork.removeNameserver(self.nameservers[index])
                        self.createConfig()
                        self.createSetup()
 
-               
+
 class AdapterSetup(Screen, ConfigListScreen):
        def __init__(self, session, iface):
                Screen.__init__(self, session)
-               
+
                self.iface = iface
 
                print iNetwork.getAdapterAttribute(self.iface, "dhcp")
@@ -109,9 +117,9 @@ class AdapterSetup(Screen, ConfigListScreen):
                self.ipConfigEntry = NoSave(ConfigIP(default=iNetwork.getAdapterAttribute(self.iface, "ip")))
                self.netmaskConfigEntry = NoSave(ConfigIP(default=iNetwork.getAdapterAttribute(self.iface, "netmask")))
                self.gatewayConfigEntry = NoSave(ConfigIP(default=iNetwork.getAdapterAttribute(self.iface, "gateway")))
-        
+       
                self["iface"] = Label(iNetwork.getAdapterName(self.iface))
-                       
+
                self["actions"] = ActionMap(["SetupActions"],
                {
                        "ok": self.ok,
@@ -135,8 +143,9 @@ class AdapterSetup(Screen, ConfigListScreen):
                        self.list.append(getConfigListEntry(_('Use a gateway'), self.hasGatewayConfigEntry))
                        if self.hasGatewayConfigEntry.value:
                                self.list.append(getConfigListEntry(_('Gateway'), self.gatewayConfigEntry))
-               
+
                self.extended = None
+               self.extendedSetup = None
                for p in plugins.getPlugins(PluginDescriptor.WHERE_NETWORKSETUP):
                        callFnc = p.__call__["ifaceSupported"](self.iface)
                        if callFnc is not None:
@@ -146,7 +155,12 @@ class AdapterSetup(Screen, ConfigListScreen):
                                        self.configStrings = p.__call__["configStrings"]
                                else:
                                        self.configStrings = None
-                               self.extendedSetup = getConfigListEntry(_('Extended Setup...'), NoSave(ConfigNothing()))
+
+                               if p.__call__.has_key("menuEntryName"):
+                                       menuEntryName = p.__call__["menuEntryName"](self.iface)
+                               else:
+                                       menuEntryName = _('Extended Setup...')
+                               self.extendedSetup = getConfigListEntry(menuEntryName, NoSave(ConfigNothing()))
                                self.list.append(self.extendedSetup)
 
                self["config"].list = self.list
@@ -177,14 +191,12 @@ class AdapterSetup(Screen, ConfigListScreen):
                                iNetwork.setAdapterAttribute(self.iface, "gateway", self.gatewayConfigEntry.value)
                        else:
                                iNetwork.removeAdapterAttribute(self.iface, "gateway")
-                       
-                       print "self.extended:", self.extended
-                       print "self.configStrings:", self.configStrings
+
                        if self.extended is not None and self.configStrings is not None:
                                iNetwork.setAdapterAttribute(self.iface, "configStrings", self.configStrings(self.iface))
 
                        iNetwork.deactivateNetworkConfig()
-                       iNetwork.writeNetworkConfig()    
+                       iNetwork.writeNetworkConfig()
                        iNetwork.activateNetworkConfig()
                        self.close()