- 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()
+ default = self.essid or wsconfig['ssid']
+ if default not in self.nwlist:
+ self.nwlist.append(default)
+ config.plugins.wlan.essid = NoSave(ConfigSelection(self.nwlist, default = default ))
+ 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()