aboutsummaryrefslogtreecommitdiff
path: root/lib/python/Plugins/SystemPlugins
diff options
context:
space:
mode:
authorMladen Horvat <acid-burn@opendreambox.org>2011-04-13 16:23:09 +0200
committerMladen Horvat <acid-burn@opendreambox.org>2011-04-13 16:23:09 +0200
commitc563ffd07163d5982fa4a3d8e9c2486f480b899a (patch)
tree61b3c5c40b8860ea5f0abb9fdc985c6470ca34b0 /lib/python/Plugins/SystemPlugins
parent8a21c8eebc037850431ac627061e46e48e93a0ec (diff)
downloadenigma2-c563ffd07163d5982fa4a3d8e9c2486f480b899a.tar.gz
enigma2-c563ffd07163d5982fa4a3d8e9c2486f480b899a.zip
Enigma2-{Network,NetworkWizard,WirelessLan}: more work on wireless lan / networking. removed 'hidden' links from lists and replaced with more intuitive options in networkwizard/networksetup.
fixes #725
Diffstat (limited to 'lib/python/Plugins/SystemPlugins')
-rwxr-xr-xlib/python/Plugins/SystemPlugins/NetworkWizard/NetworkWizard.py89
-rwxr-xr-xlib/python/Plugins/SystemPlugins/NetworkWizard/networkwizard.xml25
-rwxr-xr-xlib/python/Plugins/SystemPlugins/WirelessLan/Wlan.py190
-rw-r--r--lib/python/Plugins/SystemPlugins/WirelessLan/plugin.py140
4 files changed, 222 insertions, 222 deletions
diff --git a/lib/python/Plugins/SystemPlugins/NetworkWizard/NetworkWizard.py b/lib/python/Plugins/SystemPlugins/NetworkWizard/NetworkWizard.py
index 9f254066..cb954bb2 100755
--- a/lib/python/Plugins/SystemPlugins/NetworkWizard/NetworkWizard.py
+++ b/lib/python/Plugins/SystemPlugins/NetworkWizard/NetworkWizard.py
@@ -57,7 +57,6 @@ class NetworkWizard(WizardLanguage, Rc):
self.AdapterRef = None
self.APList = None
self.newAPlist = None
- self.WlanList = None
self.oldlist = None
self.originalInterfaceState = {}
@@ -79,6 +78,11 @@ class NetworkWizard(WizardLanguage, Rc):
self.checkOldInterfaceState()
pass
+ def back(self):
+ self.stopScan()
+ self.ap = None
+ WizardLanguage.back(self)
+
def stopScan(self):
self.rescanTimer.stop()
if self.w is not None:
@@ -88,7 +92,6 @@ class NetworkWizard(WizardLanguage, Rc):
def getInstalledInterfaceCount(self):
self.originalInterfaceState = {}
- self.stopScan()
self.Adapterlist = iNetwork.getAdapterList()
self.InstalledInterfaceCount = len(self.Adapterlist)
if self.Adapterlist is not None:
@@ -105,7 +108,7 @@ class NetworkWizard(WizardLanguage, Rc):
if not iNetwork.isWirelessInterface(self.selectedInterface):
self.NextStep = 'nwconfig'
else:
- self.NextStep = 'scanwlan'
+ self.NextStep = 'asknetworktype'
self.checkInterface(self.selectedInterface)
else:
self.NextStep = 'selectinterface'
@@ -115,19 +118,19 @@ class NetworkWizard(WizardLanguage, Rc):
if not iNetwork.isWirelessInterface(self.selectedInterface):
self.NextStep = 'nwconfig'
else:
- self.NextStep = 'scanwlan'
+ self.NextStep = 'asknetworktype'
self.checkInterface(self.selectedInterface)
def checkOldInterfaceState(self):
# disable up interface if it was originally down and config is unchanged.
if self.originalInterfaceStateChanged is False:
for interface in self.originalInterfaceState.keys():
- if self.originalInterfaceState[interface]["up"] is False:
- if iNetwork.checkforInterface(interface) is True:
- system("ifconfig " + interface + " down")
+ if interface == self.selectedInterface:
+ if self.originalInterfaceState[interface]["up"] is False:
+ if iNetwork.checkforInterface(interface) is True:
+ system("ifconfig " + interface + " down")
def listInterfaces(self):
- self.stopScan()
self.checkOldInterfaceState()
list = [(iNetwork.getFriendlyAdapterName(x),x) for x in iNetwork.getAdapterList()]
list.append((_("Exit network wizard"), "end"))
@@ -143,7 +146,7 @@ class NetworkWizard(WizardLanguage, Rc):
elif index == 'eth0':
self.NextStep = 'nwconfig'
else:
- self.NextStep = 'scanwlan'
+ self.NextStep = 'asknetworktype'
def InterfaceSelectionMoved(self):
self.InterfaceSelect(self.selection)
@@ -229,7 +232,7 @@ class NetworkWizard(WizardLanguage, Rc):
if data is True:
if status is not None:
text1 = _("Your Dreambox is now ready to use.\n\nYour internet connection is working now.\n\n")
- text2 = _('Accesspoint:') + "\t" + str(status[self.selectedInterface]["acesspoint"]) + "\n"
+ text2 = _('Accesspoint:') + "\t" + str(status[self.selectedInterface]["accesspoint"]) + "\n"
text3 = _('SSID:') + "\t" + str(status[self.selectedInterface]["essid"]) + "\n"
text4 = _('Link Quality:') + "\t" + str(status[self.selectedInterface]["quality"])+ "\n"
text5 = _('Signal Strength:') + "\t" + str(status[self.selectedInterface]["signal"]) + "\n"
@@ -239,7 +242,7 @@ class NetworkWizard(WizardLanguage, Rc):
infotext = text1 + text2 + text3 + text4 + text5 + text7 +"\n" + text8
self.currStep = self.getStepWithID("checkWlanstatusend")
self.Text = infotext
- if str(status[self.selectedInterface]["acesspoint"]) == "Not-Associated":
+ if str(status[self.selectedInterface]["accesspoint"]) == "Not-Associated":
self.InterfaceState = False
self.afterAsyncCode()
@@ -284,42 +287,32 @@ class NetworkWizard(WizardLanguage, Rc):
newList.append(oldentry)
for newentry in newList:
- if newentry[1] == "<hidden>":
- continue
self.newAPlist.append(newentry)
-
- if len(self.newAPlist):
- if "<hidden>" not in self.newAPlist:
- self.newAPlist.append(( _("enter hidden network SSID"), "<hidden>" ))
+ if len(self.newAPlist):
if (self.wizard[self.currStep].has_key("dynamiclist")):
currentListEntry = self["list"].getCurrent()
- idx = 0
- for entry in self.newAPlist:
- if entry == currentListEntry:
- newListIndex = idx
- idx +=1
+ if currentListEntry is not None:
+ idx = 0
+ for entry in self.newAPlist:
+ if entry == currentListEntry:
+ newListIndex = idx
+ idx +=1
self.wizard[self.currStep]["evaluatedlist"] = self.newAPlist
self['list'].setList(self.newAPlist)
- self["list"].setIndex(newListIndex)
+ if newListIndex is not None:
+ self["list"].setIndex(newListIndex)
self["list"].updateList(self.newAPlist)
def listAccessPoints(self):
self.APList = []
if self.WlanPluginInstalled is False:
- self.APList.append( ( _("No networks found"),_("unavailable") ) )
- return self.APList
+ self.APList.append( ( _("No networks found"), None ) )
else:
- try:
- from Plugins.SystemPlugins.WirelessLan.Wlan import iWlan
- iWlan.setInterface(self.selectedInterface)
- self.w = iWlan.getInterface()
- aps = iWlan.getNetworkList()
- except ValueError:
- self.APList = []
- self.APList.append( ( _("No networks found"),_("unavailable") ) )
- return self.APList
-
+ from Plugins.SystemPlugins.WirelessLan.Wlan import iWlan
+ iWlan.setInterface(self.selectedInterface)
+ self.w = iWlan.getInterface()
+ aps = iWlan.getNetworkList()
if aps is not None:
print "[NetworkWizard.py] got Accespoints!"
tmplist = []
@@ -337,28 +330,16 @@ 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 len(aps):
+ self.APList.append( ( _("No networks found"), None ) )
- self.rescanTimer.start(5000)
- return self.APList
+ self.rescanTimer.start(4000)
+ return self.APList
- def AccessPointsSelectionMade(self, index):
- self.ap = index
- self.WlanList = []
- if (self.wizard[self.currStep].has_key("dynamiclist")):
- for entry in self['list'].list:
- if entry[1] == "<hidden>":
- continue
- self.WlanList.append( (entry[1], entry[0]) )
- self.AccessPointsSelect(index)
-
- def AccessPointsSelect(self, index):
- self.NextStep = 'wlanconfig'
def AccessPointsSelectionMoved(self):
- self.AccessPointsSelect(self.selection)
+ self.ap = self.selection
+ self.NextStep = 'wlanconfig'
def checkWlanSelection(self):
self.stopScan()
@@ -391,7 +372,7 @@ class NetworkWizard(WizardLanguage, Rc):
self.selectedInterface = "eth0"
self.NextStep = 'nwconfig'
else:
- self.NextStep = 'scanwlan'
+ self.NextStep = 'asknetworktype'
def ChoicesSelectionMoved(self):
pass
diff --git a/lib/python/Plugins/SystemPlugins/NetworkWizard/networkwizard.xml b/lib/python/Plugins/SystemPlugins/NetworkWizard/networkwizard.xml
index c4300436..0b3a2988 100755
--- a/lib/python/Plugins/SystemPlugins/NetworkWizard/networkwizard.xml
+++ b/lib/python/Plugins/SystemPlugins/NetworkWizard/networkwizard.xml
@@ -87,13 +87,33 @@ self.selectKey("DOWN")
<listentry caption="Exit network wizard" step="end" />
</list>
</step>
+
+ <step id="asknetworktype">
+ <condition>
+self.condition = (self.isInterfaceUp == True and self.WlanPluginInstalled == True)
+ </condition>
+ <text value="Wireless network connection setup." />
+ <displaytext value="Wireless network connection setup" />
+ <code>
+self.clearSelectedKeys()
+self.selectKey("OK")
+self.selectKey("UP")
+self.selectKey("DOWN")
+ </code>
+ <list>
+ <listentry caption="List available networks" step="scanwlan" />
+ <listentry caption="Manual configuration" step="wlanconfig" />
+ <listentry caption="Exit network wizard" step="end" />
+ </list>
+ </step>
+
<step id="scanwlan">
<condition>
self.condition = (self.isInterfaceUp == True and self.WlanPluginInstalled == True)
</condition>
<text value="Please select the wireless network that you want to connect to.\n\nPlease press OK to continue." />
<displaytext value="Select wireless network" />
- <list type="dynamic" source="listAccessPoints" evaluation="AccessPointsSelectionMade" onselect="AccessPointsSelectionMoved" />
+ <list type="dynamic" source="listAccessPoints" onselect="AccessPointsSelectionMoved" />
<code>
self.clearSelectedKeys()
self.selectKey("OK")
@@ -138,7 +158,7 @@ self.selectKey("DOWN")
<step id="wlanconfig">
<text value="Please configure your internet connection by filling out the required values.\nWhen you are ready press OK to continue." />
<displaytext value="Configure interface" />
- <config screen="AdapterSetup" module="NetworkSetup" args="(self.selectedInterface,self.ap,self.WlanList)" type="ConfigList" />
+ <config screen="AdapterSetup" module="NetworkSetup" args="(self.selectedInterface,self.ap)" type="ConfigList" />
<code>
self.clearSelectedKeys()
self.selectKey("OK")
@@ -196,4 +216,3 @@ self.selectKey("OK")
</step>
</wizard>
-
diff --git a/lib/python/Plugins/SystemPlugins/WirelessLan/Wlan.py b/lib/python/Plugins/SystemPlugins/WirelessLan/Wlan.py
index 4a7b1e88..a1851579 100755
--- a/lib/python/Plugins/SystemPlugins/WirelessLan/Wlan.py
+++ b/lib/python/Plugins/SystemPlugins/WirelessLan/Wlan.py
@@ -6,29 +6,28 @@ from os import system, path as os_path
from string import maketrans, strip
import sys
import types
-from re import compile as re_compile, search as re_search
+from re import compile as re_compile, search as re_search, escape as re_escape
from pythonwifi.iwlibs import getNICnames, Wireless, Iwfreq, getWNICnames
from pythonwifi import flags as wififlags
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.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 = True))
-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))
def getWlanConfigName(iface):
return '/etc/wpa_supplicant.' + iface + '.conf'
@@ -74,10 +73,9 @@ class Wlan:
scanresults = ifobj.scan()
except:
scanresults = None
- print "[Wlan.py] No Wireless Networks could be found"
-
+ print "[Wlan.py] No wireless networks could be found"
+ aps = {}
if scanresults is not None:
- aps = {}
(num_channels, frequencies) = ifobj.getChannelInfo()
index = 1
for result in scanresults:
@@ -116,9 +114,9 @@ class Wlan:
'signal' : str(signal),
'custom' : extra,
}
- #print "GOT APS ENTRY:",aps[bssid]
+
index = index + 1
- return aps
+ return aps
def stopGetNetworkList(self):
if self.oldInterfaceState is not None:
@@ -137,10 +135,9 @@ class wpaSupplicant:
def writeConfig(self, iface):
essid = config.plugins.wlan.essid.value
hiddenessid = config.plugins.wlan.hiddenessid.value
- encrypted = config.plugins.wlan.encryption.enabled.value
- encryption = config.plugins.wlan.encryption.type.value
- wepkeytype = config.plugins.wlan.encryption.wepkeytype.value
- psk = config.plugins.wlan.encryption.psk.value
+ encryption = config.plugins.wlan.encryption.value
+ wepkeytype = config.plugins.wlan.wepkeytype.value
+ psk = config.plugins.wlan.psk.value
fp = file(getWlanConfigName(iface), 'w')
fp.write('#WPA Supplicant Configuration by enigma2\n')
fp.write('ctrl_interface=/var/run/wpa_supplicant\n')
@@ -154,31 +151,29 @@ class wpaSupplicant:
fp.write('network={\n')
fp.write('\tssid="'+essid+'"\n')
fp.write('\tscan_ssid=0\n')
- if encrypted:
- if encryption in ('WPA', 'WPA2', 'WPA/WPA2'):
- fp.write('\tkey_mgmt=WPA-PSK\n')
-
- if encryption == 'WPA':
- fp.write('\tproto=WPA\n')
- fp.write('\tpairwise=TKIP\n')
- fp.write('\tgroup=TKIP\n')
- elif encryption == 'WPA2':
- fp.write('\tproto=RSN\n')
- fp.write('\tpairwise=CCMP\n')
- fp.write('\tgroup=CCMP\n')
- else:
- fp.write('\tproto=WPA RSN\n')
- fp.write('\tpairwise=CCMP TKIP\n')
- fp.write('\tgroup=CCMP TKIP\n')
- fp.write('\tpsk="'+psk+'"\n')
- elif encryption == 'WEP':
- fp.write('\tkey_mgmt=NONE\n')
- if wepkeytype == 'ASCII':
- fp.write('\twep_key0="'+psk+'"\n')
- else:
- fp.write('\twep_key0='+psk+'\n')
+ if encryption in ('WPA', 'WPA2', 'WPA/WPA2'):
+ fp.write('\tkey_mgmt=WPA-PSK\n')
+ if encryption == 'WPA':
+ fp.write('\tproto=WPA\n')
+ fp.write('\tpairwise=TKIP\n')
+ fp.write('\tgroup=TKIP\n')
+ elif encryption == 'WPA2':
+ fp.write('\tproto=RSN\n')
+ fp.write('\tpairwise=CCMP\n')
+ fp.write('\tgroup=CCMP\n')
+ else:
+ fp.write('\tproto=WPA RSN\n')
+ fp.write('\tpairwise=CCMP TKIP\n')
+ fp.write('\tgroup=CCMP TKIP\n')
+ fp.write('\tpsk="'+psk+'"\n')
+ elif encryption == 'WEP':
+ fp.write('\tkey_mgmt=NONE\n')
+ if wepkeytype == 'ASCII':
+ fp.write('\twep_key0="'+psk+'"\n')
+ else:
+ fp.write('\twep_key0='+psk+'\n')
else:
- fp.write('\tkey_mgmt=NONE\n')
+ fp.write('\tkey_mgmt=NONE\n')
fp.write('}')
fp.write('\n')
fp.close()
@@ -195,54 +190,51 @@ class wpaSupplicant:
supplicant = fp.readlines()
fp.close()
essid = None
+ encryption = "Unencrypted"
for s in supplicant:
split = s.strip().split('=',1)
if split[0] == 'ap_scan':
- #print "[Wlan.py] Got Hidden SSID Scan Value ",split[1]
if split[1] == '2':
config.plugins.wlan.hiddenessid.value = True
else:
config.plugins.wlan.hiddenessid.value = False
-
+
elif split[0] == 'ssid':
- #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' :
mode = 'WPA'
if split[1] == 'RSN':
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
+ encryption = mode
elif split[0] == 'wep_key0':
- config.plugins.wlan.encryption.enabled.value = True
- config.plugins.wlan.encryption.type.value = 'WEP'
+ encryption = 'WEP'
if split[1].startswith('"') and split[1].endswith('"'):
- config.plugins.wlan.encryption.wepkeytype.value = 'ASCII'
- config.plugins.wlan.encryption.psk.value = split[1][1:-1]
+ config.plugins.wlan.wepkeytype.value = 'ASCII'
+ config.plugins.wlan.psk.value = split[1][1:-1]
else:
- config.plugins.wlan.encryption.wepkeytype.value = 'HEX'
- config.plugins.wlan.encryption.psk.value = split[1]
+ config.plugins.wlan.wepkeytype.value = 'HEX'
+ config.plugins.wlan.psk.value = split[1]
elif split[0] == 'psk':
- config.plugins.wlan.encryption.psk.value = split[1][1:-1]
+ config.plugins.wlan.psk.value = split[1][1:-1]
else:
pass
+
+ config.plugins.wlan.encryption.value = encryption
wsconfig = {
'hiddenessid': config.plugins.wlan.hiddenessid.value,
'ssid': config.plugins.wlan.essid.value,
- 'encryption': config.plugins.wlan.encryption.enabled.value,
- 'encryption_type': config.plugins.wlan.encryption.type.value,
- 'encryption_wepkeytype': config.plugins.wlan.encryption.wepkeytype.value,
- 'key': config.plugins.wlan.encryption.psk.value,
+ 'encryption': config.plugins.wlan.encryption.value,
+ 'wepkeytype': config.plugins.wlan.wepkeytype.value,
+ 'key': config.plugins.wlan.psk.value,
}
for (key, item) in wsconfig.items():
@@ -250,24 +242,21 @@ class wpaSupplicant:
if key == 'hiddenessid':
wsconfig['hiddenessid'] = False
if key == 'ssid':
- wsconfig['ssid'] = "home"
+ wsconfig['ssid'] = ""
if key == 'encryption':
- wsconfig['encryption'] = True
- if key == 'encryption_type':
- wsconfig['encryption_type'] = "WPA/WPA2"
- if key == 'encryption_wepkeytype':
- wsconfig['encryption_wepkeytype'] = "ASCII"
+ wsconfig['encryption'] = "WPA2"
+ if key == 'wepkeytype':
+ wsconfig['wepkeytype'] = "ASCII"
if key == 'key':
- wsconfig['key'] = "mysecurewlan"
+ wsconfig['key'] = ""
except:
print "[Wlan.py] Error parsing ",configfile
wsconfig = {
'hiddenessid': False,
- 'ssid': "home",
- 'encryption': True,
- 'encryption_type': "WPA/WPA2",
- 'encryption_wepkeytype': "ASCII",
- 'key': "mysecurewlan",
+ 'ssid': "",
+ 'encryption': "WPA2",
+ 'wepkeytype': "ASCII",
+ 'key': "",
}
#print "[Wlan.py] WS-CONFIG-->",wsconfig
return wsconfig
@@ -277,6 +266,7 @@ class Status:
def __init__(self):
self.wlaniface = {}
self.backupwlaniface = {}
+ self.statusCallback = None
self.WlanConsole = Console()
def stopWlanConsole(self):
@@ -288,66 +278,54 @@ class Status:
def getDataForInterface(self, iface, callback = None):
self.WlanConsole = Console()
cmd = "iwconfig " + iface
- self.WlanConsole.ePopen(cmd, self.iwconfigFinished, [iface, callback])
+ if callback is not None:
+ self.statusCallback = callback
+ self.WlanConsole.ePopen(cmd, self.iwconfigFinished, iface)
def iwconfigFinished(self, result, retval, extra_args):
- (iface, callback) = extra_args
- data = { 'essid': False, 'frequency': False, 'acesspoint': False, 'bitrate': False, 'encryption': False, 'quality': False, 'signal': False }
+ iface = extra_args
+ data = { 'essid': False, 'frequency': False, 'accesspoint': False, 'bitrate': False, 'encryption': False, 'quality': False, 'signal': False }
for line in result.splitlines():
line = line.strip()
if "ESSID" in line:
if "off/any" in line:
- ssid = _("No Connection")
+ ssid = "off"
else:
if "Nickname" in line:
- tmpssid=(line[line.index('ESSID')+7:line.index('" Nickname')])
- if tmpssid in ('', ' '):
- ssid = _("Hidden networkname")
- else:
- ssid = tmpssid
+ ssid=(line[line.index('ESSID')+7:line.index('" Nickname')])
else:
- tmpssid=(line[line.index('ESSID')+7:len(line)-1])
- if tmpssid in ('', ' '):
- ssid = _("Hidden networkname")
- else:
- ssid = tmpssid
+ ssid=(line[line.index('ESSID')+7:len(line)-1])
if ssid is not None:
data['essid'] = ssid
- if 'Frequency' in line:
+ if "Frequency" in line:
frequency = line[line.index('Frequency')+10 :line.index(' GHz')]
if frequency is not None:
data['frequency'] = frequency
if "Access Point" in line:
- ap=line[line.index('Access Point')+14:len(line)]
+ if "Sensitivity" in line:
+ ap=line[line.index('Access Point')+14:line.index(' Sensitivity')]
+ else:
+ ap=line[line.index('Access Point')+14:len(line)]
if ap is not None:
- data['acesspoint'] = ap
- if ap == "Not-Associated":
- data['essid'] = _("No Connection")
+ data['accesspoint'] = ap
if "Bit Rate" in line:
if "kb" in line:
br = line[line.index('Bit Rate')+9 :line.index(' kb/s')]
- if br == '0':
- br = _("Unsupported")
- else:
- br += " Mb/s"
else:
- br = line[line.index('Bit Rate')+9 :line.index(' Mb/s')] + " Mb/s"
+ br = line[line.index('Bit Rate')+9 :line.index(' Mb/s')]
if br is not None:
data['bitrate'] = br
- if 'Encryption key' in line:
+ if "Encryption key" in line:
if ":off" in line:
- if data['acesspoint'] is not "Not-Associated":
- enc = _("Unsupported")
- else:
- enc = _("Disabled")
+ enc = "off"
elif "Security" in line:
enc = line[line.index('Encryption key')+15 :line.index(' Security')]
if enc is not None:
- enc = _("Enabled")
+ enc = "on"
else:
enc = line[line.index('Encryption key')+15 :len(line)]
if enc is not None:
- enc = _("Enabled")
+ enc = "on"
if enc is not None:
data['encryption'] = enc
if 'Quality' in line:
@@ -359,8 +337,7 @@ class Status:
data['quality'] = qual
if 'Signal level' in line:
if "dBm" in line:
- signal = line[line.index('Signal level')+13 :line.index(' dBm')]
- signal += " dBm"
+ signal = line[line.index('Signal level')+13 :line.index(' dBm')] + " dBm"
elif "/100" in line:
if "Noise" in line:
signal = line[line.index('Signal level')+13:line.index(' Noise')]
@@ -380,8 +357,9 @@ class Status:
if self.WlanConsole is not None:
if len(self.WlanConsole.appContainers) == 0:
print "[Wlan.py] self.wlaniface after loading:", self.wlaniface
- if callback is not None:
- callback(True,self.wlaniface)
+ if self.statusCallback is not None:
+ self.statusCallback(True,self.wlaniface)
+ self.statusCallback = None
def getAdapterAttribute(self, iface, attribute):
self.iface = iface
diff --git a/lib/python/Plugins/SystemPlugins/WirelessLan/plugin.py b/lib/python/Plugins/SystemPlugins/WirelessLan/plugin.py
index 6e88a3ea..3462146f 100644
--- a/lib/python/Plugins/SystemPlugins/WirelessLan/plugin.py
+++ b/lib/python/Plugins/SystemPlugins/WirelessLan/plugin.py
@@ -19,29 +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.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):
@@ -108,7 +108,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)
@@ -116,7 +116,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)
@@ -125,32 +125,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)
@@ -234,19 +267,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()
@@ -261,10 +290,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 = []
@@ -281,20 +307,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()
@@ -326,9 +351,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] ))
@@ -341,20 +363,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>":
- continue
- else:
- self.WlanList.append( (entry[0], entry[0]) )
+ self.WlanList.append( (entry[0], entry[0]) )
def getLength(self):
return self.listLength
@@ -419,8 +438,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)
@@ -440,14 +462,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.hiddenessid.value:
- ret += "\tpre-up iwconfig " + iface + " essid \"" + config.plugins.wlan.essid.value + "\" || true\n"
+ 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