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 description=self.getAdapterDescription(x)
88 if description == "Unknown network adapter":
89 list.append((description,x))
91 list.append((description + " (%s)"%x,x))
94 def getAdapterDescription(self, iface):
95 classdir = "/sys/class/net/" + iface + "/device/"
96 driverdir = "/sys/class/net/" + iface + "/device/driver/"
97 if os_path.exists(classdir):
98 files = listdir(classdir)
100 if os_path.realpath(driverdir).endswith('rtw_usb_drv'):
101 return _("Realtak")+ " " + _("WLAN adapter.")
102 elif os_path.realpath(driverdir).endswith('ath_pci'):
103 return _("Atheros")+ " " + _("WLAN adapter.")
104 elif os_path.realpath(driverdir).endswith('zd1211b'):
105 return _("Zydas")+ " " + _("WLAN adapter.")
106 elif os_path.realpath(driverdir).endswith('rt73'):
107 return _("Ralink")+ " " + _("WLAN adapter.")
108 elif os_path.realpath(driverdir).endswith('rt73usb'):
109 return _("Ralink")+ " " + _("WLAN adapter.")
111 return str(os_path.basename(os_path.realpath(driverdir))) + " " + _("WLAN adapter")
113 return _("Unknown network adapter")
115 return _("Unknown network adapter")
117 class WlanSetup(Screen,HelpableScreen):
119 <screen name="WlanSetup" position="209,48" size="865,623" title="Wireless Network Configuration..." flags="wfNoBorder" backgroundColor="transparent">
120 <ePixmap pixmap="Vu_HD/Bg_EPG_view.png" zPosition="-1" position="0,0" size="865,623" alphatest="on" />
121 <ePixmap pixmap="Vu_HD/menu/ico_title_Setup.png" position="32,41" size="40,40" alphatest="blend" transparent="1" />
122 <eLabel text="Wireless Network Setup Menu..." position="90,50" size="600,32" font="Semiboldit;32" foregroundColor="#5d5d5d" backgroundColor="#27b5b9bd" transparent="1" />
123 <ePixmap pixmap="Vu_HD/icons/clock.png" position="750,55" zPosition="1" size="20,20" alphatest="blend" />
124 <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">
125 <convert type="ClockToText">Format:%H:%M</convert>
127 <ePixmap pixmap="Vu_HD/buttons/red.png" position="45,98" size="25,25" alphatest="blend" />
128 <ePixmap pixmap="Vu_HD/buttons/green.png" position="240,98" size="25,25" alphatest="blend" />
129 <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" />
130 <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" />
131 <ePixmap pixmap="Vu_HD/border_menu.png" position="120,140" zPosition="-1" size="342,358" transparent="1" alphatest="blend" />
132 <widget name="menulist" position="130,150" size="322,338" transparent="1" backgroundColor="#27d9dee2" zPosition="10" scrollbarMode="showOnDemand" />
133 <widget source="description" render="Label" position="500,140" size="280,360" font="Regular;19" halign="center" valign="center" backgroundColor="#c5c9cc" transparent="1"/>
135 def __init__(self, session, ifaces):
136 Screen.__init__(self, session)
137 HelpableScreen.__init__(self)
138 self.session = session
140 self.restartLanRef = None
141 self.LinkState = None
142 self.mainmenu = self.MakeMenu()
143 self["menulist"] = MenuList(self.mainmenu)
144 self["key_red"] = StaticText(_("Close"))
145 self["key_green"] = StaticText(_("Select"))
146 self["description"] = StaticText()
147 self["IFtext"] = StaticText()
148 self["IF"] = StaticText()
149 self["Statustext"] = StaticText()
150 self["statuspic"] = MultiPixmap()
151 self["statuspic"].hide()
152 self.onLayoutFinish.append(self.loadDescription)
154 self.oktext = _("Press OK on your remote control to continue.")
156 self["WizardActions"] = HelpableActionMap(self, "WizardActions",
158 "up": (self.up, _("move up to previous entry")),
159 "down": (self.down, _("move down to next entry")),
160 "left": (self.left, _("move up to first entry")),
161 "right": (self.right, _("move down to last entry")),
164 self["OkCancelActions"] = HelpableActionMap(self, "OkCancelActions",
166 "cancel": (self.close, _("exit networkadapter setup menu")),
167 "ok": (self.ok, _("select menu entry")),
170 self["ColorActions"] = HelpableActionMap(self, "ColorActions",
172 "red": (self.close, _("exit networkadapter setup menu")),
173 "green": (self.ok, _("select menu entry")),
176 self["actions"] = NumberActionMap(["WizardActions","ShortcutActions"],
187 def loadDescription(self):
188 if self["menulist"].getCurrent()[1] == 'setting':
189 self["description"].setText(_("Edit the network configuration of your STB.\n" ) + self.oktext )
190 if self["menulist"].getCurrent()[1] == 'scanap':
191 self["description"].setText(_("Scan your network for wireless access points and connect to them using your selected wireless device.\n" ) + self.oktext )
192 if self["menulist"].getCurrent()[1] == 'dns':
193 self["description"].setText(_("Edit the Nameserver configuration of your STB.\n" ) + self.oktext )
194 if self["menulist"].getCurrent()[1] == 'status':
195 self["description"].setText(_("Shows the state of your wireless LAN connection.\n" ) + self.oktext )
196 if self["menulist"].getCurrent()[1] == 'test':
197 self["description"].setText(_("Test the network configuration of your STB.\n" ) + self.oktext )
198 if self["menulist"].getCurrent()[1] == 'restart':
199 self["description"].setText(_("Restart your network connection and interfaces.\n" ) + self.oktext )
202 self["menulist"].up()
203 self.loadDescription()
206 self["menulist"].down()
207 self.loadDescription()
210 self["menulist"].pageUp()
211 self.loadDescription()
214 self["menulist"].pageDown()
215 self.loadDescription()
218 if self["menulist"].getCurrent()[1] == 'setting':
219 self.session.openWithCallback(self.checklist, WlanConfig, self.iface)
220 elif self["menulist"].getCurrent()[1] == 'scanap':
221 self.session.open(WlanScanAp, self.iface)
222 elif self["menulist"].getCurrent()[1] == 'dns':
223 self.session.open(NameserverSetup)
224 elif self["menulist"].getCurrent()[1] == 'status':
225 self.session.open(Wlanstatus, self.iface)
226 elif self["menulist"].getCurrent()[1] == 'test':
227 self.session.openWithCallback(self.checklist,NetworkAdapterTest,self.iface)
228 elif self["menulist"].getCurrent()[1] == 'restart':
229 self.session.openWithCallback(self.restartLan, MessageBox, (_("Are you sure you want to restart your network interfaces?\n\n") + self.oktext ) )
232 self["menulist"].setList(self.MakeMenu())
236 menu.append((_("Adapter settings"), "setting"))
237 menu.append((_("Scan Wireless AP"), "scanap"))
238 menu.append((_("Nameserver settings"), "dns"))
239 if iNetwork.getAdapterAttribute(self.iface, "up"):
240 menu.append((_("Show WLAN Status"), "status"))
241 menu.append((_("Network test"), "test"))
242 menu.append((_("Restart network"), "restart"))
246 def restartLan(self, ret = False):
248 iNetwork.restartNetwork(self.restartLanDataAvail)
249 self.restartLanRef = self.session.openWithCallback(self.restartfinishedCB, MessageBox, _("Please wait while your network is restarting..."), type = MessageBox.TYPE_INFO, enable_input = False)
251 def restartLanDataAvail(self, data):
253 iNetwork.getInterfaces(self.getInterfacesDataAvail)
255 def getInterfacesDataAvail(self, data):
257 self.restartLanRef.close(True)
259 def restartfinishedCB(self,data):
261 self.session.open(MessageBox, _("Finished restarting your network"), type = MessageBox.TYPE_INFO, timeout = 5, default = False)
263 wlanconfig = ConfigSubsection()
264 wlanconfig.usedevice = ConfigSelection(default = "off", choices = [
265 ("off", _("off")), ("on", _("on"))])
266 wlanconfig.usedhcp = ConfigSelection(default = "off", choices = [
267 ("off", _("no")), ("on", _("yes"))])
268 wlanconfig.essid = ConfigSelection(default = "none", choices = ["none"])
269 wlanconfig.encrypt = ConfigSelection(default = "off", choices = [
270 ("off", _("no")), ("on", _("yes"))])
271 wlanconfig.method = ConfigSelection(default = "wep", choices = [
272 ("wep", _("WEP")), ("wpa", _("WPA")), ("wpa2", _("WPA2")),("wpa/wpa2", _("WPA/WPA2"))])
273 wlanconfig.keytype = ConfigSelection(default = "ascii", choices = [
274 ("ascii", _("ASCII")), ("hex", _("HEX"))])
275 wlanconfig.key = ConfigText(default = "XXXXXXXX", visible_width = 50, fixed_size = False)
276 wlanconfig.usegateway = ConfigSelection(default = "off", choices = [
277 ("off", _("no")), ("on", _("yes"))])
278 wlanconfig.ip = ConfigIP([0,0,0,0])
279 wlanconfig.netmask = ConfigIP([0,0,0,0])
280 wlanconfig.gateway = ConfigIP([0,0,0,0])
283 class WlanConfig(Screen, ConfigListScreen, HelpableScreen):
285 <screen name="WlanConfig" position="209,48" size="865,623" title="Wireless Network Configuration..." flags="wfNoBorder" backgroundColor="transparent">
286 <ePixmap pixmap="Vu_HD/Bg_EPG_view.png" zPosition="-1" position="0,0" size="865,623" alphatest="on" />
287 <ePixmap pixmap="Vu_HD/menu/ico_title_Setup.png" position="32,41" size="40,40" alphatest="blend" transparent="1" />
288 <eLabel text="Wireless Network Configuration..." position="90,50" size="600,32" font="Semiboldit;32" foregroundColor="#5d5d5d" backgroundColor="#27b5b9bd" transparent="1" />
289 <ePixmap pixmap="Vu_HD/icons/clock.png" position="750,55" zPosition="1" size="20,20" alphatest="blend" />
290 <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">
291 <convert type="ClockToText">Format:%H:%M</convert>
293 <ePixmap pixmap="Vu_HD/buttons/red.png" position="45,98" size="25,25" alphatest="blend" />
294 <ePixmap pixmap="Vu_HD/buttons/green.png" position="240,98" size="25,25" alphatest="blend" />
295 <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" />
296 <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" />
297 <ePixmap pixmap="Vu_HD/border_menu.png" position="120,140" zPosition="-1" size="342,358" transparent="1" alphatest="blend" />
298 <widget name="config" position="130,150" size="322,338" transparent="1" backgroundColor="#27d9dee2" zPosition="10" scrollbarMode="showOnDemand" />
299 <eLabel text="IP Address : " position="500,160" size="200,26" font="Semiboldit;22" foregroundColor="#5d5d5d" backgroundColor="#27b5b9bd" transparent="1" />
300 <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" />
301 <eLabel text="NetMask : " position="500,220" size="200,26" font="Semiboldit;22" foregroundColor="#5d5d5d" backgroundColor="#27b5b9bd" transparent="1" />
302 <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" />
303 <eLabel text="Gateway : " position="500,280" size="200,26" font="Semiboldit;22" foregroundColor="#5d5d5d" backgroundColor="#27b5b9bd" transparent="1" />
304 <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" />
307 def __init__(self, session, iface):
308 Screen.__init__(self,session)
309 self.session = session
310 self["key_red"] = StaticText(_("Close"))
311 self["key_grean"] = StaticText(_("Ok"))
312 self["ipaddress"] = StaticText(_("[ N/A ]"))
313 self["netmask"] = StaticText(_("[ N/A ]"))
314 self["gateway"] = StaticText(_("[ N/A ]"))
315 self["OkCancelActions"] = ActionMap(["ShortcutActions", "SetupActions" ],
317 "ok": self.saveWlanConfig,
318 "green": self.saveWlanConfig,
319 "cancel": self.keyCancel,
320 "red": self.keyCancel,
325 self.scan_ssid = None
329 self.encryption_key = None
330 self.wlanscanap = None
331 # self.scanAPcount =5
334 ConfigListScreen.__init__(self, self.list,session = self.session)
335 self.oldInterfaceState = iNetwork.getAdapterAttribute(self.iface, "up")
336 self.readWpaSupplicantConf()
337 self.scanAPFailedTimer = eTimer()
338 self.scanAPFailedTimer.callback.append(self.scanAPFailed)
339 self.scanAplistTimer = eTimer()
340 self.scanAplistTimer.callback.append(self.scanApList)
341 self.Console = Console()
342 # self.scanAplistTimer.start(100,True)
343 iNetwork.getInterfaces(self.readWlanSettings)
345 def readWlanSettings(self,ret=None):
347 print "getInterfaces Fail... "
348 if iNetwork.getAdapterAttribute(self.iface, "up") == True:
352 wlanconfig.usedevice = ConfigSelection(default=default_tmp, choices = [("off", _("off")), ("on", _("on"))])
354 if iNetwork.getAdapterAttribute(self.iface, "dhcp"):
358 wlanconfig.usedhcp = ConfigSelection(default=default_tmp, choices = [("off", _("no")), ("on", _("yes"))])
360 wlanconfig.ip = ConfigIP(default=iNetwork.getAdapterAttribute(self.iface, "ip")) or [0,0,0,0]
362 wlanconfig.netmask = ConfigIP(default=iNetwork.getAdapterAttribute(self.iface, "netmask") or [255,0,0,0])
363 if iNetwork.getAdapterAttribute(self.iface, "gateway"):
367 wlanconfig.usegateway = ConfigSelection(default = default_tmp, choices = [("off", _("no")), ("on", _("yes"))])
369 wlanconfig.gateway = ConfigIP(default=iNetwork.getAdapterAttribute(self.iface, "gateway") or [0,0,0,0])
371 self["ipaddress"].setText(_(self.formatip(iNetwork.getAdapterAttribute(self.iface, "ip"))))
372 self["netmask"].setText(_(self.formatip(iNetwork.getAdapterAttribute(self.iface, "netmask"))))
373 self["gateway"].setText(_(self.formatip(iNetwork.getAdapterAttribute(self.iface, "gateway"))))
375 if self.encryption_key is not None:
379 wlanconfig.encrypt = ConfigSelection(default = default_tmp, choices = [("off", _("no")), ("on", _("yes"))])
381 if self.key_mgmt=="NONE":
383 elif self.key_mgmt == "WPA-PSK":
384 if self.proto == "WPA":
386 elif self.proto == "RSN":
388 elif self.proto in ( "WPA RSN", "WPA WPA2"):
389 default_tmp = "wpa/wpa2"
395 wlanconfig.method = ConfigSelection(default = default_tmp, choices = [
396 ("wep", _("WEP")), ("wpa", _("WPA")), ("wpa2", _("WPA2")),("wpa/wpa2", _("WPA/WPA2"))])
398 if self.key_type == 0:
401 default_tmp = "ascii"
402 wlanconfig.keytype = ConfigSelection(default = default_tmp, choices = [
403 ("ascii", _("ASCII")), ("hex", _("HEX"))])
404 default_tmp = self.encryption_key or "XXXXXXXX"
405 wlanconfig.key = ConfigText(default = default_tmp, visible_width = 50, fixed_size = False)
406 self.scanAplistTimer.start(100,True)
408 def readWpaSupplicantConf(self):
410 if fileExists("/etc/wpa_supplicant.conf"):
411 wpafd = open("/etc/wpa_supplicant.conf","r")
413 data = wpafd.readline()
415 # print "####readWpaSupplicantConf, data : ",data
418 data = wpafd.readline()
420 if data.startswith('ssid=') and len(data) > 6:
421 self.ssid = data[6:-2]
422 elif data.startswith('ap_scan=') :
423 self.ap_scan = data[8:]
424 # print "####readWpaSupplicantConf, ap_scan : ",self.ap_scan
425 elif data.startswith('scan_ssid=') and len(data) > 10:
426 self.scan_ssid = data[10:-1]
427 elif data.startswith('key_mgmt=') and len(data) > 9:
428 self.key_mgmt = data[9:-1]
429 elif data.startswith('proto=') and len(data) > 6:
430 self.proto = data[6:-1]
431 elif data.startswith('wep_key0="') and len(data) > 11:
432 self.key_type = 1 # ascii
433 self.encryption_key = data[10:-2]
434 elif data.startswith('wep_key0=') and len(data) > 9:
435 self.key_type = 0 # hex
436 self.encryption_key = data[9:-1]
437 elif data.startswith('psk="') and len(data) > 6:
438 self.key_type = 1 # ascii
439 self.encryption_key = data[5:-2]
440 elif data.startswith('psk=') and len(data) > 4:
441 self.key_type = 0 # hex
442 self.encryption_key = data[4:-1]
443 data = wpafd.readline()
444 print self.ssid,self.scan_ssid,self.key_mgmt,self.proto,self.key_type,self.encryption_key
451 print 'failed loading wpasupplicant.conf'
453 def createConfig(self):
455 self.usedeviceEntry = getConfigListEntry(_("Use Device"), wlanconfig.usedevice)
456 self.usedhcpEntry = getConfigListEntry(_("Use DHCP"), wlanconfig.usedhcp)
457 self.essidEntry = getConfigListEntry(_("ESSID"), wlanconfig.essid)
458 self.hiddenessidEntry = getConfigListEntry(_("Input Hidden ESSID"), wlanconfig.hiddenessid)
459 self.encryptEntry = getConfigListEntry(_("Encrypt"), wlanconfig.encrypt)
460 self.methodEntry = getConfigListEntry(_("Method"), wlanconfig.method)
461 self.keytypeEntry = getConfigListEntry(_("Key Type"), wlanconfig.keytype)
462 self.keyEntry = getConfigListEntry(_("KEY"), wlanconfig.key)
464 self.ipEntry = getConfigListEntry(_("IP"), wlanconfig.ip)
465 self.netmaskEntry = getConfigListEntry(_("NetMask"), wlanconfig.netmask)
467 self.usegatewayEntry = getConfigListEntry(_("Use Gateway"), wlanconfig.usegateway)
468 self.gatewayEntry = getConfigListEntry(_("Gateway"), wlanconfig.gateway)
470 self.configList.append( self.usedeviceEntry )
471 if wlanconfig.usedevice.value is "on":
472 self.configList.append( self.usedhcpEntry )
473 if wlanconfig.usedhcp.value is "off":
474 self.configList.append(self.ipEntry)
475 self.configList.append(self.netmaskEntry)
476 self.configList.append(self.usegatewayEntry)
477 if wlanconfig.usegateway.value is "on":
478 self.configList.append(self.gatewayEntry)
479 self.configList.append( self.essidEntry )
480 # print "#### wlanconfig.essid.value : ",wlanconfig.essid.value
481 if wlanconfig.essid.value == 'Input hidden ESSID':
482 self.configList.append( self.hiddenessidEntry )
483 self.configList.append( self.encryptEntry )
484 if wlanconfig.encrypt.value is "on" :
485 self.configList.append( self.methodEntry )
486 self.configList.append( self.keytypeEntry )
487 self.configList.append( self.keyEntry )
489 self["config"].list = self.configList
490 self["config"].l.setList(self.configList)
491 # if not self.selectionChanged in self["config"].onSelectionChanged:
492 # self["config"].onSelectionChanged.append(self.selectionChanged)
494 def scanApList(self):
496 self.configurationmsg = self.session.open(MessageBox, _("Please wait for scanning AP..."), type = MessageBox.TYPE_INFO, enable_input = False)
497 cmd = "ifconfig "+self.iface+" up"
500 self.wlanscanap = Console()
501 cmd = "iwlist "+self.iface+" scan"
503 self.wlanscanap.ePopen(cmd, self.apListFinnished,self.apListParse)
505 def apListFinnished(self, result, retval,extra_args):
506 (callback) = extra_args
507 if self.wlanscanap is not None:
509 self.wlanscanap = None
510 content = result.splitlines()
511 first = content[0].split()
516 if completed == True:
523 def apListParse(self,data):
526 if self.scanAPcount >0:
528 self.configurationmsg.close(True)
530 self.scanAplistTimer.start(500,True)
533 self.configurationmsg.close(True)
534 self.scanAPFailedTimer.start(500,True)
538 # self.scanAPcount =5
540 list = data.splitlines()
543 if xx.startswith('ESSID:') and len(xx)>8 and xx[7:-1]not in self.apList:
544 self.apList.append(xx[7:-1])
545 self.apList.append('Input hidden ESSID')
546 # print "###### selectap : ",selectap
547 if selectap is not None and selectap in self.apList:
548 wlanconfig.essid = ConfigSelection(default=selectap,choices = self.apList)
549 elif self.ap_scan is not None and self.ap_scan.strip() == '2':
550 wlanconfig.essid = ConfigSelection(default='Input hidden ESSID',choices = self.apList)
551 elif self.ssid is not None and self.ssid in self.apList:
552 wlanconfig.essid = ConfigSelection(default=self.ssid,choices = self.apList)
554 wlanconfig.essid = ConfigSelection(choices = self.apList)
555 if self.ssid is not None:
556 wlanconfig.hiddenessid = ConfigText(default = self.ssid, visible_width = 50, fixed_size = False)
558 wlanconfig.hiddenessid = ConfigText(default = "<Input ESSID>", visible_width = 50, fixed_size = False)
559 self.configurationmsg.close(True)
562 def scanAPFailed(self):
563 self.session.openWithCallback(self.keyCancel ,MessageBox, _("Scan AP Failed"), MessageBox.TYPE_ERROR,10)
566 ConfigListScreen.keyLeft(self)
570 ConfigListScreen.keyRight(self)
574 if self["config"].getCurrent() == self.usedeviceEntry or self["config"].getCurrent() == self.encryptEntry \
575 or self["config"].getCurrent() == self.usedhcpEntry or self["config"].getCurrent() == self.usegatewayEntry \
576 or self["config"].getCurrent() == self.essidEntry:
579 def saveWlanConfig(self):
580 if self["config"].getCurrent() == self.keyEntry or self["config"].getCurrent() == self.hiddenessidEntry :
581 self["config"].getCurrent()[1].onDeselect(self.session)
582 if self["config"].isChanged():
583 self.session.openWithCallback(self.checkNetworkShares, MessageBox, (_("Are you sure you want to restart your network interfaces?\n") ) )
585 self.session.openWithCallback(self.checkNetworkShares, MessageBox, (_("Network configuration is not changed....\n\nAre you sure you want to restart your network interfaces?\n") ) )
587 def checkNetworkShares(self,ret = False):
589 if self["config"].getCurrent() == self.keyEntry or self["config"].getCurrent() == self.hiddenessidEntry :
590 self["config"].getCurrent()[1].onSelect(self.session)
593 self.Console = Console()
594 cmd = "cat /proc/mounts"
595 self.Console.ePopen(cmd, self.checkSharesFinished, self.confirmAnotherIfaces)
597 def checkSharesFinished(self, result, retval, extra_args):
598 callback = extra_args
599 print "checkMountsFinished : result : \n",result
600 networks = ['nfs','smbfs','ncp','coda']
601 for line in result.splitlines():
602 split = line.strip().split(' ',3)
603 if split[2] in networks:
604 self.session.open(MessageBox, ("NOT deconfiguring network interfaces :\n network shares still mounted\n"), type = MessageBox.TYPE_ERROR, timeout = 10)
606 if self["config"].getCurrent() == self.keyEntry or self["config"].getCurrent() == self.hiddenessidEntry :
607 self["config"].getCurrent()[1].onSelect(self.session)
611 def confirmAnotherIfaces(self, ret = False):
615 num_configured_if = len(iNetwork.getConfiguredAdapters())
616 if num_configured_if >= 1:
617 if num_configured_if == 1 and self.iface in iNetwork.getConfiguredAdapters():
618 self.writeWlanConfig(False)
620 self.session.openWithCallback(self.writeWlanConfig, MessageBox, _("A second configured interface has been found.\n\nDo you want to disable the second network interface?"), default = True)
622 self.writeWlanConfig(False)
624 def writeWlanConfig(self,ret = False):
626 configuredInterfaces = iNetwork.getConfiguredAdapters()
627 for interface in configuredInterfaces:
628 if interface == self.iface:
630 iNetwork.setAdapterAttribute(interface, "up", False)
631 iNetwork.deactivateInterface(interface)
632 ret=self.writeWpasupplicantConf()
634 self.session.open(MessageBox, _("wpa_supplicant.conf open error."), type = MessageBox.TYPE_ERROR, timeout = 10)
637 self.session.open(MessageBox, _("hidden ESSID empty"), type = MessageBox.TYPE_ERROR, timeout = 10)
640 if wlanconfig.usedevice.value=="on":
641 iNetwork.setAdapterAttribute(self.iface, "up", True)
642 if wlanconfig.usedhcp.value =="on":
643 iNetwork.setAdapterAttribute(self.iface, "dhcp", True)
645 iNetwork.setAdapterAttribute(self.iface, "dhcp", False)
646 iNetwork.setAdapterAttribute(self.iface, "ip", wlanconfig.ip.value)
647 iNetwork.setAdapterAttribute(self.iface, "netmask", wlanconfig.netmask.value)
648 if wlanconfig.usegateway.value == "on":
649 iNetwork.setAdapterAttribute(self.iface, "gateway", wlanconfig.gateway.value)
651 iNetwork.setAdapterAttribute(self.iface, "up", False)
652 iNetwork.deactivateInterface(self.iface)
653 contents = "\tpre-up wpa_supplicant -i"+self.iface+" -c/etc/wpa_supplicant.conf -B -D"+iNetwork.detectWlanModule(self.iface)+"\n"
654 contents += "\tpost-down wpa_cli terminate\n\n"
655 iNetwork.setAdapterAttribute(self.iface, "configStrings", contents)
656 iNetwork.writeNetworkConfig()
657 iNetwork.restartNetwork(self.updateCurrentInterfaces)
658 self.configurationmsg = None
659 self.configurationmsg = self.session.openWithCallback(self.configFinished, MessageBox, _("Please wait for activation of your network configuration..."), type = MessageBox.TYPE_INFO, enable_input = False)
661 def writeWpasupplicantConf(self):
662 wpafd = open("/etc/wpa_supplicant.conf","w")
664 contents = "#WPA Supplicant Configuration by STB\n"
665 contents += "ctrl_interface=/var/run/wpa_supplicant\n"
666 contents += "eapol_version=1\n"
667 contents += "fast_reauth=1\n"
669 if wlanconfig.essid.value == 'Input hidden ESSID':
670 contents += "ap_scan=2\n"
672 contents += "ap_scan=1\n"
673 contents += "network={\n"
674 if wlanconfig.essid.value == 'Input hidden ESSID':
675 if len(wlanconfig.hiddenessid.value) == 0:
678 contents += "\tssid=\""+wlanconfig.hiddenessid.value+"\"\n"
680 contents += "\tssid=\""+wlanconfig.essid.value+"\"\n"
681 contents += "\tscan_ssid=0\n"
682 if wlanconfig.encrypt.value == "on":
683 if wlanconfig.method.value =="wep":
684 contents += "\tkey_mgmt=NONE\n"
685 contents += "\twep_key0="
686 elif wlanconfig.method.value == "wpa":
687 contents += "\tkey_mgmt=WPA-PSK\n"
688 contents += "\tproto=WPA\n"
689 contents += "\tpairwise=CCMP TKIP\n"
690 contents += "\tgroup=CCMP TKIP\n"
692 elif wlanconfig.method.value == "wpa2":
693 contents += "\tkey_mgmt=WPA-PSK\n"
694 contents += "\tproto=RSN\n"
695 contents += "\tpairwise=CCMP TKIP\n"
696 contents += "\tgroup=CCMP TKIP\n"
699 contents += "\tkey_mgmt=WPA-PSK\n"
700 contents += "\tproto=WPA RSN\n"
701 contents += "\tpairwise=CCMP TKIP\n"
702 contents += "\tgroup=CCMP TKIP\n"
704 if wlanconfig.keytype.value == "ascii":
705 contents += "\""+wlanconfig.key.value+"\"\n"
707 contents += wlanconfig.key.value+"\n"
709 contents += "\tkey_mgmt=NONE\n"
711 print "content = \n"+contents
712 wpafd.write(contents)
716 self.session.open(MessageBox, _("wpa_supplicant.conf open error."), type = MessageBox.TYPE_ERROR, timeout = 10)
718 def updateCurrentInterfaces(self,ret):
720 iNetwork.getInterfaces(self.configurationMsgClose)
722 def configurationMsgClose(self,ret):
723 if ret is True and self.configurationmsg is not None:
724 self.configurationmsg.close(True)
726 def configFinished(self,data):
729 self.session.openWithCallback(self.configFinishedCB, MessageBox, _("Your network configuration has been activated."), type = MessageBox.TYPE_INFO, timeout = 10)
730 selectap = wlanconfig.essid.value
732 def configFinishedCB(self,data):
737 def formatip(self, iplist):
740 # print "iplist : ",iplist
743 result = str(iplist[0])+"."+str(iplist[1])+"."+str(iplist[2])+"."+str(iplist[3])
746 # print "result : ",result
751 def keyCancelConfirm(self, result):
754 if self.oldInterfaceState is False:
755 iNetwork.setAdapterAttribute(self.iface, "up", False)
756 iNetwork.deactivateInterface(self.iface,self.keyCancelCB)
760 def keyCancel(self,yesno = True):
761 if self["config"].isChanged():
762 self.session.openWithCallback(self.keyCancelConfirm, MessageBox, _("Really close without saving settings?"))
764 self.keyCancelConfirm(True)
766 def keyCancelCB(self,data):
771 # def selectionChanged(self):
772 # current = self["config"].getCurrent()
775 class WlanScanAp(Screen,HelpableScreen):
777 <screen name="WlanScanAp" position="209,48" size="865,623" title="Wireless Network Configuration..." flags="wfNoBorder" backgroundColor="transparent">
778 <ePixmap pixmap="Vu_HD/Bg_EPG_view.png" zPosition="-1" position="0,0" size="865,623" alphatest="on" />
779 <ePixmap pixmap="Vu_HD/menu/ico_title_Setup.png" position="32,41" size="40,40" alphatest="blend" transparent="1" />
780 <eLabel text="Wireless Network AP Scan..." position="90,50" size="600,32" font="Semiboldit;32" foregroundColor="#5d5d5d" backgroundColor="#27b5b9bd" transparent="1" />
781 <ePixmap pixmap="Vu_HD/icons/clock.png" position="750,55" zPosition="1" size="20,20" alphatest="blend" />
782 <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">
783 <convert type="ClockToText">Format:%H:%M</convert>
785 <ePixmap pixmap="Vu_HD/buttons/red.png" position="45,98" size="25,25" alphatest="blend" />
786 <ePixmap pixmap="Vu_HD/buttons/green.png" position="240,98" size="25,25" alphatest="blend" />
787 <ePixmap pixmap="Vu_HD/buttons/blue.png" position="630,98" size="25,25" alphatest="blend" />
788 <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" />
789 <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" />
790 <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" />
791 <ePixmap pixmap="Vu_HD/border_menu.png" position="120,140" zPosition="-1" size="342,358" transparent="1" alphatest="blend" />
792 <widget name="menulist" position="130,150" size="322,338" transparent="1" backgroundColor="#27d9dee2" zPosition="10" scrollbarMode="showOnDemand" />
793 <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" />
794 <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" />
795 <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" />
796 <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" />
797 <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" />
798 <widget source="BitRate" render="Label" position="490,370" zPosition="1" size="300,60" font="Regular;20" halign="center" valign="center" backgroundColor="#27b5b9bd" foregroundColor="#1c1c1c" transparent="1" />
801 def __init__(self, session, iface):
802 Screen.__init__(self,session)
803 HelpableScreen.__init__(self)
804 self.session = session
806 self.wlanscanap = None
807 # self.scanAPcount = 5
812 self["WizardActions"] = HelpableActionMap(self, "WizardActions",
814 "up": (self.up, _("move up to previous entry")),
815 "down": (self.down, _("move down to next entry")),
816 "left": (self.left, _("move up to first entry")),
817 "right": (self.right, _("move down to last entry")),
820 self["OkCancelActions"] = HelpableActionMap(self, "OkCancelActions",
822 "cancel": (self.close, _("exit")),
823 "ok": (self.ok, "select AP"),
826 self["ColorActions"] = HelpableActionMap(self, "ColorActions",
828 "red": (self.close, _("exit")),
829 "green": (self.ok, "select AP"),
830 "blue": (self.startWlanConfig, "Edit Wireless settings"),
833 self["actions"] = NumberActionMap(["WizardActions","ShortcutActions"],
844 self["menulist"] = MenuList(self.SetApList)
845 self["key_red"] = StaticText(_("Close"))
846 self["key_green"] = StaticText(_("Select"))
847 self["key_blue"] = StaticText(_("EditSetting"))
848 self["Address"] = StaticText(_("Scanning AP List.."))
849 self["ESSID"] = StaticText(_("Wait a moment"))
850 self["Protocol"] = StaticText(" ")
851 self["Frequency"] = StaticText(" ")
852 self["Encryption key"] = StaticText(" ")
853 self["BitRate"] = StaticText(" ")
854 self.scanAPFailedTimer = eTimer()
855 self.scanAPFailedTimer.callback.append(self.scanAPFailed)
856 self.scanAplistTimer = eTimer()
857 self.scanAplistTimer.callback.append(self.scanApList)
858 self.scanAplistTimer.start(100,True)
861 self["menulist"].pageUp()
865 self["menulist"].pageDown()
869 self["menulist"].up()
873 self["menulist"].down()
878 selectAp=self["menulist"].getCurrent()[0]
882 def startWlanConfig(self):
884 selectAp=self["menulist"].getCurrent()[0]
886 self.session.open(WlanConfig,self.iface)
889 def scanApList(self):
890 # print "self.scanAPcount : ",self.scanAPcount
893 self.configurationmsg = self.session.open(MessageBox, _("Please wait for scanning AP..."), type = MessageBox.TYPE_INFO, enable_input = False)
894 os_system('ifconfig '+self.iface+" up")
895 self.wlanscanap = Console()
896 cmd = "iwlist "+self.iface+" scan"
898 self.wlanscanap.ePopen(cmd, self.iwlistfinnished,self.APListParse)
900 def iwlistfinnished(self, result, retval,extra_args):
901 # print "iwlistfinnished"
902 (statecallback) = extra_args
903 if self.wlanscanap is not None:
904 # print "retval = ",retval
906 self.wlanscanap = None
907 content = result.splitlines()
908 first = content[0].split()
913 if completed == True:
914 statecallback(result)
920 def APListParse(self,data):
922 if self.scanAPcount >0:
924 self.configurationmsg.close(True)
926 self.scanAplistTimer.start(500,True)
929 self.configurationmsg.close(True)
930 self.scanAPFailedTimer.start(500,True)
935 # self.scanAPcount =5
937 list = data.splitlines()
939 # print "line : ",line
940 if line.strip().startswith("Cell"): # Cell 01 - Address: 00:26:66:5C:EF:24
941 parts = line.strip().split(" ")
942 current_ap_id = int(parts[1])
943 self.apList[current_ap_id]={}
944 self.apList[current_ap_id]["Address"]=parts[4]
945 elif line.strip().startswith("ESSID"):
946 self.apList[current_ap_id]["ESSID"]=line.strip()[6:].strip('"')
947 self.SetApList.append( (self.apList[current_ap_id]["ESSID"],current_ap_id) )
948 elif line.strip().startswith("Protocol"):
949 self.apList[current_ap_id]["Protocol"]=line.strip()[9:]
950 elif line.strip().startswith("Frequency"):
951 self.apList[current_ap_id]["Frequency"]=line.strip()[10:]
952 elif line.strip().startswith("Encryption key"):
953 self.apList[current_ap_id]["Encryption key"]=line.strip()[15:]
954 elif line.strip().startswith("Bit Rates"):
955 self.apList[current_ap_id]["BitRate"]=line.strip()[10:]
957 print len(self.apList)
958 self.configurationmsg.close(True)
961 def scanAPFailed(self):
962 self.session.openWithCallback(self.ScanAPclose,MessageBox, _("Scan AP Failed"), MessageBox.TYPE_ERROR,10)
964 def displayApInfo(self):
965 if len(self.apList) >0:
966 self["menulist"].setList(self.SetApList)
967 index = self["menulist"].getCurrent()[1]
968 for key in ["Address", "ESSID", "Protocol", "Frequency", "Encryption key", "BitRate"]:
969 if self.apList[index].has_key(key):
970 self[key].setText((key+": "+self.apList[index][key]))
972 self[key].setText(("None"))
974 self.session.openWithCallback(self.ScanAPclose, MessageBox, _("No AP detected."), type = MessageBox.TYPE_INFO, timeout = 10)
976 def ScanAPclose(self,data):
979 class NetworkAdapterTest(Screen):
980 def __init__(self, session,iface):
981 Screen.__init__(self, session)
983 self.oldInterfaceState = iNetwork.getAdapterAttribute(self.iface, "up")
985 self.onClose.append(self.cleanup)
986 self.onHide.append(self.cleanup)
988 self["updown_actions"] = NumberActionMap(["WizardActions","ShortcutActions"],
992 "up": lambda: self.updownhandler('up'),
993 "down": lambda: self.updownhandler('down'),
997 self["shortcuts"] = ActionMap(["ShortcutActions","WizardActions"],
1000 "back": self.cancel,
1002 self["infoshortcuts"] = ActionMap(["ShortcutActions","WizardActions"],
1004 "red": self.closeInfo,
1005 "back": self.closeInfo,
1007 self["shortcutsgreen"] = ActionMap(["ShortcutActions"],
1009 "green": self.KeyGreen,
1011 self["shortcutsgreen_restart"] = ActionMap(["ShortcutActions"],
1013 "green": self.KeyGreenRestart,
1015 self["shortcutsyellow"] = ActionMap(["ShortcutActions"],
1017 "yellow": self.KeyYellow,
1020 self["shortcutsgreen_restart"].setEnabled(False)
1021 self["updown_actions"].setEnabled(False)
1022 self["infoshortcuts"].setEnabled(False)
1023 self.onClose.append(self.delTimer)
1024 self.onLayoutFinish.append(self.layoutFinished)
1025 self.steptimer = False
1027 self.activebutton = 0
1028 self.nextStepTimer = eTimer()
1029 self.nextStepTimer.callback.append(self.nextStepTimerFire)
1032 if self.oldInterfaceState is False:
1033 iNetwork.setAdapterAttribute(self.iface, "up", self.oldInterfaceState)
1034 iNetwork.deactivateInterface(self.iface)
1037 def closeInfo(self):
1038 self["shortcuts"].setEnabled(True)
1039 self["infoshortcuts"].setEnabled(False)
1040 self["InfoText"].hide()
1041 self["InfoTextBorder"].hide()
1042 self["key_red"].setText(_("Close"))
1046 del self.nextStepTimer
1048 def nextStepTimerFire(self):
1049 self.nextStepTimer.stop()
1050 self.steptimer = False
1053 def updownhandler(self,direction):
1054 if direction == 'up':
1055 if self.activebutton >=2:
1056 self.activebutton -= 1
1058 self.activebutton = 6
1059 self.setActiveButton(self.activebutton)
1060 if direction == 'down':
1061 if self.activebutton <=5:
1062 self.activebutton += 1
1064 self.activebutton = 1
1065 self.setActiveButton(self.activebutton)
1067 def setActiveButton(self,button):
1069 self["EditSettingsButton"].setPixmapNum(0)
1070 self["EditSettings_Text"].setForegroundColorNum(0)
1071 self["NetworkInfo"].setPixmapNum(0)
1072 self["NetworkInfo_Text"].setForegroundColorNum(1)
1073 self["AdapterInfo"].setPixmapNum(1) # active
1074 self["AdapterInfo_Text"].setForegroundColorNum(2) # active
1076 self["AdapterInfo_Text"].setForegroundColorNum(1)
1077 self["AdapterInfo"].setPixmapNum(0)
1078 self["DhcpInfo"].setPixmapNum(0)
1079 self["DhcpInfo_Text"].setForegroundColorNum(1)
1080 self["NetworkInfo"].setPixmapNum(1) # active
1081 self["NetworkInfo_Text"].setForegroundColorNum(2) # active
1083 self["NetworkInfo"].setPixmapNum(0)
1084 self["NetworkInfo_Text"].setForegroundColorNum(1)
1085 self["IPInfo"].setPixmapNum(0)
1086 self["IPInfo_Text"].setForegroundColorNum(1)
1087 self["DhcpInfo"].setPixmapNum(1) # active
1088 self["DhcpInfo_Text"].setForegroundColorNum(2) # active
1090 self["DhcpInfo"].setPixmapNum(0)
1091 self["DhcpInfo_Text"].setForegroundColorNum(1)
1092 self["DNSInfo"].setPixmapNum(0)
1093 self["DNSInfo_Text"].setForegroundColorNum(1)
1094 self["IPInfo"].setPixmapNum(1) # active
1095 self["IPInfo_Text"].setForegroundColorNum(2) # active
1097 self["IPInfo"].setPixmapNum(0)
1098 self["IPInfo_Text"].setForegroundColorNum(1)
1099 self["EditSettingsButton"].setPixmapNum(0)
1100 self["EditSettings_Text"].setForegroundColorNum(0)
1101 self["DNSInfo"].setPixmapNum(1) # active
1102 self["DNSInfo_Text"].setForegroundColorNum(2) # active
1104 self["DNSInfo"].setPixmapNum(0)
1105 self["DNSInfo_Text"].setForegroundColorNum(1)
1106 self["EditSettingsButton"].setPixmapNum(1) # active
1107 self["EditSettings_Text"].setForegroundColorNum(2) # active
1108 self["AdapterInfo"].setPixmapNum(0)
1109 self["AdapterInfo_Text"].setForegroundColorNum(1)
1112 next = self.nextstep
1128 self.steptimer = True
1129 self.nextStepTimer.start(3000)
1130 self["key_yellow"].setText(_("Stop test"))
1133 self["Adapter"].setText(iNetwork.getFriendlyAdapterName(self.iface))
1134 self["Adapter"].setForegroundColorNum(2)
1135 self["Adaptertext"].setForegroundColorNum(1)
1136 self["AdapterInfo_Text"].setForegroundColorNum(1)
1137 self["AdapterInfo_OK"].show()
1138 self.steptimer = True
1139 self.nextStepTimer.start(3000)
1142 self["Networktext"].setForegroundColorNum(1)
1143 self["Network"].setText(_("Please wait..."))
1144 self.AccessPointInfo(self.iface)
1145 self["NetworkInfo_Text"].setForegroundColorNum(1)
1146 self.steptimer = True
1147 self.nextStepTimer.start(3000)
1150 self["Dhcptext"].setForegroundColorNum(1)
1151 if iNetwork.getAdapterAttribute(self.iface, 'dhcp') is True:
1152 self["Dhcp"].setForegroundColorNum(2)
1153 self["Dhcp"].setText(_("enabled"))
1154 self["DhcpInfo_Check"].setPixmapNum(0)
1156 self["Dhcp"].setForegroundColorNum(1)
1157 self["Dhcp"].setText(_("disabled"))
1158 self["DhcpInfo_Check"].setPixmapNum(1)
1159 self["DhcpInfo_Check"].show()
1160 self["DhcpInfo_Text"].setForegroundColorNum(1)
1161 self.steptimer = True
1162 self.nextStepTimer.start(3000)
1165 self["IPtext"].setForegroundColorNum(1)
1166 self["IP"].setText(_("Please wait..."))
1167 iNetwork.checkNetworkState(self.NetworkStatedataAvail)
1170 self.steptimer = False
1171 self.nextStepTimer.stop()
1172 self["DNStext"].setForegroundColorNum(1)
1173 self["DNS"].setText(_("Please wait..."))
1174 iNetwork.checkDNSLookup(self.DNSLookupdataAvail)
1177 self["shortcutsgreen"].setEnabled(False)
1178 self["shortcutsyellow"].setEnabled(True)
1179 self["updown_actions"].setEnabled(False)
1180 self["key_yellow"].setText("")
1181 self["key_green"].setText("")
1182 self.steptimer = True
1183 self.nextStepTimer.start(1000)
1185 def KeyGreenRestart(self):
1187 self.layoutFinished()
1188 self["Adapter"].setText((""))
1189 self["Network"].setText((""))
1190 self["Dhcp"].setText((""))
1191 self["IP"].setText((""))
1192 self["DNS"].setText((""))
1193 self["AdapterInfo_Text"].setForegroundColorNum(0)
1194 self["NetworkInfo_Text"].setForegroundColorNum(0)
1195 self["DhcpInfo_Text"].setForegroundColorNum(0)
1196 self["IPInfo_Text"].setForegroundColorNum(0)
1197 self["DNSInfo_Text"].setForegroundColorNum(0)
1198 self["shortcutsgreen_restart"].setEnabled(False)
1199 self["shortcutsgreen"].setEnabled(False)
1200 self["shortcutsyellow"].setEnabled(True)
1201 self["updown_actions"].setEnabled(False)
1202 self["key_yellow"].setText("")
1203 self["key_green"].setText("")
1204 self.steptimer = True
1205 self.nextStepTimer.start(1000)
1208 self["infoshortcuts"].setEnabled(True)
1209 self["shortcuts"].setEnabled(False)
1210 if self.activebutton == 1: # Adapter Check
1211 self["InfoText"].setText(_("This test detects your configured Wireless LAN-Adapter."))
1212 self["InfoTextBorder"].show()
1213 self["InfoText"].show()
1214 self["key_red"].setText(_("Back"))
1215 if self.activebutton == 2: #LAN Check
1216 self["InfoText"].setText(_("This test checks whether a network cable is connected to your Wireless LAN-Adapter."))
1217 self["InfoTextBorder"].show()
1218 self["InfoText"].show()
1219 self["key_red"].setText(_("Back"))
1220 if self.activebutton == 3: #DHCP Check
1221 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."))
1222 self["InfoTextBorder"].show()
1223 self["InfoText"].show()
1224 self["key_red"].setText(_("Back"))
1225 if self.activebutton == 4: # IP Check
1226 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"))
1227 self["InfoTextBorder"].show()
1228 self["InfoText"].show()
1229 self["key_red"].setText(_("Back"))
1230 if self.activebutton == 5: # DNS Check
1231 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"))
1232 self["InfoTextBorder"].show()
1233 self["InfoText"].show()
1234 self["key_red"].setText(_("Back"))
1235 if self.activebutton == 6: # Edit Settings
1236 self.session.open(WlanConfig,self.iface)
1237 self["shortcuts"].setEnabled(True)
1238 self["infoshortcuts"].setEnabled(False)
1240 def KeyYellow(self):
1242 self["shortcutsgreen_restart"].setEnabled(True)
1243 self["shortcutsgreen"].setEnabled(False)
1244 self["shortcutsyellow"].setEnabled(False)
1245 self["key_green"].setText(_("Restart test"))
1246 self["key_yellow"].setText("")
1247 self.steptimer = False
1248 self.nextStepTimer.stop()
1250 def layoutFinished(self):
1251 self.setTitle(_("Network test: ") + iNetwork.getFriendlyAdapterName(self.iface) )
1252 self["shortcutsyellow"].setEnabled(False)
1253 self["AdapterInfo_OK"].hide()
1254 self["NetworkInfo_Check"].hide()
1255 self["DhcpInfo_Check"].hide()
1256 self["IPInfo_Check"].hide()
1257 self["DNSInfo_Check"].hide()
1258 self["EditSettings_Text"].hide()
1259 self["EditSettingsButton"].hide()
1260 self["InfoText"].hide()
1261 self["InfoTextBorder"].hide()
1262 self["key_yellow"].setText("")
1264 def setLabels(self):
1265 self["Adaptertext"] = MultiColorLabel(_("LAN Adapter"))
1266 self["Adapter"] = MultiColorLabel()
1267 self["AdapterInfo"] = MultiPixmap()
1268 self["AdapterInfo_Text"] = MultiColorLabel(_("Show Info"))
1269 self["AdapterInfo_OK"] = Pixmap()
1271 if self.iface in iNetwork.wlan_interfaces:
1272 self["Networktext"] = MultiColorLabel(_("Wireless Network"))
1274 self["Networktext"] = MultiColorLabel(_("Local Network"))
1276 self["Network"] = MultiColorLabel()
1277 self["NetworkInfo"] = MultiPixmap()
1278 self["NetworkInfo_Text"] = MultiColorLabel(_("Show Info"))
1279 self["NetworkInfo_Check"] = MultiPixmap()
1281 self["Dhcptext"] = MultiColorLabel(_("DHCP"))
1282 self["Dhcp"] = MultiColorLabel()
1283 self["DhcpInfo"] = MultiPixmap()
1284 self["DhcpInfo_Text"] = MultiColorLabel(_("Show Info"))
1285 self["DhcpInfo_Check"] = MultiPixmap()
1287 self["IPtext"] = MultiColorLabel(_("IP Address"))
1288 self["IP"] = MultiColorLabel()
1289 self["IPInfo"] = MultiPixmap()
1290 self["IPInfo_Text"] = MultiColorLabel(_("Show Info"))
1291 self["IPInfo_Check"] = MultiPixmap()
1293 self["DNStext"] = MultiColorLabel(_("Nameserver"))
1294 self["DNS"] = MultiColorLabel()
1295 self["DNSInfo"] = MultiPixmap()
1296 self["DNSInfo_Text"] = MultiColorLabel(_("Show Info"))
1297 self["DNSInfo_Check"] = MultiPixmap()
1299 self["EditSettings_Text"] = MultiColorLabel(_("Edit settings"))
1300 self["EditSettingsButton"] = MultiPixmap()
1302 self["key_red"] = StaticText(_("Close"))
1303 self["key_green"] = StaticText(_("Start test"))
1304 self["key_yellow"] = StaticText(_("Stop test"))
1306 self["InfoTextBorder"] = Pixmap()
1307 self["InfoText"] = Label()
1309 def NetworkStatedataAvail(self,data):
1311 self["IP"].setForegroundColorNum(2)
1312 self["IP"].setText(_("confirmed"))
1313 self["IPInfo_Check"].setPixmapNum(0)
1315 self["IP"].setForegroundColorNum(1)
1316 self["IP"].setText(_("unconfirmed"))
1317 self["IPInfo_Check"].setPixmapNum(1)
1318 self["IPInfo_Check"].show()
1319 self["IPInfo_Text"].setForegroundColorNum(1)
1320 self.steptimer = True
1321 self.nextStepTimer.start(3000)
1323 def DNSLookupdataAvail(self,data):
1325 self["DNS"].setForegroundColorNum(2)
1326 self["DNS"].setText(_("confirmed"))
1327 self["DNSInfo_Check"].setPixmapNum(0)
1329 self["DNS"].setForegroundColorNum(1)
1330 self["DNS"].setText(_("unconfirmed"))
1331 self["DNSInfo_Check"].setPixmapNum(1)
1332 self["DNSInfo_Check"].show()
1333 self["DNSInfo_Text"].setForegroundColorNum(1)
1334 self["EditSettings_Text"].show()
1335 self["EditSettingsButton"].setPixmapNum(1)
1336 self["EditSettings_Text"].setForegroundColorNum(2) # active
1337 self["EditSettingsButton"].show()
1338 self["key_yellow"].setText("")
1339 self["key_green"].setText(_("Restart test"))
1340 self["shortcutsgreen"].setEnabled(False)
1341 self["shortcutsgreen_restart"].setEnabled(True)
1342 self["shortcutsyellow"].setEnabled(False)
1343 self["updown_actions"].setEnabled(True)
1344 self.activebutton = 6
1346 def getInfoCB(self,status):
1347 if status is not None:
1348 if status.startswith("No Connection") or status.startswith("Not-Associated") or status == False:
1349 self["Network"].setForegroundColorNum(1)
1350 self["Network"].setText(_("disconnected"))
1351 self["NetworkInfo_Check"].setPixmapNum(1)
1352 self["NetworkInfo_Check"].show()
1354 self["Network"].setForegroundColorNum(2)
1355 self["Network"].setText(_("connected"))
1356 self["NetworkInfo_Check"].setPixmapNum(0)
1357 self["NetworkInfo_Check"].show()
1360 iNetwork.stopLinkStateConsole()
1361 iNetwork.stopDNSConsole()
1363 def AccessPointInfo(self,iface):
1364 cmd = "iwconfig %s"%iface
1365 self.iwconfigConsole = Console()
1366 self.iwconfigConsole.ePopen(cmd,self.readAP,self.getInfoCB)
1368 def readAP(self,result,retval,extra_args):
1369 (callback) = extra_args
1371 if self.iwconfigConsole is not None:
1373 self.iwconfigConsole = None
1374 for content in result.splitlines():
1375 if 'Access Point' in content:
1376 self.apState = content.strip().split('Access Point: ')[1]
1377 callback(self.apState)
1379 callback(self.apState)
1381 class Wlanstatus(Screen):
1383 <screen name="Wlanstatus" position="209,48" size="865,623" title="Wireless Network Configuration..." flags="wfNoBorder" backgroundColor="transparent">
1384 <ePixmap pixmap="Vu_HD/Bg_EPG_view.png" zPosition="-1" position="0,0" size="865,623" alphatest="on" />
1385 <ePixmap pixmap="Vu_HD/menu/ico_title_Setup.png" position="32,41" size="40,40" alphatest="blend" transparent="1" />
1386 <eLabel text="Wireless Network Status..." position="90,50" size="600,32" font="Semiboldit;32" foregroundColor="#5d5d5d" backgroundColor="#27b5b9bd" transparent="1" />
1387 <ePixmap pixmap="Vu_HD/icons/clock.png" position="750,55" zPosition="1" size="20,20" alphatest="blend" />
1388 <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">
1389 <convert type="ClockToText">Format:%H:%M</convert>
1391 <ePixmap pixmap="Vu_HD/buttons/red.png" position="45,98" size="25,25" alphatest="blend" />
1392 <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" />
1393 <widget source="status" render="Label" position="110,200" size="650,400" transparent="1" font="Regular;20" foregroundColor="#1c1c1c" backgroundColor="#27d9dee2" zPosition="1" />
1395 def __init__(self, session,iface):
1396 Screen.__init__(self,session)
1397 self.session = session
1399 self["status"] = StaticText(_("Wait a moment..."))
1400 self["key_red"] = StaticText(_("Close"))
1401 self["OkCancelActions"] = ActionMap(["ShortcutActions", "SetupActions" ],
1404 "cancel": self.close,
1409 def readstatus(self):
1410 self.wlanstatus = Console()
1411 cmd1 = "iwconfig "+self.iface
1412 self.wlanstatus.ePopen(cmd1, self.iwconfigfinnished,self.statusdisplay)
1414 def iwconfigfinnished(self, result, retval,extra_args):
1416 (statecallback) = extra_args
1417 if self.wlanstatus is not None:
1419 statecallback(result)
1426 def statusdisplay(self,data):
1428 self["status"].setText(_("No information..."))
1430 self["status"].setText(data)
1435 def openconfig(session, **kwargs):
1436 session.open(WlanSelection)
1438 def selSetup(menuid, **kwargs):
1440 if menuid != "system":
1443 for x in iNetwork.getAdapterList():
1444 if x.startswith('eth'):
1448 return [(_("Wireless LAN Setup"), openconfig, "wlansetup_config", 80)]
1453 def Plugins(**kwargs):
1454 return PluginDescriptor(name=_("Wireless LAN Setup"), description="Wireless LAN Setup", where = PluginDescriptor.WHERE_MENU, fnc=selSetup)