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()
177 iNetwork.stopGetInterfacesConsole()
179 def restartLan(self):
180 iNetwork.restartNetwork(self.restartLanDataAvail)
181 self.restartLanRef = self.session.openWithCallback(self.restartfinishedCB, MessageBox, _("Please wait while we configure your network..."), type = MessageBox.TYPE_INFO, enable_input = False)
183 def restartLanDataAvail(self, data):
185 iNetwork.getInterfaces(self.getInterfacesDataAvail)
187 def getInterfacesDataAvail(self, data):
189 self.restartLanRef.close(True)
191 def restartfinishedCB(self,data):
194 self.session.open(MessageBox, _("Finished configuring your network"), type = MessageBox.TYPE_INFO, timeout = 10, default = False)
197 class NameserverSetup(Screen, ConfigListScreen, HelpableScreen):
198 def __init__(self, session):
199 Screen.__init__(self, session)
200 HelpableScreen.__init__(self)
201 self.backupNameserverList = iNetwork.getNameserverList()[:]
202 print "backup-list:", self.backupNameserverList
204 self["ButtonGreentext"] = Label(_("Add"))
205 self["ButtonYellowtext"] = Label(_("Delete"))
206 self["ButtonRedtext"] = Label(_("Close"))
207 self["introduction"] = Label(_("Press OK to activate the settings."))
210 self["OkCancelActions"] = HelpableActionMap(self, "OkCancelActions",
212 "cancel": (self.cancel, _("exit nameserver configuration")),
213 "ok": (self.ok, _("activate current configuration")),
216 self["ColorActions"] = HelpableActionMap(self, "ColorActions",
218 "red": (self.cancel, _("exit nameserver configuration")),
219 "green": (self.add, _("add a nameserver entry")),
220 "yellow": (self.remove, _("remove a nameserver entry")),
223 self["actions"] = NumberActionMap(["SetupActions"],
229 ConfigListScreen.__init__(self, self.list)
232 def createConfig(self):
233 self.nameservers = iNetwork.getNameserverList()
234 self.nameserverEntries = []
236 for nameserver in self.nameservers:
237 self.nameserverEntries.append(NoSave(ConfigIP(default=nameserver)))
239 def createSetup(self):
242 for i in range(len(self.nameserverEntries)):
243 self.list.append(getConfigListEntry(_("Nameserver %d") % (i + 1), self.nameserverEntries[i]))
245 self["config"].list = self.list
246 self["config"].l.setList(self.list)
249 iNetwork.clearNameservers()
250 for nameserver in self.nameserverEntries:
251 iNetwork.addNameserver(nameserver.value)
252 iNetwork.writeNameserverConfig()
259 iNetwork.clearNameservers()
260 print "backup-list:", self.backupNameserverList
261 for nameserver in self.backupNameserverList:
262 iNetwork.addNameserver(nameserver)
266 iNetwork.addNameserver([0,0,0,0])
271 print "currentIndex:", self["config"].getCurrentIndex()
273 index = self["config"].getCurrentIndex()
274 if index < len(self.nameservers):
275 iNetwork.removeNameserver(self.nameservers[index])
279 class AdapterSetup(Screen, ConfigListScreen, HelpableScreen):
280 def __init__(self, session, networkinfo, essid=None, aplist=None):
281 Screen.__init__(self, session)
282 HelpableScreen.__init__(self)
283 self.session = session
284 if isinstance(networkinfo, (list, tuple)):
285 self.iface = networkinfo[0]
286 self.essid = networkinfo[1]
287 self.aplist = networkinfo[2]
289 self.iface = networkinfo
293 self.applyConfigRef = None
294 self.finished_cb = None
295 self.oktext = _("Press OK on your remote control to continue.")
296 self.oldInterfaceState = iNetwork.getAdapterAttribute(self.iface, "up")
300 self["OkCancelActions"] = HelpableActionMap(self, "OkCancelActions",
302 "cancel": (self.cancel, _("exit network adapter setup menu")),
303 "ok": (self.ok, _("select menu entry")),
306 self["ColorActions"] = HelpableActionMap(self, "ColorActions",
308 "red": (self.cancel, _("exit network adapter configuration")),
309 "blue": (self.KeyBlue, _("open nameserver configuration")),
312 self["VirtualKB"] = HelpableActionMap(self, "ColorActions",
314 "green": (self.KeyGreen, [_("open virtual keyboard input help"),_("* Only available when entering hidden SSID or network key")] ),
317 self["actions"] = NumberActionMap(["SetupActions"],
324 ConfigListScreen.__init__(self, self.list,session = self.session)
326 self.onLayoutFinish.append(self.layoutFinished)
327 self.onClose.append(self.cleanup)
329 self["DNS1text"] = Label(_("Primary DNS"))
330 self["DNS2text"] = Label(_("Secondary DNS"))
331 self["DNS1"] = Label()
332 self["DNS2"] = Label()
334 self["introduction"] = Label(_("Current settings:"))
336 self["IPtext"] = Label(_("IP Address"))
337 self["Netmasktext"] = Label(_("Netmask"))
338 self["Gatewaytext"] = Label(_("Gateway"))
341 self["Mask"] = Label()
342 self["Gateway"] = Label()
344 self["BottomBG"] = Pixmap()
345 self["Adaptertext"] = Label(_("Network:"))
346 self["Adapter"] = Label()
347 self["introduction2"] = Label(_("Press OK to activate the settings."))
348 self["ButtonRed"] = Pixmap()
349 self["ButtonRedtext"] = Label(_("Close"))
350 self["ButtonBlue"] = Pixmap()
351 self["ButtonBluetext"] = Label(_("Edit DNS"))
352 self["ButtonGreen"] = Pixmap()
353 self["VKeyIcon"] = Pixmap()
354 self["HelpWindow"] = Pixmap()
356 def layoutFinished(self):
357 self["DNS1"].setText(self.primaryDNS.getText())
358 self["DNS2"].setText(self.secondaryDNS.getText())
359 if self.ipConfigEntry.getText() is not None:
360 if self.ipConfigEntry.getText() == "0.0.0.0":
361 self["IP"].setText(_("N/A"))
363 self["IP"].setText(self.ipConfigEntry.getText())
365 self["IP"].setText(_("N/A"))
366 if self.netmaskConfigEntry.getText() is not None:
367 if self.netmaskConfigEntry.getText() == "0.0.0.0":
368 self["Mask"].setText(_("N/A"))
370 self["Mask"].setText(self.netmaskConfigEntry.getText())
372 self["IP"].setText(_("N/A"))
373 if iNetwork.getAdapterAttribute(self.iface, "gateway"):
374 if self.gatewayConfigEntry.getText() == "0.0.0.0":
375 self["Gateway"].setText(_("N/A"))
377 self["Gateway"].setText(self.gatewayConfigEntry.getText())
379 self["Gateway"].hide()
380 self["Gatewaytext"].hide()
381 self["Adapter"].setText(iNetwork.getFriendlyAdapterName(self.iface))
382 self["ButtonGreen"].hide()
383 self["VKeyIcon"].hide()
384 self["VirtualKB"].setEnabled(False)
385 self["HelpWindow"].hide()
387 def createConfig(self):
388 self.InterfaceEntry = None
389 self.dhcpEntry = None
390 self.gatewayEntry = None
391 self.hiddenSSID = None
393 self.encryptionEnabled = None
394 self.encryptionKey = None
395 self.encryptionType = None
397 self.encryptionlist = None
402 if self.iface == "wlan0" or self.iface == "ath0" :
403 from Plugins.SystemPlugins.WirelessLan.Wlan import wpaSupplicant,Wlan
404 self.w = Wlan(self.iface)
405 self.ws = wpaSupplicant()
406 self.encryptionlist = []
407 self.encryptionlist.append(("WEP", _("WEP")))
408 self.encryptionlist.append(("WPA", _("WPA")))
409 self.encryptionlist.append(("WPA2", _("WPA2")))
410 self.encryptionlist.append(("WPA/WPA2", _("WPA or WPA2")))
412 self.weplist.append("ASCII")
413 self.weplist.append("HEX")
414 if self.aplist is not None:
415 self.nwlist = self.aplist
416 self.nwlist.sort(key = lambda x: x[0])
421 self.aps = self.w.getNetworkList()
422 if self.aps is not None:
423 print "[NetworkSetup.py] got Accespoints!"
428 a['essid'] = a['bssid']
429 self.nwlist.append( a['essid'])
430 self.nwlist.sort(key = lambda x: x[0])
432 self.nwlist.append("No Networks found")
434 self.wsconfig = self.ws.loadConfig()
435 if self.essid is not None: # ssid from wlan scan
436 self.default = self.essid
438 self.default = self.wsconfig['ssid']
440 if "hidden..." not in self.nwlist:
441 self.nwlist.append("hidden...")
442 if self.default not in self.nwlist:
443 self.nwlist.append(self.default)
445 config.plugins.wlan.essid = NoSave(ConfigSelection(self.nwlist, default = self.default ))
446 config.plugins.wlan.hiddenessid = NoSave(ConfigText(default = self.wsconfig['hiddenessid'], visible_width = 50, fixed_size = False))
448 config.plugins.wlan.encryption.enabled = NoSave(ConfigYesNo(default = self.wsconfig['encryption'] ))
449 config.plugins.wlan.encryption.type = NoSave(ConfigSelection(self.encryptionlist, default = self.wsconfig['encryption_type'] ))
450 config.plugins.wlan.encryption.wepkeytype = NoSave(ConfigSelection(self.weplist, default = self.wsconfig['encryption_wepkeytype'] ))
451 config.plugins.wlan.encryption.psk = NoSave(ConfigPassword(default = self.wsconfig['key'], visible_width = 50, fixed_size = False))
453 self.activateInterfaceEntry = NoSave(ConfigYesNo(default=iNetwork.getAdapterAttribute(self.iface, "up") or False))
454 self.dhcpConfigEntry = NoSave(ConfigYesNo(default=iNetwork.getAdapterAttribute(self.iface, "dhcp") or False))
455 self.ipConfigEntry = NoSave(ConfigIP(default=iNetwork.getAdapterAttribute(self.iface, "ip")) or [0,0,0,0])
456 self.netmaskConfigEntry = NoSave(ConfigIP(default=iNetwork.getAdapterAttribute(self.iface, "netmask") or [255,0,0,0]))
457 if iNetwork.getAdapterAttribute(self.iface, "gateway"):
458 self.dhcpdefault=True
460 self.dhcpdefault=False
461 self.hasGatewayConfigEntry = NoSave(ConfigYesNo(default=self.dhcpdefault or False))
462 self.gatewayConfigEntry = NoSave(ConfigIP(default=iNetwork.getAdapterAttribute(self.iface, "gateway") or [0,0,0,0]))
463 nameserver = (iNetwork.getNameserverList() + [[0,0,0,0]] * 2)[0:2]
464 self.primaryDNS = NoSave(ConfigIP(default=nameserver[0]))
465 self.secondaryDNS = NoSave(ConfigIP(default=nameserver[1]))
467 def createSetup(self):
469 self.InterfaceEntry = getConfigListEntry(_("Use Interface"), self.activateInterfaceEntry)
471 self.list.append(self.InterfaceEntry)
472 if self.activateInterfaceEntry.value:
473 self.dhcpEntry = getConfigListEntry(_("Use DHCP"), self.dhcpConfigEntry)
474 self.list.append(self.dhcpEntry)
475 if not self.dhcpConfigEntry.value:
476 self.list.append(getConfigListEntry(_('IP Address'), self.ipConfigEntry))
477 self.list.append(getConfigListEntry(_('Netmask'), self.netmaskConfigEntry))
478 self.gatewayEntry = getConfigListEntry(_('Use a gateway'), self.hasGatewayConfigEntry)
479 self.list.append(self.gatewayEntry)
480 if self.hasGatewayConfigEntry.value:
481 self.list.append(getConfigListEntry(_('Gateway'), self.gatewayConfigEntry))
484 for p in plugins.getPlugins(PluginDescriptor.WHERE_NETWORKSETUP):
485 callFnc = p.__call__["ifaceSupported"](self.iface)
486 if callFnc is not None:
487 if p.__call__.has_key("WlanPluginEntry"): # internally used only for WLAN Plugin
488 self.extended = callFnc
489 if p.__call__.has_key("configStrings"):
490 self.configStrings = p.__call__["configStrings"]
492 self.configStrings = None
493 if config.plugins.wlan.essid.value == 'hidden...':
494 self.wlanSSID = getConfigListEntry(_("Network SSID"), config.plugins.wlan.essid)
495 self.list.append(self.wlanSSID)
496 self.hiddenSSID = getConfigListEntry(_("Hidden network SSID"), config.plugins.wlan.hiddenessid)
497 self.list.append(self.hiddenSSID)
499 self.wlanSSID = getConfigListEntry(_("Network SSID"), config.plugins.wlan.essid)
500 self.list.append(self.wlanSSID)
501 self.encryptionEnabled = getConfigListEntry(_("Encryption"), config.plugins.wlan.encryption.enabled)
502 self.list.append(self.encryptionEnabled)
504 if config.plugins.wlan.encryption.enabled.value:
505 self.encryptionType = getConfigListEntry(_("Encryption Type"), config.plugins.wlan.encryption.type)
506 self.list.append(self.encryptionType)
507 if config.plugins.wlan.encryption.type.value == 'WEP':
508 self.list.append(getConfigListEntry(_("Encryption Keytype"), config.plugins.wlan.encryption.wepkeytype))
509 self.encryptionKey = getConfigListEntry(_("Encryption Key"), config.plugins.wlan.encryption.psk)
510 self.list.append(self.encryptionKey)
512 self.encryptionKey = getConfigListEntry(_("Encryption Key"), config.plugins.wlan.encryption.psk)
513 self.list.append(self.encryptionKey)
516 self["config"].list = self.list
517 self["config"].l.setList(self.list)
518 if not self.selectionChanged in self["config"].onSelectionChanged:
519 self["config"].onSelectionChanged.append(self.selectionChanged)
522 self.session.openWithCallback(self.NameserverSetupClosed, NameserverSetup)
525 if self.iface == "wlan0" or self.iface == "ath0" :
526 if self["config"].getCurrent() == self.hiddenSSID:
527 if config.plugins.wlan.essid.value == 'hidden...':
528 self.session.openWithCallback(self.VirtualKeyBoardSSIDCallback, VirtualKeyBoard, title = (_("Enter WLAN network name/SSID:")), text = config.plugins.wlan.essid.value)
529 if self["config"].getCurrent() == self.encryptionKey:
530 self.session.openWithCallback(self.VirtualKeyBoardKeyCallback, VirtualKeyBoard, title = (_("Enter WLAN passphrase/key:")), text = config.plugins.wlan.encryption.psk.value)
532 def VirtualKeyBoardSSIDCallback(self, callback = None):
533 if callback is not None and len(callback):
534 config.plugins.wlan.hiddenessid = NoSave(ConfigText(default = callback, visible_width = 50, fixed_size = False))
537 def VirtualKeyBoardKeyCallback(self, callback = None):
538 if callback is not None and len(callback):
539 config.plugins.wlan.encryption.psk = NoSave(ConfigPassword(default = callback, visible_width = 50, fixed_size = False))
543 if self["config"].getCurrent() == self.InterfaceEntry:
545 if self["config"].getCurrent() == self.dhcpEntry:
547 if self["config"].getCurrent() == self.gatewayEntry:
549 if self.iface == "wlan0" or self.iface == "ath0" :
550 if self["config"].getCurrent() == self.wlanSSID:
552 if self["config"].getCurrent() == self.encryptionEnabled:
554 if self["config"].getCurrent() == self.encryptionType:
557 ConfigListScreen.keyLeft(self)
561 ConfigListScreen.keyRight(self)
564 def selectionChanged(self):
565 current = self["config"].getCurrent()
566 if current == self.hiddenSSID and config.plugins.wlan.essid.value == 'hidden...':
567 helpwindowpos = self["HelpWindow"].getPosition()
568 if current[1].help_window.instance is not None:
569 current[1].help_window.instance.move(ePoint(helpwindowpos[0],helpwindowpos[1]))
570 self["ButtonGreen"].show()
571 self["VKeyIcon"].show()
572 self["VirtualKB"].setEnabled(True)
573 elif current == self.encryptionKey and config.plugins.wlan.encryption.enabled.value:
574 helpwindowpos = self["HelpWindow"].getPosition()
575 if current[1].help_window.instance is not None:
576 current[1].help_window.instance.move(ePoint(helpwindowpos[0],helpwindowpos[1]))
577 self["ButtonGreen"].show()
578 self["VKeyIcon"].show()
579 self["VirtualKB"].setEnabled(True)
581 self["ButtonGreen"].hide()
582 self["VKeyIcon"].hide()
583 self["VirtualKB"].setEnabled(False)
586 current = self["config"].getCurrent()
587 if current == self.hiddenSSID and config.plugins.wlan.essid.value == 'hidden...':
588 if current[1].help_window.instance is not None:
589 current[1].help_window.instance.hide()
590 elif current == self.encryptionKey and config.plugins.wlan.encryption.enabled.value:
591 if current[1].help_window.instance is not None:
592 current[1].help_window.instance.hide()
593 self.session.openWithCallback(self.applyConfig, MessageBox, (_("Are you sure you want to activate this network configuration?\n\n") + self.oktext ) )
595 def applyConfig(self, ret = False):
597 iNetwork.setAdapterAttribute(self.iface, "up", self.activateInterfaceEntry.value)
598 iNetwork.setAdapterAttribute(self.iface, "dhcp", self.dhcpConfigEntry.value)
599 iNetwork.setAdapterAttribute(self.iface, "ip", self.ipConfigEntry.value)
600 iNetwork.setAdapterAttribute(self.iface, "netmask", self.netmaskConfigEntry.value)
601 if self.hasGatewayConfigEntry.value:
602 iNetwork.setAdapterAttribute(self.iface, "gateway", self.gatewayConfigEntry.value)
604 iNetwork.removeAdapterAttribute(self.iface, "gateway")
605 if self.extended is not None and self.configStrings is not None:
606 iNetwork.setAdapterAttribute(self.iface, "configStrings", self.configStrings(self.iface))
607 self.ws.writeConfig()
608 if self.activateInterfaceEntry.value is False:
609 iNetwork.deactivateInterface(self.iface)
610 iNetwork.writeNetworkConfig()
611 iNetwork.restartNetwork(self.applyConfigDataAvail)
612 self.applyConfigRef = self.session.openWithCallback(self.applyConfigfinishedCB, MessageBox, _("Please wait for activation of your network configuration..."), type = MessageBox.TYPE_INFO, enable_input = False)
616 def applyConfigDataAvail(self, data):
618 iNetwork.getInterfaces(self.getInterfacesDataAvail)
620 def getInterfacesDataAvail(self, data):
622 self.applyConfigRef.close(True)
624 def applyConfigfinishedCB(self,data):
626 num_configured_if = len(iNetwork.getConfiguredAdapters())
627 if num_configured_if >= 2:
628 self.session.openWithCallback(self.secondIfaceFoundCB, MessageBox, _("Your network configuration has been activated.\nA second configured interface has been found.\n\nDo you want to disable the second network interface?"), default = True)
631 self.session.openWithCallback(lambda x : self.finished_cb(), MessageBox, _("Your network configuration has been activated."), type = MessageBox.TYPE_INFO, timeout = 10)
633 self.session.openWithCallback(self.ConfigfinishedCB, MessageBox, _("Your network configuration has been activated."), type = MessageBox.TYPE_INFO, timeout = 10)
635 def secondIfaceFoundCB(self,data):
639 configuredInterfaces = iNetwork.getConfiguredAdapters()
640 for interface in configuredInterfaces:
641 if interface == self.iface:
643 iNetwork.setAdapterAttribute(interface, "up", False)
644 iNetwork.deactivateInterface(interface)
645 self.applyConfig(True)
647 def ConfigfinishedCB(self,data):
653 if self.oldInterfaceState is False:
654 iNetwork.deactivateInterface(self.iface,self.deactivateInterfaceCB)
658 def deactivateInterfaceCB(self,data):
661 iNetwork.getInterfaces(self.cancelCB)
663 def cancelCB(self,data):
668 def runAsync(self, finished_cb):
669 self.finished_cb = finished_cb
672 def NameserverSetupClosed(self, *ret):
673 iNetwork.loadNameserverConfig()
674 nameserver = (iNetwork.getNameserverList() + [[0,0,0,0]] * 2)[0:2]
675 self.primaryDNS = NoSave(ConfigIP(default=nameserver[0]))
676 self.secondaryDNS = NoSave(ConfigIP(default=nameserver[1]))
678 self.layoutFinished()
681 iNetwork.stopLinkStateConsole()
684 class AdapterSetupConfiguration(Screen, HelpableScreen):
685 def __init__(self, session,iface):
686 Screen.__init__(self, session)
687 HelpableScreen.__init__(self)
688 self.session = session
690 self.restartLanRef = None
691 self.mainmenu = self.genMainMenu()
692 self["menulist"] = MenuList(self.mainmenu)
693 self["description"] = Label()
694 self["IFtext"] = Label()
696 self["BottomBG"] = Label()
697 self["Statustext"] = Label()
698 self["statuspic"] = MultiPixmap()
699 self["statuspic"].hide()
700 self["BottomBG"] = Pixmap()
701 self["ButtonRed"] = Pixmap()
702 self["ButtonRedtext"] = Label(_("Close"))
704 self.oktext = _("Press OK on your remote control to continue.")
705 self.reboottext = _("Your Dreambox will restart after pressing OK on your remote control.")
706 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.")
708 self["WizardActions"] = HelpableActionMap(self, "WizardActions",
710 "up": (self.up, _("move up to previous entry")),
711 "down": (self.down, _("move down to next entry")),
712 "left": (self.left, _("move up to first entry")),
713 "right": (self.right, _("move down to last entry")),
716 self["OkCancelActions"] = HelpableActionMap(self, "OkCancelActions",
718 "cancel": (self.close, _("exit networkadapter setup menu")),
719 "ok": (self.ok, _("select menu entry")),
722 self["ColorActions"] = HelpableActionMap(self, "ColorActions",
724 "red": (self.close, _("exit networkadapter setup menu")),
727 self["actions"] = NumberActionMap(["WizardActions","ShortcutActions"],
738 self.updateStatusbar()
739 self.onLayoutFinish.append(self.layoutFinished)
740 self.onClose.append(self.cleanup)
743 if self["menulist"].getCurrent()[1] == 'edit':
744 if self.iface == 'wlan0' or self.iface == 'ath0':
746 from Plugins.SystemPlugins.WirelessLan.plugin import WlanScan
747 from Plugins.SystemPlugins.WirelessLan.iwlibs import Wireless
749 self.session.open(MessageBox, _("The wireless LAN plugin is not installed!\nPlease install it."), type = MessageBox.TYPE_INFO,timeout = 10 )
751 ifobj = Wireless(self.iface) # a Wireless NIC Object
752 self.wlanresponse = ifobj.getStatistics()
753 if self.wlanresponse[0] != 19: # Wlan Interface found.
754 self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetup,self.iface)
756 # Display Wlan not available Message
757 self.showErrorMessage()
759 self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetup,self.iface)
760 if self["menulist"].getCurrent()[1] == 'test':
761 self.session.open(NetworkAdapterTest,self.iface)
762 if self["menulist"].getCurrent()[1] == 'dns':
763 self.session.open(NameserverSetup)
764 if self["menulist"].getCurrent()[1] == 'scanwlan':
766 from Plugins.SystemPlugins.WirelessLan.plugin import WlanScan
767 from Plugins.SystemPlugins.WirelessLan.iwlibs import Wireless
769 self.session.open(MessageBox, _("The wireless LAN plugin is not installed!\nPlease install it."), type = MessageBox.TYPE_INFO,timeout = 10 )
771 ifobj = Wireless(self.iface) # a Wireless NIC Object
772 self.wlanresponse = ifobj.getStatistics()
773 if self.wlanresponse[0] != 19:
774 self.session.openWithCallback(self.WlanScanClosed, WlanScan, self.iface)
776 # Display Wlan not available Message
777 self.showErrorMessage()
778 if self["menulist"].getCurrent()[1] == 'wlanstatus':
780 from Plugins.SystemPlugins.WirelessLan.plugin import WlanStatus
781 from Plugins.SystemPlugins.WirelessLan.iwlibs import Wireless
783 self.session.open(MessageBox, _("The wireless LAN plugin is not installed!\nPlease install it."), type = MessageBox.TYPE_INFO,timeout = 10 )
785 ifobj = Wireless(self.iface) # a Wireless NIC Object
786 self.wlanresponse = ifobj.getStatistics()
787 if self.wlanresponse[0] != 19:
788 self.session.openWithCallback(self.WlanStatusClosed, WlanStatus,self.iface)
790 # Display Wlan not available Message
791 self.showErrorMessage()
792 if self["menulist"].getCurrent()[1] == 'lanrestart':
793 self.session.openWithCallback(self.restartLan, MessageBox, (_("Are you sure you want to restart your network interfaces?\n\n") + self.oktext ) )
794 if self["menulist"].getCurrent()[1] == 'openwizard':
795 from Plugins.SystemPlugins.NetworkWizard.NetworkWizard import NetworkWizard
796 self.session.openWithCallback(self.AdapterSetupClosed, NetworkWizard)
797 if self["menulist"].getCurrent()[1][0] == 'extendedSetup':
798 self.extended = self["menulist"].getCurrent()[1][2]
799 self.extended(self.session, self.iface)
802 self["menulist"].up()
803 self.loadDescription()
806 self["menulist"].down()
807 self.loadDescription()
810 self["menulist"].pageUp()
811 self.loadDescription()
814 self["menulist"].pageDown()
815 self.loadDescription()
817 def layoutFinished(self):
819 self["menulist"].moveToIndex(idx)
820 self.loadDescription()
822 def loadDescription(self):
823 print self["menulist"].getCurrent()[1]
824 if self["menulist"].getCurrent()[1] == 'edit':
825 self["description"].setText(_("Edit the network configuration of your Dreambox.\n" ) + self.oktext )
826 if self["menulist"].getCurrent()[1] == 'test':
827 self["description"].setText(_("Test the network configuration of your Dreambox.\n" ) + self.oktext )
828 if self["menulist"].getCurrent()[1] == 'dns':
829 self["description"].setText(_("Edit the Nameserver configuration of your Dreambox.\n" ) + self.oktext )
830 if self["menulist"].getCurrent()[1] == 'scanwlan':
831 self["description"].setText(_("Scan your network for wireless Access Points and connect to them using your WLAN USB Stick\n" ) + self.oktext )
832 if self["menulist"].getCurrent()[1] == 'wlanstatus':
833 self["description"].setText(_("Shows the state of your wireless LAN connection.\n" ) + self.oktext )
834 if self["menulist"].getCurrent()[1] == 'lanrestart':
835 self["description"].setText(_("Restart your network connection and interfaces.\n" ) + self.oktext )
836 if self["menulist"].getCurrent()[1] == 'openwizard':
837 self["description"].setText(_("Use the Networkwizard to configure your Network\n" ) + self.oktext )
838 if self["menulist"].getCurrent()[1][0] == 'extendedSetup':
839 self["description"].setText(_(self["menulist"].getCurrent()[1][1]) + self.oktext )
841 def updateStatusbar(self, data = None):
842 self["IFtext"].setText(_("Network:"))
843 self["IF"].setText(iNetwork.getFriendlyAdapterName(self.iface))
844 self["Statustext"].setText(_("Link:"))
846 if self.iface == 'wlan0' or self.iface == 'ath0':
848 from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus,Status
850 self["statuspic"].setPixmapNum(1)
851 self["statuspic"].show()
853 iStatus.getDataForInterface(self.iface,self.getInfoCB)
855 iNetwork.getLinkState(self.iface,self.dataAvail)
860 def genMainMenu(self):
862 menu.append((_("Adapter settings"), "edit"))
863 menu.append((_("Nameserver settings"), "dns"))
864 menu.append((_("Network test"), "test"))
865 menu.append((_("Restart network"), "lanrestart"))
868 self.extendedSetup = None
869 for p in plugins.getPlugins(PluginDescriptor.WHERE_NETWORKSETUP):
870 callFnc = p.__call__["ifaceSupported"](self.iface)
871 if callFnc is not None:
872 self.extended = callFnc
874 if p.__call__.has_key("WlanPluginEntry"): # internally used only for WLAN Plugin
875 menu.append((_("Scan Wireless Networks"), "scanwlan"))
876 if iNetwork.getAdapterAttribute(self.iface, "up"):
877 menu.append((_("Show WLAN Status"), "wlanstatus"))
879 if p.__call__.has_key("menuEntryName"):
880 menuEntryName = p.__call__["menuEntryName"](self.iface)
882 menuEntryName = _('Extended Setup...')
883 if p.__call__.has_key("menuEntryDescription"):
884 menuEntryDescription = p.__call__["menuEntryDescription"](self.iface)
886 menuEntryDescription = _('Extended Networksetup Plugin...')
887 self.extendedSetup = ('extendedSetup',menuEntryDescription, self.extended)
888 menu.append((menuEntryName,self.extendedSetup))
890 if os_path.exists(resolveFilename(SCOPE_PLUGINS, "SystemPlugins/NetworkWizard/networkwizard.xml")):
891 menu.append((_("NetworkWizard"), "openwizard"))
895 def AdapterSetupClosed(self, *ret):
896 if ret is not None and len(ret):
897 if ret[0] == 'ok' and (self.iface == 'wlan0' or self.iface == 'ath0') and iNetwork.getAdapterAttribute(self.iface, "up") is True:
899 from Plugins.SystemPlugins.WirelessLan.plugin import WlanStatus
900 from Plugins.SystemPlugins.WirelessLan.iwlibs import Wireless
902 self.session.open(MessageBox, _("The wireless LAN plugin is not installed!\nPlease install it."), type = MessageBox.TYPE_INFO,timeout = 10 )
904 ifobj = Wireless(self.iface) # a Wireless NIC Object
905 self.wlanresponse = ifobj.getStatistics()
906 if self.wlanresponse[0] != 19:
907 self.session.openWithCallback(self.WlanStatusClosed, WlanStatus,self.iface)
909 # Display Wlan not available Message
910 self.showErrorMessage()
912 self.mainmenu = self.genMainMenu()
913 self["menulist"].l.setList(self.mainmenu)
914 self.updateStatusbar()
916 self.mainmenu = self.genMainMenu()
917 self["menulist"].l.setList(self.mainmenu)
918 self.updateStatusbar()
920 def WlanStatusClosed(self, *ret):
921 if ret is not None and len(ret):
922 from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus,Status
923 iStatus.stopWlanConsole()
924 self.mainmenu = self.genMainMenu()
925 self["menulist"].l.setList(self.mainmenu)
926 self.updateStatusbar()
928 def WlanScanClosed(self,*ret):
929 if ret[0] is not None:
930 self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetup, self.iface,ret[0],ret[1])
932 from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus,Status
933 iStatus.stopWlanConsole()
934 self.mainmenu = self.genMainMenu()
935 self["menulist"].l.setList(self.mainmenu)
936 self.updateStatusbar()
938 def restartLan(self, ret = False):
940 iNetwork.restartNetwork(self.restartLanDataAvail)
941 self.restartLanRef = self.session.openWithCallback(self.restartfinishedCB, MessageBox, _("Please wait while your network is restarting..."), type = MessageBox.TYPE_INFO, enable_input = False)
943 def restartLanDataAvail(self, data):
945 iNetwork.getInterfaces(self.getInterfacesDataAvail)
947 def getInterfacesDataAvail(self, data):
949 self.restartLanRef.close(True)
951 def restartfinishedCB(self,data):
953 self.session.open(MessageBox, _("Finished restarting your network"), type = MessageBox.TYPE_INFO, timeout = 10, default = False)
955 def dataAvail(self,data):
956 self.output = data.strip()
957 result = self.output.split('\n')
958 pattern = re_compile("Link detected: yes")
960 if re_search(pattern, item):
961 self["statuspic"].setPixmapNum(0)
963 self["statuspic"].setPixmapNum(1)
964 self["statuspic"].show()
966 def showErrorMessage(self):
967 self.session.open(MessageBox, self.errortext, type = MessageBox.TYPE_INFO,timeout = 10 )
970 iNetwork.stopLinkStateConsole()
971 iNetwork.stopDeactivateInterfaceConsole()
973 from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus,Status
977 iStatus.stopWlanConsole()
979 def getInfoCB(self,data,status):
982 if status is not None:
983 if status[self.iface]["acesspoint"] == "No Connection" or status[self.iface]["acesspoint"] == "Not-Associated" or status[self.iface]["acesspoint"] == False:
984 self["statuspic"].setPixmapNum(1)
986 self["statuspic"].setPixmapNum(0)
987 self["statuspic"].show()
989 class NetworkAdapterTest(Screen):
990 def __init__(self, session,iface):
991 Screen.__init__(self, session)
993 self.oldInterfaceState = iNetwork.getAdapterAttribute(self.iface, "up")
995 self.onClose.append(self.cleanup)
996 self.onHide.append(self.cleanup)
998 self["updown_actions"] = NumberActionMap(["WizardActions","ShortcutActions"],
1002 "up": lambda: self.updownhandler('up'),
1003 "down": lambda: self.updownhandler('down'),
1007 self["shortcuts"] = ActionMap(["ShortcutActions","WizardActions"],
1010 "back": self.cancel,
1012 self["infoshortcuts"] = ActionMap(["ShortcutActions","WizardActions"],
1014 "red": self.closeInfo,
1015 "back": self.closeInfo,
1017 self["shortcutsgreen"] = ActionMap(["ShortcutActions"],
1019 "green": self.KeyGreen,
1021 self["shortcutsgreen_restart"] = ActionMap(["ShortcutActions"],
1023 "green": self.KeyGreenRestart,
1025 self["shortcutsyellow"] = ActionMap(["ShortcutActions"],
1027 "yellow": self.KeyYellow,
1030 self["shortcutsgreen_restart"].setEnabled(False)
1031 self["updown_actions"].setEnabled(False)
1032 self["infoshortcuts"].setEnabled(False)
1033 self.onClose.append(self.delTimer)
1034 self.onLayoutFinish.append(self.layoutFinished)
1035 self.steptimer = False
1037 self.activebutton = 0
1038 self.nextStepTimer = eTimer()
1039 self.nextStepTimer.callback.append(self.nextStepTimerFire)
1042 if self.oldInterfaceState is False:
1043 iNetwork.setAdapterAttribute(self.iface, "up", self.oldInterfaceState)
1044 iNetwork.deactivateInterface(self.iface)
1047 def closeInfo(self):
1048 self["shortcuts"].setEnabled(True)
1049 self["infoshortcuts"].setEnabled(False)
1050 self["InfoText"].hide()
1051 self["InfoTextBorder"].hide()
1052 self["ButtonRedtext"].setText(_("Close"))
1056 del self.nextStepTimer
1058 def nextStepTimerFire(self):
1059 self.nextStepTimer.stop()
1060 self.steptimer = False
1063 def updownhandler(self,direction):
1064 if direction == 'up':
1065 if self.activebutton >=2:
1066 self.activebutton -= 1
1068 self.activebutton = 6
1069 self.setActiveButton(self.activebutton)
1070 if direction == 'down':
1071 if self.activebutton <=5:
1072 self.activebutton += 1
1074 self.activebutton = 1
1075 self.setActiveButton(self.activebutton)
1077 def setActiveButton(self,button):
1079 self["EditSettingsButton"].setPixmapNum(0)
1080 self["EditSettings_Text"].setForegroundColorNum(0)
1081 self["NetworkInfo"].setPixmapNum(0)
1082 self["NetworkInfo_Text"].setForegroundColorNum(1)
1083 self["AdapterInfo"].setPixmapNum(1) # active
1084 self["AdapterInfo_Text"].setForegroundColorNum(2) # active
1086 self["AdapterInfo_Text"].setForegroundColorNum(1)
1087 self["AdapterInfo"].setPixmapNum(0)
1088 self["DhcpInfo"].setPixmapNum(0)
1089 self["DhcpInfo_Text"].setForegroundColorNum(1)
1090 self["NetworkInfo"].setPixmapNum(1) # active
1091 self["NetworkInfo_Text"].setForegroundColorNum(2) # active
1093 self["NetworkInfo"].setPixmapNum(0)
1094 self["NetworkInfo_Text"].setForegroundColorNum(1)
1095 self["IPInfo"].setPixmapNum(0)
1096 self["IPInfo_Text"].setForegroundColorNum(1)
1097 self["DhcpInfo"].setPixmapNum(1) # active
1098 self["DhcpInfo_Text"].setForegroundColorNum(2) # active
1100 self["DhcpInfo"].setPixmapNum(0)
1101 self["DhcpInfo_Text"].setForegroundColorNum(1)
1102 self["DNSInfo"].setPixmapNum(0)
1103 self["DNSInfo_Text"].setForegroundColorNum(1)
1104 self["IPInfo"].setPixmapNum(1) # active
1105 self["IPInfo_Text"].setForegroundColorNum(2) # active
1107 self["IPInfo"].setPixmapNum(0)
1108 self["IPInfo_Text"].setForegroundColorNum(1)
1109 self["EditSettingsButton"].setPixmapNum(0)
1110 self["EditSettings_Text"].setForegroundColorNum(0)
1111 self["DNSInfo"].setPixmapNum(1) # active
1112 self["DNSInfo_Text"].setForegroundColorNum(2) # active
1114 self["DNSInfo"].setPixmapNum(0)
1115 self["DNSInfo_Text"].setForegroundColorNum(1)
1116 self["EditSettingsButton"].setPixmapNum(1) # active
1117 self["EditSettings_Text"].setForegroundColorNum(2) # active
1118 self["AdapterInfo"].setPixmapNum(0)
1119 self["AdapterInfo_Text"].setForegroundColorNum(1)
1122 next = self.nextstep
1138 self.steptimer = True
1139 self.nextStepTimer.start(3000)
1140 self["ButtonYellow_Check"].show()
1141 self["ButtonYellowtext"].show()
1144 self["Adapter"].setText(iNetwork.getFriendlyAdapterName(self.iface))
1145 self["Adapter"].setForegroundColorNum(2)
1146 self["Adaptertext"].setForegroundColorNum(1)
1147 self["AdapterInfo_Text"].setForegroundColorNum(1)
1148 self["AdapterInfo_OK"].show()
1149 self.steptimer = True
1150 self.nextStepTimer.start(3000)
1153 self["Networktext"].setForegroundColorNum(1)
1154 self["Network"].setText(_("Please wait..."))
1155 self.getLinkState(self.iface)
1156 self["NetworkInfo_Text"].setForegroundColorNum(1)
1157 self.steptimer = True
1158 self.nextStepTimer.start(3000)
1161 self["Dhcptext"].setForegroundColorNum(1)
1162 if iNetwork.getAdapterAttribute(self.iface, 'dhcp') is True:
1163 self["Dhcp"].setForegroundColorNum(2)
1164 self["Dhcp"].setText(_("enabled"))
1165 self["DhcpInfo_Check"].setPixmapNum(0)
1167 self["Dhcp"].setForegroundColorNum(1)
1168 self["Dhcp"].setText(_("disabled"))
1169 self["DhcpInfo_Check"].setPixmapNum(1)
1170 self["DhcpInfo_Check"].show()
1171 self["DhcpInfo_Text"].setForegroundColorNum(1)
1172 self.steptimer = True
1173 self.nextStepTimer.start(3000)
1176 self["IPtext"].setForegroundColorNum(1)
1177 self["IP"].setText(_("Please wait..."))
1178 iNetwork.checkNetworkState(self.NetworkStatedataAvail)
1181 self.steptimer = False
1182 self.nextStepTimer.stop()
1183 self["DNStext"].setForegroundColorNum(1)
1184 self["DNS"].setText(_("Please wait..."))
1185 iNetwork.checkDNSLookup(self.DNSLookupdataAvail)
1188 self["shortcutsgreen"].setEnabled(False)
1189 self["shortcutsyellow"].setEnabled(True)
1190 self["updown_actions"].setEnabled(False)
1191 self["ButtonYellow_Check"].setPixmapNum(0)
1192 self["ButtonGreen_Check"].setPixmapNum(1)
1193 self.steptimer = True
1194 self.nextStepTimer.start(1000)
1196 def KeyGreenRestart(self):
1198 self.layoutFinished()
1199 self["Adapter"].setText((""))
1200 self["Network"].setText((""))
1201 self["Dhcp"].setText((""))
1202 self["IP"].setText((""))
1203 self["DNS"].setText((""))
1204 self["AdapterInfo_Text"].setForegroundColorNum(0)
1205 self["NetworkInfo_Text"].setForegroundColorNum(0)
1206 self["DhcpInfo_Text"].setForegroundColorNum(0)
1207 self["IPInfo_Text"].setForegroundColorNum(0)
1208 self["DNSInfo_Text"].setForegroundColorNum(0)
1209 self["shortcutsgreen_restart"].setEnabled(False)
1210 self["shortcutsgreen"].setEnabled(False)
1211 self["shortcutsyellow"].setEnabled(True)
1212 self["updown_actions"].setEnabled(False)
1213 self["ButtonYellow_Check"].setPixmapNum(0)
1214 self["ButtonGreen_Check"].setPixmapNum(1)
1215 self.steptimer = True
1216 self.nextStepTimer.start(1000)
1219 self["infoshortcuts"].setEnabled(True)
1220 self["shortcuts"].setEnabled(False)
1221 if self.activebutton == 1: # Adapter Check
1222 self["InfoText"].setText(_("This test detects your configured LAN-Adapter."))
1223 self["InfoTextBorder"].show()
1224 self["InfoText"].show()
1225 self["ButtonRedtext"].setText(_("Back"))
1226 if self.activebutton == 2: #LAN Check
1227 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"))
1228 self["InfoTextBorder"].show()
1229 self["InfoText"].show()
1230 self["ButtonRedtext"].setText(_("Back"))
1231 if self.activebutton == 3: #DHCP Check
1232 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."))
1233 self["InfoTextBorder"].show()
1234 self["InfoText"].show()
1235 self["ButtonRedtext"].setText(_("Back"))
1236 if self.activebutton == 4: # IP Check
1237 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"))
1238 self["InfoTextBorder"].show()
1239 self["InfoText"].show()
1240 self["ButtonRedtext"].setText(_("Back"))
1241 if self.activebutton == 5: # DNS Check
1242 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"))
1243 self["InfoTextBorder"].show()
1244 self["InfoText"].show()
1245 self["ButtonRedtext"].setText(_("Back"))
1246 if self.activebutton == 6: # Edit Settings
1247 self.session.open(AdapterSetup,self.iface)
1249 def KeyYellow(self):
1251 self["shortcutsgreen_restart"].setEnabled(True)
1252 self["shortcutsgreen"].setEnabled(False)
1253 self["shortcutsyellow"].setEnabled(False)
1254 self["ButtonGreentext"].setText(_("Restart test"))
1255 self["ButtonYellow_Check"].setPixmapNum(1)
1256 self["ButtonGreen_Check"].setPixmapNum(0)
1257 self.steptimer = False
1258 self.nextStepTimer.stop()
1260 def layoutFinished(self):
1261 self["shortcutsyellow"].setEnabled(False)
1262 self["AdapterInfo_OK"].hide()
1263 self["NetworkInfo_Check"].hide()
1264 self["DhcpInfo_Check"].hide()
1265 self["IPInfo_Check"].hide()
1266 self["DNSInfo_Check"].hide()
1267 self["EditSettings_Text"].hide()
1268 self["EditSettingsButton"].hide()
1269 self["InfoText"].hide()
1270 self["InfoTextBorder"].hide()
1271 self["ButtonYellow_Check"].hide()
1272 self["ButtonYellowtext"].hide()
1274 def setLabels(self):
1275 self["Adaptertext"] = MultiColorLabel(_("LAN Adapter"))
1276 self["Adapter"] = MultiColorLabel()
1277 self["AdapterInfo"] = MultiPixmap()
1278 self["AdapterInfo_Text"] = MultiColorLabel(_("Show Info"))
1279 self["AdapterInfo_OK"] = Pixmap()
1281 if self.iface == 'wlan0' or self.iface == 'ath0':
1282 self["Networktext"] = MultiColorLabel(_("Wireless Network"))
1284 self["Networktext"] = MultiColorLabel(_("Local Network"))
1286 self["Network"] = MultiColorLabel()
1287 self["NetworkInfo"] = MultiPixmap()
1288 self["NetworkInfo_Text"] = MultiColorLabel(_("Show Info"))
1289 self["NetworkInfo_Check"] = MultiPixmap()
1291 self["Dhcptext"] = MultiColorLabel(_("DHCP"))
1292 self["Dhcp"] = MultiColorLabel()
1293 self["DhcpInfo"] = MultiPixmap()
1294 self["DhcpInfo_Text"] = MultiColorLabel(_("Show Info"))
1295 self["DhcpInfo_Check"] = MultiPixmap()
1297 self["IPtext"] = MultiColorLabel(_("IP Address"))
1298 self["IP"] = MultiColorLabel()
1299 self["IPInfo"] = MultiPixmap()
1300 self["IPInfo_Text"] = MultiColorLabel(_("Show Info"))
1301 self["IPInfo_Check"] = MultiPixmap()
1303 self["DNStext"] = MultiColorLabel(_("Nameserver"))
1304 self["DNS"] = MultiColorLabel()
1305 self["DNSInfo"] = MultiPixmap()
1306 self["DNSInfo_Text"] = MultiColorLabel(_("Show Info"))
1307 self["DNSInfo_Check"] = MultiPixmap()
1309 self["EditSettings_Text"] = MultiColorLabel(_("Edit settings"))
1310 self["EditSettingsButton"] = MultiPixmap()
1312 self["ButtonRedtext"] = Label(_("Close"))
1313 self["ButtonRed"] = Pixmap()
1315 self["ButtonGreentext"] = Label(_("Start test"))
1316 self["ButtonGreen_Check"] = MultiPixmap()
1318 self["ButtonYellowtext"] = Label(_("Stop test"))
1319 self["ButtonYellow_Check"] = MultiPixmap()
1321 self["InfoTextBorder"] = Pixmap()
1322 self["InfoText"] = Label()
1324 def getLinkState(self,iface):
1325 if iface == 'wlan0' or iface == 'ath0':
1327 from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus,Status
1329 self["Network"].setForegroundColorNum(1)
1330 self["Network"].setText(_("disconnected"))
1331 self["NetworkInfo_Check"].setPixmapNum(1)
1332 self["NetworkInfo_Check"].show()
1334 iStatus.getDataForInterface(self.iface,self.getInfoCB)
1336 iNetwork.getLinkState(iface,self.LinkStatedataAvail)
1338 def LinkStatedataAvail(self,data):
1339 self.output = data.strip()
1340 result = self.output.split('\n')
1341 pattern = re_compile("Link detected: yes")
1343 if re_search(pattern, item):
1344 self["Network"].setForegroundColorNum(2)
1345 self["Network"].setText(_("connected"))
1346 self["NetworkInfo_Check"].setPixmapNum(0)
1348 self["Network"].setForegroundColorNum(1)
1349 self["Network"].setText(_("disconnected"))
1350 self["NetworkInfo_Check"].setPixmapNum(1)
1351 self["NetworkInfo_Check"].show()
1353 def NetworkStatedataAvail(self,data):
1355 self["IP"].setForegroundColorNum(2)
1356 self["IP"].setText(_("confirmed"))
1357 self["IPInfo_Check"].setPixmapNum(0)
1359 self["IP"].setForegroundColorNum(1)
1360 self["IP"].setText(_("unconfirmed"))
1361 self["IPInfo_Check"].setPixmapNum(1)
1362 self["IPInfo_Check"].show()
1363 self["IPInfo_Text"].setForegroundColorNum(1)
1364 self.steptimer = True
1365 self.nextStepTimer.start(3000)
1367 def DNSLookupdataAvail(self,data):
1369 self["DNS"].setForegroundColorNum(2)
1370 self["DNS"].setText(_("confirmed"))
1371 self["DNSInfo_Check"].setPixmapNum(0)
1373 self["DNS"].setForegroundColorNum(1)
1374 self["DNS"].setText(_("unconfirmed"))
1375 self["DNSInfo_Check"].setPixmapNum(1)
1376 self["DNSInfo_Check"].show()
1377 self["DNSInfo_Text"].setForegroundColorNum(1)
1378 self["EditSettings_Text"].show()
1379 self["EditSettingsButton"].setPixmapNum(1)
1380 self["EditSettings_Text"].setForegroundColorNum(2) # active
1381 self["EditSettingsButton"].show()
1382 self["ButtonYellow_Check"].setPixmapNum(1)
1383 self["ButtonGreentext"].setText(_("Restart test"))
1384 self["ButtonGreen_Check"].setPixmapNum(0)
1385 self["shortcutsgreen"].setEnabled(False)
1386 self["shortcutsgreen_restart"].setEnabled(True)
1387 self["shortcutsyellow"].setEnabled(False)
1388 self["updown_actions"].setEnabled(True)
1389 self.activebutton = 6
1391 def getInfoCB(self,data,status):
1392 if data is not None:
1394 if status is not None:
1395 if status[self.iface]["acesspoint"] == "No Connection" or status[self.iface]["acesspoint"] == "Not-Associated" or status[self.iface]["acesspoint"] == False:
1396 self["Network"].setForegroundColorNum(1)
1397 self["Network"].setText(_("disconnected"))
1398 self["NetworkInfo_Check"].setPixmapNum(1)
1399 self["NetworkInfo_Check"].show()
1401 self["Network"].setForegroundColorNum(2)
1402 self["Network"].setText(_("connected"))
1403 self["NetworkInfo_Check"].setPixmapNum(0)
1404 self["NetworkInfo_Check"].show()
1407 iNetwork.stopLinkStateConsole()
1408 iNetwork.stopDNSConsole()
1410 from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus,Status
1414 iStatus.stopWlanConsole()