networksetup fixes / cleanups
authorAndreas Monzner <andreas.monzner@multimedia-labs.de>
Fri, 13 Jun 2008 13:12:34 +0000 (13:12 +0000)
committerAndreas Monzner <andreas.monzner@multimedia-labs.de>
Fri, 13 Jun 2008 13:12:34 +0000 (13:12 +0000)
data/skin_default.xml
lib/python/Screens/NetworkSetup.py

index 3c8426c135a6a65e6c724b1fc7f72227b17ba045..995cb083ae76372c9b58af91156814a86315cdf2 100644 (file)
@@ -544,30 +544,30 @@ self.instance.move(ePoint(orgpos.x() + (orgwidth - newwidth)/2, orgpos.y()))
                <widget name="Adaptertext" position="10,20" size="120,21" zPosition="1" font="Regular;19" foregroundColors="#8c8c93,#1cff1c" />                 
                <widget name="Adapter" position="130,20" size="270,21" zPosition="1" font="Regular;19" halign="center" foregroundColors="#8c8c93,#f23d21,#1cff1c" />
                <widget name="AdapterInfo" pixmaps="skin_default/buttons/blue.png,skin_default/buttons/blue_pressed.png" position="425,10" zPosition="1" size="140,40" transparent="1" alphatest="on" />
-               <widget name="AdapterInfo_Text" position="440,20" size="110,21" zPosition="2" font="Regular;19" transparent="1" foregroundColors="#8c8c93,#000000" />
+               <widget name="AdapterInfo_Text" position="440,20" size="110,21" zPosition="2" font="Regular;19" transparent="1" foregroundColors="#8c8c93,#000000,#1cff1c" />
                <widget name="AdapterInfo_OK" pixmap="skin_default/icons/lock_on.png" position="400,15" size="38,31" alphatest="on" zPosition="2" />
                <widget name="Networktext" position="10,70" size="120,21" zPosition="1" font="Regular;19" foregroundColors="#8c8c93,#1cff1c" />                 
                <widget name="Network" position="160,70" size="240,21" zPosition="1" font="Regular;19" halign="center" foregroundColors="#8c8c93,#f23d21,#1cff1c" />
                <widget name="NetworkInfo" pixmaps="skin_default/buttons/blue.png,skin_default/buttons/blue_pressed.png" position="425,60" zPosition="1" size="140,40" transparent="1" alphatest="on" />
-               <widget name="NetworkInfo_Text" position="440,70" size="110,21" zPosition="2" font="Regular;19" transparent="1" foregroundColors="#8c8c93,#000000" />
+               <widget name="NetworkInfo_Text" position="440,70" size="110,21" zPosition="2" font="Regular;19" transparent="1" foregroundColors="#8c8c93,#000000,#1cff1c" />
                <widget name="NetworkInfo_Check" pixmaps="skin_default/icons/lock_on.png,skin_default/icons/lock_error.png" position="400,65" size="38,31" alphatest="on" zPosition="2" />
                <widget name="Dhcptext" position="10,120" size="120,21" zPosition="1" font="Regular;19" foregroundColors="#8c8c93,#1cff1c" />                   
                <widget name="Dhcp" position="160,120" size="240,21" zPosition="1" font="Regular;19" halign="center" foregroundColors="#8c8c93,#f23d21,#1cff1c" />
                <widget name="DhcpInfo" pixmaps="skin_default/buttons/blue.png,skin_default/buttons/blue_pressed.png" position="425,110" zPosition="1" size="140,40" transparent="1" alphatest="on" />
-               <widget name="DhcpInfo_Text" position="440,120" size="110,21" zPosition="2" font="Regular;19" transparent="1" foregroundColors="#8c8c93,#000000" />
+               <widget name="DhcpInfo_Text" position="440,120" size="110,21" zPosition="2" font="Regular;19" transparent="1" foregroundColors="#8c8c93,#000000,#1cff1c" />
                <widget name="DhcpInfo_Check" pixmaps="skin_default/icons/lock_on.png,skin_default/icons/lock_error.png" position="400,115" size="38,31" alphatest="on" zPosition="2" />
                <widget name="IPtext" position="10,170" size="120,21" zPosition="1" font="Regular;19" foregroundColors="#8c8c93,#1cff1c" />                     
                <widget name="IP" position="160,170" size="240,21" zPosition="1" font="Regular;19" halign="center" foregroundColors="#8c8c93,#f23d21,#1cff1c" />
                <widget name="IPInfo" pixmaps="skin_default/buttons/blue.png,skin_default/buttons/blue_pressed.png" position="425,160" zPosition="1" size="140,40" transparent="1" alphatest="on" />
-               <widget name="IPInfo_Text" position="440,170" size="110,21" zPosition="2" font="Regular;19" transparent="1" foregroundColors="#8c8c93,#000000" />
+               <widget name="IPInfo_Text" position="440,170" size="110,21" zPosition="2" font="Regular;19" transparent="1" foregroundColors="#8c8c93,#000000,#1cff1c" />
                <widget name="IPInfo_Check" pixmaps="skin_default/icons/lock_on.png,skin_default/icons/lock_error.png" position="400,165" size="38,31" alphatest="on" zPosition="2" />
                <widget name="DNStext" position="10,220" size="120,21" zPosition="1" font="Regular;19" foregroundColors="#8c8c93,#1cff1c" />                    
                <widget name="DNS" position="160,220" size="240,21" zPosition="1" font="Regular;19" halign="center" foregroundColors="#8c8c93,#f23d21,#1cff1c" />
                <widget name="DNSInfo" pixmaps="skin_default/buttons/blue.png,skin_default/buttons/blue_pressed.png" position="425,210" zPosition="1" size="140,40" transparent="1" alphatest="on" />
-               <widget name="DNSInfo_Text" position="440,220" size="110,21" zPosition="2" font="Regular;19" transparent="1" foregroundColors="#8c8c93,#000000" />
+               <widget name="DNSInfo_Text" position="440,220" size="110,21" zPosition="2" font="Regular;19" transparent="1" foregroundColors="#8c8c93,#000000,#1cff1c" />
                <widget name="DNSInfo_Check" pixmaps="skin_default/icons/lock_on.png,skin_default/icons/lock_error.png" position="400,215" size="38,31" alphatest="on" zPosition="2" />
                <widget name="EditSettingsButton" pixmaps="skin_default/buttons/blue.png,skin_default/buttons/blue_pressed.png" position="425,260" zPosition="1" size="140,40" transparent="1" alphatest="on" />
-               <widget name="EditSettings_Text" position="440,270" size="110,21" zPosition="2" font="Regular;19" foregroundColor="black" transparent="1" />
+               <widget name="EditSettings_Text" position="440,270" size="110,21" zPosition="2" font="Regular;19" transparent="1" foregroundColors="#000000,#8c8c93,#1cff1c" />
                <ePixmap pixmap="skin_default/bottombar.png" position="15,310" size="540,120" zPosition="1" transparent="1" alphatest="on" />
                <widget name="ButtonRedtext" position="430,325" size="120,21" zPosition="10" font="Regular;21" transparent="1" />
                <widget name="ButtonRed" pixmap="skin_default/buttons/button_red.png" position="410,325" zPosition="10" size="15,16" transparent="1" alphatest="on" />
index d49622c2ce8e5dbb1ab61872dc18195a065c817f..8bffaf728886c96ba620b1fcc442402baa277815 100644 (file)
@@ -127,10 +127,12 @@ class NameserverSetup(Screen, ConfigListScreen):
                        self.createSetup()
 
 class AdapterSetup(Screen, ConfigListScreen):
-       def __init__(self, session, iface):
+       def __init__(self, session, iface,essid=None, aplist=None):
                Screen.__init__(self, session)
                self.session = session
                iNetwork.getInterfaces()
+               self.essid = essid
+               self.aplist = aplist
                ## FIXME , workaround against current wizzard not able to send arguments
                if iface == 0:
                        self.iface = "eth0"
@@ -146,33 +148,35 @@ class AdapterSetup(Screen, ConfigListScreen):
                        list.append(_("WEP"))
                        list.append(_("WPA"))
                        list.append(_("WPA2"))
-                       if iNetwork.getAdapterAttribute('wlan0', 'up') is True:
-                               try:
-                                       self.w = Wlan('wlan0')
-                                       aps = self.w.getNetworkList()
-                                       nwlist = []
-                                       if aps is not None:
-                                               print "[Wlan.py] got Accespoints!"
-                                               for ap in aps:
-                                                       a = aps[ap]
-                                                       if a['active']:
-                                                               if a['essid'] == "":
-                                                                       a['essid'] = a['bssid']
-                                                               nwlist.append( a['essid'])
-                                       nwlist.sort(key = lambda x: x[0])
-                               except:
-                                       nwlist = []
-                                       nwlist.append("No Networks found")
-                                       
-                       if nwlist is None:
-                               nwlist = []
-                               nwlist.append("No Networks found")
-                       
-                       config.plugins.wlan.essid = NoSave(ConfigSelection(nwlist, default = nwlist[0]))
-                       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))
-                       self.ws.loadConfig()
+                       if self.aplist is not None:
+                               self.nwlist = self.aplist
+                               self.nwlist.sort(key = lambda x: x[0])
+                       else:
+                               if iNetwork.getAdapterAttribute('wlan0', 'up') is True:
+                                       self.nwlist = []
+                                       try:
+                                               self.w = Wlan('wlan0')
+                                               aps = self.w.getNetworkList()
+                                               if aps is not None:
+                                                       print "[Wlan.py] got Accespoints!"
+                                                       for ap in aps:
+                                                               a = aps[ap]
+                                                               if a['active']:
+                                                                       if a['essid'] == "":
+                                                                               a['essid'] = a['bssid']
+                                                                       self.nwlist.append( a['essid'])
+                                               self.nwlist.sort(key = lambda x: x[0])
+                                       except:
+                                               self.nwlist.append("No Networks found")
+                               else:
+                                       self.nwlist.append("No Networks found")
+                               
+                       wsconfig = self.ws.loadConfig()
+                       config.plugins.wlan.essid = NoSave(ConfigSelection(self.nwlist, default = self.essid or wsconfig['ssid'] ))
+                       config.plugins.wlan.encryption.enabled = NoSave(ConfigYesNo(default = wsconfig['encryption'] ))
+                       config.plugins.wlan.encryption.type = NoSave(ConfigSelection(list, default = wsconfig['encryption_type'] ))
+                       config.plugins.wlan.encryption.psk = NoSave(ConfigText(default = wsconfig['key'], fixed_size = False,visible_width = 30))
+                       #self.ws.loadConfig()
                
                self.dhcpConfigEntry = NoSave(ConfigYesNo(default=iNetwork.getAdapterAttribute(self.iface, "dhcp") or False))
                self.hasGatewayConfigEntry = NoSave(ConfigYesNo(default=True))
@@ -372,7 +376,7 @@ class AdapterSetupConfiguration(Screen):
                        self.wlanresponse = ifobj.getStatistics()
                        if self.wlanresponse[0] != 19:
                                from Plugins.SystemPlugins.WirelessLan.plugin import WlanScan
-                               self.session.open(WlanScan,self.iface)
+                               self.session.openWithCallback(self.WlanScanClosed, WlanScan, self.iface)
                        else:
                                # Display Wlan not available Message
                                self.showErrorMessage()
@@ -444,7 +448,7 @@ class AdapterSetupConfiguration(Screen):
                
                if self.iface == 'wlan0':
                        try:
-                               from Plugins.SystemPlugins.WirelessLan.Wlan import Wlan, WlanList, wpaSupplicant
+                               from Plugins.SystemPlugins.WirelessLan.Wlan import Wlan
                                w = Wlan(self.iface)
                                stats = w.getStatus()
                                if stats['BSSID'] == "00:00:00:00:00:00":
@@ -488,6 +492,13 @@ class AdapterSetupConfiguration(Screen):
        def AdapterSetupClosed(self, *ret):
                self.mainmenu = self.genMainMenu()
                self["menulist"].l.setList(self.mainmenu)
+               self.updateStatusbar()
+
+       def WlanScanClosed(self,*ret):
+               if ret[0] is not None:
+                       self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetup, 'wlan0',ret[0],ret[1])
+               else:
+                       self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetup, 'wlan0',None,ret[0])
 
        def enableWlan(self, ret = False):
                if (ret == True):
@@ -495,7 +506,12 @@ class AdapterSetupConfiguration(Screen):
                        iNetwork.getInterfaces()
                        if iNetwork.getAdapterAttribute('wlan0', 'up') is True:
                                self.iface = 'wlan0'
-                               self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetup, 'wlan0')
+                               try:
+                                       from Plugins.SystemPlugins.WirelessLan.plugin import WlanScan
+                               except ImportError:
+                                       self.session.open(MessageBox, _("The wireless LAN plugin is not installed!\nPlease install it."), type = MessageBox.TYPE_INFO,timeout = 10 )
+                               else:   
+                                       self.session.openWithCallback(self.WlanScanClosed, WlanScan, self.iface)
                        else:
                                self.session.openWithCallback(self.restartDreambox, MessageBox, _("Your wireless LAN Adapter could not be started.\nDo you want to reboot your Dreambox to apply the new configuration?\n"))
 
@@ -618,29 +634,47 @@ class NetworkAdapterTest(Screen):
        def setActiveButton(self,button):
                if button == 1:
                        self["EditSettingsButton"].setPixmapNum(0)
+                       self["EditSettings_Text"].setForegroundColorNum(0)
                        self["NetworkInfo"].setPixmapNum(0)
-                       self["AdapterInfo"].setPixmapNum(1)
+                       self["NetworkInfo_Text"].setForegroundColorNum(1)
+                       self["AdapterInfo"].setPixmapNum(1)               # active
+                       self["AdapterInfo_Text"].setForegroundColorNum(2) # active
                if button == 2:
+                       self["AdapterInfo_Text"].setForegroundColorNum(1)
                        self["AdapterInfo"].setPixmapNum(0)
                        self["DhcpInfo"].setPixmapNum(0)
-                       self["NetworkInfo"].setPixmapNum(1)
+                       self["DhcpInfo_Text"].setForegroundColorNum(1)
+                       self["NetworkInfo"].setPixmapNum(1)               # active
+                       self["NetworkInfo_Text"].setForegroundColorNum(2) # active
                if button == 3:
                        self["NetworkInfo"].setPixmapNum(0)
+                       self["NetworkInfo_Text"].setForegroundColorNum(1)
                        self["IPInfo"].setPixmapNum(0)
-                       self["DhcpInfo"].setPixmapNum(1)
+                       self["IPInfo_Text"].setForegroundColorNum(1)
+                       self["DhcpInfo"].setPixmapNum(1)                  # active
+                       self["DhcpInfo_Text"].setForegroundColorNum(2)    # active
                if button == 4:
                        self["DhcpInfo"].setPixmapNum(0)
+                       self["DhcpInfo_Text"].setForegroundColorNum(1)
                        self["DNSInfo"].setPixmapNum(0)
-                       self["IPInfo"].setPixmapNum(1)
+                       self["DNSInfo_Text"].setForegroundColorNum(1)
+                       self["IPInfo"].setPixmapNum(1)                  # active
+                       self["IPInfo_Text"].setForegroundColorNum(2)    # active                
                if button == 5:
                        self["IPInfo"].setPixmapNum(0)
+                       self["IPInfo_Text"].setForegroundColorNum(1)
                        self["EditSettingsButton"].setPixmapNum(0)
-                       self["DNSInfo"].setPixmapNum(1)
+                       self["EditSettings_Text"].setForegroundColorNum(0)
+                       self["DNSInfo"].setPixmapNum(1)                 # active
+                       self["DNSInfo_Text"].setForegroundColorNum(2)   # active
                if button == 6:
                        self["DNSInfo"].setPixmapNum(0)
-                       self["EditSettingsButton"].setPixmapNum(1)
+                       self["DNSInfo_Text"].setForegroundColorNum(1)
+                       self["EditSettingsButton"].setPixmapNum(1)         # active
+                       self["EditSettings_Text"].setForegroundColorNum(2) # active
                        self["AdapterInfo"].setPixmapNum(0)
-
+                       self["AdapterInfo_Text"].setForegroundColorNum(1)
+                       
        def runTest(self):
                next = self.nextstep
                if next == 0:
@@ -726,6 +760,7 @@ class NetworkAdapterTest(Screen):
                
                self["EditSettings_Text"].show()
                self["EditSettingsButton"].setPixmapNum(1)
+               self["EditSettings_Text"].setForegroundColorNum(2) # active
                self["EditSettingsButton"].show()
                self["ButtonYellow_Check"].setPixmapNum(1)
                self["ButtonGreentext"].setText(_("Restart test"))
@@ -856,7 +891,7 @@ class NetworkAdapterTest(Screen):
                self["DNSInfo_Text"] = MultiColorLabel(_("Show Info"))
                self["DNSInfo_Check"] = MultiPixmap()
                
-               self["EditSettings_Text"] = Label(_("Edit settings"))
+               self["EditSettings_Text"] = MultiColorLabel(_("Edit settings"))
                self["EditSettingsButton"] = MultiPixmap()
                
                self["ButtonRedtext"] = Label(_("Close"))