WPA: minimize driver specific code for /etc/network/interfaces
[enigma2.git] / lib / python / Plugins / SystemPlugins / WirelessLan / plugin.py
old mode 100755 (executable)
new mode 100644 (file)
index 28ee363..efec340
@@ -1,4 +1,4 @@
-from enigma import eTimer, eTPM
+from enigma import eTimer, eTPM, eEnv
 from Screens.Screen import Screen
 from Components.ActionMap import ActionMap, NumberActionMap
 from Components.Pixmap import Pixmap,MultiPixmap
@@ -18,7 +18,7 @@ from Tools.HardwareInfo import HardwareInfo
 from Wlan import Wlan, wpaSupplicant, iStatus
 import sha
 
-plugin_path = "/usr/lib/enigma2/python/Plugins/SystemPlugins/WirelessLan"
+plugin_path = eEnv.resolve("${libdir}/enigma2/python/Plugins/SystemPlugins/WirelessLan")
 
 list = []
 list.append("WEP")
@@ -454,13 +454,12 @@ def configStrings(iface):
                driver = iNetwork.detectWlanModule(iface)
        else:
                driver = 'dreambox'
-       if driver  in ('ralink', 'zydas'):
-               return "        pre-up /usr/sbin/wpa_supplicant -i"+iface+" -c/etc/wpa_supplicant.conf -B -D"+driver+"\n        post-down wpa_cli terminate"
-       else:
-               if config.plugins.wlan.essid.value == "hidden...":
-                       return '        pre-up iwconfig '+iface+' essid "'+config.plugins.wlan.hiddenessid.value+'"\n   pre-up /usr/sbin/wpa_supplicant -i'+iface+' -c/etc/wpa_supplicant.conf -B -dd -D'+driver+'\n    post-down wpa_cli terminate'
-               else:
-                       return '        pre-up iwconfig '+iface+' essid "'+config.plugins.wlan.essid.value+'"\n pre-up /usr/sbin/wpa_supplicant -i'+iface+' -c/etc/wpa_supplicant.conf -B -dd -D'+driver+'\n    post-down wpa_cli terminate'
+       ret = ""
+       if driver == 'madwifi' and config.plugins.wlan.essid.value == "hidden...":
+               ret += "\tpre-up iwconfig " + iface + " essid \"" + config.plugins.wlan.hiddenessid.value + "\" || true\n"
+       ret += "\tpre-up wpa_supplicant -i" + iface + " -c/etc/wpa_supplicant.conf -B -dd -D" + driver + " || true\n"
+       ret += "\tpre-down wpa_cli -i" + iface + " terminate || true\n"
+       return ret
 
 def Plugins(**kwargs):
-       return PluginDescriptor(name=_("Wireless LAN"), description=_("Connect to a Wireless Network"), where = PluginDescriptor.WHERE_NETWORKSETUP, fnc={"ifaceSupported": callFunction, "configStrings": configStrings, "WlanPluginEntry": lambda x: "Wireless Network Configuartion..."})
+       return PluginDescriptor(name=_("Wireless LAN"), description=_("Connect to a Wireless Network"), where = PluginDescriptor.WHERE_NETWORKSETUP, needsRestart = False, fnc={"ifaceSupported": callFunction, "configStrings": configStrings, "WlanPluginEntry": lambda x: "Wireless Network Configuartion..."})