follow async changes(needs enigma2 update)
authorMladen Horvat <acid-burn@opendreambox.org>
Fri, 7 Nov 2008 20:44:42 +0000 (20:44 +0000)
committerMladen Horvat <acid-burn@opendreambox.org>
Fri, 7 Nov 2008 20:44:42 +0000 (20:44 +0000)
numericaltextinput doesnt hide inputfields anymore
better workflow
install License file
translations will follow

networkwizard/src/Makefile.am
networkwizard/src/NetworkWizard.py
networkwizard/src/networkwizard.xml

index d41ce77..d14c294 100755 (executable)
@@ -5,5 +5,6 @@ install_PYTHON =        \
        plugin.py \\r
        NetworkWizard.py \\r
        networkwizard.xml \\r
-       WizardPluginLanguage.py\r
+       WizardPluginLanguage.py \\r
+       LICENSE\r
        \r
index 2691111..7cadd91 100755 (executable)
@@ -2,8 +2,9 @@
 from __init__ import _
 
 from Screens.Wizard import wizardManager, WizardSummary
+from Screens.MessageBox import MessageBox
 from Components.Pixmap import Pixmap, MovingPixmap, MultiPixmap
-from Components.config import config, ConfigBoolean, configfile, ConfigYesNo, NoSave, ConfigSubsection, ConfigText, getConfigListEntry, ConfigSelection
+from Components.config import config, ConfigBoolean, configfile, ConfigYesNo, NoSave, ConfigSubsection, ConfigText, getConfigListEntry, ConfigSelection, ConfigPassword
 from Components.Network import iNetwork
 from Components.Label import Label
 from Components.MenuList import MenuList
@@ -16,26 +17,33 @@ from Screens.Rc import Rc
 
 config.misc.firstrun = ConfigBoolean(default = True)
 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.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 NetworkWizard(WizardPluginLanguage, Rc):
        skin = """
                <screen position="0,0" size="720,576" title="Welcome..." flags="wfNoBorder" >
-                       <widget name="text" position="153,50" size="340,300" font="Regular;22" />
-                       <widget source="list" render="Listbox" position="53,310" size="440,220" scrollbarMode="showOnDemand" >
+                       <widget name="text" position="153,40" size="340,330" font="Regular;22" />
+                       <widget source="list" render="Listbox" position="53,340" size="440,180" scrollbarMode="showOnDemand" >
                                <convert type="StringList" />
                        </widget>
-                       <widget name="config" position="53,310" zPosition="1" size="440,220" transparent="1" scrollbarMode="showOnDemand" />
+                       <widget name="config" position="53,340" zPosition="1" size="440,180" transparent="1" scrollbarMode="showOnDemand" />
                        <ePixmap pixmap="skin_default/buttons/button_red.png" position="40,225" zPosition="0" size="15,16" transparent="1" alphatest="on" />
                        <widget name="languagetext" position="55,225" size="95,30" font="Regular;18" />
                        <widget name="wizard" pixmap="skin_default/wizard.png" position="40,50" zPosition="10" size="110,174" alphatest="on" />
@@ -58,12 +66,15 @@ class NetworkWizard(WizardPluginLanguage, Rc):
                self.ap = None
                self.selectedInterface = None
                self.NextStep = None
-               
+               self.myref = None
+               self.checkRef = None
+               self.AdapterRef = None
+               self.WlanList = None
                self.isWlanPluginInstalled()
 
        def listInterfaces(self):
                list = [(iNetwork.getFriendlyAdapterName(x),x) for x in iNetwork.getAdapterList()]
-               list.append((_("Exit wizard and configure later manually"), "end"))
+               list.append((_("Exit network wizard"), "end"))
                return list
 
        def InterfaceSelectionMade(self, index):
@@ -83,77 +94,121 @@ class NetworkWizard(WizardPluginLanguage, Rc):
                
        def checkInterface(self,iface):
                self.Adapterlist = iNetwork.getAdapterList()
-               if len(self.Adapterlist) == 0:
-                       #Reset Network to defaults if network broken
-                       iNetwork.resetNetworkConfig('lan')
-               if iface == 'eth0':
-                       iNetwork.resetNetworkConfig('lan')
-                       self.InterfaceUp('eth0')
-               if iface == 'wlan0':
-                       iNetwork.resetNetworkConfig('wlan')
-                       self.InterfaceUp('wlan0')
-               if iface == 'ath0':
-                       iNetwork.resetNetworkConfig('wlan-mpci')
-                       self.InterfaceUp('ath0')
+               if self.NextStep is not 'end':
+                       if len(self.Adapterlist) == 0:
+                               #Reset Network to defaults if network broken
+                               iNetwork.resetNetworkConfig('lan', self.checkInterfaceCB)
+                               self.myref = self.session.openWithCallback(self.resetfinishedCB, MessageBox, _("Please wait while we prepare your network interfaces..."), type = MessageBox.TYPE_INFO, enable_input = False)
+                       if iface == 'eth0':
+                               iNetwork.resetNetworkConfig('lan',self.checkInterfaceCB)
+                               self.myref = self.session.openWithCallback(self.resetfinishedCB, MessageBox, _("Please wait while we prepare your network interfaces..."), type = MessageBox.TYPE_INFO, enable_input = False)
+                       elif iface == 'wlan0':
+                               iNetwork.resetNetworkConfig('wlan',self.checkInterfaceCB)
+                               self.myref = self.session.openWithCallback(self.resetfinishedCB, MessageBox, _("Please wait while we prepare your network interfaces..."), type = MessageBox.TYPE_INFO, enable_input = False)
+                       elif iface == 'ath0':
+                               iNetwork.resetNetworkConfig('wlan-mpci',self.checkInterfaceCB)
+                               self.myref = self.session.openWithCallback(self.resetfinishedCB, MessageBox, _("Please wait while we prepare your network interfaces..."), type = MessageBox.TYPE_INFO, enable_input = False)
+               else:
+                       self.resetfinishedCB(False)
                        
-       def InterfaceUp(self,iface):
-               iNetwork.getInterfaces()
-               if iNetwork.getAdapterAttribute(iface, 'up') is True:
-                       self.isInterfaceUp = True
+       def resetfinishedCB(self,data):
+               if data is True:
+                       self.currStep = self.getStepWithID(self.NextStep)
+                       self.afterAsyncCode()
+               else:
+                       self.currStep = self.getStepWithID(self.NextStep)
+                       self.afterAsyncCode()
+
+       def checkInterfaceCB(self,callback,iface):
+               if callback is not None:
+                       if callback is True:
+                               iNetwork.getInterfaces(self.getInterfacesDataAvail)
+                               
+
+       def getInterfacesDataAvail(self, data):
+               if data is True:
+                       if iNetwork.getAdapterAttribute(self.selectedInterface, 'up') is True:
+                               self.isInterfaceUp = True
+                       else:
+                               self.isInterfaceUp = False
+                       self.myref.close(True)
+
+       def AdapterSetupEnd(self, iface):
+               if iNetwork.getAdapterAttribute(iface, "dhcp") is True:
+                       iNetwork.checkNetworkState(self.AdapterSetupEndFinished)
+                       self.AdapterRef = self.session.openWithCallback(self.AdapterSetupEndCB, MessageBox, _("Please wait while we test your network..."), type = MessageBox.TYPE_INFO, enable_input = False)
+
                else:
-                       self.isInterfaceUp = False
+                       self.currStep = self.getStepWithID("confdns")
+                       self.afterAsyncCode()
+
+       def AdapterSetupEndCB(self,data):
+               if data is True:
+                       self.currStep = self.getStepWithID("checklanstatusend")
+                       self.afterAsyncCode()
+
+       def AdapterSetupEndFinished(self,data):
+               if data <= 2:
+                       self.InterfaceState = True
+               else:
+                       self.InterfaceState = False
+               self.AdapterRef.close(True)
                        
+       def checkNetwork(self):
+               iNetwork.checkNetworkState(self.checkNetworkStateFinished)
+               self.checkRef = self.session.openWithCallback(self.checkNetworkCB, MessageBox, _("Please wait while we test your network..."), type = MessageBox.TYPE_INFO, enable_input = False)
+
+       def checkNetworkCB(self,data):
+               if data is True:
+                       self.currStep = self.getStepWithID("checklanstatusend")
+                       self.afterAsyncCode()
+
+       def checkNetworkStateFinished(self,data):
+               if data <= 2:
+                       self.InterfaceState = True
+               else:
+                       self.InterfaceState = False
+               self.checkRef.close(True)
+       
        def markDone(self):
                pass
 
        def listModes(self):
                list = []
+               self.WlanList = []
                try:
                        from Plugins.SystemPlugins.WirelessLan.Wlan import Wlan
                except ImportError:
-                       list.append( ( _("No Networks found"),_("unavailable") ) )
+                       list.append( ( _("No networks found"),_("unavailable") ) )
+                       self.WlanList.append(_("No networks found"))
                        return list
                else:   
                        self.w = Wlan(self.selectedInterface)
                        aps = self.w.getNetworkList()
                        if aps is not None:
-                               print "[Wlan.py] got Accespoints!"
+                               print "[NetworkWizard.py] got Accespoints!"
                                for ap in aps:
                                        a = aps[ap]
                                        if a['active']:
                                                if a['essid'] == "":
                                                        a['essid'] = a['bssid']
                                                list.append( (a['essid'], a['essid']) )
-                       else:
-                               list.append( ( _("No Networks found"),_("unavailable") ) )
-                       list.sort(key = lambda x: x[0])
+                                               self.WlanList.append(a['essid'])        
+                       if "hidden..." not in list:
+                               list.append( ( _("enter hidden network SSID"),_("hidden...") ) )
+                               self.WlanList.append(_("hidden..."))    
                        return list
 
        def modeSelectionMade(self, index):
-               self.ap = index
                self.modeSelect(index)
                
        def modeSelectionMoved(self):
                self.modeSelect(self.selection)
                
        def modeSelect(self, mode):
+               self.ap = mode
                print "ModeSelected:", mode
 
-       def saveAccessPoint(self, mode):
-               from Plugins.SystemPlugins.WirelessLan.Wlan import wpaSupplicant,Wlan
-               self.ws = wpaSupplicant()
-               wsconfig = self.ws.loadConfig()
-               config.plugins.wlan.essid.value = str(mode)
-               config.plugins.wlan.essid.save()
-               self.ws.writeConfig()
-
-       def checkNetwork(self):
-               ret = iNetwork.checkNetworkState()
-               if ret == True:
-                       self.InterfaceState = True
-               else:
-                       self.InterfaceState = False
-
        def restartNetwork(self):
                iNetwork.restartNetwork()
                self.checkNetwork()
@@ -166,13 +221,3 @@ class NetworkWizard(WizardPluginLanguage, Rc):
                else:
                        self.WlanPluginInstalled = True
 
-       def AdapterSetupEnd(self, iface):
-               self.iface = iface
-               if iNetwork.getAdapterAttribute(self.iface, "dhcp") is True:
-                       self.checkNetwork()
-                       self.NextStep = 'checklanstatusend'
-               else:
-                       self.NextStep = 'confdns'
-                       
-
-
index e7b63ea..3b4f412 100755 (executable)
@@ -18,9 +18,8 @@ self.selectKey("OK")
 self.selectKey("UP")
 self.selectKey("DOWN")
                        </code>
-                       <code pos="after">
-self.checkInterface(self.selectedInterface)                        
-self.currStep = self.getStepWithID(self.NextStep)
+                       <code pos="after" async="yes">
+self.checkInterface(self.selectedInterface)
                        </code> 
                </step>
 
@@ -36,9 +35,8 @@ self.selectKey("DOWN")
 self.selectKey("LEFT")
 self.selectKey("RIGHT")
                        </code>
-                       <code pos="after">
-self.AdapterSetupEnd(self.selectedInterface)    
-self.currStep = self.getStepWithID(self.NextStep)
+                       <code pos="after" async="yes">
+self.AdapterSetupEnd(self.selectedInterface)
                        </code>                 
                </step>
 
@@ -50,7 +48,7 @@ self.currStep = self.getStepWithID(self.NextStep)
 self.clearSelectedKeys()
 self.selectKey("OK")
                        </code>
-                       <code pos="after">
+                       <code pos="after" async="yes">
 self.checkNetwork()
                        </code> 
                </step>
@@ -87,13 +85,12 @@ self.selectKey("DOWN")
                        </code>
                        <list>
                                <listentry caption="Configure your network again" step="selectinterface" />
-                               <listentry caption="Exit wizard and configure later manually" step="end" />
+                               <listentry caption="Exit network wizard" step="end" />
                        </list>
                </step>
 
-               <step id="scanwlan" nextstep="nwconfig">
+               <step id="scanwlan" nextstep="wlanconfig">
                <condition>
-self.checkInterface(self.selectedInterface)                    
 self.condition = (self.isInterfaceUp == True and self.WlanPluginInstalled == True)
                </condition>
                        <text value="Please select the wireless LAN network that you want to connect to.\n\nPlease press OK to continue." />
@@ -107,14 +104,10 @@ self.selectKey("DOWN")
 self.selectKey("LEFT")
 self.selectKey("RIGHT")
                        </code>
-                       <code pos="after">
-self.saveAccessPoint(self.ap)
-                       </code>
                </step>
 
                <step id="scanwlan">
                <condition>
-self.checkInterface(self.selectedInterface)                            
 self.condition = (self.isInterfaceUp == False and self.WlanPluginInstalled == True)
                </condition>
                        <text value="Your wireless LAN internet connection could not be started!\nHave you attached your USB WLAN Stick?\n\nPlease choose what you want to do next." />
@@ -122,7 +115,7 @@ self.condition = (self.isInterfaceUp == False and self.WlanPluginInstalled == Tr
                        <list>
                                <listentry caption="Configure your wireless LAN again" step="scanwlan" />
                                <listentry caption="Configure your internal LAN" step="selectinterface" />
-                               <listentry caption="Exit wizard and configure later manually" step="end" />
+                               <listentry caption="Exit network wizard" step="end" />
                        </list>
                        <code>
 self.clearSelectedKeys()
@@ -134,14 +127,13 @@ self.selectKey("DOWN")
 
                <step id="scanwlan">
                <condition>
-self.checkInterface(self.selectedInterface)                            
 self.condition = (self.isInterfaceUp == True and self.WlanPluginInstalled == False)
                </condition>
                        <text value="The wireless LAN plugin is not installed!\nPlease install it and choose what you want to do next." />
                        <displaytext value="Please follow the instructions on the TV" />
                        <list>
                                <listentry caption="Configure your internal LAN" step="selectinterface" />
-                               <listentry caption="Exit wizard and configure later manually" step="end" />
+                               <listentry caption="Exit network wizard" step="end" />
                        </list>
                        <code>
 self.clearSelectedKeys()
@@ -151,6 +143,23 @@ self.selectKey("DOWN")
                        </code>
                </step>
 
+               <step id="wlanconfig">
+                       <text value="Please configure your internet connection by filling out the required values.\nWhen you are ready press OK to continue." />
+                       <displaytext value="Configure interface" />
+                       <config screen="AdapterSetup" module="NetworkSetup" args="(self.selectedInterface,self.ap,self.WlanList)" type="ConfigList" />
+                       <code>
+self.clearSelectedKeys()
+self.selectKey("OK")
+self.selectKey("UP")
+self.selectKey("DOWN")
+self.selectKey("LEFT")
+self.selectKey("RIGHT")
+                       </code>
+                       <code pos="after" async="yes">
+self.AdapterSetupEnd(self.selectedInterface)
+                       </code>                 
+               </step>
+
                <step id="end">
                        <text value="Thank you for using the wizard.\nPlease press OK to continue." />
                        <code>