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.Label import Label,MultiColorLabel
9 from Components.Pixmap import Pixmap,MultiPixmap
10 from Components.MenuList import MenuList
11 from Components.config import config, ConfigYesNo, ConfigIP, NoSave, ConfigText, ConfigPassword, ConfigSelection, getConfigListEntry, ConfigNothing
12 from Components.ConfigList import ConfigListScreen
13 from Components.PluginComponent import plugins
14 from Components.MultiContent import MultiContentEntryText, MultiContentEntryPixmapAlphaTest
15 from Components.ActionMap import ActionMap, NumberActionMap, HelpableActionMap
16 from Tools.Directories import resolveFilename, SCOPE_PLUGINS, SCOPE_SKIN_IMAGE
17 from Tools.LoadPixmap import LoadPixmap
18 from Plugins.Plugin import PluginDescriptor
19 from enigma import eTimer, ePoint, eSize, RT_HALIGN_LEFT, eListboxPythonMultiContent, gFont
20 from os import path as os_path, system as os_system, unlink
21 from re import compile as re_compile, search as re_search
24 class InterfaceList(MenuList):
25 def __init__(self, list, enableWrapAround=False):
26 MenuList.__init__(self, list, enableWrapAround, eListboxPythonMultiContent)
27 self.l.setFont(0, gFont("Regular", 20))
28 self.l.setItemHeight(30)
30 def InterfaceEntryComponent(index,name,default,active ):
33 MultiContentEntryText(pos=(80, 5), size=(430, 25), font=0, text=name)
35 num_configured_if = len(iNetwork.getConfiguredAdapters())
36 if num_configured_if >= 2:
38 png = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/buttons/button_blue.png"))
40 png = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/buttons/button_blue_off.png"))
41 res.append(MultiContentEntryPixmapAlphaTest(pos=(10, 5), size=(25, 25), png = png))
43 png2 = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/icons/lock_on.png"))
45 png2 = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/icons/lock_error.png"))
46 res.append(MultiContentEntryPixmapAlphaTest(pos=(40, 1), size=(25, 25), png = png2))
50 class NetworkAdapterSelection(Screen,HelpableScreen):
51 def __init__(self, session):
52 Screen.__init__(self, session)
53 HelpableScreen.__init__(self)
55 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.")
56 self.lan_errortext = _("No working local network adapter found.\nPlease verify that you have attached a network cable and your network is configured correctly.")
57 self.oktext = _("Press OK on your remote control to continue.")
58 self.restartLanRef = None
60 self["ButtonBluetext"] = Label(_("Set as default Interface"))
61 self["ButtonBlue"] = Pixmap()
62 self["ButtonRedtext"] = Label(_("Close"))
63 self["introduction"] = Label(_("Press OK to edit the settings."))
65 self.adapters = [(iNetwork.getFriendlyAdapterName(x),x) for x in iNetwork.getAdapterList()]
68 self.onFirstExecBegin.append(self.NetworkFallback)
70 self["OkCancelActions"] = HelpableActionMap(self, "OkCancelActions",
72 "cancel": (self.close, _("exit network interface list")),
73 "ok": (self.okbuttonClick, _("select interface")),
76 self["ColorActions"] = HelpableActionMap(self, "ColorActions",
78 "red": (self.close, _("exit network interface list")),
81 self["DefaultInterfaceAction"] = HelpableActionMap(self, "ColorActions",
83 "blue": (self.setDefaultInterface, [_("Set interface as default Interface"),_("* Only available if more than one interface is active.")] ),
87 self["list"] = InterfaceList(self.list)
90 if len(self.adapters) == 1:
91 self.onFirstExecBegin.append(self.okbuttonClick)
92 self.onClose.append(self.cleanup)
98 num_configured_if = len(iNetwork.getConfiguredAdapters())
99 if num_configured_if >= 2:
100 self["ButtonBlue"].show()
101 self["ButtonBluetext"].show()
102 self["DefaultInterfaceAction"].setEnabled(True)
104 self["ButtonBlue"].hide()
105 self["ButtonBluetext"].hide()
106 self["DefaultInterfaceAction"].setEnabled(False)
108 if num_configured_if < 2 and os_path.exists("/etc/default_gw"):
109 unlink("/etc/default_gw")
111 if os_path.exists("/etc/default_gw"):
112 fp = file('/etc/default_gw', 'r')
117 if len(self.adapters) == 0: # no interface available => display only eth0
118 self.list.append(InterfaceEntryComponent("eth0",iNetwork.getFriendlyAdapterName('eth0'),True,True ))
120 for x in self.adapters:
121 if x[1] == default_gw:
125 if iNetwork.getAdapterAttribute(x[1], 'up') is True:
129 self.list.append(InterfaceEntryComponent(index = x[1],name = _(x[0]),default=default_int,active=active_int ))
130 self["list"].l.setList(self.list)
132 def setDefaultInterface(self):
133 selection = self["list"].getCurrent()
134 num_if = len(self.list)
135 old_default_gw = None
136 num_configured_if = len(iNetwork.getConfiguredAdapters())
137 if os_path.exists("/etc/default_gw"):
138 fp = open('/etc/default_gw', 'r')
139 old_default_gw = fp.read()
141 if num_configured_if > 1 and (not old_default_gw or old_default_gw != selection[0]):
142 fp = open('/etc/default_gw', 'w+')
143 fp.write(selection[0])
146 elif old_default_gw and num_configured_if < 2:
147 unlink("/etc/default_gw")
150 def okbuttonClick(self):
151 selection = self["list"].getCurrent()
152 if selection is not None:
153 self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetupConfiguration, selection[0])
155 def AdapterSetupClosed(self, *ret):
156 if len(self.adapters) == 1:
161 def NetworkFallback(self):
162 if iNetwork.configuredNetworkAdapters.has_key('wlan0') is True:
163 self.session.openWithCallback(self.ErrorMessageClosed, MessageBox, self.wlan_errortext, type = MessageBox.TYPE_INFO,timeout = 10)
164 if iNetwork.configuredNetworkAdapters.has_key('ath0') is True:
165 self.session.openWithCallback(self.ErrorMessageClosed, MessageBox, self.wlan_errortext, type = MessageBox.TYPE_INFO,timeout = 10)
167 self.session.openWithCallback(self.ErrorMessageClosed, MessageBox, self.lan_errortext, type = MessageBox.TYPE_INFO,timeout = 10)
169 def ErrorMessageClosed(self, *ret):
170 if iNetwork.configuredNetworkAdapters.has_key('wlan0') is True:
171 self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetupConfiguration, 'wlan0')
172 elif iNetwork.configuredNetworkAdapters.has_key('ath0') is True:
173 self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetupConfiguration, 'ath0')
175 self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetupConfiguration, 'eth0')
178 iNetwork.stopLinkStateConsole()
179 iNetwork.stopRestartConsole()
180 iNetwork.stopGetInterfacesConsole()
182 def restartLan(self):
183 iNetwork.restartNetwork(self.restartLanDataAvail)
184 self.restartLanRef = self.session.openWithCallback(self.restartfinishedCB, MessageBox, _("Please wait while we configure your network..."), type = MessageBox.TYPE_INFO, enable_input = False)
186 def restartLanDataAvail(self, data):
188 iNetwork.getInterfaces(self.getInterfacesDataAvail)
190 def getInterfacesDataAvail(self, data):
192 self.restartLanRef.close(True)
194 def restartfinishedCB(self,data):
197 self.session.open(MessageBox, _("Finished configuring your network"), type = MessageBox.TYPE_INFO, timeout = 10, default = False)
200 class NameserverSetup(Screen, ConfigListScreen, HelpableScreen):
201 def __init__(self, session):
202 Screen.__init__(self, session)
203 HelpableScreen.__init__(self)
204 self.backupNameserverList = iNetwork.getNameserverList()[:]
205 print "backup-list:", self.backupNameserverList
207 self["ButtonGreentext"] = Label(_("Add"))
208 self["ButtonYellowtext"] = Label(_("Delete"))
209 self["ButtonRedtext"] = Label(_("Close"))
210 self["introduction"] = Label(_("Press OK to activate the settings."))
213 self["OkCancelActions"] = HelpableActionMap(self, "OkCancelActions",
215 "cancel": (self.cancel, _("exit nameserver configuration")),
216 "ok": (self.ok, _("activate current configuration")),
219 self["ColorActions"] = HelpableActionMap(self, "ColorActions",
221 "red": (self.cancel, _("exit nameserver configuration")),
222 "green": (self.add, _("add a nameserver entry")),
223 "yellow": (self.remove, _("remove a nameserver entry")),
226 self["actions"] = NumberActionMap(["SetupActions"],
232 ConfigListScreen.__init__(self, self.list)
235 def createConfig(self):
236 self.nameservers = iNetwork.getNameserverList()
237 self.nameserverEntries = [ NoSave(ConfigIP(default=nameserver)) for nameserver in self.nameservers]
239 def createSetup(self):
243 for x in self.nameserverEntries:
244 self.list.append(getConfigListEntry(_("Nameserver %d") % (i), x))
247 self["config"].list = self.list
248 self["config"].l.setList(self.list)
251 iNetwork.clearNameservers()
252 for nameserver in self.nameserverEntries:
253 iNetwork.addNameserver(nameserver.value)
254 iNetwork.writeNameserverConfig()
261 iNetwork.clearNameservers()
262 print "backup-list:", self.backupNameserverList
263 for nameserver in self.backupNameserverList:
264 iNetwork.addNameserver(nameserver)
268 iNetwork.addNameserver([0,0,0,0])
273 print "currentIndex:", self["config"].getCurrentIndex()
275 index = self["config"].getCurrentIndex()
276 if index < len(self.nameservers):
277 iNetwork.removeNameserver(self.nameservers[index])
281 class AdapterSetup(Screen, ConfigListScreen, HelpableScreen):
282 def __init__(self, session, networkinfo, essid=None, aplist=None):
283 Screen.__init__(self, session)
284 HelpableScreen.__init__(self)
285 self.session = session
286 if isinstance(networkinfo, (list, tuple)):
287 self.iface = networkinfo[0]
288 self.essid = networkinfo[1]
289 self.aplist = networkinfo[2]
291 self.iface = networkinfo
295 self.applyConfigRef = None
296 self.finished_cb = None
297 self.oktext = _("Press OK on your remote control to continue.")
298 self.oldInterfaceState = iNetwork.getAdapterAttribute(self.iface, "up")
302 self["OkCancelActions"] = HelpableActionMap(self, "OkCancelActions",
304 "cancel": (self.cancel, _("exit network adapter setup menu")),
305 "ok": (self.ok, _("select menu entry")),
308 self["ColorActions"] = HelpableActionMap(self, "ColorActions",
310 "red": (self.cancel, _("exit network adapter configuration")),
311 "blue": (self.KeyBlue, _("open nameserver configuration")),
314 self["VirtualKB"] = HelpableActionMap(self, "ColorActions",
316 "green": (self.KeyGreen, [_("open virtual keyboard input help"),_("* Only available when entering hidden SSID or network key")] ),
319 self["actions"] = NumberActionMap(["SetupActions"],
326 ConfigListScreen.__init__(self, self.list,session = self.session)
328 self.onLayoutFinish.append(self.layoutFinished)
329 self.onClose.append(self.cleanup)
331 self["DNS1text"] = Label(_("Primary DNS"))
332 self["DNS2text"] = Label(_("Secondary DNS"))
333 self["DNS1"] = Label()
334 self["DNS2"] = Label()
336 self["introduction"] = Label(_("Current settings:"))
338 self["IPtext"] = Label(_("IP Address"))
339 self["Netmasktext"] = Label(_("Netmask"))
340 self["Gatewaytext"] = Label(_("Gateway"))
343 self["Mask"] = Label()
344 self["Gateway"] = Label()
346 self["BottomBG"] = Pixmap()
347 self["Adaptertext"] = Label(_("Network:"))
348 self["Adapter"] = Label()
349 self["introduction2"] = Label(_("Press OK to activate the settings."))
350 self["ButtonRed"] = Pixmap()
351 self["ButtonRedtext"] = Label(_("Close"))
352 self["ButtonBlue"] = Pixmap()
353 self["ButtonBluetext"] = Label(_("Edit DNS"))
354 self["ButtonGreen"] = Pixmap()
355 self["VKeyIcon"] = Pixmap()
356 self["HelpWindow"] = Pixmap()
358 def layoutFinished(self):
359 self["DNS1"].setText(self.primaryDNS.getText())
360 self["DNS2"].setText(self.secondaryDNS.getText())
361 if self.ipConfigEntry.getText() is not None:
362 if self.ipConfigEntry.getText() == "0.0.0.0":
363 self["IP"].setText(_("N/A"))
365 self["IP"].setText(self.ipConfigEntry.getText())
367 self["IP"].setText(_("N/A"))
368 if self.netmaskConfigEntry.getText() is not None:
369 if self.netmaskConfigEntry.getText() == "0.0.0.0":
370 self["Mask"].setText(_("N/A"))
372 self["Mask"].setText(self.netmaskConfigEntry.getText())
374 self["IP"].setText(_("N/A"))
375 if iNetwork.getAdapterAttribute(self.iface, "gateway"):
376 if self.gatewayConfigEntry.getText() == "0.0.0.0":
377 self["Gateway"].setText(_("N/A"))
379 self["Gateway"].setText(self.gatewayConfigEntry.getText())
381 self["Gateway"].hide()
382 self["Gatewaytext"].hide()
383 self["Adapter"].setText(iNetwork.getFriendlyAdapterName(self.iface))
384 self["ButtonGreen"].hide()
385 self["VKeyIcon"].hide()
386 self["VirtualKB"].setEnabled(False)
387 self["HelpWindow"].hide()
389 def createConfig(self):
390 self.InterfaceEntry = None
391 self.dhcpEntry = None
392 self.gatewayEntry = None
393 self.hiddenSSID = None
395 self.encryptionEnabled = None
396 self.encryptionKey = None
397 self.encryptionType = None
399 self.encryptionlist = None
404 if self.iface == "wlan0" or self.iface == "ath0" :
405 from Plugins.SystemPlugins.WirelessLan.Wlan import wpaSupplicant,Wlan
406 self.w = Wlan(self.iface)
407 self.ws = wpaSupplicant()
408 self.encryptionlist = []
409 self.encryptionlist.append(("WEP", _("WEP")))
410 self.encryptionlist.append(("WPA", _("WPA")))
411 self.encryptionlist.append(("WPA2", _("WPA2")))
412 self.encryptionlist.append(("WPA/WPA2", _("WPA or WPA2")))
414 self.weplist.append("ASCII")
415 self.weplist.append("HEX")
416 if self.aplist is not None:
417 self.nwlist = self.aplist
418 self.nwlist.sort(key = lambda x: x[0])
423 self.aps = self.w.getNetworkList()
424 if self.aps is not None:
425 print "[NetworkSetup.py] got Accespoints!"
430 a['essid'] = a['bssid']
431 self.nwlist.append((a['essid'],a['essid']))
432 self.nwlist.sort(key = lambda x: x[0])
434 self.nwlist.append(("No Networks found",_("No Networks found")))
436 self.wsconfig = self.ws.loadConfig()
437 if self.essid is not None: # ssid from wlan scan
438 self.default = self.essid
440 self.default = self.wsconfig['ssid']
442 if "hidden..." not in self.nwlist:
443 self.nwlist.append(("hidden...",_("hidden network")))
444 if self.default not in self.nwlist:
445 self.nwlist.append((self.default,self.default))
446 config.plugins.wlan.essid = NoSave(ConfigSelection(self.nwlist, default = self.default ))
447 config.plugins.wlan.hiddenessid = NoSave(ConfigText(default = self.wsconfig['hiddenessid'], visible_width = 50, fixed_size = False))
449 config.plugins.wlan.encryption.enabled = NoSave(ConfigYesNo(default = self.wsconfig['encryption'] ))
450 config.plugins.wlan.encryption.type = NoSave(ConfigSelection(self.encryptionlist, default = self.wsconfig['encryption_type'] ))
451 config.plugins.wlan.encryption.wepkeytype = NoSave(ConfigSelection(self.weplist, default = self.wsconfig['encryption_wepkeytype'] ))
452 config.plugins.wlan.encryption.psk = NoSave(ConfigPassword(default = self.wsconfig['key'], visible_width = 50, fixed_size = False))
454 self.activateInterfaceEntry = NoSave(ConfigYesNo(default=iNetwork.getAdapterAttribute(self.iface, "up") or False))
455 self.dhcpConfigEntry = NoSave(ConfigYesNo(default=iNetwork.getAdapterAttribute(self.iface, "dhcp") or False))
456 self.ipConfigEntry = NoSave(ConfigIP(default=iNetwork.getAdapterAttribute(self.iface, "ip")) or [0,0,0,0])
457 self.netmaskConfigEntry = NoSave(ConfigIP(default=iNetwork.getAdapterAttribute(self.iface, "netmask") or [255,0,0,0]))
458 if iNetwork.getAdapterAttribute(self.iface, "gateway"):
459 self.dhcpdefault=True
461 self.dhcpdefault=False
462 self.hasGatewayConfigEntry = NoSave(ConfigYesNo(default=self.dhcpdefault or False))
463 self.gatewayConfigEntry = NoSave(ConfigIP(default=iNetwork.getAdapterAttribute(self.iface, "gateway") or [0,0,0,0]))
464 nameserver = (iNetwork.getNameserverList() + [[0,0,0,0]] * 2)[0:2]
465 self.primaryDNS = NoSave(ConfigIP(default=nameserver[0]))
466 self.secondaryDNS = NoSave(ConfigIP(default=nameserver[1]))
468 def createSetup(self):
470 self.InterfaceEntry = getConfigListEntry(_("Use Interface"), self.activateInterfaceEntry)
472 self.list.append(self.InterfaceEntry)
473 if self.activateInterfaceEntry.value:
474 self.dhcpEntry = getConfigListEntry(_("Use DHCP"), self.dhcpConfigEntry)
475 self.list.append(self.dhcpEntry)
476 if not self.dhcpConfigEntry.value:
477 self.list.append(getConfigListEntry(_('IP Address'), self.ipConfigEntry))
478 self.list.append(getConfigListEntry(_('Netmask'), self.netmaskConfigEntry))
479 self.gatewayEntry = getConfigListEntry(_('Use a gateway'), self.hasGatewayConfigEntry)
480 self.list.append(self.gatewayEntry)
481 if self.hasGatewayConfigEntry.value:
482 self.list.append(getConfigListEntry(_('Gateway'), self.gatewayConfigEntry))
485 for p in plugins.getPlugins(PluginDescriptor.WHERE_NETWORKSETUP):
486 callFnc = p.__call__["ifaceSupported"](self.iface)
487 if callFnc is not None:
488 if p.__call__.has_key("WlanPluginEntry"): # internally used only for WLAN Plugin
489 self.extended = callFnc
490 if p.__call__.has_key("configStrings"):
491 self.configStrings = p.__call__["configStrings"]
493 self.configStrings = None
494 if config.plugins.wlan.essid.value == 'hidden...':
495 self.wlanSSID = getConfigListEntry(_("Network SSID"), config.plugins.wlan.essid)
496 self.list.append(self.wlanSSID)
497 self.hiddenSSID = getConfigListEntry(_("Hidden network SSID"), config.plugins.wlan.hiddenessid)
498 self.list.append(self.hiddenSSID)
500 self.wlanSSID = getConfigListEntry(_("Network SSID"), config.plugins.wlan.essid)
501 self.list.append(self.wlanSSID)
502 self.encryptionEnabled = getConfigListEntry(_("Encryption"), config.plugins.wlan.encryption.enabled)
503 self.list.append(self.encryptionEnabled)
505 if config.plugins.wlan.encryption.enabled.value:
506 self.encryptionType = getConfigListEntry(_("Encryption Type"), config.plugins.wlan.encryption.type)
507 self.list.append(self.encryptionType)
508 if config.plugins.wlan.encryption.type.value == 'WEP':
509 self.list.append(getConfigListEntry(_("Encryption Keytype"), config.plugins.wlan.encryption.wepkeytype))
510 self.encryptionKey = getConfigListEntry(_("Encryption Key"), config.plugins.wlan.encryption.psk)
511 self.list.append(self.encryptionKey)
513 self.encryptionKey = getConfigListEntry(_("Encryption Key"), config.plugins.wlan.encryption.psk)
514 self.list.append(self.encryptionKey)
517 self["config"].list = self.list
518 self["config"].l.setList(self.list)
519 if not self.selectionChanged in self["config"].onSelectionChanged:
520 self["config"].onSelectionChanged.append(self.selectionChanged)
523 self.session.openWithCallback(self.NameserverSetupClosed, NameserverSetup)
526 if self.iface == "wlan0" or self.iface == "ath0" :
527 if self["config"].getCurrent() == self.hiddenSSID:
528 if config.plugins.wlan.essid.value == 'hidden...':
529 self.session.openWithCallback(self.VirtualKeyBoardSSIDCallback, VirtualKeyBoard, title = (_("Enter WLAN network name/SSID:")), text = config.plugins.wlan.essid.value)
530 if self["config"].getCurrent() == self.encryptionKey:
531 self.session.openWithCallback(self.VirtualKeyBoardKeyCallback, VirtualKeyBoard, title = (_("Enter WLAN passphrase/key:")), text = config.plugins.wlan.encryption.psk.value)
533 def VirtualKeyBoardSSIDCallback(self, callback = None):
534 if callback is not None and len(callback):
535 config.plugins.wlan.hiddenessid = NoSave(ConfigText(default = callback, visible_width = 50, fixed_size = False))
538 def VirtualKeyBoardKeyCallback(self, callback = None):
539 if callback is not None and len(callback):
540 config.plugins.wlan.encryption.psk = NoSave(ConfigPassword(default = callback, visible_width = 50, fixed_size = False))
544 if self["config"].getCurrent() == self.InterfaceEntry:
546 if self["config"].getCurrent() == self.dhcpEntry:
548 if self["config"].getCurrent() == self.gatewayEntry:
550 if self.iface == "wlan0" or self.iface == "ath0" :
551 if self["config"].getCurrent() == self.wlanSSID:
553 if self["config"].getCurrent() == self.encryptionEnabled:
555 if self["config"].getCurrent() == self.encryptionType:
558 ConfigListScreen.keyLeft(self)
562 ConfigListScreen.keyRight(self)
565 def selectionChanged(self):
566 current = self["config"].getCurrent()
567 if current == self.hiddenSSID and config.plugins.wlan.essid.value == 'hidden...':
568 helpwindowpos = self["HelpWindow"].getPosition()
569 if current[1].help_window.instance is not None:
570 current[1].help_window.instance.move(ePoint(helpwindowpos[0],helpwindowpos[1]))
571 self["ButtonGreen"].show()
572 self["VKeyIcon"].show()
573 self["VirtualKB"].setEnabled(True)
574 elif current == self.encryptionKey and config.plugins.wlan.encryption.enabled.value:
575 helpwindowpos = self["HelpWindow"].getPosition()
576 if current[1].help_window.instance is not None:
577 current[1].help_window.instance.move(ePoint(helpwindowpos[0],helpwindowpos[1]))
578 self["ButtonGreen"].show()
579 self["VKeyIcon"].show()
580 self["VirtualKB"].setEnabled(True)
582 self["ButtonGreen"].hide()
583 self["VKeyIcon"].hide()
584 self["VirtualKB"].setEnabled(False)
587 current = self["config"].getCurrent()
588 if current == self.hiddenSSID and config.plugins.wlan.essid.value == 'hidden...':
589 if current[1].help_window.instance is not None:
590 current[1].help_window.instance.hide()
591 elif current == self.encryptionKey and config.plugins.wlan.encryption.enabled.value:
592 if current[1].help_window.instance is not None:
593 current[1].help_window.instance.hide()
594 self.session.openWithCallback(self.applyConfig, MessageBox, (_("Are you sure you want to activate this network configuration?\n\n") + self.oktext ) )
596 def applyConfig(self, ret = False):
598 iNetwork.setAdapterAttribute(self.iface, "up", self.activateInterfaceEntry.value)
599 iNetwork.setAdapterAttribute(self.iface, "dhcp", self.dhcpConfigEntry.value)
600 iNetwork.setAdapterAttribute(self.iface, "ip", self.ipConfigEntry.value)
601 iNetwork.setAdapterAttribute(self.iface, "netmask", self.netmaskConfigEntry.value)
602 if self.hasGatewayConfigEntry.value:
603 iNetwork.setAdapterAttribute(self.iface, "gateway", self.gatewayConfigEntry.value)
605 iNetwork.removeAdapterAttribute(self.iface, "gateway")
606 if self.extended is not None and self.configStrings is not None:
607 iNetwork.setAdapterAttribute(self.iface, "configStrings", self.configStrings(self.iface))
608 self.ws.writeConfig()
609 if self.activateInterfaceEntry.value is False:
610 iNetwork.deactivateInterface(self.iface)
611 iNetwork.writeNetworkConfig()
612 iNetwork.restartNetwork(self.applyConfigDataAvail)
613 self.applyConfigRef = self.session.openWithCallback(self.applyConfigfinishedCB, MessageBox, _("Please wait for activation of your network configuration..."), type = MessageBox.TYPE_INFO, enable_input = False)
617 def applyConfigDataAvail(self, data):
619 iNetwork.getInterfaces(self.getInterfacesDataAvail)
621 def getInterfacesDataAvail(self, data):
623 self.applyConfigRef.close(True)
625 def applyConfigfinishedCB(self,data):
627 num_configured_if = len(iNetwork.getConfiguredAdapters())
628 if num_configured_if >= 2:
629 self.session.openWithCallback(self.secondIfaceFoundCB, MessageBox, _("Your network configuration has been activated.\nA second configured interface has been found.\n\nDo you want to disable the second network interface?"), default = True)
632 self.session.openWithCallback(lambda x : self.finished_cb(), MessageBox, _("Your network configuration has been activated."), type = MessageBox.TYPE_INFO, timeout = 10)
634 self.session.openWithCallback(self.ConfigfinishedCB, MessageBox, _("Your network configuration has been activated."), type = MessageBox.TYPE_INFO, timeout = 10)
636 def secondIfaceFoundCB(self,data):
640 configuredInterfaces = iNetwork.getConfiguredAdapters()
641 for interface in configuredInterfaces:
642 if interface == self.iface:
644 iNetwork.setAdapterAttribute(interface, "up", False)
645 iNetwork.deactivateInterface(interface)
646 self.applyConfig(True)
648 def ConfigfinishedCB(self,data):
654 if self.oldInterfaceState is False:
655 iNetwork.deactivateInterface(self.iface,self.cancelCB)
659 def cancelCB(self,data):
664 def runAsync(self, finished_cb):
665 self.finished_cb = finished_cb
668 def NameserverSetupClosed(self, *ret):
669 iNetwork.loadNameserverConfig()
670 nameserver = (iNetwork.getNameserverList() + [[0,0,0,0]] * 2)[0:2]
671 self.primaryDNS = NoSave(ConfigIP(default=nameserver[0]))
672 self.secondaryDNS = NoSave(ConfigIP(default=nameserver[1]))
674 self.layoutFinished()
677 iNetwork.stopLinkStateConsole()
680 class AdapterSetupConfiguration(Screen, HelpableScreen):
681 def __init__(self, session,iface):
682 Screen.__init__(self, session)
683 HelpableScreen.__init__(self)
684 self.session = session
686 self.restartLanRef = None
687 self.mainmenu = self.genMainMenu()
688 self["menulist"] = MenuList(self.mainmenu)
689 self["description"] = Label()
690 self["IFtext"] = Label()
692 self["BottomBG"] = Label()
693 self["Statustext"] = Label()
694 self["statuspic"] = MultiPixmap()
695 self["statuspic"].hide()
696 self["BottomBG"] = Pixmap()
697 self["ButtonRed"] = Pixmap()
698 self["ButtonRedtext"] = Label(_("Close"))
700 self.oktext = _("Press OK on your remote control to continue.")
701 self.reboottext = _("Your Dreambox will restart after pressing OK on your remote control.")
702 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.")
704 self["WizardActions"] = HelpableActionMap(self, "WizardActions",
706 "up": (self.up, _("move up to previous entry")),
707 "down": (self.down, _("move down to next entry")),
708 "left": (self.left, _("move up to first entry")),
709 "right": (self.right, _("move down to last entry")),
712 self["OkCancelActions"] = HelpableActionMap(self, "OkCancelActions",
714 "cancel": (self.close, _("exit networkadapter setup menu")),
715 "ok": (self.ok, _("select menu entry")),
718 self["ColorActions"] = HelpableActionMap(self, "ColorActions",
720 "red": (self.close, _("exit networkadapter setup menu")),
723 self["actions"] = NumberActionMap(["WizardActions","ShortcutActions"],
734 self.updateStatusbar()
735 self.onLayoutFinish.append(self.layoutFinished)
736 self.onClose.append(self.cleanup)
739 if self["menulist"].getCurrent()[1] == 'edit':
740 if self.iface == 'wlan0' or self.iface == 'ath0':
742 from Plugins.SystemPlugins.WirelessLan.plugin import WlanScan
743 from Plugins.SystemPlugins.WirelessLan.iwlibs import Wireless
745 self.session.open(MessageBox, _("The wireless LAN plugin is not installed!\nPlease install it."), type = MessageBox.TYPE_INFO,timeout = 10 )
747 ifobj = Wireless(self.iface) # a Wireless NIC Object
748 self.wlanresponse = ifobj.getStatistics()
749 if self.wlanresponse[0] != 19: # Wlan Interface found.
750 self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetup,self.iface)
752 # Display Wlan not available Message
753 self.showErrorMessage()
755 self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetup,self.iface)
756 if self["menulist"].getCurrent()[1] == 'test':
757 self.session.open(NetworkAdapterTest,self.iface)
758 if self["menulist"].getCurrent()[1] == 'dns':
759 self.session.open(NameserverSetup)
760 if self["menulist"].getCurrent()[1] == 'scanwlan':
762 from Plugins.SystemPlugins.WirelessLan.plugin import WlanScan
763 from Plugins.SystemPlugins.WirelessLan.iwlibs import Wireless
765 self.session.open(MessageBox, _("The wireless LAN plugin is not installed!\nPlease install it."), type = MessageBox.TYPE_INFO,timeout = 10 )
767 ifobj = Wireless(self.iface) # a Wireless NIC Object
768 self.wlanresponse = ifobj.getStatistics()
769 if self.wlanresponse[0] != 19:
770 self.session.openWithCallback(self.WlanScanClosed, WlanScan, self.iface)
772 # Display Wlan not available Message
773 self.showErrorMessage()
774 if self["menulist"].getCurrent()[1] == 'wlanstatus':
776 from Plugins.SystemPlugins.WirelessLan.plugin import WlanStatus
777 from Plugins.SystemPlugins.WirelessLan.iwlibs import Wireless
779 self.session.open(MessageBox, _("The wireless LAN plugin is not installed!\nPlease install it."), type = MessageBox.TYPE_INFO,timeout = 10 )
781 ifobj = Wireless(self.iface) # a Wireless NIC Object
782 self.wlanresponse = ifobj.getStatistics()
783 if self.wlanresponse[0] != 19:
784 self.session.openWithCallback(self.WlanStatusClosed, WlanStatus,self.iface)
786 # Display Wlan not available Message
787 self.showErrorMessage()
788 if self["menulist"].getCurrent()[1] == 'lanrestart':
789 self.session.openWithCallback(self.restartLan, MessageBox, (_("Are you sure you want to restart your network interfaces?\n\n") + self.oktext ) )
790 if self["menulist"].getCurrent()[1] == 'openwizard':
791 from Plugins.SystemPlugins.NetworkWizard.NetworkWizard import NetworkWizard
792 self.session.openWithCallback(self.AdapterSetupClosed, NetworkWizard)
793 if self["menulist"].getCurrent()[1][0] == 'extendedSetup':
794 self.extended = self["menulist"].getCurrent()[1][2]
795 self.extended(self.session, self.iface)
798 self["menulist"].up()
799 self.loadDescription()
802 self["menulist"].down()
803 self.loadDescription()
806 self["menulist"].pageUp()
807 self.loadDescription()
810 self["menulist"].pageDown()
811 self.loadDescription()
813 def layoutFinished(self):
815 self["menulist"].moveToIndex(idx)
816 self.loadDescription()
818 def loadDescription(self):
819 print self["menulist"].getCurrent()[1]
820 if self["menulist"].getCurrent()[1] == 'edit':
821 self["description"].setText(_("Edit the network configuration of your Dreambox.\n" ) + self.oktext )
822 if self["menulist"].getCurrent()[1] == 'test':
823 self["description"].setText(_("Test the network configuration of your Dreambox.\n" ) + self.oktext )
824 if self["menulist"].getCurrent()[1] == 'dns':
825 self["description"].setText(_("Edit the Nameserver configuration of your Dreambox.\n" ) + self.oktext )
826 if self["menulist"].getCurrent()[1] == 'scanwlan':
827 self["description"].setText(_("Scan your network for wireless Access Points and connect to them using your WLAN USB Stick\n" ) + self.oktext )
828 if self["menulist"].getCurrent()[1] == 'wlanstatus':
829 self["description"].setText(_("Shows the state of your wireless LAN connection.\n" ) + self.oktext )
830 if self["menulist"].getCurrent()[1] == 'lanrestart':
831 self["description"].setText(_("Restart your network connection and interfaces.\n" ) + self.oktext )
832 if self["menulist"].getCurrent()[1] == 'openwizard':
833 self["description"].setText(_("Use the Networkwizard to configure your Network\n" ) + self.oktext )
834 if self["menulist"].getCurrent()[1][0] == 'extendedSetup':
835 self["description"].setText(_(self["menulist"].getCurrent()[1][1]) + self.oktext )
837 def updateStatusbar(self, data = None):
838 self["IFtext"].setText(_("Network:"))
839 self["IF"].setText(iNetwork.getFriendlyAdapterName(self.iface))
840 self["Statustext"].setText(_("Link:"))
842 if self.iface == 'wlan0' or self.iface == 'ath0':
844 from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus,Status
846 self["statuspic"].setPixmapNum(1)
847 self["statuspic"].show()
849 iStatus.getDataForInterface(self.iface,self.getInfoCB)
851 iNetwork.getLinkState(self.iface,self.dataAvail)
856 def genMainMenu(self):
858 menu.append((_("Adapter settings"), "edit"))
859 menu.append((_("Nameserver settings"), "dns"))
860 menu.append((_("Network test"), "test"))
861 menu.append((_("Restart network"), "lanrestart"))
864 self.extendedSetup = None
865 for p in plugins.getPlugins(PluginDescriptor.WHERE_NETWORKSETUP):
866 callFnc = p.__call__["ifaceSupported"](self.iface)
867 if callFnc is not None:
868 self.extended = callFnc
870 if p.__call__.has_key("WlanPluginEntry"): # internally used only for WLAN Plugin
871 menu.append((_("Scan Wireless Networks"), "scanwlan"))
872 if iNetwork.getAdapterAttribute(self.iface, "up"):
873 menu.append((_("Show WLAN Status"), "wlanstatus"))
875 if p.__call__.has_key("menuEntryName"):
876 menuEntryName = p.__call__["menuEntryName"](self.iface)
878 menuEntryName = _('Extended Setup...')
879 if p.__call__.has_key("menuEntryDescription"):
880 menuEntryDescription = p.__call__["menuEntryDescription"](self.iface)
882 menuEntryDescription = _('Extended Networksetup Plugin...')
883 self.extendedSetup = ('extendedSetup',menuEntryDescription, self.extended)
884 menu.append((menuEntryName,self.extendedSetup))
886 if os_path.exists(resolveFilename(SCOPE_PLUGINS, "SystemPlugins/NetworkWizard/networkwizard.xml")):
887 menu.append((_("NetworkWizard"), "openwizard"))
891 def AdapterSetupClosed(self, *ret):
892 if ret is not None and len(ret):
893 if ret[0] == 'ok' and (self.iface == 'wlan0' or self.iface == 'ath0') and iNetwork.getAdapterAttribute(self.iface, "up") is True:
895 from Plugins.SystemPlugins.WirelessLan.plugin import WlanStatus
896 from Plugins.SystemPlugins.WirelessLan.iwlibs import Wireless
898 self.session.open(MessageBox, _("The wireless LAN plugin is not installed!\nPlease install it."), type = MessageBox.TYPE_INFO,timeout = 10 )
900 ifobj = Wireless(self.iface) # a Wireless NIC Object
901 self.wlanresponse = ifobj.getStatistics()
902 if self.wlanresponse[0] != 19:
903 self.session.openWithCallback(self.WlanStatusClosed, WlanStatus,self.iface)
905 # Display Wlan not available Message
906 self.showErrorMessage()
908 self.mainmenu = self.genMainMenu()
909 self["menulist"].l.setList(self.mainmenu)
910 self.updateStatusbar()
912 self.mainmenu = self.genMainMenu()
913 self["menulist"].l.setList(self.mainmenu)
914 self.updateStatusbar()
916 def WlanStatusClosed(self, *ret):
917 if ret is not None and len(ret):
918 from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus,Status
919 iStatus.stopWlanConsole()
920 self.mainmenu = self.genMainMenu()
921 self["menulist"].l.setList(self.mainmenu)
922 self.updateStatusbar()
924 def WlanScanClosed(self,*ret):
925 if ret[0] is not None:
926 self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetup, self.iface,ret[0],ret[1])
928 from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus,Status
929 iStatus.stopWlanConsole()
930 self.mainmenu = self.genMainMenu()
931 self["menulist"].l.setList(self.mainmenu)
932 self.updateStatusbar()
934 def restartLan(self, ret = False):
936 iNetwork.restartNetwork(self.restartLanDataAvail)
937 self.restartLanRef = self.session.openWithCallback(self.restartfinishedCB, MessageBox, _("Please wait while your network is restarting..."), type = MessageBox.TYPE_INFO, enable_input = False)
939 def restartLanDataAvail(self, data):
941 iNetwork.getInterfaces(self.getInterfacesDataAvail)
943 def getInterfacesDataAvail(self, data):
945 self.restartLanRef.close(True)
947 def restartfinishedCB(self,data):
949 self.updateStatusbar()
950 self.session.open(MessageBox, _("Finished restarting your network"), type = MessageBox.TYPE_INFO, timeout = 10, default = False)
952 def dataAvail(self,data):
953 self.output = data.strip()
954 result = self.output.split('\n')
955 pattern = re_compile("Link detected: yes")
957 if re_search(pattern, item):
958 self["statuspic"].setPixmapNum(0)
960 self["statuspic"].setPixmapNum(1)
961 self["statuspic"].show()
963 def showErrorMessage(self):
964 self.session.open(MessageBox, self.errortext, type = MessageBox.TYPE_INFO,timeout = 10 )
967 iNetwork.stopLinkStateConsole()
968 iNetwork.stopDeactivateInterfaceConsole()
970 from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus,Status
974 iStatus.stopWlanConsole()
976 def getInfoCB(self,data,status):
979 if status is not None:
980 if status[self.iface]["acesspoint"] == "No Connection" or status[self.iface]["acesspoint"] == "Not-Associated" or status[self.iface]["acesspoint"] == False:
981 self["statuspic"].setPixmapNum(1)
983 self["statuspic"].setPixmapNum(0)
984 self["statuspic"].show()
986 class NetworkAdapterTest(Screen):
987 def __init__(self, session,iface):
988 Screen.__init__(self, session)
990 self.oldInterfaceState = iNetwork.getAdapterAttribute(self.iface, "up")
992 self.onClose.append(self.cleanup)
993 self.onHide.append(self.cleanup)
995 self["updown_actions"] = NumberActionMap(["WizardActions","ShortcutActions"],
999 "up": lambda: self.updownhandler('up'),
1000 "down": lambda: self.updownhandler('down'),
1004 self["shortcuts"] = ActionMap(["ShortcutActions","WizardActions"],
1007 "back": self.cancel,
1009 self["infoshortcuts"] = ActionMap(["ShortcutActions","WizardActions"],
1011 "red": self.closeInfo,
1012 "back": self.closeInfo,
1014 self["shortcutsgreen"] = ActionMap(["ShortcutActions"],
1016 "green": self.KeyGreen,
1018 self["shortcutsgreen_restart"] = ActionMap(["ShortcutActions"],
1020 "green": self.KeyGreenRestart,
1022 self["shortcutsyellow"] = ActionMap(["ShortcutActions"],
1024 "yellow": self.KeyYellow,
1027 self["shortcutsgreen_restart"].setEnabled(False)
1028 self["updown_actions"].setEnabled(False)
1029 self["infoshortcuts"].setEnabled(False)
1030 self.onClose.append(self.delTimer)
1031 self.onLayoutFinish.append(self.layoutFinished)
1032 self.steptimer = False
1034 self.activebutton = 0
1035 self.nextStepTimer = eTimer()
1036 self.nextStepTimer.callback.append(self.nextStepTimerFire)
1039 if self.oldInterfaceState is False:
1040 iNetwork.setAdapterAttribute(self.iface, "up", self.oldInterfaceState)
1041 iNetwork.deactivateInterface(self.iface)
1044 def closeInfo(self):
1045 self["shortcuts"].setEnabled(True)
1046 self["infoshortcuts"].setEnabled(False)
1047 self["InfoText"].hide()
1048 self["InfoTextBorder"].hide()
1049 self["ButtonRedtext"].setText(_("Close"))
1053 del self.nextStepTimer
1055 def nextStepTimerFire(self):
1056 self.nextStepTimer.stop()
1057 self.steptimer = False
1060 def updownhandler(self,direction):
1061 if direction == 'up':
1062 if self.activebutton >=2:
1063 self.activebutton -= 1
1065 self.activebutton = 6
1066 self.setActiveButton(self.activebutton)
1067 if direction == 'down':
1068 if self.activebutton <=5:
1069 self.activebutton += 1
1071 self.activebutton = 1
1072 self.setActiveButton(self.activebutton)
1074 def setActiveButton(self,button):
1076 self["EditSettingsButton"].setPixmapNum(0)
1077 self["EditSettings_Text"].setForegroundColorNum(0)
1078 self["NetworkInfo"].setPixmapNum(0)
1079 self["NetworkInfo_Text"].setForegroundColorNum(1)
1080 self["AdapterInfo"].setPixmapNum(1) # active
1081 self["AdapterInfo_Text"].setForegroundColorNum(2) # active
1083 self["AdapterInfo_Text"].setForegroundColorNum(1)
1084 self["AdapterInfo"].setPixmapNum(0)
1085 self["DhcpInfo"].setPixmapNum(0)
1086 self["DhcpInfo_Text"].setForegroundColorNum(1)
1087 self["NetworkInfo"].setPixmapNum(1) # active
1088 self["NetworkInfo_Text"].setForegroundColorNum(2) # active
1090 self["NetworkInfo"].setPixmapNum(0)
1091 self["NetworkInfo_Text"].setForegroundColorNum(1)
1092 self["IPInfo"].setPixmapNum(0)
1093 self["IPInfo_Text"].setForegroundColorNum(1)
1094 self["DhcpInfo"].setPixmapNum(1) # active
1095 self["DhcpInfo_Text"].setForegroundColorNum(2) # active
1097 self["DhcpInfo"].setPixmapNum(0)
1098 self["DhcpInfo_Text"].setForegroundColorNum(1)
1099 self["DNSInfo"].setPixmapNum(0)
1100 self["DNSInfo_Text"].setForegroundColorNum(1)
1101 self["IPInfo"].setPixmapNum(1) # active
1102 self["IPInfo_Text"].setForegroundColorNum(2) # active
1104 self["IPInfo"].setPixmapNum(0)
1105 self["IPInfo_Text"].setForegroundColorNum(1)
1106 self["EditSettingsButton"].setPixmapNum(0)
1107 self["EditSettings_Text"].setForegroundColorNum(0)
1108 self["DNSInfo"].setPixmapNum(1) # active
1109 self["DNSInfo_Text"].setForegroundColorNum(2) # active
1111 self["DNSInfo"].setPixmapNum(0)
1112 self["DNSInfo_Text"].setForegroundColorNum(1)
1113 self["EditSettingsButton"].setPixmapNum(1) # active
1114 self["EditSettings_Text"].setForegroundColorNum(2) # active
1115 self["AdapterInfo"].setPixmapNum(0)
1116 self["AdapterInfo_Text"].setForegroundColorNum(1)
1119 next = self.nextstep
1135 self.steptimer = True
1136 self.nextStepTimer.start(3000)
1137 self["ButtonYellow_Check"].show()
1138 self["ButtonYellowtext"].show()
1141 self["Adapter"].setText(iNetwork.getFriendlyAdapterName(self.iface))
1142 self["Adapter"].setForegroundColorNum(2)
1143 self["Adaptertext"].setForegroundColorNum(1)
1144 self["AdapterInfo_Text"].setForegroundColorNum(1)
1145 self["AdapterInfo_OK"].show()
1146 self.steptimer = True
1147 self.nextStepTimer.start(3000)
1150 self["Networktext"].setForegroundColorNum(1)
1151 self["Network"].setText(_("Please wait..."))
1152 self.getLinkState(self.iface)
1153 self["NetworkInfo_Text"].setForegroundColorNum(1)
1154 self.steptimer = True
1155 self.nextStepTimer.start(3000)
1158 self["Dhcptext"].setForegroundColorNum(1)
1159 if iNetwork.getAdapterAttribute(self.iface, 'dhcp') is True:
1160 self["Dhcp"].setForegroundColorNum(2)
1161 self["Dhcp"].setText(_("enabled"))
1162 self["DhcpInfo_Check"].setPixmapNum(0)
1164 self["Dhcp"].setForegroundColorNum(1)
1165 self["Dhcp"].setText(_("disabled"))
1166 self["DhcpInfo_Check"].setPixmapNum(1)
1167 self["DhcpInfo_Check"].show()
1168 self["DhcpInfo_Text"].setForegroundColorNum(1)
1169 self.steptimer = True
1170 self.nextStepTimer.start(3000)
1173 self["IPtext"].setForegroundColorNum(1)
1174 self["IP"].setText(_("Please wait..."))
1175 iNetwork.checkNetworkState(self.NetworkStatedataAvail)
1178 self.steptimer = False
1179 self.nextStepTimer.stop()
1180 self["DNStext"].setForegroundColorNum(1)
1181 self["DNS"].setText(_("Please wait..."))
1182 iNetwork.checkDNSLookup(self.DNSLookupdataAvail)
1185 self["shortcutsgreen"].setEnabled(False)
1186 self["shortcutsyellow"].setEnabled(True)
1187 self["updown_actions"].setEnabled(False)
1188 self["ButtonYellow_Check"].setPixmapNum(0)
1189 self["ButtonGreen_Check"].setPixmapNum(1)
1190 self.steptimer = True
1191 self.nextStepTimer.start(1000)
1193 def KeyGreenRestart(self):
1195 self.layoutFinished()
1196 self["Adapter"].setText((""))
1197 self["Network"].setText((""))
1198 self["Dhcp"].setText((""))
1199 self["IP"].setText((""))
1200 self["DNS"].setText((""))
1201 self["AdapterInfo_Text"].setForegroundColorNum(0)
1202 self["NetworkInfo_Text"].setForegroundColorNum(0)
1203 self["DhcpInfo_Text"].setForegroundColorNum(0)
1204 self["IPInfo_Text"].setForegroundColorNum(0)
1205 self["DNSInfo_Text"].setForegroundColorNum(0)
1206 self["shortcutsgreen_restart"].setEnabled(False)
1207 self["shortcutsgreen"].setEnabled(False)
1208 self["shortcutsyellow"].setEnabled(True)
1209 self["updown_actions"].setEnabled(False)
1210 self["ButtonYellow_Check"].setPixmapNum(0)
1211 self["ButtonGreen_Check"].setPixmapNum(1)
1212 self.steptimer = True
1213 self.nextStepTimer.start(1000)
1216 self["infoshortcuts"].setEnabled(True)
1217 self["shortcuts"].setEnabled(False)
1218 if self.activebutton == 1: # Adapter Check
1219 self["InfoText"].setText(_("This test detects your configured LAN-Adapter."))
1220 self["InfoTextBorder"].show()
1221 self["InfoText"].show()
1222 self["ButtonRedtext"].setText(_("Back"))
1223 if self.activebutton == 2: #LAN Check
1224 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"))
1225 self["InfoTextBorder"].show()
1226 self["InfoText"].show()
1227 self["ButtonRedtext"].setText(_("Back"))
1228 if self.activebutton == 3: #DHCP Check
1229 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."))
1230 self["InfoTextBorder"].show()
1231 self["InfoText"].show()
1232 self["ButtonRedtext"].setText(_("Back"))
1233 if self.activebutton == 4: # IP Check
1234 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"))
1235 self["InfoTextBorder"].show()
1236 self["InfoText"].show()
1237 self["ButtonRedtext"].setText(_("Back"))
1238 if self.activebutton == 5: # DNS Check
1239 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"))
1240 self["InfoTextBorder"].show()
1241 self["InfoText"].show()
1242 self["ButtonRedtext"].setText(_("Back"))
1243 if self.activebutton == 6: # Edit Settings
1244 self.session.open(AdapterSetup,self.iface)
1246 def KeyYellow(self):
1248 self["shortcutsgreen_restart"].setEnabled(True)
1249 self["shortcutsgreen"].setEnabled(False)
1250 self["shortcutsyellow"].setEnabled(False)
1251 self["ButtonGreentext"].setText(_("Restart test"))
1252 self["ButtonYellow_Check"].setPixmapNum(1)
1253 self["ButtonGreen_Check"].setPixmapNum(0)
1254 self.steptimer = False
1255 self.nextStepTimer.stop()
1257 def layoutFinished(self):
1258 self["shortcutsyellow"].setEnabled(False)
1259 self["AdapterInfo_OK"].hide()
1260 self["NetworkInfo_Check"].hide()
1261 self["DhcpInfo_Check"].hide()
1262 self["IPInfo_Check"].hide()
1263 self["DNSInfo_Check"].hide()
1264 self["EditSettings_Text"].hide()
1265 self["EditSettingsButton"].hide()
1266 self["InfoText"].hide()
1267 self["InfoTextBorder"].hide()
1268 self["ButtonYellow_Check"].hide()
1269 self["ButtonYellowtext"].hide()
1271 def setLabels(self):
1272 self["Adaptertext"] = MultiColorLabel(_("LAN Adapter"))
1273 self["Adapter"] = MultiColorLabel()
1274 self["AdapterInfo"] = MultiPixmap()
1275 self["AdapterInfo_Text"] = MultiColorLabel(_("Show Info"))
1276 self["AdapterInfo_OK"] = Pixmap()
1278 if self.iface == 'wlan0' or self.iface == 'ath0':
1279 self["Networktext"] = MultiColorLabel(_("Wireless Network"))
1281 self["Networktext"] = MultiColorLabel(_("Local Network"))
1283 self["Network"] = MultiColorLabel()
1284 self["NetworkInfo"] = MultiPixmap()
1285 self["NetworkInfo_Text"] = MultiColorLabel(_("Show Info"))
1286 self["NetworkInfo_Check"] = MultiPixmap()
1288 self["Dhcptext"] = MultiColorLabel(_("DHCP"))
1289 self["Dhcp"] = MultiColorLabel()
1290 self["DhcpInfo"] = MultiPixmap()
1291 self["DhcpInfo_Text"] = MultiColorLabel(_("Show Info"))
1292 self["DhcpInfo_Check"] = MultiPixmap()
1294 self["IPtext"] = MultiColorLabel(_("IP Address"))
1295 self["IP"] = MultiColorLabel()
1296 self["IPInfo"] = MultiPixmap()
1297 self["IPInfo_Text"] = MultiColorLabel(_("Show Info"))
1298 self["IPInfo_Check"] = MultiPixmap()
1300 self["DNStext"] = MultiColorLabel(_("Nameserver"))
1301 self["DNS"] = MultiColorLabel()
1302 self["DNSInfo"] = MultiPixmap()
1303 self["DNSInfo_Text"] = MultiColorLabel(_("Show Info"))
1304 self["DNSInfo_Check"] = MultiPixmap()
1306 self["EditSettings_Text"] = MultiColorLabel(_("Edit settings"))
1307 self["EditSettingsButton"] = MultiPixmap()
1309 self["ButtonRedtext"] = Label(_("Close"))
1310 self["ButtonRed"] = Pixmap()
1312 self["ButtonGreentext"] = Label(_("Start test"))
1313 self["ButtonGreen_Check"] = MultiPixmap()
1315 self["ButtonYellowtext"] = Label(_("Stop test"))
1316 self["ButtonYellow_Check"] = MultiPixmap()
1318 self["InfoTextBorder"] = Pixmap()
1319 self["InfoText"] = Label()
1321 def getLinkState(self,iface):
1322 if iface == 'wlan0' or iface == 'ath0':
1324 from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus,Status
1326 self["Network"].setForegroundColorNum(1)
1327 self["Network"].setText(_("disconnected"))
1328 self["NetworkInfo_Check"].setPixmapNum(1)
1329 self["NetworkInfo_Check"].show()
1331 iStatus.getDataForInterface(self.iface,self.getInfoCB)
1333 iNetwork.getLinkState(iface,self.LinkStatedataAvail)
1335 def LinkStatedataAvail(self,data):
1336 self.output = data.strip()
1337 result = self.output.split('\n')
1338 pattern = re_compile("Link detected: yes")
1340 if re_search(pattern, item):
1341 self["Network"].setForegroundColorNum(2)
1342 self["Network"].setText(_("connected"))
1343 self["NetworkInfo_Check"].setPixmapNum(0)
1345 self["Network"].setForegroundColorNum(1)
1346 self["Network"].setText(_("disconnected"))
1347 self["NetworkInfo_Check"].setPixmapNum(1)
1348 self["NetworkInfo_Check"].show()
1350 def NetworkStatedataAvail(self,data):
1352 self["IP"].setForegroundColorNum(2)
1353 self["IP"].setText(_("confirmed"))
1354 self["IPInfo_Check"].setPixmapNum(0)
1356 self["IP"].setForegroundColorNum(1)
1357 self["IP"].setText(_("unconfirmed"))
1358 self["IPInfo_Check"].setPixmapNum(1)
1359 self["IPInfo_Check"].show()
1360 self["IPInfo_Text"].setForegroundColorNum(1)
1361 self.steptimer = True
1362 self.nextStepTimer.start(3000)
1364 def DNSLookupdataAvail(self,data):
1366 self["DNS"].setForegroundColorNum(2)
1367 self["DNS"].setText(_("confirmed"))
1368 self["DNSInfo_Check"].setPixmapNum(0)
1370 self["DNS"].setForegroundColorNum(1)
1371 self["DNS"].setText(_("unconfirmed"))
1372 self["DNSInfo_Check"].setPixmapNum(1)
1373 self["DNSInfo_Check"].show()
1374 self["DNSInfo_Text"].setForegroundColorNum(1)
1375 self["EditSettings_Text"].show()
1376 self["EditSettingsButton"].setPixmapNum(1)
1377 self["EditSettings_Text"].setForegroundColorNum(2) # active
1378 self["EditSettingsButton"].show()
1379 self["ButtonYellow_Check"].setPixmapNum(1)
1380 self["ButtonGreentext"].setText(_("Restart test"))
1381 self["ButtonGreen_Check"].setPixmapNum(0)
1382 self["shortcutsgreen"].setEnabled(False)
1383 self["shortcutsgreen_restart"].setEnabled(True)
1384 self["shortcutsyellow"].setEnabled(False)
1385 self["updown_actions"].setEnabled(True)
1386 self.activebutton = 6
1388 def getInfoCB(self,data,status):
1389 if data is not None:
1391 if status is not None:
1392 if status[self.iface]["acesspoint"] == "No Connection" or status[self.iface]["acesspoint"] == "Not-Associated" or status[self.iface]["acesspoint"] == False:
1393 self["Network"].setForegroundColorNum(1)
1394 self["Network"].setText(_("disconnected"))
1395 self["NetworkInfo_Check"].setPixmapNum(1)
1396 self["NetworkInfo_Check"].show()
1398 self["Network"].setForegroundColorNum(2)
1399 self["Network"].setText(_("connected"))
1400 self["NetworkInfo_Check"].setPixmapNum(0)
1401 self["NetworkInfo_Check"].show()
1404 iNetwork.stopLinkStateConsole()
1405 iNetwork.stopDNSConsole()
1407 from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus,Status
1411 iStatus.stopWlanConsole()