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, NetworkAdapterTest
9 from Screens.NetworkSetup import NameserverSetup
10 from Components.Sources.StaticText import StaticText
11 from Components.Sources.Boolean import Boolean
12 from Components.Sources.List import List
13 from Components.Label import Label,MultiColorLabel
14 from Components.Pixmap import Pixmap,MultiPixmap
15 from Components.MenuList import MenuList
16 from Components.config import config, ConfigYesNo, ConfigIP, NoSave, ConfigText, ConfigPassword, ConfigSelection, getConfigListEntry, ConfigNothing
17 from Components.config import ConfigInteger, ConfigSubsection
18 from Components.ConfigList import ConfigListScreen
19 from Components.PluginComponent import plugins
20 from Components.MultiContent import MultiContentEntryText, MultiContentEntryPixmapAlphaTest
21 from Components.ActionMap import ActionMap, NumberActionMap, HelpableActionMap
22 from Components.Console import Console
23 from Tools.Directories import resolveFilename, SCOPE_PLUGINS, SCOPE_CURRENT_SKIN
24 from Tools.LoadPixmap import LoadPixmap
25 from Plugins.Plugin import PluginDescriptor
26 from enigma import eTimer, ePoint, eSize, RT_HALIGN_LEFT, eListboxPythonMultiContent, gFont
27 from os import path as os_path, system as os_system, unlink
28 from re import compile as re_compile, search as re_search
29 from Tools.Directories import fileExists
32 class WlanSelection(Screen):
34 <screen name="WlanSelection" position="209,48" size="865,623" title="Wireless Network Selection..." flags="wfNoBorder" backgroundColor="transparent">
35 <ePixmap pixmap="Vu_HD/Bg_EPG_view.png" zPosition="-1" position="0,0" size="865,623" alphatest="on" />
36 <ePixmap pixmap="Vu_HD/menu/ico_title_Setup.png" position="32,41" size="40,40" alphatest="blend" transparent="1" />
37 <eLabel text="Wireless Network Selection..." position="90,50" size="600,32" font="Semiboldit;32" foregroundColor="#5d5d5d" backgroundColor="#27b5b9bd" transparent="1" />
38 <ePixmap pixmap="Vu_HD/icons/clock.png" position="750,55" zPosition="1" size="20,20" alphatest="blend" />
39 <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">
40 <convert type="ClockToText">Format:%H:%M</convert>
42 <ePixmap pixmap="Vu_HD/buttons/red.png" position="45,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 <ePixmap pixmap="Vu_HD/border_menu.png" position="120,140" zPosition="-1" size="342,358" transparent="1" alphatest="blend" />
45 <widget name="menulist" position="130,150" size="322,338" transparent="1" backgroundColor="#27d9dee2" zPosition="10" scrollbarMode="showOnDemand" />
48 def __init__(self, session):
49 Screen.__init__(self,session)
50 self.mainmenu = self.getWlandevice()
51 self["menulist"] = MenuList(self.mainmenu)
52 self["key_red"] = StaticText(_("Close"))
53 self["OkCancelActions"] = ActionMap(["ShortcutActions", "SetupActions" ],
61 ifaces=self["menulist"].getCurrent()[1]
65 self.session.open(WlanSetup,ifaces)
68 def getWlandevice(self):
70 for x in iNetwork.getAdapterList():
71 if x.startswith('eth'):
73 list.append((iNetwork.getFriendlyAdapterName(x),x))
75 # self.adapters = [(iNetwork.getFriendlyAdapterName(x),x) for x in iNetwork.getAdapterList()]
77 # return self.adapters
81 class WlanSetup(Screen,HelpableScreen):
83 <screen name="WlanSetup" position="209,48" size="865,623" title="Wireless Network Configuration..." flags="wfNoBorder" backgroundColor="transparent">
84 <ePixmap pixmap="Vu_HD/Bg_EPG_view.png" zPosition="-1" position="0,0" size="865,623" alphatest="on" />
85 <ePixmap pixmap="Vu_HD/menu/ico_title_Setup.png" position="32,41" size="40,40" alphatest="blend" transparent="1" />
86 <eLabel text="Wireless Network Configuration..." position="90,50" size="600,32" font="Semiboldit;32" foregroundColor="#5d5d5d" backgroundColor="#27b5b9bd" transparent="1" />
87 <ePixmap pixmap="Vu_HD/icons/clock.png" position="750,55" zPosition="1" size="20,20" alphatest="blend" />
88 <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">
89 <convert type="ClockToText">Format:%H:%M</convert>
91 <ePixmap pixmap="Vu_HD/buttons/red.png" position="45,98" size="25,25" alphatest="blend" />
92 <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" />
93 <ePixmap pixmap="Vu_HD/border_menu.png" position="120,140" zPosition="-1" size="342,358" transparent="1" alphatest="blend" />
94 <widget name="menulist" position="130,150" size="322,338" transparent="1" backgroundColor="#27d9dee2" zPosition="10" scrollbarMode="showOnDemand" />
96 def __init__(self, session, ifaces):
97 Screen.__init__(self, session)
98 HelpableScreen.__init__(self)
99 self.session = session
101 self.restartLanRef = None
102 self.LinkState = None
103 self.mainmenu = self.MakeMenu()
104 self["menulist"] = MenuList(self.mainmenu)
105 self["key_red"] = StaticText(_("Close"))
106 self["description"] = StaticText()
107 self["IFtext"] = StaticText()
108 self["IF"] = StaticText()
109 self["Statustext"] = StaticText()
110 self["statuspic"] = MultiPixmap()
111 self["statuspic"].hide()
113 self.oktext = _("Press OK on your remote control to continue.")
114 self.reboottext = _("Your STB will restart after pressing OK on your remote control.")
115 self.errortext = _("No working wireless network interface found.\n Please verify that you have attached a compatible WLAN device or enable your local network interface.")
117 self["WizardActions"] = HelpableActionMap(self, "WizardActions",
119 "up": (self.up, _("move up to previous entry")),
120 "down": (self.down, _("move down to next entry")),
121 "left": (self.left, _("move up to first entry")),
122 "right": (self.right, _("move down to last entry")),
125 self["OkCancelActions"] = HelpableActionMap(self, "OkCancelActions",
127 "cancel": (self.close, _("exit networkadapter setup menu")),
128 "ok": (self.ok, _("select menu entry")),
131 self["ColorActions"] = HelpableActionMap(self, "ColorActions",
133 "red": (self.close, _("exit networkadapter setup menu")),
136 self["actions"] = NumberActionMap(["WizardActions","ShortcutActions"],
147 self["menulist"].up()
149 self["menulist"].down()
151 self["menulist"].pageUp()
153 self["menulist"].pageDown()
155 if self["menulist"].getCurrent()[1] == 'setting':
156 self.session.openWithCallback(self.checklist, WlanConfig, self.iface)
157 elif self["menulist"].getCurrent()[1] == 'scanap':
158 self.session.open(WlanScanAp, self.iface)
159 elif self["menulist"].getCurrent()[1] == 'dns':
160 self.session.open(NameserverSetup)
161 elif self["menulist"].getCurrent()[1] == 'status':
162 self.session.open(Wlanstatus, self.iface)
163 elif self["menulist"].getCurrent()[1] == 'test':
164 self.session.openWithCallback(self.checklist,NetworkAdapterTest,self.iface)
165 elif self["menulist"].getCurrent()[1] == 'restart':
166 self.session.openWithCallback(self.restartNet, MessageBox, (_("Are you sure you want to restart your network interfaces?\n\n") + self.oktext ) )
169 self["menulist"].setList(self.MakeMenu())
173 menu.append((_("Adapter settings"), "setting"))
174 menu.append((_("Scan Wireless AP"), "scanap"))
175 menu.append((_("Nameserver settings"), "dns"))
176 if iNetwork.getAdapterAttribute(self.iface, "up"):
177 menu.append((_("Show WLAN Status"), "status"))
178 menu.append((_("Network test"), "test"))
179 menu.append((_("Restart network"), "restart"))
183 def restartNet(self,ret = False):
185 os_system('/etc/init.d/networking restart')
186 # self.updateStatusbar()
187 # self.onLayoutFinish.append(self.layoutFinished)
188 # self.onClose.append(self.cleanup)
190 wlanconfig = ConfigSubsection()
191 wlanconfig.usedevice = ConfigSelection(default = "off", choices = [
192 ("off", _("off")), ("on", _("on"))])
193 wlanconfig.usedhcp = ConfigSelection(default = "off", choices = [
194 ("off", _("no")), ("on", _("yes"))])
195 wlanconfig.essid = ConfigSelection(default = "none", choices = ["none"])
196 wlanconfig.encrypt = ConfigSelection(default = "off", choices = [
197 ("off", _("no")), ("on", _("yes"))])
198 wlanconfig.method = ConfigSelection(default = "wep", choices = [
199 ("wep", _("WEP")), ("wpa", _("WPA")), ("wpa2", _("WPA2")),("wpa/wpa2", _("WPA/WPA2"))])
200 wlanconfig.keytype = ConfigSelection(default = "ascii", choices = [
201 ("ascii", _("ASCII")), ("hex", _("HEX"))])
202 wlanconfig.key = ConfigText(default = "XXXXXXXX", visible_width = 50, fixed_size = False)
203 wlanconfig.usegateway = ConfigSelection(default = "off", choices = [
204 ("off", _("no")), ("on", _("yes"))])
205 wlanconfig.ip = ConfigIP([0,0,0,0])
206 wlanconfig.netmask = ConfigIP([0,0,0,0])
207 wlanconfig.gateway = ConfigIP([0,0,0,0])
210 class WlanConfig(Screen, ConfigListScreen, HelpableScreen):
212 <screen name="WlanConfig" position="209,48" size="865,623" title="Wireless Network Configuration..." flags="wfNoBorder" backgroundColor="transparent">
213 <ePixmap pixmap="Vu_HD/Bg_EPG_view.png" zPosition="-1" position="0,0" size="865,623" alphatest="on" />
214 <ePixmap pixmap="Vu_HD/menu/ico_title_Setup.png" position="32,41" size="40,40" alphatest="blend" transparent="1" />
215 <eLabel text="Wireless Network Configuration..." position="90,50" size="600,32" font="Semiboldit;32" foregroundColor="#5d5d5d" backgroundColor="#27b5b9bd" transparent="1" />
216 <ePixmap pixmap="Vu_HD/icons/clock.png" position="750,55" zPosition="1" size="20,20" alphatest="blend" />
217 <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">
218 <convert type="ClockToText">Format:%H:%M</convert>
220 <ePixmap pixmap="Vu_HD/buttons/red.png" position="45,98" size="25,25" alphatest="blend" />
221 <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" />
222 <ePixmap pixmap="Vu_HD/border_menu.png" position="120,140" zPosition="-1" size="342,358" transparent="1" alphatest="blend" />
223 <widget name="config" position="130,150" size="322,338" transparent="1" backgroundColor="#27d9dee2" zPosition="10" scrollbarMode="showOnDemand" />
224 <eLabel text="IP Address : " position="500,160" size="200,26" font="Semiboldit;22" foregroundColor="#5d5d5d" backgroundColor="#27b5b9bd" transparent="1" />
225 <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" />
226 <eLabel text="NetMask : " position="500,220" size="200,26" font="Semiboldit;22" foregroundColor="#5d5d5d" backgroundColor="#27b5b9bd" transparent="1" />
227 <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" />
228 <eLabel text="Gateway : " position="500,280" size="200,26" font="Semiboldit;22" foregroundColor="#5d5d5d" backgroundColor="#27b5b9bd" transparent="1" />
229 <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" />
231 def __init__(self, session, iface):
232 Screen.__init__(self,session)
233 self.session = session
235 self["key_red"] = StaticText(_("Close"))
236 self["ipaddress"] = StaticText(_("[ N/A ]"))
237 self["netmask"] = StaticText(_("[ N/A ]"))
238 self["gateway"] = StaticText(_("[ N/A ]"))
239 self["OkCancelActions"] = ActionMap(["ShortcutActions", "SetupActions" ],
242 "cancel": self.close,
247 self.scan_ssid = None
254 self.wlanscanap = None
255 ConfigListScreen.__init__(self, self.list,session = self.session)
260 ConfigListScreen.keyLeft(self)
264 ConfigListScreen.keyRight(self)
269 if self["config"].isChanged():
270 self.session.openWithCallback(self.confirmactive, MessageBox, (_("Are you sure you want to restart your network interfaces?\n") ) )
272 def confirmactive(self, ret = False):
276 num_configured_if = len(iNetwork.getConfiguredAdapters())
277 if num_configured_if >= 1:
278 if num_configured_if == 1 and self.iface in iNetwork.getConfiguredAdapters():
281 self.session.openWithCallback(self.saveif, MessageBox, (_("Are you sure you want to deactive another network interfaces?\n") ) )
285 def saveif(self,ret = False):
286 self["OkCancelActions"].setEnabled(False)
287 self["config_actions"].setEnabled(False)
289 configuredInterfaces = iNetwork.getConfiguredAdapters()
290 for interface in configuredInterfaces:
291 if interface == self.iface:
293 iNetwork.setAdapterAttribute(interface, "up", False)
294 iNetwork.deactivateInterface(interface)
295 wpafd = open("/etc/wpa_supplicant.conf","w")
297 contents = "#WPA Supplicant Configuration by enigma2\n"
298 contents += "ctrl_interface=/var/run/wpa_supplicant\n"
299 contents += "eapol_version=1\n"
300 contents += "fast_reauth=1\n"
301 contents += "ap_scan=1\n"
302 contents += "network={\n"
303 contents += "\tssid=\""+wlanconfig.essid.value+"\"\n"
304 contents += "\tscan_ssid=0\n"
305 if wlanconfig.encrypt.value == "on":
306 if wlanconfig.method.value =="wep":
307 contents += "\tkey_mgmt=NONE\n"
308 contents += "\twep_key0="
309 elif wlanconfig.method.value == "wpa":
310 contents += "\tkey_mgmt=WPA-PSK\n"
311 contents += "\tproto=WPA\n"
312 contents += "\tpairwise=CCMP TKIP\n"
313 contents += "\tgroup=CCMP TKIP\n"
315 elif wlanconfig.method.value == "wpa2":
316 contents += "\tkey_mgmt=WPA-PSK\n"
317 contents += "\tproto=WPA RSN\n"
318 contents += "\tpairwise=CCMP TKIP\n"
319 contents += "\tgroup=CCMP TKIP\n"
321 elif wlanconfig.method.value == "wpa/wpa2":
322 contents += "\tkey_mgmt=WPA-PSK\n"
323 contents += "\tproto=WPA WPA2\n"
324 contents += "\tpairwise=CCMP TKIP\n"
325 contents += "\tgroup=CCMP TKIP\n"
327 if wlanconfig.keytype.value == "ascii":
328 contents += "\""+wlanconfig.key.value+"\"\n"
330 contents += wlanconfig.key.value+"\n"
332 contents += "\tkey_mgmt=NONE\n"
334 print "content = \n"+contents
335 wpafd.write(contents)
337 iffd = open("/etc/network/interfaces","r")
341 data = iffd.readline()
344 if data.startswith('iface '+self.iface) or data.startswith('auto '+self.iface):
346 data = iffd.readline()
348 elif not data.startswith('auto lo') and data.startswith('auto '):
349 if ret == True or data[5:] not in iNetwork.getConfiguredAdapters():
350 data = iffd.readline()
352 if status == 1 and data.startswith('iface ') or data.startswith('auto '):
358 data = iffd.readline()
360 iffd = open("/etc/network/interfaces","w")
362 if prev_content == "":
363 prev_content = "# automatically generated by enigma2\n"
364 prev_content += "# do Not change manually!\n\n"
365 prev_content += "auto lo\n"
366 prev_content += "iface lo inet loopback\n\n"
367 iffd.write(prev_content)
368 if wlanconfig.usedevice.value=="on":
369 iNetwork.setAdapterAttribute(self.iface, "up", True)
370 contents = "auto "+self.iface+"\n"
371 contents += "iface "+self.iface+" inet "
372 if wlanconfig.usedhcp.value =="on":
373 iNetwork.setAdapterAttribute(self.iface, "dhcp", True)
376 iNetwork.setAdapterAttribute(self.iface, "dhcp", False)
377 contents +="static\n"
378 print wlanconfig.ip.value
379 iNetwork.setAdapterAttribute(self.iface, "ip", wlanconfig.ip.value)
380 iNetwork.setAdapterAttribute(self.iface, "netmask", wlanconfig.netmask.value)
381 contents +="\taddress "+ self.formatip(wlanconfig.ip.value)+"\n"
382 contents +="\tnetmask "+ self.formatip(wlanconfig.netmask.value)+"\n"
383 if wlanconfig.usegateway.value == "on":
384 iNetwork.setAdapterAttribute(self.iface, "gateway", wlanconfig.gateway.value)
385 contents +="\tgateway "+ self.formatip(wlanconfig.gateway.value)+"\n"
386 contents += "\n\tpre-up /usr/sbin/wpa_supplicant -i"+self.iface+" -c/etc/wpa_supplicant.conf -B -D"+iNetwork.detectWlanModule(self.iface)+"\n"
387 contents += "\tpost-down wpa_cli terminate\n\n"
390 iNetwork.setAdapterAttribute(self.iface, "up", False)
391 iNetwork.deactivateInterface(self.iface)
392 iffd.write(next_content)
394 self.restartNetwork(self.ConfigDataApply)
395 self.configurationmsg = self.session.openWithCallback(self.WlanConfigClose, MessageBox, _("Please wait for activation of your network configuration..."), type = MessageBox.TYPE_INFO, enable_input = False)
397 def restartNetwork(self,callback=None):
398 self.restartConsole = Console()
399 cmd="/etc/init.d/networking restart"
400 self.restartConsole.ePopen(cmd, self.restartNetworkFinished, callback)
402 def restartNetworkFinished(self, result, retval,extra_args):
403 ( callback ) = extra_args
404 if callback is not None:
407 def ConfigDataApply(self,ret):
409 iNetwork.getInterfaces(self.configurationmsgClose)
411 def configurationmsgClose(self,ret):
413 self.configurationmsg.close(True)
415 def WlanConfigClose(self,ret):
419 def formatip(self, iplist):
423 result = str(iplist[0])+"."+str(iplist[1])+"."+str(iplist[2])+"."+str(iplist[3])
428 def createConfig(self):
429 # wlanconfig.essid = ConfigSelection(default = "none", choices = ["maruap3","maruap2","none"])
432 self.usedeviceEntry = getConfigListEntry(_("Use Device"), wlanconfig.usedevice)
433 self.usedhcpEntry = getConfigListEntry(_("Use DHCP"), wlanconfig.usedhcp)
434 self.essidEntry = getConfigListEntry(_("ESSID"), wlanconfig.essid)
435 self.encryptEntry = getConfigListEntry(_("Encrypt"), wlanconfig.encrypt)
436 self.methodEntry = getConfigListEntry(_("Method"), wlanconfig.method)
437 self.keytypeEntry = getConfigListEntry(_("Key Type"), wlanconfig.keytype)
438 self.keyEntry = getConfigListEntry(_("KEY"), wlanconfig.key)
440 self.ipEntry = getConfigListEntry(_("IP"), wlanconfig.ip)
441 self.netmaskEntry = getConfigListEntry(_("NetMask"), wlanconfig.netmask)
443 self.usegatewayEntry = getConfigListEntry(_("Use Gateway"), wlanconfig.usegateway)
444 self.gatewayEntry = getConfigListEntry(_("Gateway"), wlanconfig.gateway)
446 self.tlist.append( self.usedeviceEntry )
447 if wlanconfig.usedevice.value is "on":
448 self.tlist.append( self.usedhcpEntry )
449 if wlanconfig.usedhcp.value is "off":
450 self.tlist.append(self.ipEntry)
451 self.tlist.append(self.netmaskEntry)
452 self.tlist.append(self.usegatewayEntry)
453 if wlanconfig.usegateway.value is "on":
454 self.tlist.append(self.gatewayEntry)
455 self.tlist.append( self.essidEntry )
456 self.tlist.append( self.encryptEntry )
457 if wlanconfig.encrypt.value is "on" :
458 self.tlist.append( self.methodEntry )
459 self.tlist.append( self.keytypeEntry )
460 self.tlist.append( self.keyEntry )
462 self["config"].list = self.tlist
463 self["config"].l.setList(self.tlist)
464 if not self.selectionChanged in self["config"].onSelectionChanged:
465 self["config"].onSelectionChanged.append(self.selectionChanged)
467 def readifSetting(self):
469 if fileExists("/etc/wpa_supplicant.conf"):
470 wpafd = open("/etc/wpa_supplicant.conf","r")
472 data = wpafd.readline()
476 data = wpafd.readline()
478 if data.startswith('ssid=') and len(data) > 6:
479 self.ssid = data[6:-2]
480 elif data.startswith('scan_ssid=') and len(data) > 10:
481 self.scan_ssid = data[10:-1]
482 elif data.startswith('key_mgmt=') and len(data) > 9:
483 self.key_mgmt = data[9:-1]
484 elif data.startswith('proto=') and len(data) > 6:
485 self.proto = data[6:-1]
486 elif data.startswith('wep_key0="') and len(data) > 11:
488 self.wep_key = data[10:-2]
489 elif data.startswith('wep_key0=') and len(data) > 9:
491 self.wep_key = data[9:-1]
492 elif data.startswith('psk="') and len(data) > 6:
494 self.wep_key = data[5:-2]
495 elif data.startswith('psk=') and len(data) > 4:
497 self.wep_key = data[4:-1]
499 data = wpafd.readline()
500 print self.ssid,self.scan_ssid,self.key_mgmt,self.proto,self.key_type,self.wep_key
510 def setfromread(self):
511 iNetwork.getInterfaces()
513 if iNetwork.getAdapterAttribute(self.iface, "up") == True:
517 wlanconfig.usedevice = ConfigSelection(default=default_tmp, choices = [
518 ("off", _("off")), ("on", _("on"))])
519 if iNetwork.getAdapterAttribute(self.iface, "dhcp"):
523 wlanconfig.usedhcp = ConfigSelection(default=default_tmp, choices = [
524 ("off", _("no")), ("on", _("yes"))])
525 wlanconfig .ip = ConfigIP(default=iNetwork.getAdapterAttribute(self.iface, "ip")) or [0,0,0,0]
526 wlanconfig.netmask = ConfigIP(default=iNetwork.getAdapterAttribute(self.iface, "netmask") or [255,0,0,0])
527 if iNetwork.getAdapterAttribute(self.iface, "gateway"):
531 wlanconfig.usegateway = ConfigSelection(default = default_tmp, choices = [
532 ("off", _("no")), ("on", _("yes"))])
533 wlanconfig.gateway = ConfigIP(default=iNetwork.getAdapterAttribute(self.iface, "gateway") or [0,0,0,0])
535 self["ipaddress"] = StaticText(_(self.formatip(iNetwork.getAdapterAttribute(self.iface, "ip"))))
536 self["netmask"] = StaticText(_(self.formatip(iNetwork.getAdapterAttribute(self.iface, "netmask"))))
537 self["gateway"] = StaticText(_(self.formatip(iNetwork.getAdapterAttribute(self.iface, "gateway"))))
539 if self.wep_key is not None:
543 wlanconfig.encrypt = ConfigSelection(default = default_tmp, choices = [
544 ("off", _("no")), ("on", _("yes"))])
546 if self.key_mgmt=="NONE":
548 elif self.key_mgmt == "WPA-PSK":
549 if self.proto == "WPA":
551 elif self.proto == "WPA RSN":
553 elif self.proto == "WPA WPA2":
554 default_tmp = "wpa/wpa2"
560 wlanconfig.method = ConfigSelection(default = default_tmp, choices = [
561 ("wep", _("WEP")), ("wpa", _("WPA")), ("wpa2", _("WPA2")),("wpa/wpa2", _("WPA/WPA2"))])
563 if self.key_type == 0:
566 default_tmp = "ascii"
567 wlanconfig.keytype = ConfigSelection(default = default_tmp, choices = [
568 ("ascii", _("ASCII")), ("hex", _("HEX"))])
569 default_tmp = self.wep_key or "XXXXXXXX"
570 wlanconfig.key = ConfigText(default = default_tmp, visible_width = 50, fixed_size = False)
572 if wlanconfig.usedevice.value is "on":
579 if self["config"].getCurrent() == self.usedeviceEntry :
580 if wlanconfig.usedevice.value is "on":
583 if iNetwork.getAdapterAttribute(self.iface, "up"):
584 iNetwork.setAdapterAttribute(self.iface, "up",False)
585 iNetwork.deactivateInterface(self.iface)
587 elif self["config"].getCurrent() == self.encryptEntry or self["config"].getCurrent() == self.usedhcpEntry \
588 or self["config"].getCurrent() == self.usegatewayEntry :
591 def selectionChanged(self):
592 current = self["config"].getCurrent()
596 self["OkCancelActions"].setEnabled(False) #chang
597 self["config_actions"].setEnabled(False) #chang
598 if iNetwork.getAdapterAttribute(self.iface, "up") is not True:
599 os_system('ifconfig '+self.iface+" up")
600 iNetwork.setAdapterAttribute(self.iface, "up",True)
602 self.wlanscanap = Console()
603 cmd1 = "iwlist "+self.iface+" scan"
605 self.wlanscanap.ePopen(cmd1, self.iwlistfinnished,self.aplistparse)
607 def iwlistfinnished(self, result, retval,extra_args):
608 (statecallback) = extra_args
610 if self.wlanscanap is not None:
612 self.wlanscanap = None
613 content = result.splitlines()
614 first = content[0].split()
619 if completed == True:
620 statecallback(result)
629 def aplistparse(self,data):
632 # self.session.openWithCallback(self.createConfig ,MessageBox, _("Scan AP Failed"), MessageBox.TYPE_INFO,2)
633 self.session.open(MessageBox, _("Scan AP Failed"), MessageBox.TYPE_INFO,2)
636 list = data.splitlines()
637 # print 'aplistparse',list
640 if xx.startswith('ESSID:') and len(xx)>8:
641 self.aplist.append(xx[7:-1])
642 # print 'rlist\n',rlist
643 if len(self.aplist) ==0:
644 self.aplist.append('none')
645 # print 'aplist', self.aplist
647 for x in self.aplist:
650 print 'defaultap',defaultap,self.aplist,selectap
651 if selectap is None and self.ssid is not None and self.ssid in self.aplist:
652 wlanconfig.essid = ConfigSelection(default=self.ssid,choices = self.aplist)
653 elif defaultap == selectap and selectap is not None:
654 wlanconfig.essid = ConfigSelection(default=selectap,choices = self.aplist)
656 wlanconfig.essid = ConfigSelection(choices = self.aplist)
659 self["OkCancelActions"].setEnabled(True)
660 self["config_actions"].setEnabled(True)
661 if iNetwork.getAdapterAttribute(self.iface, "up"):
664 os_system('ifconfig '+self.iface+" down")
666 class WlanScanAp(Screen):
668 <screen name="WlanScanAp" position="209,48" size="865,623" title="Wireless Network Scan..." flags="wfNoBorder" backgroundColor="transparent">
669 <ePixmap pixmap="Vu_HD/Bg_EPG_view.png" zPosition="-1" position="0,0" size="865,623" alphatest="on" />
670 <ePixmap pixmap="Vu_HD/menu/ico_title_Setup.png" position="32,41" size="40,40" alphatest="blend" transparent="1" />
671 <eLabel text="Wireless Network Scan..." position="90,50" size="600,32" font="Semiboldit;32" foregroundColor="#5d5d5d" backgroundColor="#27b5b9bd" transparent="1" />
672 <ePixmap pixmap="Vu_HD/icons/clock.png" position="750,55" zPosition="1" size="20,20" alphatest="blend" />
673 <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">
674 <convert type="ClockToText">Format:%H:%M</convert>
676 <ePixmap pixmap="Vu_HD/buttons/red.png" position="45,98" size="25,25" alphatest="blend" />
677 <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" />
678 <ePixmap pixmap="Vu_HD/border_menu.png" position="120,140" zPosition="-1" size="342,358" transparent="1" alphatest="blend" />
679 <widget name="menulist" position="130,150" size="322,338" transparent="1" backgroundColor="#27d9dee2" zPosition="10" scrollbarMode="showOnDemand" />
680 <widget source="ap_strength" render="Label" position="490,250" zPosition="1" size="300,30" font="Regular;20" halign="center" valign="center" backgroundColor="#27b5b9bd" foregroundColor="#1c1c1c" transparent="1" />
681 <widget source="ap_quality" render="Label" position="490,280" zPosition="1" size="300,30" font="Regular;20" halign="center" valign="center" backgroundColor="#27b5b9bd" foregroundColor="#1c1c1c" transparent="1" />
683 def __init__(self, session, iface):
684 Screen.__init__(self,session)
685 self.session = session
691 self.wlanscanap = None
692 self["OkCancelActions"] = ActionMap(["ShortcutActions", "SetupActions","WizardActions" ],
695 "cancel": self.close,
703 print 'getAplist',self.mainmenu
704 self["menulist"] = MenuList(self.mainmenu)
705 self["key_red"] = StaticText(_("Close"))
706 self["ap_strength"] = StaticText(_("Scanning AP List.."))
707 self["ap_quality"] = StaticText(_("Wait a moment"))
711 self["menulist"].pageUp()
712 if len(self.ap_extra) > self["menulist"].getSelectionIndex():
713 self["ap_strength"].setText((self.ap_extra[self["menulist"].getSelectionIndex()])+"%")
714 self["ap_quality"].setText(self.ap_quality[self["menulist"].getSelectionIndex()])
717 self["menulist"].pageDown()
718 if len(self.ap_extra) > self["menulist"].getSelectionIndex():
719 self["ap_strength"].setText((self.ap_extra[self["menulist"].getSelectionIndex()])+"%")
720 self["ap_quality"].setText(self.ap_quality[self["menulist"].getSelectionIndex()])
723 self["menulist"].up()
724 if len(self.ap_extra) > self["menulist"].getSelectionIndex():
725 self["ap_strength"].setText((self.ap_extra[self["menulist"].getSelectionIndex()])+"%")
726 self["ap_quality"].setText(self.ap_quality[self["menulist"].getSelectionIndex()])
729 self["menulist"].down()
730 if len(self.ap_extra) > self["menulist"].getSelectionIndex():
731 self["ap_strength"].setText((self.ap_extra[self["menulist"].getSelectionIndex()])+"%")
732 self["ap_quality"].setText(self.ap_quality[self["menulist"].getSelectionIndex()])
736 ifaces=self["menulist"].getCurrent()
737 print 'select', ifaces
742 self["OkCancelActions"].setEnabled(False)
743 if iNetwork.getAdapterAttribute(self.iface, "up"):
746 os_system('ifconfig '+self.iface+" up")
748 self.wlanscanap = Console()
749 cmd1 = "iwlist "+self.iface+" scan"
750 self.wlanscanap.ePopen(cmd1, self.iwlistfinnished,self.aplistparse)
752 def iwlistfinnished(self, result, retval,extra_args):
753 (statecallback) = extra_args
755 if self.wlanscanap is not None:
757 self.wlanscanap = None
758 content = result.splitlines()
759 first = content[0].split()
764 if completed == True:
765 statecallback(result)
774 def aplistparse(self,data):
778 self.session.open(MessageBox, _("Scan AP Failed"), MessageBox.TYPE_INFO,2)
779 self["menulist"].setList(rlist)
781 list = data.splitlines()
784 if xx.startswith('ESSID:') and len(xx)>8:
785 rlist.append(xx[7:-1])
787 if essid_on == 1 and xx.startswith('Extra:SignalStrength=') and len(xx)>21:
788 self.ap_extra.append(xx[6:])
789 if essid_on == 1 and xx.startswith('%,LinkQuality:') and len(xx)>14:
790 self.ap_quality.append(xx[2:])
793 self["menulist"].setList(rlist)
794 if len(self.ap_extra) > 0 and len(self.ap_quality) > 0:
795 self["ap_strength"].setText((self.ap_extra[self["menulist"].getSelectionIndex()])+"%")
796 self["ap_quality"].setText(self.ap_quality[self["menulist"].getSelectionIndex()])
798 self["ap_strength"].setText("Select AP")
799 self["ap_quality"].setText(" ")
800 if iNetwork.getAdapterAttribute(self.iface, "up"):
803 os_system('ifconfig '+self.iface+" down")
804 self["OkCancelActions"].setEnabled(True)
806 class NetworkAdapterTest(Screen):
807 def __init__(self, session,iface):
808 Screen.__init__(self, session)
810 self.oldInterfaceState = iNetwork.getAdapterAttribute(self.iface, "up")
812 self.onClose.append(self.cleanup)
813 self.onHide.append(self.cleanup)
815 self["updown_actions"] = NumberActionMap(["WizardActions","ShortcutActions"],
819 "up": lambda: self.updownhandler('up'),
820 "down": lambda: self.updownhandler('down'),
824 self["shortcuts"] = ActionMap(["ShortcutActions","WizardActions"],
829 self["infoshortcuts"] = ActionMap(["ShortcutActions","WizardActions"],
831 "red": self.closeInfo,
832 "back": self.closeInfo,
834 self["shortcutsgreen"] = ActionMap(["ShortcutActions"],
836 "green": self.KeyGreen,
838 self["shortcutsgreen_restart"] = ActionMap(["ShortcutActions"],
840 "green": self.KeyGreenRestart,
842 self["shortcutsyellow"] = ActionMap(["ShortcutActions"],
844 "yellow": self.KeyYellow,
847 self["shortcutsgreen_restart"].setEnabled(False)
848 self["updown_actions"].setEnabled(False)
849 self["infoshortcuts"].setEnabled(False)
850 self.onClose.append(self.delTimer)
851 self.onLayoutFinish.append(self.layoutFinished)
852 self.steptimer = False
854 self.activebutton = 0
855 self.nextStepTimer = eTimer()
856 self.nextStepTimer.callback.append(self.nextStepTimerFire)
859 if self.oldInterfaceState is False:
860 iNetwork.setAdapterAttribute(self.iface, "up", self.oldInterfaceState)
861 iNetwork.deactivateInterface(self.iface)
865 self["shortcuts"].setEnabled(True)
866 self["infoshortcuts"].setEnabled(False)
867 self["InfoText"].hide()
868 self["InfoTextBorder"].hide()
869 self["key_red"].setText(_("Close"))
873 del self.nextStepTimer
875 def nextStepTimerFire(self):
876 self.nextStepTimer.stop()
877 self.steptimer = False
880 def updownhandler(self,direction):
881 if direction == 'up':
882 if self.activebutton >=2:
883 self.activebutton -= 1
885 self.activebutton = 6
886 self.setActiveButton(self.activebutton)
887 if direction == 'down':
888 if self.activebutton <=5:
889 self.activebutton += 1
891 self.activebutton = 1
892 self.setActiveButton(self.activebutton)
894 def setActiveButton(self,button):
896 self["EditSettingsButton"].setPixmapNum(0)
897 self["EditSettings_Text"].setForegroundColorNum(0)
898 self["NetworkInfo"].setPixmapNum(0)
899 self["NetworkInfo_Text"].setForegroundColorNum(1)
900 self["AdapterInfo"].setPixmapNum(1) # active
901 self["AdapterInfo_Text"].setForegroundColorNum(2) # active
903 self["AdapterInfo_Text"].setForegroundColorNum(1)
904 self["AdapterInfo"].setPixmapNum(0)
905 self["DhcpInfo"].setPixmapNum(0)
906 self["DhcpInfo_Text"].setForegroundColorNum(1)
907 self["NetworkInfo"].setPixmapNum(1) # active
908 self["NetworkInfo_Text"].setForegroundColorNum(2) # active
910 self["NetworkInfo"].setPixmapNum(0)
911 self["NetworkInfo_Text"].setForegroundColorNum(1)
912 self["IPInfo"].setPixmapNum(0)
913 self["IPInfo_Text"].setForegroundColorNum(1)
914 self["DhcpInfo"].setPixmapNum(1) # active
915 self["DhcpInfo_Text"].setForegroundColorNum(2) # active
917 self["DhcpInfo"].setPixmapNum(0)
918 self["DhcpInfo_Text"].setForegroundColorNum(1)
919 self["DNSInfo"].setPixmapNum(0)
920 self["DNSInfo_Text"].setForegroundColorNum(1)
921 self["IPInfo"].setPixmapNum(1) # active
922 self["IPInfo_Text"].setForegroundColorNum(2) # active
924 self["IPInfo"].setPixmapNum(0)
925 self["IPInfo_Text"].setForegroundColorNum(1)
926 self["EditSettingsButton"].setPixmapNum(0)
927 self["EditSettings_Text"].setForegroundColorNum(0)
928 self["DNSInfo"].setPixmapNum(1) # active
929 self["DNSInfo_Text"].setForegroundColorNum(2) # active
931 self["DNSInfo"].setPixmapNum(0)
932 self["DNSInfo_Text"].setForegroundColorNum(1)
933 self["EditSettingsButton"].setPixmapNum(1) # active
934 self["EditSettings_Text"].setForegroundColorNum(2) # active
935 self["AdapterInfo"].setPixmapNum(0)
936 self["AdapterInfo_Text"].setForegroundColorNum(1)
955 self.steptimer = True
956 self.nextStepTimer.start(3000)
957 self["key_yellow"].setText(_("Stop test"))
960 self["Adapter"].setText(iNetwork.getFriendlyAdapterName(self.iface))
961 self["Adapter"].setForegroundColorNum(2)
962 self["Adaptertext"].setForegroundColorNum(1)
963 self["AdapterInfo_Text"].setForegroundColorNum(1)
964 self["AdapterInfo_OK"].show()
965 self.steptimer = True
966 self.nextStepTimer.start(3000)
969 self["Networktext"].setForegroundColorNum(1)
970 self["Network"].setText(_("Please wait..."))
971 self.AccessPointInfo(self.iface)
972 self["NetworkInfo_Text"].setForegroundColorNum(1)
973 self.steptimer = True
974 self.nextStepTimer.start(3000)
977 self["Dhcptext"].setForegroundColorNum(1)
978 if iNetwork.getAdapterAttribute(self.iface, 'dhcp') is True:
979 self["Dhcp"].setForegroundColorNum(2)
980 self["Dhcp"].setText(_("enabled"))
981 self["DhcpInfo_Check"].setPixmapNum(0)
983 self["Dhcp"].setForegroundColorNum(1)
984 self["Dhcp"].setText(_("disabled"))
985 self["DhcpInfo_Check"].setPixmapNum(1)
986 self["DhcpInfo_Check"].show()
987 self["DhcpInfo_Text"].setForegroundColorNum(1)
988 self.steptimer = True
989 self.nextStepTimer.start(3000)
992 self["IPtext"].setForegroundColorNum(1)
993 self["IP"].setText(_("Please wait..."))
994 iNetwork.checkNetworkState(self.NetworkStatedataAvail)
997 self.steptimer = False
998 self.nextStepTimer.stop()
999 self["DNStext"].setForegroundColorNum(1)
1000 self["DNS"].setText(_("Please wait..."))
1001 iNetwork.checkDNSLookup(self.DNSLookupdataAvail)
1004 self["shortcutsgreen"].setEnabled(False)
1005 self["shortcutsyellow"].setEnabled(True)
1006 self["updown_actions"].setEnabled(False)
1007 self["key_yellow"].setText("")
1008 self["key_green"].setText("")
1009 self.steptimer = True
1010 self.nextStepTimer.start(1000)
1012 def KeyGreenRestart(self):
1014 self.layoutFinished()
1015 self["Adapter"].setText((""))
1016 self["Network"].setText((""))
1017 self["Dhcp"].setText((""))
1018 self["IP"].setText((""))
1019 self["DNS"].setText((""))
1020 self["AdapterInfo_Text"].setForegroundColorNum(0)
1021 self["NetworkInfo_Text"].setForegroundColorNum(0)
1022 self["DhcpInfo_Text"].setForegroundColorNum(0)
1023 self["IPInfo_Text"].setForegroundColorNum(0)
1024 self["DNSInfo_Text"].setForegroundColorNum(0)
1025 self["shortcutsgreen_restart"].setEnabled(False)
1026 self["shortcutsgreen"].setEnabled(False)
1027 self["shortcutsyellow"].setEnabled(True)
1028 self["updown_actions"].setEnabled(False)
1029 self["key_yellow"].setText("")
1030 self["key_green"].setText("")
1031 self.steptimer = True
1032 self.nextStepTimer.start(1000)
1035 self["infoshortcuts"].setEnabled(True)
1036 self["shortcuts"].setEnabled(False)
1037 if self.activebutton == 1: # Adapter Check
1038 self["InfoText"].setText(_("This test detects your configured LAN-Adapter."))
1039 self["InfoTextBorder"].show()
1040 self["InfoText"].show()
1041 self["key_red"].setText(_("Back"))
1042 if self.activebutton == 2: #LAN Check
1043 self["InfoText"].setText(_("This test checks whether a network cable is connected to your LAN-Adapter.\nIf you get a \"disconnected\" message:\n- verify that a network cable is attached\n- verify that the cable is not broken"))
1044 self["InfoTextBorder"].show()
1045 self["InfoText"].show()
1046 self["key_red"].setText(_("Back"))
1047 if self.activebutton == 3: #DHCP Check
1048 self["InfoText"].setText(_("This test checks whether your LAN Adapter is set up for automatic IP Address configuration with DHCP.\nIf you get a \"disabled\" message:\n - then your 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."))
1049 self["InfoTextBorder"].show()
1050 self["InfoText"].show()
1051 self["key_red"].setText(_("Back"))
1052 if self.activebutton == 4: # IP Check
1053 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"))
1054 self["InfoTextBorder"].show()
1055 self["InfoText"].show()
1056 self["key_red"].setText(_("Back"))
1057 if self.activebutton == 5: # DNS Check
1058 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"))
1059 self["InfoTextBorder"].show()
1060 self["InfoText"].show()
1061 self["key_red"].setText(_("Back"))
1062 if self.activebutton == 6: # Edit Settings
1063 self.session.open(WlanConfig,self.iface)
1064 self["shortcuts"].setEnabled(True)
1065 self["infoshortcuts"].setEnabled(False)
1067 def KeyYellow(self):
1069 self["shortcutsgreen_restart"].setEnabled(True)
1070 self["shortcutsgreen"].setEnabled(False)
1071 self["shortcutsyellow"].setEnabled(False)
1072 self["key_green"].setText(_("Restart test"))
1073 self["key_yellow"].setText("")
1074 self.steptimer = False
1075 self.nextStepTimer.stop()
1077 def layoutFinished(self):
1078 self.setTitle(_("Network test: ") + iNetwork.getFriendlyAdapterName(self.iface) )
1079 self["shortcutsyellow"].setEnabled(False)
1080 self["AdapterInfo_OK"].hide()
1081 self["NetworkInfo_Check"].hide()
1082 self["DhcpInfo_Check"].hide()
1083 self["IPInfo_Check"].hide()
1084 self["DNSInfo_Check"].hide()
1085 self["EditSettings_Text"].hide()
1086 self["EditSettingsButton"].hide()
1087 self["InfoText"].hide()
1088 self["InfoTextBorder"].hide()
1089 self["key_yellow"].setText("")
1091 def setLabels(self):
1092 self["Adaptertext"] = MultiColorLabel(_("LAN Adapter"))
1093 self["Adapter"] = MultiColorLabel()
1094 self["AdapterInfo"] = MultiPixmap()
1095 self["AdapterInfo_Text"] = MultiColorLabel(_("Show Info"))
1096 self["AdapterInfo_OK"] = Pixmap()
1098 if self.iface in iNetwork.wlan_interfaces:
1099 self["Networktext"] = MultiColorLabel(_("Wireless Network"))
1101 self["Networktext"] = MultiColorLabel(_("Local Network"))
1103 self["Network"] = MultiColorLabel()
1104 self["NetworkInfo"] = MultiPixmap()
1105 self["NetworkInfo_Text"] = MultiColorLabel(_("Show Info"))
1106 self["NetworkInfo_Check"] = MultiPixmap()
1108 self["Dhcptext"] = MultiColorLabel(_("DHCP"))
1109 self["Dhcp"] = MultiColorLabel()
1110 self["DhcpInfo"] = MultiPixmap()
1111 self["DhcpInfo_Text"] = MultiColorLabel(_("Show Info"))
1112 self["DhcpInfo_Check"] = MultiPixmap()
1114 self["IPtext"] = MultiColorLabel(_("IP Address"))
1115 self["IP"] = MultiColorLabel()
1116 self["IPInfo"] = MultiPixmap()
1117 self["IPInfo_Text"] = MultiColorLabel(_("Show Info"))
1118 self["IPInfo_Check"] = MultiPixmap()
1120 self["DNStext"] = MultiColorLabel(_("Nameserver"))
1121 self["DNS"] = MultiColorLabel()
1122 self["DNSInfo"] = MultiPixmap()
1123 self["DNSInfo_Text"] = MultiColorLabel(_("Show Info"))
1124 self["DNSInfo_Check"] = MultiPixmap()
1126 self["EditSettings_Text"] = MultiColorLabel(_("Edit settings"))
1127 self["EditSettingsButton"] = MultiPixmap()
1129 self["key_red"] = StaticText(_("Close"))
1130 self["key_green"] = StaticText(_("Start test"))
1131 self["key_yellow"] = StaticText(_("Stop test"))
1133 self["InfoTextBorder"] = Pixmap()
1134 self["InfoText"] = Label()
1136 def NetworkStatedataAvail(self,data):
1138 self["IP"].setForegroundColorNum(2)
1139 self["IP"].setText(_("confirmed"))
1140 self["IPInfo_Check"].setPixmapNum(0)
1142 self["IP"].setForegroundColorNum(1)
1143 self["IP"].setText(_("unconfirmed"))
1144 self["IPInfo_Check"].setPixmapNum(1)
1145 self["IPInfo_Check"].show()
1146 self["IPInfo_Text"].setForegroundColorNum(1)
1147 self.steptimer = True
1148 self.nextStepTimer.start(3000)
1150 def DNSLookupdataAvail(self,data):
1152 self["DNS"].setForegroundColorNum(2)
1153 self["DNS"].setText(_("confirmed"))
1154 self["DNSInfo_Check"].setPixmapNum(0)
1156 self["DNS"].setForegroundColorNum(1)
1157 self["DNS"].setText(_("unconfirmed"))
1158 self["DNSInfo_Check"].setPixmapNum(1)
1159 self["DNSInfo_Check"].show()
1160 self["DNSInfo_Text"].setForegroundColorNum(1)
1161 self["EditSettings_Text"].show()
1162 self["EditSettingsButton"].setPixmapNum(1)
1163 self["EditSettings_Text"].setForegroundColorNum(2) # active
1164 self["EditSettingsButton"].show()
1165 self["key_yellow"].setText("")
1166 self["key_green"].setText(_("Restart test"))
1167 self["shortcutsgreen"].setEnabled(False)
1168 self["shortcutsgreen_restart"].setEnabled(True)
1169 self["shortcutsyellow"].setEnabled(False)
1170 self["updown_actions"].setEnabled(True)
1171 self.activebutton = 6
1173 def getInfoCB(self,status):
1174 if status is not None:
1175 if status == "No Connection" or status == "Not-Associated" or status == False:
1176 self["Network"].setForegroundColorNum(1)
1177 self["Network"].setText(_("disconnected"))
1178 self["NetworkInfo_Check"].setPixmapNum(1)
1179 self["NetworkInfo_Check"].show()
1181 self["Network"].setForegroundColorNum(2)
1182 self["Network"].setText(_("connected"))
1183 self["NetworkInfo_Check"].setPixmapNum(0)
1184 self["NetworkInfo_Check"].show()
1187 iNetwork.stopLinkStateConsole()
1188 iNetwork.stopDNSConsole()
1190 def AccessPointInfo(self,iface):
1191 cmd = "iwconfig %s"%iface
1192 self.iwconfigConsole = Console()
1193 self.iwconfigConsole.ePopen(cmd,self.readAP,self.getInfoCB)
1195 def readAP(self,result,retval,extra_args):
1196 (callback) = extra_args
1197 self.apState = False
1198 if self.iwconfigConsole is not None:
1200 self.iwconfigConsole = None
1201 content=result.splitlines()
1203 if 'Access Point' in x:
1204 self.apState = x[x.find('Access Point')+len('Access Point'):].strip(':').strip()
1205 callback(self.apState)
1207 class Wlanstatus(Screen):
1209 <screen name="Wlanstatus" position="209,48" size="865,623" title="Wireless Network Status..." flags="wfNoBorder" backgroundColor="transparent">
1210 <ePixmap pixmap="Vu_HD/Bg_EPG_view.png" zPosition="-1" position="0,0" size="865,623" alphatest="on" />
1211 <ePixmap pixmap="Vu_HD/menu/ico_title_Setup.png" position="32,41" size="40,40" alphatest="blend" transparent="1" />
1212 <eLabel text="Wireless Network Status..." position="90,50" size="600,32" font="Semiboldit;32" foregroundColor="#5d5d5d" backgroundColor="#27b5b9bd" transparent="1" />
1213 <ePixmap pixmap="Vu_HD/icons/clock.png" position="750,55" zPosition="1" size="20,20" alphatest="blend" />
1214 <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">
1215 <convert type="ClockToText">Format:%H:%M</convert>
1217 <ePixmap pixmap="Vu_HD/buttons/red.png" position="45,98" size="25,25" alphatest="blend" />
1218 <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" />
1219 <widget source="status" render="Label" position="110,200" size="650,400" transparent="1" font="Regular;22" foregroundColor="#1c1c1c" backgroundColor="#27d9dee2" zPosition="1" />
1221 def __init__(self, session,iface):
1222 Screen.__init__(self,session)
1223 self.session = session
1226 self["status"] = StaticText(_("Wait a moment..."))
1227 self["key_red"] = StaticText(_("Close"))
1228 self["OkCancelActions"] = ActionMap(["ShortcutActions", "SetupActions" ],
1231 "cancel": self.close,
1236 def readstatus(self):
1237 self.wlanstatus = Console()
1238 cmd1 = "iwconfig "+self.iface
1239 self.wlanstatus.ePopen(cmd1, self.iwconfigfinnished,self.statusdisplay)
1241 def iwconfigfinnished(self, result, retval,extra_args):
1243 (statecallback) = extra_args
1244 if self.wlanstatus is not None:
1246 statecallback(result)
1253 def statusdisplay(self,data):
1256 self["status"].setText(_("No information..."))
1258 self["status"].setText(data)
1263 def openconfig(session, **kwargs):
1264 # session.open(WlanSetup)
1265 session.open(WlanSelection)
1267 def selSetup(menuid, **kwargs):
1268 if menuid != "system":
1271 return [(_("Wireless LAN Setup"), openconfig, "wlansetup_config", 80)]
1273 def Plugins(**kwargs):
1274 return PluginDescriptor(name=_("Wireless LAN Setup"), description="Fan Control", where = PluginDescriptor.WHERE_MENU, fnc=selSetup);
1275 # return [PluginDescriptor(name = "Fancontrols", description = "check Fan Control settings", where = PluginDescriptor.WHERE_AUTOSTART, fnc = setfancontrol),
1276 # PluginDescriptor(name=_("Wireless LAN Setup"), description="Fan Control", where = PluginDescriptor.WHERE_MENU, fnc=selSetup)]