Wlan-Connect fixes
authorMladen Horvat <acid-burn@opendreambox.org>
Wed, 5 Nov 2008 23:13:51 +0000 (23:13 +0000)
committerMladen Horvat <acid-burn@opendreambox.org>
Wed, 5 Nov 2008 23:13:51 +0000 (23:13 +0000)
Wlan-Status rewrite
install license file
-needs enigma2 networkupdate

wirelesslan/src/Makefile.am
wirelesslan/src/Wlan.py
wirelesslan/src/plugin.py

index 0579e8b..7689eab 100644 (file)
@@ -1,3 +1,3 @@
 installdir = /usr/lib/enigma2/python/Plugins/SystemPlugins/WirelessLan/
 
-install_PYTHON = __init__.py plugin.py Wlan.py flags.py iwlibs.py
+install_PYTHON = __init__.py plugin.py Wlan.py flags.py iwlibs.py LICENSE
index f218d77..e483151 100644 (file)
@@ -5,25 +5,35 @@ from enigma import eListboxPythonMultiContent, eListbox, gFont, RT_HALIGN_LEFT,
 from Components.MultiContent import MultiContentEntryText
 from Components.GUIComponent import GUIComponent
 from Components.HTMLComponent import HTMLComponent
-from Components.config import config, ConfigYesNo, NoSave, ConfigSubsection, ConfigText, ConfigSelection
+from Components.config import config, ConfigYesNo, NoSave, ConfigSubsection, ConfigText, ConfigSelection, ConfigPassword
+from Components.Console import Console
 
 from os import system
 from string import maketrans, strip
+import sys
+import types
+from re import compile as re_compile, search as re_search
 from iwlibs import getNICnames, Wireless, Iwfreq
 
 list = []
-list.append(_("WEP"))
-list.append(_("WPA"))
-list.append(_("WPA2"))
+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.essidscan = NoSave(ConfigYesNo(default = True))
 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")))
-config.plugins.wlan.encryption.psk = NoSave(ConfigText(default = "mysecurewlan", fixed_size = False))
+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))
 
 class Wlan:
        def __init__(self, iface):
@@ -37,9 +47,100 @@ class Wlan:
                        b = b + chr(i)
                
                self.iface = iface
+               self.wlaniface = {}
+               self.WlanConsole = Console()
                self.asciitrans = maketrans(a, b)
 
-       
+       def stopWlanConsole(self):
+               if self.WlanConsole is not None:
+                       print "killing self.WlanConsole"
+                       self.WlanConsole = None
+                       del self.WlanConsole
+                       
+       def getDataForInterface(self, callback = None):
+               #get ip out of ip addr, as avahi sometimes overrides it in ifconfig.
+               print "self.iface im getDataForInterface",self.iface
+               if len(self.WlanConsole.appContainers) == 0:
+                       self.WlanConsole = Console()
+                       cmd = "iwconfig " + self.iface
+                       self.WlanConsole.ePopen(cmd, self.iwconfigFinished, callback)
+
+       def iwconfigFinished(self, result, retval, extra_args):
+               print "self.iface im iwconfigFinished",self.iface
+               callback = extra_args
+               data = { 'essid': False, 'frequency': False, 'acesspoint': False, 'bitrate': False, 'encryption': False, 'quality': False, 'signal': False }
+               #print "result im iwconfigFinished",result
+               
+               for line in result.splitlines():
+                       #print "line",line
+                       line = line.strip()
+                       if "ESSID" in line:
+                               if "off/any" in line:
+                                       ssid = _("No Connection")
+                               else:
+                                       tmpssid=(line[line.index('ESSID')+7:len(line)-1])
+                                       if tmpssid == '':
+                                               ssid = _("Hidden networkname")
+                                       elif tmpssid ==' ':
+                                               ssid = _("Hidden networkname")
+                                       else:
+                                           ssid = tmpssid
+                               #print "SSID->",ssid
+                               if ssid is not None:
+                                       data['essid'] = ssid
+                       if 'Frequency' in line:
+                               frequency = line[line.index('Frequency')+10 :line.index(' GHz')]
+                               #print "Frequency",frequency   
+                               if frequency is not None:
+                                       data['frequency'] = frequency
+                       if "Access Point" in line:
+                               ap=line[line.index('Access Point')+14:len(line)-1]
+                               #print "AP",ap
+                               if ap is not None:
+                                       data['acesspoint'] = ap
+                       if "Bit Rate" in line:
+                               br = line[line.index('Bit Rate')+9 :line.index(' Mb/s')]
+                               #print "Bitrate",br
+                               if br is not None:
+                                       data['bitrate'] = br
+                       if 'Encryption key' in line:
+                               if ":off" in line:
+                                   enc = _("Disabled")
+                               else:
+                                   enc = line[line.index('Encryption key')+15 :line.index('   Security')]
+                               #print "Encryption key",enc 
+                               if enc is not None:
+                                       data['encryption'] = _("Enabled")
+                       if 'Quality' in line:
+                               if "/100" in line:
+                                       qual = line[line.index('Quality')+8:line.index('/100')]
+                               else:
+                                       qual = line[line.index('Quality')+8:line.index('Sig')]
+                               #print "Quality",qual
+                               if qual is not None:
+                                       data['quality'] = qual
+                       if 'Signal level' in line:
+                               signal = line[line.index('Signal level')+14 :line.index(' dBm')]
+                               #print "Signal level",signal            
+                               if signal is not None:
+                                       data['signal'] = signal
+
+               self.wlaniface[self.iface] = data
+               
+               if len(self.WlanConsole.appContainers) == 0:
+                       print "self.wlaniface after loading:", self.wlaniface
+                       self.WlanConsole = None
+                       if callback is not None:
+                               callback(True,self.wlaniface)
+
+       def getAdapterAttribute(self, attribute):
+               print "im getAdapterAttribute"
+               if self.wlaniface.has_key(self.iface):
+                       print "self.wlaniface.has_key",self.iface
+                       if self.wlaniface[self.iface].has_key(attribute):
+                               return self.wlaniface[self.iface][attribute]
+               return None
+               
        def asciify(self, str):
                return str.translate(self.asciitrans)
 
@@ -55,9 +156,8 @@ class Wlan:
 
        
        def getNetworkList(self):
-               ifobj = Wireless(self.iface) # a Wireless NIC Object
                system("ifconfig "+self.iface+" up")
-               print "ifobj.getStatistics(): ", ifobj.getStatistics()
+               ifobj = Wireless(self.iface) # a Wireless NIC Object
                
                #Association mappings
                stats, quality, discard, missed_beacon = ifobj.getStatistics()
@@ -72,7 +172,7 @@ class Wlan:
                if scanresults is not None:
                        aps = {}
                        for result in scanresults:
-                               
+                       
                                bssid = result.bssid
                
                                encryption = map(lambda x: hex(ord(x)), result.encode)
@@ -87,8 +187,6 @@ class Wlan:
                                        element = element.encode()
                                        extra.append( strip(self.asciify(element)) )
                                
-                               print result.quality.getSignallevel()
-                               
                                if result.quality.sl is 0 and len(extra) > 0:
                                        begin = extra[0].find('SignalStrength=')+15
                                                                        
@@ -103,7 +201,7 @@ class Wlan:
                                                        end -= 1
                                        
                                        signal = extra[0][begin:end]
-                                       print "[Wlan.py] signal is:" + str(signal)
+                                       #print "[Wlan.py] signal is:" + str(signal)
 
                                else:
                                        signal = str(result.quality.sl)
@@ -132,6 +230,7 @@ class Wlan:
                        self.channel = str(fq.getChannel(str(ifobj.getFrequency()[0:-3])))
                except:
                        self.channel = 0
+               #print ifobj.getStatistics()
                status = {
                                  'BSSID': str(ifobj.getAPaddr()),
                                  'ESSID': str(ifobj.getEssid()),
@@ -230,83 +329,110 @@ class wpaSupplicant:
                
        def writeConfig(self):  
                        
-                       essidscan = config.plugins.wlan.essidscan.value
                        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
-
-
                        fp = file('/etc/wpa_supplicant.conf', 'w')
                        fp.write('#WPA Supplicant Configuration by enigma2\n')
-                       if essidscan:
-                               fp.write('#essidscan=automatic\n\n')
-                       else:
-                               fp.write('#essidscan=manual\n\n')
                        fp.write('ctrl_interface=/var/run/wpa_supplicant\n')
-                       fp.write('ctrl_interface_group=0\n')
                        fp.write('eapol_version=1\n')
-                       fp.write('ap_scan=2\n')
-                       fp.write('fast_reauth=1\n')                     
+                       fp.write('fast_reauth=1\n')     
+                       if essid == 'hidden...':
+                               fp.write('ap_scan=2\n')
+                       else:
+                               fp.write('ap_scan=1\n')
                        fp.write('network={\n')
-                       fp.write('\tssid="'+essid+'"\n')
-                       fp.write('\tscan_ssid=0\n')
-                       
+                       if essid == 'hidden...':
+                               fp.write('\tssid="'+hiddenessid+'"\n')
+                       else:
+                               fp.write('\tssid="'+essid+'"\n')
+                       fp.write('\tscan_ssid=0\n')                     
                        if encrypted:
-                                                       
-                               if encryption == 'WPA' or encryption == 'WPA2':
-                                       fp.write('\tkey_mgmt=WPA-PSK\n')
+                               if encryption == 'WPA' or encryption == 'WPA2' or encryption == 'WPA/WPA2' :
                                        
                                        if encryption == 'WPA':
                                                fp.write('\tproto=WPA\n')
                                                fp.write('\tpairwise=TKIP\n')
                                                fp.write('\tgroup=TKIP\n')
-                                       else:
+                                       elif encryption == 'WPA2':
                                                fp.write('\tproto=WPA RSN\n')
                                                fp.write('\tpairwise=CCMP TKIP\n')
-                                               fp.write('\tgroup=CCMP TKIP\n')
-                                       
+                                               fp.write('\tgroup=CCMP TKIP\n')                                         
+                                       else:
+                                               fp.write('\tproto=WPA WPA2\n')
+                                               fp.write('\tpairwise=CCMP\n')
+                                               fp.write('\tgroup=TKIP\n')                                      
                                        fp.write('\tpsk="'+psk+'"\n')
-                               
+                                               
                                elif encryption == 'WEP':
                                        fp.write('\tkey_mgmt=NONE\n')
-                                       fp.write('\twep_key0="'+psk+'"\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('}')   
+                       fp.write('}')
+                       fp.write('\n')
                        fp.close()
-                               
-                       
+                       system("cat /etc/wpa_supplicant.conf")
+               
        def loadConfig(self):
                try:
                        #parse the wpasupplicant configfile
                        fp = file('/etc/wpa_supplicant.conf', 'r')
                        supplicant = fp.readlines()
                        fp.close()
+                       ap_scan = False
+                       essid = None
 
                        for s in supplicant:
                                split = s.strip().split('=',1)
-                               if split[0] == '#essidscan':
-                                       print "[Wlan.py] Got SSID Scan Value "+split[1]#[1:-1]
-                                       if split[1] == "automatic":
-                                               config.plugins.wlan.essidscan.value = True
-                                       if split[1] == "manual":
-                                               config.plugins.wlan.essidscan.value = False
-                               if split[0] == 'ssid':
+                               if split[0] == 'ap_scan':
+                                       print "[Wlan.py] Got Hidden SSID Scan  Value "+split[1]
+                                       if split[1] == '2':
+                                               ap_scan = True
+                                       else:
+                                               ap_scan = False
+                                               
+                               elif split[0] == 'ssid':
                                        print "[Wlan.py] Got SSID "+split[1][1:-1]
-                                       config.plugins.wlan.essid.value = split[1][1:-1]
+                                       essid = split[1][1:-1]
                                        
                                elif split[0] == 'proto':
+                                       print "split[1]",split[1]
                                        config.plugins.wlan.encryption.enabled.value = True
-                                       if split[1] == "WPA RSN" : split[1] = 'WPA2'
-                                       config.plugins.wlan.encryption.type.value = split[1]
-                                       print "[Wlan.py] Got Encryption: "+split[1]
+                                       if split[1] == "WPA" :
+                                               mode = 'WPA'
+                                       if split[1] == "WPA WPA2" :
+                                               mode = 'WPA/WPA2'
+                                       if split[1] == "WPA RSN" :
+                                               mode = 'WPA2'
+                                       config.plugins.wlan.encryption.type.value = mode
+                                       print "[Wlan.py] Got Encryption: "+mode
+                                       
+                               #currently unused !
+                               #elif split[0] == 'key_mgmt':
+                               #       print "split[1]",split[1]
+                               #       if split[1] == "WPA-PSK" :
+                               #               config.plugins.wlan.encryption.enabled.value = True
+                               #               config.plugins.wlan.encryption.type.value = "WPA/WPA2"
+                               #       print "[Wlan.py] Got Encryption: "+ config.plugins.wlan.encryption.type.value
                                        
                                elif split[0] == 'wep_key0':
                                        config.plugins.wlan.encryption.enabled.value = True
                                        config.plugins.wlan.encryption.type.value = 'WEP'
-                                       config.plugins.wlan.encryption.psk.value = split[1][1:-1]
-                                       print "[Wlan.py] Got Encryption: WEP - key0 is: "+split[1][1:-1]
+                                       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]
+                                       else:
+                                               config.plugins.wlan.encryption.wepkeytype.value = 'HEX'
+                                               config.plugins.wlan.encryption.psk.value = split[1]                                             
+                                       print "[Wlan.py] Got Encryption: WEP - keytype is: "+config.plugins.wlan.encryption.wepkeytype.value
+                                       print "[Wlan.py] Got Encryption: WEP - key0 is: "+config.plugins.wlan.encryption.psk.value
                                        
                                elif split[0] == 'psk':
                                        config.plugins.wlan.encryption.psk.value = split[1][1:-1]
@@ -314,37 +440,47 @@ 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 = {
-                                       'ssidscan': config.plugins.wlan.essidscan.value,
+                                       '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,
                                }
                
                        for (key, item) in wsconfig.items():
                                if item is "None" or item is "":
-                                       if key == 'ssidscan':
-                                               wsconfig['ssidscan'] = True
+                                       if key == 'hiddenessid':
+                                               wsconfig['hiddenessid'] = "home"
                                        if key == 'ssid':
                                                wsconfig['ssid'] = "home"
                                        if key == 'encryption':
-                                               wsconfig['encryption'] = False                          
+                                               wsconfig['encryption'] = True                           
+                                       if key == 'encryption':
+                                               wsconfig['encryption_type'] = "WPA/WPA2"
                                        if key == 'encryption':
-                                               wsconfig['encryption_type'] = "WPA"
+                                               wsconfig['encryption_wepkeytype'] = "ASCII"
                                        if key == 'encryption':
                                                wsconfig['key'] = "mysecurewlan"
 
                except:
                        print "[Wlan.py] Error parsing /etc/wpa_supplicant.conf"
                        wsconfig = {
-                                       'ssidscan': True,
+                                       'hiddenessid': "home",
                                        'ssid': "home",
-                                       'encryption': False,
-                                       'encryption_type': "WPA",
+                                       'encryption': True,
+                                       'encryption_type': "WPA/WPA2",
+                                       'encryption_wepkeytype': "ASCII",
                                        'key': "mysecurewlan",
                                }
-               print "WS-CONFIG-->",wsconfig
+               print "[Wlan.py] WS-CONFIG-->",wsconfig
                return wsconfig
 
        
@@ -352,4 +488,116 @@ class wpaSupplicant:
                system("start-stop-daemon -K -x /usr/sbin/wpa_supplicant")
                system("start-stop-daemon -S -x /usr/sbin/wpa_supplicant -- -B -i"+iface+" -c/etc/wpa_supplicant.conf")
 
+class Status:
+       def __init__(self):
+               self.wlaniface = {}
+               self.backupwlaniface = {}
+               self.WlanConsole = Console()
+
+       def stopWlanConsole(self):
+               if self.WlanConsole is not None:
+                       print "killing self.WlanConsole"
+                       self.WlanConsole = None
+                       
+       def getDataForInterface(self, iface, callback = None):
+               self.WlanConsole = Console()
+               cmd = "iwconfig " + iface
+               self.WlanConsole.ePopen(cmd, self.iwconfigFinished, [iface, callback])
 
+       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 }
+               for line in result.splitlines():
+                       line = line.strip()
+                       if "ESSID" in line:
+                               if "off/any" in line:
+                                       ssid = _("No Connection")
+                               else:
+                                       tmpssid=(line[line.index('ESSID')+7:len(line)-1])
+                                       if tmpssid == '':
+                                               ssid = _("Hidden networkname")
+                                       elif tmpssid ==' ':
+                                               ssid = _("Hidden networkname")
+                                       else:
+                                           ssid = tmpssid
+                               #print "SSID->",ssid
+                               if ssid is not None:
+                                       data['essid'] = ssid
+                       if 'Frequency' in line:
+                               frequency = line[line.index('Frequency')+10 :line.index(' GHz')]
+                               #print "Frequency",frequency   
+                               if frequency is not None:
+                                       data['frequency'] = frequency
+                       if "Access Point" in line:
+                               ap=line[line.index('Access Point')+14:len(line)]
+                               #print "AP",ap
+                               if ap is not None:
+                                       data['acesspoint'] = ap
+                                       if ap == "Not-Associated":
+                                               data['essid'] = _("No Connection")
+                       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"
+                               #print "Bitrate",br
+                               if br is not None:
+                                       data['bitrate'] = br
+                       if 'Encryption key' in line:
+                               if ":off" in line:
+                                       if data['acesspoint'] is not "Not-Associated":
+                                               enc = _("Unsupported")
+                                       else:
+                                               enc = _("Disabled")
+                               else:
+                                       enc = line[line.index('Encryption key')+15 :line.index('   Security')]
+                                       if enc is not None:
+                                               enc = _("Enabled")
+                               #print "Encryption key",enc 
+                               if enc is not None:
+                                       data['encryption'] = enc
+                       if 'Quality' in line:
+                               if "/100" in line:
+                                       qual = line[line.index('Quality')+8:line.index('/100')]
+                               else:
+                                       qual = line[line.index('Quality')+8:line.index('Sig')]
+                               #print "Quality",qual
+                               if qual is not None:
+                                       data['quality'] = qual
+                       if 'Signal level' in line:
+                               if "dBm" in line:
+                                       signal = line[line.index('Signal level')+14 :line.index(' dBm')]
+                                       signal += " dBm"
+                               elif "/100" in line:
+                                       signal = line[line.index('Signal level')+13:line.index('/100  Noise')]
+                                       signal += "%"
+                               else:
+                                       signal = line[line.index('Signal level')+13:line.index('  Noise')]
+                                       signal += "%"
+                               #print "Signal level",signal            
+                               if signal is not None:
+                                       data['signal'] = signal
+
+               self.wlaniface[iface] = data
+               self.backupwlaniface = self.wlaniface
+               
+               if self.WlanConsole is not None:
+                       if len(self.WlanConsole.appContainers) == 0:
+                               print "self.wlaniface after loading:", self.wlaniface
+                               if callback is not None:
+                                       callback(True,self.wlaniface)
+
+       def getAdapterAttribute(self, iface, attribute):
+               print "im getAdapterAttribute"
+               self.iface = iface
+               if self.wlaniface.has_key(self.iface):
+                       print "self.wlaniface.has_key",self.iface
+                       if self.wlaniface[self.iface].has_key(attribute):
+                               return self.wlaniface[self.iface][attribute]
+               return None
+       
+iStatus = Status()
\ No newline at end of file
index 0630e14..b2bfdbe 100644 (file)
@@ -7,46 +7,53 @@ from Components.ActionMap import ActionMap, NumberActionMap
 from Components.Pixmap import Pixmap
 from Components.Label import Label
 from Components.MenuList import MenuList
-from Components.config import config, getConfigListEntry, ConfigYesNo, NoSave, ConfigSubsection, ConfigText, ConfigSelection
+from Components.config import config, getConfigListEntry, ConfigYesNo, NoSave, ConfigSubsection, ConfigText, ConfigSelection, ConfigPassword
 from Components.ConfigList import ConfigListScreen
 from Components.Network import Network, iNetwork
 from Plugins.Plugin import PluginDescriptor
 from os import system, path as os_path, listdir
 from Wlan import Wlan, WlanList, wpaSupplicant
+from Wlan import Status, iStatus
 
 plugin_path = "/usr/lib/enigma2/python/Plugins/SystemPlugins/WirelessLan"
 
 list = []
-list.append(_("WEP"))
-list.append(_("WPA"))
-list.append(_("WPA2"))
+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.essidscan = NoSave(ConfigYesNo(default = False))
 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")))
-config.plugins.wlan.encryption.psk = NoSave(ConfigText(default = "mysecurewlan", fixed_size = 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):
        skin = """
        <screen position="90,150" size="550,300" title="Wireless Network State" >
-               <widget name="LabelBSSID" position="10,10" size="150,25" valign="left" font="Regular;20" transparent="1" foregroundColor="#FFFFFF" />
-               <widget name="LabelESSID" position="10,38" size="150,25" valign="center" font="Regular;20" transparent="1" foregroundColor="#FFFFFF" />
-               <widget name="LabelQuality" position="10,66" size="150,25" valign="center" font="Regular;20" transparent="1" foregroundColor="#FFFFFF" />
-               <widget name="LabelSignal" position="10,94" size="150,25" valign="center" font="Regular;20" transparent="1" foregroundColor="#FFFFFF" />
-               <widget name="LabelBitrate" position="10,122" size="150,25" valign="center" font="Regular;20" transparent="1" foregroundColor="#FFFFFF" />
-               <widget name="LabelChannel" position="10,150" size="150,25" valign="center" font="Regular;20" transparent="1" foregroundColor="#FFFFFF" />
+               <widget name="LabelBSSID" position="10,10" size="250,25" valign="left" font="Regular;20" transparent="1" foregroundColor="#FFFFFF" />
+               <widget name="LabelESSID" position="10,38" size="250,25" valign="center" font="Regular;20" transparent="1" foregroundColor="#FFFFFF" />
+               <widget name="LabelQuality" position="10,66" size="250,25" valign="center" font="Regular;20" transparent="1" foregroundColor="#FFFFFF" />
+               <widget name="LabelSignal" position="10,94" size="250,25" valign="center" font="Regular;20" transparent="1" foregroundColor="#FFFFFF" />
+               <widget name="LabelBitrate" position="10,122" size="250,25" valign="center" font="Regular;20" transparent="1" foregroundColor="#FFFFFF" />
+               <widget name="LabelEnc" position="10,150" size="250,25" valign="center" font="Regular;20" transparent="1" foregroundColor="#FFFFFF" />
                
                <widget name="BSSID" position="320,10" size="180,25" valign="center" font="Regular;20" transparent="1" foregroundColor="#FFFFFF" />
                <widget name="ESSID" position="320,38" size="180,25" valign="center" font="Regular;20" transparent="1" foregroundColor="#FFFFFF" />
                <widget name="quality" position="320,66" size="180,25" valign="center" font="Regular;20" transparent="1" foregroundColor="#FFFFFF" />
                <widget name="signal" position="320,94" size="180,25" valign="center" font="Regular;20" transparent="1" foregroundColor="#FFFFFF" />
                <widget name="bitrate" position="320,122" size="180,25" valign="center" font="Regular;20" transparent="1" foregroundColor="#FFFFFF" />
-               <widget name="channel" position="320,150" size="180,25" valign="center" font="Regular;20" transparent="1" foregroundColor="#FFFFFF" />
+               <widget name="enc" position="320,150" size="180,25" valign="center" font="Regular;20" transparent="1" foregroundColor="#FFFFFF" />
                
                <widget name="BottomBG" pixmap="skin_default/bottombar.png" position="5,210" size="540,120" zPosition="1" transparent="1" alphatest="on" />
                <widget name="IFtext" position="20,225" size="100,21" zPosition="10" font="Regular;19" transparent="1" />
@@ -68,24 +75,20 @@ class WlanStatus(Screen):
                self.session = session
                self.iface = iface
                self.skin = WlanStatus.skin
-               
-               self.timer = eTimer()
-               self.timer.timeout.get().append(self.resetList) 
-               self.onShown.append(lambda: self.timer.start(5000))
-                                                   
+                                   
                self["LabelBSSID"] = Label(_('Accesspoint:'))
                self["LabelESSID"] = Label(_('SSID:'))
                self["LabelQuality"] = Label(_('Link Quality:'))
                self["LabelSignal"] = Label(_('Signal Strength:'))
                self["LabelBitrate"] = Label(_('Bitrate:'))
-               self["LabelChannel"] = Label(_('Channel:'))
+               self["LabelEnc"] = Label(_('Encryption:'))
                        
                self["BSSID"] = Label()
                self["ESSID"] = Label()
                self["quality"] = Label()
                self["signal"] = Label()
                self["bitrate"] = Label()
-               self["channel"] = Label()
+               self["enc"] = Label()
 
                self["IFtext"] = Label()
                self["IF"] = Label()
@@ -107,40 +110,61 @@ class WlanStatus(Screen):
                        "back": self.exit,
                        "red": self.exit,
                }, -1)
+               self.timer = eTimer()
+               self.timer.timeout.get().append(self.resetList) 
+               self.onShown.append(lambda: self.timer.start(5000))
                self.onLayoutFinish.append(self.layoutFinished)
+               self.onClose.append(self.cleanup)
+
+       def cleanup(self):
+               iStatus.stopWlanConsole()
                
        def layoutFinished(self):
                self.setTitle(_("Wireless Network State"))
                
        def resetList(self):
-               w = Wlan(self.iface)
-               stats = w.getStatus()
-               if stats['BSSID'] == "00:00:00:00:00:00":
-                       stats['BSSID'] = _("No Connection!")
-               self["BSSID"].setText(stats['BSSID'])
-               self["ESSID"].setText(stats['ESSID'])
-               self["quality"].setText(stats['quality']+"%")
-               self["signal"].setText(stats['signal']+"%")
-               self["bitrate"].setText(stats['bitrate'])
-               self["channel"].setText(stats['channel'])
+               print "self.iface im resetlist",self.iface
+               iStatus.getDataForInterface(self.iface,self.getInfoCB)
                
-       
+       def getInfoCB(self,data,status):
+               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"])
+                                       self.updateStatusLink(status)
+
        def exit(self):
                self.timer.stop()
                self.close()    
 
        def updateStatusbar(self):
+               print "self.iface im updateStatusbar",self.iface
+               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..."))
                self["IFtext"].setText(_("Network:"))
                self["IF"].setText(iNetwork.getFriendlyAdapterName(self.iface))
                self["Statustext"].setText(_("Link:"))
-               w = Wlan(self.iface)
-               stats = w.getStatus()
-               if stats['BSSID'] == "00:00:00:00:00:00":
-                       self["statuspic_active"].hide()
-                       self["statuspic_inactive"].show()
-               else:
-                       self["statuspic_active"].show()
-                       self["statuspic_inactive"].hide()
+
+       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:
+                               self["statuspic_active"].hide()
+                               self["statuspic_inactive"].show()
+                       else:
+                               self["statuspic_active"].show()
+                               self["statuspic_inactive"].hide()               
+
+
 
 
 class WlanScan(Screen):
@@ -254,7 +278,7 @@ def configStrings(iface):
        if driver == 'madwifi':
                return "        pre-up /usr/sbin/wpa_supplicant -i"+iface+" -c/etc/wpa_supplicant.conf -B -dd -Dmadwifi\n       post-down wpa_cli terminate"
        if driver == 'zydas':
-               return "        pre-up /usr/sbin/wpa_supplicant -i"+iface+" -c/etc/wpa_supplicant.conf -B -Dzydas\n     post-down wpa_cli terminate"
+               return "        pre-up /usr/sbin/wpa_supplicant -i"+iface+" -c/etc/wpa_supplicant.conf -B -dd -Dzydas\n post-down wpa_cli terminate"
 
 def Plugins(**kwargs):
        return PluginDescriptor(name=_("Wireless LAN"), description=_("Connect to a Wireless Network"), where = PluginDescriptor.WHERE_NETWORKSETUP, fnc={"ifaceSupported": callFunction, "configStrings": configStrings, "WlanPluginEntry": lambda x: "Wireless Network Configuartion..."})