X-Git-Url: http://code.vuplus.com/gitweb/?p=vuplus_dvbapp;a=blobdiff_plain;f=lib%2Fpython%2FScreens%2FNetworkSetup.py;h=e5eb74089dfb6d96daa6d6c438b587fae750a64a;hp=4b15ee0073433eefa3ca01b3d76087d1f9c14d42;hb=bd1476c4800f2d3d9025db14fcb8fc168d87006a;hpb=e639c45b8e1a50ccf55ed6bb117855436576b60e diff --git a/lib/python/Screens/NetworkSetup.py b/lib/python/Screens/NetworkSetup.py index 4b15ee0..e5eb740 100755 --- a/lib/python/Screens/NetworkSetup.py +++ b/lib/python/Screens/NetworkSetup.py @@ -324,7 +324,6 @@ class AdapterSetup(Screen, ConfigListScreen, HelpableScreen): self["ColorActions"] = HelpableActionMap(self, "ColorActions", { "red": (self.keyCancel, _("exit network adapter configuration")), - "blue": (self.KeyBlue, _("open nameserver configuration")), }) self["actions"] = NumberActionMap(["SetupActions"], @@ -356,7 +355,7 @@ class AdapterSetup(Screen, ConfigListScreen, HelpableScreen): self["Adapter"] = StaticText() self["introduction2"] = StaticText(_("Press OK to activate the settings.")) self["key_red"] = StaticText(_("Cancel")) - self["key_blue"] = StaticText(_("Edit DNS")) + self["key_blue"] = StaticText() self["VKeyIcon"] = Boolean(False) self["HelpWindow"] = Pixmap() @@ -395,6 +394,7 @@ class AdapterSetup(Screen, ConfigListScreen, HelpableScreen): self.InterfaceEntry = None self.dhcpEntry = None self.gatewayEntry = None + self.DNSConfigEntry = None self.hiddenSSID = None self.wlanSSID = None self.encryption = None @@ -438,6 +438,14 @@ class AdapterSetup(Screen, ConfigListScreen, HelpableScreen): self.dhcpdefault=False self.hasGatewayConfigEntry = NoSave(ConfigYesNo(default=self.dhcpdefault or False)) self.gatewayConfigEntry = NoSave(ConfigIP(default=iNetwork.getAdapterAttribute(self.iface, "gateway") or [0,0,0,0])) + if iNetwork.getAdapterAttribute(self.iface, "dns-nameservers"): + self.dnsconfigdefault=True + else: + self.dnsconfigdefault=False + self.hasDNSConfigEntry = NoSave(ConfigYesNo(default=self.dnsconfigdefault or False)) + manualNameservers = (iNetwork.getInterfacesNameserverList(self.iface) + [[0,0,0,0]] * 2)[0:2] + self.manualPrimaryDNS = NoSave(ConfigIP(default=manualNameservers[0])) + self.manualSecondaryDNS = NoSave(ConfigIP(default=manualNameservers[1])) nameserver = (iNetwork.getNameserverList() + [[0,0,0,0]] * 2)[0:2] self.primaryDNS = NoSave(ConfigIP(default=nameserver[0])) self.secondaryDNS = NoSave(ConfigIP(default=nameserver[1])) @@ -458,6 +466,13 @@ class AdapterSetup(Screen, ConfigListScreen, HelpableScreen): if self.hasGatewayConfigEntry.value: self.list.append(getConfigListEntry(_('Gateway'), self.gatewayConfigEntry)) + self.DNSConfigEntry = getConfigListEntry(_("Use Manual dns-nameserver"), self.hasDNSConfigEntry) + if self.dhcpConfigEntry.value: + self.list.append(self.DNSConfigEntry) + if self.hasDNSConfigEntry.value or not self.dhcpConfigEntry.value: + self.list.append(getConfigListEntry(_('Primary DNS'), self.manualPrimaryDNS)) + self.list.append(getConfigListEntry(_('Secondary DNS'), self.manualSecondaryDNS)) + self.extended = None self.configStrings = None for p in plugins.getPlugins(PluginDescriptor.WHERE_NETWORKSETUP): @@ -485,9 +500,6 @@ class AdapterSetup(Screen, ConfigListScreen, HelpableScreen): self["config"].list = self.list self["config"].l.setList(self.list) - def KeyBlue(self): - self.session.openWithCallback(self.NameserverSetupClosed, NameserverSetup) - def newConfig(self): if self["config"].getCurrent() == self.InterfaceEntry: self.createSetup() @@ -495,6 +507,8 @@ class AdapterSetup(Screen, ConfigListScreen, HelpableScreen): self.createSetup() if self["config"].getCurrent() == self.gatewayEntry: self.createSetup() + if self["config"].getCurrent() == self.DNSConfigEntry: + self.createSetup() if iNetwork.isWirelessInterface(self.iface): if self["config"].getCurrent() == self.encryption: self.createSetup() @@ -557,6 +571,14 @@ class AdapterSetup(Screen, ConfigListScreen, HelpableScreen): else: iNetwork.removeAdapterAttribute(self.iface, "gateway") + if self.hasDNSConfigEntry.value or not self.dhcpConfigEntry.value: + interfacesDnsLines = self.makeLineDnsNameservers([self.manualPrimaryDNS.value, self.manualSecondaryDNS.value]) + if interfacesDnsLines == "" : + interfacesDnsLines = False + iNetwork.setAdapterAttribute(self.iface, "dns-nameservers", interfacesDnsLines) + else: + iNetwork.setAdapterAttribute(self.iface, "dns-nameservers", False) + if (self.extended is not None and self.configStrings is not None): iNetwork.setAdapterAttribute(self.iface, "configStrings", self.configStrings(self.iface)) self.ws.writeConfig(self.iface) @@ -647,6 +669,12 @@ class AdapterSetup(Screen, ConfigListScreen, HelpableScreen): if current[1].help_window.instance is not None: current[1].help_window.instance.hide() + def makeLineDnsNameservers(self, nameservers = []): + line = "" + entry = ' '.join([("%d.%d.%d.%d" % tuple(x)) for x in nameservers if x != [0, 0, 0, 0] ]) + if len(entry): + line+="\tdns-nameservers %s\n" % entry + return line class AdapterSetupConfiguration(Screen, HelpableScreen): def __init__(self, session,iface): @@ -667,7 +695,7 @@ class AdapterSetupConfiguration(Screen, HelpableScreen): self["statuspic"].hide() self.oktext = _("Press OK on your remote control to continue.") - self.reboottext = _("Your Dreambox will restart after pressing OK on your remote control.") + self.reboottext = _("Your STB will restart after pressing OK on your remote control.") self.errortext = _("No working wireless network interface found.\n Please verify that you have attached a compatible WLAN device or enable your local network interface.") self.missingwlanplugintxt = _("The wireless LAN plugin is not installed!\nPlease install it.") @@ -796,11 +824,11 @@ class AdapterSetupConfiguration(Screen, HelpableScreen): def loadDescription(self): if self["menulist"].getCurrent()[1] == 'edit': - self["description"].setText(_("Edit the network configuration of your Dreambox.\n" ) + self.oktext ) + self["description"].setText(_("Edit the network configuration of your STB.\n" ) + self.oktext ) if self["menulist"].getCurrent()[1] == 'test': - self["description"].setText(_("Test the network configuration of your Dreambox.\n" ) + self.oktext ) + self["description"].setText(_("Test the network configuration of your STB.\n" ) + self.oktext ) if self["menulist"].getCurrent()[1] == 'dns': - self["description"].setText(_("Edit the Nameserver configuration of your Dreambox.\n" ) + self.oktext ) + self["description"].setText(_("Edit the Nameserver configuration of your STB.\n" ) + self.oktext ) if self["menulist"].getCurrent()[1] == 'scanwlan': self["description"].setText(_("Scan your network for wireless access points and connect to them using your selected wireless device.\n" ) + self.oktext ) if self["menulist"].getCurrent()[1] == 'wlanstatus': @@ -836,7 +864,7 @@ class AdapterSetupConfiguration(Screen, HelpableScreen): def genMainMenu(self): menu = [] menu.append((_("Adapter settings"), "edit")) - menu.append((_("Nameserver settings"), "dns")) +# menu.append((_("Nameserver settings"), "dns")) menu.append((_("Network test"), "test")) menu.append((_("Restart network"), "lanrestart")) @@ -960,20 +988,22 @@ class AdapterSetupConfiguration(Screen, HelpableScreen): iNetwork.checkNetworkState(self.checkNetworkCB) def checkNetworkCB(self,data): - if iNetwork.getAdapterAttribute(self.iface, "up") is True: - if self.LinkState is True: - if data <= 2: - self["statuspic"].setPixmapNum(0) + try: + if iNetwork.getAdapterAttribute(self.iface, "up") is True: + if self.LinkState is True: + if data <= 2: + self["statuspic"].setPixmapNum(0) + else: + self["statuspic"].setPixmapNum(1) + self["statuspic"].show() else: self["statuspic"].setPixmapNum(1) - self["statuspic"].show() + self["statuspic"].show() else: self["statuspic"].setPixmapNum(1) self["statuspic"].show() - else: - self["statuspic"].setPixmapNum(1) - self["statuspic"].show() - + except: + pass class NetworkAdapterTest(Screen): def __init__(self, session,iface):