1 # for localized messages
4 from Screens.Wizard import wizardManager, WizardSummary
5 from Screens.MessageBox import MessageBox
6 from Components.Pixmap import Pixmap, MovingPixmap, MultiPixmap
7 from Components.config import config, ConfigBoolean, configfile, ConfigYesNo, NoSave, ConfigSubsection, ConfigText, getConfigListEntry, ConfigSelection, ConfigPassword
8 from Components.Network import iNetwork
9 from Components.Label import Label
10 from Components.MenuList import MenuList
11 from Components.PluginComponent import plugins
12 from Plugins.Plugin import PluginDescriptor
13 from Tools.Directories import resolveFilename, SCOPE_PLUGINS, SCOPE_SKIN_IMAGE
15 from WizardPluginLanguage import WizardPluginLanguage
16 from Screens.Rc import Rc
18 config.misc.firstrun = ConfigBoolean(default = True)
23 list.append("WPA/WPA2")
26 weplist.append("ASCII")
29 config.plugins.wlan = ConfigSubsection()
30 config.plugins.wlan.essid = NoSave(ConfigText(default = "home", fixed_size = False))
31 config.plugins.wlan.hiddenessid = NoSave(ConfigText(default = "home", fixed_size = False))
33 config.plugins.wlan.encryption = ConfigSubsection()
34 config.plugins.wlan.encryption.enabled = NoSave(ConfigYesNo(default = False))
35 config.plugins.wlan.encryption.type = NoSave(ConfigSelection(list, default = "WPA/WPA2" ))
36 config.plugins.wlan.encryption.wepkeytype = NoSave(ConfigSelection(weplist, default = "ASCII"))
37 config.plugins.wlan.encryption.psk = NoSave(ConfigPassword(default = "mysecurewlan", fixed_size = False))
39 class NetworkWizard(WizardPluginLanguage, Rc):
41 <screen position="0,0" size="720,576" title="Welcome..." flags="wfNoBorder" >
42 <widget name="text" position="153,40" size="340,330" font="Regular;22" />
43 <widget source="list" render="Listbox" position="53,340" size="440,180" scrollbarMode="showOnDemand" >
44 <convert type="StringList" />
46 <widget name="config" position="53,340" zPosition="1" size="440,180" transparent="1" scrollbarMode="showOnDemand" />
47 <ePixmap pixmap="skin_default/buttons/button_red.png" position="40,225" zPosition="0" size="15,16" transparent="1" alphatest="on" />
48 <widget name="languagetext" position="55,225" size="95,30" font="Regular;18" />
49 <widget name="wizard" pixmap="skin_default/wizard.png" position="40,50" zPosition="10" size="110,174" alphatest="on" />
50 <widget name="rc" pixmaps="skin_default/rc.png,skin_default/rcold.png" position="500,50" zPosition="10" size="154,500" alphatest="on" />
51 <widget name="arrowdown" pixmap="skin_default/arrowdown.png" position="-100,-100" zPosition="11" size="37,70" alphatest="on" />
52 <widget name="arrowdown2" pixmap="skin_default/arrowdown.png" position="-100,-100" zPosition="11" size="37,70" alphatest="on" />
53 <widget name="arrowup" pixmap="skin_default/arrowup.png" position="-100,-100" zPosition="11" size="37,70" alphatest="on" />
54 <widget name="arrowup2" pixmap="skin_default/arrowup.png" position="-100,-100" zPosition="11" size="37,70" alphatest="on" />
56 def __init__(self, session):
57 self.xmlfile = resolveFilename(SCOPE_PLUGINS, "SystemPlugins/NetworkWizard/networkwizard.xml")
58 WizardPluginLanguage.__init__(self, session, showSteps = False, showStepSlider = False)
60 self.session = session
61 self["wizard"] = Pixmap()
63 self.InterfaceState = None
64 self.isInterfaceUp = None
65 self.WlanPluginInstalled = None
67 self.selectedInterface = None
71 self.AdapterRef = None
73 self.isWlanPluginInstalled()
75 def listInterfaces(self):
76 list = [(iNetwork.getFriendlyAdapterName(x),x) for x in iNetwork.getAdapterList()]
77 list.append((_("Exit network wizard"), "end"))
80 def InterfaceSelectionMade(self, index):
81 self.selectedInterface = index
82 self.InterfaceSelect(index)
84 def InterfaceSelect(self, index):
88 self.NextStep = 'nwconfig'
90 self.NextStep = 'scanwlan'
92 def InterfaceSelectionMoved(self):
93 self.InterfaceSelect(self.selection)
95 def checkInterface(self,iface):
96 self.Adapterlist = iNetwork.getAdapterList()
97 if self.NextStep is not 'end':
98 if len(self.Adapterlist) == 0:
99 #Reset Network to defaults if network broken
100 iNetwork.resetNetworkConfig('lan', self.checkInterfaceCB)
101 self.myref = self.session.openWithCallback(self.resetfinishedCB, MessageBox, _("Please wait while we prepare your network interfaces..."), type = MessageBox.TYPE_INFO, enable_input = False)
103 iNetwork.resetNetworkConfig('lan',self.checkInterfaceCB)
104 self.myref = self.session.openWithCallback(self.resetfinishedCB, MessageBox, _("Please wait while we prepare your network interfaces..."), type = MessageBox.TYPE_INFO, enable_input = False)
105 elif iface == 'wlan0':
106 iNetwork.resetNetworkConfig('wlan',self.checkInterfaceCB)
107 self.myref = self.session.openWithCallback(self.resetfinishedCB, MessageBox, _("Please wait while we prepare your network interfaces..."), type = MessageBox.TYPE_INFO, enable_input = False)
108 elif iface == 'ath0':
109 iNetwork.resetNetworkConfig('wlan-mpci',self.checkInterfaceCB)
110 self.myref = self.session.openWithCallback(self.resetfinishedCB, MessageBox, _("Please wait while we prepare your network interfaces..."), type = MessageBox.TYPE_INFO, enable_input = False)
112 self.resetfinishedCB(False)
114 def resetfinishedCB(self,data):
116 self.currStep = self.getStepWithID(self.NextStep)
117 self.afterAsyncCode()
119 self.currStep = self.getStepWithID(self.NextStep)
120 self.afterAsyncCode()
122 def checkInterfaceCB(self,callback,iface):
123 if callback is not None:
125 iNetwork.getInterfaces(self.getInterfacesDataAvail)
128 def getInterfacesDataAvail(self, data):
130 if iNetwork.getAdapterAttribute(self.selectedInterface, 'up') is True:
131 self.isInterfaceUp = True
133 self.isInterfaceUp = False
134 self.myref.close(True)
136 def AdapterSetupEnd(self, iface):
137 if iNetwork.getAdapterAttribute(iface, "dhcp") is True:
138 iNetwork.checkNetworkState(self.AdapterSetupEndFinished)
139 self.AdapterRef = self.session.openWithCallback(self.AdapterSetupEndCB, MessageBox, _("Please wait while we test your network..."), type = MessageBox.TYPE_INFO, enable_input = False)
142 self.currStep = self.getStepWithID("confdns")
143 self.afterAsyncCode()
145 def AdapterSetupEndCB(self,data):
147 self.currStep = self.getStepWithID("checklanstatusend")
148 self.afterAsyncCode()
150 def AdapterSetupEndFinished(self,data):
152 self.InterfaceState = True
154 self.InterfaceState = False
155 self.AdapterRef.close(True)
157 def checkNetwork(self):
158 iNetwork.checkNetworkState(self.checkNetworkStateFinished)
159 self.checkRef = self.session.openWithCallback(self.checkNetworkCB, MessageBox, _("Please wait while we test your network..."), type = MessageBox.TYPE_INFO, enable_input = False)
161 def checkNetworkCB(self,data):
163 self.currStep = self.getStepWithID("checklanstatusend")
164 self.afterAsyncCode()
166 def checkNetworkStateFinished(self,data):
168 self.InterfaceState = True
170 self.InterfaceState = False
171 self.checkRef.close(True)
180 from Plugins.SystemPlugins.WirelessLan.Wlan import Wlan
182 list.append( ( _("No networks found"),_("unavailable") ) )
183 self.WlanList.append(_("No networks found"))
186 self.w = Wlan(self.selectedInterface)
187 aps = self.w.getNetworkList()
189 print "[NetworkWizard.py] got Accespoints!"
194 a['essid'] = a['bssid']
195 list.append( (a['essid'], a['essid']) )
196 self.WlanList.append(a['essid'])
197 if "hidden..." not in list:
198 list.append( ( _("enter hidden network SSID"),_("hidden...") ) )
199 self.WlanList.append(_("hidden..."))
202 def modeSelectionMade(self, index):
203 self.modeSelect(index)
205 def modeSelectionMoved(self):
206 self.modeSelect(self.selection)
208 def modeSelect(self, mode):
210 print "ModeSelected:", mode
212 def restartNetwork(self):
213 iNetwork.restartNetwork()
216 def isWlanPluginInstalled(self):
218 from Plugins.SystemPlugins.WirelessLan.Wlan import Wlan
220 self.WlanPluginInstalled = False
222 self.WlanPluginInstalled = True