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
330 ConfigListScreen.__init__(self, self.list,session = self.session)
331 self.oldInterfaceState = iNetwork.getAdapterAttribute(self.iface, "up")
332 self.readWpaSupplicantConf()
333 # iNetwork.getInterfaces()
334 self.readWlanSettings()
335 self.scanAplistTimer = eTimer()
336 self.scanAplistTimer.callback.append(self.scanApList)
337 self.scanAplistTimer.start(100,True)
338 self.Console = Console()
340 def readWlanSettings(self):
341 if iNetwork.getAdapterAttribute(self.iface, "up") == True:
345 wlanconfig.usedevice = ConfigSelection(default=default_tmp, choices = [("off", _("off")), ("on", _("on"))])
347 if iNetwork.getAdapterAttribute(self.iface, "dhcp"):
351 wlanconfig.usedhcp = ConfigSelection(default=default_tmp, choices = [("off", _("no")), ("on", _("yes"))])
353 wlanconfig.ip = ConfigIP(default=iNetwork.getAdapterAttribute(self.iface, "ip")) or [0,0,0,0]
355 wlanconfig.netmask = ConfigIP(default=iNetwork.getAdapterAttribute(self.iface, "netmask") or [255,0,0,0])
356 if iNetwork.getAdapterAttribute(self.iface, "gateway"):
360 wlanconfig.usegateway = ConfigSelection(default = default_tmp, choices = [("off", _("no")), ("on", _("yes"))])
362 wlanconfig.gateway = ConfigIP(default=iNetwork.getAdapterAttribute(self.iface, "gateway") or [0,0,0,0])
364 self["ipaddress"] = StaticText(_(self.formatip(iNetwork.getAdapterAttribute(self.iface, "ip"))))
365 self["netmask"] = StaticText(_(self.formatip(iNetwork.getAdapterAttribute(self.iface, "netmask"))))
366 self["gateway"] = StaticText(_(self.formatip(iNetwork.getAdapterAttribute(self.iface, "gateway"))))
368 if self.encryption_key is not None:
372 wlanconfig.encrypt = ConfigSelection(default = default_tmp, choices = [("off", _("no")), ("on", _("yes"))])
374 if self.key_mgmt=="NONE":
376 elif self.key_mgmt == "WPA-PSK":
377 if self.proto == "WPA":
379 elif self.proto == "RSN":
381 elif self.proto in ( "WPA RSN", "WPA WPA2"):
382 default_tmp = "wpa/wpa2"
388 wlanconfig.method = ConfigSelection(default = default_tmp, choices = [
389 ("wep", _("WEP")), ("wpa", _("WPA")), ("wpa2", _("WPA2")),("wpa/wpa2", _("WPA/WPA2"))])
391 if self.key_type == 0:
394 default_tmp = "ascii"
395 wlanconfig.keytype = ConfigSelection(default = default_tmp, choices = [
396 ("ascii", _("ASCII")), ("hex", _("HEX"))])
397 default_tmp = self.encryption_key or "XXXXXXXX"
398 wlanconfig.key = ConfigText(default = default_tmp, visible_width = 50, fixed_size = False)
400 def readWpaSupplicantConf(self):
402 if fileExists("/etc/wpa_supplicant.conf"):
403 wpafd = open("/etc/wpa_supplicant.conf","r")
405 data = wpafd.readline()
407 # print "####readWpaSupplicantConf, data : ",data
410 data = wpafd.readline()
412 if data.startswith('ssid=') and len(data) > 6:
413 self.ssid = data[6:-2]
414 elif data.startswith('ap_scan=') :
415 self.ap_scan = data[8:]
416 # print "####readWpaSupplicantConf, ap_scan : ",self.ap_scan
417 elif data.startswith('scan_ssid=') and len(data) > 10:
418 self.scan_ssid = data[10:-1]
419 elif data.startswith('key_mgmt=') and len(data) > 9:
420 self.key_mgmt = data[9:-1]
421 elif data.startswith('proto=') and len(data) > 6:
422 self.proto = data[6:-1]
423 elif data.startswith('wep_key0="') and len(data) > 11:
424 self.key_type = 1 # ascii
425 self.encryption_key = data[10:-2]
426 elif data.startswith('wep_key0=') and len(data) > 9:
427 self.key_type = 0 # hex
428 self.encryption_key = data[9:-1]
429 elif data.startswith('psk="') and len(data) > 6:
430 self.key_type = 1 # ascii
431 self.encryption_key = data[5:-2]
432 elif data.startswith('psk=') and len(data) > 4:
433 self.key_type = 0 # hex
434 self.encryption_key = data[4:-1]
435 data = wpafd.readline()
436 print self.ssid,self.scan_ssid,self.key_mgmt,self.proto,self.key_type,self.wep_key
443 print 'failed loading wpasupplicant.conf'
445 def createConfig(self):
447 self.usedeviceEntry = getConfigListEntry(_("Use Device"), wlanconfig.usedevice)
448 self.usedhcpEntry = getConfigListEntry(_("Use DHCP"), wlanconfig.usedhcp)
449 self.essidEntry = getConfigListEntry(_("ESSID"), wlanconfig.essid)
450 self.hiddenessidEntry = getConfigListEntry(_("Input Hidden ESSID"), wlanconfig.hiddenessid)
451 self.encryptEntry = getConfigListEntry(_("Encrypt"), wlanconfig.encrypt)
452 self.methodEntry = getConfigListEntry(_("Method"), wlanconfig.method)
453 self.keytypeEntry = getConfigListEntry(_("Key Type"), wlanconfig.keytype)
454 self.keyEntry = getConfigListEntry(_("KEY"), wlanconfig.key)
456 self.ipEntry = getConfigListEntry(_("IP"), wlanconfig.ip)
457 self.netmaskEntry = getConfigListEntry(_("NetMask"), wlanconfig.netmask)
459 self.usegatewayEntry = getConfigListEntry(_("Use Gateway"), wlanconfig.usegateway)
460 self.gatewayEntry = getConfigListEntry(_("Gateway"), wlanconfig.gateway)
462 self.configList.append( self.usedeviceEntry )
463 if wlanconfig.usedevice.value is "on":
464 self.configList.append( self.usedhcpEntry )
465 if wlanconfig.usedhcp.value is "off":
466 self.configList.append(self.ipEntry)
467 self.configList.append(self.netmaskEntry)
468 self.configList.append(self.usegatewayEntry)
469 if wlanconfig.usegateway.value is "on":
470 self.configList.append(self.gatewayEntry)
471 self.configList.append( self.essidEntry )
472 print "#### wlanconfig.essid.value : ",wlanconfig.essid.value
473 if wlanconfig.essid.value == 'Input hidden ESSID':
474 self.configList.append( self.hiddenessidEntry )
475 self.configList.append( self.encryptEntry )
476 if wlanconfig.encrypt.value is "on" :
477 self.configList.append( self.methodEntry )
478 self.configList.append( self.keytypeEntry )
479 self.configList.append( self.keyEntry )
481 self["config"].list = self.configList
482 self["config"].l.setList(self.configList)
483 # if not self.selectionChanged in self["config"].onSelectionChanged:
484 # self["config"].onSelectionChanged.append(self.selectionChanged)
486 def scanApList(self):
489 self.configurationmsg = self.session.open(MessageBox, _("Please wait for scanning AP..."), type = MessageBox.TYPE_INFO, enable_input = False)
490 os_system('ifconfig '+self.iface+" up")
491 self.wlanscanap = Console()
492 cmd = "iwlist "+self.iface+" scan"
494 self.wlanscanap.ePopen(cmd, self.apListFinnished,self.apListParse)
496 def apListFinnished(self, result, retval,extra_args):
497 (callback) = extra_args
498 if self.wlanscanap is not None:
500 self.wlanscanap = None
501 content = result.splitlines()
502 first = content[0].split()
507 if completed == True:
514 def apListParse(self,data):
517 if self.scanAPcount >0:
518 self.configurationmsg.close(True)
519 self.scanAplistTimer.start(100,True)
522 self.configurationmsg.close(True)
523 self.session.open(MessageBox, _("Scan AP Failed"), MessageBox.TYPE_INFO,2)
528 list = data.splitlines()
531 if xx.startswith('ESSID:') and len(xx)>8:
532 self.apList.append(xx[7:-1])
533 self.apList.append('Input hidden ESSID')
534 print "###### selectap : ",selectap
535 if selectap is not None and selectap in self.apList:
536 wlanconfig.essid = ConfigSelection(default=selectap,choices = self.apList)
537 elif self.ap_scan is not None and self.ap_scan.strip() == '2':
538 wlanconfig.essid = ConfigSelection(default='Input hidden ESSID',choices = self.apList)
539 elif self.ssid is not None and self.ssid in self.apList:
540 wlanconfig.essid = ConfigSelection(default=self.ssid,choices = self.apList)
542 wlanconfig.essid = ConfigSelection(choices = self.apList)
543 if self.ssid is not None:
544 wlanconfig.hiddenessid = ConfigText(default = self.ssid, visible_width = 50, fixed_size = False)
546 wlanconfig.hiddenessid = ConfigText(default = "<Input ESSID>", visible_width = 50, fixed_size = False)
547 self.configurationmsg.close(True)
551 ConfigListScreen.keyLeft(self)
555 ConfigListScreen.keyRight(self)
559 if self["config"].getCurrent() == self.usedeviceEntry or self["config"].getCurrent() == self.encryptEntry \
560 or self["config"].getCurrent() == self.usedhcpEntry or self["config"].getCurrent() == self.usegatewayEntry \
561 or self["config"].getCurrent() == self.essidEntry:
564 def saveWlanConfig(self):
565 if self["config"].isChanged():
566 self.session.openWithCallback(self.checkNetworkShares, MessageBox, (_("Are you sure you want to restart your network interfaces?\n") ) )
568 def checkNetworkShares(self,ret = False):
571 print "########## checkNetworkShares : "
573 self.Console = Console()
574 cmd = "cat /proc/mounts"
575 self.Console.ePopen(cmd, self.checkSharesFinished, self.confirmAnotherIfaces)
577 def checkSharesFinished(self, result, retval, extra_args):
578 callback = extra_args
579 print "checkMountsFinished : result : \n",result
580 networks = ['nfs','smbfs','ncp','coda']
581 for line in result.splitlines():
582 split = line.strip().split(' ',3)
583 if split[2] in networks:
584 self.session.open(MessageBox, ("NOT deconfiguring network interfaces :\n network shares still mounted\n"), type = MessageBox.TYPE_ERROR, timeout = 10)
589 def confirmAnotherIfaces(self, ret = False):
593 num_configured_if = len(iNetwork.getConfiguredAdapters())
594 if num_configured_if >= 1:
595 if num_configured_if == 1 and self.iface in iNetwork.getConfiguredAdapters():
596 self.writeWlanConfig(False)
598 self.session.openWithCallback(self.writeWlanConfig, MessageBox, (_("Are you sure you want to deactive another network interfaces?\n") ) )
600 self.writeWlanConfig(False)
602 def writeWlanConfig(self,ret = False):
604 configuredInterfaces = iNetwork.getConfiguredAdapters()
605 for interface in configuredInterfaces:
606 if interface == self.iface:
608 iNetwork.setAdapterAttribute(interface, "up", False)
609 iNetwork.deactivateInterface(interface)
610 ret=self.writeWpasupplicantConf()
612 self.session.open(MessageBox, _("wpa_supplicant.conf open error."), type = MessageBox.TYPE_ERROR, timeout = 10)
615 self.session.open(MessageBox, _("hidden ESSID empty"), type = MessageBox.TYPE_ERROR, timeout = 10)
617 iffd = open("/etc/network/interfaces","r")
621 data = iffd.readline()
624 if data.startswith('iface '+self.iface) or data.startswith('auto '+self.iface):
626 data = iffd.readline()
628 elif not data.startswith('auto lo') and data.startswith('auto '):
629 if ret == True or data[5:] not in iNetwork.getConfiguredAdapters():
630 data = iffd.readline()
632 if status == 1 and data.startswith('iface ') or data.startswith('auto '):
638 data = iffd.readline()
640 iffd = open("/etc/network/interfaces","w")
642 if prev_content == "":
643 prev_content = "# automatically generated by STB\n"
644 prev_content += "# do Not change manually!\n\n"
645 prev_content += "auto lo\n"
646 prev_content += "iface lo inet loopback\n\n"
647 iffd.write(prev_content)
648 if wlanconfig.usedevice.value=="on":
649 iNetwork.setAdapterAttribute(self.iface, "up", True)
650 contents = "auto "+self.iface+"\n"
651 contents += "iface "+self.iface+" inet "
652 if wlanconfig.usedhcp.value =="on":
653 iNetwork.setAdapterAttribute(self.iface, "dhcp", True)
656 iNetwork.setAdapterAttribute(self.iface, "dhcp", False)
657 contents +="static\n"
658 print wlanconfig.ip.value
659 iNetwork.setAdapterAttribute(self.iface, "ip", wlanconfig.ip.value)
660 iNetwork.setAdapterAttribute(self.iface, "netmask", wlanconfig.netmask.value)
661 contents +="\taddress "+ self.formatip(wlanconfig.ip.value)+"\n"
662 contents +="\tnetmask "+ self.formatip(wlanconfig.netmask.value)+"\n"
663 if wlanconfig.usegateway.value == "on":
664 iNetwork.setAdapterAttribute(self.iface, "gateway", wlanconfig.gateway.value)
665 contents +="\tgateway "+ self.formatip(wlanconfig.gateway.value)+"\n"
666 contents += "\tpre-up wpa_supplicant -i"+self.iface+" -c/etc/wpa_supplicant.conf -B -D"+iNetwork.detectWlanModule(self.iface)+"\n"
667 contents += "\tpost-down wpa_cli terminate\n\n"
670 iNetwork.setAdapterAttribute(self.iface, "up", False)
671 iNetwork.deactivateInterface(self.iface)
672 iffd.write(next_content)
675 self.session.open(MessageBox, _("/etc/network/interfaces open error."), type = MessageBox.TYPE_ERROR, timeout = 10)
677 iNetwork.restartNetwork(self.updateCurrentInterfaces)
678 self.configurationmsg = None
679 self.configurationmsg = self.session.openWithCallback(self.configFinished, MessageBox, _("Please wait for activation of your network configuration..."), type = MessageBox.TYPE_INFO, enable_input = False)
681 def writeWpasupplicantConf(self):
682 wpafd = open("/etc/wpa_supplicant.conf","w")
684 contents = "#WPA Supplicant Configuration by STB\n"
685 contents += "ctrl_interface=/var/run/wpa_supplicant\n"
686 contents += "eapol_version=1\n"
687 contents += "fast_reauth=1\n"
689 if wlanconfig.essid.value == 'Input hidden ESSID':
690 contents += "ap_scan=2\n"
692 contents += "ap_scan=1\n"
693 contents += "network={\n"
694 if wlanconfig.essid.value == 'Input hidden ESSID':
695 if len(wlanconfig.hiddenessid.value) == 0:
698 contents += "\tssid=\""+wlanconfig.hiddenessid.value+"\"\n"
700 contents += "\tssid=\""+wlanconfig.essid.value+"\"\n"
701 contents += "\tscan_ssid=0\n"
702 if wlanconfig.encrypt.value == "on":
703 if wlanconfig.method.value =="wep":
704 contents += "\tkey_mgmt=NONE\n"
705 contents += "\twep_key0="
706 elif wlanconfig.method.value == "wpa":
707 contents += "\tkey_mgmt=WPA-PSK\n"
708 contents += "\tproto=WPA\n"
709 contents += "\tpairwise=CCMP TKIP\n"
710 contents += "\tgroup=CCMP TKIP\n"
712 elif wlanconfig.method.value == "wpa2":
713 contents += "\tkey_mgmt=WPA-PSK\n"
714 contents += "\tproto=RSN\n"
715 contents += "\tpairwise=CCMP TKIP\n"
716 contents += "\tgroup=CCMP TKIP\n"
719 contents += "\tkey_mgmt=WPA-PSK\n"
720 contents += "\tproto=WPA RSN\n"
721 contents += "\tpairwise=CCMP TKIP\n"
722 contents += "\tgroup=CCMP TKIP\n"
724 if wlanconfig.keytype.value == "ascii":
725 contents += "\""+wlanconfig.key.value+"\"\n"
727 contents += wlanconfig.key.value+"\n"
729 contents += "\tkey_mgmt=NONE\n"
731 print "content = \n"+contents
732 wpafd.write(contents)
736 self.session.open(MessageBox, _("wpa_supplicant.conf open error."), type = MessageBox.TYPE_ERROR, timeout = 10)
738 def updateCurrentInterfaces(self,ret):
740 iNetwork.getInterfaces(self.configurationMsgClose)
742 def configurationMsgClose(self,ret):
743 if ret is True and self.configurationmsg is not None:
744 self.configurationmsg.close(True)
746 def configFinished(self,data):
749 self.session.openWithCallback(self.configFinishedCB, MessageBox, _("Your network configuration has been activated."), type = MessageBox.TYPE_INFO, timeout = 10)
750 selectap = wlanconfig.essid.value
752 def configFinishedCB(self,data):
757 def formatip(self, iplist):
762 result = str(iplist[0])+"."+str(iplist[1])+"."+str(iplist[2])+"."+str(iplist[3])
769 def keyCancelConfirm(self, result):
772 if self.oldInterfaceState is False:
773 iNetwork.deactivateInterface(self.iface,self.keyCancelCB)
778 if self["config"].isChanged():
779 self.session.openWithCallback(self.keyCancelConfirm, MessageBox, _("Really close without saving settings?"))
783 def keyCancelCB(self,data):
788 # def selectionChanged(self):
789 # current = self["config"].getCurrent()
792 class WlanScanAp(Screen,HelpableScreen):
794 <screen name="WlanScanAp" position="209,48" size="865,623" title="Wireless Network Configuration..." flags="wfNoBorder" backgroundColor="transparent">
795 <ePixmap pixmap="Vu_HD/Bg_EPG_view.png" zPosition="-1" position="0,0" size="865,623" alphatest="on" />
796 <ePixmap pixmap="Vu_HD/menu/ico_title_Setup.png" position="32,41" size="40,40" alphatest="blend" transparent="1" />
797 <eLabel text="Wireless Network AP Scan..." position="90,50" size="600,32" font="Semiboldit;32" foregroundColor="#5d5d5d" backgroundColor="#27b5b9bd" transparent="1" />
798 <ePixmap pixmap="Vu_HD/icons/clock.png" position="750,55" zPosition="1" size="20,20" alphatest="blend" />
799 <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">
800 <convert type="ClockToText">Format:%H:%M</convert>
802 <ePixmap pixmap="Vu_HD/buttons/red.png" position="45,98" size="25,25" alphatest="blend" />
803 <ePixmap pixmap="Vu_HD/buttons/green.png" position="240,98" size="25,25" alphatest="blend" />
804 <ePixmap pixmap="Vu_HD/buttons/blue.png" position="630,98" size="25,25" alphatest="blend" />
805 <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" />
806 <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" />
807 <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" />
808 <ePixmap pixmap="Vu_HD/border_menu.png" position="120,140" zPosition="-1" size="342,358" transparent="1" alphatest="blend" />
809 <widget name="menulist" position="130,150" size="322,338" transparent="1" backgroundColor="#27d9dee2" zPosition="10" scrollbarMode="showOnDemand" />
810 <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" />
811 <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" />
812 <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" />
813 <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" />
814 <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" />
815 <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" />
818 def __init__(self, session, iface):
819 Screen.__init__(self,session)
820 HelpableScreen.__init__(self)
821 self.session = session
823 self.wlanscanap = None
828 self["WizardActions"] = HelpableActionMap(self, "WizardActions",
830 "up": (self.up, _("move up to previous entry")),
831 "down": (self.down, _("move down to next entry")),
832 "left": (self.left, _("move up to first entry")),
833 "right": (self.right, _("move down to last entry")),
836 self["OkCancelActions"] = HelpableActionMap(self, "OkCancelActions",
838 "cancel": (self.close, _("exit")),
839 "ok": (self.ok, "select AP"),
842 self["ColorActions"] = HelpableActionMap(self, "ColorActions",
844 "red": (self.close, _("exit")),
845 "green": (self.ok, "select AP"),
846 "blue": (self.startWlanConfig, "Edit Wireless settings"),
849 self["actions"] = NumberActionMap(["WizardActions","ShortcutActions"],
860 self["menulist"] = MenuList(self.SetApList)
861 self["key_red"] = StaticText(_("Close"))
862 self["key_green"] = StaticText(_("Select"))
863 self["key_blue"] = StaticText(_("EditSetting"))
864 self["Address"] = StaticText(_("Scanning AP List.."))
865 self["ESSID"] = StaticText(_("Wait a moment"))
866 self["Protocol"] = StaticText(" ")
867 self["Frequency"] = StaticText(" ")
868 self["Encryption key"] = StaticText(" ")
869 self["BitRate"] = StaticText(" ")
870 self.scanAplistTimer = eTimer()
871 self.scanAplistTimer.callback.append(self.scanApList)
872 self.scanAplistTimer.start(100,True)
876 self["menulist"].pageUp()
880 self["menulist"].pageDown()
884 self["menulist"].up()
888 self["menulist"].down()
893 selectAp=self["menulist"].getCurrent()[0]
897 def startWlanConfig(self):
899 selectAp=self["menulist"].getCurrent()[0]
901 self.session.open(WlanConfig,self.iface)
904 def scanApList(self):
905 print "self.scanAPcount : ",self.scanAPcount
908 self.configurationmsg = self.session.open(MessageBox, _("Please wait for scanning AP..."), type = MessageBox.TYPE_INFO, enable_input = False)
910 os_system('ifconfig '+self.iface+" up")
911 self.wlanscanap = Console()
912 cmd = "iwlist "+self.iface+" scan"
914 self.wlanscanap.ePopen(cmd, self.iwlistfinnished,self.APListParse)
916 def iwlistfinnished(self, result, retval,extra_args):
917 # print "iwlistfinnished"
918 (statecallback) = extra_args
919 if self.wlanscanap is not None:
920 # print "retval = ",retval
922 self.wlanscanap = None
923 content = result.splitlines()
924 first = content[0].split()
929 if completed == True:
930 statecallback(result)
936 def APListParse(self,data):
938 if self.scanAPcount >0:
939 self.configurationmsg.close(True)
940 self.scanAplistTimer.start(100,True)
943 self.session.open(MessageBox, _("Scan AP Failed"), MessageBox.TYPE_INFO,5)
949 list = data.splitlines()
951 # print "line : ",line
952 if line.strip().startswith("Cell"): # Cell 01 - Address: 00:26:66:5C:EF:24
953 parts = line.strip().split(" ")
954 current_ap_id = int(parts[1])
955 self.apList[current_ap_id]={}
956 self.apList[current_ap_id]["Address"]=parts[4]
957 elif line.strip().startswith("ESSID"):
958 self.apList[current_ap_id]["ESSID"]=line.strip()[6:].strip('"')
959 self.SetApList.append( (self.apList[current_ap_id]["ESSID"],current_ap_id) )
960 elif line.strip().startswith("Protocol"):
961 self.apList[current_ap_id]["Protocol"]=line.strip()[9:]
962 elif line.strip().startswith("Frequency"):
963 self.apList[current_ap_id]["Frequency"]=line.strip()[10:]
964 elif line.strip().startswith("Encryption key"):
965 self.apList[current_ap_id]["Encryption key"]=line.strip()[15:]
966 elif line.strip().startswith("Bit Rates"):
967 self.apList[current_ap_id]["BitRate"]=line.strip()[10:]
969 print len(self.apList)
970 self.configurationmsg.close(True)
973 def displayApInfo(self):
974 if len(self.apList) >0:
975 self["menulist"].setList(self.SetApList)
976 index = self["menulist"].getCurrent()[1]
977 for key in ["Address", "ESSID", "Protocol", "Frequency", "Encryption key", "BitRate"]:
978 if self.apList[index].has_key(key):
979 self[key].setText((key+": "+self.apList[index][key]))
981 self[key].setText(("None"))
983 self.session.openWithCallback(self.ScanAPclose, MessageBox, _("No AP detected."), type = MessageBox.TYPE_INFO, timeout = 10)
985 def ScanAPclose(self,data):
988 class NetworkAdapterTest(Screen):
989 def __init__(self, session,iface):
990 Screen.__init__(self, session)
992 self.oldInterfaceState = iNetwork.getAdapterAttribute(self.iface, "up")
994 self.onClose.append(self.cleanup)
995 self.onHide.append(self.cleanup)
997 self["updown_actions"] = NumberActionMap(["WizardActions","ShortcutActions"],
1001 "up": lambda: self.updownhandler('up'),
1002 "down": lambda: self.updownhandler('down'),
1006 self["shortcuts"] = ActionMap(["ShortcutActions","WizardActions"],
1009 "back": self.cancel,
1011 self["infoshortcuts"] = ActionMap(["ShortcutActions","WizardActions"],
1013 "red": self.closeInfo,
1014 "back": self.closeInfo,
1016 self["shortcutsgreen"] = ActionMap(["ShortcutActions"],
1018 "green": self.KeyGreen,
1020 self["shortcutsgreen_restart"] = ActionMap(["ShortcutActions"],
1022 "green": self.KeyGreenRestart,
1024 self["shortcutsyellow"] = ActionMap(["ShortcutActions"],
1026 "yellow": self.KeyYellow,
1029 self["shortcutsgreen_restart"].setEnabled(False)
1030 self["updown_actions"].setEnabled(False)
1031 self["infoshortcuts"].setEnabled(False)
1032 self.onClose.append(self.delTimer)
1033 self.onLayoutFinish.append(self.layoutFinished)
1034 self.steptimer = False
1036 self.activebutton = 0
1037 self.nextStepTimer = eTimer()
1038 self.nextStepTimer.callback.append(self.nextStepTimerFire)
1041 if self.oldInterfaceState is False:
1042 iNetwork.setAdapterAttribute(self.iface, "up", self.oldInterfaceState)
1043 iNetwork.deactivateInterface(self.iface)
1046 def closeInfo(self):
1047 self["shortcuts"].setEnabled(True)
1048 self["infoshortcuts"].setEnabled(False)
1049 self["InfoText"].hide()
1050 self["InfoTextBorder"].hide()
1051 self["key_red"].setText(_("Close"))
1055 del self.nextStepTimer
1057 def nextStepTimerFire(self):
1058 self.nextStepTimer.stop()
1059 self.steptimer = False
1062 def updownhandler(self,direction):
1063 if direction == 'up':
1064 if self.activebutton >=2:
1065 self.activebutton -= 1
1067 self.activebutton = 6
1068 self.setActiveButton(self.activebutton)
1069 if direction == 'down':
1070 if self.activebutton <=5:
1071 self.activebutton += 1
1073 self.activebutton = 1
1074 self.setActiveButton(self.activebutton)
1076 def setActiveButton(self,button):
1078 self["EditSettingsButton"].setPixmapNum(0)
1079 self["EditSettings_Text"].setForegroundColorNum(0)
1080 self["NetworkInfo"].setPixmapNum(0)
1081 self["NetworkInfo_Text"].setForegroundColorNum(1)
1082 self["AdapterInfo"].setPixmapNum(1) # active
1083 self["AdapterInfo_Text"].setForegroundColorNum(2) # active
1085 self["AdapterInfo_Text"].setForegroundColorNum(1)
1086 self["AdapterInfo"].setPixmapNum(0)
1087 self["DhcpInfo"].setPixmapNum(0)
1088 self["DhcpInfo_Text"].setForegroundColorNum(1)
1089 self["NetworkInfo"].setPixmapNum(1) # active
1090 self["NetworkInfo_Text"].setForegroundColorNum(2) # active
1092 self["NetworkInfo"].setPixmapNum(0)
1093 self["NetworkInfo_Text"].setForegroundColorNum(1)
1094 self["IPInfo"].setPixmapNum(0)
1095 self["IPInfo_Text"].setForegroundColorNum(1)
1096 self["DhcpInfo"].setPixmapNum(1) # active
1097 self["DhcpInfo_Text"].setForegroundColorNum(2) # active
1099 self["DhcpInfo"].setPixmapNum(0)
1100 self["DhcpInfo_Text"].setForegroundColorNum(1)
1101 self["DNSInfo"].setPixmapNum(0)
1102 self["DNSInfo_Text"].setForegroundColorNum(1)
1103 self["IPInfo"].setPixmapNum(1) # active
1104 self["IPInfo_Text"].setForegroundColorNum(2) # active
1106 self["IPInfo"].setPixmapNum(0)
1107 self["IPInfo_Text"].setForegroundColorNum(1)
1108 self["EditSettingsButton"].setPixmapNum(0)
1109 self["EditSettings_Text"].setForegroundColorNum(0)
1110 self["DNSInfo"].setPixmapNum(1) # active
1111 self["DNSInfo_Text"].setForegroundColorNum(2) # active
1113 self["DNSInfo"].setPixmapNum(0)
1114 self["DNSInfo_Text"].setForegroundColorNum(1)
1115 self["EditSettingsButton"].setPixmapNum(1) # active
1116 self["EditSettings_Text"].setForegroundColorNum(2) # active
1117 self["AdapterInfo"].setPixmapNum(0)
1118 self["AdapterInfo_Text"].setForegroundColorNum(1)
1121 next = self.nextstep
1137 self.steptimer = True
1138 self.nextStepTimer.start(3000)
1139 self["key_yellow"].setText(_("Stop test"))
1142 self["Adapter"].setText(iNetwork.getFriendlyAdapterName(self.iface))
1143 self["Adapter"].setForegroundColorNum(2)
1144 self["Adaptertext"].setForegroundColorNum(1)
1145 self["AdapterInfo_Text"].setForegroundColorNum(1)
1146 self["AdapterInfo_OK"].show()
1147 self.steptimer = True
1148 self.nextStepTimer.start(3000)
1151 self["Networktext"].setForegroundColorNum(1)
1152 self["Network"].setText(_("Please wait..."))
1153 self.AccessPointInfo(self.iface)
1154 self["NetworkInfo_Text"].setForegroundColorNum(1)
1155 self.steptimer = True
1156 self.nextStepTimer.start(3000)
1159 self["Dhcptext"].setForegroundColorNum(1)
1160 if iNetwork.getAdapterAttribute(self.iface, 'dhcp') is True:
1161 self["Dhcp"].setForegroundColorNum(2)
1162 self["Dhcp"].setText(_("enabled"))
1163 self["DhcpInfo_Check"].setPixmapNum(0)
1165 self["Dhcp"].setForegroundColorNum(1)
1166 self["Dhcp"].setText(_("disabled"))
1167 self["DhcpInfo_Check"].setPixmapNum(1)
1168 self["DhcpInfo_Check"].show()
1169 self["DhcpInfo_Text"].setForegroundColorNum(1)
1170 self.steptimer = True
1171 self.nextStepTimer.start(3000)
1174 self["IPtext"].setForegroundColorNum(1)
1175 self["IP"].setText(_("Please wait..."))
1176 iNetwork.checkNetworkState(self.NetworkStatedataAvail)
1179 self.steptimer = False
1180 self.nextStepTimer.stop()
1181 self["DNStext"].setForegroundColorNum(1)
1182 self["DNS"].setText(_("Please wait..."))
1183 iNetwork.checkDNSLookup(self.DNSLookupdataAvail)
1186 self["shortcutsgreen"].setEnabled(False)
1187 self["shortcutsyellow"].setEnabled(True)
1188 self["updown_actions"].setEnabled(False)
1189 self["key_yellow"].setText("")
1190 self["key_green"].setText("")
1191 self.steptimer = True
1192 self.nextStepTimer.start(1000)
1194 def KeyGreenRestart(self):
1196 self.layoutFinished()
1197 self["Adapter"].setText((""))
1198 self["Network"].setText((""))
1199 self["Dhcp"].setText((""))
1200 self["IP"].setText((""))
1201 self["DNS"].setText((""))
1202 self["AdapterInfo_Text"].setForegroundColorNum(0)
1203 self["NetworkInfo_Text"].setForegroundColorNum(0)
1204 self["DhcpInfo_Text"].setForegroundColorNum(0)
1205 self["IPInfo_Text"].setForegroundColorNum(0)
1206 self["DNSInfo_Text"].setForegroundColorNum(0)
1207 self["shortcutsgreen_restart"].setEnabled(False)
1208 self["shortcutsgreen"].setEnabled(False)
1209 self["shortcutsyellow"].setEnabled(True)
1210 self["updown_actions"].setEnabled(False)
1211 self["key_yellow"].setText("")
1212 self["key_green"].setText("")
1213 self.steptimer = True
1214 self.nextStepTimer.start(1000)
1217 self["infoshortcuts"].setEnabled(True)
1218 self["shortcuts"].setEnabled(False)
1219 if self.activebutton == 1: # Adapter Check
1220 self["InfoText"].setText(_("This test detects your configured Wireless LAN-Adapter."))
1221 self["InfoTextBorder"].show()
1222 self["InfoText"].show()
1223 self["key_red"].setText(_("Back"))
1224 if self.activebutton == 2: #LAN Check
1225 self["InfoText"].setText(_("This test checks whether a network cable is connected to your Wireless LAN-Adapter."))
1226 self["InfoTextBorder"].show()
1227 self["InfoText"].show()
1228 self["key_red"].setText(_("Back"))
1229 if self.activebutton == 3: #DHCP Check
1230 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."))
1231 self["InfoTextBorder"].show()
1232 self["InfoText"].show()
1233 self["key_red"].setText(_("Back"))
1234 if self.activebutton == 4: # IP Check
1235 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"))
1236 self["InfoTextBorder"].show()
1237 self["InfoText"].show()
1238 self["key_red"].setText(_("Back"))
1239 if self.activebutton == 5: # DNS Check
1240 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"))
1241 self["InfoTextBorder"].show()
1242 self["InfoText"].show()
1243 self["key_red"].setText(_("Back"))
1244 if self.activebutton == 6: # Edit Settings
1245 self.session.open(WlanConfig,self.iface)
1246 self["shortcuts"].setEnabled(True)
1247 self["infoshortcuts"].setEnabled(False)
1249 def KeyYellow(self):
1251 self["shortcutsgreen_restart"].setEnabled(True)
1252 self["shortcutsgreen"].setEnabled(False)
1253 self["shortcutsyellow"].setEnabled(False)
1254 self["key_green"].setText(_("Restart test"))
1255 self["key_yellow"].setText("")
1256 self.steptimer = False
1257 self.nextStepTimer.stop()
1259 def layoutFinished(self):
1260 self.setTitle(_("Network test: ") + iNetwork.getFriendlyAdapterName(self.iface) )
1261 self["shortcutsyellow"].setEnabled(False)
1262 self["AdapterInfo_OK"].hide()
1263 self["NetworkInfo_Check"].hide()
1264 self["DhcpInfo_Check"].hide()
1265 self["IPInfo_Check"].hide()
1266 self["DNSInfo_Check"].hide()
1267 self["EditSettings_Text"].hide()
1268 self["EditSettingsButton"].hide()
1269 self["InfoText"].hide()
1270 self["InfoTextBorder"].hide()
1271 self["key_yellow"].setText("")
1273 def setLabels(self):
1274 self["Adaptertext"] = MultiColorLabel(_("LAN Adapter"))
1275 self["Adapter"] = MultiColorLabel()
1276 self["AdapterInfo"] = MultiPixmap()
1277 self["AdapterInfo_Text"] = MultiColorLabel(_("Show Info"))
1278 self["AdapterInfo_OK"] = Pixmap()
1280 if self.iface in iNetwork.wlan_interfaces:
1281 self["Networktext"] = MultiColorLabel(_("Wireless Network"))
1283 self["Networktext"] = MultiColorLabel(_("Local Network"))
1285 self["Network"] = MultiColorLabel()
1286 self["NetworkInfo"] = MultiPixmap()
1287 self["NetworkInfo_Text"] = MultiColorLabel(_("Show Info"))
1288 self["NetworkInfo_Check"] = MultiPixmap()
1290 self["Dhcptext"] = MultiColorLabel(_("DHCP"))
1291 self["Dhcp"] = MultiColorLabel()
1292 self["DhcpInfo"] = MultiPixmap()
1293 self["DhcpInfo_Text"] = MultiColorLabel(_("Show Info"))
1294 self["DhcpInfo_Check"] = MultiPixmap()
1296 self["IPtext"] = MultiColorLabel(_("IP Address"))
1297 self["IP"] = MultiColorLabel()
1298 self["IPInfo"] = MultiPixmap()
1299 self["IPInfo_Text"] = MultiColorLabel(_("Show Info"))
1300 self["IPInfo_Check"] = MultiPixmap()
1302 self["DNStext"] = MultiColorLabel(_("Nameserver"))
1303 self["DNS"] = MultiColorLabel()
1304 self["DNSInfo"] = MultiPixmap()
1305 self["DNSInfo_Text"] = MultiColorLabel(_("Show Info"))
1306 self["DNSInfo_Check"] = MultiPixmap()
1308 self["EditSettings_Text"] = MultiColorLabel(_("Edit settings"))
1309 self["EditSettingsButton"] = MultiPixmap()
1311 self["key_red"] = StaticText(_("Close"))
1312 self["key_green"] = StaticText(_("Start test"))
1313 self["key_yellow"] = StaticText(_("Stop test"))
1315 self["InfoTextBorder"] = Pixmap()
1316 self["InfoText"] = Label()
1318 def NetworkStatedataAvail(self,data):
1320 self["IP"].setForegroundColorNum(2)
1321 self["IP"].setText(_("confirmed"))
1322 self["IPInfo_Check"].setPixmapNum(0)
1324 self["IP"].setForegroundColorNum(1)
1325 self["IP"].setText(_("unconfirmed"))
1326 self["IPInfo_Check"].setPixmapNum(1)
1327 self["IPInfo_Check"].show()
1328 self["IPInfo_Text"].setForegroundColorNum(1)
1329 self.steptimer = True
1330 self.nextStepTimer.start(3000)
1332 def DNSLookupdataAvail(self,data):
1334 self["DNS"].setForegroundColorNum(2)
1335 self["DNS"].setText(_("confirmed"))
1336 self["DNSInfo_Check"].setPixmapNum(0)
1338 self["DNS"].setForegroundColorNum(1)
1339 self["DNS"].setText(_("unconfirmed"))
1340 self["DNSInfo_Check"].setPixmapNum(1)
1341 self["DNSInfo_Check"].show()
1342 self["DNSInfo_Text"].setForegroundColorNum(1)
1343 self["EditSettings_Text"].show()
1344 self["EditSettingsButton"].setPixmapNum(1)
1345 self["EditSettings_Text"].setForegroundColorNum(2) # active
1346 self["EditSettingsButton"].show()
1347 self["key_yellow"].setText("")
1348 self["key_green"].setText(_("Restart test"))
1349 self["shortcutsgreen"].setEnabled(False)
1350 self["shortcutsgreen_restart"].setEnabled(True)
1351 self["shortcutsyellow"].setEnabled(False)
1352 self["updown_actions"].setEnabled(True)
1353 self.activebutton = 6
1355 def getInfoCB(self,status):
1356 if status is not None:
1357 if status.startswith("No Connection") or status.startswith("Not-Associated") or status == False:
1358 self["Network"].setForegroundColorNum(1)
1359 self["Network"].setText(_("disconnected"))
1360 self["NetworkInfo_Check"].setPixmapNum(1)
1361 self["NetworkInfo_Check"].show()
1363 self["Network"].setForegroundColorNum(2)
1364 self["Network"].setText(_("connected"))
1365 self["NetworkInfo_Check"].setPixmapNum(0)
1366 self["NetworkInfo_Check"].show()
1369 iNetwork.stopLinkStateConsole()
1370 iNetwork.stopDNSConsole()
1372 def AccessPointInfo(self,iface):
1373 cmd = "iwconfig %s"%iface
1374 self.iwconfigConsole = Console()
1375 self.iwconfigConsole.ePopen(cmd,self.readAP,self.getInfoCB)
1377 def readAP(self,result,retval,extra_args):
1378 (callback) = extra_args
1379 self.apState = False
1380 if self.iwconfigConsole is not None:
1382 self.iwconfigConsole = None
1383 for content in result.splitlines():
1384 if 'Access Point' in content:
1385 self.apState = content.strip().split('Access Point: ')[1]
1386 callback(self.apState)
1388 callback(self.apState)
1390 class Wlanstatus(Screen):
1392 <screen name="Wlanstatus" position="209,48" size="865,623" title="Wireless Network Configuration..." flags="wfNoBorder" backgroundColor="transparent">
1393 <ePixmap pixmap="Vu_HD/Bg_EPG_view.png" zPosition="-1" position="0,0" size="865,623" alphatest="on" />
1394 <ePixmap pixmap="Vu_HD/menu/ico_title_Setup.png" position="32,41" size="40,40" alphatest="blend" transparent="1" />
1395 <eLabel text="Wireless Network Status..." position="90,50" size="600,32" font="Semiboldit;32" foregroundColor="#5d5d5d" backgroundColor="#27b5b9bd" transparent="1" />
1396 <ePixmap pixmap="Vu_HD/icons/clock.png" position="750,55" zPosition="1" size="20,20" alphatest="blend" />
1397 <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">
1398 <convert type="ClockToText">Format:%H:%M</convert>
1400 <ePixmap pixmap="Vu_HD/buttons/red.png" position="45,98" size="25,25" alphatest="blend" />
1401 <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" />
1402 <widget source="status" render="Label" position="110,200" size="650,400" transparent="1" font="Regular;20" foregroundColor="#1c1c1c" backgroundColor="#27d9dee2" zPosition="1" />
1404 def __init__(self, session,iface):
1405 Screen.__init__(self,session)
1406 self.session = session
1408 self["status"] = StaticText(_("Wait a moment..."))
1409 self["key_red"] = StaticText(_("Close"))
1410 self["OkCancelActions"] = ActionMap(["ShortcutActions", "SetupActions" ],
1413 "cancel": self.close,
1418 def readstatus(self):
1419 self.wlanstatus = Console()
1420 cmd1 = "iwconfig "+self.iface
1421 self.wlanstatus.ePopen(cmd1, self.iwconfigfinnished,self.statusdisplay)
1423 def iwconfigfinnished(self, result, retval,extra_args):
1425 (statecallback) = extra_args
1426 if self.wlanstatus is not None:
1428 statecallback(result)
1435 def statusdisplay(self,data):
1437 self["status"].setText(_("No information..."))
1439 self["status"].setText(data)
1444 def openconfig(session, **kwargs):
1445 session.open(WlanSelection)
1447 def selSetup(menuid, **kwargs):
1449 if menuid != "system":
1452 for x in iNetwork.getAdapterList():
1453 if x.startswith('eth'):
1457 return [(_("Wireless LAN Setup"), openconfig, "wlansetup_config", 80)]
1462 def Plugins(**kwargs):
1463 return PluginDescriptor(name=_("Wireless LAN Setup"), description="Wireless LAN Setup", where = PluginDescriptor.WHERE_MENU, fnc=selSetup)