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)
95 num_configured_if = len(iNetwork.getConfiguredAdapters())
96 if num_configured_if >= 2:
97 self["ButtonBlue"].show()
98 self["ButtonBluetext"].show()
99 self["DefaultInterfaceAction"].setEnabled(True)
101 self["ButtonBlue"].hide()
102 self["ButtonBluetext"].hide()
103 self["DefaultInterfaceAction"].setEnabled(False)
105 if num_configured_if < 2 and os_path.exists("/etc/default_gw"):
106 unlink("/etc/default_gw")
108 if os_path.exists("/etc/default_gw"):
109 fp = file('/etc/default_gw', 'r')
114 if len(self.adapters) == 0: # no interface available => display only eth0
115 self.list.append(InterfaceEntryComponent("eth0",iNetwork.getFriendlyAdapterName('eth0'),True,True ))
117 for x in self.adapters:
118 if x[1] == default_gw:
122 if iNetwork.getAdapterAttribute(x[1], 'up') is True:
126 self.list.append(InterfaceEntryComponent(index = x[1],name = _(x[0]),default=default_int,active=active_int ))
127 self["list"].l.setList(self.list)
129 def setDefaultInterface(self):
130 selection = self["list"].getCurrent()
131 num_if = len(self.list)
132 old_default_gw = None
133 num_configured_if = len(iNetwork.getConfiguredAdapters())
134 if os_path.exists("/etc/default_gw"):
135 fp = open('/etc/default_gw', 'r')
136 old_default_gw = fp.read()
138 if num_configured_if > 1 and (not old_default_gw or old_default_gw != selection[0]):
139 fp = open('/etc/default_gw', 'w+')
140 fp.write(selection[0])
143 elif old_default_gw and num_configured_if < 2:
144 unlink("/etc/default_gw")
147 def okbuttonClick(self):
148 selection = self["list"].getCurrent()
149 if selection is not None:
150 self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetupConfiguration, selection[0])
152 def AdapterSetupClosed(self, *ret):
153 if len(self.adapters) == 1:
158 def NetworkFallback(self):
159 if iNetwork.configuredNetworkAdapters.has_key('wlan0') is True:
160 self.session.openWithCallback(self.ErrorMessageClosed, MessageBox, self.wlan_errortext, type = MessageBox.TYPE_INFO,timeout = 10)
161 if iNetwork.configuredNetworkAdapters.has_key('ath0') is True:
162 self.session.openWithCallback(self.ErrorMessageClosed, MessageBox, self.wlan_errortext, type = MessageBox.TYPE_INFO,timeout = 10)
164 self.session.openWithCallback(self.ErrorMessageClosed, MessageBox, self.lan_errortext, type = MessageBox.TYPE_INFO,timeout = 10)
166 def ErrorMessageClosed(self, *ret):
167 if iNetwork.configuredNetworkAdapters.has_key('wlan0') is True:
168 self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetupConfiguration, 'wlan0')
169 elif iNetwork.configuredNetworkAdapters.has_key('ath0') is True:
170 self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetupConfiguration, 'ath0')
172 self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetupConfiguration, 'eth0')
175 iNetwork.stopLinkStateConsole()
176 iNetwork.stopRestartConsole()
178 def restartLan(self):
179 iNetwork.restartNetwork(self.restartLanDataAvail)
180 self.restartLanRef = self.session.openWithCallback(self.restartfinishedCB, MessageBox, _("Please wait while we configure your network..."), type = MessageBox.TYPE_INFO, enable_input = False)
182 def restartLanDataAvail(self, data):
184 iNetwork.getInterfaces(self.getInterfacesDataAvail)
186 def getInterfacesDataAvail(self, data):
188 self.restartLanRef.close(True)
190 def restartfinishedCB(self,data):
193 self.session.open(MessageBox, _("Finished configuring your network"), type = MessageBox.TYPE_INFO, timeout = 10, default = False)
196 class NameserverSetup(Screen, ConfigListScreen, HelpableScreen):
197 def __init__(self, session):
198 Screen.__init__(self, session)
199 HelpableScreen.__init__(self)
200 self.backupNameserverList = iNetwork.getNameserverList()[:]
201 print "backup-list:", self.backupNameserverList
203 self["ButtonGreentext"] = Label(_("Add"))
204 self["ButtonYellowtext"] = Label(_("Delete"))
205 self["ButtonRedtext"] = Label(_("Close"))
206 self["introduction"] = Label(_("Press OK to activate the settings."))
209 self["OkCancelActions"] = HelpableActionMap(self, "OkCancelActions",
211 "cancel": (self.cancel, _("exit nameserver configuration")),
212 "ok": (self.ok, _("activate current configuration")),
215 self["ColorActions"] = HelpableActionMap(self, "ColorActions",
217 "red": (self.cancel, _("exit nameserver configuration")),
218 "green": (self.add, _("add a nameserver entry")),
219 "yellow": (self.remove, _("remove a nameserver entry")),
224 ConfigListScreen.__init__(self, self.list)
227 def createConfig(self):
228 self.nameservers = iNetwork.getNameserverList()
229 self.nameserverEntries = []
231 for nameserver in self.nameservers:
232 self.nameserverEntries.append(NoSave(ConfigIP(default=nameserver)))
234 def createSetup(self):
237 for i in range(len(self.nameserverEntries)):
238 self.list.append(getConfigListEntry(_("Nameserver %d") % (i + 1), self.nameserverEntries[i]))
240 self["config"].list = self.list
241 self["config"].l.setList(self.list)
244 iNetwork.clearNameservers()
245 for nameserver in self.nameserverEntries:
246 iNetwork.addNameserver(nameserver.value)
247 iNetwork.writeNameserverConfig()
254 iNetwork.clearNameservers()
255 print "backup-list:", self.backupNameserverList
256 for nameserver in self.backupNameserverList:
257 iNetwork.addNameserver(nameserver)
261 iNetwork.addNameserver([0,0,0,0])
266 print "currentIndex:", self["config"].getCurrentIndex()
268 index = self["config"].getCurrentIndex()
269 if index < len(self.nameservers):
270 iNetwork.removeNameserver(self.nameservers[index])
274 class AdapterSetup(Screen, ConfigListScreen, HelpableScreen):
275 def __init__(self, session, networkinfo, essid=None, aplist=None):
276 Screen.__init__(self, session)
277 HelpableScreen.__init__(self)
278 self.session = session
279 if isinstance(networkinfo, (list, tuple)):
280 self.iface = networkinfo[0]
281 self.essid = networkinfo[1]
282 self.aplist = networkinfo[2]
284 self.iface = networkinfo
288 self.applyConfigRef = None
289 self.finished_cb = None
290 self.oktext = _("Press OK on your remote control to continue.")
291 self.oldInterfaceState = iNetwork.getAdapterAttribute(self.iface, "up")
295 self["OkCancelActions"] = HelpableActionMap(self, "OkCancelActions",
297 "cancel": (self.cancel, _("exit network adapter setup menu")),
298 "ok": (self.ok, _("select menu entry")),
301 self["ColorActions"] = HelpableActionMap(self, "ColorActions",
303 "red": (self.cancel, _("exit network adapter configuration")),
304 "blue": (self.KeyBlue, _("open nameserver configuration")),
307 self["VirtualKB"] = HelpableActionMap(self, "ColorActions",
309 "green": (self.KeyGreen, [_("open virtual keyboard input help"),_("* Only available when entering hidden SSID or network key")] ),
312 self["actions"] = NumberActionMap(["SetupActions"],
319 ConfigListScreen.__init__(self, self.list,session = self.session)
321 self.onLayoutFinish.append(self.layoutFinished)
322 self.onClose.append(self.cleanup)
324 self["DNS1text"] = Label(_("Primary DNS"))
325 self["DNS2text"] = Label(_("Secondary DNS"))
326 self["DNS1"] = Label()
327 self["DNS2"] = Label()
329 self["introduction"] = Label(_("Current settings:"))
331 self["IPtext"] = Label(_("IP Address"))
332 self["Netmasktext"] = Label(_("Netmask"))
333 self["Gatewaytext"] = Label(_("Gateway"))
336 self["Mask"] = Label()
337 self["Gateway"] = Label()
339 self["BottomBG"] = Pixmap()
340 self["Adaptertext"] = Label(_("Network:"))
341 self["Adapter"] = Label()
342 self["introduction2"] = Label(_("Press OK to activate the settings."))
343 self["ButtonRed"] = Pixmap()
344 self["ButtonRedtext"] = Label(_("Close"))
345 self["ButtonBlue"] = Pixmap()
346 self["ButtonBluetext"] = Label(_("Edit DNS"))
347 self["ButtonGreen"] = Pixmap()
348 self["VKeyIcon"] = Pixmap()
349 self["HelpWindow"] = Pixmap()
351 def layoutFinished(self):
352 self["DNS1"].setText(self.primaryDNS.getText())
353 self["DNS2"].setText(self.secondaryDNS.getText())
354 if self.ipConfigEntry.getText() is not None:
355 if self.ipConfigEntry.getText() == "0.0.0.0":
356 self["IP"].setText(_("N/A"))
358 self["IP"].setText(self.ipConfigEntry.getText())
360 self["IP"].setText(_("N/A"))
361 if self.netmaskConfigEntry.getText() is not None:
362 if self.netmaskConfigEntry.getText() == "0.0.0.0":
363 self["Mask"].setText(_("N/A"))
365 self["Mask"].setText(self.netmaskConfigEntry.getText())
367 self["IP"].setText(_("N/A"))
368 if iNetwork.getAdapterAttribute(self.iface, "gateway"):
369 if self.gatewayConfigEntry.getText() == "0.0.0.0":
370 self["Gateway"].setText(_("N/A"))
372 self["Gateway"].setText(self.gatewayConfigEntry.getText())
374 self["Gateway"].hide()
375 self["Gatewaytext"].hide()
376 self["Adapter"].setText(iNetwork.getFriendlyAdapterName(self.iface))
377 self["ButtonGreen"].hide()
378 self["VKeyIcon"].hide()
379 self["VirtualKB"].setEnabled(False)
380 self["HelpWindow"].hide()
382 def createConfig(self):
383 self.InterfaceEntry = None
384 self.dhcpEntry = None
385 self.gatewayEntry = None
386 self.hiddenSSID = None
388 self.encryptionEnabled = None
389 self.encryptionKey = None
390 self.encryptionType = None
392 self.encryptionlist = None
397 if self.iface == "wlan0" or self.iface == "ath0" :
398 from Plugins.SystemPlugins.WirelessLan.Wlan import wpaSupplicant,Wlan
399 self.w = Wlan(self.iface)
400 self.ws = wpaSupplicant()
401 self.encryptionlist = []
402 self.encryptionlist.append(("WEP", _("WEP")))
403 self.encryptionlist.append(("WPA", _("WPA")))
404 self.encryptionlist.append(("WPA2", _("WPA2")))
405 self.encryptionlist.append(("WPA/WPA2", _("WPA or WPA2")))
407 self.weplist.append("ASCII")
408 self.weplist.append("HEX")
409 if self.aplist is not None:
410 self.nwlist = self.aplist
411 self.nwlist.sort(key = lambda x: x[0])
416 self.aps = self.w.getNetworkList()
417 if self.aps is not None:
418 print "[NetworkSetup.py] got Accespoints!"
423 a['essid'] = a['bssid']
424 self.nwlist.append( a['essid'])
425 self.nwlist.sort(key = lambda x: x[0])
427 self.nwlist.append("No Networks found")
429 self.wsconfig = self.ws.loadConfig()
430 if self.essid is not None: # ssid from wlan scan
431 self.default = self.essid
433 self.default = self.wsconfig['ssid']
435 if "hidden..." not in self.nwlist:
436 self.nwlist.append("hidden...")
437 if self.default not in self.nwlist:
438 self.nwlist.append(self.default)
440 config.plugins.wlan.essid = NoSave(ConfigSelection(self.nwlist, default = self.default ))
441 config.plugins.wlan.hiddenessid = NoSave(ConfigText(default = self.wsconfig['hiddenessid'], visible_width = 50, fixed_size = False))
443 config.plugins.wlan.encryption.enabled = NoSave(ConfigYesNo(default = self.wsconfig['encryption'] ))
444 config.plugins.wlan.encryption.type = NoSave(ConfigSelection(self.encryptionlist, default = self.wsconfig['encryption_type'] ))
445 config.plugins.wlan.encryption.wepkeytype = NoSave(ConfigSelection(self.weplist, default = self.wsconfig['encryption_wepkeytype'] ))
446 config.plugins.wlan.encryption.psk = NoSave(ConfigPassword(default = self.wsconfig['key'], visible_width = 50, fixed_size = False))
448 self.activateInterfaceEntry = NoSave(ConfigYesNo(default=iNetwork.getAdapterAttribute(self.iface, "up") or False))
449 self.dhcpConfigEntry = NoSave(ConfigYesNo(default=iNetwork.getAdapterAttribute(self.iface, "dhcp") or False))
450 self.ipConfigEntry = NoSave(ConfigIP(default=iNetwork.getAdapterAttribute(self.iface, "ip")) or [0,0,0,0])
451 self.netmaskConfigEntry = NoSave(ConfigIP(default=iNetwork.getAdapterAttribute(self.iface, "netmask") or [255,0,0,0]))
452 if iNetwork.getAdapterAttribute(self.iface, "gateway"):
453 self.dhcpdefault=True
455 self.dhcpdefault=False
456 self.hasGatewayConfigEntry = NoSave(ConfigYesNo(default=self.dhcpdefault or False))
457 self.gatewayConfigEntry = NoSave(ConfigIP(default=iNetwork.getAdapterAttribute(self.iface, "gateway") or [0,0,0,0]))
458 nameserver = (iNetwork.getNameserverList() + [[0,0,0,0]] * 2)[0:2]
459 self.primaryDNS = NoSave(ConfigIP(default=nameserver[0]))
460 self.secondaryDNS = NoSave(ConfigIP(default=nameserver[1]))
462 def createSetup(self):
464 self.InterfaceEntry = getConfigListEntry(_("Use Interface"), self.activateInterfaceEntry)
466 self.list.append(self.InterfaceEntry)
467 if self.activateInterfaceEntry.value:
468 self.dhcpEntry = getConfigListEntry(_("Use DHCP"), self.dhcpConfigEntry)
469 self.list.append(self.dhcpEntry)
470 if not self.dhcpConfigEntry.value:
471 self.list.append(getConfigListEntry(_('IP Address'), self.ipConfigEntry))
472 self.list.append(getConfigListEntry(_('Netmask'), self.netmaskConfigEntry))
473 self.gatewayEntry = getConfigListEntry(_('Use a gateway'), self.hasGatewayConfigEntry)
474 self.list.append(self.gatewayEntry)
475 if self.hasGatewayConfigEntry.value:
476 self.list.append(getConfigListEntry(_('Gateway'), self.gatewayConfigEntry))
479 for p in plugins.getPlugins(PluginDescriptor.WHERE_NETWORKSETUP):
480 callFnc = p.__call__["ifaceSupported"](self.iface)
481 if callFnc is not None:
482 if p.__call__.has_key("WlanPluginEntry"): # internally used only for WLAN Plugin
483 self.extended = callFnc
484 if p.__call__.has_key("configStrings"):
485 self.configStrings = p.__call__["configStrings"]
487 self.configStrings = None
488 if config.plugins.wlan.essid.value == 'hidden...':
489 self.wlanSSID = getConfigListEntry(_("Network SSID"), config.plugins.wlan.essid)
490 self.list.append(self.wlanSSID)
491 self.hiddenSSID = getConfigListEntry(_("Hidden network SSID"), config.plugins.wlan.hiddenessid)
492 self.list.append(self.hiddenSSID)
494 self.wlanSSID = getConfigListEntry(_("Network SSID"), config.plugins.wlan.essid)
495 self.list.append(self.wlanSSID)
496 self.encryptionEnabled = getConfigListEntry(_("Encryption"), config.plugins.wlan.encryption.enabled)
497 self.list.append(self.encryptionEnabled)
499 if config.plugins.wlan.encryption.enabled.value:
500 self.encryptionType = getConfigListEntry(_("Encryption Type"), config.plugins.wlan.encryption.type)
501 self.list.append(self.encryptionType)
502 if config.plugins.wlan.encryption.type.value == 'WEP':
503 self.list.append(getConfigListEntry(_("Encryption Keytype"), config.plugins.wlan.encryption.wepkeytype))
504 self.encryptionKey = getConfigListEntry(_("Encryption Key"), config.plugins.wlan.encryption.psk)
505 self.list.append(self.encryptionKey)
507 self.encryptionKey = getConfigListEntry(_("Encryption Key"), config.plugins.wlan.encryption.psk)
508 self.list.append(self.encryptionKey)
511 self["config"].list = self.list
512 self["config"].l.setList(self.list)
513 if not self.selectionChanged in self["config"].onSelectionChanged:
514 self["config"].onSelectionChanged.append(self.selectionChanged)
517 self.session.openWithCallback(self.NameserverSetupClosed, NameserverSetup)
520 if self.iface == "wlan0" or self.iface == "ath0" :
521 if self["config"].getCurrent() == self.hiddenSSID:
522 if config.plugins.wlan.essid.value == 'hidden...':
523 self.session.openWithCallback(self.VirtualKeyBoardSSIDCallback, VirtualKeyBoard, title = (_("Enter WLAN network name/SSID:")), text = config.plugins.wlan.essid.value)
524 if self["config"].getCurrent() == self.encryptionKey:
525 self.session.openWithCallback(self.VirtualKeyBoardKeyCallback, VirtualKeyBoard, title = (_("Enter WLAN passphrase/key:")), text = config.plugins.wlan.encryption.psk.value)
527 def VirtualKeyBoardSSIDCallback(self, callback = None):
528 if callback is not None and len(callback):
529 config.plugins.wlan.hiddenessid = NoSave(ConfigText(default = callback, visible_width = 50, fixed_size = False))
532 def VirtualKeyBoardKeyCallback(self, callback = None):
533 if callback is not None and len(callback):
534 config.plugins.wlan.encryption.psk = NoSave(ConfigPassword(default = callback, visible_width = 50, fixed_size = False))
538 if self["config"].getCurrent() == self.InterfaceEntry:
540 if self["config"].getCurrent() == self.dhcpEntry:
542 if self["config"].getCurrent() == self.gatewayEntry:
544 if self.iface == "wlan0" or self.iface == "ath0" :
545 if self["config"].getCurrent() == self.wlanSSID:
547 if self["config"].getCurrent() == self.encryptionEnabled:
549 if self["config"].getCurrent() == self.encryptionType:
552 ConfigListScreen.keyLeft(self)
556 ConfigListScreen.keyRight(self)
559 def selectionChanged(self):
560 current = self["config"].getCurrent()
561 if current == self.hiddenSSID and config.plugins.wlan.essid.value == 'hidden...':
562 helpwindowpos = self["HelpWindow"].getPosition()
563 if current[1].help_window.instance is not None:
564 current[1].help_window.instance.move(ePoint(helpwindowpos[0],helpwindowpos[1]))
565 self["ButtonGreen"].show()
566 self["VKeyIcon"].show()
567 self["VirtualKB"].setEnabled(True)
568 elif current == self.encryptionKey and config.plugins.wlan.encryption.enabled.value:
569 helpwindowpos = self["HelpWindow"].getPosition()
570 if current[1].help_window.instance is not None:
571 current[1].help_window.instance.move(ePoint(helpwindowpos[0],helpwindowpos[1]))
572 self["ButtonGreen"].show()
573 self["VKeyIcon"].show()
574 self["VirtualKB"].setEnabled(True)
576 self["ButtonGreen"].hide()
577 self["VKeyIcon"].hide()
578 self["VirtualKB"].setEnabled(False)
581 current = self["config"].getCurrent()
582 if current == self.hiddenSSID and config.plugins.wlan.essid.value == 'hidden...':
583 if current[1].help_window.instance is not None:
584 current[1].help_window.instance.hide()
585 elif current == self.encryptionKey and config.plugins.wlan.encryption.enabled.value:
586 if current[1].help_window.instance is not None:
587 current[1].help_window.instance.hide()
588 self.session.openWithCallback(self.applyConfig, MessageBox, (_("Are you sure you want to activate this network configuration?\n\n") + self.oktext ) )
590 def applyConfig(self, ret = False):
592 iNetwork.setAdapterAttribute(self.iface, "up", self.activateInterfaceEntry.value)
593 iNetwork.setAdapterAttribute(self.iface, "dhcp", self.dhcpConfigEntry.value)
594 iNetwork.setAdapterAttribute(self.iface, "ip", self.ipConfigEntry.value)
595 iNetwork.setAdapterAttribute(self.iface, "netmask", self.netmaskConfigEntry.value)
596 if self.hasGatewayConfigEntry.value:
597 iNetwork.setAdapterAttribute(self.iface, "gateway", self.gatewayConfigEntry.value)
599 iNetwork.removeAdapterAttribute(self.iface, "gateway")
600 if self.extended is not None and self.configStrings is not None:
601 iNetwork.setAdapterAttribute(self.iface, "configStrings", self.configStrings(self.iface))
602 self.ws.writeConfig()
603 if self.activateInterfaceEntry.value is False:
604 iNetwork.deactivateInterface(self.iface)
605 iNetwork.writeNetworkConfig()
606 iNetwork.restartNetwork(self.applyConfigDataAvail)
607 self.applyConfigRef = self.session.openWithCallback(self.applyConfigfinishedCB, MessageBox, _("Please wait for activation of your network configuration..."), type = MessageBox.TYPE_INFO, enable_input = False)
611 def applyConfigDataAvail(self, data):
613 iNetwork.getInterfaces(self.getInterfacesDataAvail)
615 def getInterfacesDataAvail(self, data):
617 self.applyConfigRef.close(True)
619 def applyConfigfinishedCB(self,data):
621 num_configured_if = len(iNetwork.getConfiguredAdapters())
622 if num_configured_if >= 2:
623 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)
626 self.session.openWithCallback(lambda x : self.finished_cb(), MessageBox, _("Your network configuration has been activated."), type = MessageBox.TYPE_INFO, timeout = 10)
628 self.session.openWithCallback(self.ConfigfinishedCB, MessageBox, _("Your network configuration has been activated."), type = MessageBox.TYPE_INFO, timeout = 10)
630 def secondIfaceFoundCB(self,data):
634 configuredInterfaces = iNetwork.getConfiguredAdapters()
635 for interface in configuredInterfaces:
636 if interface == self.iface:
638 iNetwork.setAdapterAttribute(interface, "up", False)
639 iNetwork.deactivateInterface(interface)
640 self.applyConfig(True)
642 def ConfigfinishedCB(self,data):
648 if self.oldInterfaceState is False:
649 iNetwork.deactivateInterface(self.iface,self.deactivateInterfaceCB)
653 def deactivateInterfaceCB(self,data):
656 iNetwork.getInterfaces(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()