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 networkadapter found.\nPlease verify that you have attached a compatible WLAN USB Stick and your Network is configured correctly.")
54 self.lan_errortext = _("No working local networkadapter 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 networkinterface list")),
71 "ok": (self.okbuttonClick, _("select interface")),
74 self["ColorActions"] = HelpableActionMap(self, "ColorActions",
76 "red": (self.close, _("exit networkinterface list")),
79 self["DefaultInterfaceAction"] = HelpableActionMap(self, "ColorActions",
81 "blue": (self.setDefaultInterface, [_("Set interface as default Interface"),_("* Only available if more then 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)
93 iNetwork.getInterfaces()
96 num_configured_if = len(iNetwork.getConfiguredAdapters())
97 if num_configured_if >= 2:
98 self["ButtonBlue"].show()
99 self["ButtonBluetext"].show()
100 self["DefaultInterfaceAction"].setEnabled(True)
102 self["ButtonBlue"].hide()
103 self["ButtonBluetext"].hide()
104 self["DefaultInterfaceAction"].setEnabled(False)
106 if num_configured_if < 2 and os_path.exists("/etc/default_gw"):
107 unlink("/etc/default_gw")
109 if os_path.exists("/etc/default_gw"):
110 fp = file('/etc/default_gw', 'r')
115 if len(self.adapters) == 0: # no interface available => display only eth0
116 self.list.append(InterfaceEntryComponent("eth0",iNetwork.getFriendlyAdapterName('eth0'),True,True ))
118 for x in self.adapters:
119 if x[1] == default_gw:
123 if iNetwork.getAdapterAttribute(x[1], 'up') is True:
127 self.list.append(InterfaceEntryComponent(index = x[1],name = _(x[0]),default=default_int,active=active_int ))
128 self["list"].l.setList(self.list)
130 def setDefaultInterface(self):
131 selection = self["list"].getCurrent()
132 num_if = len(self.list)
133 old_default_gw = None
134 num_configured_if = len(iNetwork.getConfiguredAdapters())
135 if os_path.exists("/etc/default_gw"):
136 fp = open('/etc/default_gw', 'r')
137 old_default_gw = fp.read()
139 if num_configured_if > 1 and (not old_default_gw or old_default_gw != selection[0]):
140 fp = open('/etc/default_gw', 'w+')
141 fp.write(selection[0])
144 elif old_default_gw and num_configured_if < 2:
145 unlink("/etc/default_gw")
148 def okbuttonClick(self):
149 selection = self["list"].getCurrent()
150 if selection is not None:
151 self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetupConfiguration, selection[0])
153 def AdapterSetupClosed(self, *ret):
154 if len(self.adapters) == 1:
159 def NetworkFallback(self):
160 if iNetwork.configuredNetworkAdapters.has_key('wlan0') is True:
161 self.session.openWithCallback(self.ErrorMessageClosed, MessageBox, self.wlan_errortext, type = MessageBox.TYPE_INFO,timeout = 10)
162 if iNetwork.configuredNetworkAdapters.has_key('ath0') is True:
163 self.session.openWithCallback(self.ErrorMessageClosed, MessageBox, self.wlan_errortext, type = MessageBox.TYPE_INFO,timeout = 10)
165 self.session.openWithCallback(self.ErrorMessageClosed, MessageBox, self.lan_errortext, type = MessageBox.TYPE_INFO,timeout = 10)
167 def ErrorMessageClosed(self, *ret):
168 if iNetwork.configuredNetworkAdapters.has_key('wlan0') is True:
169 self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetupConfiguration, 'wlan0')
170 elif iNetwork.configuredNetworkAdapters.has_key('ath0') is True:
171 self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetupConfiguration, 'ath0')
173 self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetupConfiguration, 'eth0')
176 iNetwork.stopLinkStateConsole()
177 iNetwork.stopRestartConsole()
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")),
225 ConfigListScreen.__init__(self, self.list)
228 def createConfig(self):
229 self.nameservers = iNetwork.getNameserverList()
230 self.nameserverEntries = []
232 for nameserver in self.nameservers:
233 self.nameserverEntries.append(NoSave(ConfigIP(default=nameserver)))
235 def createSetup(self):
238 for i in range(len(self.nameserverEntries)):
239 self.list.append(getConfigListEntry(_("Nameserver %d") % (i + 1), self.nameserverEntries[i]))
241 self["config"].list = self.list
242 self["config"].l.setList(self.list)
245 iNetwork.clearNameservers()
246 for nameserver in self.nameserverEntries:
247 iNetwork.addNameserver(nameserver.value)
248 iNetwork.writeNameserverConfig()
255 iNetwork.clearNameservers()
256 print "backup-list:", self.backupNameserverList
257 for nameserver in self.backupNameserverList:
258 iNetwork.addNameserver(nameserver)
262 iNetwork.addNameserver([0,0,0,0])
267 print "currentIndex:", self["config"].getCurrentIndex()
269 index = self["config"].getCurrentIndex()
270 if index < len(self.nameservers):
271 iNetwork.removeNameserver(self.nameservers[index])
275 class AdapterSetup(Screen, ConfigListScreen, HelpableScreen):
276 def __init__(self, session, iface,essid=None, aplist=None):
277 Screen.__init__(self, session)
278 HelpableScreen.__init__(self)
279 self.session = session
284 self.applyConfigRef = None
285 self.finished_cb = None
286 self.oktext = _("Press OK on your remote control to continue.")
287 self.oldInterfaceState = iNetwork.getAdapterAttribute(self.iface, "up")
291 self["OkCancelActions"] = HelpableActionMap(self, "OkCancelActions",
293 "cancel": (self.cancel, _("exit networkadapter setup menu")),
294 "ok": (self.ok, _("select menu entry")),
297 self["ColorActions"] = HelpableActionMap(self, "ColorActions",
299 "red": (self.cancel, _("exit networkadapter configuration")),
300 "blue": (self.KeyBlue, _("open nameserver configuration")),
303 self["VirtualKB"] = HelpableActionMap(self, "ColorActions",
305 "green": (self.KeyGreen, [_("open virtual keyboard input help"),_("* Only available when entering hidden ssid or network key")] ),
308 self["actions"] = NumberActionMap(["SetupActions"],
315 ConfigListScreen.__init__(self, self.list,session = self.session)
317 self.onLayoutFinish.append(self.layoutFinished)
318 self.onClose.append(self.cleanup)
320 self["DNS1text"] = Label(_("Primary DNS"))
321 self["DNS2text"] = Label(_("Secondary DNS"))
322 self["DNS1"] = Label()
323 self["DNS2"] = Label()
325 self["introduction"] = Label(_("Current settings:"))
327 self["IPtext"] = Label(_("IP Address"))
328 self["Netmasktext"] = Label(_("Netmask"))
329 self["Gatewaytext"] = Label(_("Gateway"))
332 self["Mask"] = Label()
333 self["Gateway"] = Label()
335 self["BottomBG"] = Pixmap()
336 self["Adaptertext"] = Label(_("Network:"))
337 self["Adapter"] = Label()
338 self["introduction2"] = Label(_("Press OK to activate the settings."))
339 self["ButtonRed"] = Pixmap()
340 self["ButtonRedtext"] = Label(_("Close"))
341 self["ButtonBlue"] = Pixmap()
342 self["ButtonBluetext"] = Label(_("Edit DNS"))
343 self["ButtonGreen"] = Pixmap()
344 self["VKeyIcon"] = Pixmap()
345 self["HelpWindow"] = Pixmap()
347 def layoutFinished(self):
348 self["DNS1"].setText(self.primaryDNS.getText())
349 self["DNS2"].setText(self.secondaryDNS.getText())
350 if self.ipConfigEntry.getText() is not None:
351 if self.ipConfigEntry.getText() == "0.0.0.0":
352 self["IP"].setText(_("N/A"))
354 self["IP"].setText(self.ipConfigEntry.getText())
356 self["IP"].setText(_("N/A"))
357 if self.netmaskConfigEntry.getText() is not None:
358 if self.netmaskConfigEntry.getText() == "0.0.0.0":
359 self["Mask"].setText(_("N/A"))
361 self["Mask"].setText(self.netmaskConfigEntry.getText())
363 self["IP"].setText(_("N/A"))
364 if iNetwork.getAdapterAttribute(self.iface, "gateway"):
365 if self.gatewayConfigEntry.getText() == "0.0.0.0":
366 self["Gateway"].setText(_("N/A"))
368 self["Gateway"].setText(self.gatewayConfigEntry.getText())
370 self["Gateway"].hide()
371 self["Gatewaytext"].hide()
372 self["Adapter"].setText(iNetwork.getFriendlyAdapterName(self.iface))
373 self["ButtonGreen"].hide()
374 self["VKeyIcon"].hide()
375 self["VirtualKB"].setEnabled(False)
376 self["HelpWindow"].hide()
378 def createConfig(self):
379 self.InterfaceEntry = None
380 self.dhcpEntry = None
381 self.gatewayEntry = None
382 self.hiddenSSID = None
384 self.encryptionEnabled = None
385 self.encryptionKey = None
386 self.encryptionType = None
388 self.encryptionlist = None
393 if self.iface == "wlan0" or self.iface == "ath0" :
394 from Plugins.SystemPlugins.WirelessLan.Wlan import wpaSupplicant,Wlan
395 self.w = Wlan(self.iface)
396 self.ws = wpaSupplicant()
397 self.encryptionlist = []
398 self.encryptionlist.append(("WEP", _("WEP")))
399 self.encryptionlist.append(("WPA", _("WPA")))
400 self.encryptionlist.append(("WPA2", _("WPA2")))
401 self.encryptionlist.append(("WPA/WPA2", _("WPA or WPA2")))
403 self.weplist.append("ASCII")
404 self.weplist.append("HEX")
405 if self.aplist is not None:
406 self.nwlist = self.aplist
407 self.nwlist.sort(key = lambda x: x[0])
412 self.aps = self.w.getNetworkList()
413 if self.aps is not None:
414 print "[NetworkSetup.py] got Accespoints!"
419 a['essid'] = a['bssid']
420 self.nwlist.append( a['essid'])
421 self.nwlist.sort(key = lambda x: x[0])
423 self.nwlist.append("No Networks found")
425 self.wsconfig = self.ws.loadConfig()
426 if self.essid is not None: # ssid from wlan scan
427 self.default = self.essid
429 self.default = self.wsconfig['ssid']
431 if "hidden..." not in self.nwlist:
432 self.nwlist.append("hidden...")
433 if self.default not in self.nwlist:
434 self.nwlist.append(self.default)
436 config.plugins.wlan.essid = NoSave(ConfigSelection(self.nwlist, default = self.default ))
437 config.plugins.wlan.hiddenessid = NoSave(ConfigText(default = self.wsconfig['hiddenessid'], visible_width = 50, fixed_size = False))
439 config.plugins.wlan.encryption.enabled = NoSave(ConfigYesNo(default = self.wsconfig['encryption'] ))
440 config.plugins.wlan.encryption.type = NoSave(ConfigSelection(self.encryptionlist, default = self.wsconfig['encryption_type'] ))
441 config.plugins.wlan.encryption.wepkeytype = NoSave(ConfigSelection(self.weplist, default = self.wsconfig['encryption_wepkeytype'] ))
442 config.plugins.wlan.encryption.psk = NoSave(ConfigPassword(default = self.wsconfig['key'], visible_width = 50, fixed_size = False))
444 self.activateInterfaceEntry = NoSave(ConfigYesNo(default=iNetwork.getAdapterAttribute(self.iface, "up") or False))
445 self.dhcpConfigEntry = NoSave(ConfigYesNo(default=iNetwork.getAdapterAttribute(self.iface, "dhcp") or False))
446 self.ipConfigEntry = NoSave(ConfigIP(default=iNetwork.getAdapterAttribute(self.iface, "ip")) or [0,0,0,0])
447 self.netmaskConfigEntry = NoSave(ConfigIP(default=iNetwork.getAdapterAttribute(self.iface, "netmask") or [255,0,0,0]))
448 if iNetwork.getAdapterAttribute(self.iface, "gateway"):
449 self.dhcpdefault=True
451 self.dhcpdefault=False
452 self.hasGatewayConfigEntry = NoSave(ConfigYesNo(default=self.dhcpdefault or False))
453 self.gatewayConfigEntry = NoSave(ConfigIP(default=iNetwork.getAdapterAttribute(self.iface, "gateway") or [0,0,0,0]))
454 nameserver = (iNetwork.getNameserverList() + [[0,0,0,0]] * 2)[0:2]
455 self.primaryDNS = NoSave(ConfigIP(default=nameserver[0]))
456 self.secondaryDNS = NoSave(ConfigIP(default=nameserver[1]))
458 def createSetup(self):
460 self.InterfaceEntry = getConfigListEntry(_("Use Interface"), self.activateInterfaceEntry)
462 self.list.append(self.InterfaceEntry)
463 if self.activateInterfaceEntry.value:
464 self.dhcpEntry = getConfigListEntry(_("Use DHCP"), self.dhcpConfigEntry)
465 self.list.append(self.dhcpEntry)
466 if not self.dhcpConfigEntry.value:
467 self.list.append(getConfigListEntry(_('IP Address'), self.ipConfigEntry))
468 self.list.append(getConfigListEntry(_('Netmask'), self.netmaskConfigEntry))
469 self.gatewayEntry = getConfigListEntry(_('Use a gateway'), self.hasGatewayConfigEntry)
470 self.list.append(self.gatewayEntry)
471 if self.hasGatewayConfigEntry.value:
472 self.list.append(getConfigListEntry(_('Gateway'), self.gatewayConfigEntry))
475 for p in plugins.getPlugins(PluginDescriptor.WHERE_NETWORKSETUP):
476 callFnc = p.__call__["ifaceSupported"](self.iface)
477 if callFnc is not None:
478 if p.__call__.has_key("WlanPluginEntry"): # internally used only for WLAN Plugin
479 self.extended = callFnc
480 if p.__call__.has_key("configStrings"):
481 self.configStrings = p.__call__["configStrings"]
483 self.configStrings = None
484 if config.plugins.wlan.essid.value == 'hidden...':
485 self.wlanSSID = getConfigListEntry(_("Network SSID"), config.plugins.wlan.essid)
486 self.list.append(self.wlanSSID)
487 self.hiddenSSID = getConfigListEntry(_("Hidden network SSID"), config.plugins.wlan.hiddenessid)
488 self.list.append(self.hiddenSSID)
490 self.wlanSSID = getConfigListEntry(_("Network SSID"), config.plugins.wlan.essid)
491 self.list.append(self.wlanSSID)
492 self.encryptionEnabled = getConfigListEntry(_("Encryption"), config.plugins.wlan.encryption.enabled)
493 self.list.append(self.encryptionEnabled)
495 if config.plugins.wlan.encryption.enabled.value:
496 self.encryptionType = getConfigListEntry(_("Encryption Type"), config.plugins.wlan.encryption.type)
497 self.list.append(self.encryptionType)
498 if config.plugins.wlan.encryption.type.value == 'WEP':
499 self.list.append(getConfigListEntry(_("Encryption Keytype"), config.plugins.wlan.encryption.wepkeytype))
500 self.encryptionKey = getConfigListEntry(_("Encryption Key"), config.plugins.wlan.encryption.psk)
501 self.list.append(self.encryptionKey)
503 self.encryptionKey = getConfigListEntry(_("Encryption Key"), config.plugins.wlan.encryption.psk)
504 self.list.append(self.encryptionKey)
507 self["config"].list = self.list
508 self["config"].l.setList(self.list)
509 if not self.selectionChanged in self["config"].onSelectionChanged:
510 self["config"].onSelectionChanged.append(self.selectionChanged)
513 self.session.openWithCallback(self.NameserverSetupClosed, NameserverSetup)
516 if self.iface == "wlan0" or self.iface == "ath0" :
517 if self["config"].getCurrent() == self.hiddenSSID:
518 if config.plugins.wlan.essid.value == 'hidden...':
519 self.session.openWithCallback(self.VirtualKeyBoardSSIDCallback, VirtualKeyBoard, title = (_("Enter WLAN networkname/SSID:")), text = config.plugins.wlan.essid.value)
520 if self["config"].getCurrent() == self.encryptionKey:
521 self.session.openWithCallback(self.VirtualKeyBoardKeyCallback, VirtualKeyBoard, title = (_("Enter WLAN passphrase/key:")), text = config.plugins.wlan.encryption.psk.value)
523 def VirtualKeyBoardSSIDCallback(self, callback = None):
524 if callback is not None and len(callback):
525 config.plugins.wlan.hiddenessid = NoSave(ConfigText(default = callback, visible_width = 50, fixed_size = False))
528 def VirtualKeyBoardKeyCallback(self, callback = None):
529 if callback is not None and len(callback):
530 config.plugins.wlan.encryption.psk = NoSave(ConfigPassword(default = callback, visible_width = 50, fixed_size = False))
534 if self["config"].getCurrent() == self.InterfaceEntry:
536 if self["config"].getCurrent() == self.dhcpEntry:
538 if self["config"].getCurrent() == self.gatewayEntry:
540 if self.iface == "wlan0" or self.iface == "ath0" :
541 if self["config"].getCurrent() == self.wlanSSID:
543 if self["config"].getCurrent() == self.encryptionEnabled:
545 if self["config"].getCurrent() == self.encryptionType:
548 ConfigListScreen.keyLeft(self)
552 ConfigListScreen.keyRight(self)
555 def selectionChanged(self):
556 current = self["config"].getCurrent()
557 if current == self.hiddenSSID and config.plugins.wlan.essid.value == 'hidden...':
558 helpwindowpos = self["HelpWindow"].getPosition()
559 if current[1].help_window.instance is not None:
560 current[1].help_window.instance.move(ePoint(helpwindowpos[0],helpwindowpos[1]))
561 self["ButtonGreen"].show()
562 self["VKeyIcon"].show()
563 self["VirtualKB"].setEnabled(True)
564 elif current == self.encryptionKey and config.plugins.wlan.encryption.enabled.value:
565 helpwindowpos = self["HelpWindow"].getPosition()
566 if current[1].help_window.instance is not None:
567 current[1].help_window.instance.move(ePoint(helpwindowpos[0],helpwindowpos[1]))
568 self["ButtonGreen"].show()
569 self["VKeyIcon"].show()
570 self["VirtualKB"].setEnabled(True)
572 self["ButtonGreen"].hide()
573 self["VKeyIcon"].hide()
574 self["VirtualKB"].setEnabled(False)
577 current = self["config"].getCurrent()
578 if current == self.hiddenSSID and config.plugins.wlan.essid.value == 'hidden...':
579 if current[1].help_window.instance is not None:
580 current[1].help_window.instance.hide()
581 elif current == self.encryptionKey and config.plugins.wlan.encryption.enabled.value:
582 if current[1].help_window.instance is not None:
583 current[1].help_window.instance.hide()
584 self.session.openWithCallback(self.applyConfig, MessageBox, (_("Are you sure you want to activate this network configuration?\n\n") + self.oktext ) )
586 def applyConfig(self, ret = False):
588 iNetwork.setAdapterAttribute(self.iface, "up", self.activateInterfaceEntry.value)
589 iNetwork.setAdapterAttribute(self.iface, "dhcp", self.dhcpConfigEntry.value)
590 iNetwork.setAdapterAttribute(self.iface, "ip", self.ipConfigEntry.value)
591 iNetwork.setAdapterAttribute(self.iface, "netmask", self.netmaskConfigEntry.value)
592 if self.hasGatewayConfigEntry.value:
593 iNetwork.setAdapterAttribute(self.iface, "gateway", self.gatewayConfigEntry.value)
595 iNetwork.removeAdapterAttribute(self.iface, "gateway")
596 if self.extended is not None and self.configStrings is not None:
597 iNetwork.setAdapterAttribute(self.iface, "configStrings", self.configStrings(self.iface))
598 self.ws.writeConfig()
599 if self.activateInterfaceEntry.value is False:
600 iNetwork.deactivateInterface(self.iface)
601 iNetwork.writeNetworkConfig()
602 iNetwork.restartNetwork(self.applyConfigDataAvail)
603 self.applyConfigRef = self.session.openWithCallback(self.applyConfigfinishedCB, MessageBox, _("Please wait while activating your network configuration..."), type = MessageBox.TYPE_INFO, enable_input = False)
607 def applyConfigDataAvail(self, data):
609 iNetwork.getInterfaces(self.getInterfacesDataAvail)
611 def getInterfacesDataAvail(self, data):
613 self.applyConfigRef.close(True)
615 def applyConfigfinishedCB(self,data):
617 num_configured_if = len(iNetwork.getConfiguredAdapters())
618 if num_configured_if >= 2:
619 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 networkinterface?"), default = True)
622 self.session.openWithCallback(self.finished_cb, MessageBox, _("Your network configuration has been activated."), type = MessageBox.TYPE_INFO, timeout = 10)
624 self.session.openWithCallback(self.ConfigfinishedCB, MessageBox, _("Your network configuration has been activated."), type = MessageBox.TYPE_INFO, timeout = 10)
626 def secondIfaceFoundCB(self,data):
630 configuredInterfaces = iNetwork.getConfiguredAdapters()
631 for interface in configuredInterfaces:
632 if interface == self.iface:
634 iNetwork.setAdapterAttribute(interface, "up", False)
635 iNetwork.deactivateInterface(interface)
636 self.applyConfig(True)
638 def ConfigfinishedCB(self,data):
644 if self.oldInterfaceState is False:
645 iNetwork.deactivateInterface(self.iface,self.deactivateInterfaceCB)
649 def deactivateInterfaceCB(self,data):
652 iNetwork.getInterfaces(self.cancelCB)
654 def cancelCB(self,data):
659 def runAsync(self, finished_cb):
660 self.finished_cb = finished_cb
663 def NameserverSetupClosed(self, *ret):
664 iNetwork.loadNameserverConfig()
665 nameserver = (iNetwork.getNameserverList() + [[0,0,0,0]] * 2)[0:2]
666 self.primaryDNS = NoSave(ConfigIP(default=nameserver[0]))
667 self.secondaryDNS = NoSave(ConfigIP(default=nameserver[1]))
669 self.layoutFinished()
672 iNetwork.stopLinkStateConsole()
673 iNetwork.stopDeactivateInterfaceConsole()
676 class AdapterSetupConfiguration(Screen, HelpableScreen):
677 def __init__(self, session,iface):
678 Screen.__init__(self, session)
679 HelpableScreen.__init__(self)
680 self.session = session
682 self.restartLanRef = None
683 self.mainmenu = self.genMainMenu()
684 self["menulist"] = MenuList(self.mainmenu)
685 self["description"] = Label()
686 self["IFtext"] = Label()
688 self["BottomBG"] = Label()
689 self["Statustext"] = Label()
690 self["statuspic"] = MultiPixmap()
691 self["statuspic"].hide()
692 self["BottomBG"] = Pixmap()
693 self["ButtonRed"] = Pixmap()
694 self["ButtonRedtext"] = Label(_("Close"))
696 self.oktext = _("Press OK on your remote control to continue.")
697 self.reboottext = _("Your Dreambox will restart after pressing OK on your remote control.")
698 self.errortext = _("No working wireless interface found.\n Please verify that you have attached a compatible WLAN device or enable you local network interface.")
700 self["WizardActions"] = HelpableActionMap(self, "WizardActions",
702 "up": (self.up, _("move up to previous entry")),
703 "down": (self.down, _("move down to next entry")),
704 "left": (self.left, _("move up to first entry")),
705 "right": (self.right, _("move down to last entry")),
708 self["OkCancelActions"] = HelpableActionMap(self, "OkCancelActions",
710 "cancel": (self.close, _("exit networkadapter setup menu")),
711 "ok": (self.ok, _("select menu entry")),
714 self["ColorActions"] = HelpableActionMap(self, "ColorActions",
716 "red": (self.close, _("exit networkadapter setup menu")),
719 self["actions"] = NumberActionMap(["WizardActions","ShortcutActions"],
730 iNetwork.getInterfaces(self.updateStatusbar)
731 self.onLayoutFinish.append(self.layoutFinished)
732 self.onClose.append(self.cleanup)
735 if self["menulist"].getCurrent()[1] == 'edit':
736 if self.iface == 'wlan0' or self.iface == 'ath0':
738 from Plugins.SystemPlugins.WirelessLan.plugin import WlanScan
739 from Plugins.SystemPlugins.WirelessLan.iwlibs import Wireless
741 self.session.open(MessageBox, _("The wireless LAN plugin is not installed!\nPlease install it."), type = MessageBox.TYPE_INFO,timeout = 10 )
743 ifobj = Wireless(self.iface) # a Wireless NIC Object
744 self.wlanresponse = ifobj.getStatistics()
745 if self.wlanresponse[0] != 19: # Wlan Interface found.
746 self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetup,self.iface)
748 # Display Wlan not available Message
749 self.showErrorMessage()
751 self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetup,self.iface)
752 if self["menulist"].getCurrent()[1] == 'test':
753 self.session.open(NetworkAdapterTest,self.iface)
754 if self["menulist"].getCurrent()[1] == 'dns':
755 self.session.open(NameserverSetup)
756 if self["menulist"].getCurrent()[1] == 'scanwlan':
758 from Plugins.SystemPlugins.WirelessLan.plugin import WlanScan
759 from Plugins.SystemPlugins.WirelessLan.iwlibs import Wireless
761 self.session.open(MessageBox, _("The wireless LAN plugin is not installed!\nPlease install it."), type = MessageBox.TYPE_INFO,timeout = 10 )
763 ifobj = Wireless(self.iface) # a Wireless NIC Object
764 self.wlanresponse = ifobj.getStatistics()
765 if self.wlanresponse[0] != 19:
766 self.session.openWithCallback(self.WlanScanClosed, WlanScan, self.iface)
768 # Display Wlan not available Message
769 self.showErrorMessage()
770 if self["menulist"].getCurrent()[1] == 'wlanstatus':
772 from Plugins.SystemPlugins.WirelessLan.plugin import WlanStatus
773 from Plugins.SystemPlugins.WirelessLan.iwlibs import Wireless
775 self.session.open(MessageBox, _("The wireless LAN plugin is not installed!\nPlease install it."), type = MessageBox.TYPE_INFO,timeout = 10 )
777 ifobj = Wireless(self.iface) # a Wireless NIC Object
778 self.wlanresponse = ifobj.getStatistics()
779 if self.wlanresponse[0] != 19:
780 self.session.openWithCallback(self.WlanStatusClosed, WlanStatus,self.iface)
782 # Display Wlan not available Message
783 self.showErrorMessage()
784 if self["menulist"].getCurrent()[1] == 'lanrestart':
785 self.session.openWithCallback(self.restartLan, MessageBox, (_("Are you sure you want to restart your network interfaces?\n\n") + self.oktext ) )
786 if self["menulist"].getCurrent()[1] == 'openwizard':
787 from Plugins.SystemPlugins.NetworkWizard.NetworkWizard import NetworkWizard
788 self.session.openWithCallback(self.AdapterSetupClosed, NetworkWizard)
789 if self["menulist"].getCurrent()[1][0] == 'extendedSetup':
790 self.extended = self["menulist"].getCurrent()[1][2]
791 self.extended(self.session, self.iface)
794 self["menulist"].up()
795 self.loadDescription()
798 self["menulist"].down()
799 self.loadDescription()
802 self["menulist"].pageUp()
803 self.loadDescription()
806 self["menulist"].pageDown()
807 self.loadDescription()
809 def layoutFinished(self):
811 self["menulist"].moveToIndex(idx)
812 self.loadDescription()
814 def loadDescription(self):
815 print self["menulist"].getCurrent()[1]
816 if self["menulist"].getCurrent()[1] == 'edit':
817 self["description"].setText(_("Edit the network configuration of your Dreambox.\n" ) + self.oktext )
818 if self["menulist"].getCurrent()[1] == 'test':
819 self["description"].setText(_("Test the network configuration of your Dreambox.\n" ) + self.oktext )
820 if self["menulist"].getCurrent()[1] == 'dns':
821 self["description"].setText(_("Edit the Nameserver configuration of your Dreambox.\n" ) + self.oktext )
822 if self["menulist"].getCurrent()[1] == 'scanwlan':
823 self["description"].setText(_("Scan your network for wireless Access Points and connect to them using your WLAN USB Stick\n" ) + self.oktext )
824 if self["menulist"].getCurrent()[1] == 'wlanstatus':
825 self["description"].setText(_("Shows the state of your wireless LAN connection.\n" ) + self.oktext )
826 if self["menulist"].getCurrent()[1] == 'lanrestart':
827 self["description"].setText(_("Restart your network connection and interfaces.\n" ) + self.oktext )
828 if self["menulist"].getCurrent()[1] == 'openwizard':
829 self["description"].setText(_("Use the Networkwizard to configure your Network\n" ) + self.oktext )
830 if self["menulist"].getCurrent()[1][0] == 'extendedSetup':
831 self["description"].setText(_(self["menulist"].getCurrent()[1][1]) + self.oktext )
833 def updateStatusbar(self, data = None):
834 self["IFtext"].setText(_("Network:"))
835 self["IF"].setText(iNetwork.getFriendlyAdapterName(self.iface))
836 self["Statustext"].setText(_("Link:"))
838 if self.iface == 'wlan0' or self.iface == 'ath0':
840 from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus,Status
842 self["statuspic"].setPixmapNum(1)
843 self["statuspic"].show()
845 iStatus.getDataForInterface(self.iface,self.getInfoCB)
847 iNetwork.getLinkState(self.iface,self.dataAvail)
852 def genMainMenu(self):
854 menu.append((_("Adapter settings"), "edit"))
855 menu.append((_("Nameserver settings"), "dns"))
856 menu.append((_("Network test"), "test"))
857 menu.append((_("Restart network"), "lanrestart"))
860 self.extendedSetup = None
861 for p in plugins.getPlugins(PluginDescriptor.WHERE_NETWORKSETUP):
862 callFnc = p.__call__["ifaceSupported"](self.iface)
863 if callFnc is not None:
864 self.extended = callFnc
866 if p.__call__.has_key("WlanPluginEntry"): # internally used only for WLAN Plugin
867 menu.append((_("Scan Wireless Networks"), "scanwlan"))
868 if iNetwork.getAdapterAttribute(self.iface, "up"):
869 menu.append((_("Show WLAN Status"), "wlanstatus"))
871 if p.__call__.has_key("menuEntryName"):
872 menuEntryName = p.__call__["menuEntryName"](self.iface)
874 menuEntryName = _('Extended Setup...')
875 if p.__call__.has_key("menuEntryDescription"):
876 menuEntryDescription = p.__call__["menuEntryDescription"](self.iface)
878 menuEntryDescription = _('Extended Networksetup Plugin...')
879 self.extendedSetup = ('extendedSetup',menuEntryDescription, self.extended)
880 menu.append((menuEntryName,self.extendedSetup))
882 if os_path.exists(resolveFilename(SCOPE_PLUGINS, "SystemPlugins/NetworkWizard/networkwizard.xml")):
883 menu.append((_("NetworkWizard"), "openwizard"))
887 def AdapterSetupClosed(self, *ret):
888 if ret is not None and len(ret):
889 if ret[0] == 'ok' and (self.iface == 'wlan0' or self.iface == 'ath0') and iNetwork.getAdapterAttribute(self.iface, "up") is True:
891 from Plugins.SystemPlugins.WirelessLan.plugin import WlanStatus
892 from Plugins.SystemPlugins.WirelessLan.iwlibs import Wireless
894 self.session.open(MessageBox, _("The wireless LAN plugin is not installed!\nPlease install it."), type = MessageBox.TYPE_INFO,timeout = 10 )
896 ifobj = Wireless(self.iface) # a Wireless NIC Object
897 self.wlanresponse = ifobj.getStatistics()
898 if self.wlanresponse[0] != 19:
899 self.session.openWithCallback(self.WlanStatusClosed, WlanStatus,self.iface)
901 # Display Wlan not available Message
902 self.showErrorMessage()
904 self.mainmenu = self.genMainMenu()
905 self["menulist"].l.setList(self.mainmenu)
906 iNetwork.getInterfaces(self.updateStatusbar)
908 self.mainmenu = self.genMainMenu()
909 self["menulist"].l.setList(self.mainmenu)
910 iNetwork.getInterfaces(self.updateStatusbar)
912 def WlanStatusClosed(self, *ret):
913 if ret is not None and len(ret):
914 from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus,Status
915 iStatus.stopWlanConsole()
916 self.mainmenu = self.genMainMenu()
917 self["menulist"].l.setList(self.mainmenu)
918 iNetwork.getInterfaces(self.updateStatusbar)
920 def WlanScanClosed(self,*ret):
921 if ret[0] is not None:
922 self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetup, self.iface,ret[0],ret[1])
924 from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus,Status
925 iStatus.stopWlanConsole()
926 self.mainmenu = self.genMainMenu()
927 self["menulist"].l.setList(self.mainmenu)
928 iNetwork.getInterfaces(self.updateStatusbar)
930 def restartLan(self, ret = False):
932 iNetwork.restartNetwork(self.restartLanDataAvail)
933 self.restartLanRef = self.session.openWithCallback(self.restartfinishedCB, MessageBox, _("Please wait while your network is restarting..."), type = MessageBox.TYPE_INFO, enable_input = False)
935 def restartLanDataAvail(self, data):
937 iNetwork.getInterfaces(self.getInterfacesDataAvail)
939 def getInterfacesDataAvail(self, data):
941 self.restartLanRef.close(True)
943 def restartfinishedCB(self,data):
945 self.session.open(MessageBox, _("Finished restarting your network"), type = MessageBox.TYPE_INFO, timeout = 10, default = False)
947 def dataAvail(self,data):
948 self.output = data.strip()
949 result = self.output.split('\n')
950 pattern = re_compile("Link detected: yes")
952 if re_search(pattern, item):
953 self["statuspic"].setPixmapNum(1)
955 self["statuspic"].setPixmapNum(0)
956 self["statuspic"].show()
958 def showErrorMessage(self):
959 self.session.open(MessageBox, self.errortext, type = MessageBox.TYPE_INFO,timeout = 10 )
962 iNetwork.stopLinkStateConsole()
963 iNetwork.stopDeactivateInterfaceConsole()
965 from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus,Status
969 iStatus.stopWlanConsole()
971 def getInfoCB(self,data,status):
974 if status is not None:
975 if status[self.iface]["acesspoint"] == "No Connection" or status[self.iface]["acesspoint"] == "Not-Associated" or status[self.iface]["acesspoint"] == False:
976 self["statuspic"].setPixmapNum(1)
978 self["statuspic"].setPixmapNum(0)
979 self["statuspic"].show()
981 class NetworkAdapterTest(Screen):
982 def __init__(self, session,iface):
983 Screen.__init__(self, session)
985 self.oldInterfaceState = iNetwork.getAdapterAttribute(self.iface, "up")
986 iNetwork.getInterfaces()
988 self.onClose.append(self.cleanup)
989 self.onHide.append(self.cleanup)
991 self["updown_actions"] = NumberActionMap(["WizardActions","ShortcutActions"],
995 "up": lambda: self.updownhandler('up'),
996 "down": lambda: self.updownhandler('down'),
1000 self["shortcuts"] = ActionMap(["ShortcutActions","WizardActions"],
1003 "back": self.cancel,
1005 self["infoshortcuts"] = ActionMap(["ShortcutActions","WizardActions"],
1007 "red": self.closeInfo,
1008 "back": self.closeInfo,
1010 self["shortcutsgreen"] = ActionMap(["ShortcutActions"],
1012 "green": self.KeyGreen,
1014 self["shortcutsgreen_restart"] = ActionMap(["ShortcutActions"],
1016 "green": self.KeyGreenRestart,
1018 self["shortcutsyellow"] = ActionMap(["ShortcutActions"],
1020 "yellow": self.KeyYellow,
1023 self["shortcutsgreen_restart"].setEnabled(False)
1024 self["updown_actions"].setEnabled(False)
1025 self["infoshortcuts"].setEnabled(False)
1026 self.onClose.append(self.delTimer)
1027 self.onLayoutFinish.append(self.layoutFinished)
1028 self.steptimer = False
1030 self.activebutton = 0
1031 self.nextStepTimer = eTimer()
1032 self.nextStepTimer.callback.append(self.nextStepTimerFire)
1035 if self.oldInterfaceState is False:
1036 iNetwork.setAdapterAttribute(self.iface, "up", self.oldInterfaceState)
1037 iNetwork.deactivateInterface(self.iface)
1040 def closeInfo(self):
1041 self["shortcuts"].setEnabled(True)
1042 self["infoshortcuts"].setEnabled(False)
1043 self["InfoText"].hide()
1044 self["InfoTextBorder"].hide()
1045 self["ButtonRedtext"].setText(_("Close"))
1049 del self.nextStepTimer
1051 def nextStepTimerFire(self):
1052 self.nextStepTimer.stop()
1053 self.steptimer = False
1056 def updownhandler(self,direction):
1057 if direction == 'up':
1058 if self.activebutton >=2:
1059 self.activebutton -= 1
1061 self.activebutton = 6
1062 self.setActiveButton(self.activebutton)
1063 if direction == 'down':
1064 if self.activebutton <=5:
1065 self.activebutton += 1
1067 self.activebutton = 1
1068 self.setActiveButton(self.activebutton)
1070 def setActiveButton(self,button):
1072 self["EditSettingsButton"].setPixmapNum(0)
1073 self["EditSettings_Text"].setForegroundColorNum(0)
1074 self["NetworkInfo"].setPixmapNum(0)
1075 self["NetworkInfo_Text"].setForegroundColorNum(1)
1076 self["AdapterInfo"].setPixmapNum(1) # active
1077 self["AdapterInfo_Text"].setForegroundColorNum(2) # active
1079 self["AdapterInfo_Text"].setForegroundColorNum(1)
1080 self["AdapterInfo"].setPixmapNum(0)
1081 self["DhcpInfo"].setPixmapNum(0)
1082 self["DhcpInfo_Text"].setForegroundColorNum(1)
1083 self["NetworkInfo"].setPixmapNum(1) # active
1084 self["NetworkInfo_Text"].setForegroundColorNum(2) # active
1086 self["NetworkInfo"].setPixmapNum(0)
1087 self["NetworkInfo_Text"].setForegroundColorNum(1)
1088 self["IPInfo"].setPixmapNum(0)
1089 self["IPInfo_Text"].setForegroundColorNum(1)
1090 self["DhcpInfo"].setPixmapNum(1) # active
1091 self["DhcpInfo_Text"].setForegroundColorNum(2) # active
1093 self["DhcpInfo"].setPixmapNum(0)
1094 self["DhcpInfo_Text"].setForegroundColorNum(1)
1095 self["DNSInfo"].setPixmapNum(0)
1096 self["DNSInfo_Text"].setForegroundColorNum(1)
1097 self["IPInfo"].setPixmapNum(1) # active
1098 self["IPInfo_Text"].setForegroundColorNum(2) # active
1100 self["IPInfo"].setPixmapNum(0)
1101 self["IPInfo_Text"].setForegroundColorNum(1)
1102 self["EditSettingsButton"].setPixmapNum(0)
1103 self["EditSettings_Text"].setForegroundColorNum(0)
1104 self["DNSInfo"].setPixmapNum(1) # active
1105 self["DNSInfo_Text"].setForegroundColorNum(2) # active
1107 self["DNSInfo"].setPixmapNum(0)
1108 self["DNSInfo_Text"].setForegroundColorNum(1)
1109 self["EditSettingsButton"].setPixmapNum(1) # active
1110 self["EditSettings_Text"].setForegroundColorNum(2) # active
1111 self["AdapterInfo"].setPixmapNum(0)
1112 self["AdapterInfo_Text"].setForegroundColorNum(1)
1115 next = self.nextstep
1131 self.steptimer = True
1132 self.nextStepTimer.start(3000)
1133 self["ButtonYellow_Check"].show()
1134 self["ButtonYellowtext"].show()
1137 self["Adapter"].setText(iNetwork.getFriendlyAdapterName(self.iface))
1138 self["Adapter"].setForegroundColorNum(2)
1139 self["Adaptertext"].setForegroundColorNum(1)
1140 self["AdapterInfo_Text"].setForegroundColorNum(1)
1141 self["AdapterInfo_OK"].show()
1142 self.steptimer = True
1143 self.nextStepTimer.start(3000)
1146 self["Networktext"].setForegroundColorNum(1)
1147 self["Network"].setText(_("Please wait..."))
1148 self.getLinkState(self.iface)
1149 self["NetworkInfo_Text"].setForegroundColorNum(1)
1150 self.steptimer = True
1151 self.nextStepTimer.start(3000)
1154 self["Dhcptext"].setForegroundColorNum(1)
1155 if iNetwork.getAdapterAttribute(self.iface, 'dhcp') is True:
1156 self["Dhcp"].setForegroundColorNum(2)
1157 self["Dhcp"].setText(_("enabled"))
1158 self["DhcpInfo_Check"].setPixmapNum(0)
1160 self["Dhcp"].setForegroundColorNum(1)
1161 self["Dhcp"].setText(_("disabled"))
1162 self["DhcpInfo_Check"].setPixmapNum(1)
1163 self["DhcpInfo_Check"].show()
1164 self["DhcpInfo_Text"].setForegroundColorNum(1)
1165 self.steptimer = True
1166 self.nextStepTimer.start(3000)
1169 self["IPtext"].setForegroundColorNum(1)
1170 self["IP"].setText(_("Please wait..."))
1171 iNetwork.checkNetworkState(self.NetworkStatedataAvail)
1174 self.steptimer = False
1175 self.nextStepTimer.stop()
1176 self["DNStext"].setForegroundColorNum(1)
1177 self["DNS"].setText(_("Please wait..."))
1178 iNetwork.checkDNSLookup(self.DNSLookupdataAvail)
1181 self["shortcutsgreen"].setEnabled(False)
1182 self["shortcutsyellow"].setEnabled(True)
1183 self["updown_actions"].setEnabled(False)
1184 self["ButtonYellow_Check"].setPixmapNum(0)
1185 self["ButtonGreen_Check"].setPixmapNum(1)
1186 self.steptimer = True
1187 self.nextStepTimer.start(1000)
1189 def KeyGreenRestart(self):
1191 self.layoutFinished()
1192 self["Adapter"].setText((""))
1193 self["Network"].setText((""))
1194 self["Dhcp"].setText((""))
1195 self["IP"].setText((""))
1196 self["DNS"].setText((""))
1197 self["AdapterInfo_Text"].setForegroundColorNum(0)
1198 self["NetworkInfo_Text"].setForegroundColorNum(0)
1199 self["DhcpInfo_Text"].setForegroundColorNum(0)
1200 self["IPInfo_Text"].setForegroundColorNum(0)
1201 self["DNSInfo_Text"].setForegroundColorNum(0)
1202 self["shortcutsgreen_restart"].setEnabled(False)
1203 self["shortcutsgreen"].setEnabled(False)
1204 self["shortcutsyellow"].setEnabled(True)
1205 self["updown_actions"].setEnabled(False)
1206 self["ButtonYellow_Check"].setPixmapNum(0)
1207 self["ButtonGreen_Check"].setPixmapNum(1)
1208 self.steptimer = True
1209 self.nextStepTimer.start(1000)
1212 self["infoshortcuts"].setEnabled(True)
1213 self["shortcuts"].setEnabled(False)
1214 if self.activebutton == 1: # Adapter Check
1215 self["InfoText"].setText(_("This test detects your configured LAN-Adapter."))
1216 self["InfoTextBorder"].show()
1217 self["InfoText"].show()
1218 self["ButtonRedtext"].setText(_("Back"))
1219 if self.activebutton == 2: #LAN Check
1220 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"))
1221 self["InfoTextBorder"].show()
1222 self["InfoText"].show()
1223 self["ButtonRedtext"].setText(_("Back"))
1224 if self.activebutton == 3: #DHCP Check
1225 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."))
1226 self["InfoTextBorder"].show()
1227 self["InfoText"].show()
1228 self["ButtonRedtext"].setText(_("Back"))
1229 if self.activebutton == 4: # IP Check
1230 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"))
1231 self["InfoTextBorder"].show()
1232 self["InfoText"].show()
1233 self["ButtonRedtext"].setText(_("Back"))
1234 if self.activebutton == 5: # DNS Check
1235 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"))
1236 self["InfoTextBorder"].show()
1237 self["InfoText"].show()
1238 self["ButtonRedtext"].setText(_("Back"))
1239 if self.activebutton == 6: # Edit Settings
1240 self.session.open(AdapterSetup,self.iface)
1242 def KeyYellow(self):
1244 self["shortcutsgreen_restart"].setEnabled(True)
1245 self["shortcutsgreen"].setEnabled(False)
1246 self["shortcutsyellow"].setEnabled(False)
1247 self["ButtonGreentext"].setText(_("Restart test"))
1248 self["ButtonYellow_Check"].setPixmapNum(1)
1249 self["ButtonGreen_Check"].setPixmapNum(0)
1250 self.steptimer = False
1251 self.nextStepTimer.stop()
1253 def layoutFinished(self):
1254 self["shortcutsyellow"].setEnabled(False)
1255 self["AdapterInfo_OK"].hide()
1256 self["NetworkInfo_Check"].hide()
1257 self["DhcpInfo_Check"].hide()
1258 self["IPInfo_Check"].hide()
1259 self["DNSInfo_Check"].hide()
1260 self["EditSettings_Text"].hide()
1261 self["EditSettingsButton"].hide()
1262 self["InfoText"].hide()
1263 self["InfoTextBorder"].hide()
1264 self["ButtonYellow_Check"].hide()
1265 self["ButtonYellowtext"].hide()
1267 def setLabels(self):
1268 self["Adaptertext"] = MultiColorLabel(_("LAN Adapter"))
1269 self["Adapter"] = MultiColorLabel()
1270 self["AdapterInfo"] = MultiPixmap()
1271 self["AdapterInfo_Text"] = MultiColorLabel(_("Show Info"))
1272 self["AdapterInfo_OK"] = Pixmap()
1274 if self.iface == 'wlan0' or self.iface == 'ath0':
1275 self["Networktext"] = MultiColorLabel(_("Wireless Network"))
1277 self["Networktext"] = MultiColorLabel(_("Local Network"))
1279 self["Network"] = MultiColorLabel()
1280 self["NetworkInfo"] = MultiPixmap()
1281 self["NetworkInfo_Text"] = MultiColorLabel(_("Show Info"))
1282 self["NetworkInfo_Check"] = MultiPixmap()
1284 self["Dhcptext"] = MultiColorLabel(_("DHCP"))
1285 self["Dhcp"] = MultiColorLabel()
1286 self["DhcpInfo"] = MultiPixmap()
1287 self["DhcpInfo_Text"] = MultiColorLabel(_("Show Info"))
1288 self["DhcpInfo_Check"] = MultiPixmap()
1290 self["IPtext"] = MultiColorLabel(_("IP Address"))
1291 self["IP"] = MultiColorLabel()
1292 self["IPInfo"] = MultiPixmap()
1293 self["IPInfo_Text"] = MultiColorLabel(_("Show Info"))
1294 self["IPInfo_Check"] = MultiPixmap()
1296 self["DNStext"] = MultiColorLabel(_("Nameserver"))
1297 self["DNS"] = MultiColorLabel()
1298 self["DNSInfo"] = MultiPixmap()
1299 self["DNSInfo_Text"] = MultiColorLabel(_("Show Info"))
1300 self["DNSInfo_Check"] = MultiPixmap()
1302 self["EditSettings_Text"] = MultiColorLabel(_("Edit settings"))
1303 self["EditSettingsButton"] = MultiPixmap()
1305 self["ButtonRedtext"] = Label(_("Close"))
1306 self["ButtonRed"] = Pixmap()
1308 self["ButtonGreentext"] = Label(_("Start test"))
1309 self["ButtonGreen_Check"] = MultiPixmap()
1311 self["ButtonYellowtext"] = Label(_("Stop test"))
1312 self["ButtonYellow_Check"] = MultiPixmap()
1314 self["InfoTextBorder"] = Pixmap()
1315 self["InfoText"] = Label()
1317 def getLinkState(self,iface):
1318 if iface == 'wlan0' or iface == 'ath0':
1320 from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus,Status
1322 self["Network"].setForegroundColorNum(1)
1323 self["Network"].setText(_("disconnected"))
1324 self["NetworkInfo_Check"].setPixmapNum(1)
1325 self["NetworkInfo_Check"].show()
1327 iStatus.getDataForInterface(self.iface,self.getInfoCB)
1329 iNetwork.getLinkState(iface,self.LinkStatedataAvail)
1331 def LinkStatedataAvail(self,data):
1332 self.output = data.strip()
1333 result = self.output.split('\n')
1334 pattern = re_compile("Link detected: yes")
1336 if re_search(pattern, item):
1337 self["Network"].setForegroundColorNum(2)
1338 self["Network"].setText(_("connected"))
1339 self["NetworkInfo_Check"].setPixmapNum(0)
1341 self["Network"].setForegroundColorNum(1)
1342 self["Network"].setText(_("disconnected"))
1343 self["NetworkInfo_Check"].setPixmapNum(1)
1344 self["NetworkInfo_Check"].show()
1346 def NetworkStatedataAvail(self,data):
1348 self["IP"].setForegroundColorNum(2)
1349 self["IP"].setText(_("confirmed"))
1350 self["IPInfo_Check"].setPixmapNum(0)
1352 self["IP"].setForegroundColorNum(1)
1353 self["IP"].setText(_("unconfirmed"))
1354 self["IPInfo_Check"].setPixmapNum(1)
1355 self["IPInfo_Check"].show()
1356 self["IPInfo_Text"].setForegroundColorNum(1)
1357 self.steptimer = True
1358 self.nextStepTimer.start(3000)
1360 def DNSLookupdataAvail(self,data):
1362 self["DNS"].setForegroundColorNum(2)
1363 self["DNS"].setText(_("confirmed"))
1364 self["DNSInfo_Check"].setPixmapNum(0)
1366 self["DNS"].setForegroundColorNum(1)
1367 self["DNS"].setText(_("unconfirmed"))
1368 self["DNSInfo_Check"].setPixmapNum(1)
1369 self["DNSInfo_Check"].show()
1370 self["DNSInfo_Text"].setForegroundColorNum(1)
1371 self["EditSettings_Text"].show()
1372 self["EditSettingsButton"].setPixmapNum(1)
1373 self["EditSettings_Text"].setForegroundColorNum(2) # active
1374 self["EditSettingsButton"].show()
1375 self["ButtonYellow_Check"].setPixmapNum(1)
1376 self["ButtonGreentext"].setText(_("Restart test"))
1377 self["ButtonGreen_Check"].setPixmapNum(0)
1378 self["shortcutsgreen"].setEnabled(False)
1379 self["shortcutsgreen_restart"].setEnabled(True)
1380 self["shortcutsyellow"].setEnabled(False)
1381 self["updown_actions"].setEnabled(True)
1382 self.activebutton = 6
1384 def getInfoCB(self,data,status):
1385 if data is not None:
1387 if status is not None:
1388 if status[self.iface]["acesspoint"] == "No Connection" or status[self.iface]["acesspoint"] == "Not-Associated" or status[self.iface]["acesspoint"] == False:
1389 self["Network"].setForegroundColorNum(1)
1390 self["Network"].setText(_("disconnected"))
1391 self["NetworkInfo_Check"].setPixmapNum(1)
1392 self["NetworkInfo_Check"].show()
1394 self["Network"].setForegroundColorNum(2)
1395 self["Network"].setText(_("connected"))
1396 self["NetworkInfo_Check"].setPixmapNum(0)
1397 self["NetworkInfo_Check"].show()
1400 iNetwork.stopLinkStateConsole()
1401 iNetwork.stopDNSConsole()
1403 from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus,Status
1407 iStatus.stopWlanConsole()