+ def getWpaSupplicantName(self, iface):
+ return "/etc/wpa_supplicant.conf.%s" % iface
+
+ def readWpaSupplicantConf(self):
+ wpaSupplicantName = self.getWpaSupplicantName(self.iface)
+ wsconf = {}
+ try:
+ if fileExists(wpaSupplicantName):
+ wpafd = open(wpaSupplicantName, "r")
+ lines = wpafd.readlines()
+ wpafd.close()
+ data = {}
+ for line in lines:
+ try:
+ (key, value) = line.strip().split('=',1)
+ except:
+ continue
+
+# if key not in ('ssid', 'ap_scan', 'scan_ssid', 'key_mgmt', 'proto', 'wep_key0', 'psk', '#psk'):
+ if key not in ('ssid', 'scan_ssid', 'key_mgmt', 'proto', 'wep_key0', 'psk', '#psk'):
+ continue
+
+ elif key == 'ssid':
+ data[key] = value.strip('"')
+
+ else:
+ data[key] = value.strip()
+
+ wsconf["ssid"] = data.get("ssid", "INPUTSSID")
+ wsconf["hidden_ssid"] = data.get("scan_ssid") == '1' and True or False
+
+ key_mgmt = data.get("key_mgmt")
+ if key_mgmt == "NONE":
+ wep_key = data.get("wep_key0")
+
+ if wep_key is None:
+ wsconf["encrypt_mothod"] = "None"
+ else:
+ wsconf["encrypt_mothod"] = "wep"
+
+ if wep_key.startswith('"') and wep_key.endswith('"'):
+ wsconf["wep_keytype"] = "ascii"
+ wsconf["key"] = wep_key.strip('"')
+ else:
+ wsconf["wep_keytype"] = "hex"
+ wsconf["key"] = wep_key
+
+ elif key_mgmt == "WPA-PSK":
+ proto = data.get("proto")
+
+ if proto == "WPA":
+ wsconf["encrypt_mothod"] = "wpa"
+
+ elif proto == "RSN":
+ wsconf["encrypt_mothod"] = "wpa2"
+
+ elif proto in ( "WPA RSN", "WPA WPA2"):
+ wsconf["encrypt_mothod"] = "wpa/wpa2"
+
+ else:
+ wsconf["encrypt_mothod"] = "wpa2"
+
+ psk = data.get("#psk")
+ if psk:
+ wsconf["key"] = psk.strip('"')
+ else:
+ wsconf["key"] = data.get("psk")
+ else:
+ wsconf["encrypt_mothod"] = "wpa2"
+ except:
+ pass
+
+ if wsconf.get("ssid") is None:
+ wsconf["ssid"] = "INPUTSSID"
+ if wsconf.get("hidden_ssid") is None:
+ wsconf["hidden_ssid"] = False
+ if wsconf.get("encrypt_mothod") is None:
+ wsconf["encrypt_mothod"] = "wpa2"
+ if wsconf.get("wep_keytype") is None:
+ wsconf["wep_keytype"] = "ascii"
+ if wsconf.get("key") is None:
+ wsconf["key"] = "XXXXXXXX"
+
+# print ""
+# for (k,v) in wsconf.items():
+# print "[wsconf][%s] %s" % (k , v)
+
+ return wsconf
+
+ def displayIP(self, domain, entry):
+ text = entry.getText()
+ if text is not None and text != "0.0.0.0":
+ self[domain].setText(entry.getText())