iNetwork.msgPlugins()
iNetwork.getInterfaces()
+ def checkIfaceMode(self, iface = None):
+ try:
+ obj = Wireless(iface)
+ if obj.getMode() == 'Master':
+ return -1
+ else:
+ return 0
+ except:
+ return -2
+
def ok(self):
# print len(self["menulist"].list)
if len(self["menulist"].list) == 0:
self.session.open(MessageBox, (_("Can not find any WirelessLan Module\n")),MessageBox.TYPE_ERROR,5 )
return
- ifaces=self["menulist"].getCurrent()[1]
- if ifaces == None:
- pass
- else:
- self.session.open(WlanSetup,ifaces)
+ iface=self["menulist"].getCurrent()[1]
+ if iface == None:
+ return
+ elif iNetwork.getAdapterAttribute(iface, "up") == True:
+ ret = self.checkIfaceMode(iface)
+ if ret == -2:
+ self.session.open(MessageBox, (_("Invalid WirelessLan Module.\n")),MessageBox.TYPE_ERROR,5 )
+ return
+ elif ret == -1:
+ self.session.open(MessageBox, (_("Can not setup WirelessLan Module in 'AP Mode'\n")),MessageBox.TYPE_ERROR,5 )
+ return
+ self.session.open(WlanSetup, iface)
def getWlandevice(self):
list = []
for x in iNetwork.getInstalledAdapters():
- if x.startswith('eth'):
+ if x.startswith('eth') or x.startswith('br') or x.startswith('mon'):
continue
description=self.getAdapterDescription(x)
if description == "Unknown network adapter":
wlanconfig.hiddenessid = ConfigText(default = "<Input ESSID>", visible_width = 50, fixed_size = False)
self.createConfig()
- def scanApList(self):
- if self.oldInterfaceState is not True:
- os_system("ifconfig "+self.iface+" up")
- iNetwork.setAdapterAttribute(self.iface, "up", True)
+ def getScanResult(self, wirelessObj):
Iwscanresult = None
- wirelessObj = Wireless(self.iface)
try:
Iwscanresult = wirelessObj.scan()
except IOError:
print "%s Interface doesn't support scanning.."%self.iface
-# self.session.open(MessageBox, "%s Interface doesn't support scanning.."%self.iface, MessageBox.TYPE_ERROR,10)
+ return Iwscanresult
+
+ def scanApList(self):
+ if self.oldInterfaceState is not True:
+ os_system("ifconfig "+self.iface+" up")
+ iNetwork.setAdapterAttribute(self.iface, "up", True)
+ wirelessObj = Wireless(self.iface)
+ Iwscanresult=self.getScanResult(wirelessObj)
+ if Iwscanresult is None or len(Iwscanresult.aplist) == 0 :
+ import time
+ time.sleep(1.5)
+ Iwscanresult=self.getScanResult(wirelessObj)
self.configurationmsg.close(True)
- if Iwscanresult is None:
+ if Iwscanresult is None or len( Iwscanresult.aplist) == 0:
self.emptyListMsgTimer.start(100,True)
else:
for ap in Iwscanresult:
def ok(self):
global selectap
- selectAp=self["menulist"].getCurrent()[0]
- selectap = selectAp
+ if self["menulist"].getCurrent() is not None:
+ selectAp=self["menulist"].getCurrent()[0]
+ selectap = selectAp
self.close()
def startWlanConfig(self):
- selectAp=self["menulist"].getCurrent()[0]
- self.close(selectAp)
+ if self["menulist"].getCurrent() is not None:
+ selectAp=self["menulist"].getCurrent()[0]
+ self.close(selectAp)
def getApList(self):
self.apList = {}
self.configurationmsg = self.session.open(MessageBox, _("Please wait for scanning AP..."), type = MessageBox.TYPE_INFO, enable_input = False)
self.scanAplistTimer.start(100,True)
- def scanApList(self):
- if self.oldInterfaceState is not True:
- os_system("ifconfig "+self.iface+" up")
- iNetwork.setAdapterAttribute(self.iface, "up", True)
+ def getScanResult(self, wirelessObj):
Iwscanresult = None
- wirelessObj = Wireless(self.iface)
try:
Iwscanresult = wirelessObj.scan()
except IOError:
print "%s Interface doesn't support scanning.."%self.iface
-# self.session.open(MessageBox, "%s Interface doesn't support scanning.."%self.iface, MessageBox.TYPE_ERROR,10)
+ return Iwscanresult
+
+ def scanApList(self):
+ if self.oldInterfaceState is not True:
+ os_system("ifconfig "+self.iface+" up")
+ iNetwork.setAdapterAttribute(self.iface, "up", True)
+ wirelessObj = Wireless(self.iface)
+ Iwscanresult=self.getScanResult(wirelessObj)
+ if Iwscanresult is None or len(Iwscanresult.aplist) == 0 :
+ import time
+ time.sleep(1.5)
+ Iwscanresult=self.getScanResult(wirelessObj)
self.configurationmsg.close(True)
- if Iwscanresult is not None:
+ if Iwscanresult is not None and len(Iwscanresult.aplist) != 0:
(num_channels, frequencies) = wirelessObj.getChannelInfo()
index = 1
for ap in Iwscanresult:
def displayApInfo(self):
if len(self.apList) >0:
self["menulist"].setList(self.setApList)
- index = self["menulist"].getCurrent()[1]
- for key in ["Address", "ESSID", "Protocol", "Frequency", "Encryption key", "BitRate"]:
- if self.apList[index].has_key(key):
- self[key].setText((key+": "+self.apList[index][key]))
- else:
- self[key].setText((key+": None"))
+ if self["menulist"].getCurrent() is not None:
+ index = self["menulist"].getCurrent()[1]
+ for key in ["Address", "ESSID", "Protocol", "Frequency", "Encryption key", "BitRate"]:
+ if self.apList[index].has_key(key) and self.apList[index][key] is not None:
+ self[key].setText((key+": "+self.apList[index][key]))
+ else:
+ self[key].setText((key+": None"))
def emptyListMsg(self):
self.session.open(MessageBox, _("No AP detected."), type = MessageBox.TYPE_INFO, timeout = 10)