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 ):
32 res.append(MultiContentEntryText(pos=(80, 5), size=(430, 25), font=0, text=name))
33 num_configured_if = len(iNetwork.getConfiguredAdapters())
34 if num_configured_if >= 2:
36 png = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/buttons/button_blue.png"))
38 png = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/buttons/button_blue_off.png"))
39 res.append(MultiContentEntryPixmapAlphaTest(pos=(10, 5), size=(25, 25), png = png))
41 png2 = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/icons/lock_on.png"))
43 png2 = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/icons/lock_error.png"))
44 res.append(MultiContentEntryPixmapAlphaTest(pos=(40, 1), size=(25, 25), png = png2))
48 class NetworkAdapterSelection(Screen,HelpableScreen):
49 def __init__(self, session):
50 Screen.__init__(self, session)
51 HelpableScreen.__init__(self)
53 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.")
54 self.lan_errortext = _("No working local network adapter found.\nPlease verify that you have attached a network cable and your network is configured correctly.")
55 self.oktext = _("Press OK on your remote control to continue.")
56 self.restartLanRef = None
58 self["ButtonBluetext"] = Label(_("Set as default Interface"))
59 self["ButtonBlue"] = Pixmap()
60 self["ButtonRedtext"] = Label(_("Close"))
61 self["introduction"] = Label(_("Press OK to edit the settings."))
63 self.adapters = [(iNetwork.getFriendlyAdapterName(x),x) for x in iNetwork.getAdapterList()]
65 if len(self.adapters) == 0:
66 self.onFirstExecBegin.append(self.NetworkFallback)
68 self["OkCancelActions"] = HelpableActionMap(self, "OkCancelActions",
70 "cancel": (self.close, _("exit network interface list")),
71 "ok": (self.okbuttonClick, _("select interface")),
74 self["ColorActions"] = HelpableActionMap(self, "ColorActions",
76 "red": (self.close, _("exit network interface list")),
79 self["DefaultInterfaceAction"] = HelpableActionMap(self, "ColorActions",
81 "blue": (self.setDefaultInterface, [_("Set interface as default Interface"),_("* Only available if more than one interface is active.")] ),
85 self["list"] = InterfaceList(self.list)
88 if len(self.adapters) == 1:
89 self.onFirstExecBegin.append(self.okbuttonClick)
90 self.onClose.append(self.cleanup)
96 num_configured_if = len(iNetwork.getConfiguredAdapters())
97 if num_configured_if >= 2:
98 self["ButtonBlue"].show()
99 self["ButtonBluetext"].show()
100 self["DefaultInterfaceAction"].setEnabled(True)
102 self["ButtonBlue"].hide()
103 self["ButtonBluetext"].hide()
104 self["DefaultInterfaceAction"].setEnabled(False)
106 if num_configured_if < 2 and os_path.exists("/etc/default_gw"):
107 unlink("/etc/default_gw")
109 if os_path.exists("/etc/default_gw"):
110 fp = file('/etc/default_gw', 'r')
115 if len(self.adapters) == 0: # no interface available => display only eth0
116 self.list.append(InterfaceEntryComponent("eth0",iNetwork.getFriendlyAdapterName('eth0'),True,True ))
118 for x in self.adapters:
119 if x[1] == default_gw:
123 if iNetwork.getAdapterAttribute(x[1], 'up') is True:
127 self.list.append(InterfaceEntryComponent(index = x[1],name = _(x[0]),default=default_int,active=active_int ))
128 self["list"].l.setList(self.list)
130 def setDefaultInterface(self):
131 selection = self["list"].getCurrent()
132 num_if = len(self.list)
133 old_default_gw = None
134 num_configured_if = len(iNetwork.getConfiguredAdapters())
135 if os_path.exists("/etc/default_gw"):
136 fp = open('/etc/default_gw', 'r')
137 old_default_gw = fp.read()
139 if num_configured_if > 1 and (not old_default_gw or old_default_gw != selection[0]):
140 fp = open('/etc/default_gw', 'w+')
141 fp.write(selection[0])
144 elif old_default_gw and num_configured_if < 2:
145 unlink("/etc/default_gw")
148 def okbuttonClick(self):
149 selection = self["list"].getCurrent()
150 if selection is not None:
151 self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetupConfiguration, selection[0])
153 def AdapterSetupClosed(self, *ret):
154 if len(self.adapters) == 1:
159 def NetworkFallback(self):
160 if iNetwork.configuredNetworkAdapters.has_key('wlan0') is True:
161 self.session.openWithCallback(self.ErrorMessageClosed, MessageBox, self.wlan_errortext, type = MessageBox.TYPE_INFO,timeout = 10)
162 if iNetwork.configuredNetworkAdapters.has_key('ath0') is True:
163 self.session.openWithCallback(self.ErrorMessageClosed, MessageBox, self.wlan_errortext, type = MessageBox.TYPE_INFO,timeout = 10)
165 self.session.openWithCallback(self.ErrorMessageClosed, MessageBox, self.lan_errortext, type = MessageBox.TYPE_INFO,timeout = 10)
167 def ErrorMessageClosed(self, *ret):
168 if iNetwork.configuredNetworkAdapters.has_key('wlan0') is True:
169 self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetupConfiguration, 'wlan0')
170 elif iNetwork.configuredNetworkAdapters.has_key('ath0') is True:
171 self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetupConfiguration, 'ath0')
173 self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetupConfiguration, 'eth0')
176 iNetwork.stopLinkStateConsole()
177 iNetwork.stopRestartConsole()
178 iNetwork.stopGetInterfacesConsole()
180 def restartLan(self):
181 iNetwork.restartNetwork(self.restartLanDataAvail)
182 self.restartLanRef = self.session.openWithCallback(self.restartfinishedCB, MessageBox, _("Please wait while we configure your network..."), type = MessageBox.TYPE_INFO, enable_input = False)
184 def restartLanDataAvail(self, data):
186 iNetwork.getInterfaces(self.getInterfacesDataAvail)
188 def getInterfacesDataAvail(self, data):
190 self.restartLanRef.close(True)
192 def restartfinishedCB(self,data):
195 self.session.open(MessageBox, _("Finished configuring your network"), type = MessageBox.TYPE_INFO, timeout = 10, default = False)
198 class NameserverSetup(Screen, ConfigListScreen, HelpableScreen):
199 def __init__(self, session):
200 Screen.__init__(self, session)
201 HelpableScreen.__init__(self)
202 self.backupNameserverList = iNetwork.getNameserverList()[:]
203 print "backup-list:", self.backupNameserverList
205 self["ButtonGreentext"] = Label(_("Add"))
206 self["ButtonYellowtext"] = Label(_("Delete"))
207 self["ButtonRedtext"] = Label(_("Close"))
208 self["introduction"] = Label(_("Press OK to activate the settings."))
211 self["OkCancelActions"] = HelpableActionMap(self, "OkCancelActions",
213 "cancel": (self.cancel, _("exit nameserver configuration")),
214 "ok": (self.ok, _("activate current configuration")),
217 self["ColorActions"] = HelpableActionMap(self, "ColorActions",
219 "red": (self.cancel, _("exit nameserver configuration")),
220 "green": (self.add, _("add a nameserver entry")),
221 "yellow": (self.remove, _("remove a nameserver entry")),
224 self["actions"] = NumberActionMap(["SetupActions"],
230 ConfigListScreen.__init__(self, self.list)
233 def createConfig(self):
234 self.nameservers = iNetwork.getNameserverList()
235 self.nameserverEntries = []
237 for nameserver in self.nameservers:
238 self.nameserverEntries.append(NoSave(ConfigIP(default=nameserver)))
240 def createSetup(self):
243 for i in range(len(self.nameserverEntries)):
244 self.list.append(getConfigListEntry(_("Nameserver %d") % (i + 1), self.nameserverEntries[i]))
246 self["config"].list = self.list
247 self["config"].l.setList(self.list)
250 iNetwork.clearNameservers()
251 for nameserver in self.nameserverEntries:
252 iNetwork.addNameserver(nameserver.value)
253 iNetwork.writeNameserverConfig()
260 iNetwork.clearNameservers()
261 print "backup-list:", self.backupNameserverList
262 for nameserver in self.backupNameserverList:
263 iNetwork.addNameserver(nameserver)
267 iNetwork.addNameserver([0,0,0,0])
272 print "currentIndex:", self["config"].getCurrentIndex()
274 index = self["config"].getCurrentIndex()
275 if index < len(self.nameservers):
276 iNetwork.removeNameserver(self.nameservers[index])
280 class AdapterSetup(Screen, ConfigListScreen, HelpableScreen):
281 def __init__(self, session, networkinfo, essid=None, aplist=None):
282 Screen.__init__(self, session)
283 HelpableScreen.__init__(self)
284 self.session = session
285 if isinstance(networkinfo, (list, tuple)):
286 self.iface = networkinfo[0]
287 self.essid = networkinfo[1]
288 self.aplist = networkinfo[2]
290 self.iface = networkinfo
294 self.applyConfigRef = None
295 self.finished_cb = None
296 self.oktext = _("Press OK on your remote control to continue.")
297 self.oldInterfaceState = iNetwork.getAdapterAttribute(self.iface, "up")
301 self["OkCancelActions"] = HelpableActionMap(self, "OkCancelActions",
303 "cancel": (self.cancel, _("exit network adapter setup menu")),
304 "ok": (self.ok, _("select menu entry")),
307 self["ColorActions"] = HelpableActionMap(self, "ColorActions",
309 "red": (self.cancel, _("exit network adapter configuration")),
310 "blue": (self.KeyBlue, _("open nameserver configuration")),
313 self["VirtualKB"] = HelpableActionMap(self, "ColorActions",
315 "green": (self.KeyGreen, [_("open virtual keyboard input help"),_("* Only available when entering hidden SSID or network key")] ),
318 self["actions"] = NumberActionMap(["SetupActions"],
325 ConfigListScreen.__init__(self, self.list,session = self.session)
327 self.onLayoutFinish.append(self.layoutFinished)
328 self.onClose.append(self.cleanup)
330 self["DNS1text"] = Label(_("Primary DNS"))
331 self["DNS2text"] = Label(_("Secondary DNS"))
332 self["DNS1"] = Label()
333 self["DNS2"] = Label()
335 self["introduction"] = Label(_("Current settings:"))
337 self["IPtext"] = Label(_("IP Address"))
338 self["Netmasktext"] = Label(_("Netmask"))
339 self["Gatewaytext"] = Label(_("Gateway"))
342 self["Mask"] = Label()
343 self["Gateway"] = Label()
345 self["BottomBG"] = Pixmap()
346 self["Adaptertext"] = Label(_("Network:"))
347 self["Adapter"] = Label()
348 self["introduction2"] = Label(_("Press OK to activate the settings."))
349 self["ButtonRed"] = Pixmap()
350 self["ButtonRedtext"] = Label(_("Close"))
351 self["ButtonBlue"] = Pixmap()
352 self["ButtonBluetext"] = Label(_("Edit DNS"))
353 self["ButtonGreen"] = Pixmap()
354 self["VKeyIcon"] = Pixmap()
355 self["HelpWindow"] = Pixmap()
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["Gateway"].setText(_("N/A"))
378 self["Gateway"].setText(self.gatewayConfigEntry.getText())
380 self["Gateway"].hide()
381 self["Gatewaytext"].hide()
382 self["Adapter"].setText(iNetwork.getFriendlyAdapterName(self.iface))
383 self["ButtonGreen"].hide()
384 self["VKeyIcon"].hide()
385 self["VirtualKB"].setEnabled(False)
386 self["HelpWindow"].hide()
388 def createConfig(self):
389 self.InterfaceEntry = None
390 self.dhcpEntry = None
391 self.gatewayEntry = None
392 self.hiddenSSID = None
394 self.encryptionEnabled = None
395 self.encryptionKey = None
396 self.encryptionType = None
398 self.encryptionlist = None
403 if self.iface == "wlan0" or self.iface == "ath0" :
404 from Plugins.SystemPlugins.WirelessLan.Wlan import wpaSupplicant,Wlan
405 self.w = Wlan(self.iface)
406 self.ws = wpaSupplicant()
407 self.encryptionlist = []
408 self.encryptionlist.append(("WEP", _("WEP")))
409 self.encryptionlist.append(("WPA", _("WPA")))
410 self.encryptionlist.append(("WPA2", _("WPA2")))
411 self.encryptionlist.append(("WPA/WPA2", _("WPA or WPA2")))
413 self.weplist.append("ASCII")
414 self.weplist.append("HEX")
415 if self.aplist is not None:
416 self.nwlist = self.aplist
417 self.nwlist.sort(key = lambda x: x[0])
422 self.aps = self.w.getNetworkList()
423 if self.aps is not None:
424 print "[NetworkSetup.py] got Accespoints!"
429 a['essid'] = a['bssid']
430 self.nwlist.append((a['essid'],a['essid']))
431 self.nwlist.sort(key = lambda x: x[0])
433 self.nwlist.append(("No Networks found",_("No Networks found")))
435 self.wsconfig = self.ws.loadConfig()
436 if self.essid is not None: # ssid from wlan scan
437 self.default = self.essid
439 self.default = self.wsconfig['ssid']
441 if "hidden..." not in self.nwlist:
442 self.nwlist.append(("hidden...",_("hidden network")))
443 if self.default not in self.nwlist:
444 self.nwlist.append((self.default,self.default))
445 config.plugins.wlan.essid = NoSave(ConfigSelection(self.nwlist, default = self.default ))
446 config.plugins.wlan.hiddenessid = NoSave(ConfigText(default = self.wsconfig['hiddenessid'], visible_width = 50, fixed_size = False))
448 config.plugins.wlan.encryption.enabled = NoSave(ConfigYesNo(default = self.wsconfig['encryption'] ))
449 config.plugins.wlan.encryption.type = NoSave(ConfigSelection(self.encryptionlist, default = self.wsconfig['encryption_type'] ))
450 config.plugins.wlan.encryption.wepkeytype = NoSave(ConfigSelection(self.weplist, default = self.wsconfig['encryption_wepkeytype'] ))
451 config.plugins.wlan.encryption.psk = NoSave(ConfigPassword(default = self.wsconfig['key'], visible_width = 50, fixed_size = False))
453 self.activateInterfaceEntry = NoSave(ConfigYesNo(default=iNetwork.getAdapterAttribute(self.iface, "up") or False))
454 self.dhcpConfigEntry = NoSave(ConfigYesNo(default=iNetwork.getAdapterAttribute(self.iface, "dhcp") or False))
455 self.ipConfigEntry = NoSave(ConfigIP(default=iNetwork.getAdapterAttribute(self.iface, "ip")) or [0,0,0,0])
456 self.netmaskConfigEntry = NoSave(ConfigIP(default=iNetwork.getAdapterAttribute(self.iface, "netmask") or [255,0,0,0]))
457 if iNetwork.getAdapterAttribute(self.iface, "gateway"):
458 self.dhcpdefault=True
460 self.dhcpdefault=False
461 self.hasGatewayConfigEntry = NoSave(ConfigYesNo(default=self.dhcpdefault or False))
462 self.gatewayConfigEntry = NoSave(ConfigIP(default=iNetwork.getAdapterAttribute(self.iface, "gateway") or [0,0,0,0]))
463 nameserver = (iNetwork.getNameserverList() + [[0,0,0,0]] * 2)[0:2]
464 self.primaryDNS = NoSave(ConfigIP(default=nameserver[0]))
465 self.secondaryDNS = NoSave(ConfigIP(default=nameserver[1]))
467 def createSetup(self):
469 self.InterfaceEntry = getConfigListEntry(_("Use Interface"), self.activateInterfaceEntry)
471 self.list.append(self.InterfaceEntry)
472 if self.activateInterfaceEntry.value:
473 self.dhcpEntry = getConfigListEntry(_("Use DHCP"), self.dhcpConfigEntry)
474 self.list.append(self.dhcpEntry)
475 if not self.dhcpConfigEntry.value:
476 self.list.append(getConfigListEntry(_('IP Address'), self.ipConfigEntry))
477 self.list.append(getConfigListEntry(_('Netmask'), self.netmaskConfigEntry))
478 self.gatewayEntry = getConfigListEntry(_('Use a gateway'), self.hasGatewayConfigEntry)
479 self.list.append(self.gatewayEntry)
480 if self.hasGatewayConfigEntry.value:
481 self.list.append(getConfigListEntry(_('Gateway'), self.gatewayConfigEntry))
484 for p in plugins.getPlugins(PluginDescriptor.WHERE_NETWORKSETUP):
485 callFnc = p.__call__["ifaceSupported"](self.iface)
486 if callFnc is not None:
487 if p.__call__.has_key("WlanPluginEntry"): # internally used only for WLAN Plugin
488 self.extended = callFnc
489 if p.__call__.has_key("configStrings"):
490 self.configStrings = p.__call__["configStrings"]
492 self.configStrings = None
493 if config.plugins.wlan.essid.value == 'hidden...':
494 self.wlanSSID = getConfigListEntry(_("Network SSID"), config.plugins.wlan.essid)
495 self.list.append(self.wlanSSID)
496 self.hiddenSSID = getConfigListEntry(_("Hidden network SSID"), config.plugins.wlan.hiddenessid)
497 self.list.append(self.hiddenSSID)
499 self.wlanSSID = getConfigListEntry(_("Network SSID"), config.plugins.wlan.essid)
500 self.list.append(self.wlanSSID)
501 self.encryptionEnabled = getConfigListEntry(_("Encryption"), config.plugins.wlan.encryption.enabled)
502 self.list.append(self.encryptionEnabled)
504 if config.plugins.wlan.encryption.enabled.value:
505 self.encryptionType = getConfigListEntry(_("Encryption Type"), config.plugins.wlan.encryption.type)
506 self.list.append(self.encryptionType)
507 if config.plugins.wlan.encryption.type.value == 'WEP':
508 self.list.append(getConfigListEntry(_("Encryption Keytype"), config.plugins.wlan.encryption.wepkeytype))
509 self.encryptionKey = getConfigListEntry(_("Encryption Key"), config.plugins.wlan.encryption.psk)
510 self.list.append(self.encryptionKey)
512 self.encryptionKey = getConfigListEntry(_("Encryption Key"), config.plugins.wlan.encryption.psk)
513 self.list.append(self.encryptionKey)
516 self["config"].list = self.list
517 self["config"].l.setList(self.list)
518 if not self.selectionChanged in self["config"].onSelectionChanged:
519 self["config"].onSelectionChanged.append(self.selectionChanged)
522 self.session.openWithCallback(self.NameserverSetupClosed, NameserverSetup)
525 if self.iface == "wlan0" or self.iface == "ath0" :
526 if self["config"].getCurrent() == self.hiddenSSID:
527 if config.plugins.wlan.essid.value == 'hidden...':
528 self.session.openWithCallback(self.VirtualKeyBoardSSIDCallback, VirtualKeyBoard, title = (_("Enter WLAN network name/SSID:")), text = config.plugins.wlan.essid.value)
529 if self["config"].getCurrent() == self.encryptionKey:
530 self.session.openWithCallback(self.VirtualKeyBoardKeyCallback, VirtualKeyBoard, title = (_("Enter WLAN passphrase/key:")), text = config.plugins.wlan.encryption.psk.value)
532 def VirtualKeyBoardSSIDCallback(self, callback = None):
533 if callback is not None and len(callback):
534 config.plugins.wlan.hiddenessid = NoSave(ConfigText(default = callback, visible_width = 50, fixed_size = False))
537 def VirtualKeyBoardKeyCallback(self, callback = None):
538 if callback is not None and len(callback):
539 config.plugins.wlan.encryption.psk = NoSave(ConfigPassword(default = callback, visible_width = 50, fixed_size = False))
543 if self["config"].getCurrent() == self.InterfaceEntry:
545 if self["config"].getCurrent() == self.dhcpEntry:
547 if self["config"].getCurrent() == self.gatewayEntry:
549 if self.iface == "wlan0" or self.iface == "ath0" :
550 if self["config"].getCurrent() == self.wlanSSID:
552 if self["config"].getCurrent() == self.encryptionEnabled:
554 if self["config"].getCurrent() == self.encryptionType:
557 ConfigListScreen.keyLeft(self)
561 ConfigListScreen.keyRight(self)
564 def selectionChanged(self):
565 current = self["config"].getCurrent()
566 if current == self.hiddenSSID and config.plugins.wlan.essid.value == 'hidden...':
567 helpwindowpos = self["HelpWindow"].getPosition()
568 if current[1].help_window.instance is not None:
569 current[1].help_window.instance.move(ePoint(helpwindowpos[0],helpwindowpos[1]))
570 self["ButtonGreen"].show()
571 self["VKeyIcon"].show()
572 self["VirtualKB"].setEnabled(True)
573 elif current == self.encryptionKey and config.plugins.wlan.encryption.enabled.value:
574 helpwindowpos = self["HelpWindow"].getPosition()
575 if current[1].help_window.instance is not None:
576 current[1].help_window.instance.move(ePoint(helpwindowpos[0],helpwindowpos[1]))
577 self["ButtonGreen"].show()
578 self["VKeyIcon"].show()
579 self["VirtualKB"].setEnabled(True)
581 self["ButtonGreen"].hide()
582 self["VKeyIcon"].hide()
583 self["VirtualKB"].setEnabled(False)
586 current = self["config"].getCurrent()
587 if current == self.hiddenSSID and config.plugins.wlan.essid.value == 'hidden...':
588 if current[1].help_window.instance is not None:
589 current[1].help_window.instance.hide()
590 elif current == self.encryptionKey and config.plugins.wlan.encryption.enabled.value:
591 if current[1].help_window.instance is not None:
592 current[1].help_window.instance.hide()
593 self.session.openWithCallback(self.applyConfig, MessageBox, (_("Are you sure you want to activate this network configuration?\n\n") + self.oktext ) )
595 def applyConfig(self, ret = False):
597 iNetwork.setAdapterAttribute(self.iface, "up", self.activateInterfaceEntry.value)
598 iNetwork.setAdapterAttribute(self.iface, "dhcp", self.dhcpConfigEntry.value)
599 iNetwork.setAdapterAttribute(self.iface, "ip", self.ipConfigEntry.value)
600 iNetwork.setAdapterAttribute(self.iface, "netmask", self.netmaskConfigEntry.value)
601 if self.hasGatewayConfigEntry.value:
602 iNetwork.setAdapterAttribute(self.iface, "gateway", self.gatewayConfigEntry.value)
604 iNetwork.removeAdapterAttribute(self.iface, "gateway")
605 if self.extended is not None and self.configStrings is not None:
606 iNetwork.setAdapterAttribute(self.iface, "configStrings", self.configStrings(self.iface))
607 self.ws.writeConfig()
608 if self.activateInterfaceEntry.value is False:
609 iNetwork.deactivateInterface(self.iface)
610 iNetwork.writeNetworkConfig()
611 iNetwork.restartNetwork(self.applyConfigDataAvail)
612 self.applyConfigRef = self.session.openWithCallback(self.applyConfigfinishedCB, MessageBox, _("Please wait for activation of your network configuration..."), type = MessageBox.TYPE_INFO, enable_input = False)
616 def applyConfigDataAvail(self, data):
618 iNetwork.getInterfaces(self.getInterfacesDataAvail)
620 def getInterfacesDataAvail(self, data):
622 self.applyConfigRef.close(True)
624 def applyConfigfinishedCB(self,data):
626 num_configured_if = len(iNetwork.getConfiguredAdapters())
627 if num_configured_if >= 2:
628 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)
631 self.session.openWithCallback(lambda x : self.finished_cb(), MessageBox, _("Your network configuration has been activated."), type = MessageBox.TYPE_INFO, timeout = 10)
633 self.session.openWithCallback(self.ConfigfinishedCB, MessageBox, _("Your network configuration has been activated."), type = MessageBox.TYPE_INFO, timeout = 10)
635 def secondIfaceFoundCB(self,data):
639 configuredInterfaces = iNetwork.getConfiguredAdapters()
640 for interface in configuredInterfaces:
641 if interface == self.iface:
643 iNetwork.setAdapterAttribute(interface, "up", False)
644 iNetwork.deactivateInterface(interface)
645 self.applyConfig(True)
647 def ConfigfinishedCB(self,data):
653 if self.oldInterfaceState is False:
654 iNetwork.deactivateInterface(self.iface,self.cancelCB)
658 def cancelCB(self,data):
663 def runAsync(self, finished_cb):
664 self.finished_cb = finished_cb
667 def NameserverSetupClosed(self, *ret):
668 iNetwork.loadNameserverConfig()
669 nameserver = (iNetwork.getNameserverList() + [[0,0,0,0]] * 2)[0:2]
670 self.primaryDNS = NoSave(ConfigIP(default=nameserver[0]))
671 self.secondaryDNS = NoSave(ConfigIP(default=nameserver[1]))
673 self.layoutFinished()
676 iNetwork.stopLinkStateConsole()
679 class AdapterSetupConfiguration(Screen, HelpableScreen):
680 def __init__(self, session,iface):
681 Screen.__init__(self, session)
682 HelpableScreen.__init__(self)
683 self.session = session
685 self.restartLanRef = None
686 self.mainmenu = self.genMainMenu()
687 self["menulist"] = MenuList(self.mainmenu)
688 self["description"] = Label()
689 self["IFtext"] = Label()
691 self["BottomBG"] = Label()
692 self["Statustext"] = Label()
693 self["statuspic"] = MultiPixmap()
694 self["statuspic"].hide()
695 self["BottomBG"] = Pixmap()
696 self["ButtonRed"] = Pixmap()
697 self["ButtonRedtext"] = Label(_("Close"))
699 self.oktext = _("Press OK on your remote control to continue.")
700 self.reboottext = _("Your Dreambox will restart after pressing OK on your remote control.")
701 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.")
703 self["WizardActions"] = HelpableActionMap(self, "WizardActions",
705 "up": (self.up, _("move up to previous entry")),
706 "down": (self.down, _("move down to next entry")),
707 "left": (self.left, _("move up to first entry")),
708 "right": (self.right, _("move down to last entry")),
711 self["OkCancelActions"] = HelpableActionMap(self, "OkCancelActions",
713 "cancel": (self.close, _("exit networkadapter setup menu")),
714 "ok": (self.ok, _("select menu entry")),
717 self["ColorActions"] = HelpableActionMap(self, "ColorActions",
719 "red": (self.close, _("exit networkadapter setup menu")),
722 self["actions"] = NumberActionMap(["WizardActions","ShortcutActions"],
733 self.updateStatusbar()
734 self.onLayoutFinish.append(self.layoutFinished)
735 self.onClose.append(self.cleanup)
738 if self["menulist"].getCurrent()[1] == 'edit':
739 if self.iface == 'wlan0' or self.iface == 'ath0':
741 from Plugins.SystemPlugins.WirelessLan.plugin import WlanScan
742 from Plugins.SystemPlugins.WirelessLan.iwlibs import Wireless
744 self.session.open(MessageBox, _("The wireless LAN plugin is not installed!\nPlease install it."), type = MessageBox.TYPE_INFO,timeout = 10 )
746 ifobj = Wireless(self.iface) # a Wireless NIC Object
747 self.wlanresponse = ifobj.getStatistics()
748 if self.wlanresponse[0] != 19: # Wlan Interface found.
749 self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetup,self.iface)
751 # Display Wlan not available Message
752 self.showErrorMessage()
754 self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetup,self.iface)
755 if self["menulist"].getCurrent()[1] == 'test':
756 self.session.open(NetworkAdapterTest,self.iface)
757 if self["menulist"].getCurrent()[1] == 'dns':
758 self.session.open(NameserverSetup)
759 if self["menulist"].getCurrent()[1] == 'scanwlan':
761 from Plugins.SystemPlugins.WirelessLan.plugin import WlanScan
762 from Plugins.SystemPlugins.WirelessLan.iwlibs import Wireless
764 self.session.open(MessageBox, _("The wireless LAN plugin is not installed!\nPlease install it."), type = MessageBox.TYPE_INFO,timeout = 10 )
766 ifobj = Wireless(self.iface) # a Wireless NIC Object
767 self.wlanresponse = ifobj.getStatistics()
768 if self.wlanresponse[0] != 19:
769 self.session.openWithCallback(self.WlanScanClosed, WlanScan, self.iface)
771 # Display Wlan not available Message
772 self.showErrorMessage()
773 if self["menulist"].getCurrent()[1] == 'wlanstatus':
775 from Plugins.SystemPlugins.WirelessLan.plugin import WlanStatus
776 from Plugins.SystemPlugins.WirelessLan.iwlibs import Wireless
778 self.session.open(MessageBox, _("The wireless LAN plugin is not installed!\nPlease install it."), type = MessageBox.TYPE_INFO,timeout = 10 )
780 ifobj = Wireless(self.iface) # a Wireless NIC Object
781 self.wlanresponse = ifobj.getStatistics()
782 if self.wlanresponse[0] != 19:
783 self.session.openWithCallback(self.WlanStatusClosed, WlanStatus,self.iface)
785 # Display Wlan not available Message
786 self.showErrorMessage()
787 if self["menulist"].getCurrent()[1] == 'lanrestart':
788 self.session.openWithCallback(self.restartLan, MessageBox, (_("Are you sure you want to restart your network interfaces?\n\n") + self.oktext ) )
789 if self["menulist"].getCurrent()[1] == 'openwizard':
790 from Plugins.SystemPlugins.NetworkWizard.NetworkWizard import NetworkWizard
791 self.session.openWithCallback(self.AdapterSetupClosed, NetworkWizard)
792 if self["menulist"].getCurrent()[1][0] == 'extendedSetup':
793 self.extended = self["menulist"].getCurrent()[1][2]
794 self.extended(self.session, self.iface)
797 self["menulist"].up()
798 self.loadDescription()
801 self["menulist"].down()
802 self.loadDescription()
805 self["menulist"].pageUp()
806 self.loadDescription()
809 self["menulist"].pageDown()
810 self.loadDescription()
812 def layoutFinished(self):
814 self["menulist"].moveToIndex(idx)
815 self.loadDescription()
817 def loadDescription(self):
818 print self["menulist"].getCurrent()[1]
819 if self["menulist"].getCurrent()[1] == 'edit':
820 self["description"].setText(_("Edit the network configuration of your Dreambox.\n" ) + self.oktext )
821 if self["menulist"].getCurrent()[1] == 'test':
822 self["description"].setText(_("Test the network configuration of your Dreambox.\n" ) + self.oktext )
823 if self["menulist"].getCurrent()[1] == 'dns':
824 self["description"].setText(_("Edit the Nameserver configuration of your Dreambox.\n" ) + self.oktext )
825 if self["menulist"].getCurrent()[1] == 'scanwlan':
826 self["description"].setText(_("Scan your network for wireless Access Points and connect to them using your WLAN USB Stick\n" ) + self.oktext )
827 if self["menulist"].getCurrent()[1] == 'wlanstatus':
828 self["description"].setText(_("Shows the state of your wireless LAN connection.\n" ) + self.oktext )
829 if self["menulist"].getCurrent()[1] == 'lanrestart':
830 self["description"].setText(_("Restart your network connection and interfaces.\n" ) + self.oktext )
831 if self["menulist"].getCurrent()[1] == 'openwizard':
832 self["description"].setText(_("Use the Networkwizard to configure your Network\n" ) + self.oktext )
833 if self["menulist"].getCurrent()[1][0] == 'extendedSetup':
834 self["description"].setText(_(self["menulist"].getCurrent()[1][1]) + self.oktext )
836 def updateStatusbar(self, data = None):
837 self["IFtext"].setText(_("Network:"))
838 self["IF"].setText(iNetwork.getFriendlyAdapterName(self.iface))
839 self["Statustext"].setText(_("Link:"))
841 if self.iface == 'wlan0' or self.iface == 'ath0':
843 from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus,Status
845 self["statuspic"].setPixmapNum(1)
846 self["statuspic"].show()
848 iStatus.getDataForInterface(self.iface,self.getInfoCB)
850 iNetwork.getLinkState(self.iface,self.dataAvail)
855 def genMainMenu(self):
857 menu.append((_("Adapter settings"), "edit"))
858 menu.append((_("Nameserver settings"), "dns"))
859 menu.append((_("Network test"), "test"))
860 menu.append((_("Restart network"), "lanrestart"))
863 self.extendedSetup = None
864 for p in plugins.getPlugins(PluginDescriptor.WHERE_NETWORKSETUP):
865 callFnc = p.__call__["ifaceSupported"](self.iface)
866 if callFnc is not None:
867 self.extended = callFnc
869 if p.__call__.has_key("WlanPluginEntry"): # internally used only for WLAN Plugin
870 menu.append((_("Scan Wireless Networks"), "scanwlan"))
871 if iNetwork.getAdapterAttribute(self.iface, "up"):
872 menu.append((_("Show WLAN Status"), "wlanstatus"))
874 if p.__call__.has_key("menuEntryName"):
875 menuEntryName = p.__call__["menuEntryName"](self.iface)
877 menuEntryName = _('Extended Setup...')
878 if p.__call__.has_key("menuEntryDescription"):
879 menuEntryDescription = p.__call__["menuEntryDescription"](self.iface)
881 menuEntryDescription = _('Extended Networksetup Plugin...')
882 self.extendedSetup = ('extendedSetup',menuEntryDescription, self.extended)
883 menu.append((menuEntryName,self.extendedSetup))
885 if os_path.exists(resolveFilename(SCOPE_PLUGINS, "SystemPlugins/NetworkWizard/networkwizard.xml")):
886 menu.append((_("NetworkWizard"), "openwizard"))
890 def AdapterSetupClosed(self, *ret):
891 if ret is not None and len(ret):
892 if ret[0] == 'ok' and (self.iface == 'wlan0' or self.iface == 'ath0') and iNetwork.getAdapterAttribute(self.iface, "up") is True:
894 from Plugins.SystemPlugins.WirelessLan.plugin import WlanStatus
895 from Plugins.SystemPlugins.WirelessLan.iwlibs import Wireless
897 self.session.open(MessageBox, _("The wireless LAN plugin is not installed!\nPlease install it."), type = MessageBox.TYPE_INFO,timeout = 10 )
899 ifobj = Wireless(self.iface) # a Wireless NIC Object
900 self.wlanresponse = ifobj.getStatistics()
901 if self.wlanresponse[0] != 19:
902 self.session.openWithCallback(self.WlanStatusClosed, WlanStatus,self.iface)
904 # Display Wlan not available Message
905 self.showErrorMessage()
907 self.mainmenu = self.genMainMenu()
908 self["menulist"].l.setList(self.mainmenu)
909 self.updateStatusbar()
911 self.mainmenu = self.genMainMenu()
912 self["menulist"].l.setList(self.mainmenu)
913 self.updateStatusbar()
915 def WlanStatusClosed(self, *ret):
916 if ret is not None and len(ret):
917 from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus,Status
918 iStatus.stopWlanConsole()
919 self.mainmenu = self.genMainMenu()
920 self["menulist"].l.setList(self.mainmenu)
921 self.updateStatusbar()
923 def WlanScanClosed(self,*ret):
924 if ret[0] is not None:
925 self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetup, self.iface,ret[0],ret[1])
927 from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus,Status
928 iStatus.stopWlanConsole()
929 self.mainmenu = self.genMainMenu()
930 self["menulist"].l.setList(self.mainmenu)
931 self.updateStatusbar()
933 def restartLan(self, ret = False):
935 iNetwork.restartNetwork(self.restartLanDataAvail)
936 self.restartLanRef = self.session.openWithCallback(self.restartfinishedCB, MessageBox, _("Please wait while your network is restarting..."), type = MessageBox.TYPE_INFO, enable_input = False)
938 def restartLanDataAvail(self, data):
940 iNetwork.getInterfaces(self.getInterfacesDataAvail)
942 def getInterfacesDataAvail(self, data):
944 self.restartLanRef.close(True)
946 def restartfinishedCB(self,data):
948 self.session.open(MessageBox, _("Finished restarting your network"), type = MessageBox.TYPE_INFO, timeout = 10, default = False)
950 def dataAvail(self,data):
951 self.output = data.strip()
952 result = self.output.split('\n')
953 pattern = re_compile("Link detected: yes")
955 if re_search(pattern, item):
956 self["statuspic"].setPixmapNum(0)
958 self["statuspic"].setPixmapNum(1)
959 self["statuspic"].show()
961 def showErrorMessage(self):
962 self.session.open(MessageBox, self.errortext, type = MessageBox.TYPE_INFO,timeout = 10 )
965 iNetwork.stopLinkStateConsole()
966 iNetwork.stopDeactivateInterfaceConsole()
968 from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus,Status
972 iStatus.stopWlanConsole()
974 def getInfoCB(self,data,status):
977 if status is not None:
978 if status[self.iface]["acesspoint"] == "No Connection" or status[self.iface]["acesspoint"] == "Not-Associated" or status[self.iface]["acesspoint"] == False:
979 self["statuspic"].setPixmapNum(1)
981 self["statuspic"].setPixmapNum(0)
982 self["statuspic"].show()
984 class NetworkAdapterTest(Screen):
985 def __init__(self, session,iface):
986 Screen.__init__(self, session)
988 self.oldInterfaceState = iNetwork.getAdapterAttribute(self.iface, "up")
990 self.onClose.append(self.cleanup)
991 self.onHide.append(self.cleanup)
993 self["updown_actions"] = NumberActionMap(["WizardActions","ShortcutActions"],
997 "up": lambda: self.updownhandler('up'),
998 "down": lambda: self.updownhandler('down'),
1002 self["shortcuts"] = ActionMap(["ShortcutActions","WizardActions"],
1005 "back": self.cancel,
1007 self["infoshortcuts"] = ActionMap(["ShortcutActions","WizardActions"],
1009 "red": self.closeInfo,
1010 "back": self.closeInfo,
1012 self["shortcutsgreen"] = ActionMap(["ShortcutActions"],
1014 "green": self.KeyGreen,
1016 self["shortcutsgreen_restart"] = ActionMap(["ShortcutActions"],
1018 "green": self.KeyGreenRestart,
1020 self["shortcutsyellow"] = ActionMap(["ShortcutActions"],
1022 "yellow": self.KeyYellow,
1025 self["shortcutsgreen_restart"].setEnabled(False)
1026 self["updown_actions"].setEnabled(False)
1027 self["infoshortcuts"].setEnabled(False)
1028 self.onClose.append(self.delTimer)
1029 self.onLayoutFinish.append(self.layoutFinished)
1030 self.steptimer = False
1032 self.activebutton = 0
1033 self.nextStepTimer = eTimer()
1034 self.nextStepTimer.callback.append(self.nextStepTimerFire)
1037 if self.oldInterfaceState is False:
1038 iNetwork.setAdapterAttribute(self.iface, "up", self.oldInterfaceState)
1039 iNetwork.deactivateInterface(self.iface)
1042 def closeInfo(self):
1043 self["shortcuts"].setEnabled(True)
1044 self["infoshortcuts"].setEnabled(False)
1045 self["InfoText"].hide()
1046 self["InfoTextBorder"].hide()
1047 self["ButtonRedtext"].setText(_("Close"))
1051 del self.nextStepTimer
1053 def nextStepTimerFire(self):
1054 self.nextStepTimer.stop()
1055 self.steptimer = False
1058 def updownhandler(self,direction):
1059 if direction == 'up':
1060 if self.activebutton >=2:
1061 self.activebutton -= 1
1063 self.activebutton = 6
1064 self.setActiveButton(self.activebutton)
1065 if direction == 'down':
1066 if self.activebutton <=5:
1067 self.activebutton += 1
1069 self.activebutton = 1
1070 self.setActiveButton(self.activebutton)
1072 def setActiveButton(self,button):
1074 self["EditSettingsButton"].setPixmapNum(0)
1075 self["EditSettings_Text"].setForegroundColorNum(0)
1076 self["NetworkInfo"].setPixmapNum(0)
1077 self["NetworkInfo_Text"].setForegroundColorNum(1)
1078 self["AdapterInfo"].setPixmapNum(1) # active
1079 self["AdapterInfo_Text"].setForegroundColorNum(2) # active
1081 self["AdapterInfo_Text"].setForegroundColorNum(1)
1082 self["AdapterInfo"].setPixmapNum(0)
1083 self["DhcpInfo"].setPixmapNum(0)
1084 self["DhcpInfo_Text"].setForegroundColorNum(1)
1085 self["NetworkInfo"].setPixmapNum(1) # active
1086 self["NetworkInfo_Text"].setForegroundColorNum(2) # active
1088 self["NetworkInfo"].setPixmapNum(0)
1089 self["NetworkInfo_Text"].setForegroundColorNum(1)
1090 self["IPInfo"].setPixmapNum(0)
1091 self["IPInfo_Text"].setForegroundColorNum(1)
1092 self["DhcpInfo"].setPixmapNum(1) # active
1093 self["DhcpInfo_Text"].setForegroundColorNum(2) # active
1095 self["DhcpInfo"].setPixmapNum(0)
1096 self["DhcpInfo_Text"].setForegroundColorNum(1)
1097 self["DNSInfo"].setPixmapNum(0)
1098 self["DNSInfo_Text"].setForegroundColorNum(1)
1099 self["IPInfo"].setPixmapNum(1) # active
1100 self["IPInfo_Text"].setForegroundColorNum(2) # active
1102 self["IPInfo"].setPixmapNum(0)
1103 self["IPInfo_Text"].setForegroundColorNum(1)
1104 self["EditSettingsButton"].setPixmapNum(0)
1105 self["EditSettings_Text"].setForegroundColorNum(0)
1106 self["DNSInfo"].setPixmapNum(1) # active
1107 self["DNSInfo_Text"].setForegroundColorNum(2) # active
1109 self["DNSInfo"].setPixmapNum(0)
1110 self["DNSInfo_Text"].setForegroundColorNum(1)
1111 self["EditSettingsButton"].setPixmapNum(1) # active
1112 self["EditSettings_Text"].setForegroundColorNum(2) # active
1113 self["AdapterInfo"].setPixmapNum(0)
1114 self["AdapterInfo_Text"].setForegroundColorNum(1)
1117 next = self.nextstep
1133 self.steptimer = True
1134 self.nextStepTimer.start(3000)
1135 self["ButtonYellow_Check"].show()
1136 self["ButtonYellowtext"].show()
1139 self["Adapter"].setText(iNetwork.getFriendlyAdapterName(self.iface))
1140 self["Adapter"].setForegroundColorNum(2)
1141 self["Adaptertext"].setForegroundColorNum(1)
1142 self["AdapterInfo_Text"].setForegroundColorNum(1)
1143 self["AdapterInfo_OK"].show()
1144 self.steptimer = True
1145 self.nextStepTimer.start(3000)
1148 self["Networktext"].setForegroundColorNum(1)
1149 self["Network"].setText(_("Please wait..."))
1150 self.getLinkState(self.iface)
1151 self["NetworkInfo_Text"].setForegroundColorNum(1)
1152 self.steptimer = True
1153 self.nextStepTimer.start(3000)
1156 self["Dhcptext"].setForegroundColorNum(1)
1157 if iNetwork.getAdapterAttribute(self.iface, 'dhcp') is True:
1158 self["Dhcp"].setForegroundColorNum(2)
1159 self["Dhcp"].setText(_("enabled"))
1160 self["DhcpInfo_Check"].setPixmapNum(0)
1162 self["Dhcp"].setForegroundColorNum(1)
1163 self["Dhcp"].setText(_("disabled"))
1164 self["DhcpInfo_Check"].setPixmapNum(1)
1165 self["DhcpInfo_Check"].show()
1166 self["DhcpInfo_Text"].setForegroundColorNum(1)
1167 self.steptimer = True
1168 self.nextStepTimer.start(3000)
1171 self["IPtext"].setForegroundColorNum(1)
1172 self["IP"].setText(_("Please wait..."))
1173 iNetwork.checkNetworkState(self.NetworkStatedataAvail)
1176 self.steptimer = False
1177 self.nextStepTimer.stop()
1178 self["DNStext"].setForegroundColorNum(1)
1179 self["DNS"].setText(_("Please wait..."))
1180 iNetwork.checkDNSLookup(self.DNSLookupdataAvail)
1183 self["shortcutsgreen"].setEnabled(False)
1184 self["shortcutsyellow"].setEnabled(True)
1185 self["updown_actions"].setEnabled(False)
1186 self["ButtonYellow_Check"].setPixmapNum(0)
1187 self["ButtonGreen_Check"].setPixmapNum(1)
1188 self.steptimer = True
1189 self.nextStepTimer.start(1000)
1191 def KeyGreenRestart(self):
1193 self.layoutFinished()
1194 self["Adapter"].setText((""))
1195 self["Network"].setText((""))
1196 self["Dhcp"].setText((""))
1197 self["IP"].setText((""))
1198 self["DNS"].setText((""))
1199 self["AdapterInfo_Text"].setForegroundColorNum(0)
1200 self["NetworkInfo_Text"].setForegroundColorNum(0)
1201 self["DhcpInfo_Text"].setForegroundColorNum(0)
1202 self["IPInfo_Text"].setForegroundColorNum(0)
1203 self["DNSInfo_Text"].setForegroundColorNum(0)
1204 self["shortcutsgreen_restart"].setEnabled(False)
1205 self["shortcutsgreen"].setEnabled(False)
1206 self["shortcutsyellow"].setEnabled(True)
1207 self["updown_actions"].setEnabled(False)
1208 self["ButtonYellow_Check"].setPixmapNum(0)
1209 self["ButtonGreen_Check"].setPixmapNum(1)
1210 self.steptimer = True
1211 self.nextStepTimer.start(1000)
1214 self["infoshortcuts"].setEnabled(True)
1215 self["shortcuts"].setEnabled(False)
1216 if self.activebutton == 1: # Adapter Check
1217 self["InfoText"].setText(_("This test detects your configured LAN-Adapter."))
1218 self["InfoTextBorder"].show()
1219 self["InfoText"].show()
1220 self["ButtonRedtext"].setText(_("Back"))
1221 if self.activebutton == 2: #LAN Check
1222 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"))
1223 self["InfoTextBorder"].show()
1224 self["InfoText"].show()
1225 self["ButtonRedtext"].setText(_("Back"))
1226 if self.activebutton == 3: #DHCP Check
1227 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."))
1228 self["InfoTextBorder"].show()
1229 self["InfoText"].show()
1230 self["ButtonRedtext"].setText(_("Back"))
1231 if self.activebutton == 4: # IP Check
1232 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"))
1233 self["InfoTextBorder"].show()
1234 self["InfoText"].show()
1235 self["ButtonRedtext"].setText(_("Back"))
1236 if self.activebutton == 5: # DNS Check
1237 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"))
1238 self["InfoTextBorder"].show()
1239 self["InfoText"].show()
1240 self["ButtonRedtext"].setText(_("Back"))
1241 if self.activebutton == 6: # Edit Settings
1242 self.session.open(AdapterSetup,self.iface)
1244 def KeyYellow(self):
1246 self["shortcutsgreen_restart"].setEnabled(True)
1247 self["shortcutsgreen"].setEnabled(False)
1248 self["shortcutsyellow"].setEnabled(False)
1249 self["ButtonGreentext"].setText(_("Restart test"))
1250 self["ButtonYellow_Check"].setPixmapNum(1)
1251 self["ButtonGreen_Check"].setPixmapNum(0)
1252 self.steptimer = False
1253 self.nextStepTimer.stop()
1255 def layoutFinished(self):
1256 self["shortcutsyellow"].setEnabled(False)
1257 self["AdapterInfo_OK"].hide()
1258 self["NetworkInfo_Check"].hide()
1259 self["DhcpInfo_Check"].hide()
1260 self["IPInfo_Check"].hide()
1261 self["DNSInfo_Check"].hide()
1262 self["EditSettings_Text"].hide()
1263 self["EditSettingsButton"].hide()
1264 self["InfoText"].hide()
1265 self["InfoTextBorder"].hide()
1266 self["ButtonYellow_Check"].hide()
1267 self["ButtonYellowtext"].hide()
1269 def setLabels(self):
1270 self["Adaptertext"] = MultiColorLabel(_("LAN Adapter"))
1271 self["Adapter"] = MultiColorLabel()
1272 self["AdapterInfo"] = MultiPixmap()
1273 self["AdapterInfo_Text"] = MultiColorLabel(_("Show Info"))
1274 self["AdapterInfo_OK"] = Pixmap()
1276 if self.iface == 'wlan0' or self.iface == 'ath0':
1277 self["Networktext"] = MultiColorLabel(_("Wireless Network"))
1279 self["Networktext"] = MultiColorLabel(_("Local Network"))
1281 self["Network"] = MultiColorLabel()
1282 self["NetworkInfo"] = MultiPixmap()
1283 self["NetworkInfo_Text"] = MultiColorLabel(_("Show Info"))
1284 self["NetworkInfo_Check"] = MultiPixmap()
1286 self["Dhcptext"] = MultiColorLabel(_("DHCP"))
1287 self["Dhcp"] = MultiColorLabel()
1288 self["DhcpInfo"] = MultiPixmap()
1289 self["DhcpInfo_Text"] = MultiColorLabel(_("Show Info"))
1290 self["DhcpInfo_Check"] = MultiPixmap()
1292 self["IPtext"] = MultiColorLabel(_("IP Address"))
1293 self["IP"] = MultiColorLabel()
1294 self["IPInfo"] = MultiPixmap()
1295 self["IPInfo_Text"] = MultiColorLabel(_("Show Info"))
1296 self["IPInfo_Check"] = MultiPixmap()
1298 self["DNStext"] = MultiColorLabel(_("Nameserver"))
1299 self["DNS"] = MultiColorLabel()
1300 self["DNSInfo"] = MultiPixmap()
1301 self["DNSInfo_Text"] = MultiColorLabel(_("Show Info"))
1302 self["DNSInfo_Check"] = MultiPixmap()
1304 self["EditSettings_Text"] = MultiColorLabel(_("Edit settings"))
1305 self["EditSettingsButton"] = MultiPixmap()
1307 self["ButtonRedtext"] = Label(_("Close"))
1308 self["ButtonRed"] = Pixmap()
1310 self["ButtonGreentext"] = Label(_("Start test"))
1311 self["ButtonGreen_Check"] = MultiPixmap()
1313 self["ButtonYellowtext"] = Label(_("Stop test"))
1314 self["ButtonYellow_Check"] = MultiPixmap()
1316 self["InfoTextBorder"] = Pixmap()
1317 self["InfoText"] = Label()
1319 def getLinkState(self,iface):
1320 if iface == 'wlan0' or iface == 'ath0':
1322 from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus,Status
1324 self["Network"].setForegroundColorNum(1)
1325 self["Network"].setText(_("disconnected"))
1326 self["NetworkInfo_Check"].setPixmapNum(1)
1327 self["NetworkInfo_Check"].show()
1329 iStatus.getDataForInterface(self.iface,self.getInfoCB)
1331 iNetwork.getLinkState(iface,self.LinkStatedataAvail)
1333 def LinkStatedataAvail(self,data):
1334 self.output = data.strip()
1335 result = self.output.split('\n')
1336 pattern = re_compile("Link detected: yes")
1338 if re_search(pattern, item):
1339 self["Network"].setForegroundColorNum(2)
1340 self["Network"].setText(_("connected"))
1341 self["NetworkInfo_Check"].setPixmapNum(0)
1343 self["Network"].setForegroundColorNum(1)
1344 self["Network"].setText(_("disconnected"))
1345 self["NetworkInfo_Check"].setPixmapNum(1)
1346 self["NetworkInfo_Check"].show()
1348 def NetworkStatedataAvail(self,data):
1350 self["IP"].setForegroundColorNum(2)
1351 self["IP"].setText(_("confirmed"))
1352 self["IPInfo_Check"].setPixmapNum(0)
1354 self["IP"].setForegroundColorNum(1)
1355 self["IP"].setText(_("unconfirmed"))
1356 self["IPInfo_Check"].setPixmapNum(1)
1357 self["IPInfo_Check"].show()
1358 self["IPInfo_Text"].setForegroundColorNum(1)
1359 self.steptimer = True
1360 self.nextStepTimer.start(3000)
1362 def DNSLookupdataAvail(self,data):
1364 self["DNS"].setForegroundColorNum(2)
1365 self["DNS"].setText(_("confirmed"))
1366 self["DNSInfo_Check"].setPixmapNum(0)
1368 self["DNS"].setForegroundColorNum(1)
1369 self["DNS"].setText(_("unconfirmed"))
1370 self["DNSInfo_Check"].setPixmapNum(1)
1371 self["DNSInfo_Check"].show()
1372 self["DNSInfo_Text"].setForegroundColorNum(1)
1373 self["EditSettings_Text"].show()
1374 self["EditSettingsButton"].setPixmapNum(1)
1375 self["EditSettings_Text"].setForegroundColorNum(2) # active
1376 self["EditSettingsButton"].show()
1377 self["ButtonYellow_Check"].setPixmapNum(1)
1378 self["ButtonGreentext"].setText(_("Restart test"))
1379 self["ButtonGreen_Check"].setPixmapNum(0)
1380 self["shortcutsgreen"].setEnabled(False)
1381 self["shortcutsgreen_restart"].setEnabled(True)
1382 self["shortcutsyellow"].setEnabled(False)
1383 self["updown_actions"].setEnabled(True)
1384 self.activebutton = 6
1386 def getInfoCB(self,data,status):
1387 if data is not None:
1389 if status is not None:
1390 if status[self.iface]["acesspoint"] == "No Connection" or status[self.iface]["acesspoint"] == "Not-Associated" or status[self.iface]["acesspoint"] == False:
1391 self["Network"].setForegroundColorNum(1)
1392 self["Network"].setText(_("disconnected"))
1393 self["NetworkInfo_Check"].setPixmapNum(1)
1394 self["NetworkInfo_Check"].show()
1396 self["Network"].setForegroundColorNum(2)
1397 self["Network"].setText(_("connected"))
1398 self["NetworkInfo_Check"].setPixmapNum(0)
1399 self["NetworkInfo_Check"].show()
1402 iNetwork.stopLinkStateConsole()
1403 iNetwork.stopDNSConsole()
1405 from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus,Status
1409 iStatus.stopWlanConsole()