X-Git-Url: http://code.vuplus.com/gitweb/?a=blobdiff_plain;f=lib%2Fpython%2FPlugins%2FSystemPlugins%2FWirelessLan%2Fplugin.py;h=10213eb0c49c49b49fb913c1a0fda45c41abb41e;hb=a1c8dbaceeb6df080f092e6caa6747ae19799a3c;hp=c296ab70f031a87b02d06909fbbaf30e653d3b81;hpb=26a1c69f126a59ec9aeda715ef6d516d42fd10c4;p=vuplus_dvbapp diff --git a/lib/python/Plugins/SystemPlugins/WirelessLan/plugin.py b/lib/python/Plugins/SystemPlugins/WirelessLan/plugin.py index c296ab7..10213eb 100644 --- a/lib/python/Plugins/SystemPlugins/WirelessLan/plugin.py +++ b/lib/python/Plugins/SystemPlugins/WirelessLan/plugin.py @@ -19,28 +19,29 @@ from Wlan import iWlan, wpaSupplicant, iStatus, getWlanConfigName import hashlib from time import time from os import urandom, system +from re import escape as re_escape plugin_path = eEnv.resolve("${libdir}/enigma2/python/Plugins/SystemPlugins/WirelessLan") + list = [] +list.append("Unencrypted") list.append("WEP") list.append("WPA") -list.append("WPA2") list.append("WPA/WPA2") +list.append("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.essid = NoSave(ConfigText(default = "", fixed_size = False)) +config.plugins.wlan.hiddenessid = NoSave(ConfigYesNo(default = False)) +config.plugins.wlan.encryption = NoSave(ConfigSelection(list, default = "WPA2")) +config.plugins.wlan.wepkeytype = NoSave(ConfigSelection(weplist, default = "ASCII")) +config.plugins.wlan.psk = NoSave(ConfigPassword(default = "", 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 WlanStatus(Screen): @@ -48,20 +49,19 @@ class WlanStatus(Screen): - - - - - - - - - - - - - - + + + + + + + + + + + + + @@ -107,7 +107,7 @@ class WlanStatus(Screen): }, -1) self.timer = eTimer() self.timer.timeout.get().append(self.resetList) - self.onShown.append(lambda: self.timer.start(5000)) + self.onShown.append(lambda: self.timer.start(8000)) self.onLayoutFinish.append(self.layoutFinished) self.onClose.append(self.cleanup) @@ -115,7 +115,7 @@ class WlanStatus(Screen): iStatus.stopWlanConsole() def layoutFinished(self): - self.setTitle(_("Wireless Network State")) + self.setTitle(_("Wireless network state")) def resetList(self): iStatus.getDataForInterface(self.iface,self.getInfoCB) @@ -124,32 +124,65 @@ class WlanStatus(Screen): if data is not None: if data is True: if status is not None: - self["BSSID"].setText(status[self.iface]["acesspoint"]) - self["ESSID"].setText(status[self.iface]["essid"]) - self["quality"].setText(status[self.iface]["quality"]) - self["signal"].setText(status[self.iface]["signal"]) - self["bitrate"].setText(status[self.iface]["bitrate"]) - self["enc"].setText(status[self.iface]["encryption"]) + if status[self.iface]["essid"] == "off": + essid = _("No Connection") + else: + essid = status[self.iface]["essid"] + if status[self.iface]["accesspoint"] == "Not-Associated": + accesspoint = _("Not-Associated") + essid = _("No Connection") + else: + accesspoint = status[self.iface]["accesspoint"] + if self.has_key("BSSID"): + self["BSSID"].setText(accesspoint) + if self.has_key("ESSID"): + self["ESSID"].setText(essid) + + quality = status[self.iface]["quality"] + if self.has_key("quality"): + self["quality"].setText(quality) + + if status[self.iface]["bitrate"] == '0': + bitrate = _("Unsupported") + else: + bitrate = str(status[self.iface]["bitrate"]) + " Mb/s" + if self.has_key("bitrate"): + self["bitrate"].setText(bitrate) + + signal = status[self.iface]["signal"] + if self.has_key("signal"): + self["signal"].setText(signal) + + if status[self.iface]["encryption"] == "off": + if accesspoint == "Not-Associated": + encryption = _("Disabled") + else: + encryption = _("Unsupported") + else: + encryption = _("Enabled") + if self.has_key("enc"): + self["enc"].setText(encryption) self.updateStatusLink(status) def exit(self): self.timer.stop() - self.close(True) + self.close(True) def updateStatusbar(self): - self["BSSID"].setText(_("Please wait...")) - self["ESSID"].setText(_("Please wait...")) - self["quality"].setText(_("Please wait...")) - self["signal"].setText(_("Please wait...")) - self["bitrate"].setText(_("Please wait...")) - self["enc"].setText(_("Please wait...")) + wait_txt = _("Please wait...") + self["BSSID"].setText(wait_txt) + self["ESSID"].setText(wait_txt) + self["quality"].setText(wait_txt) + self["signal"].setText(wait_txt) + self["bitrate"].setText(wait_txt) + self["enc"].setText(wait_txt) self["IFtext"].setText(_("Network:")) self["IF"].setText(iNetwork.getFriendlyAdapterName(self.iface)) self["Statustext"].setText(_("Link:")) def updateStatusLink(self,status): if status is not None: - if status[self.iface]["acesspoint"] == "No Connection" or status[self.iface]["acesspoint"] == "Not-Associated" or status[self.iface]["acesspoint"] == False: + if status[self.iface]["essid"] == "off" or status[self.iface]["accesspoint"] == "Not-Associated" or status[self.iface]["accesspoint"] == False: self["statuspic"].setPixmapNum(1) else: self["statuspic"].setPixmapNum(0) @@ -233,19 +266,15 @@ class WlanScan(Screen): iWlan.stopGetNetworkList() self.rescanTimer.stop() del self.rescanTimer - if cur[1] is not None: - if cur[1] == 'hidden...': - essid = cur[1] - else: - essid = cur[0] - self.close(essid,self.getWlanList()) + if cur[0] is not None: + self.close(cur[0]) else: - self.close(None,None) + self.close(None) else: iWlan.stopGetNetworkList() self.rescanTimer.stop() del self.rescanTimer - self.close(None,None) + self.close(None) def cancel(self): iWlan.stopGetNetworkList() @@ -260,10 +289,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...': - 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)) + return((essid, bssid, _("Signal: ") + str(signal), _("Max. Bitrate: ") + str(maxrate), _("Encrypted: ") + encryption, _("Interface: ") + str(iface), divpng)) def updateAPList(self): newList = [] @@ -280,20 +306,19 @@ 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"), "" ) ) - for entry in tmpList: self.newAPList.append(self.buildEntryComponent( entry[0], entry[1], entry[2], entry[3], entry[4], entry[5] )) currentListEntry = self["list"].getCurrent() - idx = 0 - for entry in self.newAPList: - if entry[0] == currentListEntry[0]: - newListIndex = idx - idx +=1 + if currentListEntry is not None: + idx = 0 + for entry in self.newAPList: + if entry[0] == currentListEntry[0]: + newListIndex = idx + idx +=1 self['list'].setList(self.newAPList) - self["list"].setIndex(newListIndex) + if newListIndex is not None: + self["list"].setIndex(newListIndex) self["list"].updateList(self.newAPList) self.listLength = len(self.newAPList) self.buildWlanList() @@ -325,9 +350,6 @@ 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"), "" ) ) - for entry in self.cleanList: self.APList.append(self.buildEntryComponent( entry[0], entry[1], entry[2], entry[3], entry[4], entry[5] )) @@ -340,20 +362,17 @@ class WlanScan(Screen): def setInfo(self): length = self.getLength() - if length <= 1: - self["info"].setText(_("No wireless networks found! Please refresh.")) - elif length == 2: + if length == 0: + self["info"].setText(_("No wireless networks found! Searching...")) + elif length == 1: self["info"].setText(_("1 wireless network found!")) else: - self["info"].setText(str(length-1)+_(" wireless networks found!")) + self["info"].setText(str(length)+_(" wireless networks found!")) def buildWlanList(self): self.WlanList = [] for entry in self['list'].list: - if entry[1] == "hidden...": - self.WlanList.append(( "hidden...",_("enter hidden network SSID") )) - else: - self.WlanList.append( (entry[0], entry[0]) ) + self.WlanList.append( (entry[0], entry[0]) ) def getLength(self): return self.listLength @@ -418,8 +437,11 @@ def callFunction(iface): return None def configStrings(iface): - hardware_info = HardwareInfo() - if hardware_info.device_name != "dm7025": + try: + device = open("/proc/stb/info/model", "r").readline().strip() + except: + device = "" + if device != "dm7025": rootkey = ['\x9f', '|', '\xe4', 'G', '\xc9', '\xb4', '\xf4', '#', '&', '\xce', '\xb3', '\xfe', '\xda', '\xc9', 'U', '`', '\xd8', '\x8c', 's', 'o', '\x90', '\x9b', '\\', 'b', '\xc0', '\x89', '\xd1', '\x8c', '\x9e', 'J', 'T', '\xc5', 'X', '\xa1', '\xb8', '\x13', '5', 'E', '\x02', '\xc9', '\xb2', '\xe6', 't', '\x89', '\xde', '\xcd', '\x9d', '\x11', '\xdd', '\xc7', '\xf4', '\xe4', '\xe4', '\xbc', '\xdb', '\x9c', '\xea', '}', '\xad', '\xda', 't', 'r', '\x9b', '\xdc', '\xbc', '\x18', '3', '\xe7', '\xaf', '|', '\xae', '\x0c', '\xe3', '\xb5', '\x84', '\x8d', '\r', '\x8d', '\x9d', '2', '\xd0', '\xce', '\xd5', 'q', '\t', '\x84', 'c', '\xa8', ')', '\x99', '\xdc', '<', '"', 'x', '\xe8', '\x87', '\x8f', '\x02', ';', 'S', 'm', '\xd5', '\xf0', '\xa3', '_', '\xb7', 'T', '\t', '\xde', '\xa7', '\xf1', '\xc9', '\xae', '\x8a', '\xd7', '\xd2', '\xcf', '\xb2', '.', '\x13', '\xfb', '\xac', 'j', '\xdf', '\xb1', '\x1d', ':', '?'] etpm = eTPM() l2cert = etpm.getCert(eTPM.TPMD_DT_LEVEL2_CERT) @@ -439,14 +461,14 @@ def configStrings(iface): return val = etpm.challenge(rnd) result = decrypt_block(val, l3key) - if hardware_info.device_name == "dm7025" or result[80:88] == rnd: + if device == "dm7025" or result[80:88] == rnd: driver = iNetwork.detectWlanModule(iface) else: 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 \"" + re_escape(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