+ def createConfig(self):
+ self.InterfaceEntry = None
+ self.dhcpEntry = None
+ self.gatewayEntry = None
+ self.SSIDscan = None
+ self.wlanSSID = None
+ self.manualwlanSSID = None
+ self.encryptionEnabled = None
+ self.encryptionKey = None
+ self.nwlist = None
+ self.wsconfig = None
+ self.default = None
+
+ if self.iface == "wlan0" or self.iface == "ath0" :
+ from Plugins.SystemPlugins.WirelessLan.Wlan import wpaSupplicant,Wlan
+ self.ws = wpaSupplicant()
+ list = []
+ list.append(_("WEP"))
+ list.append(_("WPA"))
+ list.append(_("WPA2"))
+ if self.aplist is not None:
+ self.nwlist = self.aplist
+ self.nwlist.sort(key = lambda x: x[0])
+ else:
+ self.nwlist = []
+ self.w = None
+ self.aps = None
+ try:
+ self.w = Wlan(self.iface)
+ self.aps = self.w.getNetworkList()
+ if self.aps is not None:
+ print "[NetworkSetup.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")
+
+ self.wsconfig = self.ws.loadConfig()
+ self.default = self.essid or self.wsconfig['ssid']
+ if self.default not in self.nwlist:
+ self.nwlist.append(self.default)
+ config.plugins.wlan.essidscan = NoSave(ConfigYesNo(default = self.wsconfig['ssidscan']))
+ if self.wsconfig['ssidscan'] is True:
+ config.plugins.wlan.essid = NoSave(ConfigSelection(self.nwlist, default = self.default ))
+ else:
+ config.plugins.wlan.essid = NoSave(ConfigText(default = self.default, visible_width = 50, fixed_size = False))
+ config.plugins.wlan.encryption.enabled = NoSave(ConfigYesNo(default = self.wsconfig['encryption'] ))
+ config.plugins.wlan.encryption.type = NoSave(ConfigSelection(list, default = self.wsconfig['encryption_type'] ))
+ config.plugins.wlan.encryption.psk = NoSave(ConfigText(default = self.wsconfig['key'], visible_width = 50, fixed_size = False))
+
+ self.activateInterfaceEntry = NoSave(ConfigYesNo(default=iNetwork.getAdapterAttribute(self.iface, "up") or False))
+ self.dhcpConfigEntry = NoSave(ConfigYesNo(default=iNetwork.getAdapterAttribute(self.iface, "dhcp") or False))
+ self.ipConfigEntry = NoSave(ConfigIP(default=iNetwork.getAdapterAttribute(self.iface, "ip")) or [0,0,0,0])
+ self.netmaskConfigEntry = NoSave(ConfigIP(default=iNetwork.getAdapterAttribute(self.iface, "netmask") or [255,0,0,0]))
+ if iNetwork.getAdapterAttribute(self.iface, "gateway"):
+ self.dhcpdefault=True
+ else:
+ self.dhcpdefault=False
+ self.hasGatewayConfigEntry = NoSave(ConfigYesNo(default=self.dhcpdefault or False))
+ self.gatewayConfigEntry = NoSave(ConfigIP(default=iNetwork.getAdapterAttribute(self.iface, "gateway") or [0,0,0,0]))
+ nameserver = (iNetwork.getNameserverList() + [[0,0,0,0]] * 2)[0:2]
+ self.primaryDNS = NoSave(ConfigIP(default=nameserver[0]))
+ self.secondaryDNS = NoSave(ConfigIP(default=nameserver[1]))