From 3b50bda73c2dbc9038376a0d70d47343589f7fea Mon Sep 17 00:00:00 2001 From: acid-burn Date: Fri, 6 Nov 2009 08:49:12 +0100 Subject: Enigma2-SystemPlugins: -move NetworkWizard and WirelessLan Plugins into Enigma2 git repo. This fixes bug #140 --- .../Plugins/SystemPlugins/NetworkWizard/LICENSE | 12 + .../SystemPlugins/NetworkWizard/Makefile.am | 12 + .../SystemPlugins/NetworkWizard/NetworkWizard.py | 244 +++++++++++++++++++++ .../SystemPlugins/NetworkWizard/__init__.py | 0 .../SystemPlugins/NetworkWizard/meta/Makefile.am | 3 + .../NetworkWizard/meta/plugin_networkwizard.xml | 25 +++ .../SystemPlugins/NetworkWizard/networkwizard.xml | 172 +++++++++++++++ .../Plugins/SystemPlugins/NetworkWizard/plugin.py | 22 ++ 8 files changed, 490 insertions(+) create mode 100755 lib/python/Plugins/SystemPlugins/NetworkWizard/LICENSE create mode 100755 lib/python/Plugins/SystemPlugins/NetworkWizard/Makefile.am create mode 100755 lib/python/Plugins/SystemPlugins/NetworkWizard/NetworkWizard.py create mode 100755 lib/python/Plugins/SystemPlugins/NetworkWizard/__init__.py create mode 100755 lib/python/Plugins/SystemPlugins/NetworkWizard/meta/Makefile.am create mode 100755 lib/python/Plugins/SystemPlugins/NetworkWizard/meta/plugin_networkwizard.xml create mode 100755 lib/python/Plugins/SystemPlugins/NetworkWizard/networkwizard.xml create mode 100755 lib/python/Plugins/SystemPlugins/NetworkWizard/plugin.py (limited to 'lib/python/Plugins/SystemPlugins/NetworkWizard') diff --git a/lib/python/Plugins/SystemPlugins/NetworkWizard/LICENSE b/lib/python/Plugins/SystemPlugins/NetworkWizard/LICENSE new file mode 100755 index 00000000..99700593 --- /dev/null +++ b/lib/python/Plugins/SystemPlugins/NetworkWizard/LICENSE @@ -0,0 +1,12 @@ +This plugin is licensed under the Creative Commons +Attribution-NonCommercial-ShareAlike 3.0 Unported +License. To view a copy of this license, visit +http://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter to Creative +Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA. + +Alternatively, this plugin may be distributed and executed on hardware which +is licensed by Dream Multimedia GmbH. + +This plugin is NOT free software. It is open source, you are allowed to +modify it (if you keep the license), but it may not be commercially +distributed other than under the conditions noted above. diff --git a/lib/python/Plugins/SystemPlugins/NetworkWizard/Makefile.am b/lib/python/Plugins/SystemPlugins/NetworkWizard/Makefile.am new file mode 100755 index 00000000..2a71bb2d --- /dev/null +++ b/lib/python/Plugins/SystemPlugins/NetworkWizard/Makefile.am @@ -0,0 +1,12 @@ +installdir = $(pkglibdir)/python/Plugins/SystemPlugins/NetworkWizard + +SUBDIRS = meta + +install_PYTHON = \ + __init__.py \ + NetworkWizard.py \ + plugin.py + +dist_install_DATA = \ + LICENSE \ + networkwizard.xml \ No newline at end of file diff --git a/lib/python/Plugins/SystemPlugins/NetworkWizard/NetworkWizard.py b/lib/python/Plugins/SystemPlugins/NetworkWizard/NetworkWizard.py new file mode 100755 index 00000000..4d361157 --- /dev/null +++ b/lib/python/Plugins/SystemPlugins/NetworkWizard/NetworkWizard.py @@ -0,0 +1,244 @@ +from Screens.Wizard import wizardManager, WizardSummary +from Screens.WizardLanguage import WizardLanguage +from Screens.Rc import Rc +from Screens.MessageBox import MessageBox + +from Components.Pixmap import Pixmap, MovingPixmap, MultiPixmap +from Components.config import config, ConfigBoolean, configfile, ConfigYesNo, NoSave, ConfigSubsection, ConfigText, getConfigListEntry, ConfigSelection, ConfigPassword +from Components.Network import iNetwork + +#from Components.Label import Label +#from Components.MenuList import MenuList +#from Components.PluginComponent import plugins +#from Plugins.Plugin import PluginDescriptor +from Tools.Directories import resolveFilename, SCOPE_PLUGINS, SCOPE_SKIN_IMAGE +#import time, os, re + + +config.misc.firstrun = ConfigBoolean(default = True) +list = [] +list.append("WEP") +list.append("WPA") +list.append("WPA2") +list.append("WPA/WPA2") + +weplist = [] +weplist.append("ASCII") +weplist.append("HEX") + +config.plugins.wlan = ConfigSubsection() +config.plugins.wlan.essid = NoSave(ConfigText(default = "home", fixed_size = False)) +config.plugins.wlan.hiddenessid = NoSave(ConfigText(default = "home", fixed_size = False)) + +config.plugins.wlan.encryption = ConfigSubsection() +config.plugins.wlan.encryption.enabled = NoSave(ConfigYesNo(default = False)) +config.plugins.wlan.encryption.type = NoSave(ConfigSelection(list, default = "WPA/WPA2" )) +config.plugins.wlan.encryption.wepkeytype = NoSave(ConfigSelection(weplist, default = "ASCII")) +config.plugins.wlan.encryption.psk = NoSave(ConfigPassword(default = "mysecurewlan", fixed_size = False)) + +class NetworkWizard(WizardLanguage, Rc): + skin = """ + + + + + + + + + + + + + + + """ + def __init__(self, session): + self.xmlfile = resolveFilename(SCOPE_PLUGINS, "SystemPlugins/NetworkWizard/networkwizard.xml") + WizardLanguage.__init__(self, session, showSteps = False, showStepSlider = False) + Rc.__init__(self) + self.session = session + self["wizard"] = Pixmap() + + self.InterfaceState = None + self.isInterfaceUp = None + self.WlanPluginInstalled = None + self.ap = None + self.selectedInterface = None + self.NextStep = None + self.myref = None + self.checkRef = None + self.AdapterRef = None + self.WlanList = None + self.isWlanPluginInstalled() + + def listInterfaces(self): + list = [(iNetwork.getFriendlyAdapterName(x),x) for x in iNetwork.getAdapterList()] + list.append((_("Exit network wizard"), "end")) + return list + + def InterfaceSelectionMade(self, index): + self.selectedInterface = index + self.InterfaceSelect(index) + + def InterfaceSelect(self, index): + if index == 'end': + self.NextStep = 'end' + elif index == 'eth0': + self.NextStep = 'nwconfig' + else: + self.NextStep = 'scanwlan' + + def InterfaceSelectionMoved(self): + self.InterfaceSelect(self.selection) + + def checkInterface(self,iface): + self.Adapterlist = iNetwork.getAdapterList() + if self.NextStep is not 'end': + if len(self.Adapterlist) == 0: + #Reset Network to defaults if network broken + iNetwork.resetNetworkConfig('lan', self.checkInterfaceCB) + self.myref = self.session.openWithCallback(self.resetfinishedCB, MessageBox, _("Please wait while we prepare your network interfaces..."), type = MessageBox.TYPE_INFO, enable_input = False) + if iface == 'eth0': + if iface in iNetwork.configuredNetworkAdapters and len(iNetwork.configuredNetworkAdapters) == 1: + if iNetwork.getAdapterAttribute(iface, 'up') is True: + self.isInterfaceUp = True + else: + self.isInterfaceUp = False + self.resetfinishedCB(False) + else: + iNetwork.resetNetworkConfig('lan',self.checkInterfaceCB) + self.myref = self.session.openWithCallback(self.resetfinishedCB, MessageBox, _("Please wait while we prepare your network interfaces..."), type = MessageBox.TYPE_INFO, enable_input = False) + elif iface == 'wlan0': + if iface in iNetwork.configuredNetworkAdapters and len(iNetwork.configuredNetworkAdapters) == 1: + if iNetwork.getAdapterAttribute(iface, 'up') is True: + self.isInterfaceUp = True + else: + self.isInterfaceUp = False + self.resetfinishedCB(False) + else: + iNetwork.resetNetworkConfig('wlan',self.checkInterfaceCB) + self.myref = self.session.openWithCallback(self.resetfinishedCB, MessageBox, _("Please wait while we prepare your network interfaces..."), type = MessageBox.TYPE_INFO, enable_input = False) + elif iface == 'ath0': + if iface in iNetwork.configuredNetworkAdapters and len(iNetwork.configuredNetworkAdapters) == 1: + if iNetwork.getAdapterAttribute(iface, 'up') is True: + self.isInterfaceUp = True + else: + self.isInterfaceUp = False + self.resetfinishedCB(False) + else: + iNetwork.resetNetworkConfig('wlan-mpci',self.checkInterfaceCB) + self.myref = self.session.openWithCallback(self.resetfinishedCB, MessageBox, _("Please wait while we prepare your network interfaces..."), type = MessageBox.TYPE_INFO, enable_input = False) + else: + self.resetfinishedCB(False) + + def resetfinishedCB(self,data): + if data is True: + self.currStep = self.getStepWithID(self.NextStep) + self.afterAsyncCode() + else: + self.currStep = self.getStepWithID(self.NextStep) + self.afterAsyncCode() + + def checkInterfaceCB(self,callback,iface): + if callback is not None: + if callback is True: + iNetwork.getInterfaces(self.getInterfacesDataAvail) + + + def getInterfacesDataAvail(self, data): + if data is True: + if iNetwork.getAdapterAttribute(self.selectedInterface, 'up') is True: + self.isInterfaceUp = True + else: + self.isInterfaceUp = False + self.myref.close(True) + + def AdapterSetupEnd(self, iface): + if iNetwork.getAdapterAttribute(iface, "dhcp") is True: + iNetwork.checkNetworkState(self.AdapterSetupEndFinished) + self.AdapterRef = self.session.openWithCallback(self.AdapterSetupEndCB, MessageBox, _("Please wait while we test your network..."), type = MessageBox.TYPE_INFO, enable_input = False) + + else: + self.currStep = self.getStepWithID("confdns") + self.afterAsyncCode() + + def AdapterSetupEndCB(self,data): + if data is True: + self.currStep = self.getStepWithID("checklanstatusend") + self.afterAsyncCode() + + def AdapterSetupEndFinished(self,data): + if data <= 2: + self.InterfaceState = True + else: + self.InterfaceState = False + self.AdapterRef.close(True) + + def checkNetwork(self): + iNetwork.checkNetworkState(self.checkNetworkStateFinished) + self.checkRef = self.session.openWithCallback(self.checkNetworkCB, MessageBox, _("Please wait while we test your network..."), type = MessageBox.TYPE_INFO, enable_input = False) + + def checkNetworkCB(self,data): + if data is True: + self.currStep = self.getStepWithID("checklanstatusend") + self.afterAsyncCode() + + def checkNetworkStateFinished(self,data): + if data <= 2: + self.InterfaceState = True + else: + self.InterfaceState = False + self.checkRef.close(True) + + def markDone(self): + pass + + def listModes(self): + list = [] + self.WlanList = [] + try: + from Plugins.SystemPlugins.WirelessLan.Wlan import Wlan + except ImportError: + list.append( ( _("No networks found"),_("unavailable") ) ) + self.WlanList.append(_("No networks found")) + return list + else: + self.w = Wlan(self.selectedInterface) + aps = self.w.getNetworkList() + if aps is not None: + print "[NetworkWizard.py] got Accespoints!" + for ap in aps: + a = aps[ap] + if a['active']: + if a['essid'] != "": + #a['essid'] = a['bssid'] + list.append( (a['essid'], a['essid']) ) + self.WlanList.append(a['essid']) + if "hidden..." not in list: + list.append( ( _("enter hidden network SSID"),_("hidden...") ) ) + self.WlanList.append(_("hidden...")) + return list + + def modeSelectionMade(self, index): + self.modeSelect(index) + + def modeSelectionMoved(self): + self.modeSelect(self.selection) + + def modeSelect(self, mode): + self.ap = mode + print "ModeSelected:", mode + + def restartNetwork(self): + iNetwork.restartNetwork() + self.checkNetwork() + + def isWlanPluginInstalled(self): + try: + from Plugins.SystemPlugins.WirelessLan.Wlan import Wlan + except ImportError: + self.WlanPluginInstalled = False + else: + self.WlanPluginInstalled = True + diff --git a/lib/python/Plugins/SystemPlugins/NetworkWizard/__init__.py b/lib/python/Plugins/SystemPlugins/NetworkWizard/__init__.py new file mode 100755 index 00000000..e69de29b diff --git a/lib/python/Plugins/SystemPlugins/NetworkWizard/meta/Makefile.am b/lib/python/Plugins/SystemPlugins/NetworkWizard/meta/Makefile.am new file mode 100755 index 00000000..98dbe80b --- /dev/null +++ b/lib/python/Plugins/SystemPlugins/NetworkWizard/meta/Makefile.am @@ -0,0 +1,3 @@ +installdir = $(datadir)/meta/ + +dist_install_DATA = plugin_networkwizard.xml diff --git a/lib/python/Plugins/SystemPlugins/NetworkWizard/meta/plugin_networkwizard.xml b/lib/python/Plugins/SystemPlugins/NetworkWizard/meta/plugin_networkwizard.xml new file mode 100755 index 00000000..660bbcd2 --- /dev/null +++ b/lib/python/Plugins/SystemPlugins/NetworkWizard/meta/plugin_networkwizard.xml @@ -0,0 +1,25 @@ + + + + + + Dream Multimedia + NetworkWizard + enigma2-plugin-systemplugins-networkwizard + Step by step network configuration + With the NetworkWizard you can easy configure your network step by step. + + + + Dream Multimedia + NetzwerkWizard + enigma2-plugin-systemplugins-networkwizard + Schritt für Schritt Netzwerk konfiguration + Mit dem NetzwerkWizard können Sie Ihr Netzwerk konfigurieren. Sie werden Schritt + für Schritt durch die Konfiguration geleitet. + + + + + + diff --git a/lib/python/Plugins/SystemPlugins/NetworkWizard/networkwizard.xml b/lib/python/Plugins/SystemPlugins/NetworkWizard/networkwizard.xml new file mode 100755 index 00000000..134797a7 --- /dev/null +++ b/lib/python/Plugins/SystemPlugins/NetworkWizard/networkwizard.xml @@ -0,0 +1,172 @@ + + + + + +self.clearSelectedKeys() +self.selectKey("OK") + + + + + + + + +self.clearSelectedKeys() +self.selectKey("OK") +self.selectKey("UP") +self.selectKey("DOWN") + + +self.checkInterface(self.selectedInterface) + + + + + + + + +self.clearSelectedKeys() +self.selectKey("OK") +self.selectKey("UP") +self.selectKey("DOWN") +self.selectKey("LEFT") +self.selectKey("RIGHT") + + +self.AdapterSetupEnd(self.selectedInterface) + + + + + + + + +self.clearSelectedKeys() +self.selectKey("OK") + + +self.checkNetwork() + + + + + +self.condition = (self.InterfaceState == True ) + + + + +self.clearSelectedKeys() +self.selectKey("OK") + + +currStep = self.numSteps +self.wizard[currStep]["nextstep"] = None +self.markDone() +self.close() + + + + + +self.condition = (self.InterfaceState == False ) + + + + +self.clearSelectedKeys() +self.selectKey("OK") +self.selectKey("UP") +self.selectKey("DOWN") + + + + + + + + + +self.condition = (self.isInterfaceUp == True and self.WlanPluginInstalled == True) + + + + + +self.clearSelectedKeys() +self.selectKey("OK") +self.selectKey("UP") +self.selectKey("DOWN") +self.selectKey("LEFT") +self.selectKey("RIGHT") + + + + + +self.condition = (self.isInterfaceUp == False and self.WlanPluginInstalled == True) + + + + + + + + + +self.clearSelectedKeys() +self.selectKey("OK") +self.selectKey("UP") +self.selectKey("DOWN") + + + + + +self.condition = (self.isInterfaceUp == True and self.WlanPluginInstalled == False) + + + + + + + + +self.clearSelectedKeys() +self.selectKey("OK") +self.selectKey("UP") +self.selectKey("DOWN") + + + + + + + + +self.clearSelectedKeys() +self.selectKey("OK") +self.selectKey("UP") +self.selectKey("DOWN") +self.selectKey("LEFT") +self.selectKey("RIGHT") + + +self.AdapterSetupEnd(self.selectedInterface) + + + + + + +self.clearSelectedKeys() +self.selectKey("OK") + + + + + diff --git a/lib/python/Plugins/SystemPlugins/NetworkWizard/plugin.py b/lib/python/Plugins/SystemPlugins/NetworkWizard/plugin.py new file mode 100755 index 00000000..dc3becac --- /dev/null +++ b/lib/python/Plugins/SystemPlugins/NetworkWizard/plugin.py @@ -0,0 +1,22 @@ +from Screens.Screen import Screen +from Plugins.Plugin import PluginDescriptor +from Components.config import getConfigListEntry, config + +def NetworkWizardMain(session, **kwargs): + session.open(NetworkWizard) + +def startSetup(menuid): + if menuid != "system": + return [ ] + + return [(_("Network Wizard") + "...", NetworkWizardMain, "nw_wizard", 40)] + +def NetworkWizard(*args, **kwargs): + from NetworkWizard import NetworkWizard + return NetworkWizard(*args, **kwargs) + +def Plugins(**kwargs): + list = [] + if config.misc.firstrun.value: + list.append(PluginDescriptor(name=_("Network Wizard"), where = PluginDescriptor.WHERE_WIZARD, fnc=(25, NetworkWizard))) + return list -- cgit v1.2.3