Screens/NetworkSetup.py, WirelessLan/plugin.py: - fix wrong networkstate in some...
authoracid-burn <acid-burn@opendreambox.org>
Tue, 15 Dec 2009 18:27:02 +0000 (19:27 +0100)
committeracid-burn <acid-burn@opendreambox.org>
Tue, 15 Dec 2009 18:27:02 +0000 (19:27 +0100)
This fixex #203

lib/python/Plugins/SystemPlugins/WirelessLan/plugin.py
lib/python/Screens/NetworkSetup.py

index b7a64b9..c8568b9 100755 (executable)
@@ -4,6 +4,7 @@ from Components.ActionMap import ActionMap, NumberActionMap
 from Components.Pixmap import Pixmap,MultiPixmap
 from Components.Label import Label
 from Components.Sources.StaticText import StaticText
+from Components.Sources.List import List
 from Components.MenuList import MenuList
 from Components.config import config, getConfigListEntry, ConfigYesNo, NoSave, ConfigSubsection, ConfigText, ConfigSelection, ConfigPassword
 from Components.ConfigList import ConfigListScreen
@@ -11,8 +12,9 @@ from Components.Network import Network, iNetwork
 from Components.Console import Console
 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
+from Tools.Directories import resolveFilename, SCOPE_PLUGINS, SCOPE_SKIN_IMAGE
+from Tools.LoadPixmap import LoadPixmap
+from Wlan import Wlan, wpaSupplicant, iStatus
 
 plugin_path = "/usr/lib/enigma2/python/Plugins/SystemPlugins/WirelessLan"
 
@@ -39,37 +41,35 @@ config.plugins.wlan.encryption.psk = NoSave(ConfigPassword(default = "mysecurewl
 
 class WlanStatus(Screen):
        skin = """
-       <screen position="center,center" size="560,400" title="Wireless Network State" >
-               <ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" alphatest="on" />
-               <widget source="key_red" render="Label" position="0,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" transparent="1" />
-
-               <widget source="LabelBSSID" render="Label" position="10,60" size="250,25" valign="left" font="Regular;20" transparent="1" foregroundColor="#FFFFFF" />
-               <widget source="LabelESSID" render="Label" position="10,100" size="250,25" valign="center" font="Regular;20" transparent="1" foregroundColor="#FFFFFF" />
-               <widget source="LabelQuality" render="Label" position="10,140" size="250,25" valign="center" font="Regular;20" transparent="1" foregroundColor="#FFFFFF" />
-               <widget source="LabelSignal" render="Label" position="10,180" size="250,25" valign="center" font="Regular;20" transparent="1" foregroundColor="#FFFFFF" />
-               <widget source="LabelBitrate" render="Label" position="10,220" size="250,25" valign="center" font="Regular;20" transparent="1" foregroundColor="#FFFFFF" />
-               <widget source="LabelEnc" render="Label" position="10,260" size="250,25" valign="center" font="Regular;20" transparent="1" foregroundColor="#FFFFFF" />
-               
-               <widget source="BSSID" render="Label" position="320,60" size="180,25" valign="center" font="Regular;20" transparent="1" foregroundColor="#FFFFFF" />
-               <widget source="ESSID" render="Label" position="320,100" size="180,25" valign="center" font="Regular;20" transparent="1" foregroundColor="#FFFFFF" />
-               <widget source="quality" render="Label" position="320,140" size="180,25" valign="center" font="Regular;20" transparent="1" foregroundColor="#FFFFFF" />
-               <widget source="signal" render="Label" position="320,180" size="180,25" valign="center" font="Regular;20" transparent="1" foregroundColor="#FFFFFF" />
-               <widget source="bitrate" render="Label" position="320,220" size="180,25" valign="center" font="Regular;20" transparent="1" foregroundColor="#FFFFFF" />
-               <widget source="enc" render="Label" position="320,260" size="180,25" valign="center" font="Regular;20" transparent="1" foregroundColor="#FFFFFF" />
-
-               <ePixmap pixmap="skin_default/div-h.png" position="0,350" zPosition="1" size="560,2" />         
-               <widget source="IFtext" render="Label" position="10,355" size="120,21" zPosition="10" font="Regular;20" halign="left" backgroundColor="#25062748" transparent="1" />
-               <widget source="IF" render="Label" position="120,355" size="400,21" zPosition="10" font="Regular;20" halign="left" backgroundColor="#25062748" transparent="1" />
-               <widget source="Statustext" render="Label" position="10,375" size="115,21" zPosition="10" font="Regular;20" halign="left" backgroundColor="#25062748" transparent="1"/>
-               <widget name="statuspic" pixmaps="skin_default/buttons/button_green.png,skin_default/buttons/button_green_off.png" position="130,380" zPosition="10" size="15,16" transparent="1" alphatest="on"/>
-       </screen>
-       """
+               <screen name="WlanStatus" position="center,center" size="560,400" title="Wireless Network State" >
+                       <ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" alphatest="on" />
+                       <widget source="key_red" render="Label" position="0,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" transparent="1" />
+       
+                       <widget source="LabelBSSID" render="Label" position="10,60" size="250,25" valign="left" font="Regular;20" transparent="1" foregroundColor="#FFFFFF" />
+                       <widget source="LabelESSID" render="Label" position="10,100" size="250,25" valign="center" font="Regular;20" transparent="1" foregroundColor="#FFFFFF" />
+                       <widget source="LabelQuality" render="Label" position="10,140" size="250,25" valign="center" font="Regular;20" transparent="1" foregroundColor="#FFFFFF" />
+                       <widget source="LabelSignal" render="Label" position="10,180" size="250,25" valign="center" font="Regular;20" transparent="1" foregroundColor="#FFFFFF" />
+                       <widget source="LabelBitrate" render="Label" position="10,220" size="250,25" valign="center" font="Regular;20" transparent="1" foregroundColor="#FFFFFF" />
+                       <widget source="LabelEnc" render="Label" position="10,260" size="250,25" valign="center" font="Regular;20" transparent="1" foregroundColor="#FFFFFF" />
+                       
+                       <widget source="BSSID" render="Label" position="320,60" size="180,25" valign="center" font="Regular;20" transparent="1" foregroundColor="#FFFFFF" />
+                       <widget source="ESSID" render="Label" position="320,100" size="180,25" valign="center" font="Regular;20" transparent="1" foregroundColor="#FFFFFF" />
+                       <widget source="quality" render="Label" position="320,140" size="180,25" valign="center" font="Regular;20" transparent="1" foregroundColor="#FFFFFF" />
+                       <widget source="signal" render="Label" position="320,180" size="180,25" valign="center" font="Regular;20" transparent="1" foregroundColor="#FFFFFF" />
+                       <widget source="bitrate" render="Label" position="320,220" size="180,25" valign="center" font="Regular;20" transparent="1" foregroundColor="#FFFFFF" />
+                       <widget source="enc" render="Label" position="320,260" size="180,25" valign="center" font="Regular;20" transparent="1" foregroundColor="#FFFFFF" />
+       
+                       <ePixmap pixmap="skin_default/div-h.png" position="0,350" zPosition="1" size="560,2" />         
+                       <widget source="IFtext" render="Label" position="10,355" size="120,21" zPosition="10" font="Regular;20" halign="left" backgroundColor="#25062748" transparent="1" />
+                       <widget source="IF" render="Label" position="120,355" size="400,21" zPosition="10" font="Regular;20" halign="left" backgroundColor="#25062748" transparent="1" />
+                       <widget source="Statustext" render="Label" position="10,375" size="115,21" zPosition="10" font="Regular;20" halign="left" backgroundColor="#25062748" transparent="1"/>
+                       <widget name="statuspic" pixmaps="skin_default/buttons/button_green.png,skin_default/buttons/button_green_off.png" position="130,380" zPosition="10" size="15,16" transparent="1" alphatest="on"/>
+               </screen>"""
        
        def __init__(self, session, iface):
                Screen.__init__(self, session)
                self.session = session
                self.iface = iface
-               self.skin = WlanStatus.skin
                                    
                self["LabelBSSID"] = StaticText(_('Accesspoint:'))
                self["LabelESSID"] = StaticText(_('SSID:'))
@@ -114,7 +114,6 @@ class WlanStatus(Screen):
                self.setTitle(_("Wireless Network State"))
                
        def resetList(self):
-               print "self.iface im resetlist",self.iface
                iStatus.getDataForInterface(self.iface,self.getInfoCB)
                
        def getInfoCB(self,data,status):
@@ -131,10 +130,9 @@ class WlanStatus(Screen):
 
        def exit(self):
                self.timer.stop()
-               self.close()    
+               self.close(True)        
 
        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..."))
@@ -155,37 +153,55 @@ class WlanStatus(Screen):
 
 class WlanScan(Screen):
        skin = """
-       <screen position="center,center" size="560,400" title="Choose a Wireless Network" >
-               <ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" alphatest="on" />
-               <ePixmap pixmap="skin_default/buttons/green.png" position="140,0" size="140,40" alphatest="on" />
-               <ePixmap pixmap="skin_default/buttons/yellow.png" position="280,0" size="140,40" alphatest="on" />
-               <widget source="key_red" render="Label" position="0,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" transparent="1" />
-               <widget source="key_green" render="Label" position="140,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#1f771f" transparent="1" />
-               <widget source="key_yellow" render="Label" position="280,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#a08500" transparent="1" />
-               <widget name="list" position="5,50" size="550,280" scrollbarMode="showOnDemand" />
-               <ePixmap pixmap="skin_default/div-h.png" position="0,340" zPosition="1" size="560,2" />         
-               <widget source="info" render="Label" position="0,350" size="560,50" font="Regular;24" halign="center" valign="center" backgroundColor="#25062748" transparent="1" />
-       </screen>
-       """
+               <screen name="WlanScan" position="center,center" size="560,400" title="Choose a Wireless Network" >
+                       <ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" alphatest="on" />
+                       <ePixmap pixmap="skin_default/buttons/green.png" position="140,0" size="140,40" alphatest="on" />
+                       <ePixmap pixmap="skin_default/buttons/yellow.png" position="280,0" size="140,40" alphatest="on" />
+                       <widget source="key_red" render="Label" position="0,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" transparent="1" />
+                       <widget source="key_green" render="Label" position="140,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#1f771f" transparent="1" />
+                       <widget source="key_yellow" render="Label" position="280,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#a08500" transparent="1" />
+                       <widget source="list" render="Listbox" position="5,40" size="550,300" scrollbarMode="showOnDemand">
+                               <convert type="TemplatedMultiContent">
+                                       {"template": [
+                                                       MultiContentEntryText(pos = (0, 0), size = (550, 30), font=0, flags = RT_HALIGN_LEFT, text = 0), # index 0 is the essid
+                                                       MultiContentEntryText(pos = (0, 30), size = (175, 20), font=1, flags = RT_HALIGN_LEFT, text = 5), # index 5 is the interface
+                                                       MultiContentEntryText(pos = (175, 30), size = (175, 20), font=1, flags = RT_HALIGN_LEFT, text = 4), # index 0 is the encryption
+                                                       MultiContentEntryText(pos = (350, 0), size = (200, 20), font=1, flags = RT_HALIGN_LEFT, text = 2), # index 0 is the signal
+                                                       MultiContentEntryText(pos = (350, 30), size = (200, 20), font=1, flags = RT_HALIGN_LEFT, text = 3), # index 0 is the maxrate
+                                                       MultiContentEntryPixmapAlphaTest(pos = (0, 52), size = (550, 2), png = 6), # index 6 is the div pixmap
+                                               ],
+                                       "fonts": [gFont("Regular", 28),gFont("Regular", 18)],
+                                       "itemHeight": 54
+                                       }
+                               </convert>
+                       </widget>
+                       <ePixmap pixmap="skin_default/div-h.png" position="0,340" zPosition="1" size="560,2" />         
+                       <widget source="info" render="Label" position="0,350" size="560,50" font="Regular;24" halign="center" valign="center" backgroundColor="#25062748" transparent="1" />
+               </screen>"""
 
        def __init__(self, session, iface):
                Screen.__init__(self, session)
                self.session = session
                self.iface = iface
-               self.skin = WlanScan.skin
                self.skin_path = plugin_path
                self.oldInterfaceState = iNetwork.getAdapterAttribute(self.iface, "up")
+               self.APList = None
+               self.newAPList = None
+               self.WlanList = None
+               self.cleanList = None
+               self.oldlist = None
+               self.listLenght = None
+               self.rescanTimer = eTimer()
+               self.rescanTimer.callback.append(self.rescanTimerFired)
                
                self["info"] = StaticText()
                
-               self.list = []  
-               self["list"] = WlanList(self.session, self.iface)
+               self.list = []
+               self["list"] = List(self.list)
                
-               self.setInfo()
-
                self["key_red"] = StaticText(_("Close"))
                self["key_green"] = StaticText(_("Connect"))
-               self["key_yellow"] = StaticText(_("Refresh"))
+               self["key_yellow"] = StaticText()
                        
                self["actions"] = NumberActionMap(["WizardActions", "InputActions", "EPGSelectActions"],
                {
@@ -195,63 +211,161 @@ class WlanScan(Screen):
                
                self["shortcuts"] = ActionMap(["ShortcutActions"],
                {
-                       "red": self.cancel,
+                       "red": self.cancel,
                        "green": self.select,
-                       "yellow": self.rescan,
                })
                self.onLayoutFinish.append(self.layoutFinished)
+               self.getAccessPoints(refresh = False)
                
        def layoutFinished(self):
                self.setTitle(_("Choose a wireless network"))
        
        def select(self):
                cur = self["list"].getCurrent()
-               #print "CURRENT",cur
                if cur is not None:
+                       self.rescanTimer.stop()
+                       del self.rescanTimer
                        if cur[1] is not None:
-                               essid = cur[0]
-                               if essid == '':
-                                       essid = cur[1]
-                               encrypted = cur[2]
-                               self.close(essid,self["list"].getList())
+                               essid = cur[1]
+                               self.close(essid,self.getWlanList())
                        else:
                                self.close(None,None)
                else:
+                       self.rescanTimer.stop()
+                       del self.rescanTimer
                        self.close(None,None)
        
        def WlanSetupClosed(self, *ret):
                if ret[0] == 2:
+                       self.rescanTimer.stop()
+                       del self.rescanTimer
                        self.close(None)
        
-       def rescan(self):
-               self["list"].reload()
-               self.setInfo()
-       
        def cancel(self):
                if self.oldInterfaceState is False:
+                       iNetwork.setAdapterAttribute(self.iface, "up", False)
                        iNetwork.deactivateInterface(self.iface,self.deactivateInterfaceCB)
                else:
+                       self.rescanTimer.stop()
+                       del self.rescanTimer
                        self.close(None)
 
        def deactivateInterfaceCB(self,data):
                if data is not None:
                        if data is True:
-                               iNetwork.getInterfaces(self.cancelCB)
-       
-       def cancelCB(self,data):                        
-               if data is not None:
-                       if data is True:
+                               self.rescanTimer.stop()
+                               del self.rescanTimer
                                self.close(None)
 
-       def setInfo(self):
-               length = self["list"].getLength()
+       def rescanTimerFired(self):
+               self.rescanTimer.stop()
+               self.updateAPList()
+
+       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))
+
+       def updateAPList(self):
+               self.oldlist = []
+               self.oldlist = self.cleanList
+               self.newAPList = []
+               newList = []
+               tmpList = []
+               newListIndex = None
+               currentListEntry = None
+               currentListIndex = None
+               newList = self.getAccessPoints(refresh = True)
                
+               for oldentry in self.oldlist:
+                       if oldentry not in newList:
+                               newList.append(oldentry)
+
+               for newentry in newList:
+                       if newentry[1] == "hidden...":
+                               continue
+                       tmpList.append(newentry)
+
+               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 == currentListEntry:
+                                       newListIndex = idx
+                               idx +=1
+                       self['list'].setList(self.newAPList)
+                       self["list"].setIndex(newListIndex)
+                       self["list"].updateList(self.newAPList)
+                       self.listLenght = len(self.newAPList)
+                       self.buildWlanList()
+                       self.setInfo()
+
+       def getAccessPoints(self, refresh = False):
+               self.APList = []
+               self.cleanList = []
+               self.w = Wlan(self.iface)
+               aps = self.w.getNetworkList()
+               if aps is not None:
+                       print "[NetworkWizard.py] got Accespoints!"
+                       tmpList = []
+                       compList = []
+                       for ap in aps:
+                               a = aps[ap]
+                               if a['active']:
+                                       tmpList.append( (a['essid'], a['bssid']) )
+                                       compList.append( (a['essid'], a['bssid'], a['encrypted'], a['iface'], a['maxrate'], a['signal']) )
+
+                       for entry in tmpList:
+                               if entry[0] == "":
+                                       for compentry in compList:
+                                               if compentry[1] == entry[1]:
+                                                       compList.remove(compentry)
+                       for entry in compList:
+                               self.cleanList.append( ( entry[0], entry[1], entry[2], entry[3], entry[4], entry[5] ) )
+               
+               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] ))
+               
+               if refresh is False:
+                       self['list'].setList(self.APList)
+               self.listLenght = len(self.APList)
+               self.setInfo()
+               self.rescanTimer.start(5000)
+               return self.cleanList
+
+       def setInfo(self):
+               length = self.getLength()
                if length == 0:
                        self["info"].setText(_("No wireless networks found! Please refresh."))
                elif length == 1:
                        self["info"].setText(_("1 wireless network found!"))
                else:
-                       self["info"].setText(str(length)+_(" wireless networks found!"))        
+                       self["info"].setText(str(length)+_(" wireless networks found!"))
+
+       def buildWlanList(self):
+               self.WlanList = []
+               currList = []
+               currList = self['list'].list
+               for entry in currList:
+                       self.WlanList.append( (entry[1], entry[0]) )            
+
+       def getLength(self):
+               return self.listLenght          
+
+       def getWlanList(self):
+               return self.WlanList
 
 
 def WlanStatusScreenMain(session, iface):
@@ -259,13 +373,11 @@ def WlanStatusScreenMain(session, iface):
 
 
 def callFunction(iface):
-       
        w = Wlan(iface)
        i = w.getWirelessInterfaces()
        if i:
                if iface in i:
                        return WlanStatusScreenMain
-       
        return None
 
 
index ec2bafe..e16f26f 100755 (executable)
@@ -6,6 +6,7 @@ from Screens.VirtualKeyBoard import VirtualKeyBoard
 from Screens.HelpMenu import HelpableScreen
 from Components.Network import iNetwork
 from Components.Sources.StaticText import StaticText
+from Components.Sources.Boolean import Boolean
 from Components.Label import Label,MultiColorLabel
 from Components.Pixmap import Pixmap,MultiPixmap
 from Components.MenuList import MenuList
@@ -14,7 +15,7 @@ from Components.ConfigList import ConfigListScreen
 from Components.PluginComponent import plugins
 from Components.MultiContent import MultiContentEntryText, MultiContentEntryPixmapAlphaTest
 from Components.ActionMap import ActionMap, NumberActionMap, HelpableActionMap
-from Tools.Directories import resolveFilename, SCOPE_PLUGINS, SCOPE_SKIN_IMAGE
+from Tools.Directories import resolveFilename, SCOPE_PLUGINS, SCOPE_CURRENT_SKIN
 from Tools.LoadPixmap import LoadPixmap
 from Plugins.Plugin import PluginDescriptor
 from enigma import eTimer, ePoint, eSize, RT_HALIGN_LEFT, eListboxPythonMultiContent, gFont
@@ -36,14 +37,14 @@ def InterfaceEntryComponent(index,name,default,active ):
        num_configured_if = len(iNetwork.getConfiguredAdapters())
        if num_configured_if >= 2:
                if default is True:
-                       png = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/buttons/button_blue.png"))
+                       png = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/buttons/button_blue.png"))
                if default is False:
-                       png = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/buttons/button_blue_off.png"))
+                       png = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/buttons/button_blue_off.png"))
                res.append(MultiContentEntryPixmapAlphaTest(pos=(10, 5), size=(25, 25), png = png))
        if active is True:
-               png2 = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/icons/lock_on.png"))
+               png2 = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/icons/lock_on.png"))
        if active is False:
-               png2 = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/icons/lock_error.png"))
+               png2 = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/icons/lock_error.png"))
        res.append(MultiContentEntryPixmapAlphaTest(pos=(40, 1), size=(25, 25), png = png2))
        return res
 
@@ -278,7 +279,6 @@ class NameserverSetup(Screen, ConfigListScreen, HelpableScreen):
 
        def remove(self):
                print "currentIndex:", self["config"].getCurrentIndex()
-               
                index = self["config"].getCurrentIndex()
                if index < len(self.nameservers):
                        iNetwork.removeNameserver(self.nameservers[index])
@@ -309,24 +309,19 @@ class AdapterSetup(Screen, ConfigListScreen, HelpableScreen):
 
                self["OkCancelActions"] = HelpableActionMap(self, "OkCancelActions",
                        {
-                       "cancel": (self.cancel, _("exit network adapter setup menu")),
-                       "ok": (self.ok, _("select menu entry")),
+                       "cancel": (self.keyCancel, _("exit network adapter configuration")),
+                       "ok": (self.keySave, _("activate network adapter configuration")),
                        })
 
                self["ColorActions"] = HelpableActionMap(self, "ColorActions",
                        {
-                       "red": (self.cancel, _("exit network adapter configuration")),
+                       "red": (self.keyCancel, _("exit network adapter configuration")),
                        "blue": (self.KeyBlue, _("open nameserver configuration")),
                        })
 
-               self["VirtualKB"] = HelpableActionMap(self, "VirtualKeyboardActions",
-                       {
-                       "showVirtualKeyboard": (self.KeyText, [_("open virtual keyboard input help"),_("* Only available when entering hidden SSID or network key")] ),
-                       })
-
                self["actions"] = NumberActionMap(["SetupActions"],
                {
-                       "ok": self.ok,
+                       "ok": self.keySave,
                }, -2)
 
                self.list = []
@@ -355,9 +350,10 @@ class AdapterSetup(Screen, ConfigListScreen, HelpableScreen):
                self["key_red"] = StaticText(_("Cancel"))
                self["key_blue"] = StaticText(_("Edit DNS"))
 
-               self["VKeyIcon"] = Pixmap()
+               self["VKeyIcon"] = Boolean(False)
                self["HelpWindow"] = Pixmap()
-
+               self["HelpWindow"].hide()
+               
        def layoutFinished(self):
                self["DNS1"].setText(self.primaryDNS.getText())
                self["DNS2"].setText(self.secondaryDNS.getText())
@@ -386,9 +382,6 @@ class AdapterSetup(Screen, ConfigListScreen, HelpableScreen):
                        self["Gateway"].setText("")
                        self["Gatewaytext"].setText("")
                self["Adapter"].setText(iNetwork.getFriendlyAdapterName(self.iface))
-               self["VKeyIcon"].hide()
-               self["VirtualKB"].setEnabled(False)
-               self["HelpWindow"].hide()
 
        def createConfig(self):
                self.InterfaceEntry = None
@@ -426,7 +419,6 @@ class AdapterSetup(Screen, ConfigListScreen, HelpableScreen):
                                try:
                                        self.aps = self.w.getNetworkList()
                                        if self.aps is not None:
-                                               print "[NetworkSetup.py] got Accespoints!"
                                                for ap in self.aps:
                                                        a = self.aps[ap]
                                                        if a['active']:
@@ -443,7 +435,7 @@ class AdapterSetup(Screen, ConfigListScreen, HelpableScreen):
                                self.default = self.wsconfig['ssid']
 
                        if "hidden..." not in self.nwlist:
-                               self.nwlist.append(("hidden...",_("hidden network")))
+                               self.nwlist.append(("hidden...",_("enter hidden network SSID")))
                        if self.default not in self.nwlist:
                                self.nwlist.append((self.default,self.default))
                        config.plugins.wlan.essid = NoSave(ConfigSelection(self.nwlist, default = self.default ))
@@ -518,30 +510,10 @@ class AdapterSetup(Screen, ConfigListScreen, HelpableScreen):
 
                self["config"].list = self.list
                self["config"].l.setList(self.list)
-               if not self.selectionChanged in self["config"].onSelectionChanged:
-                       self["config"].onSelectionChanged.append(self.selectionChanged)
 
        def KeyBlue(self):
                self.session.openWithCallback(self.NameserverSetupClosed, NameserverSetup)
 
-       def KeyText(self):
-               if self.iface == "wlan0" or self.iface == "ath0" :
-                       if self["config"].getCurrent() == self.hiddenSSID:
-                               if config.plugins.wlan.essid.value == 'hidden...':
-                                       self.session.openWithCallback(self.VirtualKeyBoardSSIDCallback, VirtualKeyBoard, title = (_("Enter WLAN network name/SSID:")), text = config.plugins.wlan.essid.value)
-                       if self["config"].getCurrent() == self.encryptionKey:
-                               self.session.openWithCallback(self.VirtualKeyBoardKeyCallback, VirtualKeyBoard, title = (_("Enter WLAN passphrase/key:")), text = config.plugins.wlan.encryption.psk.value)
-
-       def VirtualKeyBoardSSIDCallback(self, callback = None):
-               if callback is not None and len(callback):
-                       config.plugins.wlan.hiddenessid.setValue(callback)
-                       self["config"].invalidate(self.hiddenSSID)
-
-       def VirtualKeyBoardKeyCallback(self, callback = None):
-               if callback is not None and len(callback):
-                       config.plugins.wlan.encryption.psk.setValue(callback)
-                       self["config"].invalidate(self.encryptionKey)
-
        def newConfig(self):
                if self["config"].getCurrent() == self.InterfaceEntry:
                        self.createSetup()
@@ -564,34 +536,38 @@ class AdapterSetup(Screen, ConfigListScreen, HelpableScreen):
        def keyRight(self):
                ConfigListScreen.keyRight(self)
                self.newConfig()
+       
+       def keySave(self):
+               self.hideInputHelp()
+               if self["config"].isChanged():
+                       self.session.openWithCallback(self.keySaveConfirm, MessageBox, (_("Are you sure you want to activate this network configuration?\n\n") + self.oktext ) )
+               else:
+                       if self.finished_cb:
+                               self.finished_cb()
+                       else:
+                               self.close('cancel')
 
-       def selectionChanged(self):
-               current = self["config"].getCurrent()
-               if current == self.hiddenSSID and config.plugins.wlan.essid.value == 'hidden...':
-                       helpwindowpos = self["HelpWindow"].getPosition()
-                       if current[1].help_window.instance is not None:
-                               current[1].help_window.instance.move(ePoint(helpwindowpos[0],helpwindowpos[1]))
-                               self["VKeyIcon"].show()
-                               self["VirtualKB"].setEnabled(True)
-               elif current == self.encryptionKey and config.plugins.wlan.encryption.enabled.value:
-                       helpwindowpos = self["HelpWindow"].getPosition()
-                       if current[1].help_window.instance is not None:
-                               current[1].help_window.instance.move(ePoint(helpwindowpos[0],helpwindowpos[1]))
-                               self["VKeyIcon"].show()
-                               self["VirtualKB"].setEnabled(True)
+       def keySaveConfirm(self, ret = False):
+               if (ret == True):               
+                       num_configured_if = len(iNetwork.getConfiguredAdapters())
+                       if num_configured_if >= 1:
+                               self.session.openWithCallback(self.secondIfaceFoundCB, MessageBox, _("A second configured interface has been found.\n\nDo you want to disable the second network interface?"), default = True)
+                       else:
+                               self.applyConfig(True)
                else:
-                       self["VKeyIcon"].hide()
-                       self["VirtualKB"].setEnabled(False)
+                       self.keyCancel()                
 
-       def ok(self):
-               current = self["config"].getCurrent()
-               if current == self.hiddenSSID and config.plugins.wlan.essid.value == 'hidden...':
-                       if current[1].help_window.instance is not None:
-                               current[1].help_window.instance.hide()
-               elif current == self.encryptionKey and config.plugins.wlan.encryption.enabled.value:
-                       if current[1].help_window.instance is not None:
-                               current[1].help_window.instance.hide()
-               self.session.openWithCallback(self.applyConfig, MessageBox, (_("Are you sure you want to activate this network configuration?\n\n") + self.oktext ) )
+       def secondIfaceFoundCB(self,data):
+               if data is False:
+                       self.applyConfig(True)
+               else:
+                       configuredInterfaces = iNetwork.getConfiguredAdapters()
+                       for interface in configuredInterfaces:
+                               if interface == self.iface:
+                                       continue
+                               iNetwork.setAdapterAttribute(interface, "up", False)
+                               iNetwork.deactivateInterface(interface)
+                               self.applyConfig(True)
 
        def applyConfig(self, ret = False):
                if (ret == True):
@@ -612,7 +588,7 @@ class AdapterSetup(Screen, ConfigListScreen, HelpableScreen):
                        iNetwork.restartNetwork(self.applyConfigDataAvail)
                        self.applyConfigRef = self.session.openWithCallback(self.applyConfigfinishedCB, MessageBox, _("Please wait for activation of your network configuration..."), type = MessageBox.TYPE_INFO, enable_input = False)
                else:
-                       self.cancel()
+                       self.keyCancel()
 
        def applyConfigDataAvail(self, data):
                if data is True:
@@ -624,46 +600,39 @@ class AdapterSetup(Screen, ConfigListScreen, HelpableScreen):
 
        def applyConfigfinishedCB(self,data):
                if data is True:
-                       num_configured_if = len(iNetwork.getConfiguredAdapters())
-                       if num_configured_if >= 2:
-                               self.session.openWithCallback(self.secondIfaceFoundCB, MessageBox, _("Your network configuration has been activated.\nA second configured interface has been found.\n\nDo you want to disable the second network interface?"), default = True)
+                       if self.finished_cb:
+                               self.session.openWithCallback(lambda x : self.finished_cb(), MessageBox, _("Your network configuration has been activated."), type = MessageBox.TYPE_INFO, timeout = 10)
                        else:
-                               if self.finished_cb:
-                                       self.session.openWithCallback(lambda x : self.finished_cb(), MessageBox, _("Your network configuration has been activated."), type = MessageBox.TYPE_INFO, timeout = 10)
-                               else:
-                                       self.session.openWithCallback(self.ConfigfinishedCB, MessageBox, _("Your network configuration has been activated."), type = MessageBox.TYPE_INFO, timeout = 10)
-
-       def secondIfaceFoundCB(self,data):
-               if data is False:
-                       self.close('ok')
-               else:
-                       configuredInterfaces = iNetwork.getConfiguredAdapters()
-                       for interface in configuredInterfaces:
-                               if interface == self.iface:
-                                       continue
-                               iNetwork.setAdapterAttribute(interface, "up", False)
-                               iNetwork.deactivateInterface(interface)
-                               self.applyConfig(True)
+                               self.session.openWithCallback(self.ConfigfinishedCB, MessageBox, _("Your network configuration has been activated."), type = MessageBox.TYPE_INFO, timeout = 10)
 
        def ConfigfinishedCB(self,data):
                if data is not None:
                        if data is True:
                                self.close('ok')
 
-       def cancel(self):
+       def keyCancelConfirm(self, result):
+               if not result:
+                       return
                if self.oldInterfaceState is False:
-                       iNetwork.deactivateInterface(self.iface,self.cancelCB)
+                       iNetwork.deactivateInterface(self.iface,self.keyCancelCB)
                else:
                        self.close('cancel')
 
-       def cancelCB(self,data):
+       def keyCancel(self):
+               self.hideInputHelp()
+               if self["config"].isChanged():
+                       self.session.openWithCallback(self.keyCancelConfirm, MessageBox, _("Really close without saving settings?"))
+               else:
+                       self.close('cancel')
+
+       def keyCancelCB(self,data):
                if data is not None:
                        if data is True:
                                self.close('cancel')
 
        def runAsync(self, finished_cb):
                self.finished_cb = finished_cb
-               self.ok()
+               self.keySave()
 
        def NameserverSetupClosed(self, *ret):
                iNetwork.loadNameserverConfig()
@@ -675,6 +644,15 @@ class AdapterSetup(Screen, ConfigListScreen, HelpableScreen):
 
        def cleanup(self):
                iNetwork.stopLinkStateConsole()
+               
+       def hideInputHelp(self):
+               current = self["config"].getCurrent()
+               if current == self.hiddenSSID and config.plugins.wlan.essid.value == 'hidden...':
+                       if current[1].help_window.instance is not None:
+                               current[1].help_window.instance.hide()
+               elif current == self.encryptionKey and config.plugins.wlan.encryption.enabled.value:
+                       if current[1].help_window.instance is not None:
+                               current[1].help_window.instance.hide()
 
 
 class AdapterSetupConfiguration(Screen, HelpableScreen):
@@ -684,6 +662,7 @@ class AdapterSetupConfiguration(Screen, HelpableScreen):
                self.session = session
                self.iface = iface
                self.restartLanRef = None
+               self.LinkState = None
                self.mainmenu = self.genMainMenu()
                self["menulist"] = MenuList(self.mainmenu)
                self["key_red"] = StaticText(_("Close"))
@@ -733,6 +712,7 @@ class AdapterSetupConfiguration(Screen, HelpableScreen):
                self.onClose.append(self.cleanup)
 
        def ok(self):
+               self.stopCheckNetworkConsole()
                if self["menulist"].getCurrent()[1] == 'edit':
                        if self.iface == 'wlan0' or self.iface == 'ath0':
                                try:
@@ -813,7 +793,6 @@ class AdapterSetupConfiguration(Screen, HelpableScreen):
                self.loadDescription()
 
        def loadDescription(self):
-               print self["menulist"].getCurrent()[1]
                if self["menulist"].getCurrent()[1] == 'edit':
                        self["description"].setText(_("Edit the network configuration of your Dreambox.\n" ) + self.oktext )
                if self["menulist"].getCurrent()[1] == 'test':
@@ -832,16 +811,18 @@ class AdapterSetupConfiguration(Screen, HelpableScreen):
                        self["description"].setText(_(self["menulist"].getCurrent()[1][1]) + self.oktext )
                
        def updateStatusbar(self, data = None):
+               self.mainmenu = self.genMainMenu()
+               self["menulist"].l.setList(self.mainmenu)
                self["IFtext"].setText(_("Network:"))
                self["IF"].setText(iNetwork.getFriendlyAdapterName(self.iface))
                self["Statustext"].setText(_("Link:"))
                
                if self.iface == 'wlan0' or self.iface == 'ath0':
                        try:
-                               from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus,Status
+                               from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus
                        except:
-                                       self["statuspic"].setPixmapNum(1)
-                                       self["statuspic"].show()
+                               self["statuspic"].setPixmapNum(1)
+                               self["statuspic"].show()
                        else:
                                iStatus.getDataForInterface(self.iface,self.getInfoCB)
                else:
@@ -863,7 +844,6 @@ class AdapterSetupConfiguration(Screen, HelpableScreen):
                        callFnc = p.__call__["ifaceSupported"](self.iface)
                        if callFnc is not None:
                                self.extended = callFnc
-                               print p.__call__
                                if p.__call__.has_key("WlanPluginEntry"): # internally used only for WLAN Plugin
                                        menu.append((_("Scan Wireless Networks"), "scanwlan"))
                                        if iNetwork.getAdapterAttribute(self.iface, "up"):
@@ -902,20 +882,14 @@ class AdapterSetupConfiguration(Screen, HelpableScreen):
                                                # Display Wlan not available Message
                                                self.showErrorMessage()
                        else:
-                               self.mainmenu = self.genMainMenu()
-                               self["menulist"].l.setList(self.mainmenu)
                                self.updateStatusbar()
                else:
-                       self.mainmenu = self.genMainMenu()
-                       self["menulist"].l.setList(self.mainmenu)
                        self.updateStatusbar()
 
        def WlanStatusClosed(self, *ret):
                if ret is not None and len(ret):
                        from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus,Status
                        iStatus.stopWlanConsole()
-                       self.mainmenu = self.genMainMenu()
-                       self["menulist"].l.setList(self.mainmenu)
                        self.updateStatusbar()
 
        def WlanScanClosed(self,*ret):
@@ -924,8 +898,6 @@ class AdapterSetupConfiguration(Screen, HelpableScreen):
                else:
                        from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus,Status
                        iStatus.stopWlanConsole()
-                       self.mainmenu = self.genMainMenu()
-                       self["menulist"].l.setList(self.mainmenu)
                        self.updateStatusbar()
                        
        def restartLan(self, ret = False):
@@ -947,15 +919,15 @@ class AdapterSetupConfiguration(Screen, HelpableScreen):
                        self.session.open(MessageBox, _("Finished restarting your network"), type = MessageBox.TYPE_INFO, timeout = 10, default = False)
 
        def dataAvail(self,data):
-               self.output = data.strip()
-               result = self.output.split('\n')
-               pattern = re_compile("Link detected: yes")
-               for item in result:
-                       if re_search(pattern, item):
-                               self["statuspic"].setPixmapNum(0)
-                       else:
-                               self["statuspic"].setPixmapNum(1)
-               self["statuspic"].show()
+               self.LinkState = None
+               for line in data.splitlines():
+                       line = line.strip()
+                       if 'Link detected:' in line:
+                               if "yes" in line:
+                                       self.LinkState = True
+                               else:
+                                       self.LinkState = False
+               iNetwork.checkNetworkState(self.checkNetworkCB)
 
        def showErrorMessage(self):
                self.session.open(MessageBox, self.errortext, type = MessageBox.TYPE_INFO,timeout = 10 )
@@ -963,8 +935,9 @@ class AdapterSetupConfiguration(Screen, HelpableScreen):
        def cleanup(self):
                iNetwork.stopLinkStateConsole()
                iNetwork.stopDeactivateInterfaceConsole()
+               self.stopCheckNetworkConsole()
                try:
-                       from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus,Status
+                       from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus
                except ImportError:
                        pass
                else:
@@ -980,6 +953,25 @@ class AdapterSetupConfiguration(Screen, HelpableScreen):
                                                self["statuspic"].setPixmapNum(0)
                                        self["statuspic"].show()
 
+       def checkNetworkCB(self,data):
+               if iNetwork.getAdapterAttribute(self.iface, "up") is True:
+                       if self.LinkState is True:
+                               if data <= 2:
+                                       self["statuspic"].setPixmapNum(0)
+                               else:
+                                       self["statuspic"].setPixmapNum(1)
+                       else:
+                               self["statuspic"].setPixmapNum(1)
+               else:
+                       self["statuspic"].setPixmapNum(1)
+               self["statuspic"].show()
+
+       def stopCheckNetworkConsole(self):
+               if iNetwork.PingConsole is not None:
+                       if len(iNetwork.PingConsole.appContainers):
+                               for name in iNetwork.PingConsole.appContainers.keys():
+                                       iNetwork.PingConsole.kill(name)
+
 class NetworkAdapterTest(Screen):      
        def __init__(self, session,iface):
                Screen.__init__(self, session)