diff options
| author | acid-burn <acidburn@opendreambox.org> | 2009-11-06 08:49:12 +0100 |
|---|---|---|
| committer | acid-burn <acidburn@opendreambox.org> | 2009-11-06 08:49:12 +0100 |
| commit | 3b50bda73c2dbc9038376a0d70d47343589f7fea (patch) | |
| tree | 3e25e46964597b3fa4563b50a57236ef42e2c4bf /lib/python/Plugins/SystemPlugins/NetworkWizard | |
| parent | aaeba87c8ee1b528dc9660dab9c6980155e878d4 (diff) | |
| download | enigma2-3b50bda73c2dbc9038376a0d70d47343589f7fea.tar.gz enigma2-3b50bda73c2dbc9038376a0d70d47343589f7fea.zip | |
Enigma2-SystemPlugins: -move NetworkWizard and WirelessLan Plugins into Enigma2 git repo. This fixes bug #140
Diffstat (limited to 'lib/python/Plugins/SystemPlugins/NetworkWizard')
8 files changed, 490 insertions, 0 deletions
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 = """ + <screen position="0,0" size="720,576" title="Welcome..." flags="wfNoBorder" > + <widget name="text" position="153,40" size="340,330" font="Regular;22" /> + <widget source="list" render="Listbox" position="53,340" size="440,180" scrollbarMode="showOnDemand" > + <convert type="StringList" /> + </widget> + <widget name="config" position="53,340" zPosition="1" size="440,180" transparent="1" scrollbarMode="showOnDemand" /> + <ePixmap pixmap="skin_default/buttons/button_red.png" position="40,225" zPosition="0" size="15,16" transparent="1" alphatest="on" /> + <widget name="languagetext" position="55,225" size="95,30" font="Regular;18" /> + <widget name="wizard" pixmap="skin_default/wizard.png" position="40,50" zPosition="10" size="110,174" alphatest="on" /> + <widget name="rc" pixmaps="skin_default/rc.png,skin_default/rcold.png" position="500,50" zPosition="10" size="154,500" alphatest="on" /> + <widget name="arrowdown" pixmap="skin_default/arrowdown.png" position="-100,-100" zPosition="11" size="37,70" alphatest="on" /> + <widget name="arrowdown2" pixmap="skin_default/arrowdown.png" position="-100,-100" zPosition="11" size="37,70" alphatest="on" /> + <widget name="arrowup" pixmap="skin_default/arrowup.png" position="-100,-100" zPosition="11" size="37,70" alphatest="on" /> + <widget name="arrowup2" pixmap="skin_default/arrowup.png" position="-100,-100" zPosition="11" size="37,70" alphatest="on" /> + </screen>""" + 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 --- /dev/null +++ b/lib/python/Plugins/SystemPlugins/NetworkWizard/__init__.py 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 @@ +<default> + <prerequisites> + <tag type="System" /> + </prerequisites> + <info language="en"> + <author>Dream Multimedia</author> + <name>NetworkWizard</name> + <packagename>enigma2-plugin-systemplugins-networkwizard</packagename> + <shortdescription>Step by step network configuration</shortdescription> + <description>With the NetworkWizard you can easy configure your network step by step. + </description> + </info> + <info language="de"> + <author>Dream Multimedia</author> + <name>NetzwerkWizard</name> + <packagename>enigma2-plugin-systemplugins-networkwizard</packagename> + <shortdescription>Schritt für Schritt Netzwerk konfiguration</shortdescription> + <description>Mit dem NetzwerkWizard können Sie Ihr Netzwerk konfigurieren. Sie werden Schritt + für Schritt durch die Konfiguration geleitet. + </description> + </info> + <files type="package"> <!-- without version, without .ipk --> + <file type="package" name="enigma2-plugin-systemplugins-networkwizard" /> + </files> +</default> 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 @@ +<wizard> + <step id="welcome" nextstep="selectinterface"> + <text value="Welcome.\n\nIf you want to connect your Dreambox to the Internet, this wizard will guide you through the basic network setup of your Dreambox.\n\nPress OK to start configuring your network" /> + <displaytext value="Network Wizard" /> + <code> +self.clearSelectedKeys() +self.selectKey("OK") + </code> + </step> + + <step id="selectinterface"> + <text value="Please select the network interface that you want to use for your internet connection.\n\nPlease press OK to continue." /> + <displaytext value="Select interface" /> + <list type="dynamic" source="listInterfaces" evaluation="InterfaceSelectionMade" onselect="InterfaceSelectionMoved" /> + <code> +self.clearSelectedKeys() +self.selectKey("OK") +self.selectKey("UP") +self.selectKey("DOWN") + </code> + <code pos="after" async="yes"> +self.checkInterface(self.selectedInterface) + </code> + </step> + + <step id="nwconfig"> + <text value="Please configure your internet connection by filling out the required values.\nWhen you are ready press OK to continue." /> + <displaytext value="Configure interface" /> + <config screen="AdapterSetup" module="NetworkSetup" args="self.selectedInterface" type="ConfigList" /> + <code> +self.clearSelectedKeys() +self.selectKey("OK") +self.selectKey("UP") +self.selectKey("DOWN") +self.selectKey("LEFT") +self.selectKey("RIGHT") + </code> + <code pos="after" async="yes"> +self.AdapterSetupEnd(self.selectedInterface) + </code> + </step> + + <step id="confdns" nextstep="checklanstatusend"> + <text value="Please configure or verify your Nameservers by filling out the required values.\nWhen you are ready press OK to continue." /> + <displaytext value="Configure nameservers" /> + <config screen="NameserverSetup" module="NetworkSetup" type="ConfigList" /> + <code> +self.clearSelectedKeys() +self.selectKey("OK") + </code> + <code pos="after" async="yes"> +self.checkNetwork() + </code> + </step> + + <step id="checklanstatusend" nextstep="end"> + <condition> +self.condition = (self.InterfaceState == True ) + </condition> + <text value="Your Dreambox is now ready to use.\n\nYour internet connection is working now.\n\nPlease press OK to continue." /> + <displaytext value="Please follow the instructions on the TV" /> + <code> +self.clearSelectedKeys() +self.selectKey("OK") + </code> + <code pos="after"> +currStep = self.numSteps +self.wizard[currStep]["nextstep"] = None +self.markDone() +self.close() + </code> + </step> + + <step id="checklanstatusend"> + <condition> +self.condition = (self.InterfaceState == False ) + </condition> + <text value="Your internet connection is not working!\nPlease choose what you want to do next." /> + <displaytext value="Please follow the instructions on the TV" /> + <code> +self.clearSelectedKeys() +self.selectKey("OK") +self.selectKey("UP") +self.selectKey("DOWN") + </code> + <list> + <listentry caption="Configure your network again" step="selectinterface" /> + <listentry caption="Exit network wizard" step="end" /> + </list> + </step> + + <step id="scanwlan" nextstep="wlanconfig"> + <condition> +self.condition = (self.isInterfaceUp == True and self.WlanPluginInstalled == True) + </condition> + <text value="Please select the wireless network that you want to connect to.\n\nPlease press OK to continue." /> + <displaytext value="Select wireless network" /> + <list type="dynamic" source="listModes" evaluation="modeSelectionMade" onselect="modeSelectionMoved" /> + <code> +self.clearSelectedKeys() +self.selectKey("OK") +self.selectKey("UP") +self.selectKey("DOWN") +self.selectKey("LEFT") +self.selectKey("RIGHT") + </code> + </step> + + <step id="scanwlan"> + <condition> +self.condition = (self.isInterfaceUp == False and self.WlanPluginInstalled == True) + </condition> + <text value="Your wireless LAN internet connection could not be started!\nHave you attached your USB WLAN Stick?\n\nPlease choose what you want to do next." /> + <displaytext value="Please follow the instructions on the TV" /> + <list> + <listentry caption="Configure your wireless LAN again" step="scanwlan" /> + <listentry caption="Configure your internal LAN" step="selectinterface" /> + <listentry caption="Exit network wizard" step="end" /> + </list> + <code> +self.clearSelectedKeys() +self.selectKey("OK") +self.selectKey("UP") +self.selectKey("DOWN") + </code> + </step> + + <step id="scanwlan"> + <condition> +self.condition = (self.isInterfaceUp == True and self.WlanPluginInstalled == False) + </condition> + <text value="The wireless LAN plugin is not installed!\nPlease install it and choose what you want to do next." /> + <displaytext value="Please follow the instructions on the TV" /> + <list> + <listentry caption="Configure your internal LAN" step="selectinterface" /> + <listentry caption="Exit network wizard" step="end" /> + </list> + <code> +self.clearSelectedKeys() +self.selectKey("OK") +self.selectKey("UP") +self.selectKey("DOWN") + </code> + </step> + + <step id="wlanconfig"> + <text value="Please configure your internet connection by filling out the required values.\nWhen you are ready press OK to continue." /> + <displaytext value="Configure interface" /> + <config screen="AdapterSetup" module="NetworkSetup" args="(self.selectedInterface,self.ap,self.WlanList)" type="ConfigList" /> + <code> +self.clearSelectedKeys() +self.selectKey("OK") +self.selectKey("UP") +self.selectKey("DOWN") +self.selectKey("LEFT") +self.selectKey("RIGHT") + </code> + <code pos="after" async="yes"> +self.AdapterSetupEnd(self.selectedInterface) + </code> + </step> + + <step id="end"> + <text value="Thank you for using the wizard.\nPlease press OK to continue." /> + <code> +self.clearSelectedKeys() +self.selectKey("OK") + </code> + </step> +</wizard> + + 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 |
