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")),
222 self["actions"] = NumberActionMap(["SetupActions"],
228 ConfigListScreen.__init__(self, self.list)
231 def createConfig(self):
232 self.nameservers = iNetwork.getNameserverList()
233 self.nameserverEntries = []
235 for nameserver in self.nameservers:
236 self.nameserverEntries.append(NoSave(ConfigIP(default=nameserver)))
238 def createSetup(self):
241 for i in range(len(self.nameserverEntries)):
242 self.list.append(getConfigListEntry(_("Nameserver %d") % (i + 1), self.nameserverEntries[i]))
244 self["config"].list = self.list
245 self["config"].l.setList(self.list)
248 iNetwork.clearNameservers()
249 for nameserver in self.nameserverEntries:
250 iNetwork.addNameserver(nameserver.value)
251 iNetwork.writeNameserverConfig()
258 iNetwork.clearNameservers()
259 print "backup-list:", self.backupNameserverList
260 for nameserver in self.backupNameserverList:
261 iNetwork.addNameserver(nameserver)
265 iNetwork.addNameserver([0,0,0,0])
270 print "currentIndex:", self["config"].getCurrentIndex()
272 index = self["config"].getCurrentIndex()
273 if index < len(self.nameservers):
274 iNetwork.removeNameserver(self.nameservers[index])
278 class AdapterSetup(Screen, ConfigListScreen, HelpableScreen):
279 def __init__(self, session, networkinfo, essid=None, aplist=None):
280 Screen.__init__(self, session)
281 HelpableScreen.__init__(self)
282 self.session = session
283 if isinstance(networkinfo, (list, tuple)):
284 self.iface = networkinfo[0]
285 self.essid = networkinfo[1]
286 self.aplist = networkinfo[2]
288 self.iface = networkinfo
292 self.applyConfigRef = None
293 self.finished_cb = None
294 self.oktext = _("Press OK on your remote control to continue.")
295 self.oldInterfaceState = iNetwork.getAdapterAttribute(self.iface, "up")
299 self["OkCancelActions"] = HelpableActionMap(self, "OkCancelActions",
301 "cancel": (self.cancel, _("exit network adapter setup menu")),
302 "ok": (self.ok, _("select menu entry")),
305 self["ColorActions"] = HelpableActionMap(self, "ColorActions",
307 "red": (self.cancel, _("exit network adapter configuration")),
308 "blue": (self.KeyBlue, _("open nameserver configuration")),
311 self["VirtualKB"] = HelpableActionMap(self, "ColorActions",
313 "green": (self.KeyGreen, [_("open virtual keyboard input help"),_("* Only available when entering hidden SSID or network key")] ),
316 self["actions"] = NumberActionMap(["SetupActions"],
323 ConfigListScreen.__init__(self, self.list,session = self.session)
325 self.onLayoutFinish.append(self.layoutFinished)
326 self.onClose.append(self.cleanup)
328 self["DNS1text"] = Label(_("Primary DNS"))
329 self["DNS2text"] = Label(_("Secondary DNS"))
330 self["DNS1"] = Label()
331 self["DNS2"] = Label()
333 self["introduction"] = Label(_("Current settings:"))
335 self["IPtext"] = Label(_("IP Address"))
336 self["Netmasktext"] = Label(_("Netmask"))
337 self["Gatewaytext"] = Label(_("Gateway"))
340 self["Mask"] = Label()
341 self["Gateway"] = Label()
343 self["BottomBG"] = Pixmap()
344 self["Adaptertext"] = Label(_("Network:"))
345 self["Adapter"] = Label()
346 self["introduction2"] = Label(_("Press OK to activate the settings."))
347 self["ButtonRed"] = Pixmap()
348 self["ButtonRedtext"] = Label(_("Close"))
349 self["ButtonBlue"] = Pixmap()
350 self["ButtonBluetext"] = Label(_("Edit DNS"))
351 self["ButtonGreen"] = Pixmap()
352 self["VKeyIcon"] = Pixmap()
353 self["HelpWindow"] = Pixmap()
355 def layoutFinished(self):
356 self["DNS1"].setText(self.primaryDNS.getText())
357 self["DNS2"].setText(self.secondaryDNS.getText())
358 if self.ipConfigEntry.getText() is not None:
359 if self.ipConfigEntry.getText() == "0.0.0.0":
360 self["IP"].setText(_("N/A"))
362 self["IP"].setText(self.ipConfigEntry.getText())
364 self["IP"].setText(_("N/A"))
365 if self.netmaskConfigEntry.getText() is not None:
366 if self.netmaskConfigEntry.getText() == "0.0.0.0":
367 self["Mask"].setText(_("N/A"))
369 self["Mask"].setText(self.netmaskConfigEntry.getText())
371 self["IP"].setText(_("N/A"))
372 if iNetwork.getAdapterAttribute(self.iface, "gateway"):
373 if self.gatewayConfigEntry.getText() == "0.0.0.0":
374 self["Gateway"].setText(_("N/A"))
376 self["Gateway"].setText(self.gatewayConfigEntry.getText())
378 self["Gateway"].hide()
379 self["Gatewaytext"].hide()
380 self["Adapter"].setText(iNetwork.getFriendlyAdapterName(self.iface))
381 self["ButtonGreen"].hide()
382 self["VKeyIcon"].hide()
383 self["VirtualKB"].setEnabled(False)
384 self["HelpWindow"].hide()
386 def createConfig(self):
387 self.InterfaceEntry = None
388 self.dhcpEntry = None
389 self.gatewayEntry = None
390 self.hiddenSSID = None
392 self.encryptionEnabled = None
393 self.encryptionKey = None
394 self.encryptionType = None
396 self.encryptionlist = None
401 if self.iface == "wlan0" or self.iface == "ath0" :
402 from Plugins.SystemPlugins.WirelessLan.Wlan import wpaSupplicant,Wlan
403 self.w = Wlan(self.iface)
404 self.ws = wpaSupplicant()
405 self.encryptionlist = []
406 self.encryptionlist.append(("WEP", _("WEP")))
407 self.encryptionlist.append(("WPA", _("WPA")))
408 self.encryptionlist.append(("WPA2", _("WPA2")))
409 self.encryptionlist.append(("WPA/WPA2", _("WPA or WPA2")))
411 self.weplist.append("ASCII")
412 self.weplist.append("HEX")
413 if self.aplist is not None:
414 self.nwlist = self.aplist
415 self.nwlist.sort(key = lambda x: x[0])
420 self.aps = self.w.getNetworkList()
421 if self.aps is not None:
422 print "[NetworkSetup.py] got Accespoints!"
427 a['essid'] = a['bssid']
428 self.nwlist.append( a['essid'])
429 self.nwlist.sort(key = lambda x: x[0])
431 self.nwlist.append("No Networks found")
433 self.wsconfig = self.ws.loadConfig()
434 if self.essid is not None: # ssid from wlan scan
435 self.default = self.essid
437 self.default = self.wsconfig['ssid']
439 if "hidden..." not in self.nwlist:
440 self.nwlist.append("hidden...")
441 if self.default not in self.nwlist:
442 self.nwlist.append(self.default)
444 config.plugins.wlan.essid = NoSave(ConfigSelection(self.nwlist, default = self.default ))
445 config.plugins.wlan.hiddenessid = NoSave(ConfigText(default = self.wsconfig['hiddenessid'], visible_width = 50, fixed_size = False))
447 config.plugins.wlan.encryption.enabled = NoSave(ConfigYesNo(default = self.wsconfig['encryption'] ))
448 config.plugins.wlan.encryption.type = NoSave(ConfigSelection(self.encryptionlist, default = self.wsconfig['encryption_type'] ))
449 config.plugins.wlan.encryption.wepkeytype = NoSave(ConfigSelection(self.weplist, default = self.wsconfig['encryption_wepkeytype'] ))
450 config.plugins.wlan.encryption.psk = NoSave(ConfigPassword(default = self.wsconfig['key'], visible_width = 50, fixed_size = False))
452 self.activateInterfaceEntry = NoSave(ConfigYesNo(default=iNetwork.getAdapterAttribute(self.iface, "up") or False))
453 self.dhcpConfigEntry = NoSave(ConfigYesNo(default=iNetwork.getAdapterAttribute(self.iface, "dhcp") or False))
454 self.ipConfigEntry = NoSave(ConfigIP(default=iNetwork.getAdapterAttribute(self.iface, "ip")) or [0,0,0,0])
455 self.netmaskConfigEntry = NoSave(ConfigIP(default=iNetwork.getAdapterAttribute(self.iface, "netmask") or [255,0,0,0]))
456 if iNetwork.getAdapterAttribute(self.iface, "gateway"):
457 self.dhcpdefault=True
459 self.dhcpdefault=False
460 self.hasGatewayConfigEntry = NoSave(ConfigYesNo(default=self.dhcpdefault or False))
461 self.gatewayConfigEntry = NoSave(ConfigIP(default=iNetwork.getAdapterAttribute(self.iface, "gateway") or [0,0,0,0]))
462 nameserver = (iNetwork.getNameserverList() + [[0,0,0,0]] * 2)[0:2]
463 self.primaryDNS = NoSave(ConfigIP(default=nameserver[0]))
464 self.secondaryDNS = NoSave(ConfigIP(default=nameserver[1]))
466 def createSetup(self):
468 self.InterfaceEntry = getConfigListEntry(_("Use Interface"), self.activateInterfaceEntry)
470 self.list.append(self.InterfaceEntry)
471 if self.activateInterfaceEntry.value:
472 self.dhcpEntry = getConfigListEntry(_("Use DHCP"), self.dhcpConfigEntry)
473 self.list.append(self.dhcpEntry)
474 if not self.dhcpConfigEntry.value:
475 self.list.append(getConfigListEntry(_('IP Address'), self.ipConfigEntry))
476 self.list.append(getConfigListEntry(_('Netmask'), self.netmaskConfigEntry))
477 self.gatewayEntry = getConfigListEntry(_('Use a gateway'), self.hasGatewayConfigEntry)
478 self.list.append(self.gatewayEntry)
479 if self.hasGatewayConfigEntry.value:
480 self.list.append(getConfigListEntry(_('Gateway'), self.gatewayConfigEntry))
483 for p in plugins.getPlugins(PluginDescriptor.WHERE_NETWORKSETUP):
484 callFnc = p.__call__["ifaceSupported"](self.iface)
485 if callFnc is not None:
486 if p.__call__.has_key("WlanPluginEntry"): # internally used only for WLAN Plugin
487 self.extended = callFnc
488 if p.__call__.has_key("configStrings"):
489 self.configStrings = p.__call__["configStrings"]
491 self.configStrings = None
492 if config.plugins.wlan.essid.value == 'hidden...':
493 self.wlanSSID = getConfigListEntry(_("Network SSID"), config.plugins.wlan.essid)
494 self.list.append(self.wlanSSID)
495 self.hiddenSSID = getConfigListEntry(_("Hidden network SSID"), config.plugins.wlan.hiddenessid)
496 self.list.append(self.hiddenSSID)
498 self.wlanSSID = getConfigListEntry(_("Network SSID"), config.plugins.wlan.essid)
499 self.list.append(self.wlanSSID)
500 self.encryptionEnabled = getConfigListEntry(_("Encryption"), config.plugins.wlan.encryption.enabled)
501 self.list.append(self.encryptionEnabled)
503 if config.plugins.wlan.encryption.enabled.value:
504 self.encryptionType = getConfigListEntry(_("Encryption Type"), config.plugins.wlan.encryption.type)
505 self.list.append(self.encryptionType)
506 if config.plugins.wlan.encryption.type.value == 'WEP':
507 self.list.append(getConfigListEntry(_("Encryption Keytype"), config.plugins.wlan.encryption.wepkeytype))
508 self.encryptionKey = getConfigListEntry(_("Encryption Key"), config.plugins.wlan.encryption.psk)
509 self.list.append(self.encryptionKey)
511 self.encryptionKey = getConfigListEntry(_("Encryption Key"), config.plugins.wlan.encryption.psk)
512 self.list.append(self.encryptionKey)
515 self["config"].list = self.list
516 self["config"].l.setList(self.list)
517 if not self.selectionChanged in self["config"].onSelectionChanged:
518 self["config"].onSelectionChanged.append(self.selectionChanged)
521 self.session.openWithCallback(self.NameserverSetupClosed, NameserverSetup)
524 if self.iface == "wlan0" or self.iface == "ath0" :
525 if self["config"].getCurrent() == self.hiddenSSID:
526 if config.plugins.wlan.essid.value == 'hidden...':
527 self.session.openWithCallback(self.VirtualKeyBoardSSIDCallback, VirtualKeyBoard, title = (_("Enter WLAN network name/SSID:")), text = config.plugins.wlan.essid.value)
528 if self["config"].getCurrent() == self.encryptionKey:
529 self.session.openWithCallback(self.VirtualKeyBoardKeyCallback, VirtualKeyBoard, title = (_("Enter WLAN passphrase/key:")), text = config.plugins.wlan.encryption.psk.value)
531 def VirtualKeyBoardSSIDCallback(self, callback = None):
532 if callback is not None and len(callback):
533 config.plugins.wlan.hiddenessid = NoSave(ConfigText(default = callback, visible_width = 50, fixed_size = False))
536 def VirtualKeyBoardKeyCallback(self, callback = None):
537 if callback is not None and len(callback):
538 config.plugins.wlan.encryption.psk = NoSave(ConfigPassword(default = callback, visible_width = 50, fixed_size = False))
542 if self["config"].getCurrent() == self.InterfaceEntry:
544 if self["config"].getCurrent() == self.dhcpEntry:
546 if self["config"].getCurrent() == self.gatewayEntry:
548 if self.iface == "wlan0" or self.iface == "ath0" :
549 if self["config"].getCurrent() == self.wlanSSID:
551 if self["config"].getCurrent() == self.encryptionEnabled:
553 if self["config"].getCurrent() == self.encryptionType:
556 ConfigListScreen.keyLeft(self)
560 ConfigListScreen.keyRight(self)
563 def selectionChanged(self):
564 current = self["config"].getCurrent()
565 if current == self.hiddenSSID and config.plugins.wlan.essid.value == 'hidden...':
566 helpwindowpos = self["HelpWindow"].getPosition()
567 if current[1].help_window.instance is not None:
568 current[1].help_window.instance.move(ePoint(helpwindowpos[0],helpwindowpos[1]))
569 self["ButtonGreen"].show()
570 self["VKeyIcon"].show()
571 self["VirtualKB"].setEnabled(True)
572 elif current == self.encryptionKey and config.plugins.wlan.encryption.enabled.value:
573 helpwindowpos = self["HelpWindow"].getPosition()
574 if current[1].help_window.instance is not None:
575 current[1].help_window.instance.move(ePoint(helpwindowpos[0],helpwindowpos[1]))
576 self["ButtonGreen"].show()
577 self["VKeyIcon"].show()
578 self["VirtualKB"].setEnabled(True)
580 self["ButtonGreen"].hide()
581 self["VKeyIcon"].hide()
582 self["VirtualKB"].setEnabled(False)
585 current = self["config"].getCurrent()
586 if current == self.hiddenSSID and config.plugins.wlan.essid.value == 'hidden...':
587 if current[1].help_window.instance is not None:
588 current[1].help_window.instance.hide()
589 elif current == self.encryptionKey and config.plugins.wlan.encryption.enabled.value:
590 if current[1].help_window.instance is not None:
591 current[1].help_window.instance.hide()
592 self.session.openWithCallback(self.applyConfig, MessageBox, (_("Are you sure you want to activate this network configuration?\n\n") + self.oktext ) )
594 def applyConfig(self, ret = False):
596 iNetwork.setAdapterAttribute(self.iface, "up", self.activateInterfaceEntry.value)
597 iNetwork.setAdapterAttribute(self.iface, "dhcp", self.dhcpConfigEntry.value)
598 iNetwork.setAdapterAttribute(self.iface, "ip", self.ipConfigEntry.value)
599 iNetwork.setAdapterAttribute(self.iface, "netmask", self.netmaskConfigEntry.value)
600 if self.hasGatewayConfigEntry.value:
601 iNetwork.setAdapterAttribute(self.iface, "gateway", self.gatewayConfigEntry.value)
603 iNetwork.removeAdapterAttribute(self.iface, "gateway")
604 if self.extended is not None and self.configStrings is not None:
605 iNetwork.setAdapterAttribute(self.iface, "configStrings", self.configStrings(self.iface))
606 self.ws.writeConfig()
607 if self.activateInterfaceEntry.value is False:
608 iNetwork.deactivateInterface(self.iface)
609 iNetwork.writeNetworkConfig()
610 iNetwork.restartNetwork(self.applyConfigDataAvail)
611 self.applyConfigRef = self.session.openWithCallback(self.applyConfigfinishedCB, MessageBox, _("Please wait for activation of your network configuration..."), type = MessageBox.TYPE_INFO, enable_input = False)
615 def applyConfigDataAvail(self, data):
617 iNetwork.getInterfaces(self.getInterfacesDataAvail)
619 def getInterfacesDataAvail(self, data):
621 self.applyConfigRef.close(True)
623 def applyConfigfinishedCB(self,data):
625 num_configured_if = len(iNetwork.getConfiguredAdapters())
626 if num_configured_if >= 2:
627 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)
630 self.session.openWithCallback(lambda x : self.finished_cb(), MessageBox, _("Your network configuration has been activated."), type = MessageBox.TYPE_INFO, timeout = 10)
632 self.session.openWithCallback(self.ConfigfinishedCB, MessageBox, _("Your network configuration has been activated."), type = MessageBox.TYPE_INFO, timeout = 10)
634 def secondIfaceFoundCB(self,data):
638 configuredInterfaces = iNetwork.getConfiguredAdapters()
639 for interface in configuredInterfaces:
640 if interface == self.iface:
642 iNetwork.setAdapterAttribute(interface, "up", False)
643 iNetwork.deactivateInterface(interface)
644 self.applyConfig(True)
646 def ConfigfinishedCB(self,data):
652 if self.oldInterfaceState is False:
653 iNetwork.deactivateInterface(self.iface,self.deactivateInterfaceCB)
657 def deactivateInterfaceCB(self,data):
660 iNetwork.getInterfaces(self.cancelCB)
662 def cancelCB(self,data):
667 def runAsync(self, finished_cb):
668 self.finished_cb = finished_cb
671 def NameserverSetupClosed(self, *ret):
672 iNetwork.loadNameserverConfig()
673 nameserver = (iNetwork.getNameserverList() + [[0,0,0,0]] * 2)[0:2]
674 self.primaryDNS = NoSave(ConfigIP(default=nameserver[0]))
675 self.secondaryDNS = NoSave(ConfigIP(default=nameserver[1]))
677 self.layoutFinished()
680 iNetwork.stopLinkStateConsole()
683 class AdapterSetupConfiguration(Screen, HelpableScreen):
684 def __init__(self, session,iface):
685 Screen.__init__(self, session)
686 HelpableScreen.__init__(self)
687 self.session = session
689 self.restartLanRef = None
690 self.mainmenu = self.genMainMenu()
691 self["menulist"] = MenuList(self.mainmenu)
692 self["description"] = Label()
693 self["IFtext"] = Label()
695 self["BottomBG"] = Label()
696 self["Statustext"] = Label()
697 self["statuspic"] = MultiPixmap()
698 self["statuspic"].hide()
699 self["BottomBG"] = Pixmap()
700 self["ButtonRed"] = Pixmap()
701 self["ButtonRedtext"] = Label(_("Close"))
703 self.oktext = _("Press OK on your remote control to continue.")
704 self.reboottext = _("Your Dreambox will restart after pressing OK on your remote control.")
705 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.")
707 self["WizardActions"] = HelpableActionMap(self, "WizardActions",
709 "up": (self.up, _("move up to previous entry")),
710 "down": (self.down, _("move down to next entry")),
711 "left": (self.left, _("move up to first entry")),
712 "right": (self.right, _("move down to last entry")),
715 self["OkCancelActions"] = HelpableActionMap(self, "OkCancelActions",
717 "cancel": (self.close, _("exit networkadapter setup menu")),
718 "ok": (self.ok, _("select menu entry")),
721 self["ColorActions"] = HelpableActionMap(self, "ColorActions",
723 "red": (self.close, _("exit networkadapter setup menu")),
726 self["actions"] = NumberActionMap(["WizardActions","ShortcutActions"],
737 self.updateStatusbar()
738 self.onLayoutFinish.append(self.layoutFinished)
739 self.onClose.append(self.cleanup)
742 if self["menulist"].getCurrent()[1] == 'edit':
743 if self.iface == 'wlan0' or self.iface == 'ath0':
745 from Plugins.SystemPlugins.WirelessLan.plugin import WlanScan
746 from Plugins.SystemPlugins.WirelessLan.iwlibs import Wireless
748 self.session.open(MessageBox, _("The wireless LAN plugin is not installed!\nPlease install it."), type = MessageBox.TYPE_INFO,timeout = 10 )
750 ifobj = Wireless(self.iface) # a Wireless NIC Object
751 self.wlanresponse = ifobj.getStatistics()
752 if self.wlanresponse[0] != 19: # Wlan Interface found.
753 self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetup,self.iface)
755 # Display Wlan not available Message
756 self.showErrorMessage()
758 self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetup,self.iface)
759 if self["menulist"].getCurrent()[1] == 'test':
760 self.session.open(NetworkAdapterTest,self.iface)
761 if self["menulist"].getCurrent()[1] == 'dns':
762 self.session.open(NameserverSetup)
763 if self["menulist"].getCurrent()[1] == 'scanwlan':
765 from Plugins.SystemPlugins.WirelessLan.plugin import WlanScan
766 from Plugins.SystemPlugins.WirelessLan.iwlibs import Wireless
768 self.session.open(MessageBox, _("The wireless LAN plugin is not installed!\nPlease install it."), type = MessageBox.TYPE_INFO,timeout = 10 )
770 ifobj = Wireless(self.iface) # a Wireless NIC Object
771 self.wlanresponse = ifobj.getStatistics()
772 if self.wlanresponse[0] != 19:
773 self.session.openWithCallback(self.WlanScanClosed, WlanScan, self.iface)
775 # Display Wlan not available Message
776 self.showErrorMessage()
777 if self["menulist"].getCurrent()[1] == 'wlanstatus':
779 from Plugins.SystemPlugins.WirelessLan.plugin import WlanStatus
780 from Plugins.SystemPlugins.WirelessLan.iwlibs import Wireless
782 self.session.open(MessageBox, _("The wireless LAN plugin is not installed!\nPlease install it."), type = MessageBox.TYPE_INFO,timeout = 10 )
784 ifobj = Wireless(self.iface) # a Wireless NIC Object
785 self.wlanresponse = ifobj.getStatistics()
786 if self.wlanresponse[0] != 19:
787 self.session.openWithCallback(self.WlanStatusClosed, WlanStatus,self.iface)
789 # Display Wlan not available Message
790 self.showErrorMessage()
791 if self["menulist"].getCurrent()[1] == 'lanrestart':
792 self.session.openWithCallback(self.restartLan, MessageBox, (_("Are you sure you want to restart your network interfaces?\n\n") + self.oktext ) )
793 if self["menulist"].getCurrent()[1] == 'openwizard':
794 from Plugins.SystemPlugins.NetworkWizard.NetworkWizard import NetworkWizard
795 self.session.openWithCallback(self.AdapterSetupClosed, NetworkWizard)
796 if self["menulist"].getCurrent()[1][0] == 'extendedSetup':
797 self.extended = self["menulist"].getCurrent()[1][2]
798 self.extended(self.session, self.iface)
801 self["menulist"].up()
802 self.loadDescription()
805 self["menulist"].down()
806 self.loadDescription()
809 self["menulist"].pageUp()
810 self.loadDescription()
813 self["menulist"].pageDown()
814 self.loadDescription()
816 def layoutFinished(self):
818 self["menulist"].moveToIndex(idx)
819 self.loadDescription()
821 def loadDescription(self):
822 print self["menulist"].getCurrent()[1]
823 if self["menulist"].getCurrent()[1] == 'edit':
824 self["description"].setText(_("Edit the network configuration of your Dreambox.\n" ) + self.oktext )
825 if self["menulist"].getCurrent()[1] == 'test':
826 self["description"].setText(_("Test the network configuration of your Dreambox.\n" ) + self.oktext )
827 if self["menulist"].getCurrent()[1] == 'dns':
828 self["description"].setText(_("Edit the Nameserver configuration of your Dreambox.\n" ) + self.oktext )
829 if self["menulist"].getCurrent()[1] == 'scanwlan':
830 self["description"].setText(_("Scan your network for wireless Access Points and connect to them using your WLAN USB Stick\n" ) + self.oktext )
831 if self["menulist"].getCurrent()[1] == 'wlanstatus':
832 self["description"].setText(_("Shows the state of your wireless LAN connection.\n" ) + self.oktext )
833 if self["menulist"].getCurrent()[1] == 'lanrestart':
834 self["description"].setText(_("Restart your network connection and interfaces.\n" ) + self.oktext )
835 if self["menulist"].getCurrent()[1] == 'openwizard':
836 self["description"].setText(_("Use the Networkwizard to configure your Network\n" ) + self.oktext )
837 if self["menulist"].getCurrent()[1][0] == 'extendedSetup':
838 self["description"].setText(_(self["menulist"].getCurrent()[1][1]) + self.oktext )
840 def updateStatusbar(self, data = None):
841 self["IFtext"].setText(_("Network:"))
842 self["IF"].setText(iNetwork.getFriendlyAdapterName(self.iface))
843 self["Statustext"].setText(_("Link:"))
845 if self.iface == 'wlan0' or self.iface == 'ath0':
847 from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus,Status
849 self["statuspic"].setPixmapNum(1)
850 self["statuspic"].show()
852 iStatus.getDataForInterface(self.iface,self.getInfoCB)
854 iNetwork.getLinkState(self.iface,self.dataAvail)
859 def genMainMenu(self):
861 menu.append((_("Adapter settings"), "edit"))
862 menu.append((_("Nameserver settings"), "dns"))
863 menu.append((_("Network test"), "test"))
864 menu.append((_("Restart network"), "lanrestart"))
867 self.extendedSetup = None
868 for p in plugins.getPlugins(PluginDescriptor.WHERE_NETWORKSETUP):
869 callFnc = p.__call__["ifaceSupported"](self.iface)
870 if callFnc is not None:
871 self.extended = callFnc
873 if p.__call__.has_key("WlanPluginEntry"): # internally used only for WLAN Plugin
874 menu.append((_("Scan Wireless Networks"), "scanwlan"))
875 if iNetwork.getAdapterAttribute(self.iface, "up"):
876 menu.append((_("Show WLAN Status"), "wlanstatus"))
878 if p.__call__.has_key("menuEntryName"):
879 menuEntryName = p.__call__["menuEntryName"](self.iface)
881 menuEntryName = _('Extended Setup...')
882 if p.__call__.has_key("menuEntryDescription"):
883 menuEntryDescription = p.__call__["menuEntryDescription"](self.iface)
885 menuEntryDescription = _('Extended Networksetup Plugin...')
886 self.extendedSetup = ('extendedSetup',menuEntryDescription, self.extended)
887 menu.append((menuEntryName,self.extendedSetup))
889 if os_path.exists(resolveFilename(SCOPE_PLUGINS, "SystemPlugins/NetworkWizard/networkwizard.xml")):
890 menu.append((_("NetworkWizard"), "openwizard"))
894 def AdapterSetupClosed(self, *ret):
895 if ret is not None and len(ret):
896 if ret[0] == 'ok' and (self.iface == 'wlan0' or self.iface == 'ath0') and iNetwork.getAdapterAttribute(self.iface, "up") is True:
898 from Plugins.SystemPlugins.WirelessLan.plugin import WlanStatus
899 from Plugins.SystemPlugins.WirelessLan.iwlibs import Wireless
901 self.session.open(MessageBox, _("The wireless LAN plugin is not installed!\nPlease install it."), type = MessageBox.TYPE_INFO,timeout = 10 )
903 ifobj = Wireless(self.iface) # a Wireless NIC Object
904 self.wlanresponse = ifobj.getStatistics()
905 if self.wlanresponse[0] != 19:
906 self.session.openWithCallback(self.WlanStatusClosed, WlanStatus,self.iface)
908 # Display Wlan not available Message
909 self.showErrorMessage()
911 self.mainmenu = self.genMainMenu()
912 self["menulist"].l.setList(self.mainmenu)
913 self.updateStatusbar()
915 self.mainmenu = self.genMainMenu()
916 self["menulist"].l.setList(self.mainmenu)
917 self.updateStatusbar()
919 def WlanStatusClosed(self, *ret):
920 if ret is not None and len(ret):
921 from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus,Status
922 iStatus.stopWlanConsole()
923 self.mainmenu = self.genMainMenu()
924 self["menulist"].l.setList(self.mainmenu)
925 self.updateStatusbar()
927 def WlanScanClosed(self,*ret):
928 if ret[0] is not None:
929 self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetup, self.iface,ret[0],ret[1])
931 from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus,Status
932 iStatus.stopWlanConsole()
933 self.mainmenu = self.genMainMenu()
934 self["menulist"].l.setList(self.mainmenu)
935 self.updateStatusbar()
937 def restartLan(self, ret = False):
939 iNetwork.restartNetwork(self.restartLanDataAvail)
940 self.restartLanRef = self.session.openWithCallback(self.restartfinishedCB, MessageBox, _("Please wait while your network is restarting..."), type = MessageBox.TYPE_INFO, enable_input = False)
942 def restartLanDataAvail(self, data):
944 iNetwork.getInterfaces(self.getInterfacesDataAvail)
946 def getInterfacesDataAvail(self, data):
948 self.restartLanRef.close(True)
950 def restartfinishedCB(self,data):
952 self.session.open(MessageBox, _("Finished restarting your network"), type = MessageBox.TYPE_INFO, timeout = 10, default = False)
954 def dataAvail(self,data):
955 self.output = data.strip()
956 result = self.output.split('\n')
957 pattern = re_compile("Link detected: yes")
959 if re_search(pattern, item):
960 self["statuspic"].setPixmapNum(0)
962 self["statuspic"].setPixmapNum(1)
963 self["statuspic"].show()
965 def showErrorMessage(self):
966 self.session.open(MessageBox, self.errortext, type = MessageBox.TYPE_INFO,timeout = 10 )
969 iNetwork.stopLinkStateConsole()
970 iNetwork.stopDeactivateInterfaceConsole()
972 from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus,Status
976 iStatus.stopWlanConsole()
978 def getInfoCB(self,data,status):
981 if status is not None:
982 if status[self.iface]["acesspoint"] == "No Connection" or status[self.iface]["acesspoint"] == "Not-Associated" or status[self.iface]["acesspoint"] == False:
983 self["statuspic"].setPixmapNum(1)
985 self["statuspic"].setPixmapNum(0)
986 self["statuspic"].show()
988 class NetworkAdapterTest(Screen):
989 def __init__(self, session,iface):
990 Screen.__init__(self, session)
992 self.oldInterfaceState = iNetwork.getAdapterAttribute(self.iface, "up")
994 self.onClose.append(self.cleanup)
995 self.onHide.append(self.cleanup)
997 self["updown_actions"] = NumberActionMap(["WizardActions","ShortcutActions"],
1001 "up": lambda: self.updownhandler('up'),
1002 "down": lambda: self.updownhandler('down'),
1006 self["shortcuts"] = ActionMap(["ShortcutActions","WizardActions"],
1009 "back": self.cancel,
1011 self["infoshortcuts"] = ActionMap(["ShortcutActions","WizardActions"],
1013 "red": self.closeInfo,
1014 "back": self.closeInfo,
1016 self["shortcutsgreen"] = ActionMap(["ShortcutActions"],
1018 "green": self.KeyGreen,
1020 self["shortcutsgreen_restart"] = ActionMap(["ShortcutActions"],
1022 "green": self.KeyGreenRestart,
1024 self["shortcutsyellow"] = ActionMap(["ShortcutActions"],
1026 "yellow": self.KeyYellow,
1029 self["shortcutsgreen_restart"].setEnabled(False)
1030 self["updown_actions"].setEnabled(False)
1031 self["infoshortcuts"].setEnabled(False)
1032 self.onClose.append(self.delTimer)
1033 self.onLayoutFinish.append(self.layoutFinished)
1034 self.steptimer = False
1036 self.activebutton = 0
1037 self.nextStepTimer = eTimer()
1038 self.nextStepTimer.callback.append(self.nextStepTimerFire)
1041 if self.oldInterfaceState is False:
1042 iNetwork.setAdapterAttribute(self.iface, "up", self.oldInterfaceState)
1043 iNetwork.deactivateInterface(self.iface)
1046 def closeInfo(self):
1047 self["shortcuts"].setEnabled(True)
1048 self["infoshortcuts"].setEnabled(False)
1049 self["InfoText"].hide()
1050 self["InfoTextBorder"].hide()
1051 self["ButtonRedtext"].setText(_("Close"))
1055 del self.nextStepTimer
1057 def nextStepTimerFire(self):
1058 self.nextStepTimer.stop()
1059 self.steptimer = False
1062 def updownhandler(self,direction):
1063 if direction == 'up':
1064 if self.activebutton >=2:
1065 self.activebutton -= 1
1067 self.activebutton = 6
1068 self.setActiveButton(self.activebutton)
1069 if direction == 'down':
1070 if self.activebutton <=5:
1071 self.activebutton += 1
1073 self.activebutton = 1
1074 self.setActiveButton(self.activebutton)
1076 def setActiveButton(self,button):
1078 self["EditSettingsButton"].setPixmapNum(0)
1079 self["EditSettings_Text"].setForegroundColorNum(0)
1080 self["NetworkInfo"].setPixmapNum(0)
1081 self["NetworkInfo_Text"].setForegroundColorNum(1)
1082 self["AdapterInfo"].setPixmapNum(1) # active
1083 self["AdapterInfo_Text"].setForegroundColorNum(2) # active
1085 self["AdapterInfo_Text"].setForegroundColorNum(1)
1086 self["AdapterInfo"].setPixmapNum(0)
1087 self["DhcpInfo"].setPixmapNum(0)
1088 self["DhcpInfo_Text"].setForegroundColorNum(1)
1089 self["NetworkInfo"].setPixmapNum(1) # active
1090 self["NetworkInfo_Text"].setForegroundColorNum(2) # active
1092 self["NetworkInfo"].setPixmapNum(0)
1093 self["NetworkInfo_Text"].setForegroundColorNum(1)
1094 self["IPInfo"].setPixmapNum(0)
1095 self["IPInfo_Text"].setForegroundColorNum(1)
1096 self["DhcpInfo"].setPixmapNum(1) # active
1097 self["DhcpInfo_Text"].setForegroundColorNum(2) # active
1099 self["DhcpInfo"].setPixmapNum(0)
1100 self["DhcpInfo_Text"].setForegroundColorNum(1)
1101 self["DNSInfo"].setPixmapNum(0)
1102 self["DNSInfo_Text"].setForegroundColorNum(1)
1103 self["IPInfo"].setPixmapNum(1) # active
1104 self["IPInfo_Text"].setForegroundColorNum(2) # active
1106 self["IPInfo"].setPixmapNum(0)
1107 self["IPInfo_Text"].setForegroundColorNum(1)
1108 self["EditSettingsButton"].setPixmapNum(0)
1109 self["EditSettings_Text"].setForegroundColorNum(0)
1110 self["DNSInfo"].setPixmapNum(1) # active
1111 self["DNSInfo_Text"].setForegroundColorNum(2) # active
1113 self["DNSInfo"].setPixmapNum(0)
1114 self["DNSInfo_Text"].setForegroundColorNum(1)
1115 self["EditSettingsButton"].setPixmapNum(1) # active
1116 self["EditSettings_Text"].setForegroundColorNum(2) # active
1117 self["AdapterInfo"].setPixmapNum(0)
1118 self["AdapterInfo_Text"].setForegroundColorNum(1)
1121 next = self.nextstep
1137 self.steptimer = True
1138 self.nextStepTimer.start(3000)
1139 self["ButtonYellow_Check"].show()
1140 self["ButtonYellowtext"].show()
1143 self["Adapter"].setText(iNetwork.getFriendlyAdapterName(self.iface))
1144 self["Adapter"].setForegroundColorNum(2)
1145 self["Adaptertext"].setForegroundColorNum(1)
1146 self["AdapterInfo_Text"].setForegroundColorNum(1)
1147 self["AdapterInfo_OK"].show()
1148 self.steptimer = True
1149 self.nextStepTimer.start(3000)
1152 self["Networktext"].setForegroundColorNum(1)
1153 self["Network"].setText(_("Please wait..."))
1154 self.getLinkState(self.iface)
1155 self["NetworkInfo_Text"].setForegroundColorNum(1)
1156 self.steptimer = True
1157 self.nextStepTimer.start(3000)
1160 self["Dhcptext"].setForegroundColorNum(1)
1161 if iNetwork.getAdapterAttribute(self.iface, 'dhcp') is True:
1162 self["Dhcp"].setForegroundColorNum(2)
1163 self["Dhcp"].setText(_("enabled"))
1164 self["DhcpInfo_Check"].setPixmapNum(0)
1166 self["Dhcp"].setForegroundColorNum(1)
1167 self["Dhcp"].setText(_("disabled"))
1168 self["DhcpInfo_Check"].setPixmapNum(1)
1169 self["DhcpInfo_Check"].show()
1170 self["DhcpInfo_Text"].setForegroundColorNum(1)
1171 self.steptimer = True
1172 self.nextStepTimer.start(3000)
1175 self["IPtext"].setForegroundColorNum(1)
1176 self["IP"].setText(_("Please wait..."))
1177 iNetwork.checkNetworkState(self.NetworkStatedataAvail)
1180 self.steptimer = False
1181 self.nextStepTimer.stop()
1182 self["DNStext"].setForegroundColorNum(1)
1183 self["DNS"].setText(_("Please wait..."))
1184 iNetwork.checkDNSLookup(self.DNSLookupdataAvail)
1187 self["shortcutsgreen"].setEnabled(False)
1188 self["shortcutsyellow"].setEnabled(True)
1189 self["updown_actions"].setEnabled(False)
1190 self["ButtonYellow_Check"].setPixmapNum(0)
1191 self["ButtonGreen_Check"].setPixmapNum(1)
1192 self.steptimer = True
1193 self.nextStepTimer.start(1000)
1195 def KeyGreenRestart(self):
1197 self.layoutFinished()
1198 self["Adapter"].setText((""))
1199 self["Network"].setText((""))
1200 self["Dhcp"].setText((""))
1201 self["IP"].setText((""))
1202 self["DNS"].setText((""))
1203 self["AdapterInfo_Text"].setForegroundColorNum(0)
1204 self["NetworkInfo_Text"].setForegroundColorNum(0)
1205 self["DhcpInfo_Text"].setForegroundColorNum(0)
1206 self["IPInfo_Text"].setForegroundColorNum(0)
1207 self["DNSInfo_Text"].setForegroundColorNum(0)
1208 self["shortcutsgreen_restart"].setEnabled(False)
1209 self["shortcutsgreen"].setEnabled(False)
1210 self["shortcutsyellow"].setEnabled(True)
1211 self["updown_actions"].setEnabled(False)
1212 self["ButtonYellow_Check"].setPixmapNum(0)
1213 self["ButtonGreen_Check"].setPixmapNum(1)
1214 self.steptimer = True
1215 self.nextStepTimer.start(1000)
1218 self["infoshortcuts"].setEnabled(True)
1219 self["shortcuts"].setEnabled(False)
1220 if self.activebutton == 1: # Adapter Check
1221 self["InfoText"].setText(_("This test detects your configured LAN-Adapter."))
1222 self["InfoTextBorder"].show()
1223 self["InfoText"].show()
1224 self["ButtonRedtext"].setText(_("Back"))
1225 if self.activebutton == 2: #LAN Check
1226 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"))
1227 self["InfoTextBorder"].show()
1228 self["InfoText"].show()
1229 self["ButtonRedtext"].setText(_("Back"))
1230 if self.activebutton == 3: #DHCP Check
1231 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."))
1232 self["InfoTextBorder"].show()
1233 self["InfoText"].show()
1234 self["ButtonRedtext"].setText(_("Back"))
1235 if self.activebutton == 4: # IP Check
1236 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"))
1237 self["InfoTextBorder"].show()
1238 self["InfoText"].show()
1239 self["ButtonRedtext"].setText(_("Back"))
1240 if self.activebutton == 5: # DNS Check
1241 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"))
1242 self["InfoTextBorder"].show()
1243 self["InfoText"].show()
1244 self["ButtonRedtext"].setText(_("Back"))
1245 if self.activebutton == 6: # Edit Settings
1246 self.session.open(AdapterSetup,self.iface)
1248 def KeyYellow(self):
1250 self["shortcutsgreen_restart"].setEnabled(True)
1251 self["shortcutsgreen"].setEnabled(False)
1252 self["shortcutsyellow"].setEnabled(False)
1253 self["ButtonGreentext"].setText(_("Restart test"))
1254 self["ButtonYellow_Check"].setPixmapNum(1)
1255 self["ButtonGreen_Check"].setPixmapNum(0)
1256 self.steptimer = False
1257 self.nextStepTimer.stop()
1259 def layoutFinished(self):
1260 self["shortcutsyellow"].setEnabled(False)
1261 self["AdapterInfo_OK"].hide()
1262 self["NetworkInfo_Check"].hide()
1263 self["DhcpInfo_Check"].hide()
1264 self["IPInfo_Check"].hide()
1265 self["DNSInfo_Check"].hide()
1266 self["EditSettings_Text"].hide()
1267 self["EditSettingsButton"].hide()
1268 self["InfoText"].hide()
1269 self["InfoTextBorder"].hide()
1270 self["ButtonYellow_Check"].hide()
1271 self["ButtonYellowtext"].hide()
1273 def setLabels(self):
1274 self["Adaptertext"] = MultiColorLabel(_("LAN Adapter"))
1275 self["Adapter"] = MultiColorLabel()
1276 self["AdapterInfo"] = MultiPixmap()
1277 self["AdapterInfo_Text"] = MultiColorLabel(_("Show Info"))
1278 self["AdapterInfo_OK"] = Pixmap()
1280 if self.iface == 'wlan0' or self.iface == 'ath0':
1281 self["Networktext"] = MultiColorLabel(_("Wireless Network"))
1283 self["Networktext"] = MultiColorLabel(_("Local Network"))
1285 self["Network"] = MultiColorLabel()
1286 self["NetworkInfo"] = MultiPixmap()
1287 self["NetworkInfo_Text"] = MultiColorLabel(_("Show Info"))
1288 self["NetworkInfo_Check"] = MultiPixmap()
1290 self["Dhcptext"] = MultiColorLabel(_("DHCP"))
1291 self["Dhcp"] = MultiColorLabel()
1292 self["DhcpInfo"] = MultiPixmap()
1293 self["DhcpInfo_Text"] = MultiColorLabel(_("Show Info"))
1294 self["DhcpInfo_Check"] = MultiPixmap()
1296 self["IPtext"] = MultiColorLabel(_("IP Address"))
1297 self["IP"] = MultiColorLabel()
1298 self["IPInfo"] = MultiPixmap()
1299 self["IPInfo_Text"] = MultiColorLabel(_("Show Info"))
1300 self["IPInfo_Check"] = MultiPixmap()
1302 self["DNStext"] = MultiColorLabel(_("Nameserver"))
1303 self["DNS"] = MultiColorLabel()
1304 self["DNSInfo"] = MultiPixmap()
1305 self["DNSInfo_Text"] = MultiColorLabel(_("Show Info"))
1306 self["DNSInfo_Check"] = MultiPixmap()
1308 self["EditSettings_Text"] = MultiColorLabel(_("Edit settings"))
1309 self["EditSettingsButton"] = MultiPixmap()
1311 self["ButtonRedtext"] = Label(_("Close"))
1312 self["ButtonRed"] = Pixmap()
1314 self["ButtonGreentext"] = Label(_("Start test"))
1315 self["ButtonGreen_Check"] = MultiPixmap()
1317 self["ButtonYellowtext"] = Label(_("Stop test"))
1318 self["ButtonYellow_Check"] = MultiPixmap()
1320 self["InfoTextBorder"] = Pixmap()
1321 self["InfoText"] = Label()
1323 def getLinkState(self,iface):
1324 if iface == 'wlan0' or iface == 'ath0':
1326 from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus,Status
1328 self["Network"].setForegroundColorNum(1)
1329 self["Network"].setText(_("disconnected"))
1330 self["NetworkInfo_Check"].setPixmapNum(1)
1331 self["NetworkInfo_Check"].show()
1333 iStatus.getDataForInterface(self.iface,self.getInfoCB)
1335 iNetwork.getLinkState(iface,self.LinkStatedataAvail)
1337 def LinkStatedataAvail(self,data):
1338 self.output = data.strip()
1339 result = self.output.split('\n')
1340 pattern = re_compile("Link detected: yes")
1342 if re_search(pattern, item):
1343 self["Network"].setForegroundColorNum(2)
1344 self["Network"].setText(_("connected"))
1345 self["NetworkInfo_Check"].setPixmapNum(0)
1347 self["Network"].setForegroundColorNum(1)
1348 self["Network"].setText(_("disconnected"))
1349 self["NetworkInfo_Check"].setPixmapNum(1)
1350 self["NetworkInfo_Check"].show()
1352 def NetworkStatedataAvail(self,data):
1354 self["IP"].setForegroundColorNum(2)
1355 self["IP"].setText(_("confirmed"))
1356 self["IPInfo_Check"].setPixmapNum(0)
1358 self["IP"].setForegroundColorNum(1)
1359 self["IP"].setText(_("unconfirmed"))
1360 self["IPInfo_Check"].setPixmapNum(1)
1361 self["IPInfo_Check"].show()
1362 self["IPInfo_Text"].setForegroundColorNum(1)
1363 self.steptimer = True
1364 self.nextStepTimer.start(3000)
1366 def DNSLookupdataAvail(self,data):
1368 self["DNS"].setForegroundColorNum(2)
1369 self["DNS"].setText(_("confirmed"))
1370 self["DNSInfo_Check"].setPixmapNum(0)
1372 self["DNS"].setForegroundColorNum(1)
1373 self["DNS"].setText(_("unconfirmed"))
1374 self["DNSInfo_Check"].setPixmapNum(1)
1375 self["DNSInfo_Check"].show()
1376 self["DNSInfo_Text"].setForegroundColorNum(1)
1377 self["EditSettings_Text"].show()
1378 self["EditSettingsButton"].setPixmapNum(1)
1379 self["EditSettings_Text"].setForegroundColorNum(2) # active
1380 self["EditSettingsButton"].show()
1381 self["ButtonYellow_Check"].setPixmapNum(1)
1382 self["ButtonGreentext"].setText(_("Restart test"))
1383 self["ButtonGreen_Check"].setPixmapNum(0)
1384 self["shortcutsgreen"].setEnabled(False)
1385 self["shortcutsgreen_restart"].setEnabled(True)
1386 self["shortcutsyellow"].setEnabled(False)
1387 self["updown_actions"].setEnabled(True)
1388 self.activebutton = 6
1390 def getInfoCB(self,data,status):
1391 if data is not None:
1393 if status is not None:
1394 if status[self.iface]["acesspoint"] == "No Connection" or status[self.iface]["acesspoint"] == "Not-Associated" or status[self.iface]["acesspoint"] == False:
1395 self["Network"].setForegroundColorNum(1)
1396 self["Network"].setText(_("disconnected"))
1397 self["NetworkInfo_Check"].setPixmapNum(1)
1398 self["NetworkInfo_Check"].show()
1400 self["Network"].setForegroundColorNum(2)
1401 self["Network"].setText(_("connected"))
1402 self["NetworkInfo_Check"].setPixmapNum(0)
1403 self["NetworkInfo_Check"].show()
1406 iNetwork.stopLinkStateConsole()
1407 iNetwork.stopDNSConsole()
1409 from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus,Status
1413 iStatus.stopWlanConsole()