1 from Screens.Screen import Screen
2 from Screens.MessageBox import MessageBox
3 from Screens.InputBox import InputBox
4 from Screens.Standby import *
5 from Screens.VirtualKeyBoard import VirtualKeyBoard
6 from Screens.HelpMenu import HelpableScreen
7 from Components.Network import iNetwork
8 from Screens.NetworkSetup import NameserverSetup
9 from Components.Sources.StaticText import StaticText
10 from Components.Sources.Boolean import Boolean
11 from Components.Sources.List import List
12 from Components.Label import Label,MultiColorLabel
13 from Components.Pixmap import Pixmap,MultiPixmap
14 from Components.MenuList import MenuList
15 from Components.config import config, ConfigYesNo, ConfigIP, NoSave, ConfigText, ConfigPassword, ConfigSelection, getConfigListEntry, ConfigNothing
16 from Components.config import ConfigInteger, ConfigSubsection
17 from Components.ConfigList import ConfigListScreen
18 from Components.PluginComponent import plugins
19 from Components.MultiContent import MultiContentEntryText, MultiContentEntryPixmapAlphaTest
20 from Components.ActionMap import ActionMap, NumberActionMap, HelpableActionMap
21 from Components.Console import Console
22 from Tools.Directories import resolveFilename, SCOPE_PLUGINS, SCOPE_CURRENT_SKIN
23 from Tools.LoadPixmap import LoadPixmap
24 from Plugins.Plugin import PluginDescriptor
25 from enigma import eTimer, ePoint, eSize, RT_HALIGN_LEFT, eListboxPythonMultiContent, gFont
26 from os import path as os_path, system as os_system, unlink,listdir
27 from re import compile as re_compile, search as re_search
28 from Tools.Directories import fileExists
31 class WlanSelection(Screen,HelpableScreen):
33 <screen name="WlanSelection" position="209,48" size="865,623" title="Wireless Network Configuration..." flags="wfNoBorder" backgroundColor="transparent">
34 <ePixmap pixmap="Vu_HD/Bg_EPG_view.png" zPosition="-1" position="0,0" size="865,623" alphatest="on" />
35 <ePixmap pixmap="Vu_HD/menu/ico_title_Setup.png" position="32,41" size="40,40" alphatest="blend" transparent="1" />
36 <eLabel text="Wireless Network Adapter Selection..." position="90,50" size="600,32" font="Semiboldit;32" foregroundColor="#5d5d5d" backgroundColor="#27b5b9bd" transparent="1" />
37 <ePixmap pixmap="Vu_HD/icons/clock.png" position="750,55" zPosition="1" size="20,20" alphatest="blend" />
38 <widget source="global.CurrentTime" render="Label" position="770,57" zPosition="1" size="50,20" font="Regular;20" foregroundColor="#1c1c1c" backgroundColor="#27d9dee2" halign="right" transparent="1">
39 <convert type="ClockToText">Format:%H:%M</convert>
41 <ePixmap pixmap="Vu_HD/buttons/red.png" position="45,98" size="25,25" alphatest="blend" />
42 <ePixmap pixmap="Vu_HD/buttons/green.png" position="240,98" size="25,25" alphatest="blend" />
43 <widget source="key_red" render="Label" position="66,97" zPosition="1" size="150,25" font="Regular;20" halign="center" valign="center" backgroundColor="darkgrey" foregroundColor="#1c1c1c" transparent="1" />
44 <widget source="key_green" render="Label" position="268,97" zPosition="1" size="150,25" font="Regular;20" halign="center" valign="center" backgroundColor="darkgrey" foregroundColor="#1c1c1c" transparent="1" />
45 <ePixmap pixmap="Vu_HD/border_menu.png" position="120,140" zPosition="-1" size="342,358" transparent="1" alphatest="blend" />
46 <widget name="menulist" position="130,150" size="322,338" transparent="1" backgroundColor="#27d9dee2" zPosition="10" scrollbarMode="showOnDemand" />
47 <widget source="description" render="Label" position="500,140" size="280,360" font="Regular;19" halign="center" valign="center" backgroundColor="#c5c9cc" transparent="1"/>
50 def __init__(self, session):
51 Screen.__init__(self,session)
52 HelpableScreen.__init__(self)
53 self.mainmenu = self.getWlandevice()
54 self["menulist"] = MenuList(self.mainmenu)
55 self["key_red"] = StaticText(_("Close"))
56 self["key_green"] = StaticText(_("Select"))
57 self["description"] = StaticText()
58 self["description"].setText(_("Select Wireless Lan module. \n" ))
59 self["OkCancelActions"] = HelpableActionMap(self, "OkCancelActions",
61 "ok": (self.ok, _("select interface")),
62 "cancel": (self.close, _("exit network interface list")),
65 self["ColorActions"] = HelpableActionMap(self, "ColorActions",
67 "green": (self.ok, _("select interface")),
68 "red": (self.close, _("exit network interface list")),
72 ifaces=self["menulist"].getCurrent()[1]
76 self.session.open(WlanSetup,ifaces)
78 def getWlandevice(self):
80 for x in iNetwork.getAdapterList():
81 if x.startswith('eth'):
83 list.append((self.getAdapterDescription(x) + " (%s)"%x,x))
86 def getAdapterDescription(self, iface):
88 return _("Internal LAN adapter.")
90 classdir = "/sys/class/net/" + iface + "/device/"
91 driverdir = "/sys/class/net/" + iface + "/device/driver/"
92 if os_path.exists(classdir):
93 files = listdir(classdir)
95 if os_path.realpath(driverdir).endswith('rtw_usb_drv'):
96 return _("Realtak")+ " " + _("WLAN adapter.")
97 elif os_path.realpath(driverdir).endswith('ath_pci'):
98 return _("Atheros")+ " " + _("WLAN adapter.")
99 elif os_path.realpath(driverdir).endswith('zd1211b'):
100 return _("Zydas")+ " " + _("WLAN adapter.")
101 elif os_path.realpath(driverdir).endswith('rt73'):
102 return _("Ralink")+ " " + _("WLAN adapter.")
103 elif os_path.realpath(driverdir).endswith('rt73usb'):
104 return _("Ralink")+ " " + _("WLAN adapter.")
106 return str(os_path.basename(os_path.realpath(driverdir))) + " " + _("WLAN adapter.")
108 return _("Unknown network adapter.")
110 class WlanSetup(Screen,HelpableScreen):
112 <screen name="WlanSetup" position="209,48" size="865,623" title="Wireless Network Configuration..." flags="wfNoBorder" backgroundColor="transparent">
113 <ePixmap pixmap="Vu_HD/Bg_EPG_view.png" zPosition="-1" position="0,0" size="865,623" alphatest="on" />
114 <ePixmap pixmap="Vu_HD/menu/ico_title_Setup.png" position="32,41" size="40,40" alphatest="blend" transparent="1" />
115 <eLabel text="Wireless Network Setup Menu..." position="90,50" size="600,32" font="Semiboldit;32" foregroundColor="#5d5d5d" backgroundColor="#27b5b9bd" transparent="1" />
116 <ePixmap pixmap="Vu_HD/icons/clock.png" position="750,55" zPosition="1" size="20,20" alphatest="blend" />
117 <widget source="global.CurrentTime" render="Label" position="770,57" zPosition="1" size="50,20" font="Regular;20" foregroundColor="#1c1c1c" backgroundColor="#27d9dee2" halign="right" transparent="1">
118 <convert type="ClockToText">Format:%H:%M</convert>
120 <ePixmap pixmap="Vu_HD/buttons/red.png" position="45,98" size="25,25" alphatest="blend" />
121 <ePixmap pixmap="Vu_HD/buttons/green.png" position="240,98" size="25,25" alphatest="blend" />
122 <widget source="key_red" render="Label" position="66,97" zPosition="1" size="150,25" font="Regular;20" halign="center" valign="center" backgroundColor="darkgrey" foregroundColor="#1c1c1c" transparent="1" />
123 <widget source="key_green" render="Label" position="268,97" zPosition="1" size="150,25" font="Regular;20" halign="center" valign="center" backgroundColor="darkgrey" foregroundColor="#1c1c1c" transparent="1" />
124 <ePixmap pixmap="Vu_HD/border_menu.png" position="120,140" zPosition="-1" size="342,358" transparent="1" alphatest="blend" />
125 <widget name="menulist" position="130,150" size="322,338" transparent="1" backgroundColor="#27d9dee2" zPosition="10" scrollbarMode="showOnDemand" />
126 <widget source="description" render="Label" position="500,140" size="280,360" font="Regular;19" halign="center" valign="center" backgroundColor="#c5c9cc" transparent="1"/>
128 def __init__(self, session, ifaces):
129 Screen.__init__(self, session)
130 HelpableScreen.__init__(self)
131 self.session = session
133 self.restartLanRef = None
134 self.LinkState = None
135 self.mainmenu = self.MakeMenu()
136 self["menulist"] = MenuList(self.mainmenu)
137 self["key_red"] = StaticText(_("Close"))
138 self["key_green"] = StaticText(_("Select"))
139 self["description"] = StaticText()
140 self["IFtext"] = StaticText()
141 self["IF"] = StaticText()
142 self["Statustext"] = StaticText()
143 self["statuspic"] = MultiPixmap()
144 self["statuspic"].hide()
145 self.onLayoutFinish.append(self.loadDescription)
147 self.oktext = _("Press OK on your remote control to continue.")
149 self["WizardActions"] = HelpableActionMap(self, "WizardActions",
151 "up": (self.up, _("move up to previous entry")),
152 "down": (self.down, _("move down to next entry")),
153 "left": (self.left, _("move up to first entry")),
154 "right": (self.right, _("move down to last entry")),
157 self["OkCancelActions"] = HelpableActionMap(self, "OkCancelActions",
159 "cancel": (self.close, _("exit networkadapter setup menu")),
160 "ok": (self.ok, _("select menu entry")),
163 self["ColorActions"] = HelpableActionMap(self, "ColorActions",
165 "red": (self.close, _("exit networkadapter setup menu")),
166 "green": (self.ok, _("select menu entry")),
169 self["actions"] = NumberActionMap(["WizardActions","ShortcutActions"],
180 def loadDescription(self):
181 if self["menulist"].getCurrent()[1] == 'setting':
182 self["description"].setText(_("Edit the network configuration of your STB.\n" ) + self.oktext )
183 if self["menulist"].getCurrent()[1] == 'scanap':
184 self["description"].setText(_("Scan your network for wireless access points and connect to them using your selected wireless device.\n" ) + self.oktext )
185 if self["menulist"].getCurrent()[1] == 'dns':
186 self["description"].setText(_("Edit the Nameserver configuration of your STB.\n" ) + self.oktext )
187 if self["menulist"].getCurrent()[1] == 'status':
188 self["description"].setText(_("Shows the state of your wireless LAN connection.\n" ) + self.oktext )
189 if self["menulist"].getCurrent()[1] == 'test':
190 self["description"].setText(_("Test the network configuration of your STB.\n" ) + self.oktext )
191 if self["menulist"].getCurrent()[1] == 'restart':
192 self["description"].setText(_("Restart your network connection and interfaces.\n" ) + self.oktext )
195 self["menulist"].up()
196 self.loadDescription()
199 self["menulist"].down()
200 self.loadDescription()
203 self["menulist"].pageUp()
204 self.loadDescription()
207 self["menulist"].pageDown()
208 self.loadDescription()
211 if self["menulist"].getCurrent()[1] == 'setting':
212 self.session.openWithCallback(self.checklist, WlanConfig, self.iface)
213 elif self["menulist"].getCurrent()[1] == 'scanap':
214 self.session.open(WlanScanAp, self.iface)
215 elif self["menulist"].getCurrent()[1] == 'dns':
216 self.session.open(NameserverSetup)
217 elif self["menulist"].getCurrent()[1] == 'status':
218 self.session.open(Wlanstatus, self.iface)
219 elif self["menulist"].getCurrent()[1] == 'test':
220 self.session.openWithCallback(self.checklist,NetworkAdapterTest,self.iface)
221 elif self["menulist"].getCurrent()[1] == 'restart':
222 self.session.openWithCallback(self.restartLan, MessageBox, (_("Are you sure you want to restart your network interfaces?\n\n") + self.oktext ) )
225 self["menulist"].setList(self.MakeMenu())
229 menu.append((_("Adapter settings"), "setting"))
230 menu.append((_("Scan Wireless AP"), "scanap"))
231 menu.append((_("Nameserver settings"), "dns"))
232 if iNetwork.getAdapterAttribute(self.iface, "up"):
233 menu.append((_("Show WLAN Status"), "status"))
234 menu.append((_("Network test"), "test"))
235 menu.append((_("Restart network"), "restart"))
239 def restartLan(self, ret = False):
241 iNetwork.restartNetwork(self.restartLanDataAvail)
242 self.restartLanRef = self.session.openWithCallback(self.restartfinishedCB, MessageBox, _("Please wait while your network is restarting..."), type = MessageBox.TYPE_INFO, enable_input = False)
244 def restartLanDataAvail(self, data):
246 iNetwork.getInterfaces(self.getInterfacesDataAvail)
248 def getInterfacesDataAvail(self, data):
250 self.restartLanRef.close(True)
252 def restartfinishedCB(self,data):
254 self.session.open(MessageBox, _("Finished restarting your network"), type = MessageBox.TYPE_INFO, timeout = 5, default = False)
256 wlanconfig = ConfigSubsection()
257 wlanconfig.usedevice = ConfigSelection(default = "off", choices = [
258 ("off", _("off")), ("on", _("on"))])
259 wlanconfig.usedhcp = ConfigSelection(default = "off", choices = [
260 ("off", _("no")), ("on", _("yes"))])
261 wlanconfig.essid = ConfigSelection(default = "none", choices = ["none"])
262 wlanconfig.encrypt = ConfigSelection(default = "off", choices = [
263 ("off", _("no")), ("on", _("yes"))])
264 wlanconfig.method = ConfigSelection(default = "wep", choices = [
265 ("wep", _("WEP")), ("wpa", _("WPA")), ("wpa2", _("WPA2")),("wpa/wpa2", _("WPA/WPA2"))])
266 wlanconfig.keytype = ConfigSelection(default = "ascii", choices = [
267 ("ascii", _("ASCII")), ("hex", _("HEX"))])
268 wlanconfig.key = ConfigText(default = "XXXXXXXX", visible_width = 50, fixed_size = False)
269 wlanconfig.usegateway = ConfigSelection(default = "off", choices = [
270 ("off", _("no")), ("on", _("yes"))])
271 wlanconfig.ip = ConfigIP([0,0,0,0])
272 wlanconfig.netmask = ConfigIP([0,0,0,0])
273 wlanconfig.gateway = ConfigIP([0,0,0,0])
276 class WlanConfig(Screen, ConfigListScreen, HelpableScreen):
278 <screen name="WlanConfig" position="209,48" size="865,623" title="Wireless Network Configuration..." flags="wfNoBorder" backgroundColor="transparent">
279 <ePixmap pixmap="Vu_HD/Bg_EPG_view.png" zPosition="-1" position="0,0" size="865,623" alphatest="on" />
280 <ePixmap pixmap="Vu_HD/menu/ico_title_Setup.png" position="32,41" size="40,40" alphatest="blend" transparent="1" />
281 <eLabel text="Wireless Network Configuration..." position="90,50" size="600,32" font="Semiboldit;32" foregroundColor="#5d5d5d" backgroundColor="#27b5b9bd" transparent="1" />
282 <ePixmap pixmap="Vu_HD/icons/clock.png" position="750,55" zPosition="1" size="20,20" alphatest="blend" />
283 <widget source="global.CurrentTime" render="Label" position="770,57" zPosition="1" size="50,20" font="Regular;20" foregroundColor="#1c1c1c" backgroundColor="#27d9dee2" halign="right" transparent="1">
284 <convert type="ClockToText">Format:%H:%M</convert>
286 <ePixmap pixmap="Vu_HD/buttons/red.png" position="45,98" size="25,25" alphatest="blend" />
287 <ePixmap pixmap="Vu_HD/buttons/green.png" position="240,98" size="25,25" alphatest="blend" />
288 <widget source="key_red" render="Label" position="66,97" zPosition="1" size="150,25" font="Regular;20" halign="center" valign="center" backgroundColor="darkgrey" foregroundColor="#1c1c1c" transparent="1" />
289 <widget source="key_grean" render="Label" position="268,97" zPosition="1" size="150,25" font="Regular;20" halign="center" valign="center" backgroundColor="darkgrey" foregroundColor="#1c1c1c" transparent="1" />
290 <ePixmap pixmap="Vu_HD/border_menu.png" position="120,140" zPosition="-1" size="342,358" transparent="1" alphatest="blend" />
291 <widget name="config" position="130,150" size="322,338" transparent="1" backgroundColor="#27d9dee2" zPosition="10" scrollbarMode="showOnDemand" />
292 <eLabel text="IP Address : " position="500,160" size="200,26" font="Semiboldit;22" foregroundColor="#5d5d5d" backgroundColor="#27b5b9bd" transparent="1" />
293 <widget source="ipaddress" render="Label" position="530,190" zPosition="1" size="150,26" font="Regular;20" halign="center" valign="center" backgroundColor="#27b5b9bd" foregroundColor="#1c1c1c" transparent="1" />
294 <eLabel text="NetMask : " position="500,220" size="200,26" font="Semiboldit;22" foregroundColor="#5d5d5d" backgroundColor="#27b5b9bd" transparent="1" />
295 <widget source="netmask" render="Label" position="530,250" zPosition="1" size="150,26" font="Regular;20" halign="center" valign="center" backgroundColor="#27b5b9bd" foregroundColor="#1c1c1c" transparent="1" />
296 <eLabel text="Gateway : " position="500,280" size="200,26" font="Semiboldit;22" foregroundColor="#5d5d5d" backgroundColor="#27b5b9bd" transparent="1" />
297 <widget source="gateway" render="Label" position="530,310" zPosition="1" size="150,26" font="Regular;20" halign="center" valign="center" backgroundColor="#27b5b9bd" foregroundColor="#1c1c1c" transparent="1" />
300 def __init__(self, session, iface):
301 Screen.__init__(self,session)
302 self.session = session
303 self["key_red"] = StaticText(_("Close"))
304 self["key_grean"] = StaticText(_("Ok"))
305 self["ipaddress"] = StaticText(_("[ N/A ]"))
306 self["netmask"] = StaticText(_("[ N/A ]"))
307 self["gateway"] = StaticText(_("[ N/A ]"))
308 self["OkCancelActions"] = ActionMap(["ShortcutActions", "SetupActions" ],
310 "ok": self.saveWlanConfig,
311 "green": self.saveWlanConfig,
312 "cancel": self.keyCancel,
313 "red": self.keyCancel,
318 self.scan_ssid = None
322 self.encryption_key = None
323 self.wlanscanap = None
326 ConfigListScreen.__init__(self, self.list,session = self.session)
327 self.oldInterfaceState = iNetwork.getAdapterAttribute(self.iface, "up")
328 self.readWpaSupplicantConf()
329 # iNetwork.getInterfaces()
330 self.readWlanSettings()
331 self.scanAplistTimer = eTimer()
332 self.scanAplistTimer.callback.append(self.scanApList)
333 self.scanAplistTimer.start(100,True)
334 self.Console = Console()
336 def readWlanSettings(self):
337 if iNetwork.getAdapterAttribute(self.iface, "up") == True:
341 wlanconfig.usedevice = ConfigSelection(default=default_tmp, choices = [("off", _("off")), ("on", _("on"))])
343 if iNetwork.getAdapterAttribute(self.iface, "dhcp"):
347 wlanconfig.usedhcp = ConfigSelection(default=default_tmp, choices = [("off", _("no")), ("on", _("yes"))])
349 wlanconfig.ip = ConfigIP(default=iNetwork.getAdapterAttribute(self.iface, "ip")) or [0,0,0,0]
351 wlanconfig.netmask = ConfigIP(default=iNetwork.getAdapterAttribute(self.iface, "netmask") or [255,0,0,0])
352 if iNetwork.getAdapterAttribute(self.iface, "gateway"):
356 wlanconfig.usegateway = ConfigSelection(default = default_tmp, choices = [("off", _("no")), ("on", _("yes"))])
358 wlanconfig.gateway = ConfigIP(default=iNetwork.getAdapterAttribute(self.iface, "gateway") or [0,0,0,0])
360 self["ipaddress"] = StaticText(_(self.formatip(iNetwork.getAdapterAttribute(self.iface, "ip"))))
361 self["netmask"] = StaticText(_(self.formatip(iNetwork.getAdapterAttribute(self.iface, "netmask"))))
362 self["gateway"] = StaticText(_(self.formatip(iNetwork.getAdapterAttribute(self.iface, "gateway"))))
364 if self.encryption_key is not None:
368 wlanconfig.encrypt = ConfigSelection(default = default_tmp, choices = [("off", _("no")), ("on", _("yes"))])
370 if self.key_mgmt=="NONE":
372 elif self.key_mgmt == "WPA-PSK":
373 if self.proto == "WPA":
375 elif self.proto == "RSN":
377 elif self.proto in ( "WPA RSN", "WPA WPA2"):
378 default_tmp = "wpa/wpa2"
384 wlanconfig.method = ConfigSelection(default = default_tmp, choices = [
385 ("wep", _("WEP")), ("wpa", _("WPA")), ("wpa2", _("WPA2")),("wpa/wpa2", _("WPA/WPA2"))])
387 if self.key_type == 0:
390 default_tmp = "ascii"
391 wlanconfig.keytype = ConfigSelection(default = default_tmp, choices = [
392 ("ascii", _("ASCII")), ("hex", _("HEX"))])
393 default_tmp = self.encryption_key or "XXXXXXXX"
394 wlanconfig.key = ConfigText(default = default_tmp, visible_width = 50, fixed_size = False)
396 def readWpaSupplicantConf(self):
398 if fileExists("/etc/wpa_supplicant.conf"):
399 wpafd = open("/etc/wpa_supplicant.conf","r")
401 data = wpafd.readline()
403 # print "####readWpaSupplicantConf, data : ",data
406 data = wpafd.readline()
408 if data.startswith('ssid=') and len(data) > 6:
409 self.ssid = data[6:-2]
410 elif data.startswith('ap_scan=') :
411 self.ap_scan = data[8:]
412 # print "####readWpaSupplicantConf, ap_scan : ",self.ap_scan
413 elif data.startswith('scan_ssid=') and len(data) > 10:
414 self.scan_ssid = data[10:-1]
415 elif data.startswith('key_mgmt=') and len(data) > 9:
416 self.key_mgmt = data[9:-1]
417 elif data.startswith('proto=') and len(data) > 6:
418 self.proto = data[6:-1]
419 elif data.startswith('wep_key0="') and len(data) > 11:
420 self.key_type = 1 # ascii
421 self.encryption_key = data[10:-2]
422 elif data.startswith('wep_key0=') and len(data) > 9:
423 self.key_type = 0 # hex
424 self.encryption_key = data[9:-1]
425 elif data.startswith('psk="') and len(data) > 6:
426 self.key_type = 1 # ascii
427 self.encryption_key = data[5:-2]
428 elif data.startswith('psk=') and len(data) > 4:
429 self.key_type = 0 # hex
430 self.encryption_key = data[4:-1]
431 data = wpafd.readline()
432 print self.ssid,self.scan_ssid,self.key_mgmt,self.proto,self.key_type,self.wep_key
439 print 'failed loading wpasupplicant.conf'
441 def createConfig(self):
443 self.usedeviceEntry = getConfigListEntry(_("Use Device"), wlanconfig.usedevice)
444 self.usedhcpEntry = getConfigListEntry(_("Use DHCP"), wlanconfig.usedhcp)
445 self.essidEntry = getConfigListEntry(_("ESSID"), wlanconfig.essid)
446 self.hiddenessidEntry = getConfigListEntry(_("Input Hidden ESSID"), wlanconfig.hiddenessid)
447 self.encryptEntry = getConfigListEntry(_("Encrypt"), wlanconfig.encrypt)
448 self.methodEntry = getConfigListEntry(_("Method"), wlanconfig.method)
449 self.keytypeEntry = getConfigListEntry(_("Key Type"), wlanconfig.keytype)
450 self.keyEntry = getConfigListEntry(_("KEY"), wlanconfig.key)
452 self.ipEntry = getConfigListEntry(_("IP"), wlanconfig.ip)
453 self.netmaskEntry = getConfigListEntry(_("NetMask"), wlanconfig.netmask)
455 self.usegatewayEntry = getConfigListEntry(_("Use Gateway"), wlanconfig.usegateway)
456 self.gatewayEntry = getConfigListEntry(_("Gateway"), wlanconfig.gateway)
458 self.configList.append( self.usedeviceEntry )
459 if wlanconfig.usedevice.value is "on":
460 self.configList.append( self.usedhcpEntry )
461 if wlanconfig.usedhcp.value is "off":
462 self.configList.append(self.ipEntry)
463 self.configList.append(self.netmaskEntry)
464 self.configList.append(self.usegatewayEntry)
465 if wlanconfig.usegateway.value is "on":
466 self.configList.append(self.gatewayEntry)
467 self.configList.append( self.essidEntry )
468 print "#### wlanconfig.essid.value : ",wlanconfig.essid.value
469 if wlanconfig.essid.value == 'Input hidden ESSID':
470 self.configList.append( self.hiddenessidEntry )
471 self.configList.append( self.encryptEntry )
472 if wlanconfig.encrypt.value is "on" :
473 self.configList.append( self.methodEntry )
474 self.configList.append( self.keytypeEntry )
475 self.configList.append( self.keyEntry )
477 self["config"].list = self.configList
478 self["config"].l.setList(self.configList)
479 # if not self.selectionChanged in self["config"].onSelectionChanged:
480 # self["config"].onSelectionChanged.append(self.selectionChanged)
482 def scanApList(self):
485 self.configurationmsg = self.session.open(MessageBox, _("Please wait for scanning AP..."), type = MessageBox.TYPE_INFO, enable_input = False)
486 os_system('ifconfig '+self.iface+" up")
487 self.wlanscanap = Console()
488 cmd = "iwlist "+self.iface+" scan"
490 self.wlanscanap.ePopen(cmd, self.apListFinnished,self.apListParse)
492 def apListFinnished(self, result, retval,extra_args):
493 (callback) = extra_args
494 if self.wlanscanap is not None:
496 self.wlanscanap = None
497 content = result.splitlines()
498 first = content[0].split()
503 if completed == True:
510 def apListParse(self,data):
513 if self.scanAPcount >0:
514 self.configurationmsg.close(True)
515 self.scanAplistTimer.start(100,True)
518 self.configurationmsg.close(True)
519 self.session.open(MessageBox, _("Scan AP Failed"), MessageBox.TYPE_INFO,2)
524 list = data.splitlines()
527 if xx.startswith('ESSID:') and len(xx)>8:
528 self.apList.append(xx[7:-1])
529 self.apList.append('Input hidden ESSID')
530 print "###### selectap : ",selectap
531 if selectap is not None and selectap in self.apList:
532 wlanconfig.essid = ConfigSelection(default=selectap,choices = self.apList)
533 elif self.ap_scan is not None and self.ap_scan.strip() == '2':
534 wlanconfig.essid = ConfigSelection(default='Input hidden ESSID',choices = self.apList)
535 elif self.ssid is not None and self.ssid in self.apList:
536 wlanconfig.essid = ConfigSelection(default=self.ssid,choices = self.apList)
538 wlanconfig.essid = ConfigSelection(choices = self.apList)
539 if self.ssid is not None:
540 wlanconfig.hiddenessid = ConfigText(default = self.ssid, visible_width = 50, fixed_size = False)
542 wlanconfig.hiddenessid = ConfigText(default = "<Input ESSID>", visible_width = 50, fixed_size = False)
543 self.configurationmsg.close(True)
547 ConfigListScreen.keyLeft(self)
551 ConfigListScreen.keyRight(self)
555 if self["config"].getCurrent() == self.usedeviceEntry or self["config"].getCurrent() == self.encryptEntry \
556 or self["config"].getCurrent() == self.usedhcpEntry or self["config"].getCurrent() == self.usegatewayEntry \
557 or self["config"].getCurrent() == self.essidEntry:
560 def saveWlanConfig(self):
561 if self["config"].isChanged():
562 self.session.openWithCallback(self.checkNetworkShares, MessageBox, (_("Are you sure you want to restart your network interfaces?\n") ) )
564 def checkNetworkShares(self,ret = False):
567 print "########## checkNetworkShares : "
569 self.Console = Console()
570 cmd = "cat /proc/mounts"
571 self.Console.ePopen(cmd, self.checkSharesFinished, self.confirmAnotherIfaces)
573 def checkSharesFinished(self, result, retval, extra_args):
574 callback = extra_args
575 print "checkMountsFinished : result : \n",result
576 networks = ['nfs','smbfs','ncp','coda']
577 for line in result.splitlines():
578 split = line.strip().split(' ',3)
579 if split[2] in networks:
580 self.session.open(MessageBox, ("NOT deconfiguring network interfaces :\n network shares still mounted\n"), type = MessageBox.TYPE_ERROR, timeout = 10)
585 def confirmAnotherIfaces(self, ret = False):
589 num_configured_if = len(iNetwork.getConfiguredAdapters())
590 if num_configured_if >= 1:
591 if num_configured_if == 1 and self.iface in iNetwork.getConfiguredAdapters():
592 self.writeWlanConfig(False)
594 self.session.openWithCallback(self.writeWlanConfig, MessageBox, (_("Are you sure you want to deactive another network interfaces?\n") ) )
596 self.writeWlanConfig(False)
598 def writeWlanConfig(self,ret = False):
600 configuredInterfaces = iNetwork.getConfiguredAdapters()
601 for interface in configuredInterfaces:
602 if interface == self.iface:
604 iNetwork.setAdapterAttribute(interface, "up", False)
605 iNetwork.deactivateInterface(interface)
606 ret=self.writeWpasupplicantConf()
608 self.session.open(MessageBox, _("wpa_supplicant.conf open error."), type = MessageBox.TYPE_ERROR, timeout = 10)
611 self.session.open(MessageBox, _("hidden ESSID empty"), type = MessageBox.TYPE_ERROR, timeout = 10)
613 iffd = open("/etc/network/interfaces","r")
617 data = iffd.readline()
620 if data.startswith('iface '+self.iface) or data.startswith('auto '+self.iface):
622 data = iffd.readline()
624 elif not data.startswith('auto lo') and data.startswith('auto '):
625 if ret == True or data[5:] not in iNetwork.getConfiguredAdapters():
626 data = iffd.readline()
628 if status == 1 and data.startswith('iface ') or data.startswith('auto '):
634 data = iffd.readline()
636 iffd = open("/etc/network/interfaces","w")
638 if prev_content == "":
639 prev_content = "# automatically generated by STB\n"
640 prev_content += "# do Not change manually!\n\n"
641 prev_content += "auto lo\n"
642 prev_content += "iface lo inet loopback\n\n"
643 iffd.write(prev_content)
644 if wlanconfig.usedevice.value=="on":
645 iNetwork.setAdapterAttribute(self.iface, "up", True)
646 contents = "auto "+self.iface+"\n"
647 contents += "iface "+self.iface+" inet "
648 if wlanconfig.usedhcp.value =="on":
649 iNetwork.setAdapterAttribute(self.iface, "dhcp", True)
652 iNetwork.setAdapterAttribute(self.iface, "dhcp", False)
653 contents +="static\n"
654 print wlanconfig.ip.value
655 iNetwork.setAdapterAttribute(self.iface, "ip", wlanconfig.ip.value)
656 iNetwork.setAdapterAttribute(self.iface, "netmask", wlanconfig.netmask.value)
657 contents +="\taddress "+ self.formatip(wlanconfig.ip.value)+"\n"
658 contents +="\tnetmask "+ self.formatip(wlanconfig.netmask.value)+"\n"
659 if wlanconfig.usegateway.value == "on":
660 iNetwork.setAdapterAttribute(self.iface, "gateway", wlanconfig.gateway.value)
661 contents +="\tgateway "+ self.formatip(wlanconfig.gateway.value)+"\n"
662 contents += "\tpre-up wpa_supplicant -i"+self.iface+" -c/etc/wpa_supplicant.conf -B -D"+iNetwork.detectWlanModule(self.iface)+"\n"
663 contents += "\tpost-down wpa_cli terminate\n\n"
666 iNetwork.setAdapterAttribute(self.iface, "up", False)
667 iNetwork.deactivateInterface(self.iface)
668 iffd.write(next_content)
671 self.session.open(MessageBox, _("/etc/network/interfaces open error."), type = MessageBox.TYPE_ERROR, timeout = 10)
673 iNetwork.restartNetwork(self.updateCurrentInterfaces)
674 self.configurationmsg = None
675 self.configurationmsg = self.session.openWithCallback(self.configFinished, MessageBox, _("Please wait for activation of your network configuration..."), type = MessageBox.TYPE_INFO, enable_input = False)
677 def writeWpasupplicantConf(self):
678 wpafd = open("/etc/wpa_supplicant.conf","w")
680 contents = "#WPA Supplicant Configuration by STB\n"
681 contents += "ctrl_interface=/var/run/wpa_supplicant\n"
682 contents += "eapol_version=1\n"
683 contents += "fast_reauth=1\n"
685 if wlanconfig.essid.value == 'Input hidden ESSID':
686 contents += "ap_scan=2\n"
688 contents += "ap_scan=1\n"
689 contents += "network={\n"
690 if wlanconfig.essid.value == 'Input hidden ESSID':
691 if len(wlanconfig.hiddenessid.value) == 0:
694 contents += "\tssid=\""+wlanconfig.hiddenessid.value+"\"\n"
696 contents += "\tssid=\""+wlanconfig.essid.value+"\"\n"
697 contents += "\tscan_ssid=0\n"
698 if wlanconfig.encrypt.value == "on":
699 if wlanconfig.method.value =="wep":
700 contents += "\tkey_mgmt=NONE\n"
701 contents += "\twep_key0="
702 elif wlanconfig.method.value == "wpa":
703 contents += "\tkey_mgmt=WPA-PSK\n"
704 contents += "\tproto=WPA\n"
705 contents += "\tpairwise=CCMP TKIP\n"
706 contents += "\tgroup=CCMP TKIP\n"
708 elif wlanconfig.method.value == "wpa2":
709 contents += "\tkey_mgmt=WPA-PSK\n"
710 contents += "\tproto=RSN\n"
711 contents += "\tpairwise=CCMP TKIP\n"
712 contents += "\tgroup=CCMP TKIP\n"
715 contents += "\tkey_mgmt=WPA-PSK\n"
716 contents += "\tproto=WPA RSN\n"
717 contents += "\tpairwise=CCMP TKIP\n"
718 contents += "\tgroup=CCMP TKIP\n"
720 if wlanconfig.keytype.value == "ascii":
721 contents += "\""+wlanconfig.key.value+"\"\n"
723 contents += wlanconfig.key.value+"\n"
725 contents += "\tkey_mgmt=NONE\n"
727 print "content = \n"+contents
728 wpafd.write(contents)
732 self.session.open(MessageBox, _("wpa_supplicant.conf open error."), type = MessageBox.TYPE_ERROR, timeout = 10)
734 def updateCurrentInterfaces(self,ret):
736 iNetwork.getInterfaces(self.configurationMsgClose)
738 def configurationMsgClose(self,ret):
739 if ret is True and self.configurationmsg is not None:
740 self.configurationmsg.close(True)
742 def configFinished(self,data):
745 self.session.openWithCallback(self.configFinishedCB, MessageBox, _("Your network configuration has been activated."), type = MessageBox.TYPE_INFO, timeout = 10)
746 selectap = wlanconfig.essid.value
748 def configFinishedCB(self,data):
753 def formatip(self, iplist):
758 result = str(iplist[0])+"."+str(iplist[1])+"."+str(iplist[2])+"."+str(iplist[3])
765 def keyCancelConfirm(self, result):
768 if self.oldInterfaceState is False:
769 iNetwork.deactivateInterface(self.iface,self.keyCancelCB)
774 if self["config"].isChanged():
775 self.session.openWithCallback(self.keyCancelConfirm, MessageBox, _("Really close without saving settings?"))
779 def keyCancelCB(self,data):
784 # def selectionChanged(self):
785 # current = self["config"].getCurrent()
788 class WlanScanAp(Screen,HelpableScreen):
790 <screen name="WlanScanAp" position="209,48" size="865,623" title="Wireless Network Configuration..." flags="wfNoBorder" backgroundColor="transparent">
791 <ePixmap pixmap="Vu_HD/Bg_EPG_view.png" zPosition="-1" position="0,0" size="865,623" alphatest="on" />
792 <ePixmap pixmap="Vu_HD/menu/ico_title_Setup.png" position="32,41" size="40,40" alphatest="blend" transparent="1" />
793 <eLabel text="Wireless Network AP Scan..." position="90,50" size="600,32" font="Semiboldit;32" foregroundColor="#5d5d5d" backgroundColor="#27b5b9bd" transparent="1" />
794 <ePixmap pixmap="Vu_HD/icons/clock.png" position="750,55" zPosition="1" size="20,20" alphatest="blend" />
795 <widget source="global.CurrentTime" render="Label" position="770,57" zPosition="1" size="50,20" font="Regular;20" foregroundColor="#1c1c1c" backgroundColor="#27d9dee2" halign="right" transparent="1">
796 <convert type="ClockToText">Format:%H:%M</convert>
798 <ePixmap pixmap="Vu_HD/buttons/red.png" position="45,98" size="25,25" alphatest="blend" />
799 <ePixmap pixmap="Vu_HD/buttons/green.png" position="240,98" size="25,25" alphatest="blend" />
800 <ePixmap pixmap="Vu_HD/buttons/blue.png" position="630,98" size="25,25" alphatest="blend" />
801 <widget source="key_red" render="Label" position="66,97" zPosition="1" size="150,25" font="Regular;20" halign="center" valign="center" backgroundColor="darkgrey" foregroundColor="#1c1c1c" transparent="1" />
802 <widget source="key_green" render="Label" position="268,97" zPosition="1" size="150,25" font="Regular;20" halign="center" valign="center" backgroundColor="darkgrey" foregroundColor="#1c1c1c" transparent="1" />
803 <widget source="key_blue" render="Label" position="665,97" zPosition="1" size="150,25" font="Regular;20" halign="center" valign="center" backgroundColor="darkgrey" foregroundColor="#1c1c1c" transparent="1" />
804 <ePixmap pixmap="Vu_HD/border_menu.png" position="120,140" zPosition="-1" size="342,358" transparent="1" alphatest="blend" />
805 <widget name="menulist" position="130,150" size="322,338" transparent="1" backgroundColor="#27d9dee2" zPosition="10" scrollbarMode="showOnDemand" />
806 <widget source="Address" render="Label" position="490,220" zPosition="1" size="300,30" font="Regular;20" halign="center" valign="center" backgroundColor="#27b5b9bd" foregroundColor="#1c1c1c" transparent="1" />
807 <widget source="ESSID" render="Label" position="490,250" zPosition="1" size="300,30" font="Regular;20" halign="center" valign="center" backgroundColor="#27b5b9bd" foregroundColor="#1c1c1c" transparent="1" />
808 <widget source="Protocol" render="Label" position="490,280" zPosition="1" size="300,30" font="Regular;20" halign="center" valign="center" backgroundColor="#27b5b9bd" foregroundColor="#1c1c1c" transparent="1" />
809 <widget source="Frequency" render="Label" position="490,310" zPosition="1" size="300,30" font="Regular;20" halign="center" valign="center" backgroundColor="#27b5b9bd" foregroundColor="#1c1c1c" transparent="1" />
810 <widget source="Encryption key" render="Label" position="490,340" zPosition="1" size="300,30" font="Regular;20" halign="center" valign="center" backgroundColor="#27b5b9bd" foregroundColor="#1c1c1c" transparent="1" />
811 <widget source="BitRate" render="Label" position="490,370" zPosition="1" size="300,30" font="Regular;20" halign="center" valign="center" backgroundColor="#27b5b9bd" foregroundColor="#1c1c1c" transparent="1" />
814 def __init__(self, session, iface):
815 Screen.__init__(self,session)
816 HelpableScreen.__init__(self)
817 self.session = session
819 self.wlanscanap = None
824 self["WizardActions"] = HelpableActionMap(self, "WizardActions",
826 "up": (self.up, _("move up to previous entry")),
827 "down": (self.down, _("move down to next entry")),
828 "left": (self.left, _("move up to first entry")),
829 "right": (self.right, _("move down to last entry")),
832 self["OkCancelActions"] = HelpableActionMap(self, "OkCancelActions",
834 "cancel": (self.close, _("exit")),
835 "ok": (self.ok, "select AP"),
838 self["ColorActions"] = HelpableActionMap(self, "ColorActions",
840 "red": (self.close, _("exit")),
841 "green": (self.ok, "select AP"),
842 "blue": (self.startWlanConfig, "Edit Wireless settings"),
845 self["actions"] = NumberActionMap(["WizardActions","ShortcutActions"],
856 self["menulist"] = MenuList(self.SetApList)
857 self["key_red"] = StaticText(_("Close"))
858 self["key_green"] = StaticText(_("Select"))
859 self["key_blue"] = StaticText(_("EditSetting"))
860 self["Address"] = StaticText(_("Scanning AP List.."))
861 self["ESSID"] = StaticText(_("Wait a moment"))
862 self["Protocol"] = StaticText(" ")
863 self["Frequency"] = StaticText(" ")
864 self["Encryption key"] = StaticText(" ")
865 self["BitRate"] = StaticText(" ")
866 self.scanAplistTimer = eTimer()
867 self.scanAplistTimer.callback.append(self.scanApList)
868 self.scanAplistTimer.start(100,True)
872 self["menulist"].pageUp()
876 self["menulist"].pageDown()
880 self["menulist"].up()
884 self["menulist"].down()
889 selectAp=self["menulist"].getCurrent()[0]
893 def startWlanConfig(self):
895 selectAp=self["menulist"].getCurrent()[0]
897 self.session.open(WlanConfig,self.iface)
900 def scanApList(self):
901 print "self.scanAPcount : ",self.scanAPcount
904 self.configurationmsg = self.session.open(MessageBox, _("Please wait for scanning AP..."), type = MessageBox.TYPE_INFO, enable_input = False)
906 os_system('ifconfig '+self.iface+" up")
907 self.wlanscanap = Console()
908 cmd = "iwlist "+self.iface+" scan"
910 self.wlanscanap.ePopen(cmd, self.iwlistfinnished,self.APListParse)
912 def iwlistfinnished(self, result, retval,extra_args):
913 # print "iwlistfinnished"
914 (statecallback) = extra_args
915 if self.wlanscanap is not None:
916 # print "retval = ",retval
918 self.wlanscanap = None
919 content = result.splitlines()
920 first = content[0].split()
925 if completed == True:
926 statecallback(result)
932 def APListParse(self,data):
934 if self.scanAPcount >0:
935 self.configurationmsg.close(True)
936 self.scanAplistTimer.start(100,True)
939 self.session.open(MessageBox, _("Scan AP Failed"), MessageBox.TYPE_INFO,5)
945 list = data.splitlines()
947 # print "line : ",line
948 if line.strip().startswith("Cell"): # Cell 01 - Address: 00:26:66:5C:EF:24
949 parts = line.strip().split(" ")
950 current_ap_id = int(parts[1])
951 self.apList[current_ap_id]={}
952 self.apList[current_ap_id]["Address"]=parts[4]
953 elif line.strip().startswith("ESSID"):
954 self.apList[current_ap_id]["ESSID"]=line.strip()[6:].strip('"')
955 self.SetApList.append( (self.apList[current_ap_id]["ESSID"],current_ap_id) )
956 elif line.strip().startswith("Protocol"):
957 self.apList[current_ap_id]["Protocol"]=line.strip()[9:]
958 elif line.strip().startswith("Frequency"):
959 self.apList[current_ap_id]["Frequency"]=line.strip()[10:]
960 elif line.strip().startswith("Encryption key"):
961 self.apList[current_ap_id]["Encryption key"]=line.strip()[15:]
962 elif line.strip().startswith("Bit Rates"):
963 self.apList[current_ap_id]["BitRate"]=line.strip()[10:]
965 print len(self.apList)
966 self.configurationmsg.close(True)
969 def displayApInfo(self):
970 if len(self.apList) >0:
971 self["menulist"].setList(self.SetApList)
972 index = self["menulist"].getCurrent()[1]
973 for key in ["Address", "ESSID", "Protocol", "Frequency", "Encryption key", "BitRate"]:
974 if self.apList[index].has_key(key):
975 self[key].setText((key+": "+self.apList[index][key]))
977 self[key].setText(("None"))
979 self.session.openWithCallback(self.ScanAPclose, MessageBox, _("No AP detected."), type = MessageBox.TYPE_INFO, timeout = 10)
981 def ScanAPclose(self,data):
984 class NetworkAdapterTest(Screen):
985 def __init__(self, session,iface):
986 Screen.__init__(self, session)
988 self.oldInterfaceState = iNetwork.getAdapterAttribute(self.iface, "up")
990 self.onClose.append(self.cleanup)
991 self.onHide.append(self.cleanup)
993 self["updown_actions"] = NumberActionMap(["WizardActions","ShortcutActions"],
997 "up": lambda: self.updownhandler('up'),
998 "down": lambda: self.updownhandler('down'),
1002 self["shortcuts"] = ActionMap(["ShortcutActions","WizardActions"],
1005 "back": self.cancel,
1007 self["infoshortcuts"] = ActionMap(["ShortcutActions","WizardActions"],
1009 "red": self.closeInfo,
1010 "back": self.closeInfo,
1012 self["shortcutsgreen"] = ActionMap(["ShortcutActions"],
1014 "green": self.KeyGreen,
1016 self["shortcutsgreen_restart"] = ActionMap(["ShortcutActions"],
1018 "green": self.KeyGreenRestart,
1020 self["shortcutsyellow"] = ActionMap(["ShortcutActions"],
1022 "yellow": self.KeyYellow,
1025 self["shortcutsgreen_restart"].setEnabled(False)
1026 self["updown_actions"].setEnabled(False)
1027 self["infoshortcuts"].setEnabled(False)
1028 self.onClose.append(self.delTimer)
1029 self.onLayoutFinish.append(self.layoutFinished)
1030 self.steptimer = False
1032 self.activebutton = 0
1033 self.nextStepTimer = eTimer()
1034 self.nextStepTimer.callback.append(self.nextStepTimerFire)
1037 if self.oldInterfaceState is False:
1038 iNetwork.setAdapterAttribute(self.iface, "up", self.oldInterfaceState)
1039 iNetwork.deactivateInterface(self.iface)
1042 def closeInfo(self):
1043 self["shortcuts"].setEnabled(True)
1044 self["infoshortcuts"].setEnabled(False)
1045 self["InfoText"].hide()
1046 self["InfoTextBorder"].hide()
1047 self["key_red"].setText(_("Close"))
1051 del self.nextStepTimer
1053 def nextStepTimerFire(self):
1054 self.nextStepTimer.stop()
1055 self.steptimer = False
1058 def updownhandler(self,direction):
1059 if direction == 'up':
1060 if self.activebutton >=2:
1061 self.activebutton -= 1
1063 self.activebutton = 6
1064 self.setActiveButton(self.activebutton)
1065 if direction == 'down':
1066 if self.activebutton <=5:
1067 self.activebutton += 1
1069 self.activebutton = 1
1070 self.setActiveButton(self.activebutton)
1072 def setActiveButton(self,button):
1074 self["EditSettingsButton"].setPixmapNum(0)
1075 self["EditSettings_Text"].setForegroundColorNum(0)
1076 self["NetworkInfo"].setPixmapNum(0)
1077 self["NetworkInfo_Text"].setForegroundColorNum(1)
1078 self["AdapterInfo"].setPixmapNum(1) # active
1079 self["AdapterInfo_Text"].setForegroundColorNum(2) # active
1081 self["AdapterInfo_Text"].setForegroundColorNum(1)
1082 self["AdapterInfo"].setPixmapNum(0)
1083 self["DhcpInfo"].setPixmapNum(0)
1084 self["DhcpInfo_Text"].setForegroundColorNum(1)
1085 self["NetworkInfo"].setPixmapNum(1) # active
1086 self["NetworkInfo_Text"].setForegroundColorNum(2) # active
1088 self["NetworkInfo"].setPixmapNum(0)
1089 self["NetworkInfo_Text"].setForegroundColorNum(1)
1090 self["IPInfo"].setPixmapNum(0)
1091 self["IPInfo_Text"].setForegroundColorNum(1)
1092 self["DhcpInfo"].setPixmapNum(1) # active
1093 self["DhcpInfo_Text"].setForegroundColorNum(2) # active
1095 self["DhcpInfo"].setPixmapNum(0)
1096 self["DhcpInfo_Text"].setForegroundColorNum(1)
1097 self["DNSInfo"].setPixmapNum(0)
1098 self["DNSInfo_Text"].setForegroundColorNum(1)
1099 self["IPInfo"].setPixmapNum(1) # active
1100 self["IPInfo_Text"].setForegroundColorNum(2) # active
1102 self["IPInfo"].setPixmapNum(0)
1103 self["IPInfo_Text"].setForegroundColorNum(1)
1104 self["EditSettingsButton"].setPixmapNum(0)
1105 self["EditSettings_Text"].setForegroundColorNum(0)
1106 self["DNSInfo"].setPixmapNum(1) # active
1107 self["DNSInfo_Text"].setForegroundColorNum(2) # active
1109 self["DNSInfo"].setPixmapNum(0)
1110 self["DNSInfo_Text"].setForegroundColorNum(1)
1111 self["EditSettingsButton"].setPixmapNum(1) # active
1112 self["EditSettings_Text"].setForegroundColorNum(2) # active
1113 self["AdapterInfo"].setPixmapNum(0)
1114 self["AdapterInfo_Text"].setForegroundColorNum(1)
1117 next = self.nextstep
1133 self.steptimer = True
1134 self.nextStepTimer.start(3000)
1135 self["key_yellow"].setText(_("Stop test"))
1138 self["Adapter"].setText(iNetwork.getFriendlyAdapterName(self.iface))
1139 self["Adapter"].setForegroundColorNum(2)
1140 self["Adaptertext"].setForegroundColorNum(1)
1141 self["AdapterInfo_Text"].setForegroundColorNum(1)
1142 self["AdapterInfo_OK"].show()
1143 self.steptimer = True
1144 self.nextStepTimer.start(3000)
1147 self["Networktext"].setForegroundColorNum(1)
1148 self["Network"].setText(_("Please wait..."))
1149 self.AccessPointInfo(self.iface)
1150 self["NetworkInfo_Text"].setForegroundColorNum(1)
1151 self.steptimer = True
1152 self.nextStepTimer.start(3000)
1155 self["Dhcptext"].setForegroundColorNum(1)
1156 if iNetwork.getAdapterAttribute(self.iface, 'dhcp') is True:
1157 self["Dhcp"].setForegroundColorNum(2)
1158 self["Dhcp"].setText(_("enabled"))
1159 self["DhcpInfo_Check"].setPixmapNum(0)
1161 self["Dhcp"].setForegroundColorNum(1)
1162 self["Dhcp"].setText(_("disabled"))
1163 self["DhcpInfo_Check"].setPixmapNum(1)
1164 self["DhcpInfo_Check"].show()
1165 self["DhcpInfo_Text"].setForegroundColorNum(1)
1166 self.steptimer = True
1167 self.nextStepTimer.start(3000)
1170 self["IPtext"].setForegroundColorNum(1)
1171 self["IP"].setText(_("Please wait..."))
1172 iNetwork.checkNetworkState(self.NetworkStatedataAvail)
1175 self.steptimer = False
1176 self.nextStepTimer.stop()
1177 self["DNStext"].setForegroundColorNum(1)
1178 self["DNS"].setText(_("Please wait..."))
1179 iNetwork.checkDNSLookup(self.DNSLookupdataAvail)
1182 self["shortcutsgreen"].setEnabled(False)
1183 self["shortcutsyellow"].setEnabled(True)
1184 self["updown_actions"].setEnabled(False)
1185 self["key_yellow"].setText("")
1186 self["key_green"].setText("")
1187 self.steptimer = True
1188 self.nextStepTimer.start(1000)
1190 def KeyGreenRestart(self):
1192 self.layoutFinished()
1193 self["Adapter"].setText((""))
1194 self["Network"].setText((""))
1195 self["Dhcp"].setText((""))
1196 self["IP"].setText((""))
1197 self["DNS"].setText((""))
1198 self["AdapterInfo_Text"].setForegroundColorNum(0)
1199 self["NetworkInfo_Text"].setForegroundColorNum(0)
1200 self["DhcpInfo_Text"].setForegroundColorNum(0)
1201 self["IPInfo_Text"].setForegroundColorNum(0)
1202 self["DNSInfo_Text"].setForegroundColorNum(0)
1203 self["shortcutsgreen_restart"].setEnabled(False)
1204 self["shortcutsgreen"].setEnabled(False)
1205 self["shortcutsyellow"].setEnabled(True)
1206 self["updown_actions"].setEnabled(False)
1207 self["key_yellow"].setText("")
1208 self["key_green"].setText("")
1209 self.steptimer = True
1210 self.nextStepTimer.start(1000)
1213 self["infoshortcuts"].setEnabled(True)
1214 self["shortcuts"].setEnabled(False)
1215 if self.activebutton == 1: # Adapter Check
1216 self["InfoText"].setText(_("This test detects your configured Wireless LAN-Adapter."))
1217 self["InfoTextBorder"].show()
1218 self["InfoText"].show()
1219 self["key_red"].setText(_("Back"))
1220 if self.activebutton == 2: #LAN Check
1221 self["InfoText"].setText(_("This test checks whether a network cable is connected to your Wireless LAN-Adapter."))
1222 self["InfoTextBorder"].show()
1223 self["InfoText"].show()
1224 self["key_red"].setText(_("Back"))
1225 if self.activebutton == 3: #DHCP Check
1226 self["InfoText"].setText(_("This test checks whether your Wireless LAN Adapter is set up for automatic IP Address configuration with DHCP.\nIf you get a \"disabled\" message:\n - then your Wireless LAN Adapter is configured for manual IP Setup\n- verify thay you have entered correct IP informations in the AdapterSetup dialog.\nIf you get an \"enabeld\" message:\n-verify that you have a configured and working DHCP Server in your network."))
1227 self["InfoTextBorder"].show()
1228 self["InfoText"].show()
1229 self["key_red"].setText(_("Back"))
1230 if self.activebutton == 4: # IP Check
1231 self["InfoText"].setText(_("This test checks whether a valid IP Address is found for your LAN Adapter.\nIf you get a \"unconfirmed\" message:\n- no valid IP Address was found\n- please check your DHCP, cabling and adapter setup"))
1232 self["InfoTextBorder"].show()
1233 self["InfoText"].show()
1234 self["key_red"].setText(_("Back"))
1235 if self.activebutton == 5: # DNS Check
1236 self["InfoText"].setText(_("This test checks for configured Nameservers.\nIf you get a \"unconfirmed\" message:\n- please check your DHCP, cabling and Adapter setup\n- if you configured your Nameservers manually please verify your entries in the \"Nameserver\" Configuration"))
1237 self["InfoTextBorder"].show()
1238 self["InfoText"].show()
1239 self["key_red"].setText(_("Back"))
1240 if self.activebutton == 6: # Edit Settings
1241 self.session.open(WlanConfig,self.iface)
1242 self["shortcuts"].setEnabled(True)
1243 self["infoshortcuts"].setEnabled(False)
1245 def KeyYellow(self):
1247 self["shortcutsgreen_restart"].setEnabled(True)
1248 self["shortcutsgreen"].setEnabled(False)
1249 self["shortcutsyellow"].setEnabled(False)
1250 self["key_green"].setText(_("Restart test"))
1251 self["key_yellow"].setText("")
1252 self.steptimer = False
1253 self.nextStepTimer.stop()
1255 def layoutFinished(self):
1256 self.setTitle(_("Network test: ") + iNetwork.getFriendlyAdapterName(self.iface) )
1257 self["shortcutsyellow"].setEnabled(False)
1258 self["AdapterInfo_OK"].hide()
1259 self["NetworkInfo_Check"].hide()
1260 self["DhcpInfo_Check"].hide()
1261 self["IPInfo_Check"].hide()
1262 self["DNSInfo_Check"].hide()
1263 self["EditSettings_Text"].hide()
1264 self["EditSettingsButton"].hide()
1265 self["InfoText"].hide()
1266 self["InfoTextBorder"].hide()
1267 self["key_yellow"].setText("")
1269 def setLabels(self):
1270 self["Adaptertext"] = MultiColorLabel(_("LAN Adapter"))
1271 self["Adapter"] = MultiColorLabel()
1272 self["AdapterInfo"] = MultiPixmap()
1273 self["AdapterInfo_Text"] = MultiColorLabel(_("Show Info"))
1274 self["AdapterInfo_OK"] = Pixmap()
1276 if self.iface in iNetwork.wlan_interfaces:
1277 self["Networktext"] = MultiColorLabel(_("Wireless Network"))
1279 self["Networktext"] = MultiColorLabel(_("Local Network"))
1281 self["Network"] = MultiColorLabel()
1282 self["NetworkInfo"] = MultiPixmap()
1283 self["NetworkInfo_Text"] = MultiColorLabel(_("Show Info"))
1284 self["NetworkInfo_Check"] = MultiPixmap()
1286 self["Dhcptext"] = MultiColorLabel(_("DHCP"))
1287 self["Dhcp"] = MultiColorLabel()
1288 self["DhcpInfo"] = MultiPixmap()
1289 self["DhcpInfo_Text"] = MultiColorLabel(_("Show Info"))
1290 self["DhcpInfo_Check"] = MultiPixmap()
1292 self["IPtext"] = MultiColorLabel(_("IP Address"))
1293 self["IP"] = MultiColorLabel()
1294 self["IPInfo"] = MultiPixmap()
1295 self["IPInfo_Text"] = MultiColorLabel(_("Show Info"))
1296 self["IPInfo_Check"] = MultiPixmap()
1298 self["DNStext"] = MultiColorLabel(_("Nameserver"))
1299 self["DNS"] = MultiColorLabel()
1300 self["DNSInfo"] = MultiPixmap()
1301 self["DNSInfo_Text"] = MultiColorLabel(_("Show Info"))
1302 self["DNSInfo_Check"] = MultiPixmap()
1304 self["EditSettings_Text"] = MultiColorLabel(_("Edit settings"))
1305 self["EditSettingsButton"] = MultiPixmap()
1307 self["key_red"] = StaticText(_("Close"))
1308 self["key_green"] = StaticText(_("Start test"))
1309 self["key_yellow"] = StaticText(_("Stop test"))
1311 self["InfoTextBorder"] = Pixmap()
1312 self["InfoText"] = Label()
1314 def NetworkStatedataAvail(self,data):
1316 self["IP"].setForegroundColorNum(2)
1317 self["IP"].setText(_("confirmed"))
1318 self["IPInfo_Check"].setPixmapNum(0)
1320 self["IP"].setForegroundColorNum(1)
1321 self["IP"].setText(_("unconfirmed"))
1322 self["IPInfo_Check"].setPixmapNum(1)
1323 self["IPInfo_Check"].show()
1324 self["IPInfo_Text"].setForegroundColorNum(1)
1325 self.steptimer = True
1326 self.nextStepTimer.start(3000)
1328 def DNSLookupdataAvail(self,data):
1330 self["DNS"].setForegroundColorNum(2)
1331 self["DNS"].setText(_("confirmed"))
1332 self["DNSInfo_Check"].setPixmapNum(0)
1334 self["DNS"].setForegroundColorNum(1)
1335 self["DNS"].setText(_("unconfirmed"))
1336 self["DNSInfo_Check"].setPixmapNum(1)
1337 self["DNSInfo_Check"].show()
1338 self["DNSInfo_Text"].setForegroundColorNum(1)
1339 self["EditSettings_Text"].show()
1340 self["EditSettingsButton"].setPixmapNum(1)
1341 self["EditSettings_Text"].setForegroundColorNum(2) # active
1342 self["EditSettingsButton"].show()
1343 self["key_yellow"].setText("")
1344 self["key_green"].setText(_("Restart test"))
1345 self["shortcutsgreen"].setEnabled(False)
1346 self["shortcutsgreen_restart"].setEnabled(True)
1347 self["shortcutsyellow"].setEnabled(False)
1348 self["updown_actions"].setEnabled(True)
1349 self.activebutton = 6
1351 def getInfoCB(self,status):
1352 if status is not None:
1353 if status.startswith("No Connection") or status.startswith("Not-Associated") or status == False:
1354 self["Network"].setForegroundColorNum(1)
1355 self["Network"].setText(_("disconnected"))
1356 self["NetworkInfo_Check"].setPixmapNum(1)
1357 self["NetworkInfo_Check"].show()
1359 self["Network"].setForegroundColorNum(2)
1360 self["Network"].setText(_("connected"))
1361 self["NetworkInfo_Check"].setPixmapNum(0)
1362 self["NetworkInfo_Check"].show()
1365 iNetwork.stopLinkStateConsole()
1366 iNetwork.stopDNSConsole()
1368 def AccessPointInfo(self,iface):
1369 cmd = "iwconfig %s"%iface
1370 self.iwconfigConsole = Console()
1371 self.iwconfigConsole.ePopen(cmd,self.readAP,self.getInfoCB)
1373 def readAP(self,result,retval,extra_args):
1374 (callback) = extra_args
1375 self.apState = False
1376 if self.iwconfigConsole is not None:
1378 self.iwconfigConsole = None
1379 for content in result.splitlines():
1380 if 'Access Point' in content:
1381 self.apState = content.strip().split('Access Point: ')[1]
1382 callback(self.apState)
1384 callback(self.apState)
1386 class Wlanstatus(Screen):
1388 <screen name="Wlanstatus" position="209,48" size="865,623" title="Wireless Network Configuration..." flags="wfNoBorder" backgroundColor="transparent">
1389 <ePixmap pixmap="Vu_HD/Bg_EPG_view.png" zPosition="-1" position="0,0" size="865,623" alphatest="on" />
1390 <ePixmap pixmap="Vu_HD/menu/ico_title_Setup.png" position="32,41" size="40,40" alphatest="blend" transparent="1" />
1391 <eLabel text="Wireless Network Status..." position="90,50" size="600,32" font="Semiboldit;32" foregroundColor="#5d5d5d" backgroundColor="#27b5b9bd" transparent="1" />
1392 <ePixmap pixmap="Vu_HD/icons/clock.png" position="750,55" zPosition="1" size="20,20" alphatest="blend" />
1393 <widget source="global.CurrentTime" render="Label" position="770,57" zPosition="1" size="50,20" font="Regular;20" foregroundColor="#1c1c1c" backgroundColor="#27d9dee2" halign="right" transparent="1">
1394 <convert type="ClockToText">Format:%H:%M</convert>
1396 <ePixmap pixmap="Vu_HD/buttons/red.png" position="45,98" size="25,25" alphatest="blend" />
1397 <widget source="key_red" render="Label" position="66,97" zPosition="1" size="150,25" font="Regular;20" halign="center" valign="center" backgroundColor="darkgrey" foregroundColor="#1c1c1c" transparent="1" />
1398 <widget source="status" render="Label" position="110,200" size="650,400" transparent="1" font="Regular;20" foregroundColor="#1c1c1c" backgroundColor="#27d9dee2" zPosition="1" />
1400 def __init__(self, session,iface):
1401 Screen.__init__(self,session)
1402 self.session = session
1404 self["status"] = StaticText(_("Wait a moment..."))
1405 self["key_red"] = StaticText(_("Close"))
1406 self["OkCancelActions"] = ActionMap(["ShortcutActions", "SetupActions" ],
1409 "cancel": self.close,
1414 def readstatus(self):
1415 self.wlanstatus = Console()
1416 cmd1 = "iwconfig "+self.iface
1417 self.wlanstatus.ePopen(cmd1, self.iwconfigfinnished,self.statusdisplay)
1419 def iwconfigfinnished(self, result, retval,extra_args):
1421 (statecallback) = extra_args
1422 if self.wlanstatus is not None:
1424 statecallback(result)
1431 def statusdisplay(self,data):
1433 self["status"].setText(_("No information..."))
1435 self["status"].setText(data)
1440 def openconfig(session, **kwargs):
1441 session.open(WlanSelection)
1443 def selSetup(menuid, **kwargs):
1444 if menuid != "system":
1447 return [(_("Wireless LAN Setup"), openconfig, "wlansetup_config", 80)]
1449 def Plugins(**kwargs):
1450 return PluginDescriptor(name=_("Wireless LAN Setup"), description="Wireless LAN Setup", where = PluginDescriptor.WHERE_MENU, fnc=selSetup);
1451 # return [PluginDescriptor(name = "Fancontrols", description = "check Fan Control settings", where = PluginDescriptor.WHERE_AUTOSTART, fnc = setfancontrol),
1452 # PluginDescriptor(name=_("Wireless LAN Setup"), description="Fan Control", where = PluginDescriptor.WHERE_MENU, fnc=selSetup)]