Merge commit 'origin/bug_202_networkconfig_cleanup' into experimental
authoracid-burn <acid-burn@opendreambox.org>
Thu, 17 Dec 2009 12:03:23 +0000 (13:03 +0100)
committeracid-burn <acid-burn@opendreambox.org>
Thu, 17 Dec 2009 12:03:23 +0000 (13:03 +0100)
1  2 
lib/python/Screens/NetworkSetup.py

@@@ -551,7 -551,10 +551,10 @@@ class AdapterSetup(Screen, ConfigListSc
                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)
+                               if num_configured_if == 1 and self.iface in iNetwork.getConfiguredAdapters():
+                                       self.applyConfig(True)
+                               else:
+                                       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:
@@@ -662,7 -665,6 +665,7 @@@ class AdapterSetupConfiguration(Screen
                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"))
                self.onClose.append(self.cleanup)
  
        def ok(self):
 +              self.cleanup()
                if self["menulist"].getCurrent()[1] == 'edit':
                        if self.iface == 'wlan0' or self.iface == 'ath0':
                                try:
                        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:"))
                                                # 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):
                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):
                        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
 +              if self.LinkState == True:
 +                      iNetwork.checkNetworkState(self.checkNetworkCB)
 +              else:
 +                      self["statuspic"].setPixmapNum(1)
 +                      self["statuspic"].show()                        
  
        def showErrorMessage(self):
                self.session.open(MessageBox, self.errortext, type = MessageBox.TYPE_INFO,timeout = 10 )
        def cleanup(self):
                iNetwork.stopLinkStateConsole()
                iNetwork.stopDeactivateInterfaceConsole()
 +              iNetwork.stopPingConsole()
                try:
                        from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus
                except ImportError:
                        iStatus.stopWlanConsole()
  
        def getInfoCB(self,data,status):
 +              self.LinkState = None
                if data is not None:
                        if data is True:
                                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.LinkState = False
                                                self["statuspic"].setPixmapNum(1)
 +                                              self["statuspic"].show()
                                        else:
 -                                              self["statuspic"].setPixmapNum(0)
 -                                      self["statuspic"].show()
 +                                              self.LinkState = True
 +                                              iNetwork.checkNetworkState(self.checkNetworkCB)
 +
 +      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)
 +                              self["statuspic"].show()        
 +                      else:
 +                              self["statuspic"].setPixmapNum(1)
 +                              self["statuspic"].show()
 +              else:
 +                      self["statuspic"].setPixmapNum(1)
 +                      self["statuspic"].show()
 +
  
  class NetworkAdapterTest(Screen):     
        def __init__(self, session,iface):
                        pass
                else:
                        iStatus.stopWlanConsole()
 -                      
 +