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 # print len(self["menulist"].list)
73 if len(self["menulist"].list) == 0:
74 self.session.open(MessageBox, (_("Can not find any WirelessLan Module\n")),MessageBox.TYPE_ERROR,5 )
76 ifaces=self["menulist"].getCurrent()[1]
80 self.session.open(WlanSetup,ifaces)
82 def getWlandevice(self):
84 for x in iNetwork.getAdapterList():
85 if x.startswith('eth'):
87 list.append((self.getAdapterDescription(x) + " (%s)"%x,x))
90 def getAdapterDescription(self, iface):
92 return _("Internal LAN adapter.")
94 classdir = "/sys/class/net/" + iface + "/device/"
95 driverdir = "/sys/class/net/" + iface + "/device/driver/"
96 if os_path.exists(classdir):
97 files = listdir(classdir)
99 if os_path.realpath(driverdir).endswith('rtw_usb_drv'):
100 return _("Realtak")+ " " + _("WLAN adapter.")
101 elif os_path.realpath(driverdir).endswith('ath_pci'):
102 return _("Atheros")+ " " + _("WLAN adapter.")
103 elif os_path.realpath(driverdir).endswith('zd1211b'):
104 return _("Zydas")+ " " + _("WLAN adapter.")
105 elif os_path.realpath(driverdir).endswith('rt73'):
106 return _("Ralink")+ " " + _("WLAN adapter.")
107 elif os_path.realpath(driverdir).endswith('rt73usb'):
108 return _("Ralink")+ " " + _("WLAN adapter.")
110 return str(os_path.basename(os_path.realpath(driverdir))) + " " + _("WLAN adapter")
112 return _("Unknown network adapter.")
114 class WlanSetup(Screen,HelpableScreen):
116 <screen name="WlanSetup" position="209,48" size="865,623" title="Wireless Network Configuration..." flags="wfNoBorder" backgroundColor="transparent">
117 <ePixmap pixmap="Vu_HD/Bg_EPG_view.png" zPosition="-1" position="0,0" size="865,623" alphatest="on" />
118 <ePixmap pixmap="Vu_HD/menu/ico_title_Setup.png" position="32,41" size="40,40" alphatest="blend" transparent="1" />
119 <eLabel text="Wireless Network Setup Menu..." position="90,50" size="600,32" font="Semiboldit;32" foregroundColor="#5d5d5d" backgroundColor="#27b5b9bd" transparent="1" />
120 <ePixmap pixmap="Vu_HD/icons/clock.png" position="750,55" zPosition="1" size="20,20" alphatest="blend" />
121 <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">
122 <convert type="ClockToText">Format:%H:%M</convert>
124 <ePixmap pixmap="Vu_HD/buttons/red.png" position="45,98" size="25,25" alphatest="blend" />
125 <ePixmap pixmap="Vu_HD/buttons/green.png" position="240,98" size="25,25" alphatest="blend" />
126 <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" />
127 <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" />
128 <ePixmap pixmap="Vu_HD/border_menu.png" position="120,140" zPosition="-1" size="342,358" transparent="1" alphatest="blend" />
129 <widget name="menulist" position="130,150" size="322,338" transparent="1" backgroundColor="#27d9dee2" zPosition="10" scrollbarMode="showOnDemand" />
130 <widget source="description" render="Label" position="500,140" size="280,360" font="Regular;19" halign="center" valign="center" backgroundColor="#c5c9cc" transparent="1"/>
132 def __init__(self, session, ifaces):
133 Screen.__init__(self, session)
134 HelpableScreen.__init__(self)
135 self.session = session
137 self.restartLanRef = None
138 self.LinkState = None
139 self.mainmenu = self.MakeMenu()
140 self["menulist"] = MenuList(self.mainmenu)
141 self["key_red"] = StaticText(_("Close"))
142 self["key_green"] = StaticText(_("Select"))
143 self["description"] = StaticText()
144 self["IFtext"] = StaticText()
145 self["IF"] = StaticText()
146 self["Statustext"] = StaticText()
147 self["statuspic"] = MultiPixmap()
148 self["statuspic"].hide()
149 self.onLayoutFinish.append(self.loadDescription)
151 self.oktext = _("Press OK on your remote control to continue.")
153 self["WizardActions"] = HelpableActionMap(self, "WizardActions",
155 "up": (self.up, _("move up to previous entry")),
156 "down": (self.down, _("move down to next entry")),
157 "left": (self.left, _("move up to first entry")),
158 "right": (self.right, _("move down to last entry")),
161 self["OkCancelActions"] = HelpableActionMap(self, "OkCancelActions",
163 "cancel": (self.close, _("exit networkadapter setup menu")),
164 "ok": (self.ok, _("select menu entry")),
167 self["ColorActions"] = HelpableActionMap(self, "ColorActions",
169 "red": (self.close, _("exit networkadapter setup menu")),
170 "green": (self.ok, _("select menu entry")),
173 self["actions"] = NumberActionMap(["WizardActions","ShortcutActions"],
184 def loadDescription(self):
185 if self["menulist"].getCurrent()[1] == 'setting':
186 self["description"].setText(_("Edit the network configuration of your STB.\n" ) + self.oktext )
187 if self["menulist"].getCurrent()[1] == 'scanap':
188 self["description"].setText(_("Scan your network for wireless access points and connect to them using your selected wireless device.\n" ) + self.oktext )
189 if self["menulist"].getCurrent()[1] == 'dns':
190 self["description"].setText(_("Edit the Nameserver configuration of your STB.\n" ) + self.oktext )
191 if self["menulist"].getCurrent()[1] == 'status':
192 self["description"].setText(_("Shows the state of your wireless LAN connection.\n" ) + self.oktext )
193 if self["menulist"].getCurrent()[1] == 'test':
194 self["description"].setText(_("Test the network configuration of your STB.\n" ) + self.oktext )
195 if self["menulist"].getCurrent()[1] == 'restart':
196 self["description"].setText(_("Restart your network connection and interfaces.\n" ) + self.oktext )
199 self["menulist"].up()
200 self.loadDescription()
203 self["menulist"].down()
204 self.loadDescription()
207 self["menulist"].pageUp()
208 self.loadDescription()
211 self["menulist"].pageDown()
212 self.loadDescription()
215 if self["menulist"].getCurrent()[1] == 'setting':
216 self.session.openWithCallback(self.checklist, WlanConfig, self.iface)
217 elif self["menulist"].getCurrent()[1] == 'scanap':
218 self.session.open(WlanScanAp, self.iface)
219 elif self["menulist"].getCurrent()[1] == 'dns':
220 self.session.open(NameserverSetup)
221 elif self["menulist"].getCurrent()[1] == 'status':
222 self.session.open(Wlanstatus, self.iface)
223 elif self["menulist"].getCurrent()[1] == 'test':
224 self.session.openWithCallback(self.checklist,NetworkAdapterTest,self.iface)
225 elif self["menulist"].getCurrent()[1] == 'restart':
226 self.session.openWithCallback(self.restartLan, MessageBox, (_("Are you sure you want to restart your network interfaces?\n\n") + self.oktext ) )
229 self["menulist"].setList(self.MakeMenu())
233 menu.append((_("Adapter settings"), "setting"))
234 menu.append((_("Scan Wireless AP"), "scanap"))
235 menu.append((_("Nameserver settings"), "dns"))
236 if iNetwork.getAdapterAttribute(self.iface, "up"):
237 menu.append((_("Show WLAN Status"), "status"))
238 menu.append((_("Network test"), "test"))
239 menu.append((_("Restart network"), "restart"))
243 def restartLan(self, ret = False):
245 iNetwork.restartNetwork(self.restartLanDataAvail)
246 self.restartLanRef = self.session.openWithCallback(self.restartfinishedCB, MessageBox, _("Please wait while your network is restarting..."), type = MessageBox.TYPE_INFO, enable_input = False)
248 def restartLanDataAvail(self, data):
250 iNetwork.getInterfaces(self.getInterfacesDataAvail)
252 def getInterfacesDataAvail(self, data):
254 self.restartLanRef.close(True)
256 def restartfinishedCB(self,data):
258 self.session.open(MessageBox, _("Finished restarting your network"), type = MessageBox.TYPE_INFO, timeout = 5, default = False)
260 wlanconfig = ConfigSubsection()
261 wlanconfig.usedevice = ConfigSelection(default = "off", choices = [
262 ("off", _("off")), ("on", _("on"))])
263 wlanconfig.usedhcp = ConfigSelection(default = "off", choices = [
264 ("off", _("no")), ("on", _("yes"))])
265 wlanconfig.essid = ConfigSelection(default = "none", choices = ["none"])
266 wlanconfig.encrypt = ConfigSelection(default = "off", choices = [
267 ("off", _("no")), ("on", _("yes"))])
268 wlanconfig.method = ConfigSelection(default = "wep", choices = [
269 ("wep", _("WEP")), ("wpa", _("WPA")), ("wpa2", _("WPA2")),("wpa/wpa2", _("WPA/WPA2"))])
270 wlanconfig.keytype = ConfigSelection(default = "ascii", choices = [
271 ("ascii", _("ASCII")), ("hex", _("HEX"))])
272 wlanconfig.key = ConfigText(default = "XXXXXXXX", visible_width = 50, fixed_size = False)
273 wlanconfig.usegateway = ConfigSelection(default = "off", choices = [
274 ("off", _("no")), ("on", _("yes"))])
275 wlanconfig.ip = ConfigIP([0,0,0,0])
276 wlanconfig.netmask = ConfigIP([0,0,0,0])
277 wlanconfig.gateway = ConfigIP([0,0,0,0])
280 class WlanConfig(Screen, ConfigListScreen, HelpableScreen):
282 <screen name="WlanConfig" position="209,48" size="865,623" title="Wireless Network Configuration..." flags="wfNoBorder" backgroundColor="transparent">
283 <ePixmap pixmap="Vu_HD/Bg_EPG_view.png" zPosition="-1" position="0,0" size="865,623" alphatest="on" />
284 <ePixmap pixmap="Vu_HD/menu/ico_title_Setup.png" position="32,41" size="40,40" alphatest="blend" transparent="1" />
285 <eLabel text="Wireless Network Configuration..." position="90,50" size="600,32" font="Semiboldit;32" foregroundColor="#5d5d5d" backgroundColor="#27b5b9bd" transparent="1" />
286 <ePixmap pixmap="Vu_HD/icons/clock.png" position="750,55" zPosition="1" size="20,20" alphatest="blend" />
287 <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">
288 <convert type="ClockToText">Format:%H:%M</convert>
290 <ePixmap pixmap="Vu_HD/buttons/red.png" position="45,98" size="25,25" alphatest="blend" />
291 <ePixmap pixmap="Vu_HD/buttons/green.png" position="240,98" size="25,25" alphatest="blend" />
292 <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" />
293 <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" />
294 <ePixmap pixmap="Vu_HD/border_menu.png" position="120,140" zPosition="-1" size="342,358" transparent="1" alphatest="blend" />
295 <widget name="config" position="130,150" size="322,338" transparent="1" backgroundColor="#27d9dee2" zPosition="10" scrollbarMode="showOnDemand" />
296 <eLabel text="IP Address : " position="500,160" size="200,26" font="Semiboldit;22" foregroundColor="#5d5d5d" backgroundColor="#27b5b9bd" transparent="1" />
297 <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" />
298 <eLabel text="NetMask : " position="500,220" size="200,26" font="Semiboldit;22" foregroundColor="#5d5d5d" backgroundColor="#27b5b9bd" transparent="1" />
299 <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" />
300 <eLabel text="Gateway : " position="500,280" size="200,26" font="Semiboldit;22" foregroundColor="#5d5d5d" backgroundColor="#27b5b9bd" transparent="1" />
301 <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" />
304 def __init__(self, session, iface):
305 Screen.__init__(self,session)
306 self.session = session
307 self["key_red"] = StaticText(_("Close"))
308 self["key_grean"] = StaticText(_("Ok"))
309 self["ipaddress"] = StaticText(_("[ N/A ]"))
310 self["netmask"] = StaticText(_("[ N/A ]"))
311 self["gateway"] = StaticText(_("[ N/A ]"))
312 self["OkCancelActions"] = ActionMap(["ShortcutActions", "SetupActions" ],
314 "ok": self.saveWlanConfig,
315 "green": self.saveWlanConfig,
316 "cancel": self.keyCancel,
317 "red": self.keyCancel,
322 self.scan_ssid = None
326 self.encryption_key = None
327 self.wlanscanap = None
328 # self.scanAPcount =5
331 ConfigListScreen.__init__(self, self.list,session = self.session)
332 self.oldInterfaceState = iNetwork.getAdapterAttribute(self.iface, "up")
333 self.readWpaSupplicantConf()
334 # iNetwork.getInterfaces()
335 self.readWlanSettings()
336 self.scanAPFailedTimer = eTimer()
337 self.scanAPFailedTimer.callback.append(self.scanAPFailed)
338 self.scanAplistTimer = eTimer()
339 self.scanAplistTimer.callback.append(self.scanApList)
340 self.Console = Console()
341 self.scanAplistTimer.start(100,True)
343 def readWlanSettings(self):
344 iNetwork.getAddrInet(self.iface,None)
345 if iNetwork.getAdapterAttribute(self.iface, "up") == True:
349 wlanconfig.usedevice = ConfigSelection(default=default_tmp, choices = [("off", _("off")), ("on", _("on"))])
351 if iNetwork.getAdapterAttribute(self.iface, "dhcp"):
355 wlanconfig.usedhcp = ConfigSelection(default=default_tmp, choices = [("off", _("no")), ("on", _("yes"))])
357 wlanconfig.ip = ConfigIP(default=iNetwork.getAdapterAttribute(self.iface, "ip")) or [0,0,0,0]
359 wlanconfig.netmask = ConfigIP(default=iNetwork.getAdapterAttribute(self.iface, "netmask") or [255,0,0,0])
360 if iNetwork.getAdapterAttribute(self.iface, "gateway"):
364 wlanconfig.usegateway = ConfigSelection(default = default_tmp, choices = [("off", _("no")), ("on", _("yes"))])
366 wlanconfig.gateway = ConfigIP(default=iNetwork.getAdapterAttribute(self.iface, "gateway") or [0,0,0,0])
368 self["ipaddress"] = StaticText(_(self.formatip(iNetwork.getAdapterAttribute(self.iface, "ip"))))
369 self["netmask"] = StaticText(_(self.formatip(iNetwork.getAdapterAttribute(self.iface, "netmask"))))
370 self["gateway"] = StaticText(_(self.formatip(iNetwork.getAdapterAttribute(self.iface, "gateway"))))
372 if self.encryption_key is not None:
376 wlanconfig.encrypt = ConfigSelection(default = default_tmp, choices = [("off", _("no")), ("on", _("yes"))])
378 if self.key_mgmt=="NONE":
380 elif self.key_mgmt == "WPA-PSK":
381 if self.proto == "WPA":
383 elif self.proto == "RSN":
385 elif self.proto in ( "WPA RSN", "WPA WPA2"):
386 default_tmp = "wpa/wpa2"
392 wlanconfig.method = ConfigSelection(default = default_tmp, choices = [
393 ("wep", _("WEP")), ("wpa", _("WPA")), ("wpa2", _("WPA2")),("wpa/wpa2", _("WPA/WPA2"))])
395 if self.key_type == 0:
398 default_tmp = "ascii"
399 wlanconfig.keytype = ConfigSelection(default = default_tmp, choices = [
400 ("ascii", _("ASCII")), ("hex", _("HEX"))])
401 default_tmp = self.encryption_key or "XXXXXXXX"
402 wlanconfig.key = ConfigText(default = default_tmp, visible_width = 50, fixed_size = False)
404 def readWpaSupplicantConf(self):
406 if fileExists("/etc/wpa_supplicant.conf"):
407 wpafd = open("/etc/wpa_supplicant.conf","r")
409 data = wpafd.readline()
411 # print "####readWpaSupplicantConf, data : ",data
414 data = wpafd.readline()
416 if data.startswith('ssid=') and len(data) > 6:
417 self.ssid = data[6:-2]
418 elif data.startswith('ap_scan=') :
419 self.ap_scan = data[8:]
420 # print "####readWpaSupplicantConf, ap_scan : ",self.ap_scan
421 elif data.startswith('scan_ssid=') and len(data) > 10:
422 self.scan_ssid = data[10:-1]
423 elif data.startswith('key_mgmt=') and len(data) > 9:
424 self.key_mgmt = data[9:-1]
425 elif data.startswith('proto=') and len(data) > 6:
426 self.proto = data[6:-1]
427 elif data.startswith('wep_key0="') and len(data) > 11:
428 self.key_type = 1 # ascii
429 self.encryption_key = data[10:-2]
430 elif data.startswith('wep_key0=') and len(data) > 9:
431 self.key_type = 0 # hex
432 self.encryption_key = data[9:-1]
433 elif data.startswith('psk="') and len(data) > 6:
434 self.key_type = 1 # ascii
435 self.encryption_key = data[5:-2]
436 elif data.startswith('psk=') and len(data) > 4:
437 self.key_type = 0 # hex
438 self.encryption_key = data[4:-1]
439 data = wpafd.readline()
440 print self.ssid,self.scan_ssid,self.key_mgmt,self.proto,self.key_type,self.encryption_key
447 print 'failed loading wpasupplicant.conf'
449 def createConfig(self):
451 self.usedeviceEntry = getConfigListEntry(_("Use Device"), wlanconfig.usedevice)
452 self.usedhcpEntry = getConfigListEntry(_("Use DHCP"), wlanconfig.usedhcp)
453 self.essidEntry = getConfigListEntry(_("ESSID"), wlanconfig.essid)
454 self.hiddenessidEntry = getConfigListEntry(_("Input Hidden ESSID"), wlanconfig.hiddenessid)
455 self.encryptEntry = getConfigListEntry(_("Encrypt"), wlanconfig.encrypt)
456 self.methodEntry = getConfigListEntry(_("Method"), wlanconfig.method)
457 self.keytypeEntry = getConfigListEntry(_("Key Type"), wlanconfig.keytype)
458 self.keyEntry = getConfigListEntry(_("KEY"), wlanconfig.key)
460 self.ipEntry = getConfigListEntry(_("IP"), wlanconfig.ip)
461 self.netmaskEntry = getConfigListEntry(_("NetMask"), wlanconfig.netmask)
463 self.usegatewayEntry = getConfigListEntry(_("Use Gateway"), wlanconfig.usegateway)
464 self.gatewayEntry = getConfigListEntry(_("Gateway"), wlanconfig.gateway)
466 self.configList.append( self.usedeviceEntry )
467 if wlanconfig.usedevice.value is "on":
468 self.configList.append( self.usedhcpEntry )
469 if wlanconfig.usedhcp.value is "off":
470 self.configList.append(self.ipEntry)
471 self.configList.append(self.netmaskEntry)
472 self.configList.append(self.usegatewayEntry)
473 if wlanconfig.usegateway.value is "on":
474 self.configList.append(self.gatewayEntry)
475 self.configList.append( self.essidEntry )
476 # print "#### wlanconfig.essid.value : ",wlanconfig.essid.value
477 if wlanconfig.essid.value == 'Input hidden ESSID':
478 self.configList.append( self.hiddenessidEntry )
479 self.configList.append( self.encryptEntry )
480 if wlanconfig.encrypt.value is "on" :
481 self.configList.append( self.methodEntry )
482 self.configList.append( self.keytypeEntry )
483 self.configList.append( self.keyEntry )
485 self["config"].list = self.configList
486 self["config"].l.setList(self.configList)
487 # if not self.selectionChanged in self["config"].onSelectionChanged:
488 # self["config"].onSelectionChanged.append(self.selectionChanged)
490 def scanApList(self):
493 self.configurationmsg = self.session.open(MessageBox, _("Please wait for scanning AP..."), type = MessageBox.TYPE_INFO, enable_input = False)
494 cmd = "ifconfig "+self.iface+" up"
497 self.wlanscanap = Console()
498 cmd = "iwlist "+self.iface+" scan"
500 self.wlanscanap.ePopen(cmd, self.apListFinnished,self.apListParse)
502 def apListFinnished(self, result, retval,extra_args):
503 (callback) = extra_args
504 if self.wlanscanap is not None:
506 self.wlanscanap = None
507 content = result.splitlines()
508 first = content[0].split()
513 if completed == True:
520 def apListParse(self,data):
523 if self.scanAPcount >0:
524 self.configurationmsg.close(True)
525 self.scanAplistTimer.start(100,True)
528 self.configurationmsg.close(True)
529 self.scanAPFailedTimer.start(500,True)
533 # self.scanAPcount =5
535 list = data.splitlines()
538 if xx.startswith('ESSID:') and len(xx)>8:
539 self.apList.append(xx[7:-1])
540 self.apList.append('Input hidden ESSID')
541 # print "###### selectap : ",selectap
542 if selectap is not None and selectap in self.apList:
543 wlanconfig.essid = ConfigSelection(default=selectap,choices = self.apList)
544 elif self.ap_scan is not None and self.ap_scan.strip() == '2':
545 wlanconfig.essid = ConfigSelection(default='Input hidden ESSID',choices = self.apList)
546 elif self.ssid is not None and self.ssid in self.apList:
547 wlanconfig.essid = ConfigSelection(default=self.ssid,choices = self.apList)
549 wlanconfig.essid = ConfigSelection(choices = self.apList)
550 if self.ssid is not None:
551 wlanconfig.hiddenessid = ConfigText(default = self.ssid, visible_width = 50, fixed_size = False)
553 wlanconfig.hiddenessid = ConfigText(default = "<Input ESSID>", visible_width = 50, fixed_size = False)
554 self.configurationmsg.close(True)
557 def scanAPFailed(self):
558 self.session.openWithCallback(self.keyCancel ,MessageBox, _("Scan AP Failed"), MessageBox.TYPE_ERROR,10)
561 ConfigListScreen.keyLeft(self)
565 ConfigListScreen.keyRight(self)
569 if self["config"].getCurrent() == self.usedeviceEntry or self["config"].getCurrent() == self.encryptEntry \
570 or self["config"].getCurrent() == self.usedhcpEntry or self["config"].getCurrent() == self.usegatewayEntry \
571 or self["config"].getCurrent() == self.essidEntry:
574 def saveWlanConfig(self):
575 if self["config"].isChanged():
576 self.session.openWithCallback(self.checkNetworkShares, MessageBox, (_("Are you sure you want to restart your network interfaces?\n") ) )
578 def checkNetworkShares(self,ret = False):
581 # print "########## checkNetworkShares : "
583 self.Console = Console()
584 cmd = "cat /proc/mounts"
585 self.Console.ePopen(cmd, self.checkSharesFinished, self.confirmAnotherIfaces)
587 def checkSharesFinished(self, result, retval, extra_args):
588 callback = extra_args
589 print "checkMountsFinished : result : \n",result
590 networks = ['nfs','smbfs','ncp','coda']
591 for line in result.splitlines():
592 split = line.strip().split(' ',3)
593 if split[2] in networks:
594 self.session.open(MessageBox, ("NOT deconfiguring network interfaces :\n network shares still mounted\n"), type = MessageBox.TYPE_ERROR, timeout = 10)
599 def confirmAnotherIfaces(self, ret = False):
603 num_configured_if = len(iNetwork.getConfiguredAdapters())
604 if num_configured_if >= 1:
605 if num_configured_if == 1 and self.iface in iNetwork.getConfiguredAdapters():
606 self.writeWlanConfig(False)
608 self.session.openWithCallback(self.writeWlanConfig, MessageBox, (_("Are you sure you want to deactive another network interfaces?\n") ) )
610 self.writeWlanConfig(False)
612 def writeWlanConfig(self,ret = False):
614 configuredInterfaces = iNetwork.getConfiguredAdapters()
615 for interface in configuredInterfaces:
616 if interface == self.iface:
618 iNetwork.setAdapterAttribute(interface, "up", False)
619 iNetwork.deactivateInterface(interface)
620 ret=self.writeWpasupplicantConf()
622 self.session.open(MessageBox, _("wpa_supplicant.conf open error."), type = MessageBox.TYPE_ERROR, timeout = 10)
625 self.session.open(MessageBox, _("hidden ESSID empty"), type = MessageBox.TYPE_ERROR, timeout = 10)
627 iffd = open("/etc/network/interfaces","r")
631 data = iffd.readline()
634 if data.startswith('iface '+self.iface) or data.startswith('auto '+self.iface):
636 data = iffd.readline()
638 elif not data.startswith('auto lo') and data.startswith('auto '):
639 if ret == True or data[5:] not in iNetwork.getConfiguredAdapters():
640 data = iffd.readline()
642 if status == 1 and data.startswith('iface ') or data.startswith('auto '):
648 data = iffd.readline()
650 iffd = open("/etc/network/interfaces","w")
652 if prev_content == "":
653 prev_content = "# automatically generated by STB\n"
654 prev_content += "# do Not change manually!\n\n"
655 prev_content += "auto lo\n"
656 prev_content += "iface lo inet loopback\n\n"
657 iffd.write(prev_content)
658 if wlanconfig.usedevice.value=="on":
659 iNetwork.setAdapterAttribute(self.iface, "up", True)
660 contents = "auto "+self.iface+"\n"
661 contents += "iface "+self.iface+" inet "
662 if wlanconfig.usedhcp.value =="on":
663 iNetwork.setAdapterAttribute(self.iface, "dhcp", True)
666 iNetwork.setAdapterAttribute(self.iface, "dhcp", False)
667 contents +="static\n"
668 # print wlanconfig.ip.value
669 iNetwork.setAdapterAttribute(self.iface, "ip", wlanconfig.ip.value)
670 iNetwork.setAdapterAttribute(self.iface, "netmask", wlanconfig.netmask.value)
671 contents +="\taddress "+ self.formatip(wlanconfig.ip.value)+"\n"
672 contents +="\tnetmask "+ self.formatip(wlanconfig.netmask.value)+"\n"
673 if wlanconfig.usegateway.value == "on":
674 iNetwork.setAdapterAttribute(self.iface, "gateway", wlanconfig.gateway.value)
675 contents +="\tgateway "+ self.formatip(wlanconfig.gateway.value)+"\n"
676 contents += "\tpre-up wpa_supplicant -i"+self.iface+" -c/etc/wpa_supplicant.conf -B -D"+iNetwork.detectWlanModule(self.iface)+"\n"
677 contents += "\tpost-down wpa_cli terminate\n\n"
680 iNetwork.setAdapterAttribute(self.iface, "up", False)
681 iNetwork.deactivateInterface(self.iface)
682 iffd.write(next_content)
685 self.session.open(MessageBox, _("/etc/network/interfaces open error."), type = MessageBox.TYPE_ERROR, timeout = 10)
687 iNetwork.restartNetwork(self.updateCurrentInterfaces)
688 self.configurationmsg = None
689 self.configurationmsg = self.session.openWithCallback(self.configFinished, MessageBox, _("Please wait for activation of your network configuration..."), type = MessageBox.TYPE_INFO, enable_input = False)
691 def writeWpasupplicantConf(self):
692 wpafd = open("/etc/wpa_supplicant.conf","w")
694 contents = "#WPA Supplicant Configuration by STB\n"
695 contents += "ctrl_interface=/var/run/wpa_supplicant\n"
696 contents += "eapol_version=1\n"
697 contents += "fast_reauth=1\n"
699 if wlanconfig.essid.value == 'Input hidden ESSID':
700 contents += "ap_scan=2\n"
702 contents += "ap_scan=1\n"
703 contents += "network={\n"
704 if wlanconfig.essid.value == 'Input hidden ESSID':
705 if len(wlanconfig.hiddenessid.value) == 0:
708 contents += "\tssid=\""+wlanconfig.hiddenessid.value+"\"\n"
710 contents += "\tssid=\""+wlanconfig.essid.value+"\"\n"
711 contents += "\tscan_ssid=0\n"
712 if wlanconfig.encrypt.value == "on":
713 if wlanconfig.method.value =="wep":
714 contents += "\tkey_mgmt=NONE\n"
715 contents += "\twep_key0="
716 elif wlanconfig.method.value == "wpa":
717 contents += "\tkey_mgmt=WPA-PSK\n"
718 contents += "\tproto=WPA\n"
719 contents += "\tpairwise=CCMP TKIP\n"
720 contents += "\tgroup=CCMP TKIP\n"
722 elif wlanconfig.method.value == "wpa2":
723 contents += "\tkey_mgmt=WPA-PSK\n"
724 contents += "\tproto=RSN\n"
725 contents += "\tpairwise=CCMP TKIP\n"
726 contents += "\tgroup=CCMP TKIP\n"
729 contents += "\tkey_mgmt=WPA-PSK\n"
730 contents += "\tproto=WPA RSN\n"
731 contents += "\tpairwise=CCMP TKIP\n"
732 contents += "\tgroup=CCMP TKIP\n"
734 if wlanconfig.keytype.value == "ascii":
735 contents += "\""+wlanconfig.key.value+"\"\n"
737 contents += wlanconfig.key.value+"\n"
739 contents += "\tkey_mgmt=NONE\n"
741 print "content = \n"+contents
742 wpafd.write(contents)
746 self.session.open(MessageBox, _("wpa_supplicant.conf open error."), type = MessageBox.TYPE_ERROR, timeout = 10)
748 def updateCurrentInterfaces(self,ret):
750 iNetwork.getInterfaces(self.configurationMsgClose)
752 def configurationMsgClose(self,ret):
753 if ret is True and self.configurationmsg is not None:
754 self.configurationmsg.close(True)
756 def configFinished(self,data):
759 self.session.openWithCallback(self.configFinishedCB, MessageBox, _("Your network configuration has been activated."), type = MessageBox.TYPE_INFO, timeout = 10)
760 selectap = wlanconfig.essid.value
762 def configFinishedCB(self,data):
767 def formatip(self, iplist):
772 result = str(iplist[0])+"."+str(iplist[1])+"."+str(iplist[2])+"."+str(iplist[3])
779 def keyCancelConfirm(self, result):
782 if self.oldInterfaceState is False:
783 iNetwork.deactivateInterface(self.iface,self.keyCancelCB)
787 def keyCancel(self,yesno = True):
788 if self["config"].isChanged():
789 self.session.openWithCallback(self.keyCancelConfirm, MessageBox, _("Really close without saving settings?"))
791 self.keyCancelConfirm(True)
793 def keyCancelCB(self,data):
798 # def selectionChanged(self):
799 # current = self["config"].getCurrent()
802 class WlanScanAp(Screen,HelpableScreen):
804 <screen name="WlanScanAp" position="209,48" size="865,623" title="Wireless Network Configuration..." flags="wfNoBorder" backgroundColor="transparent">
805 <ePixmap pixmap="Vu_HD/Bg_EPG_view.png" zPosition="-1" position="0,0" size="865,623" alphatest="on" />
806 <ePixmap pixmap="Vu_HD/menu/ico_title_Setup.png" position="32,41" size="40,40" alphatest="blend" transparent="1" />
807 <eLabel text="Wireless Network AP Scan..." position="90,50" size="600,32" font="Semiboldit;32" foregroundColor="#5d5d5d" backgroundColor="#27b5b9bd" transparent="1" />
808 <ePixmap pixmap="Vu_HD/icons/clock.png" position="750,55" zPosition="1" size="20,20" alphatest="blend" />
809 <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">
810 <convert type="ClockToText">Format:%H:%M</convert>
812 <ePixmap pixmap="Vu_HD/buttons/red.png" position="45,98" size="25,25" alphatest="blend" />
813 <ePixmap pixmap="Vu_HD/buttons/green.png" position="240,98" size="25,25" alphatest="blend" />
814 <ePixmap pixmap="Vu_HD/buttons/blue.png" position="630,98" size="25,25" alphatest="blend" />
815 <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" />
816 <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" />
817 <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" />
818 <ePixmap pixmap="Vu_HD/border_menu.png" position="120,140" zPosition="-1" size="342,358" transparent="1" alphatest="blend" />
819 <widget name="menulist" position="130,150" size="322,338" transparent="1" backgroundColor="#27d9dee2" zPosition="10" scrollbarMode="showOnDemand" />
820 <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" />
821 <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" />
822 <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" />
823 <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" />
824 <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" />
825 <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" />
828 def __init__(self, session, iface):
829 Screen.__init__(self,session)
830 HelpableScreen.__init__(self)
831 self.session = session
833 self.wlanscanap = None
834 # self.scanAPcount = 5
839 self["WizardActions"] = HelpableActionMap(self, "WizardActions",
841 "up": (self.up, _("move up to previous entry")),
842 "down": (self.down, _("move down to next entry")),
843 "left": (self.left, _("move up to first entry")),
844 "right": (self.right, _("move down to last entry")),
847 self["OkCancelActions"] = HelpableActionMap(self, "OkCancelActions",
849 "cancel": (self.close, _("exit")),
850 "ok": (self.ok, "select AP"),
853 self["ColorActions"] = HelpableActionMap(self, "ColorActions",
855 "red": (self.close, _("exit")),
856 "green": (self.ok, "select AP"),
857 "blue": (self.startWlanConfig, "Edit Wireless settings"),
860 self["actions"] = NumberActionMap(["WizardActions","ShortcutActions"],
871 self["menulist"] = MenuList(self.SetApList)
872 self["key_red"] = StaticText(_("Close"))
873 self["key_green"] = StaticText(_("Select"))
874 self["key_blue"] = StaticText(_("EditSetting"))
875 self["Address"] = StaticText(_("Scanning AP List.."))
876 self["ESSID"] = StaticText(_("Wait a moment"))
877 self["Protocol"] = StaticText(" ")
878 self["Frequency"] = StaticText(" ")
879 self["Encryption key"] = StaticText(" ")
880 self["BitRate"] = StaticText(" ")
881 self.scanAPFailedTimer = eTimer()
882 self.scanAPFailedTimer.callback.append(self.scanAPFailed)
883 self.scanAplistTimer = eTimer()
884 self.scanAplistTimer.callback.append(self.scanApList)
885 self.scanAplistTimer.start(100,True)
888 self["menulist"].pageUp()
892 self["menulist"].pageDown()
896 self["menulist"].up()
900 self["menulist"].down()
905 selectAp=self["menulist"].getCurrent()[0]
909 def startWlanConfig(self):
911 selectAp=self["menulist"].getCurrent()[0]
913 self.session.open(WlanConfig,self.iface)
916 def scanApList(self):
917 # print "self.scanAPcount : ",self.scanAPcount
920 self.configurationmsg = self.session.open(MessageBox, _("Please wait for scanning AP..."), type = MessageBox.TYPE_INFO, enable_input = False)
922 os_system('ifconfig '+self.iface+" up")
923 self.wlanscanap = Console()
924 cmd = "iwlist "+self.iface+" scan"
926 self.wlanscanap.ePopen(cmd, self.iwlistfinnished,self.APListParse)
928 def iwlistfinnished(self, result, retval,extra_args):
929 # print "iwlistfinnished"
930 (statecallback) = extra_args
931 if self.wlanscanap is not None:
932 # print "retval = ",retval
934 self.wlanscanap = None
935 content = result.splitlines()
936 first = content[0].split()
941 if completed == True:
942 statecallback(result)
948 def APListParse(self,data):
950 if self.scanAPcount >0:
951 self.configurationmsg.close(True)
952 self.scanAplistTimer.start(100,True)
955 self.configurationmsg.close(True)
956 self.scanAPFailedTimer.start(500,True)
961 # self.scanAPcount =5
963 list = data.splitlines()
965 # print "line : ",line
966 if line.strip().startswith("Cell"): # Cell 01 - Address: 00:26:66:5C:EF:24
967 parts = line.strip().split(" ")
968 current_ap_id = int(parts[1])
969 self.apList[current_ap_id]={}
970 self.apList[current_ap_id]["Address"]=parts[4]
971 elif line.strip().startswith("ESSID"):
972 self.apList[current_ap_id]["ESSID"]=line.strip()[6:].strip('"')
973 self.SetApList.append( (self.apList[current_ap_id]["ESSID"],current_ap_id) )
974 elif line.strip().startswith("Protocol"):
975 self.apList[current_ap_id]["Protocol"]=line.strip()[9:]
976 elif line.strip().startswith("Frequency"):
977 self.apList[current_ap_id]["Frequency"]=line.strip()[10:]
978 elif line.strip().startswith("Encryption key"):
979 self.apList[current_ap_id]["Encryption key"]=line.strip()[15:]
980 elif line.strip().startswith("Bit Rates"):
981 self.apList[current_ap_id]["BitRate"]=line.strip()[10:]
983 print len(self.apList)
984 self.configurationmsg.close(True)
987 def scanAPFailed(self):
988 self.session.openWithCallback(self.ScanAPclose,MessageBox, _("Scan AP Failed"), MessageBox.TYPE_ERROR,10)
990 def displayApInfo(self):
991 if len(self.apList) >0:
992 self["menulist"].setList(self.SetApList)
993 index = self["menulist"].getCurrent()[1]
994 for key in ["Address", "ESSID", "Protocol", "Frequency", "Encryption key", "BitRate"]:
995 if self.apList[index].has_key(key):
996 self[key].setText((key+": "+self.apList[index][key]))
998 self[key].setText(("None"))
1000 self.session.openWithCallback(self.ScanAPclose, MessageBox, _("No AP detected."), type = MessageBox.TYPE_INFO, timeout = 10)
1002 def ScanAPclose(self,data):
1005 class NetworkAdapterTest(Screen):
1006 def __init__(self, session,iface):
1007 Screen.__init__(self, session)
1009 self.oldInterfaceState = iNetwork.getAdapterAttribute(self.iface, "up")
1011 self.onClose.append(self.cleanup)
1012 self.onHide.append(self.cleanup)
1014 self["updown_actions"] = NumberActionMap(["WizardActions","ShortcutActions"],
1018 "up": lambda: self.updownhandler('up'),
1019 "down": lambda: self.updownhandler('down'),
1023 self["shortcuts"] = ActionMap(["ShortcutActions","WizardActions"],
1026 "back": self.cancel,
1028 self["infoshortcuts"] = ActionMap(["ShortcutActions","WizardActions"],
1030 "red": self.closeInfo,
1031 "back": self.closeInfo,
1033 self["shortcutsgreen"] = ActionMap(["ShortcutActions"],
1035 "green": self.KeyGreen,
1037 self["shortcutsgreen_restart"] = ActionMap(["ShortcutActions"],
1039 "green": self.KeyGreenRestart,
1041 self["shortcutsyellow"] = ActionMap(["ShortcutActions"],
1043 "yellow": self.KeyYellow,
1046 self["shortcutsgreen_restart"].setEnabled(False)
1047 self["updown_actions"].setEnabled(False)
1048 self["infoshortcuts"].setEnabled(False)
1049 self.onClose.append(self.delTimer)
1050 self.onLayoutFinish.append(self.layoutFinished)
1051 self.steptimer = False
1053 self.activebutton = 0
1054 self.nextStepTimer = eTimer()
1055 self.nextStepTimer.callback.append(self.nextStepTimerFire)
1058 if self.oldInterfaceState is False:
1059 iNetwork.setAdapterAttribute(self.iface, "up", self.oldInterfaceState)
1060 iNetwork.deactivateInterface(self.iface)
1063 def closeInfo(self):
1064 self["shortcuts"].setEnabled(True)
1065 self["infoshortcuts"].setEnabled(False)
1066 self["InfoText"].hide()
1067 self["InfoTextBorder"].hide()
1068 self["key_red"].setText(_("Close"))
1072 del self.nextStepTimer
1074 def nextStepTimerFire(self):
1075 self.nextStepTimer.stop()
1076 self.steptimer = False
1079 def updownhandler(self,direction):
1080 if direction == 'up':
1081 if self.activebutton >=2:
1082 self.activebutton -= 1
1084 self.activebutton = 6
1085 self.setActiveButton(self.activebutton)
1086 if direction == 'down':
1087 if self.activebutton <=5:
1088 self.activebutton += 1
1090 self.activebutton = 1
1091 self.setActiveButton(self.activebutton)
1093 def setActiveButton(self,button):
1095 self["EditSettingsButton"].setPixmapNum(0)
1096 self["EditSettings_Text"].setForegroundColorNum(0)
1097 self["NetworkInfo"].setPixmapNum(0)
1098 self["NetworkInfo_Text"].setForegroundColorNum(1)
1099 self["AdapterInfo"].setPixmapNum(1) # active
1100 self["AdapterInfo_Text"].setForegroundColorNum(2) # active
1102 self["AdapterInfo_Text"].setForegroundColorNum(1)
1103 self["AdapterInfo"].setPixmapNum(0)
1104 self["DhcpInfo"].setPixmapNum(0)
1105 self["DhcpInfo_Text"].setForegroundColorNum(1)
1106 self["NetworkInfo"].setPixmapNum(1) # active
1107 self["NetworkInfo_Text"].setForegroundColorNum(2) # active
1109 self["NetworkInfo"].setPixmapNum(0)
1110 self["NetworkInfo_Text"].setForegroundColorNum(1)
1111 self["IPInfo"].setPixmapNum(0)
1112 self["IPInfo_Text"].setForegroundColorNum(1)
1113 self["DhcpInfo"].setPixmapNum(1) # active
1114 self["DhcpInfo_Text"].setForegroundColorNum(2) # active
1116 self["DhcpInfo"].setPixmapNum(0)
1117 self["DhcpInfo_Text"].setForegroundColorNum(1)
1118 self["DNSInfo"].setPixmapNum(0)
1119 self["DNSInfo_Text"].setForegroundColorNum(1)
1120 self["IPInfo"].setPixmapNum(1) # active
1121 self["IPInfo_Text"].setForegroundColorNum(2) # active
1123 self["IPInfo"].setPixmapNum(0)
1124 self["IPInfo_Text"].setForegroundColorNum(1)
1125 self["EditSettingsButton"].setPixmapNum(0)
1126 self["EditSettings_Text"].setForegroundColorNum(0)
1127 self["DNSInfo"].setPixmapNum(1) # active
1128 self["DNSInfo_Text"].setForegroundColorNum(2) # active
1130 self["DNSInfo"].setPixmapNum(0)
1131 self["DNSInfo_Text"].setForegroundColorNum(1)
1132 self["EditSettingsButton"].setPixmapNum(1) # active
1133 self["EditSettings_Text"].setForegroundColorNum(2) # active
1134 self["AdapterInfo"].setPixmapNum(0)
1135 self["AdapterInfo_Text"].setForegroundColorNum(1)
1138 next = self.nextstep
1154 self.steptimer = True
1155 self.nextStepTimer.start(3000)
1156 self["key_yellow"].setText(_("Stop test"))
1159 self["Adapter"].setText(iNetwork.getFriendlyAdapterName(self.iface))
1160 self["Adapter"].setForegroundColorNum(2)
1161 self["Adaptertext"].setForegroundColorNum(1)
1162 self["AdapterInfo_Text"].setForegroundColorNum(1)
1163 self["AdapterInfo_OK"].show()
1164 self.steptimer = True
1165 self.nextStepTimer.start(3000)
1168 self["Networktext"].setForegroundColorNum(1)
1169 self["Network"].setText(_("Please wait..."))
1170 self.AccessPointInfo(self.iface)
1171 self["NetworkInfo_Text"].setForegroundColorNum(1)
1172 self.steptimer = True
1173 self.nextStepTimer.start(3000)
1176 self["Dhcptext"].setForegroundColorNum(1)
1177 if iNetwork.getAdapterAttribute(self.iface, 'dhcp') is True:
1178 self["Dhcp"].setForegroundColorNum(2)
1179 self["Dhcp"].setText(_("enabled"))
1180 self["DhcpInfo_Check"].setPixmapNum(0)
1182 self["Dhcp"].setForegroundColorNum(1)
1183 self["Dhcp"].setText(_("disabled"))
1184 self["DhcpInfo_Check"].setPixmapNum(1)
1185 self["DhcpInfo_Check"].show()
1186 self["DhcpInfo_Text"].setForegroundColorNum(1)
1187 self.steptimer = True
1188 self.nextStepTimer.start(3000)
1191 self["IPtext"].setForegroundColorNum(1)
1192 self["IP"].setText(_("Please wait..."))
1193 iNetwork.checkNetworkState(self.NetworkStatedataAvail)
1196 self.steptimer = False
1197 self.nextStepTimer.stop()
1198 self["DNStext"].setForegroundColorNum(1)
1199 self["DNS"].setText(_("Please wait..."))
1200 iNetwork.checkDNSLookup(self.DNSLookupdataAvail)
1203 self["shortcutsgreen"].setEnabled(False)
1204 self["shortcutsyellow"].setEnabled(True)
1205 self["updown_actions"].setEnabled(False)
1206 self["key_yellow"].setText("")
1207 self["key_green"].setText("")
1208 self.steptimer = True
1209 self.nextStepTimer.start(1000)
1211 def KeyGreenRestart(self):
1213 self.layoutFinished()
1214 self["Adapter"].setText((""))
1215 self["Network"].setText((""))
1216 self["Dhcp"].setText((""))
1217 self["IP"].setText((""))
1218 self["DNS"].setText((""))
1219 self["AdapterInfo_Text"].setForegroundColorNum(0)
1220 self["NetworkInfo_Text"].setForegroundColorNum(0)
1221 self["DhcpInfo_Text"].setForegroundColorNum(0)
1222 self["IPInfo_Text"].setForegroundColorNum(0)
1223 self["DNSInfo_Text"].setForegroundColorNum(0)
1224 self["shortcutsgreen_restart"].setEnabled(False)
1225 self["shortcutsgreen"].setEnabled(False)
1226 self["shortcutsyellow"].setEnabled(True)
1227 self["updown_actions"].setEnabled(False)
1228 self["key_yellow"].setText("")
1229 self["key_green"].setText("")
1230 self.steptimer = True
1231 self.nextStepTimer.start(1000)
1234 self["infoshortcuts"].setEnabled(True)
1235 self["shortcuts"].setEnabled(False)
1236 if self.activebutton == 1: # Adapter Check
1237 self["InfoText"].setText(_("This test detects your configured Wireless LAN-Adapter."))
1238 self["InfoTextBorder"].show()
1239 self["InfoText"].show()
1240 self["key_red"].setText(_("Back"))
1241 if self.activebutton == 2: #LAN Check
1242 self["InfoText"].setText(_("This test checks whether a network cable is connected to your Wireless LAN-Adapter."))
1243 self["InfoTextBorder"].show()
1244 self["InfoText"].show()
1245 self["key_red"].setText(_("Back"))
1246 if self.activebutton == 3: #DHCP Check
1247 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."))
1248 self["InfoTextBorder"].show()
1249 self["InfoText"].show()
1250 self["key_red"].setText(_("Back"))
1251 if self.activebutton == 4: # IP Check
1252 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"))
1253 self["InfoTextBorder"].show()
1254 self["InfoText"].show()
1255 self["key_red"].setText(_("Back"))
1256 if self.activebutton == 5: # DNS Check
1257 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"))
1258 self["InfoTextBorder"].show()
1259 self["InfoText"].show()
1260 self["key_red"].setText(_("Back"))
1261 if self.activebutton == 6: # Edit Settings
1262 self.session.open(WlanConfig,self.iface)
1263 self["shortcuts"].setEnabled(True)
1264 self["infoshortcuts"].setEnabled(False)
1266 def KeyYellow(self):
1268 self["shortcutsgreen_restart"].setEnabled(True)
1269 self["shortcutsgreen"].setEnabled(False)
1270 self["shortcutsyellow"].setEnabled(False)
1271 self["key_green"].setText(_("Restart test"))
1272 self["key_yellow"].setText("")
1273 self.steptimer = False
1274 self.nextStepTimer.stop()
1276 def layoutFinished(self):
1277 self.setTitle(_("Network test: ") + iNetwork.getFriendlyAdapterName(self.iface) )
1278 self["shortcutsyellow"].setEnabled(False)
1279 self["AdapterInfo_OK"].hide()
1280 self["NetworkInfo_Check"].hide()
1281 self["DhcpInfo_Check"].hide()
1282 self["IPInfo_Check"].hide()
1283 self["DNSInfo_Check"].hide()
1284 self["EditSettings_Text"].hide()
1285 self["EditSettingsButton"].hide()
1286 self["InfoText"].hide()
1287 self["InfoTextBorder"].hide()
1288 self["key_yellow"].setText("")
1290 def setLabels(self):
1291 self["Adaptertext"] = MultiColorLabel(_("LAN Adapter"))
1292 self["Adapter"] = MultiColorLabel()
1293 self["AdapterInfo"] = MultiPixmap()
1294 self["AdapterInfo_Text"] = MultiColorLabel(_("Show Info"))
1295 self["AdapterInfo_OK"] = Pixmap()
1297 if self.iface in iNetwork.wlan_interfaces:
1298 self["Networktext"] = MultiColorLabel(_("Wireless Network"))
1300 self["Networktext"] = MultiColorLabel(_("Local Network"))
1302 self["Network"] = MultiColorLabel()
1303 self["NetworkInfo"] = MultiPixmap()
1304 self["NetworkInfo_Text"] = MultiColorLabel(_("Show Info"))
1305 self["NetworkInfo_Check"] = MultiPixmap()
1307 self["Dhcptext"] = MultiColorLabel(_("DHCP"))
1308 self["Dhcp"] = MultiColorLabel()
1309 self["DhcpInfo"] = MultiPixmap()
1310 self["DhcpInfo_Text"] = MultiColorLabel(_("Show Info"))
1311 self["DhcpInfo_Check"] = MultiPixmap()
1313 self["IPtext"] = MultiColorLabel(_("IP Address"))
1314 self["IP"] = MultiColorLabel()
1315 self["IPInfo"] = MultiPixmap()
1316 self["IPInfo_Text"] = MultiColorLabel(_("Show Info"))
1317 self["IPInfo_Check"] = MultiPixmap()
1319 self["DNStext"] = MultiColorLabel(_("Nameserver"))
1320 self["DNS"] = MultiColorLabel()
1321 self["DNSInfo"] = MultiPixmap()
1322 self["DNSInfo_Text"] = MultiColorLabel(_("Show Info"))
1323 self["DNSInfo_Check"] = MultiPixmap()
1325 self["EditSettings_Text"] = MultiColorLabel(_("Edit settings"))
1326 self["EditSettingsButton"] = MultiPixmap()
1328 self["key_red"] = StaticText(_("Close"))
1329 self["key_green"] = StaticText(_("Start test"))
1330 self["key_yellow"] = StaticText(_("Stop test"))
1332 self["InfoTextBorder"] = Pixmap()
1333 self["InfoText"] = Label()
1335 def NetworkStatedataAvail(self,data):
1337 self["IP"].setForegroundColorNum(2)
1338 self["IP"].setText(_("confirmed"))
1339 self["IPInfo_Check"].setPixmapNum(0)
1341 self["IP"].setForegroundColorNum(1)
1342 self["IP"].setText(_("unconfirmed"))
1343 self["IPInfo_Check"].setPixmapNum(1)
1344 self["IPInfo_Check"].show()
1345 self["IPInfo_Text"].setForegroundColorNum(1)
1346 self.steptimer = True
1347 self.nextStepTimer.start(3000)
1349 def DNSLookupdataAvail(self,data):
1351 self["DNS"].setForegroundColorNum(2)
1352 self["DNS"].setText(_("confirmed"))
1353 self["DNSInfo_Check"].setPixmapNum(0)
1355 self["DNS"].setForegroundColorNum(1)
1356 self["DNS"].setText(_("unconfirmed"))
1357 self["DNSInfo_Check"].setPixmapNum(1)
1358 self["DNSInfo_Check"].show()
1359 self["DNSInfo_Text"].setForegroundColorNum(1)
1360 self["EditSettings_Text"].show()
1361 self["EditSettingsButton"].setPixmapNum(1)
1362 self["EditSettings_Text"].setForegroundColorNum(2) # active
1363 self["EditSettingsButton"].show()
1364 self["key_yellow"].setText("")
1365 self["key_green"].setText(_("Restart test"))
1366 self["shortcutsgreen"].setEnabled(False)
1367 self["shortcutsgreen_restart"].setEnabled(True)
1368 self["shortcutsyellow"].setEnabled(False)
1369 self["updown_actions"].setEnabled(True)
1370 self.activebutton = 6
1372 def getInfoCB(self,status):
1373 if status is not None:
1374 if status.startswith("No Connection") or status.startswith("Not-Associated") or status == False:
1375 self["Network"].setForegroundColorNum(1)
1376 self["Network"].setText(_("disconnected"))
1377 self["NetworkInfo_Check"].setPixmapNum(1)
1378 self["NetworkInfo_Check"].show()
1380 self["Network"].setForegroundColorNum(2)
1381 self["Network"].setText(_("connected"))
1382 self["NetworkInfo_Check"].setPixmapNum(0)
1383 self["NetworkInfo_Check"].show()
1386 iNetwork.stopLinkStateConsole()
1387 iNetwork.stopDNSConsole()
1389 def AccessPointInfo(self,iface):
1390 cmd = "iwconfig %s"%iface
1391 self.iwconfigConsole = Console()
1392 self.iwconfigConsole.ePopen(cmd,self.readAP,self.getInfoCB)
1394 def readAP(self,result,retval,extra_args):
1395 (callback) = extra_args
1396 self.apState = False
1397 if self.iwconfigConsole is not None:
1399 self.iwconfigConsole = None
1400 for content in result.splitlines():
1401 if 'Access Point' in content:
1402 self.apState = content.strip().split('Access Point: ')[1]
1403 callback(self.apState)
1405 callback(self.apState)
1407 class Wlanstatus(Screen):
1409 <screen name="Wlanstatus" position="209,48" size="865,623" title="Wireless Network Configuration..." flags="wfNoBorder" backgroundColor="transparent">
1410 <ePixmap pixmap="Vu_HD/Bg_EPG_view.png" zPosition="-1" position="0,0" size="865,623" alphatest="on" />
1411 <ePixmap pixmap="Vu_HD/menu/ico_title_Setup.png" position="32,41" size="40,40" alphatest="blend" transparent="1" />
1412 <eLabel text="Wireless Network Status..." position="90,50" size="600,32" font="Semiboldit;32" foregroundColor="#5d5d5d" backgroundColor="#27b5b9bd" transparent="1" />
1413 <ePixmap pixmap="Vu_HD/icons/clock.png" position="750,55" zPosition="1" size="20,20" alphatest="blend" />
1414 <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">
1415 <convert type="ClockToText">Format:%H:%M</convert>
1417 <ePixmap pixmap="Vu_HD/buttons/red.png" position="45,98" size="25,25" alphatest="blend" />
1418 <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" />
1419 <widget source="status" render="Label" position="110,200" size="650,400" transparent="1" font="Regular;20" foregroundColor="#1c1c1c" backgroundColor="#27d9dee2" zPosition="1" />
1421 def __init__(self, session,iface):
1422 Screen.__init__(self,session)
1423 self.session = session
1425 self["status"] = StaticText(_("Wait a moment..."))
1426 self["key_red"] = StaticText(_("Close"))
1427 self["OkCancelActions"] = ActionMap(["ShortcutActions", "SetupActions" ],
1430 "cancel": self.close,
1435 def readstatus(self):
1436 self.wlanstatus = Console()
1437 cmd1 = "iwconfig "+self.iface
1438 self.wlanstatus.ePopen(cmd1, self.iwconfigfinnished,self.statusdisplay)
1440 def iwconfigfinnished(self, result, retval,extra_args):
1442 (statecallback) = extra_args
1443 if self.wlanstatus is not None:
1445 statecallback(result)
1452 def statusdisplay(self,data):
1454 self["status"].setText(_("No information..."))
1456 self["status"].setText(data)
1461 def openconfig(session, **kwargs):
1462 session.open(WlanSelection)
1464 def selSetup(menuid, **kwargs):
1466 if menuid != "system":
1469 for x in iNetwork.getAdapterList():
1470 if x.startswith('eth'):
1474 return [(_("Wireless LAN Setup"), openconfig, "wlansetup_config", 80)]
1479 def Plugins(**kwargs):
1480 return PluginDescriptor(name=_("Wireless LAN Setup"), description="Wireless LAN Setup", where = PluginDescriptor.WHERE_MENU, fnc=selSetup)