from Screens.MessageBox import MessageBox
from Components.Pixmap import Pixmap, MovingPixmap, MultiPixmap
from Components.Sources.Boolean import Boolean
-from Components.config import config, ConfigBoolean, configfile, ConfigYesNo, NoSave, ConfigSubsection, ConfigText, getConfigListEntry, ConfigSelection, ConfigPassword
from Components.Network import iNetwork
from Tools.Directories import resolveFilename, SCOPE_PLUGINS, SCOPE_SKIN_IMAGE
from enigma import eTimer
-
-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))
+from os import system
class NetworkWizard(WizardLanguage, Rc):
skin = """
</widget>
<widget name="HelpWindow" pixmap="skin_default/buttons/key_text.png" position="125,170" zPosition="1" size="1,1" transparent="1" alphatest="on" />
</screen>"""
- def __init__(self, session):
+ def __init__(self, session, interface = None):
self.xmlfile = resolveFilename(SCOPE_PLUGINS, "SystemPlugins/NetworkWizard/networkwizard.xml")
WizardLanguage.__init__(self, session, showSteps = False, showStepSlider = False)
Rc.__init__(self)
self.Adapterlist = None
self.InterfaceState = None
self.isInterfaceUp = None
- self.WlanPluginInstalled = None
+ self.WlanPluginInstalled = False
self.ap = None
- self.selectedInterface = None
+ self.w = None
+ if interface is not None:
+ self.selectedInterface = interface
+ else:
+ self.selectedInterface = None
self.NextStep = None
self.resetRef = None
self.checkRef = None
self.AdapterRef = None
self.APList = None
self.newAPlist = None
- self.WlanList = None
self.oldlist = None
- self.originalAth0State = None
- self.originalEth0State = None
- self.originalWlan0State = None
+
+ self.originalInterfaceState = {}
self.originalInterfaceStateChanged = False
self.Text = None
self.rescanTimer = eTimer()
self.close()
def markDone(self):
- self.rescanTimer.stop()
+ self.stopScan()
del self.rescanTimer
+ self.checkOldInterfaceState()
pass
- def getInstalledInterfaceCount(self):
+ def back(self):
+ self.stopScan()
+ self.ap = None
+ WizardLanguage.back(self)
+
+ def stopScan(self):
self.rescanTimer.stop()
+ if self.w is not None:
+ from Plugins.SystemPlugins.WirelessLan.Wlan import iWlan
+ iWlan.stopGetNetworkList()
+ self.w = None
+
+ def getInstalledInterfaceCount(self):
+ self.originalInterfaceState = {}
self.Adapterlist = iNetwork.getAdapterList()
self.InstalledInterfaceCount = len(self.Adapterlist)
- self.originalAth0State = iNetwork.getAdapterAttribute('ath0', 'up')
- self.originalEth0State = iNetwork.getAdapterAttribute('eth0', 'up')
- self.originalWlan0State = iNetwork.getAdapterAttribute('wlan0', 'up')
+ if self.Adapterlist is not None:
+ if self.InstalledInterfaceCount == 1 and self.selectedInterface is None:
+ self.selectedInterface = self.Adapterlist[0]
+ for interface in iNetwork.getAdapterList():
+ self.originalInterfaceState[interface] = {}
+ self.originalInterfaceState[interface]["up"] = iNetwork.getAdapterAttribute(interface, 'up')
+
+ def selectInterface(self):
+ self.InterfaceState = None
+ if self.selectedInterface is None:
+ if self.InstalledInterfaceCount <= 1:
+ if not iNetwork.isWirelessInterface(self.selectedInterface):
+ self.NextStep = 'nwconfig'
+ else:
+ self.NextStep = 'asknetworktype'
+ self.checkInterface(self.selectedInterface)
+ else:
+ self.NextStep = 'selectinterface'
+ self.currStep = self.getStepWithID(self.NextStep)
+ self.afterAsyncCode()
+ else:
+ if not iNetwork.isWirelessInterface(self.selectedInterface):
+ self.NextStep = 'nwconfig'
+ else:
+ self.NextStep = 'asknetworktype'
+ self.checkInterface(self.selectedInterface)
def checkOldInterfaceState(self):
# disable up interface if it was originally down and config is unchanged.
- if self.originalAth0State is False and self.originalInterfaceStateChanged is False:
- if iNetwork.checkforInterface('ath0') is True:
- iNetwork.deactivateInterface('ath0')
- if self.originalEth0State is False and self.originalInterfaceStateChanged is False:
- if iNetwork.checkforInterface('eth0') is True:
- iNetwork.deactivateInterface('eth0')
- if self.originalWlan0State is False and self.originalInterfaceStateChanged is False:
- if iNetwork.checkforInterface('wlan0') is True:
- iNetwork.deactivateInterface('wlan0')
+ if self.originalInterfaceStateChanged is False:
+ for interface in self.originalInterfaceState.keys():
+ if interface == self.selectedInterface:
+ if self.originalInterfaceState[interface]["up"] is False:
+ if iNetwork.checkforInterface(interface) is True:
+ system("ifconfig " + interface + " down")
def listInterfaces(self):
- self.rescanTimer.stop()
self.checkOldInterfaceState()
list = [(iNetwork.getFriendlyAdapterName(x),x) for x in iNetwork.getAdapterList()]
list.append((_("Exit network wizard"), "end"))
elif index == 'eth0':
self.NextStep = 'nwconfig'
else:
- self.NextStep = 'scanwlan'
+ self.NextStep = 'asknetworktype'
def InterfaceSelectionMoved(self):
self.InterfaceSelect(self.selection)
def checkInterface(self,iface):
- self.rescanTimer.stop()
+ self.stopScan()
if self.Adapterlist is None:
self.Adapterlist = iNetwork.getAdapterList()
if self.NextStep is not 'end':
#Reset Network to defaults if network broken
iNetwork.resetNetworkConfig('lan', self.resetNetworkConfigCB)
self.resetRef = self.session.openWithCallback(self.resetNetworkConfigFinished, MessageBox, _("Please wait while we prepare your network interfaces..."), type = MessageBox.TYPE_INFO, enable_input = False)
- if iface in ('eth0', 'wlan0', 'ath0'):
+ if iface in iNetwork.getInstalledAdapters():
if iface in iNetwork.configuredNetworkAdapters and len(iNetwork.configuredNetworkAdapters) == 1:
if iNetwork.getAdapterAttribute(iface, 'up') is True:
self.isInterfaceUp = True
def AdapterSetupEndCB(self,data):
if data is True:
- if self.selectedInterface in ('wlan0', 'ath0'):
+ if iNetwork.isWirelessInterface(self.selectedInterface):
if self.WlanPluginInstalled == True:
from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus
iStatus.getDataForInterface(self.selectedInterface,self.checkWlanStateCB)
if data is True:
if status is not None:
text1 = _("Your Dreambox is now ready to use.\n\nYour internet connection is working now.\n\n")
- text2 = _('Accesspoint:') + "\t" + status[self.selectedInterface]["acesspoint"] + "\n"
- text3 = _('SSID:') + "\t" + status[self.selectedInterface]["essid"] + "\n"
- text4 = _('Link Quality:') + "\t" + status[self.selectedInterface]["quality"]+"%" + "\n"
- text5 = _('Signal Strength:') + "\t" + status[self.selectedInterface]["signal"] + "\n"
- text6 = _('Bitrate:') + "\t" + status[self.selectedInterface]["bitrate"] + "\n"
- text7 = _('Encryption:') + " " + status[self.selectedInterface]["encryption"] + "\n"
+ text2 = _('Accesspoint:') + "\t" + str(status[self.selectedInterface]["accesspoint"]) + "\n"
+ text3 = _('SSID:') + "\t" + str(status[self.selectedInterface]["essid"]) + "\n"
+ text4 = _('Link Quality:') + "\t" + str(status[self.selectedInterface]["quality"])+ "\n"
+ text5 = _('Signal Strength:') + "\t" + str(status[self.selectedInterface]["signal"]) + "\n"
+ text6 = _('Bitrate:') + "\t" + str(status[self.selectedInterface]["bitrate"]) + "\n"
+ text7 = _('Encryption:') + " " + str(status[self.selectedInterface]["encryption"]) + "\n"
text8 = _("Please press OK to continue.")
infotext = text1 + text2 + text3 + text4 + text5 + text7 +"\n" + text8
self.currStep = self.getStepWithID("checkWlanstatusend")
self.Text = infotext
+ if str(status[self.selectedInterface]["accesspoint"]) == "Not-Associated":
+ self.InterfaceState = False
self.afterAsyncCode()
def checkNetwork(self):
def checkNetworkCB(self,data):
if data is True:
- if self.selectedInterface in ('wlan0', 'ath0'):
+ if iNetwork.isWirelessInterface(self.selectedInterface):
if self.WlanPluginInstalled == True:
from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus
iStatus.getDataForInterface(self.selectedInterface,self.checkWlanStateCB)
newList.append(oldentry)
for newentry in newList:
- if newentry[1] == "hidden...":
- continue
self.newAPlist.append(newentry)
-
- if len(self.newAPlist):
- if "hidden..." not in self.newAPlist:
- self.newAPlist.append(( _("enter hidden network SSID"), "hidden..." ))
+ if len(self.newAPlist):
if (self.wizard[self.currStep].has_key("dynamiclist")):
currentListEntry = self["list"].getCurrent()
- idx = 0
- for entry in self.newAPlist:
- if entry == currentListEntry:
- newListIndex = idx
- idx +=1
+ if currentListEntry is not None:
+ idx = 0
+ for entry in self.newAPlist:
+ if entry == currentListEntry:
+ newListIndex = idx
+ idx +=1
self.wizard[self.currStep]["evaluatedlist"] = self.newAPlist
self['list'].setList(self.newAPlist)
- self["list"].setIndex(newListIndex)
+ if newListIndex is not None:
+ self["list"].setIndex(newListIndex)
self["list"].updateList(self.newAPlist)
def listAccessPoints(self):
self.APList = []
- try:
- from Plugins.SystemPlugins.WirelessLan.Wlan import Wlan
- except ImportError:
- self.APList.append( ( _("No networks found"),_("unavailable") ) )
- return self.APList
- else:
- self.w = Wlan(self.selectedInterface)
- aps = self.w.getNetworkList()
+ if self.WlanPluginInstalled is False:
+ self.APList.append( ( _("No networks found"), None ) )
+ else:
+ from Plugins.SystemPlugins.WirelessLan.Wlan import iWlan
+ iWlan.setInterface(self.selectedInterface)
+ self.w = iWlan.getInterface()
+ aps = iWlan.getNetworkList()
if aps is not None:
print "[NetworkWizard.py] got Accespoints!"
tmplist = []
complist.remove(compentry)
for entry in complist:
self.APList.append( (entry[1], entry[1]) )
+ if not len(aps):
+ self.APList.append( ( _("No networks found"), None ) )
+
+ self.rescanTimer.start(4000)
+ return self.APList
- if "hidden..." not in self.APList:
- self.APList.append(( _("enter hidden network SSID"), "hidden..." ))
-
- self.rescanTimer.start(3000)
- return self.APList
-
- def AccessPointsSelectionMade(self, index):
- self.ap = index
- self.WlanList = []
- currList = []
- if (self.wizard[self.currStep].has_key("dynamiclist")):
- currList = self['list'].list
- for entry in currList:
- self.WlanList.append( (entry[1], entry[0]) )
- self.AccessPointsSelect(index)
-
- def AccessPointsSelect(self, index):
- self.NextStep = 'wlanconfig'
def AccessPointsSelectionMoved(self):
- self.AccessPointsSelect(self.selection)
+ self.ap = self.selection
+ self.NextStep = 'wlanconfig'
def checkWlanSelection(self):
- self.rescanTimer.stop()
+ self.stopScan()
self.currStep = self.getStepWithID(self.NextStep)
def isWlanPluginInstalled(self):
try:
- from Plugins.SystemPlugins.WirelessLan.Wlan import Wlan
+ from Plugins.SystemPlugins.WirelessLan.Wlan import iWlan
except ImportError:
self.WlanPluginInstalled = False
else:
self.WlanPluginInstalled = True
+ def listChoices(self):
+ self.stopScan()
+ list = []
+ if self.WlanPluginInstalled == True:
+ list.append((_("Configure your wireless LAN again"), "scanwlan"))
+ list.append((_("Configure your internal LAN"), "nwconfig"))
+ list.append((_("Exit network wizard"), "end"))
+ return list
+
+ def ChoicesSelectionMade(self, index):
+ self.ChoicesSelect(index)
+
+ def ChoicesSelect(self, index):
+ if index == 'end':
+ self.NextStep = 'end'
+ elif index == 'nwconfig':
+ self.selectedInterface = "eth0"
+ self.NextStep = 'nwconfig'
+ else:
+ self.NextStep = 'asknetworktype'
+
+ def ChoicesSelectionMoved(self):
+ pass