X-Git-Url: http://code.vuplus.com/gitweb/?p=vuplus_dvbapp;a=blobdiff_plain;f=lib%2Fpython%2FPlugins%2FSystemPlugins%2FWirelessLanSetup%2Fplugin.py;h=cf3b83136edf1276fea53ba5902e85cf5158b78a;hp=0567187ae6434237752f860c325eb84a076b87c8;hb=6289ef18d5095cef593653918df00f725b4f68c4;hpb=168c0ba02927eec87e6cea380f81b797f60e84d4 diff --git a/lib/python/Plugins/SystemPlugins/WirelessLanSetup/plugin.py b/lib/python/Plugins/SystemPlugins/WirelessLanSetup/plugin.py index 0567187..cf3b831 100755 --- a/lib/python/Plugins/SystemPlugins/WirelessLanSetup/plugin.py +++ b/lib/python/Plugins/SystemPlugins/WirelessLanSetup/plugin.py @@ -67,6 +67,13 @@ class WlanSelection(Screen,HelpableScreen): "green": (self.ok, _("select interface")), "red": (self.close, _("exit network interface list")), }) + self.updateInterfaces() + self.onClose.append(self.cleanup) + + def updateInterfaces(self): + iNetwork.config_ready = False + iNetwork.msgPlugins() + iNetwork.getInterfaces() def ok(self): # print len(self["menulist"].list) @@ -81,35 +88,41 @@ class WlanSelection(Screen,HelpableScreen): def getWlandevice(self): list = [] - for x in iNetwork.getAdapterList(): + for x in iNetwork.getInstalledAdapters(): if x.startswith('eth'): continue - list.append((self.getAdapterDescription(x) + " (%s)"%x,x)) + description=self.getAdapterDescription(x) + if description == "Unknown network adapter": + list.append((description,x)) + else: + list.append((description + " (%s)"%x,x)) return list def getAdapterDescription(self, iface): - if iface == 'eth0': - return _("Internal LAN adapter.") - else: - classdir = "/sys/class/net/" + iface + "/device/" - driverdir = "/sys/class/net/" + iface + "/device/driver/" - if os_path.exists(classdir): - files = listdir(classdir) - if 'driver' in files: - if os_path.realpath(driverdir).endswith('rtw_usb_drv'): - return _("Realtak")+ " " + _("WLAN adapter.") - elif os_path.realpath(driverdir).endswith('ath_pci'): - return _("Atheros")+ " " + _("WLAN adapter.") - elif os_path.realpath(driverdir).endswith('zd1211b'): - return _("Zydas")+ " " + _("WLAN adapter.") - elif os_path.realpath(driverdir).endswith('rt73'): - return _("Ralink")+ " " + _("WLAN adapter.") - elif os_path.realpath(driverdir).endswith('rt73usb'): - return _("Ralink")+ " " + _("WLAN adapter.") - else: - return str(os_path.basename(os_path.realpath(driverdir))) + " " + _("WLAN adapter") + classdir = "/sys/class/net/" + iface + "/device/" + driverdir = "/sys/class/net/" + iface + "/device/driver/" + if os_path.exists(classdir): + files = listdir(classdir) + if 'driver' in files: + if os_path.realpath(driverdir).endswith('rtw_usb_drv'): + return _("Realtek")+ " " + _("WLAN adapter.") + elif os_path.realpath(driverdir).endswith('ath_pci'): + return _("Atheros")+ " " + _("WLAN adapter.") + elif os_path.realpath(driverdir).endswith('zd1211b'): + return _("Zydas")+ " " + _("WLAN adapter.") + elif os_path.realpath(driverdir).endswith('rt73'): + return _("Ralink")+ " " + _("WLAN adapter.") + elif os_path.realpath(driverdir).endswith('rt73usb'): + return _("Ralink")+ " " + _("WLAN adapter.") else: - return _("Unknown network adapter.") + return str(os_path.basename(os_path.realpath(driverdir))) + " " + _("WLAN adapter") + else: + return _("Unknown network adapter") + else: + return _("Unknown network adapter") + + def cleanup(self): + iNetwork.stopGetInterfacesConsole() class WlanSetup(Screen,HelpableScreen): skin = """ @@ -180,6 +193,7 @@ class WlanSetup(Screen,HelpableScreen): "left": self.left, "right": self.right, }, -2) + self.onClose.append(self.cleanup) def loadDescription(self): if self["menulist"].getCurrent()[1] == 'setting': @@ -212,6 +226,7 @@ class WlanSetup(Screen,HelpableScreen): self.loadDescription() def ok(self): + self.cleanup() if self["menulist"].getCurrent()[1] == 'setting': self.session.openWithCallback(self.checklist, WlanConfig, self.iface) elif self["menulist"].getCurrent()[1] == 'scanap': @@ -257,6 +272,10 @@ class WlanSetup(Screen,HelpableScreen): if data is True: self.session.open(MessageBox, _("Finished restarting your network"), type = MessageBox.TYPE_INFO, timeout = 5, default = False) + def cleanup(self): + iNetwork.stopRestartConsole() + iNetwork.stopGetInterfacesConsole() + wlanconfig = ConfigSubsection() wlanconfig.usedevice = ConfigSelection(default = "off", choices = [ ("off", _("off")), ("on", _("on"))]) @@ -269,7 +288,7 @@ wlanconfig.method = ConfigSelection(default = "wep", choices = [ ("wep", _("WEP")), ("wpa", _("WPA")), ("wpa2", _("WPA2")),("wpa/wpa2", _("WPA/WPA2"))]) wlanconfig.keytype = ConfigSelection(default = "ascii", choices = [ ("ascii", _("ASCII")), ("hex", _("HEX"))]) -wlanconfig.key = ConfigText(default = "XXXXXXXX", visible_width = 50, fixed_size = False) +wlanconfig.key = ConfigPassword(default = "XXXXXXXX", visible_width = 50, fixed_size = False) wlanconfig.usegateway = ConfigSelection(default = "off", choices = [ ("off", _("no")), ("on", _("yes"))]) wlanconfig.ip = ConfigIP([0,0,0,0]) @@ -325,24 +344,30 @@ class WlanConfig(Screen, ConfigListScreen, HelpableScreen): self.key_type = None self.encryption_key = None self.wlanscanap = None + self.wpaphraseconsole = None # self.scanAPcount =5 self.scanAPcount =1 self.list = [] ConfigListScreen.__init__(self, self.list,session = self.session) self.oldInterfaceState = iNetwork.getAdapterAttribute(self.iface, "up") self.readWpaSupplicantConf() -# iNetwork.getInterfaces(self.readWlanSettings) - self.readWlanSettings() self.scanAPFailedTimer = eTimer() self.scanAPFailedTimer.callback.append(self.scanAPFailed) self.scanAplistTimer = eTimer() self.scanAplistTimer.callback.append(self.scanApList) self.Console = Console() - self.scanAplistTimer.start(100,True) +# self.scanAplistTimer.start(100,True) + self.updateInterfaces(self.readWlanSettings) + self.onClose.append(self.cleanup) + + def updateInterfaces(self,callback = None): + iNetwork.config_ready = False + iNetwork.msgPlugins() + iNetwork.getInterfaces(callback) def readWlanSettings(self,ret=None): if ret is not True: - print "getAddrInet Fail... " + print "getInterfaces Fail... " if iNetwork.getAdapterAttribute(self.iface, "up") == True: default_tmp = "on" else: @@ -366,9 +391,9 @@ class WlanConfig(Screen, ConfigListScreen, HelpableScreen): wlanconfig.gateway = ConfigIP(default=iNetwork.getAdapterAttribute(self.iface, "gateway") or [0,0,0,0]) - self["ipaddress"] = StaticText(_(self.formatip(iNetwork.getAdapterAttribute(self.iface, "ip")))) - self["netmask"] = StaticText(_(self.formatip(iNetwork.getAdapterAttribute(self.iface, "netmask")))) - self["gateway"] = StaticText(_(self.formatip(iNetwork.getAdapterAttribute(self.iface, "gateway")))) + self["ipaddress"].setText(_(self.formatip(iNetwork.getAdapterAttribute(self.iface, "ip")))) + self["netmask"].setText(_(self.formatip(iNetwork.getAdapterAttribute(self.iface, "netmask")))) + self["gateway"].setText(_(self.formatip(iNetwork.getAdapterAttribute(self.iface, "gateway")))) if self.encryption_key is not None: default_tmp = "on" @@ -400,7 +425,9 @@ class WlanConfig(Screen, ConfigListScreen, HelpableScreen): wlanconfig.keytype = ConfigSelection(default = default_tmp, choices = [ ("ascii", _("ASCII")), ("hex", _("HEX"))]) default_tmp = self.encryption_key or "XXXXXXXX" - wlanconfig.key = ConfigText(default = default_tmp, visible_width = 50, fixed_size = False) +# default_tmp = "XXXXXXXX" + wlanconfig.key = ConfigPassword(default = default_tmp, visible_width = 50, fixed_size = False) + self.scanAplistTimer.start(100,True) def readWpaSupplicantConf(self): try: @@ -434,7 +461,10 @@ class WlanConfig(Screen, ConfigListScreen, HelpableScreen): elif data.startswith('psk="') and len(data) > 6: self.key_type = 1 # ascii self.encryption_key = data[5:-2] - elif data.startswith('psk=') and len(data) > 4: + elif data.startswith('#psk="') and len(data) > 6: + self.key_type = 0 # hex + self.encryption_key = data[6:-2] + elif not self.encryption_key and data.startswith('psk=') and len(data) > 4: self.key_type = 0 # hex self.encryption_key = data[4:-1] data = wpafd.readline() @@ -480,7 +510,8 @@ class WlanConfig(Screen, ConfigListScreen, HelpableScreen): self.configList.append( self.encryptEntry ) if wlanconfig.encrypt.value is "on" : self.configList.append( self.methodEntry ) - self.configList.append( self.keytypeEntry ) + if wlanconfig.method.value =="wep": + self.configList.append( self.keytypeEntry ) self.configList.append( self.keyEntry ) self["config"].list = self.configList @@ -537,7 +568,7 @@ class WlanConfig(Screen, ConfigListScreen, HelpableScreen): list = data.splitlines() for x in list: xx = x.lstrip() - if xx.startswith('ESSID:') and len(xx)>8: + if xx.startswith('ESSID:') and len(xx)>8 and xx[7:-1]not in self.apList: self.apList.append(xx[7:-1]) self.apList.append('Input hidden ESSID') # print "###### selectap : ",selectap @@ -570,16 +601,40 @@ class WlanConfig(Screen, ConfigListScreen, HelpableScreen): def newConfig(self): if self["config"].getCurrent() == self.usedeviceEntry or self["config"].getCurrent() == self.encryptEntry \ or self["config"].getCurrent() == self.usedhcpEntry or self["config"].getCurrent() == self.usegatewayEntry \ - or self["config"].getCurrent() == self.essidEntry: + or self["config"].getCurrent() == self.essidEntry or self["config"].getCurrent() == self.methodEntry: self.createConfig() def saveWlanConfig(self): - if self["config"].isChanged(): - self.session.openWithCallback(self.checkNetworkShares, MessageBox, (_("Are you sure you want to restart your network interfaces?\n") ) ) + try: + if self["config"].getCurrent() == self.keyEntry or self["config"].getCurrent() == self.hiddenessidEntry : + self["config"].getCurrent()[1].onDeselect(self.session) + if self["config"].isChanged(): + self.session.openWithCallback(self.checkNetworkConfig, MessageBox, (_("Are you sure you want to restart your network interfaces?\n") ) ) + else: + self.session.openWithCallback(self.checkNetworkConfig, MessageBox, (_("Network configuration is not changed....\n\nAre you sure you want to restart your network interfaces?\n") ) ) + except: + pass - def checkNetworkShares(self,ret = False): + def checkNetworkConfig(self, ret = False): if ret == False: + if self["config"].getCurrent() == self.keyEntry or self["config"].getCurrent() == self.hiddenessidEntry : + self["config"].getCurrent()[1].onSelect(self.session) + return + if wlanconfig.essid.value == 'Input hidden ESSID': + if len(wlanconfig.hiddenessid.value) == 0: + self.session.open(MessageBox, ("PLEASE INPUT HIDDEN ESSID"), type = MessageBox.TYPE_ERROR, timeout = 10) + return + if len(wlanconfig.key.value) == 0: + self.session.open(MessageBox, ("PLEASE INPUT NETWORK KEY"), type = MessageBox.TYPE_ERROR, timeout = 10) return + self.checkNetworkShares() + +# def checkNetworkShares(self,ret = False): +# if ret == False: +# if self["config"].getCurrent() == self.keyEntry or self["config"].getCurrent() == self.hiddenessidEntry : +# self["config"].getCurrent()[1].onSelect(self.session) +# return + def checkNetworkShares(self): if not self.Console: self.Console = Console() cmd = "cat /proc/mounts" @@ -594,6 +649,8 @@ class WlanConfig(Screen, ConfigListScreen, HelpableScreen): if split[2] in networks: self.session.open(MessageBox, ("NOT deconfiguring network interfaces :\n network shares still mounted\n"), type = MessageBox.TYPE_ERROR, timeout = 10) callback(False) + if self["config"].getCurrent() == self.keyEntry or self["config"].getCurrent() == self.hiddenessidEntry : + self["config"].getCurrent()[1].onSelect(self.session) return callback(True) @@ -604,13 +661,13 @@ class WlanConfig(Screen, ConfigListScreen, HelpableScreen): num_configured_if = len(iNetwork.getConfiguredAdapters()) if num_configured_if >= 1: if num_configured_if == 1 and self.iface in iNetwork.getConfiguredAdapters(): - self.writeWlanConfig(False) + self.getWpaPhrase(False) else: - self.session.openWithCallback(self.writeWlanConfig, MessageBox, (_("Are you sure you want to deactive another network interfaces?\n") ) ) + self.session.openWithCallback(self.getWpaPhrase, MessageBox, _("A second configured interface has been found.\n\nDo you want to disable the second network interface?"), default = True) else: - self.writeWlanConfig(False) + self.getWpaPhrase(False) - def writeWlanConfig(self,ret = False): + def getWpaPhrase(self,ret): if ret == True: configuredInterfaces = iNetwork.getConfiguredAdapters() for interface in configuredInterfaces: @@ -618,134 +675,131 @@ class WlanConfig(Screen, ConfigListScreen, HelpableScreen): continue iNetwork.setAdapterAttribute(interface, "up", False) iNetwork.deactivateInterface(interface) - ret=self.writeWpasupplicantConf() + if wlanconfig.method.value =="wep": + self.writeWpasupplicantConf("wep") # passphrasekey is not None + else: + if wlanconfig.essid.value == 'Input hidden ESSID': + cmd = 'wpa_passphrase %s %s' % (wlanconfig.hiddenessid.value,wlanconfig.key.value) + else : + cmd = 'wpa_passphrase %s %s' % (wlanconfig.essid.value,wlanconfig.key.value) + print cmd + self.wpaphraseconsole = Console() + self.wpaphraseconsole.ePopen(cmd, self.parseWpaPhrase, self.writeWpasupplicantConf) + + def parseWpaPhrase(self, result, retval, extra_args): + print "parseWpaPhrase" + (writewlanconfig) = extra_args + if self.wpaphraseconsole is not None: + print "retval = ",retval + if retval == 0: + self.wpaphraseconsole.killAll() + self.wpaphraseconsole = None + print "parseWpaPhrase result : " + print result + psk = None + for line in result.splitlines(): + if line.find('ssid') == -1 and line.find('#psk=') != -1: + plainpwd = line + elif line.find('psk=') != -1: + psk = line + if psk: + writewlanconfig(psk,plainpwd) +# writewlanconfig(None) + else: + writewlanconfig(None) + else: + writewlanconfig(None) + + def writeWpasupplicantConf(self, passphrasekey=None,plainpwd=None): + if passphrasekey: + wpafd = open("/etc/wpa_supplicant.conf","w") + if wpafd > 0: + contents = "#WPA Supplicant Configuration by STB\n" + contents += "ctrl_interface=/var/run/wpa_supplicant\n" + contents += "eapol_version=1\n" + contents += "fast_reauth=1\n" + + if wlanconfig.essid.value == 'Input hidden ESSID': + contents += "ap_scan=2\n" + else : + contents += "ap_scan=1\n" + contents += "network={\n" + if wlanconfig.essid.value == 'Input hidden ESSID': + contents += "\tssid=\""+wlanconfig.hiddenessid.value+"\"\n" + else : + contents += "\tssid=\""+wlanconfig.essid.value+"\"\n" + contents += "\tscan_ssid=0\n" + if wlanconfig.encrypt.value == "on": + if wlanconfig.method.value =="wep": + contents += "\tkey_mgmt=NONE\n" + contents += "\twep_key0=" + if wlanconfig.keytype.value == "ascii": + contents += "\""+wlanconfig.key.value+"\"\n" + else: + contents += wlanconfig.key.value+"\n" + else: + print "plainpwd : ",plainpwd + print "passphrasekey : ",passphrasekey + if wlanconfig.method.value == "wpa": + contents += "\tkey_mgmt=WPA-PSK\n" + contents += "\tproto=WPA\n" + contents += "\tpairwise=CCMP TKIP\n" + contents += "\tgroup=CCMP TKIP\n" + elif wlanconfig.method.value == "wpa2": + contents += "\tkey_mgmt=WPA-PSK\n" + contents += "\tproto=RSN\n" + contents += "\tpairwise=CCMP TKIP\n" + contents += "\tgroup=CCMP TKIP\n" + else: + contents += "\tkey_mgmt=WPA-PSK\n" + contents += "\tproto=WPA RSN\n" + contents += "\tpairwise=CCMP TKIP\n" + contents += "\tgroup=CCMP TKIP\n" + contents += plainpwd+"\n" + contents += passphrasekey+"\n" + else: + contents += "\tkey_mgmt=NONE\n" + contents += "}\n" + print "content = \n"+contents + wpafd.write(contents) + wpafd.close() + self.writeNetConfig(0) + else : + self.session.open(MessageBox, _("wpa_supplicant.conf open error."), type = MessageBox.TYPE_ERROR, timeout = 10) + self.writeNetConfig(-1) + else: + self.writeNetConfig(-2) + + def writeNetConfig(self,ret = -1): if ret == -1: self.session.open(MessageBox, _("wpa_supplicant.conf open error."), type = MessageBox.TYPE_ERROR, timeout = 10) return elif ret == -2: - self.session.open(MessageBox, _("hidden ESSID empty"), type = MessageBox.TYPE_ERROR, timeout = 10) - return - iffd = open("/etc/network/interfaces","r") - if iffd > 0: - prev_content = "" - next_content = "" - data = iffd.readline() - status = 0 - while len(data) >0 : - if data.startswith('iface '+self.iface) or data.startswith('auto '+self.iface): - status = 1 - data = iffd.readline() - continue - elif not data.startswith('auto lo') and data.startswith('auto '): - if ret == True or data[5:] not in iNetwork.getConfiguredAdapters(): - data = iffd.readline() - continue - if status == 1 and data.startswith('iface ') or data.startswith('auto '): - status = 2 - if status == 0: - prev_content += data - elif status == 2: - next_content += data - data = iffd.readline() - iffd.close() - iffd = open("/etc/network/interfaces","w") - if iffd > 0 : - if prev_content == "": - prev_content = "# automatically generated by STB\n" - prev_content += "# do Not change manually!\n\n" - prev_content += "auto lo\n" - prev_content += "iface lo inet loopback\n\n" - iffd.write(prev_content) - if wlanconfig.usedevice.value=="on": - iNetwork.setAdapterAttribute(self.iface, "up", True) - contents = "auto "+self.iface+"\n" - contents += "iface "+self.iface+" inet " - if wlanconfig.usedhcp.value =="on": - iNetwork.setAdapterAttribute(self.iface, "dhcp", True) - contents +="dhcp\n" - else: - iNetwork.setAdapterAttribute(self.iface, "dhcp", False) - contents +="static\n" -# print wlanconfig.ip.value - iNetwork.setAdapterAttribute(self.iface, "ip", wlanconfig.ip.value) - iNetwork.setAdapterAttribute(self.iface, "netmask", wlanconfig.netmask.value) - contents +="\taddress "+ self.formatip(wlanconfig.ip.value)+"\n" - contents +="\tnetmask "+ self.formatip(wlanconfig.netmask.value)+"\n" - if wlanconfig.usegateway.value == "on": - iNetwork.setAdapterAttribute(self.iface, "gateway", wlanconfig.gateway.value) - contents +="\tgateway "+ self.formatip(wlanconfig.gateway.value)+"\n" - contents += "\tpre-up wpa_supplicant -i"+self.iface+" -c/etc/wpa_supplicant.conf -B -D"+iNetwork.detectWlanModule(self.iface)+"\n" - contents += "\tpost-down wpa_cli terminate\n\n" - iffd.write(contents) - else: - iNetwork.setAdapterAttribute(self.iface, "up", False) - iNetwork.deactivateInterface(self.iface) - iffd.write(next_content) - iffd.close() - else : - self.session.open(MessageBox, _("/etc/network/interfaces open error."), type = MessageBox.TYPE_ERROR, timeout = 10) + self.session.open(MessageBox, _("Can NOT generate passphrase"), type = MessageBox.TYPE_ERROR, timeout = 10) return + + if wlanconfig.usedevice.value=="on": + iNetwork.setAdapterAttribute(self.iface, "up", True) + if wlanconfig.usedhcp.value =="on": + iNetwork.setAdapterAttribute(self.iface, "dhcp", True) + else: + iNetwork.setAdapterAttribute(self.iface, "dhcp", False) + iNetwork.setAdapterAttribute(self.iface, "ip", wlanconfig.ip.value) + iNetwork.setAdapterAttribute(self.iface, "netmask", wlanconfig.netmask.value) + if wlanconfig.usegateway.value == "on": + iNetwork.setAdapterAttribute(self.iface, "gateway", wlanconfig.gateway.value) + else: + iNetwork.setAdapterAttribute(self.iface, "up", False) + iNetwork.deactivateInterface(self.iface) + contents = "\tpre-up wpa_supplicant -i"+self.iface+" -c/etc/wpa_supplicant.conf -B -D"+iNetwork.detectWlanModule(self.iface)+"\n" + contents += "\tpost-down wpa_cli terminate\n\n" + iNetwork.setAdapterAttribute(self.iface, "configStrings", contents) + iNetwork.writeNetworkConfig() iNetwork.restartNetwork(self.updateCurrentInterfaces) self.configurationmsg = None self.configurationmsg = self.session.openWithCallback(self.configFinished, MessageBox, _("Please wait for activation of your network configuration..."), type = MessageBox.TYPE_INFO, enable_input = False) - def writeWpasupplicantConf(self): - wpafd = open("/etc/wpa_supplicant.conf","w") - if wpafd > 0: - contents = "#WPA Supplicant Configuration by STB\n" - contents += "ctrl_interface=/var/run/wpa_supplicant\n" - contents += "eapol_version=1\n" - contents += "fast_reauth=1\n" - if wlanconfig.essid.value == 'Input hidden ESSID': - contents += "ap_scan=2\n" - else : - contents += "ap_scan=1\n" - contents += "network={\n" - if wlanconfig.essid.value == 'Input hidden ESSID': - if len(wlanconfig.hiddenessid.value) == 0: - wpafd.close() - return -2 - contents += "\tssid=\""+wlanconfig.hiddenessid.value+"\"\n" - else : - contents += "\tssid=\""+wlanconfig.essid.value+"\"\n" - contents += "\tscan_ssid=0\n" - if wlanconfig.encrypt.value == "on": - if wlanconfig.method.value =="wep": - contents += "\tkey_mgmt=NONE\n" - contents += "\twep_key0=" - elif wlanconfig.method.value == "wpa": - contents += "\tkey_mgmt=WPA-PSK\n" - contents += "\tproto=WPA\n" - contents += "\tpairwise=CCMP TKIP\n" - contents += "\tgroup=CCMP TKIP\n" - contents += "\tpsk=" - elif wlanconfig.method.value == "wpa2": - contents += "\tkey_mgmt=WPA-PSK\n" - contents += "\tproto=RSN\n" - contents += "\tpairwise=CCMP TKIP\n" - contents += "\tgroup=CCMP TKIP\n" - contents += "\tpsk=" - else: - contents += "\tkey_mgmt=WPA-PSK\n" - contents += "\tproto=WPA RSN\n" - contents += "\tpairwise=CCMP TKIP\n" - contents += "\tgroup=CCMP TKIP\n" - contents += "\tpsk=" - if wlanconfig.keytype.value == "ascii": - contents += "\""+wlanconfig.key.value+"\"\n" - else: - contents += wlanconfig.key.value+"\n" - else: - contents += "\tkey_mgmt=NONE\n" - contents += "}\n" - print "content = \n"+contents - wpafd.write(contents) - wpafd.close() - return 0 - else : - self.session.open(MessageBox, _("wpa_supplicant.conf open error."), type = MessageBox.TYPE_ERROR, timeout = 10) - return -1 def updateCurrentInterfaces(self,ret): if ret is True: iNetwork.getInterfaces(self.configurationMsgClose) @@ -799,9 +853,31 @@ class WlanConfig(Screen, ConfigListScreen, HelpableScreen): if data is True: self.close() -# def selectionChanged(self): -# current = self["config"].getCurrent() -# print current + def cleanup(self): + iNetwork.stopRestartConsole() + iNetwork.stopGetInterfacesConsole() + iNetwork.stopDeactivateInterfaceConsole() + self.stopwlanscanapConsole() + self.stopCheckNetworkSharesConsole() + self.stopWpaPhraseConsole() + + def stopwlanscanapConsole(self): + if self.wlanscanap is not None: + if len(self.wlanscanap.appContainers): + for name in self.wlanscanap.appContainers.keys(): + self.wlanscanap.kill(name) + + def stopCheckNetworkSharesConsole(self): + if self.Console is not None: + if len(self.Console.appContainers): + for name in self.Console.appContainers.keys(): + self.Console.kill(name) + + def stopWpaPhraseConsole(self): + if self.wpaphraseconsole is not None: + if len(self.wpaphraseconsole.appContainers): + for name in self.wpaphraseconsole.appContainers.keys(): + self.wpaphraseconsole.kill(name) class WlanScanAp(Screen,HelpableScreen): skin = """ @@ -887,6 +963,7 @@ class WlanScanAp(Screen,HelpableScreen): self.scanAplistTimer = eTimer() self.scanAplistTimer.callback.append(self.scanApList) self.scanAplistTimer.start(100,True) + self.onClose.append(self.cleanup) def left(self): self["menulist"].pageUp() @@ -914,6 +991,7 @@ class WlanScanAp(Screen,HelpableScreen): global selectap selectAp=self["menulist"].getCurrent()[0] selectap = selectAp + self.cleanup() self.session.open(WlanConfig,self.iface) # self.close() @@ -1007,6 +1085,15 @@ class WlanScanAp(Screen,HelpableScreen): def ScanAPclose(self,data): self.close() + def cleanup(self): + self.stopwlanscanapConsole() + + def stopwlanscanapConsole(self): + if self.wlanscanap is not None: + if len(self.wlanscanap.appContainers): + for name in self.wlanscanap.appContainers.keys(): + self.wlanscanap.kill(name) + class NetworkAdapterTest(Screen): def __init__(self, session,iface): Screen.__init__(self, session) @@ -1264,6 +1351,7 @@ class NetworkAdapterTest(Screen): self["InfoText"].show() self["key_red"].setText(_("Back")) if self.activebutton == 6: # Edit Settings + self.cleanup() self.session.open(WlanConfig,self.iface) self["shortcuts"].setEnabled(True) self["infoshortcuts"].setEnabled(False) @@ -1389,6 +1477,7 @@ class NetworkAdapterTest(Screen): def cleanup(self): iNetwork.stopLinkStateConsole() + iNetwork.stopPingConsole() iNetwork.stopDNSConsole() def AccessPointInfo(self,iface): @@ -1398,7 +1487,7 @@ class NetworkAdapterTest(Screen): def readAP(self,result,retval,extra_args): (callback) = extra_args - self.apState = False + self.apState = None if self.iwconfigConsole is not None: if retval == 0: self.iwconfigConsole = None @@ -1436,6 +1525,7 @@ class Wlanstatus(Screen): "red": self.close, }, -2) self.readstatus() + self.onClose.append(self.cleanup) def readstatus(self): self.wlanstatus = Console() @@ -1463,6 +1553,15 @@ class Wlanstatus(Screen): def ok(self): pass + def cleanup(self): + self.stopWlanStatusConsole() + + def stopWlanStatusConsole(self): + if self.wlanstatus is not None: + if len(self.wlanstatus.appContainers): + for name in self.wlanstatus.appContainers.keys(): + self.wlanstatus.kill(name) + def openconfig(session, **kwargs): session.open(WlanSelection) @@ -1471,7 +1570,7 @@ def selSetup(menuid, **kwargs): if menuid != "system": return [ ] else: - for x in iNetwork.getAdapterList(): + for x in iNetwork.getInstalledAdapters(): if x.startswith('eth'): continue list.append(x)