1 from Screens.Wizard import wizardManager, WizardSummary
2 from Screens.WizardLanguage import WizardLanguage
3 from Components.Pixmap import Pixmap, MovingPixmap
4 from Components.config import config, ConfigBoolean, configfile, ConfigYesNo, NoSave, ConfigSubsection, ConfigText, getConfigListEntry, ConfigSelection
5 from Components.Network import iNetwork
6 from Components.Label import Label
7 from Components.MenuList import MenuList
8 from Components.PluginComponent import plugins
9 from Plugins.Plugin import PluginDescriptor
10 from Plugins.SystemPlugins.WirelessLan.plugin import *
11 from Plugins.SystemPlugins.WirelessLan.Wlan import Wlan, WlanList, wpaSupplicant
12 from Tools.Directories import resolveFilename, SCOPE_PLUGINS, SCOPE_SKIN_IMAGE
15 config.misc.firstrun = ConfigBoolean(default = True)
19 list.append(_("WPA2"))
21 config.plugins.wlan = ConfigSubsection()
22 config.plugins.wlan.essid = NoSave(ConfigText(default = "home", fixed_size = False))
24 config.plugins.wlan.encryption = ConfigSubsection()
25 config.plugins.wlan.encryption.enabled = NoSave(ConfigYesNo(default = False))
26 config.plugins.wlan.encryption.type = NoSave(ConfigSelection(list, default = _("WPA")))
27 config.plugins.wlan.encryption.psk = NoSave(ConfigText(default = "mysecurewlan", fixed_size = False))
29 class NetworkWizard(WizardLanguage):
31 <screen position="0,0" size="720,576" title="Welcome..." flags="wfNoBorder" >
32 <widget name="text" position="153,50" size="340,300" font="Regular;22" />
33 <widget source="list" render="Listbox" position="53,310" size="440,220" scrollbarMode="showOnDemand" >
34 <convert type="StringList" />
36 <widget name="config" position="53,310" zPosition="1" size="440,220" transparent="1" scrollbarMode="showOnDemand" />
37 <widget name="wizard" pixmap="skin_default/wizard.png" position="40,50" zPosition="10" size="110,174" transparent="1" alphatest="on"/>
38 <ePixmap pixmap="skin_default/buttons/button_red.png" position="40,225" zPosition="0" size="15,16" transparent="1" alphatest="on" />
39 <widget name="languagetext" position="55,225" size="95,30" font="Regular;18" />
40 <widget name="rc" pixmap="skin_default/rc.png" position="500,600" zPosition="10" size="154,475" transparent="1" alphatest="on"/>
41 <widget name="arrowdown" pixmap="skin_default/arrowdown.png" position="0,0" zPosition="11" size="37,70" transparent="1" alphatest="on"/>
42 <widget name="arrowup" pixmap="skin_default/arrowup.png" position="-100,-100" zPosition="11" size="37,70" transparent="1" alphatest="on"/>
43 <widget name="arrowup2" pixmap="skin_default/arrowup.png" position="-100,-100" zPosition="11" size="37,70" transparent="1" alphatest="on"/>
44 <widget name="arrowup3" pixmap="skin_default/arrowup.png" position="-100,-100" zPosition="11" size="37,70" transparent="1" alphatest="on"/>
46 def __init__(self, session):
47 self.xmlfile = resolveFilename(SCOPE_PLUGINS, "SystemPlugins/NetworkWizard/networkwizard.xml")
49 WizardLanguage.__init__(self, session, showSteps = False, showStepSlider = False)
50 self.session = session
51 self["wizard"] = Pixmap()
52 self["rc"] = MovingPixmap()
53 self["arrowdown"] = MovingPixmap()
54 self["arrowup"] = MovingPixmap()
55 self["arrowup2"] = MovingPixmap()
56 self["arrowup3"] = MovingPixmap()
58 self.InterfaceState = None
59 self.isInterfaceUp = None
62 def checkInterface(self,iface):
63 self.Adapterlist = iNetwork.getAdapterList()
64 if len(self.Adapterlist) == 0:
65 #Reset Network to defaults if network broken
66 iNetwork.resetNetworkConfig('lan')
68 iNetwork.resetNetworkConfig('lan')
69 self.InterfaceUp('eth0')
71 iNetwork.resetNetworkConfig('wlan')
72 self.InterfaceUp('wlan0')
74 def InterfaceUp(self,iface):
75 iNetwork.getInterfaces()
76 if iNetwork.getAdapterAttribute(iface, 'up') is True:
77 self.isInterfaceUp = True
79 self.isInterfaceUp = False
85 self.w = Wlan('wlan0')
86 aps = self.w.getNetworkList()
89 print "[Wlan.py] got Accespoints!"
94 a['essid'] = a['bssid']
95 list.append( (a['essid'], a['essid']) )
96 list.sort(key = lambda x: x[0])
100 def modeSelectionMade(self, index):
101 print "modeSelectionMade:", index
103 self.modeSelect(index)
105 def modeSelectionMoved(self):
106 print "mode selection moved:", self.selection
107 self.modeSelect(self.selection)
109 def modeSelect(self, mode):
110 print "ModeSelected:", mode
112 def saveAccessPoint(self, mode):
113 config.plugins.wlan.essid.value = str(mode)
114 config.plugins.wlan.essid.save()
115 config.plugins.wlan.encryption.enabled.value = False
116 config.plugins.wlan.encryption.enabled.save()
118 def checkNetwork(self):
119 ret = iNetwork.checkNetworkState()
121 self.InterfaceState = True
123 self.InterfaceState = False
125 def restartNetwork(self):
126 iNetwork.restartNetwork()