From: Mladen Horvat Date: Thu, 31 Mar 2011 10:09:21 +0000 (+0200) Subject: Screens/NetworkSetup.py, SystemPlugins/WirelessLan,Networkwizard: dont use "hidden... X-Git-Url: https://git.cweiske.de/enigma2.git/commitdiff_plain/c3c412e8765520205b7cf8413ddf8abca74f1bc3 Screens/NetworkSetup.py, SystemPlugins/WirelessLan,Networkwizard: dont use "hidden..." as selector for hidden networks. Add config option for entering a hidden network ssid. This is more intuitive as selecting the option from the found networks. refs #725 --- diff --git a/lib/python/Plugins/SystemPlugins/NetworkWizard/NetworkWizard.py b/lib/python/Plugins/SystemPlugins/NetworkWizard/NetworkWizard.py index e99309a9..9f254066 100755 --- a/lib/python/Plugins/SystemPlugins/NetworkWizard/NetworkWizard.py +++ b/lib/python/Plugins/SystemPlugins/NetworkWizard/NetworkWizard.py @@ -4,33 +4,11 @@ from Screens.Rc import Rc from Screens.MessageBox import MessageBox from Components.Pixmap import Pixmap, MovingPixmap, MultiPixmap from Components.Sources.Boolean import Boolean -from Components.config import config, ConfigBoolean, configfile, ConfigYesNo, NoSave, ConfigSubsection, ConfigText, getConfigListEntry, ConfigSelection, ConfigPassword from Components.Network import iNetwork from Tools.Directories import resolveFilename, SCOPE_PLUGINS, SCOPE_SKIN_IMAGE from enigma import eTimer from os import system -config.misc.firstrun = ConfigBoolean(default = True) -list = [] -list.append("WEP") -list.append("WPA") -list.append("WPA2") -list.append("WPA/WPA2") - -weplist = [] -weplist.append("ASCII") -weplist.append("HEX") - -config.plugins.wlan = ConfigSubsection() -config.plugins.wlan.essid = NoSave(ConfigText(default = "home", fixed_size = False)) -config.plugins.wlan.hiddenessid = NoSave(ConfigText(default = "home", fixed_size = False)) - -config.plugins.wlan.encryption = ConfigSubsection() -config.plugins.wlan.encryption.enabled = NoSave(ConfigYesNo(default = False)) -config.plugins.wlan.encryption.type = NoSave(ConfigSelection(list, default = "WPA/WPA2" )) -config.plugins.wlan.encryption.wepkeytype = NoSave(ConfigSelection(weplist, default = "ASCII")) -config.plugins.wlan.encryption.psk = NoSave(ConfigPassword(default = "mysecurewlan", fixed_size = False)) - class NetworkWizard(WizardLanguage, Rc): skin = """ @@ -306,13 +284,13 @@ class NetworkWizard(WizardLanguage, Rc): newList.append(oldentry) for newentry in newList: - if newentry[1] == "hidden...": + if newentry[1] == "": continue self.newAPlist.append(newentry) if len(self.newAPlist): - if "hidden..." not in self.newAPlist: - self.newAPlist.append(( _("enter hidden network SSID"), "hidden..." )) + if "" not in self.newAPlist: + self.newAPlist.append(( _("enter hidden network SSID"), "" )) if (self.wizard[self.currStep].has_key("dynamiclist")): currentListEntry = self["list"].getCurrent() @@ -359,9 +337,9 @@ class NetworkWizard(WizardLanguage, Rc): complist.remove(compentry) for entry in complist: self.APList.append( (entry[1], entry[1]) ) - - if "hidden..." not in self.APList: - self.APList.append(( _("enter hidden network SSID"), "hidden..." )) + + if "" not in self.APList: + self.APList.append(( _("enter hidden network SSID"), "" )) self.rescanTimer.start(5000) return self.APList @@ -369,10 +347,10 @@ class NetworkWizard(WizardLanguage, Rc): def AccessPointsSelectionMade(self, index): self.ap = index self.WlanList = [] - currList = [] if (self.wizard[self.currStep].has_key("dynamiclist")): - currList = self['list'].list - for entry in currList: + for entry in self['list'].list: + if entry[1] == "": + continue self.WlanList.append( (entry[1], entry[0]) ) self.AccessPointsSelect(index) diff --git a/lib/python/Plugins/SystemPlugins/NetworkWizard/plugin.py b/lib/python/Plugins/SystemPlugins/NetworkWizard/plugin.py index 56cebdbf..30a24230 100644 --- a/lib/python/Plugins/SystemPlugins/NetworkWizard/plugin.py +++ b/lib/python/Plugins/SystemPlugins/NetworkWizard/plugin.py @@ -1,6 +1,8 @@ from Screens.Screen import Screen from Plugins.Plugin import PluginDescriptor -from Components.config import getConfigListEntry, config +from Components.config import getConfigListEntry, config, ConfigBoolean + +config.misc.firstrun = ConfigBoolean(default = True) def NetworkWizardMain(session, **kwargs): session.open(NetworkWizard) diff --git a/lib/python/Plugins/SystemPlugins/WirelessLan/Wlan.py b/lib/python/Plugins/SystemPlugins/WirelessLan/Wlan.py index 5b76f926..4a7b1e88 100755 --- a/lib/python/Plugins/SystemPlugins/WirelessLan/Wlan.py +++ b/lib/python/Plugins/SystemPlugins/WirelessLan/Wlan.py @@ -22,7 +22,7 @@ weplist.append("HEX") config.plugins.wlan = ConfigSubsection() config.plugins.wlan.essid = NoSave(ConfigText(default = "home", fixed_size = False)) -config.plugins.wlan.hiddenessid = NoSave(ConfigText(default = "home", fixed_size = False)) +config.plugins.wlan.hiddenessid = NoSave(ConfigYesNo(default = False)) config.plugins.wlan.encryption = ConfigSubsection() config.plugins.wlan.encryption.enabled = NoSave(ConfigYesNo(default = True)) @@ -146,15 +146,13 @@ class wpaSupplicant: fp.write('ctrl_interface=/var/run/wpa_supplicant\n') fp.write('eapol_version=1\n') fp.write('fast_reauth=1\n') - if essid == 'hidden...': + + if hiddenessid: fp.write('ap_scan=2\n') else: fp.write('ap_scan=1\n') fp.write('network={\n') - if essid == 'hidden...': - fp.write('\tssid="'+hiddenessid+'"\n') - else: - fp.write('\tssid="'+essid+'"\n') + fp.write('\tssid="'+essid+'"\n') fp.write('\tscan_ssid=0\n') if encrypted: if encryption in ('WPA', 'WPA2', 'WPA/WPA2'): @@ -184,7 +182,7 @@ class wpaSupplicant: fp.write('}') fp.write('\n') fp.close() - system('cat ' + getWlanConfigName(iface)) + #system('cat ' + getWlanConfigName(iface)) def loadConfig(self,iface): configfile = getWlanConfigName(iface) @@ -196,22 +194,22 @@ class wpaSupplicant: fp = file(configfile, 'r') supplicant = fp.readlines() fp.close() - ap_scan = False essid = None for s in supplicant: split = s.strip().split('=',1) if split[0] == 'ap_scan': - print "[Wlan.py] Got Hidden SSID Scan Value ",split[1] + #print "[Wlan.py] Got Hidden SSID Scan Value ",split[1] if split[1] == '2': - ap_scan = True + config.plugins.wlan.hiddenessid.value = True else: - ap_scan = False - + config.plugins.wlan.hiddenessid.value = False + elif split[0] == 'ssid': - print "[Wlan.py] Got SSID ",split[1][1:-1] + #print "[Wlan.py] Got SSID ",split[1][1:-1] essid = split[1][1:-1] - + config.plugins.wlan.essid.value = essid + elif split[0] == 'proto': config.plugins.wlan.encryption.enabled.value = True if split[1] == 'WPA' : @@ -220,8 +218,8 @@ class wpaSupplicant: mode = 'WPA2' if split[1] in ('WPA RSN', 'WPA WPA2'): mode = 'WPA/WPA2' + #print "[Wlan.py] Got Encryption: ",mode config.plugins.wlan.encryption.type.value = mode - print "[Wlan.py] Got Encryption: "+mode elif split[0] == 'wep_key0': config.plugins.wlan.encryption.enabled.value = True @@ -238,12 +236,6 @@ class wpaSupplicant: else: pass - if ap_scan is True: - config.plugins.wlan.hiddenessid.value = essid - config.plugins.wlan.essid.value = 'hidden...' - else: - config.plugins.wlan.hiddenessid.value = essid - config.plugins.wlan.essid.value = essid wsconfig = { 'hiddenessid': config.plugins.wlan.hiddenessid.value, 'ssid': config.plugins.wlan.essid.value, @@ -256,28 +248,28 @@ class wpaSupplicant: for (key, item) in wsconfig.items(): if item is "None" or item is "": if key == 'hiddenessid': - wsconfig['hiddenessid'] = "home" + wsconfig['hiddenessid'] = False if key == 'ssid': wsconfig['ssid'] = "home" if key == 'encryption': wsconfig['encryption'] = True - if key == 'encryption': + if key == 'encryption_type': wsconfig['encryption_type'] = "WPA/WPA2" - if key == 'encryption': + if key == 'encryption_wepkeytype': wsconfig['encryption_wepkeytype'] = "ASCII" - if key == 'encryption': + if key == 'key': wsconfig['key'] = "mysecurewlan" except: print "[Wlan.py] Error parsing ",configfile wsconfig = { - 'hiddenessid': "home", + 'hiddenessid': False, 'ssid': "home", 'encryption': True, 'encryption_type': "WPA/WPA2", 'encryption_wepkeytype': "ASCII", 'key': "mysecurewlan", } - print "[Wlan.py] WS-CONFIG-->",wsconfig + #print "[Wlan.py] WS-CONFIG-->",wsconfig return wsconfig @@ -309,17 +301,13 @@ class Status: else: if "Nickname" in line: tmpssid=(line[line.index('ESSID')+7:line.index('" Nickname')]) - if tmpssid == '': - ssid = _("Hidden networkname") - elif tmpssid ==' ': + if tmpssid in ('', ' '): ssid = _("Hidden networkname") else: ssid = tmpssid else: tmpssid=(line[line.index('ESSID')+7:len(line)-1]) - if tmpssid == '': - ssid = _("Hidden networkname") - elif tmpssid ==' ': + if tmpssid in ('', ' '): ssid = _("Hidden networkname") else: ssid = tmpssid diff --git a/lib/python/Plugins/SystemPlugins/WirelessLan/plugin.py b/lib/python/Plugins/SystemPlugins/WirelessLan/plugin.py index c296ab70..6e88a3ea 100644 --- a/lib/python/Plugins/SystemPlugins/WirelessLan/plugin.py +++ b/lib/python/Plugins/SystemPlugins/WirelessLan/plugin.py @@ -22,6 +22,7 @@ from os import urandom, system plugin_path = eEnv.resolve("${libdir}/enigma2/python/Plugins/SystemPlugins/WirelessLan") + list = [] list.append("WEP") list.append("WPA") @@ -34,7 +35,7 @@ weplist.append("HEX") config.plugins.wlan = ConfigSubsection() config.plugins.wlan.essid = NoSave(ConfigText(default = "home", fixed_size = False)) -config.plugins.wlan.hiddenessid = NoSave(ConfigText(default = "home", fixed_size = False)) +config.plugins.wlan.hiddenessid = NoSave(ConfigYesNo(default = False)) config.plugins.wlan.encryption = ConfigSubsection() config.plugins.wlan.encryption.enabled = NoSave(ConfigYesNo(default = False)) @@ -234,7 +235,7 @@ class WlanScan(Screen): self.rescanTimer.stop() del self.rescanTimer if cur[1] is not None: - if cur[1] == 'hidden...': + if cur[1] == '': essid = cur[1] else: essid = cur[0] @@ -260,7 +261,7 @@ class WlanScan(Screen): def buildEntryComponent(self, essid, bssid, encrypted, iface, maxrate, signal): divpng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/div-h.png")) encryption = encrypted and _("Yes") or _("No") - if bssid == 'hidden...': + if bssid == '': return((essid, bssid, None, None, None, None, divpng)) else: return((essid, bssid, _("Signal: ") + str(signal), _("Max. Bitrate: ") + str(maxrate), _("Encrypted: ") + encryption, _("Interface: ") + str(iface), divpng)) @@ -280,9 +281,9 @@ class WlanScan(Screen): tmpList.append(data) if len(tmpList): - if "hidden..." not in tmpList: - tmpList.append( ( _("enter hidden network SSID"), "hidden...", True, self.iface, _("unavailable"), "" ) ) - + if "" not in tmpList: + tmpList.append( ( _("enter hidden network SSID"), "", True, self.iface, _("unavailable"), "" ) ) + for entry in tmpList: self.newAPList.append(self.buildEntryComponent( entry[0], entry[1], entry[2], entry[3], entry[4], entry[5] )) @@ -325,8 +326,8 @@ class WlanScan(Screen): else: self.oldlist[entry[0]]['data'] = entry - if "hidden..." not in self.cleanList: - self.cleanList.append( ( _("enter hidden network SSID"), "hidden...", True, self.iface, _("unavailable"), "" ) ) + if "" not in self.cleanList: + self.cleanList.append( ( _("enter hidden network SSID"), "", True, self.iface, _("unavailable"), "" ) ) for entry in self.cleanList: self.APList.append(self.buildEntryComponent( entry[0], entry[1], entry[2], entry[3], entry[4], entry[5] )) @@ -350,8 +351,8 @@ class WlanScan(Screen): def buildWlanList(self): self.WlanList = [] for entry in self['list'].list: - if entry[1] == "hidden...": - self.WlanList.append(( "hidden...",_("enter hidden network SSID") )) + if entry[1] == "": + continue else: self.WlanList.append( (entry[0], entry[0]) ) @@ -445,8 +446,8 @@ def configStrings(iface): driver = 'dreambox' print 'Using "%s" as wpa-supplicant driver' % (driver) ret = "" - if driver == 'madwifi' and config.plugins.wlan.essid.value == "hidden...": - ret += "\tpre-up iwconfig " + iface + " essid \"" + config.plugins.wlan.hiddenessid.value + "\" || true\n" + if driver == 'madwifi' and config.plugins.wlan.hiddenessid.value: + ret += "\tpre-up iwconfig " + iface + " essid \"" + config.plugins.wlan.essid.value + "\" || true\n" ret += "\tpre-up wpa_supplicant -i" + iface + " -c" + getWlanConfigName(iface) + " -B -dd -D" + driver + " || true\n" ret += "\tpre-down wpa_cli -i" + iface + " terminate || true\n" return ret diff --git a/lib/python/Screens/NetworkSetup.py b/lib/python/Screens/NetworkSetup.py index 5d378524..e7ba6071 100755 --- a/lib/python/Screens/NetworkSetup.py +++ b/lib/python/Screens/NetworkSetup.py @@ -11,7 +11,7 @@ from Components.Sources.List import List from Components.Label import Label,MultiColorLabel from Components.Pixmap import Pixmap,MultiPixmap from Components.MenuList import MenuList -from Components.config import config, ConfigYesNo, ConfigIP, NoSave, ConfigText, ConfigPassword, ConfigSelection, getConfigListEntry, ConfigNothing +from Components.config import config, ConfigYesNo, ConfigIP, NoSave, ConfigText, ConfigPassword, ConfigSelection, getConfigListEntry, ConfigNothing, ConfigBoolean from Components.ConfigList import ConfigListScreen from Components.PluginComponent import plugins from Components.MultiContent import MultiContentEntryText, MultiContentEntryPixmapAlphaTest @@ -308,6 +308,7 @@ class AdapterSetup(Screen, ConfigListScreen, HelpableScreen): self.iface = networkinfo self.essid = essid self.aplist = aplist + self.extended = None self.applyConfigRef = None self.finished_cb = None @@ -406,6 +407,7 @@ class AdapterSetup(Screen, ConfigListScreen, HelpableScreen): self.weplist = None self.wsconfig = None self.default = None + self.hiddenNW = None if iNetwork.isWirelessInterface(self.iface): from Plugins.SystemPlugins.WirelessLan.Wlan import wpaSupplicant, iWlan @@ -442,16 +444,22 @@ class AdapterSetup(Screen, ConfigListScreen, HelpableScreen): self.wsconfig = self.ws.loadConfig(self.iface) if self.essid is not None: # ssid from wlan scan self.default = self.essid + self.hiddenNW = self.wsconfig['hiddenessid'] + if self.essid == '': + self.hiddenNW = True + self.default = self.default = self.wsconfig['ssid'] else: + self.hiddenNW = self.wsconfig['hiddenessid'] self.default = self.wsconfig['ssid'] - if "hidden..." not in self.nwlist: - self.nwlist.append(("hidden...",_("enter hidden network SSID"))) - if self.default not in self.nwlist: + if (self.default not in self.nwlist and self.default is not ''): self.nwlist.append((self.default,self.default)) - config.plugins.wlan.essid = NoSave(ConfigSelection(self.nwlist, default = self.default )) - config.plugins.wlan.hiddenessid = NoSave(ConfigText(default = self.wsconfig['hiddenessid'], visible_width = 50, fixed_size = False)) - + + config.plugins.wlan.hiddenessid = NoSave(ConfigYesNo(default = self.hiddenNW)) + if config.plugins.wlan.hiddenessid.value is True: + config.plugins.wlan.essid = NoSave(ConfigText(default = self.default, visible_width = 50, fixed_size = False)) + else: + config.plugins.wlan.essid = NoSave(ConfigSelection(self.nwlist, default = self.default )) config.plugins.wlan.encryption.enabled = NoSave(ConfigYesNo(default = self.wsconfig['encryption'] )) config.plugins.wlan.encryption.type = NoSave(ConfigSelection(self.encryptionlist, default = self.wsconfig['encryption_type'] )) config.plugins.wlan.encryption.wepkeytype = NoSave(ConfigSelection(self.weplist, default = self.wsconfig['encryption_wepkeytype'] )) @@ -497,14 +505,16 @@ class AdapterSetup(Screen, ConfigListScreen, HelpableScreen): if p.__call__.has_key("configStrings"): self.configStrings = p.__call__["configStrings"] - if config.plugins.wlan.essid.value == 'hidden...': - self.wlanSSID = getConfigListEntry(_("Network SSID"), config.plugins.wlan.essid) - self.list.append(self.wlanSSID) - self.hiddenSSID = getConfigListEntry(_("Hidden network SSID"), config.plugins.wlan.hiddenessid) - self.list.append(self.hiddenSSID) + self.hiddenSSID = getConfigListEntry(_("enter hidden network SSID"), config.plugins.wlan.hiddenessid) + self.list.append(self.hiddenSSID) + + if config.plugins.wlan.hiddenessid.value is True: + config.plugins.wlan.essid = NoSave(ConfigText(default = self.default, visible_width = 50, fixed_size = False)) + self.wlanSSID = getConfigListEntry(_("Hidden network SSID"), config.plugins.wlan.essid) else: + config.plugins.wlan.essid = NoSave(ConfigSelection(self.nwlist, default = self.default )) self.wlanSSID = getConfigListEntry(_("Network SSID"), config.plugins.wlan.essid) - self.list.append(self.wlanSSID) + self.list.append(self.wlanSSID) self.encryptionEnabled = getConfigListEntry(_("Encryption"), config.plugins.wlan.encryption.enabled) self.list.append(self.encryptionEnabled) @@ -532,8 +542,8 @@ class AdapterSetup(Screen, ConfigListScreen, HelpableScreen): self.createSetup() if self["config"].getCurrent() == self.gatewayEntry: self.createSetup() - if iNetwork.isWirelessInterface(self.iface): - if self["config"].getCurrent() == self.wlanSSID: + if iNetwork.isWirelessInterface(self.iface): + if self["config"].getCurrent() == self.hiddenSSID: self.createSetup() if self["config"].getCurrent() == self.encryptionEnabled: self.createSetup() @@ -677,7 +687,7 @@ class AdapterSetup(Screen, ConfigListScreen, HelpableScreen): def hideInputHelp(self): current = self["config"].getCurrent() - if current == self.hiddenSSID and config.plugins.wlan.essid.value == 'hidden...': + if current == self.wlanSSID and config.plugins.wlan.hiddenessid.value: if current[1].help_window.instance is not None: current[1].help_window.instance.hide() elif current == self.encryptionKey and config.plugins.wlan.encryption.enabled.value: