1 from 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 Components.Sources.StaticText import StaticText
9 from Components.Sources.Boolean import Boolean
10 from Components.Label import Label,MultiColorLabel
11 from Components.Pixmap import Pixmap,MultiPixmap
12 from Components.MenuList import MenuList
13 from Components.config import config, ConfigYesNo, ConfigIP, NoSave, ConfigText, ConfigPassword, ConfigSelection, getConfigListEntry, ConfigNothing
14 from Components.ConfigList import ConfigListScreen
15 from Components.PluginComponent import plugins
16 from Components.MultiContent import MultiContentEntryText, MultiContentEntryPixmapAlphaTest
17 from Components.ActionMap import ActionMap, NumberActionMap, HelpableActionMap
18 from Tools.Directories import resolveFilename, SCOPE_PLUGINS, SCOPE_CURRENT_SKIN
19 from Tools.LoadPixmap import LoadPixmap
20 from Plugins.Plugin import PluginDescriptor
21 from enigma import eTimer, ePoint, eSize, RT_HALIGN_LEFT, eListboxPythonMultiContent, gFont
22 from os import path as os_path, system as os_system, unlink
23 from re import compile as re_compile, search as re_search
26 class InterfaceList(MenuList):
27 def __init__(self, list, enableWrapAround=False):
28 MenuList.__init__(self, list, enableWrapAround, eListboxPythonMultiContent)
29 self.l.setFont(0, gFont("Regular", 20))
30 self.l.setItemHeight(30)
32 def InterfaceEntryComponent(index,name,default,active ):
35 MultiContentEntryText(pos=(80, 5), size=(430, 25), font=0, text=name)
37 num_configured_if = len(iNetwork.getConfiguredAdapters())
38 if num_configured_if >= 2:
40 png = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/buttons/button_blue.png"))
42 png = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/buttons/button_blue_off.png"))
43 res.append(MultiContentEntryPixmapAlphaTest(pos=(10, 5), size=(25, 25), png = png))
45 png2 = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/icons/lock_on.png"))
47 png2 = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/icons/lock_error.png"))
48 res.append(MultiContentEntryPixmapAlphaTest(pos=(40, 1), size=(25, 25), png = png2))
52 class NetworkAdapterSelection(Screen,HelpableScreen):
53 def __init__(self, session):
54 Screen.__init__(self, session)
55 HelpableScreen.__init__(self)
57 self.wlan_errortext = _("No working wireless network adapter found.\nPlease verify that you have attached a compatible WLAN device and your network is configured correctly.")
58 self.lan_errortext = _("No working local network adapter found.\nPlease verify that you have attached a network cable and your network is configured correctly.")
59 self.oktext = _("Press OK on your remote control to continue.")
60 self.edittext = _("Press OK to edit the settings.")
61 self.defaulttext = _("Press yellow to set this interface as default interface.")
62 self.restartLanRef = None
64 self["key_red"] = StaticText(_("Close"))
65 self["key_green"] = StaticText(_("Select"))
66 self["key_yellow"] = StaticText("")
67 self["introduction"] = StaticText(self.edittext)
69 self.adapters = [(iNetwork.getFriendlyAdapterName(x),x) for x in iNetwork.getAdapterList()]
72 self.onFirstExecBegin.append(self.NetworkFallback)
74 self["OkCancelActions"] = HelpableActionMap(self, "OkCancelActions",
76 "cancel": (self.close, _("exit network interface list")),
77 "ok": (self.okbuttonClick, _("select interface")),
80 self["ColorActions"] = HelpableActionMap(self, "ColorActions",
82 "red": (self.close, _("exit network interface list")),
83 "green": (self.okbuttonClick, _("select interface")),
86 self["DefaultInterfaceAction"] = HelpableActionMap(self, "ColorActions",
88 "yellow": (self.setDefaultInterface, [_("Set interface as default Interface"),_("* Only available if more than one interface is active.")] ),
92 self["list"] = InterfaceList(self.list)
95 if len(self.adapters) == 1:
96 self.onFirstExecBegin.append(self.okbuttonClick)
97 self.onClose.append(self.cleanup)
100 def updateList(self):
103 num_configured_if = len(iNetwork.getConfiguredAdapters())
104 if num_configured_if >= 2:
105 self["key_yellow"].setText(_("Default"))
106 self["introduction"].setText(self.defaulttext)
107 self["DefaultInterfaceAction"].setEnabled(True)
109 self["key_yellow"].setText("")
110 self["introduction"].setText(self.edittext)
111 self["DefaultInterfaceAction"].setEnabled(False)
113 if num_configured_if < 2 and os_path.exists("/etc/default_gw"):
114 unlink("/etc/default_gw")
116 if os_path.exists("/etc/default_gw"):
117 fp = file('/etc/default_gw', 'r')
122 if len(self.adapters) == 0: # no interface available => display only eth0
123 self.list.append(InterfaceEntryComponent("eth0",iNetwork.getFriendlyAdapterName('eth0'),True,True ))
125 for x in self.adapters:
126 if x[1] == default_gw:
130 if iNetwork.getAdapterAttribute(x[1], 'up') is True:
134 self.list.append(InterfaceEntryComponent(index = x[1],name = _(x[0]),default=default_int,active=active_int ))
136 self["list"].l.setList(self.list)
138 def setDefaultInterface(self):
139 selection = self["list"].getCurrent()
140 num_if = len(self.list)
141 old_default_gw = None
142 num_configured_if = len(iNetwork.getConfiguredAdapters())
143 if os_path.exists("/etc/default_gw"):
144 fp = open('/etc/default_gw', 'r')
145 old_default_gw = fp.read()
147 if num_configured_if > 1 and (not old_default_gw or old_default_gw != selection[0]):
148 fp = open('/etc/default_gw', 'w+')
149 fp.write(selection[0])
152 elif old_default_gw and num_configured_if < 2:
153 unlink("/etc/default_gw")
156 def okbuttonClick(self):
157 selection = self["list"].getCurrent()
158 if selection is not None:
159 self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetupConfiguration, selection[0])
161 def AdapterSetupClosed(self, *ret):
162 if len(self.adapters) == 1:
167 def NetworkFallback(self):
168 if iNetwork.configuredNetworkAdapters.has_key('wlan0') is True:
169 self.session.openWithCallback(self.ErrorMessageClosed, MessageBox, self.wlan_errortext, type = MessageBox.TYPE_INFO,timeout = 10)
170 if iNetwork.configuredNetworkAdapters.has_key('ath0') is True:
171 self.session.openWithCallback(self.ErrorMessageClosed, MessageBox, self.wlan_errortext, type = MessageBox.TYPE_INFO,timeout = 10)
173 self.session.openWithCallback(self.ErrorMessageClosed, MessageBox, self.lan_errortext, type = MessageBox.TYPE_INFO,timeout = 10)
175 def ErrorMessageClosed(self, *ret):
176 if iNetwork.configuredNetworkAdapters.has_key('wlan0') is True:
177 self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetupConfiguration, 'wlan0')
178 elif iNetwork.configuredNetworkAdapters.has_key('ath0') is True:
179 self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetupConfiguration, 'ath0')
181 self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetupConfiguration, 'eth0')
184 iNetwork.stopLinkStateConsole()
185 iNetwork.stopRestartConsole()
186 iNetwork.stopGetInterfacesConsole()
188 def restartLan(self):
189 iNetwork.restartNetwork(self.restartLanDataAvail)
190 self.restartLanRef = self.session.openWithCallback(self.restartfinishedCB, MessageBox, _("Please wait while we configure your network..."), type = MessageBox.TYPE_INFO, enable_input = False)
192 def restartLanDataAvail(self, data):
194 iNetwork.getInterfaces(self.getInterfacesDataAvail)
196 def getInterfacesDataAvail(self, data):
198 self.restartLanRef.close(True)
200 def restartfinishedCB(self,data):
203 self.session.open(MessageBox, _("Finished configuring your network"), type = MessageBox.TYPE_INFO, timeout = 10, default = False)
207 class NameserverSetup(Screen, ConfigListScreen, HelpableScreen):
208 def __init__(self, session):
209 Screen.__init__(self, session)
210 HelpableScreen.__init__(self)
211 self.backupNameserverList = iNetwork.getNameserverList()[:]
212 print "backup-list:", self.backupNameserverList
214 self["key_red"] = StaticText(_("Cancel"))
215 self["key_green"] = StaticText(_("Add"))
216 self["key_yellow"] = StaticText(_("Delete"))
218 self["introduction"] = StaticText(_("Press OK to activate the settings."))
221 self["OkCancelActions"] = HelpableActionMap(self, "OkCancelActions",
223 "cancel": (self.cancel, _("exit nameserver configuration")),
224 "ok": (self.ok, _("activate current configuration")),
227 self["ColorActions"] = HelpableActionMap(self, "ColorActions",
229 "red": (self.cancel, _("exit nameserver configuration")),
230 "green": (self.add, _("add a nameserver entry")),
231 "yellow": (self.remove, _("remove a nameserver entry")),
234 self["actions"] = NumberActionMap(["SetupActions"],
240 ConfigListScreen.__init__(self, self.list)
243 def createConfig(self):
244 self.nameservers = iNetwork.getNameserverList()
245 self.nameserverEntries = [ NoSave(ConfigIP(default=nameserver)) for nameserver in self.nameservers]
247 def createSetup(self):
251 for x in self.nameserverEntries:
252 self.list.append(getConfigListEntry(_("Nameserver %d") % (i), x))
255 self["config"].list = self.list
256 self["config"].l.setList(self.list)
259 iNetwork.clearNameservers()
260 for nameserver in self.nameserverEntries:
261 iNetwork.addNameserver(nameserver.value)
262 iNetwork.writeNameserverConfig()
269 iNetwork.clearNameservers()
270 print "backup-list:", self.backupNameserverList
271 for nameserver in self.backupNameserverList:
272 iNetwork.addNameserver(nameserver)
276 iNetwork.addNameserver([0,0,0,0])
281 print "currentIndex:", self["config"].getCurrentIndex()
282 index = self["config"].getCurrentIndex()
283 if index < len(self.nameservers):
284 iNetwork.removeNameserver(self.nameservers[index])
289 class AdapterSetup(Screen, ConfigListScreen, HelpableScreen):
290 def __init__(self, session, networkinfo, essid=None, aplist=None):
291 Screen.__init__(self, session)
292 HelpableScreen.__init__(self)
293 self.session = session
294 if isinstance(networkinfo, (list, tuple)):
295 self.iface = networkinfo[0]
296 self.essid = networkinfo[1]
297 self.aplist = networkinfo[2]
299 self.iface = networkinfo
303 self.applyConfigRef = None
304 self.finished_cb = None
305 self.oktext = _("Press OK on your remote control to continue.")
306 self.oldInterfaceState = iNetwork.getAdapterAttribute(self.iface, "up")
310 self["OkCancelActions"] = HelpableActionMap(self, "OkCancelActions",
312 "cancel": (self.keyCancel, _("exit network adapter configuration")),
313 "ok": (self.keySave, _("activate network adapter configuration")),
316 self["ColorActions"] = HelpableActionMap(self, "ColorActions",
318 "red": (self.keyCancel, _("exit network adapter configuration")),
319 "blue": (self.KeyBlue, _("open nameserver configuration")),
322 self["actions"] = NumberActionMap(["SetupActions"],
328 ConfigListScreen.__init__(self, self.list,session = self.session)
330 self.onLayoutFinish.append(self.layoutFinished)
331 self.onClose.append(self.cleanup)
333 self["DNS1text"] = StaticText(_("Primary DNS"))
334 self["DNS2text"] = StaticText(_("Secondary DNS"))
335 self["DNS1"] = StaticText()
336 self["DNS2"] = StaticText()
337 self["introduction"] = StaticText(_("Current settings:"))
339 self["IPtext"] = StaticText(_("IP Address"))
340 self["Netmasktext"] = StaticText(_("Netmask"))
341 self["Gatewaytext"] = StaticText(_("Gateway"))
343 self["IP"] = StaticText()
344 self["Mask"] = StaticText()
345 self["Gateway"] = StaticText()
347 self["Adaptertext"] = StaticText(_("Network:"))
348 self["Adapter"] = StaticText()
349 self["introduction2"] = StaticText(_("Press OK to activate the settings."))
350 self["key_red"] = StaticText(_("Cancel"))
351 self["key_blue"] = StaticText(_("Edit DNS"))
353 self["VKeyIcon"] = Boolean(False)
354 self["HelpWindow"] = Pixmap()
355 self["HelpWindow"].hide()
357 def layoutFinished(self):
358 self["DNS1"].setText(self.primaryDNS.getText())
359 self["DNS2"].setText(self.secondaryDNS.getText())
360 if self.ipConfigEntry.getText() is not None:
361 if self.ipConfigEntry.getText() == "0.0.0.0":
362 self["IP"].setText(_("N/A"))
364 self["IP"].setText(self.ipConfigEntry.getText())
366 self["IP"].setText(_("N/A"))
367 if self.netmaskConfigEntry.getText() is not None:
368 if self.netmaskConfigEntry.getText() == "0.0.0.0":
369 self["Mask"].setText(_("N/A"))
371 self["Mask"].setText(self.netmaskConfigEntry.getText())
373 self["IP"].setText(_("N/A"))
374 if iNetwork.getAdapterAttribute(self.iface, "gateway"):
375 if self.gatewayConfigEntry.getText() == "0.0.0.0":
376 self["Gatewaytext"].setText(_("Gateway"))
377 self["Gateway"].setText(_("N/A"))
379 self["Gatewaytext"].setText(_("Gateway"))
380 self["Gateway"].setText(self.gatewayConfigEntry.getText())
382 self["Gateway"].setText("")
383 self["Gatewaytext"].setText("")
384 self["Adapter"].setText(iNetwork.getFriendlyAdapterName(self.iface))
386 def createConfig(self):
387 self.InterfaceEntry = None
388 self.dhcpEntry = None
389 self.gatewayEntry = None
390 self.hiddenSSID = None
392 self.encryptionEnabled = None
393 self.encryptionKey = None
394 self.encryptionType = None
396 self.encryptionlist = None
401 if self.iface == "wlan0" or self.iface == "ath0" :
402 from Plugins.SystemPlugins.WirelessLan.Wlan import wpaSupplicant,Wlan
403 self.w = Wlan(self.iface)
404 self.ws = wpaSupplicant()
405 self.encryptionlist = []
406 self.encryptionlist.append(("WEP", _("WEP")))
407 self.encryptionlist.append(("WPA", _("WPA")))
408 self.encryptionlist.append(("WPA2", _("WPA2")))
409 self.encryptionlist.append(("WPA/WPA2", _("WPA or WPA2")))
411 self.weplist.append("ASCII")
412 self.weplist.append("HEX")
413 if self.aplist is not None:
414 self.nwlist = self.aplist
415 self.nwlist.sort(key = lambda x: x[0])
420 self.aps = self.w.getNetworkList()
421 if self.aps is not None:
426 self.nwlist.append((a['essid'],a['essid']))
427 self.nwlist.sort(key = lambda x: x[0])
429 self.nwlist.append(("No Networks found",_("No Networks found")))
431 self.wsconfig = self.ws.loadConfig()
432 if self.essid is not None: # ssid from wlan scan
433 self.default = self.essid
435 self.default = self.wsconfig['ssid']
437 if "hidden..." not in self.nwlist:
438 self.nwlist.append(("hidden...",_("enter hidden network SSID")))
439 if self.default not in self.nwlist:
440 self.nwlist.append((self.default,self.default))
441 config.plugins.wlan.essid = NoSave(ConfigSelection(self.nwlist, default = self.default ))
442 config.plugins.wlan.hiddenessid = NoSave(ConfigText(default = self.wsconfig['hiddenessid'], visible_width = 50, fixed_size = False))
444 config.plugins.wlan.encryption.enabled = NoSave(ConfigYesNo(default = self.wsconfig['encryption'] ))
445 config.plugins.wlan.encryption.type = NoSave(ConfigSelection(self.encryptionlist, default = self.wsconfig['encryption_type'] ))
446 config.plugins.wlan.encryption.wepkeytype = NoSave(ConfigSelection(self.weplist, default = self.wsconfig['encryption_wepkeytype'] ))
447 config.plugins.wlan.encryption.psk = NoSave(ConfigPassword(default = self.wsconfig['key'], visible_width = 50, fixed_size = False))
449 self.activateInterfaceEntry = NoSave(ConfigYesNo(default=iNetwork.getAdapterAttribute(self.iface, "up") or False))
450 self.dhcpConfigEntry = NoSave(ConfigYesNo(default=iNetwork.getAdapterAttribute(self.iface, "dhcp") or False))
451 self.ipConfigEntry = NoSave(ConfigIP(default=iNetwork.getAdapterAttribute(self.iface, "ip")) or [0,0,0,0])
452 self.netmaskConfigEntry = NoSave(ConfigIP(default=iNetwork.getAdapterAttribute(self.iface, "netmask") or [255,0,0,0]))
453 if iNetwork.getAdapterAttribute(self.iface, "gateway"):
454 self.dhcpdefault=True
456 self.dhcpdefault=False
457 self.hasGatewayConfigEntry = NoSave(ConfigYesNo(default=self.dhcpdefault or False))
458 self.gatewayConfigEntry = NoSave(ConfigIP(default=iNetwork.getAdapterAttribute(self.iface, "gateway") or [0,0,0,0]))
459 nameserver = (iNetwork.getNameserverList() + [[0,0,0,0]] * 2)[0:2]
460 self.primaryDNS = NoSave(ConfigIP(default=nameserver[0]))
461 self.secondaryDNS = NoSave(ConfigIP(default=nameserver[1]))
463 def createSetup(self):
465 self.InterfaceEntry = getConfigListEntry(_("Use Interface"), self.activateInterfaceEntry)
467 self.list.append(self.InterfaceEntry)
468 if self.activateInterfaceEntry.value:
469 self.dhcpEntry = getConfigListEntry(_("Use DHCP"), self.dhcpConfigEntry)
470 self.list.append(self.dhcpEntry)
471 if not self.dhcpConfigEntry.value:
472 self.list.append(getConfigListEntry(_('IP Address'), self.ipConfigEntry))
473 self.list.append(getConfigListEntry(_('Netmask'), self.netmaskConfigEntry))
474 self.gatewayEntry = getConfigListEntry(_('Use a gateway'), self.hasGatewayConfigEntry)
475 self.list.append(self.gatewayEntry)
476 if self.hasGatewayConfigEntry.value:
477 self.list.append(getConfigListEntry(_('Gateway'), self.gatewayConfigEntry))
480 for p in plugins.getPlugins(PluginDescriptor.WHERE_NETWORKSETUP):
481 callFnc = p.__call__["ifaceSupported"](self.iface)
482 if callFnc is not None:
483 if p.__call__.has_key("WlanPluginEntry"): # internally used only for WLAN Plugin
484 self.extended = callFnc
485 if p.__call__.has_key("configStrings"):
486 self.configStrings = p.__call__["configStrings"]
488 self.configStrings = None
489 if config.plugins.wlan.essid.value == 'hidden...':
490 self.wlanSSID = getConfigListEntry(_("Network SSID"), config.plugins.wlan.essid)
491 self.list.append(self.wlanSSID)
492 self.hiddenSSID = getConfigListEntry(_("Hidden network SSID"), config.plugins.wlan.hiddenessid)
493 self.list.append(self.hiddenSSID)
495 self.wlanSSID = getConfigListEntry(_("Network SSID"), config.plugins.wlan.essid)
496 self.list.append(self.wlanSSID)
497 self.encryptionEnabled = getConfigListEntry(_("Encryption"), config.plugins.wlan.encryption.enabled)
498 self.list.append(self.encryptionEnabled)
500 if config.plugins.wlan.encryption.enabled.value:
501 self.encryptionType = getConfigListEntry(_("Encryption Type"), config.plugins.wlan.encryption.type)
502 self.list.append(self.encryptionType)
503 if config.plugins.wlan.encryption.type.value == 'WEP':
504 self.list.append(getConfigListEntry(_("Encryption Keytype"), config.plugins.wlan.encryption.wepkeytype))
505 self.encryptionKey = getConfigListEntry(_("Encryption Key"), config.plugins.wlan.encryption.psk)
506 self.list.append(self.encryptionKey)
508 self.encryptionKey = getConfigListEntry(_("Encryption Key"), config.plugins.wlan.encryption.psk)
509 self.list.append(self.encryptionKey)
511 self["config"].list = self.list
512 self["config"].l.setList(self.list)
515 self.session.openWithCallback(self.NameserverSetupClosed, NameserverSetup)
518 if self["config"].getCurrent() == self.InterfaceEntry:
520 if self["config"].getCurrent() == self.dhcpEntry:
522 if self["config"].getCurrent() == self.gatewayEntry:
524 if self.iface == "wlan0" or self.iface == "ath0" :
525 if self["config"].getCurrent() == self.wlanSSID:
527 if self["config"].getCurrent() == self.encryptionEnabled:
529 if self["config"].getCurrent() == self.encryptionType:
533 ConfigListScreen.keyLeft(self)
537 ConfigListScreen.keyRight(self)
542 if self["config"].isChanged():
543 self.session.openWithCallback(self.keySaveConfirm, MessageBox, (_("Are you sure you want to activate this network configuration?\n\n") + self.oktext ) )
550 def keySaveConfirm(self, ret = False):
552 num_configured_if = len(iNetwork.getConfiguredAdapters())
553 if num_configured_if >= 1:
554 self.session.openWithCallback(self.secondIfaceFoundCB, MessageBox, _("A second configured interface has been found.\n\nDo you want to disable the second network interface?"), default = True)
556 self.applyConfig(True)
560 def secondIfaceFoundCB(self,data):
562 self.applyConfig(True)
564 configuredInterfaces = iNetwork.getConfiguredAdapters()
565 for interface in configuredInterfaces:
566 if interface == self.iface:
568 iNetwork.setAdapterAttribute(interface, "up", False)
569 iNetwork.deactivateInterface(interface)
570 self.applyConfig(True)
572 def applyConfig(self, ret = False):
574 iNetwork.setAdapterAttribute(self.iface, "up", self.activateInterfaceEntry.value)
575 iNetwork.setAdapterAttribute(self.iface, "dhcp", self.dhcpConfigEntry.value)
576 iNetwork.setAdapterAttribute(self.iface, "ip", self.ipConfigEntry.value)
577 iNetwork.setAdapterAttribute(self.iface, "netmask", self.netmaskConfigEntry.value)
578 if self.hasGatewayConfigEntry.value:
579 iNetwork.setAdapterAttribute(self.iface, "gateway", self.gatewayConfigEntry.value)
581 iNetwork.removeAdapterAttribute(self.iface, "gateway")
582 if self.extended is not None and self.configStrings is not None:
583 iNetwork.setAdapterAttribute(self.iface, "configStrings", self.configStrings(self.iface))
584 self.ws.writeConfig()
585 if self.activateInterfaceEntry.value is False:
586 iNetwork.deactivateInterface(self.iface)
587 iNetwork.writeNetworkConfig()
588 iNetwork.restartNetwork(self.applyConfigDataAvail)
589 self.applyConfigRef = self.session.openWithCallback(self.applyConfigfinishedCB, MessageBox, _("Please wait for activation of your network configuration..."), type = MessageBox.TYPE_INFO, enable_input = False)
593 def applyConfigDataAvail(self, data):
595 iNetwork.getInterfaces(self.getInterfacesDataAvail)
597 def getInterfacesDataAvail(self, data):
599 self.applyConfigRef.close(True)
601 def applyConfigfinishedCB(self,data):
604 self.session.openWithCallback(lambda x : self.finished_cb(), MessageBox, _("Your network configuration has been activated."), type = MessageBox.TYPE_INFO, timeout = 10)
606 self.session.openWithCallback(self.ConfigfinishedCB, MessageBox, _("Your network configuration has been activated."), type = MessageBox.TYPE_INFO, timeout = 10)
608 def ConfigfinishedCB(self,data):
613 def keyCancelConfirm(self, result):
616 if self.oldInterfaceState is False:
617 iNetwork.deactivateInterface(self.iface,self.keyCancelCB)
623 if self["config"].isChanged():
624 self.session.openWithCallback(self.keyCancelConfirm, MessageBox, _("Really close without saving settings?"))
628 def keyCancelCB(self,data):
633 def runAsync(self, finished_cb):
634 self.finished_cb = finished_cb
637 def NameserverSetupClosed(self, *ret):
638 iNetwork.loadNameserverConfig()
639 nameserver = (iNetwork.getNameserverList() + [[0,0,0,0]] * 2)[0:2]
640 self.primaryDNS = NoSave(ConfigIP(default=nameserver[0]))
641 self.secondaryDNS = NoSave(ConfigIP(default=nameserver[1]))
643 self.layoutFinished()
646 iNetwork.stopLinkStateConsole()
648 def hideInputHelp(self):
649 current = self["config"].getCurrent()
650 if current == self.hiddenSSID and config.plugins.wlan.essid.value == 'hidden...':
651 if current[1].help_window.instance is not None:
652 current[1].help_window.instance.hide()
653 elif current == self.encryptionKey and config.plugins.wlan.encryption.enabled.value:
654 if current[1].help_window.instance is not None:
655 current[1].help_window.instance.hide()
658 class AdapterSetupConfiguration(Screen, HelpableScreen):
659 def __init__(self, session,iface):
660 Screen.__init__(self, session)
661 HelpableScreen.__init__(self)
662 self.session = session
664 self.restartLanRef = None
665 self.LinkState = None
666 self.mainmenu = self.genMainMenu()
667 self["menulist"] = MenuList(self.mainmenu)
668 self["key_red"] = StaticText(_("Close"))
669 self["description"] = StaticText()
670 self["IFtext"] = StaticText()
671 self["IF"] = StaticText()
672 self["Statustext"] = StaticText()
673 self["statuspic"] = MultiPixmap()
674 self["statuspic"].hide()
676 self.oktext = _("Press OK on your remote control to continue.")
677 self.reboottext = _("Your Dreambox will restart after pressing OK on your remote control.")
678 self.errortext = _("No working wireless network interface found.\n Please verify that you have attached a compatible WLAN device or enable your local network interface.")
680 self["WizardActions"] = HelpableActionMap(self, "WizardActions",
682 "up": (self.up, _("move up to previous entry")),
683 "down": (self.down, _("move down to next entry")),
684 "left": (self.left, _("move up to first entry")),
685 "right": (self.right, _("move down to last entry")),
688 self["OkCancelActions"] = HelpableActionMap(self, "OkCancelActions",
690 "cancel": (self.close, _("exit networkadapter setup menu")),
691 "ok": (self.ok, _("select menu entry")),
694 self["ColorActions"] = HelpableActionMap(self, "ColorActions",
696 "red": (self.close, _("exit networkadapter setup menu")),
699 self["actions"] = NumberActionMap(["WizardActions","ShortcutActions"],
710 self.updateStatusbar()
711 self.onLayoutFinish.append(self.layoutFinished)
712 self.onClose.append(self.cleanup)
715 self.stopCheckNetworkConsole()
716 if self["menulist"].getCurrent()[1] == 'edit':
717 if self.iface == 'wlan0' or self.iface == 'ath0':
719 from Plugins.SystemPlugins.WirelessLan.plugin import WlanScan
720 from Plugins.SystemPlugins.WirelessLan.iwlibs import Wireless
722 self.session.open(MessageBox, _("The wireless LAN plugin is not installed!\nPlease install it."), type = MessageBox.TYPE_INFO,timeout = 10 )
724 ifobj = Wireless(self.iface) # a Wireless NIC Object
725 self.wlanresponse = ifobj.getStatistics()
726 if self.wlanresponse[0] != 19: # Wlan Interface found.
727 self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetup,self.iface)
729 # Display Wlan not available Message
730 self.showErrorMessage()
732 self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetup,self.iface)
733 if self["menulist"].getCurrent()[1] == 'test':
734 self.session.open(NetworkAdapterTest,self.iface)
735 if self["menulist"].getCurrent()[1] == 'dns':
736 self.session.open(NameserverSetup)
737 if self["menulist"].getCurrent()[1] == 'scanwlan':
739 from Plugins.SystemPlugins.WirelessLan.plugin import WlanScan
740 from Plugins.SystemPlugins.WirelessLan.iwlibs import Wireless
742 self.session.open(MessageBox, _("The wireless LAN plugin is not installed!\nPlease install it."), type = MessageBox.TYPE_INFO,timeout = 10 )
744 ifobj = Wireless(self.iface) # a Wireless NIC Object
745 self.wlanresponse = ifobj.getStatistics()
746 if self.wlanresponse[0] != 19:
747 self.session.openWithCallback(self.WlanScanClosed, WlanScan, self.iface)
749 # Display Wlan not available Message
750 self.showErrorMessage()
751 if self["menulist"].getCurrent()[1] == 'wlanstatus':
753 from Plugins.SystemPlugins.WirelessLan.plugin import WlanStatus
754 from Plugins.SystemPlugins.WirelessLan.iwlibs import Wireless
756 self.session.open(MessageBox, _("The wireless LAN plugin is not installed!\nPlease install it."), type = MessageBox.TYPE_INFO,timeout = 10 )
758 ifobj = Wireless(self.iface) # a Wireless NIC Object
759 self.wlanresponse = ifobj.getStatistics()
760 if self.wlanresponse[0] != 19:
761 self.session.openWithCallback(self.WlanStatusClosed, WlanStatus,self.iface)
763 # Display Wlan not available Message
764 self.showErrorMessage()
765 if self["menulist"].getCurrent()[1] == 'lanrestart':
766 self.session.openWithCallback(self.restartLan, MessageBox, (_("Are you sure you want to restart your network interfaces?\n\n") + self.oktext ) )
767 if self["menulist"].getCurrent()[1] == 'openwizard':
768 from Plugins.SystemPlugins.NetworkWizard.NetworkWizard import NetworkWizard
769 self.session.openWithCallback(self.AdapterSetupClosed, NetworkWizard)
770 if self["menulist"].getCurrent()[1][0] == 'extendedSetup':
771 self.extended = self["menulist"].getCurrent()[1][2]
772 self.extended(self.session, self.iface)
775 self["menulist"].up()
776 self.loadDescription()
779 self["menulist"].down()
780 self.loadDescription()
783 self["menulist"].pageUp()
784 self.loadDescription()
787 self["menulist"].pageDown()
788 self.loadDescription()
790 def layoutFinished(self):
792 self["menulist"].moveToIndex(idx)
793 self.loadDescription()
795 def loadDescription(self):
796 if self["menulist"].getCurrent()[1] == 'edit':
797 self["description"].setText(_("Edit the network configuration of your Dreambox.\n" ) + self.oktext )
798 if self["menulist"].getCurrent()[1] == 'test':
799 self["description"].setText(_("Test the network configuration of your Dreambox.\n" ) + self.oktext )
800 if self["menulist"].getCurrent()[1] == 'dns':
801 self["description"].setText(_("Edit the Nameserver configuration of your Dreambox.\n" ) + self.oktext )
802 if self["menulist"].getCurrent()[1] == 'scanwlan':
803 self["description"].setText(_("Scan your network for wireless Access Points and connect to them using your selected wireless device.\n" ) + self.oktext )
804 if self["menulist"].getCurrent()[1] == 'wlanstatus':
805 self["description"].setText(_("Shows the state of your wireless LAN connection.\n" ) + self.oktext )
806 if self["menulist"].getCurrent()[1] == 'lanrestart':
807 self["description"].setText(_("Restart your network connection and interfaces.\n" ) + self.oktext )
808 if self["menulist"].getCurrent()[1] == 'openwizard':
809 self["description"].setText(_("Use the Networkwizard to configure your Network\n" ) + self.oktext )
810 if self["menulist"].getCurrent()[1][0] == 'extendedSetup':
811 self["description"].setText(_(self["menulist"].getCurrent()[1][1]) + self.oktext )
813 def updateStatusbar(self, data = None):
814 self.mainmenu = self.genMainMenu()
815 self["menulist"].l.setList(self.mainmenu)
816 self["IFtext"].setText(_("Network:"))
817 self["IF"].setText(iNetwork.getFriendlyAdapterName(self.iface))
818 self["Statustext"].setText(_("Link:"))
820 if self.iface == 'wlan0' or self.iface == 'ath0':
822 from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus
824 self["statuspic"].setPixmapNum(1)
825 self["statuspic"].show()
827 iStatus.getDataForInterface(self.iface,self.getInfoCB)
829 iNetwork.getLinkState(self.iface,self.dataAvail)
834 def genMainMenu(self):
836 menu.append((_("Adapter settings"), "edit"))
837 menu.append((_("Nameserver settings"), "dns"))
838 menu.append((_("Network test"), "test"))
839 menu.append((_("Restart network"), "lanrestart"))
842 self.extendedSetup = None
843 for p in plugins.getPlugins(PluginDescriptor.WHERE_NETWORKSETUP):
844 callFnc = p.__call__["ifaceSupported"](self.iface)
845 if callFnc is not None:
846 self.extended = callFnc
847 if p.__call__.has_key("WlanPluginEntry"): # internally used only for WLAN Plugin
848 menu.append((_("Scan Wireless Networks"), "scanwlan"))
849 if iNetwork.getAdapterAttribute(self.iface, "up"):
850 menu.append((_("Show WLAN Status"), "wlanstatus"))
852 if p.__call__.has_key("menuEntryName"):
853 menuEntryName = p.__call__["menuEntryName"](self.iface)
855 menuEntryName = _('Extended Setup...')
856 if p.__call__.has_key("menuEntryDescription"):
857 menuEntryDescription = p.__call__["menuEntryDescription"](self.iface)
859 menuEntryDescription = _('Extended Networksetup Plugin...')
860 self.extendedSetup = ('extendedSetup',menuEntryDescription, self.extended)
861 menu.append((menuEntryName,self.extendedSetup))
863 if os_path.exists(resolveFilename(SCOPE_PLUGINS, "SystemPlugins/NetworkWizard/networkwizard.xml")):
864 menu.append((_("NetworkWizard"), "openwizard"))
868 def AdapterSetupClosed(self, *ret):
869 if ret is not None and len(ret):
870 if ret[0] == 'ok' and (self.iface == 'wlan0' or self.iface == 'ath0') and iNetwork.getAdapterAttribute(self.iface, "up") is True:
872 from Plugins.SystemPlugins.WirelessLan.plugin import WlanStatus
873 from Plugins.SystemPlugins.WirelessLan.iwlibs import Wireless
875 self.session.open(MessageBox, _("The wireless LAN plugin is not installed!\nPlease install it."), type = MessageBox.TYPE_INFO,timeout = 10 )
877 ifobj = Wireless(self.iface) # a Wireless NIC Object
878 self.wlanresponse = ifobj.getStatistics()
879 if self.wlanresponse[0] != 19:
880 self.session.openWithCallback(self.WlanStatusClosed, WlanStatus,self.iface)
882 # Display Wlan not available Message
883 self.showErrorMessage()
885 self.updateStatusbar()
887 self.updateStatusbar()
889 def WlanStatusClosed(self, *ret):
890 if ret is not None and len(ret):
891 from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus,Status
892 iStatus.stopWlanConsole()
893 self.updateStatusbar()
895 def WlanScanClosed(self,*ret):
896 if ret[0] is not None:
897 self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetup, self.iface,ret[0],ret[1])
899 from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus,Status
900 iStatus.stopWlanConsole()
901 self.updateStatusbar()
903 def restartLan(self, ret = False):
905 iNetwork.restartNetwork(self.restartLanDataAvail)
906 self.restartLanRef = self.session.openWithCallback(self.restartfinishedCB, MessageBox, _("Please wait while your network is restarting..."), type = MessageBox.TYPE_INFO, enable_input = False)
908 def restartLanDataAvail(self, data):
910 iNetwork.getInterfaces(self.getInterfacesDataAvail)
912 def getInterfacesDataAvail(self, data):
914 self.restartLanRef.close(True)
916 def restartfinishedCB(self,data):
918 self.updateStatusbar()
919 self.session.open(MessageBox, _("Finished restarting your network"), type = MessageBox.TYPE_INFO, timeout = 10, default = False)
921 def dataAvail(self,data):
922 self.LinkState = None
923 for line in data.splitlines():
925 if 'Link detected:' in line:
927 self.LinkState = True
929 self.LinkState = False
930 iNetwork.checkNetworkState(self.checkNetworkCB)
932 def showErrorMessage(self):
933 self.session.open(MessageBox, self.errortext, type = MessageBox.TYPE_INFO,timeout = 10 )
936 iNetwork.stopLinkStateConsole()
937 iNetwork.stopDeactivateInterfaceConsole()
938 self.stopCheckNetworkConsole()
940 from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus
944 iStatus.stopWlanConsole()
946 def getInfoCB(self,data,status):
949 if status is not None:
950 if status[self.iface]["acesspoint"] == "No Connection" or status[self.iface]["acesspoint"] == "Not-Associated" or status[self.iface]["acesspoint"] == False:
951 self["statuspic"].setPixmapNum(1)
953 self["statuspic"].setPixmapNum(0)
954 self["statuspic"].show()
956 def checkNetworkCB(self,data):
957 if iNetwork.getAdapterAttribute(self.iface, "up") is True:
958 if self.LinkState is True:
960 self["statuspic"].setPixmapNum(0)
962 self["statuspic"].setPixmapNum(1)
964 self["statuspic"].setPixmapNum(1)
966 self["statuspic"].setPixmapNum(1)
967 self["statuspic"].show()
969 def stopCheckNetworkConsole(self):
970 if iNetwork.PingConsole is not None:
971 if len(iNetwork.PingConsole.appContainers):
972 for name in iNetwork.PingConsole.appContainers.keys():
973 iNetwork.PingConsole.kill(name)
975 class NetworkAdapterTest(Screen):
976 def __init__(self, session,iface):
977 Screen.__init__(self, session)
979 self.oldInterfaceState = iNetwork.getAdapterAttribute(self.iface, "up")
981 self.onClose.append(self.cleanup)
982 self.onHide.append(self.cleanup)
984 self["updown_actions"] = NumberActionMap(["WizardActions","ShortcutActions"],
988 "up": lambda: self.updownhandler('up'),
989 "down": lambda: self.updownhandler('down'),
993 self["shortcuts"] = ActionMap(["ShortcutActions","WizardActions"],
998 self["infoshortcuts"] = ActionMap(["ShortcutActions","WizardActions"],
1000 "red": self.closeInfo,
1001 "back": self.closeInfo,
1003 self["shortcutsgreen"] = ActionMap(["ShortcutActions"],
1005 "green": self.KeyGreen,
1007 self["shortcutsgreen_restart"] = ActionMap(["ShortcutActions"],
1009 "green": self.KeyGreenRestart,
1011 self["shortcutsyellow"] = ActionMap(["ShortcutActions"],
1013 "yellow": self.KeyYellow,
1016 self["shortcutsgreen_restart"].setEnabled(False)
1017 self["updown_actions"].setEnabled(False)
1018 self["infoshortcuts"].setEnabled(False)
1019 self.onClose.append(self.delTimer)
1020 self.onLayoutFinish.append(self.layoutFinished)
1021 self.steptimer = False
1023 self.activebutton = 0
1024 self.nextStepTimer = eTimer()
1025 self.nextStepTimer.callback.append(self.nextStepTimerFire)
1028 if self.oldInterfaceState is False:
1029 iNetwork.setAdapterAttribute(self.iface, "up", self.oldInterfaceState)
1030 iNetwork.deactivateInterface(self.iface)
1033 def closeInfo(self):
1034 self["shortcuts"].setEnabled(True)
1035 self["infoshortcuts"].setEnabled(False)
1036 self["InfoText"].hide()
1037 self["InfoTextBorder"].hide()
1038 self["key_red"].setText(_("Close"))
1042 del self.nextStepTimer
1044 def nextStepTimerFire(self):
1045 self.nextStepTimer.stop()
1046 self.steptimer = False
1049 def updownhandler(self,direction):
1050 if direction == 'up':
1051 if self.activebutton >=2:
1052 self.activebutton -= 1
1054 self.activebutton = 6
1055 self.setActiveButton(self.activebutton)
1056 if direction == 'down':
1057 if self.activebutton <=5:
1058 self.activebutton += 1
1060 self.activebutton = 1
1061 self.setActiveButton(self.activebutton)
1063 def setActiveButton(self,button):
1065 self["EditSettingsButton"].setPixmapNum(0)
1066 self["EditSettings_Text"].setForegroundColorNum(0)
1067 self["NetworkInfo"].setPixmapNum(0)
1068 self["NetworkInfo_Text"].setForegroundColorNum(1)
1069 self["AdapterInfo"].setPixmapNum(1) # active
1070 self["AdapterInfo_Text"].setForegroundColorNum(2) # active
1072 self["AdapterInfo_Text"].setForegroundColorNum(1)
1073 self["AdapterInfo"].setPixmapNum(0)
1074 self["DhcpInfo"].setPixmapNum(0)
1075 self["DhcpInfo_Text"].setForegroundColorNum(1)
1076 self["NetworkInfo"].setPixmapNum(1) # active
1077 self["NetworkInfo_Text"].setForegroundColorNum(2) # active
1079 self["NetworkInfo"].setPixmapNum(0)
1080 self["NetworkInfo_Text"].setForegroundColorNum(1)
1081 self["IPInfo"].setPixmapNum(0)
1082 self["IPInfo_Text"].setForegroundColorNum(1)
1083 self["DhcpInfo"].setPixmapNum(1) # active
1084 self["DhcpInfo_Text"].setForegroundColorNum(2) # active
1086 self["DhcpInfo"].setPixmapNum(0)
1087 self["DhcpInfo_Text"].setForegroundColorNum(1)
1088 self["DNSInfo"].setPixmapNum(0)
1089 self["DNSInfo_Text"].setForegroundColorNum(1)
1090 self["IPInfo"].setPixmapNum(1) # active
1091 self["IPInfo_Text"].setForegroundColorNum(2) # active
1093 self["IPInfo"].setPixmapNum(0)
1094 self["IPInfo_Text"].setForegroundColorNum(1)
1095 self["EditSettingsButton"].setPixmapNum(0)
1096 self["EditSettings_Text"].setForegroundColorNum(0)
1097 self["DNSInfo"].setPixmapNum(1) # active
1098 self["DNSInfo_Text"].setForegroundColorNum(2) # active
1100 self["DNSInfo"].setPixmapNum(0)
1101 self["DNSInfo_Text"].setForegroundColorNum(1)
1102 self["EditSettingsButton"].setPixmapNum(1) # active
1103 self["EditSettings_Text"].setForegroundColorNum(2) # active
1104 self["AdapterInfo"].setPixmapNum(0)
1105 self["AdapterInfo_Text"].setForegroundColorNum(1)
1108 next = self.nextstep
1124 self.steptimer = True
1125 self.nextStepTimer.start(3000)
1126 self["key_yellow"].setText(_("Stop test"))
1129 self["Adapter"].setText(iNetwork.getFriendlyAdapterName(self.iface))
1130 self["Adapter"].setForegroundColorNum(2)
1131 self["Adaptertext"].setForegroundColorNum(1)
1132 self["AdapterInfo_Text"].setForegroundColorNum(1)
1133 self["AdapterInfo_OK"].show()
1134 self.steptimer = True
1135 self.nextStepTimer.start(3000)
1138 self["Networktext"].setForegroundColorNum(1)
1139 self["Network"].setText(_("Please wait..."))
1140 self.getLinkState(self.iface)
1141 self["NetworkInfo_Text"].setForegroundColorNum(1)
1142 self.steptimer = True
1143 self.nextStepTimer.start(3000)
1146 self["Dhcptext"].setForegroundColorNum(1)
1147 if iNetwork.getAdapterAttribute(self.iface, 'dhcp') is True:
1148 self["Dhcp"].setForegroundColorNum(2)
1149 self["Dhcp"].setText(_("enabled"))
1150 self["DhcpInfo_Check"].setPixmapNum(0)
1152 self["Dhcp"].setForegroundColorNum(1)
1153 self["Dhcp"].setText(_("disabled"))
1154 self["DhcpInfo_Check"].setPixmapNum(1)
1155 self["DhcpInfo_Check"].show()
1156 self["DhcpInfo_Text"].setForegroundColorNum(1)
1157 self.steptimer = True
1158 self.nextStepTimer.start(3000)
1161 self["IPtext"].setForegroundColorNum(1)
1162 self["IP"].setText(_("Please wait..."))
1163 iNetwork.checkNetworkState(self.NetworkStatedataAvail)
1166 self.steptimer = False
1167 self.nextStepTimer.stop()
1168 self["DNStext"].setForegroundColorNum(1)
1169 self["DNS"].setText(_("Please wait..."))
1170 iNetwork.checkDNSLookup(self.DNSLookupdataAvail)
1173 self["shortcutsgreen"].setEnabled(False)
1174 self["shortcutsyellow"].setEnabled(True)
1175 self["updown_actions"].setEnabled(False)
1176 self["key_yellow"].setText("")
1177 self["key_green"].setText("")
1178 self.steptimer = True
1179 self.nextStepTimer.start(1000)
1181 def KeyGreenRestart(self):
1183 self.layoutFinished()
1184 self["Adapter"].setText((""))
1185 self["Network"].setText((""))
1186 self["Dhcp"].setText((""))
1187 self["IP"].setText((""))
1188 self["DNS"].setText((""))
1189 self["AdapterInfo_Text"].setForegroundColorNum(0)
1190 self["NetworkInfo_Text"].setForegroundColorNum(0)
1191 self["DhcpInfo_Text"].setForegroundColorNum(0)
1192 self["IPInfo_Text"].setForegroundColorNum(0)
1193 self["DNSInfo_Text"].setForegroundColorNum(0)
1194 self["shortcutsgreen_restart"].setEnabled(False)
1195 self["shortcutsgreen"].setEnabled(False)
1196 self["shortcutsyellow"].setEnabled(True)
1197 self["updown_actions"].setEnabled(False)
1198 self["key_yellow"].setText("")
1199 self["key_green"].setText("")
1200 self.steptimer = True
1201 self.nextStepTimer.start(1000)
1204 self["infoshortcuts"].setEnabled(True)
1205 self["shortcuts"].setEnabled(False)
1206 if self.activebutton == 1: # Adapter Check
1207 self["InfoText"].setText(_("This test detects your configured LAN-Adapter."))
1208 self["InfoTextBorder"].show()
1209 self["InfoText"].show()
1210 self["key_red"].setText(_("Back"))
1211 if self.activebutton == 2: #LAN Check
1212 self["InfoText"].setText(_("This test checks whether a network cable is connected to your LAN-Adapter.\nIf you get a \"disconnected\" message:\n- verify that a network cable is attached\n- verify that the cable is not broken"))
1213 self["InfoTextBorder"].show()
1214 self["InfoText"].show()
1215 self["key_red"].setText(_("Back"))
1216 if self.activebutton == 3: #DHCP Check
1217 self["InfoText"].setText(_("This test checks whether your LAN Adapter is set up for automatic IP Address configuration with DHCP.\nIf you get a \"disabled\" message:\n - then your LAN Adapter is configured for manual IP Setup\n- verify thay you have entered correct IP informations in the AdapterSetup dialog.\nIf you get an \"enabeld\" message:\n-verify that you have a configured and working DHCP Server in your network."))
1218 self["InfoTextBorder"].show()
1219 self["InfoText"].show()
1220 self["key_red"].setText(_("Back"))
1221 if self.activebutton == 4: # IP Check
1222 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"))
1223 self["InfoTextBorder"].show()
1224 self["InfoText"].show()
1225 self["key_red"].setText(_("Back"))
1226 if self.activebutton == 5: # DNS Check
1227 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"))
1228 self["InfoTextBorder"].show()
1229 self["InfoText"].show()
1230 self["key_red"].setText(_("Back"))
1231 if self.activebutton == 6: # Edit Settings
1232 self.session.open(AdapterSetup,self.iface)
1234 def KeyYellow(self):
1236 self["shortcutsgreen_restart"].setEnabled(True)
1237 self["shortcutsgreen"].setEnabled(False)
1238 self["shortcutsyellow"].setEnabled(False)
1239 self["key_green"].setText(_("Restart test"))
1240 self["key_yellow"].setText("")
1241 self.steptimer = False
1242 self.nextStepTimer.stop()
1244 def layoutFinished(self):
1245 self["shortcutsyellow"].setEnabled(False)
1246 self["AdapterInfo_OK"].hide()
1247 self["NetworkInfo_Check"].hide()
1248 self["DhcpInfo_Check"].hide()
1249 self["IPInfo_Check"].hide()
1250 self["DNSInfo_Check"].hide()
1251 self["EditSettings_Text"].hide()
1252 self["EditSettingsButton"].hide()
1253 self["InfoText"].hide()
1254 self["InfoTextBorder"].hide()
1255 self["key_yellow"].setText("")
1257 def setLabels(self):
1258 self["Adaptertext"] = MultiColorLabel(_("LAN Adapter"))
1259 self["Adapter"] = MultiColorLabel()
1260 self["AdapterInfo"] = MultiPixmap()
1261 self["AdapterInfo_Text"] = MultiColorLabel(_("Show Info"))
1262 self["AdapterInfo_OK"] = Pixmap()
1264 if self.iface == 'wlan0' or self.iface == 'ath0':
1265 self["Networktext"] = MultiColorLabel(_("Wireless Network"))
1267 self["Networktext"] = MultiColorLabel(_("Local Network"))
1269 self["Network"] = MultiColorLabel()
1270 self["NetworkInfo"] = MultiPixmap()
1271 self["NetworkInfo_Text"] = MultiColorLabel(_("Show Info"))
1272 self["NetworkInfo_Check"] = MultiPixmap()
1274 self["Dhcptext"] = MultiColorLabel(_("DHCP"))
1275 self["Dhcp"] = MultiColorLabel()
1276 self["DhcpInfo"] = MultiPixmap()
1277 self["DhcpInfo_Text"] = MultiColorLabel(_("Show Info"))
1278 self["DhcpInfo_Check"] = MultiPixmap()
1280 self["IPtext"] = MultiColorLabel(_("IP Address"))
1281 self["IP"] = MultiColorLabel()
1282 self["IPInfo"] = MultiPixmap()
1283 self["IPInfo_Text"] = MultiColorLabel(_("Show Info"))
1284 self["IPInfo_Check"] = MultiPixmap()
1286 self["DNStext"] = MultiColorLabel(_("Nameserver"))
1287 self["DNS"] = MultiColorLabel()
1288 self["DNSInfo"] = MultiPixmap()
1289 self["DNSInfo_Text"] = MultiColorLabel(_("Show Info"))
1290 self["DNSInfo_Check"] = MultiPixmap()
1292 self["EditSettings_Text"] = MultiColorLabel(_("Edit settings"))
1293 self["EditSettingsButton"] = MultiPixmap()
1295 self["key_red"] = StaticText(_("Close"))
1296 self["key_green"] = StaticText(_("Start test"))
1297 self["key_yellow"] = StaticText(_("Stop test"))
1299 self["InfoTextBorder"] = Pixmap()
1300 self["InfoText"] = Label()
1302 def getLinkState(self,iface):
1303 if iface == 'wlan0' or iface == 'ath0':
1305 from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus,Status
1307 self["Network"].setForegroundColorNum(1)
1308 self["Network"].setText(_("disconnected"))
1309 self["NetworkInfo_Check"].setPixmapNum(1)
1310 self["NetworkInfo_Check"].show()
1312 iStatus.getDataForInterface(self.iface,self.getInfoCB)
1314 iNetwork.getLinkState(iface,self.LinkStatedataAvail)
1316 def LinkStatedataAvail(self,data):
1317 self.output = data.strip()
1318 result = self.output.split('\n')
1319 pattern = re_compile("Link detected: yes")
1321 if re_search(pattern, item):
1322 self["Network"].setForegroundColorNum(2)
1323 self["Network"].setText(_("connected"))
1324 self["NetworkInfo_Check"].setPixmapNum(0)
1326 self["Network"].setForegroundColorNum(1)
1327 self["Network"].setText(_("disconnected"))
1328 self["NetworkInfo_Check"].setPixmapNum(1)
1329 self["NetworkInfo_Check"].show()
1331 def NetworkStatedataAvail(self,data):
1333 self["IP"].setForegroundColorNum(2)
1334 self["IP"].setText(_("confirmed"))
1335 self["IPInfo_Check"].setPixmapNum(0)
1337 self["IP"].setForegroundColorNum(1)
1338 self["IP"].setText(_("unconfirmed"))
1339 self["IPInfo_Check"].setPixmapNum(1)
1340 self["IPInfo_Check"].show()
1341 self["IPInfo_Text"].setForegroundColorNum(1)
1342 self.steptimer = True
1343 self.nextStepTimer.start(3000)
1345 def DNSLookupdataAvail(self,data):
1347 self["DNS"].setForegroundColorNum(2)
1348 self["DNS"].setText(_("confirmed"))
1349 self["DNSInfo_Check"].setPixmapNum(0)
1351 self["DNS"].setForegroundColorNum(1)
1352 self["DNS"].setText(_("unconfirmed"))
1353 self["DNSInfo_Check"].setPixmapNum(1)
1354 self["DNSInfo_Check"].show()
1355 self["DNSInfo_Text"].setForegroundColorNum(1)
1356 self["EditSettings_Text"].show()
1357 self["EditSettingsButton"].setPixmapNum(1)
1358 self["EditSettings_Text"].setForegroundColorNum(2) # active
1359 self["EditSettingsButton"].show()
1360 self["key_yellow"].setText("")
1361 self["key_green"].setText(_("Restart test"))
1362 self["shortcutsgreen"].setEnabled(False)
1363 self["shortcutsgreen_restart"].setEnabled(True)
1364 self["shortcutsyellow"].setEnabled(False)
1365 self["updown_actions"].setEnabled(True)
1366 self.activebutton = 6
1368 def getInfoCB(self,data,status):
1369 if data is not None:
1371 if status is not None:
1372 if status[self.iface]["acesspoint"] == "No Connection" or status[self.iface]["acesspoint"] == "Not-Associated" or status[self.iface]["acesspoint"] == False:
1373 self["Network"].setForegroundColorNum(1)
1374 self["Network"].setText(_("disconnected"))
1375 self["NetworkInfo_Check"].setPixmapNum(1)
1376 self["NetworkInfo_Check"].show()
1378 self["Network"].setForegroundColorNum(2)
1379 self["Network"].setText(_("connected"))
1380 self["NetworkInfo_Check"].setPixmapNum(0)
1381 self["NetworkInfo_Check"].show()
1384 iNetwork.stopLinkStateConsole()
1385 iNetwork.stopDNSConsole()
1387 from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus,Status
1391 iStatus.stopWlanConsole()