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.Sources.StaticText import StaticText
9 from Components.Sources.Boolean import Boolean
10 from Components.Sources.List import List
11 from Components.Label import Label,MultiColorLabel
12 from Components.Pixmap import Pixmap,MultiPixmap
13 from Components.MenuList import MenuList
14 from Components.config import config, ConfigYesNo, ConfigIP, NoSave, ConfigText, ConfigPassword, ConfigSelection, getConfigListEntry, ConfigNothing, ConfigBoolean
15 from Components.ConfigList import ConfigListScreen
16 from Components.PluginComponent import plugins
17 from Components.MultiContent import MultiContentEntryText, MultiContentEntryPixmapAlphaTest
18 from Components.ActionMap import ActionMap, NumberActionMap, HelpableActionMap
19 from Tools.Directories import resolveFilename, SCOPE_PLUGINS, SCOPE_CURRENT_SKIN
20 from Tools.LoadPixmap import LoadPixmap
21 from Plugins.Plugin import PluginDescriptor
22 from enigma import eTimer, ePoint, eSize, RT_HALIGN_LEFT, eListboxPythonMultiContent, gFont
23 from os import path as os_path, system as os_system, unlink
24 from re import compile as re_compile, search as re_search
27 class NetworkAdapterSelection(Screen,HelpableScreen):
28 def __init__(self, session):
29 Screen.__init__(self, session)
30 HelpableScreen.__init__(self)
32 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.")
33 self.lan_errortext = _("No working local network adapter found.\nPlease verify that you have attached a network cable and your network is configured correctly.")
34 self.oktext = _("Press OK on your remote control to continue.")
35 self.edittext = _("Press OK to edit the settings.")
36 self.defaulttext = _("Press yellow to set this interface as default interface.")
37 self.restartLanRef = None
39 self["key_red"] = StaticText(_("Close"))
40 self["key_green"] = StaticText(_("Select"))
41 self["key_yellow"] = StaticText("")
42 self["key_blue"] = StaticText("")
43 self["introduction"] = StaticText(self.edittext)
45 self["OkCancelActions"] = HelpableActionMap(self, "OkCancelActions",
47 "cancel": (self.close, _("exit network interface list")),
48 "ok": (self.okbuttonClick, _("select interface")),
51 self["ColorActions"] = HelpableActionMap(self, "ColorActions",
53 "red": (self.close, _("exit network interface list")),
54 "green": (self.okbuttonClick, _("select interface")),
55 "blue": (self.openNetworkWizard, _("Use the Networkwizard to configure selected network adapter")),
58 self["DefaultInterfaceAction"] = HelpableActionMap(self, "ColorActions",
60 "yellow": (self.setDefaultInterface, [_("Set interface as default Interface"),_("* Only available if more than one interface is active.")] ),
63 self.adapters = [(iNetwork.getFriendlyAdapterName(x),x) for x in iNetwork.getAdapterList()]
66 self.adapters = [(iNetwork.getFriendlyAdapterName(x),x) for x in iNetwork.getConfiguredAdapters()]
68 if len(self.adapters) == 0:
69 self.adapters = [(iNetwork.getFriendlyAdapterName(x),x) for x in iNetwork.getInstalledAdapters()]
72 self["list"] = List(self.list)
75 if len(self.adapters) == 1:
76 self.onFirstExecBegin.append(self.okbuttonClick)
77 self.onClose.append(self.cleanup)
79 def buildInterfaceList(self,iface,name,default,active ):
80 divpng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/div-h.png"))
86 if not iNetwork.isWirelessInterface(iface):
88 interfacepng = LoadPixmap(resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/icons/network_wired-active.png"))
90 interfacepng = LoadPixmap(resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/icons/network_wired-inactive.png"))
92 interfacepng = LoadPixmap(resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/icons/network_wired.png"))
93 elif iNetwork.isWirelessInterface(iface):
95 interfacepng = LoadPixmap(resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/icons/network_wireless-active.png"))
97 interfacepng = LoadPixmap(resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/icons/network_wireless-inactive.png"))
99 interfacepng = LoadPixmap(resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/icons/network_wireless.png"))
101 num_configured_if = len(iNetwork.getConfiguredAdapters())
102 if num_configured_if >= 2:
104 defaultpng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/buttons/button_blue.png"))
105 elif default is False:
106 defaultpng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/buttons/button_blue_off.png"))
108 activepng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/icons/lock_on.png"))
109 elif active is False:
110 activepng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/icons/lock_error.png"))
112 description = iNetwork.getFriendlyAdapterDescription(iface)
114 return((iface, name, description, interfacepng, defaultpng, activepng, divpng))
116 def updateList(self):
119 num_configured_if = len(iNetwork.getConfiguredAdapters())
120 if num_configured_if >= 2:
121 self["key_yellow"].setText(_("Default"))
122 self["introduction"].setText(self.defaulttext)
123 self["DefaultInterfaceAction"].setEnabled(True)
125 self["key_yellow"].setText("")
126 self["introduction"].setText(self.edittext)
127 self["DefaultInterfaceAction"].setEnabled(False)
129 if num_configured_if < 2 and os_path.exists("/etc/default_gw"):
130 unlink("/etc/default_gw")
132 if os_path.exists("/etc/default_gw"):
133 fp = file('/etc/default_gw', 'r')
138 for x in self.adapters:
139 if x[1] == default_gw:
143 if iNetwork.getAdapterAttribute(x[1], 'up') is True:
147 self.list.append(self.buildInterfaceList(x[1],_(x[0]),default_int,active_int ))
149 if os_path.exists(resolveFilename(SCOPE_PLUGINS, "SystemPlugins/NetworkWizard/networkwizard.xml")):
150 self["key_blue"].setText(_("NetworkWizard"))
151 self["list"].setList(self.list)
153 def setDefaultInterface(self):
154 selection = self["list"].getCurrent()
155 num_if = len(self.list)
156 old_default_gw = None
157 num_configured_if = len(iNetwork.getConfiguredAdapters())
158 if os_path.exists("/etc/default_gw"):
159 fp = open('/etc/default_gw', 'r')
160 old_default_gw = fp.read()
162 if num_configured_if > 1 and (not old_default_gw or old_default_gw != selection[0]):
163 fp = open('/etc/default_gw', 'w+')
164 fp.write(selection[0])
167 elif old_default_gw and num_configured_if < 2:
168 unlink("/etc/default_gw")
171 def okbuttonClick(self):
172 selection = self["list"].getCurrent()
173 if selection is not None:
174 self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetupConfiguration, selection[0])
176 def AdapterSetupClosed(self, *ret):
177 if len(self.adapters) == 1:
183 iNetwork.stopLinkStateConsole()
184 iNetwork.stopRestartConsole()
185 iNetwork.stopGetInterfacesConsole()
187 def restartLan(self):
188 iNetwork.restartNetwork(self.restartLanDataAvail)
189 self.restartLanRef = self.session.openWithCallback(self.restartfinishedCB, MessageBox, _("Please wait while we configure your network..."), type = MessageBox.TYPE_INFO, enable_input = False)
191 def restartLanDataAvail(self, data):
193 iNetwork.getInterfaces(self.getInterfacesDataAvail)
195 def getInterfacesDataAvail(self, data):
197 self.restartLanRef.close(True)
199 def restartfinishedCB(self,data):
202 self.session.open(MessageBox, _("Finished configuring your network"), type = MessageBox.TYPE_INFO, timeout = 10, default = False)
204 def openNetworkWizard(self):
205 if os_path.exists(resolveFilename(SCOPE_PLUGINS, "SystemPlugins/NetworkWizard/networkwizard.xml")):
207 from Plugins.SystemPlugins.NetworkWizard.NetworkWizard import NetworkWizard
209 self.session.open(MessageBox, _("The NetworkWizard extension is not installed!\nPlease install it."), type = MessageBox.TYPE_INFO,timeout = 10 )
211 selection = self["list"].getCurrent()
212 if selection is not None:
213 self.session.openWithCallback(self.AdapterSetupClosed, NetworkWizard, selection[0])
216 class NameserverSetup(Screen, ConfigListScreen, HelpableScreen):
217 def __init__(self, session):
218 Screen.__init__(self, session)
219 HelpableScreen.__init__(self)
220 self.backupNameserverList = iNetwork.getNameserverList()[:]
221 print "backup-list:", self.backupNameserverList
223 self["key_red"] = StaticText(_("Cancel"))
224 self["key_green"] = StaticText(_("Add"))
225 self["key_yellow"] = StaticText(_("Delete"))
227 self["introduction"] = StaticText(_("Press OK to activate the settings."))
230 self["OkCancelActions"] = HelpableActionMap(self, "OkCancelActions",
232 "cancel": (self.cancel, _("exit nameserver configuration")),
233 "ok": (self.ok, _("activate current configuration")),
236 self["ColorActions"] = HelpableActionMap(self, "ColorActions",
238 "red": (self.cancel, _("exit nameserver configuration")),
239 "green": (self.add, _("add a nameserver entry")),
240 "yellow": (self.remove, _("remove a nameserver entry")),
243 self["actions"] = NumberActionMap(["SetupActions"],
249 ConfigListScreen.__init__(self, self.list)
252 def createConfig(self):
253 self.nameservers = iNetwork.getNameserverList()
254 self.nameserverEntries = [ NoSave(ConfigIP(default=nameserver)) for nameserver in self.nameservers]
256 def createSetup(self):
260 for x in self.nameserverEntries:
261 self.list.append(getConfigListEntry(_("Nameserver %d") % (i), x))
264 self["config"].list = self.list
265 self["config"].l.setList(self.list)
268 iNetwork.clearNameservers()
269 for nameserver in self.nameserverEntries:
270 iNetwork.addNameserver(nameserver.value)
271 iNetwork.writeNameserverConfig()
278 iNetwork.clearNameservers()
279 print "backup-list:", self.backupNameserverList
280 for nameserver in self.backupNameserverList:
281 iNetwork.addNameserver(nameserver)
285 iNetwork.addNameserver([0,0,0,0])
290 print "currentIndex:", self["config"].getCurrentIndex()
291 index = self["config"].getCurrentIndex()
292 if index < len(self.nameservers):
293 iNetwork.removeNameserver(self.nameservers[index])
298 class AdapterSetup(Screen, ConfigListScreen, HelpableScreen):
299 def __init__(self, session, networkinfo, essid=None):
300 Screen.__init__(self, session)
301 HelpableScreen.__init__(self)
302 self.session = session
303 if isinstance(networkinfo, (list, tuple)):
304 self.iface = networkinfo[0]
305 self.essid = networkinfo[1]
307 self.iface = networkinfo
311 self.applyConfigRef = None
312 self.finished_cb = None
313 self.oktext = _("Press OK on your remote control to continue.")
314 self.oldInterfaceState = iNetwork.getAdapterAttribute(self.iface, "up")
316 self["OkCancelActions"] = HelpableActionMap(self, "OkCancelActions",
318 "cancel": (self.keyCancel, _("exit network adapter configuration")),
319 "ok": (self.keySave, _("activate network adapter configuration")),
322 self["ColorActions"] = HelpableActionMap(self, "ColorActions",
324 "red": (self.keyCancel, _("exit network adapter configuration")),
327 self["actions"] = NumberActionMap(["SetupActions"],
333 ConfigListScreen.__init__(self, self.list,session = self.session)
335 self.onLayoutFinish.append(self.layoutFinished)
336 self.onClose.append(self.cleanup)
338 self["DNS1text"] = StaticText(_("Primary DNS"))
339 self["DNS2text"] = StaticText(_("Secondary DNS"))
340 self["DNS1"] = StaticText()
341 self["DNS2"] = StaticText()
342 self["introduction"] = StaticText(_("Current settings:"))
344 self["IPtext"] = StaticText(_("IP Address"))
345 self["Netmasktext"] = StaticText(_("Netmask"))
346 self["Gatewaytext"] = StaticText(_("Gateway"))
348 self["IP"] = StaticText()
349 self["Mask"] = StaticText()
350 self["Gateway"] = StaticText()
352 self["Adaptertext"] = StaticText(_("Network:"))
353 self["Adapter"] = StaticText()
354 self["introduction2"] = StaticText(_("Press OK to activate the settings."))
355 self["key_red"] = StaticText(_("Cancel"))
356 self["key_blue"] = StaticText()
358 self["VKeyIcon"] = Boolean(False)
359 self["HelpWindow"] = Pixmap()
360 self["HelpWindow"].hide()
362 def updateInterfaces(self,callback = None):
363 iNetwork.config_ready = False
364 iNetwork.msgPlugins()
365 iNetwork.getInterfaces(callback)
367 def updateInterfaceCB(self, ret=None):
370 self["DNS1"].setText(self.primaryDNS.getText())
371 self["DNS2"].setText(self.secondaryDNS.getText())
372 if self.ipConfigEntry.getText() is not None:
373 if self.ipConfigEntry.getText() == "0.0.0.0":
374 self["IP"].setText(_("N/A"))
376 self["IP"].setText(self.ipConfigEntry.getText())
378 self["IP"].setText(_("N/A"))
379 if self.netmaskConfigEntry.getText() is not None:
380 if self.netmaskConfigEntry.getText() == "0.0.0.0":
381 self["Mask"].setText(_("N/A"))
383 self["Mask"].setText(self.netmaskConfigEntry.getText())
385 self["IP"].setText(_("N/A"))
386 if iNetwork.getAdapterAttribute(self.iface, "gateway"):
387 if self.gatewayConfigEntry.getText() == "0.0.0.0":
388 self["Gatewaytext"].setText(_("Gateway"))
389 self["Gateway"].setText(_("N/A"))
391 self["Gatewaytext"].setText(_("Gateway"))
392 self["Gateway"].setText(self.gatewayConfigEntry.getText())
394 self["Gateway"].setText("")
395 self["Gatewaytext"].setText("")
396 self["Adapter"].setText(iNetwork.getFriendlyAdapterName(self.iface))
398 def layoutFinished(self):
399 self.updateInterfaces(self.updateInterfaceCB)
401 def initConfig(self):
402 self.InterfaceEntry = None
403 self.dhcpEntry = None
404 self.gatewayEntry = None
405 self.DNSConfigEntry = None
406 self.hiddenSSID = None
408 self.encryption = None
409 self.encryptionType = None
410 self.encryptionKey = None
411 self.encryptionlist = None
416 def createConfig(self):
417 if iNetwork.isWirelessInterface(self.iface):
418 from Plugins.SystemPlugins.WirelessLan.Wlan import wpaSupplicant
419 self.ws = wpaSupplicant()
420 self.encryptionlist = []
421 self.encryptionlist.append(("Unencrypted", _("Unencrypted")))
422 self.encryptionlist.append(("WEP", _("WEP")))
423 self.encryptionlist.append(("WPA", _("WPA")))
424 if not iNetwork.useWlCommand(self.iface):
425 self.encryptionlist.append(("WPA/WPA2", _("WPA or WPA2")))
426 self.encryptionlist.append(("WPA2", _("WPA2")))
428 self.weplist.append("ASCII")
429 self.weplist.append("HEX")
431 self.wsconfig = self.ws.loadConfig(self.iface)
432 if self.essid is None:
433 self.essid = self.wsconfig['ssid']
435 config.plugins.wlan.hiddenessid = NoSave(ConfigYesNo(default = self.wsconfig['hiddenessid']))
436 config.plugins.wlan.essid = NoSave(ConfigText(default = self.essid, visible_width = 50, fixed_size = False))
437 config.plugins.wlan.encryption = NoSave(ConfigSelection(self.encryptionlist, default = self.wsconfig['encryption'] ))
438 config.plugins.wlan.wepkeytype = NoSave(ConfigSelection(self.weplist, default = self.wsconfig['wepkeytype'] ))
439 config.plugins.wlan.psk = NoSave(ConfigPassword(default = self.wsconfig['key'], visible_width = 50, fixed_size = False))
441 self.activateInterfaceEntry = NoSave(ConfigYesNo(default=iNetwork.getAdapterAttribute(self.iface, "up") or False))
442 self.dhcpConfigEntry = NoSave(ConfigYesNo(default=iNetwork.getAdapterAttribute(self.iface, "dhcp") or False))
443 self.ipConfigEntry = NoSave(ConfigIP(default=iNetwork.getAdapterAttribute(self.iface, "ip")) or [0,0,0,0])
444 self.netmaskConfigEntry = NoSave(ConfigIP(default=iNetwork.getAdapterAttribute(self.iface, "netmask") or [255,0,0,0]))
445 if iNetwork.getAdapterAttribute(self.iface, "gateway"):
446 self.dhcpdefault=True
448 self.dhcpdefault=False
449 self.hasGatewayConfigEntry = NoSave(ConfigYesNo(default=self.dhcpdefault or False))
450 self.gatewayConfigEntry = NoSave(ConfigIP(default=iNetwork.getAdapterAttribute(self.iface, "gateway") or [0,0,0,0]))
451 if iNetwork.getAdapterAttribute(self.iface, "dns-nameservers"):
452 self.dnsconfigdefault=True
454 self.dnsconfigdefault=False
455 self.hasDNSConfigEntry = NoSave(ConfigYesNo(default=self.dnsconfigdefault or False))
456 manualNameservers = (iNetwork.getInterfacesNameserverList(self.iface) + [[0,0,0,0]] * 2)[0:2]
457 self.manualPrimaryDNS = NoSave(ConfigIP(default=manualNameservers[0]))
458 self.manualSecondaryDNS = NoSave(ConfigIP(default=manualNameservers[1]))
459 nameserver = (iNetwork.getNameserverList() + [[0,0,0,0]] * 2)[0:2]
460 self.primaryDNS = NoSave(ConfigIP(default=nameserver[0]))
461 self.secondaryDNS = NoSave(ConfigIP(default=nameserver[1]))
463 def createSetup(self):
465 self.InterfaceEntry = getConfigListEntry(_("Use Interface"), self.activateInterfaceEntry)
467 self.list.append(self.InterfaceEntry)
468 if self.activateInterfaceEntry.value:
469 self.dhcpEntry = getConfigListEntry(_("Use DHCP"), self.dhcpConfigEntry)
470 self.list.append(self.dhcpEntry)
471 if not self.dhcpConfigEntry.value:
472 self.list.append(getConfigListEntry(_('IP Address'), self.ipConfigEntry))
473 self.list.append(getConfigListEntry(_('Netmask'), self.netmaskConfigEntry))
474 self.gatewayEntry = getConfigListEntry(_('Use a gateway'), self.hasGatewayConfigEntry)
475 self.list.append(self.gatewayEntry)
476 if self.hasGatewayConfigEntry.value:
477 self.list.append(getConfigListEntry(_('Gateway'), self.gatewayConfigEntry))
479 self.DNSConfigEntry = getConfigListEntry(_("Use Manual dns-nameserver"), self.hasDNSConfigEntry)
480 if self.dhcpConfigEntry.value:
481 self.list.append(self.DNSConfigEntry)
482 if self.hasDNSConfigEntry.value or not self.dhcpConfigEntry.value:
483 self.list.append(getConfigListEntry(_('Primary DNS'), self.manualPrimaryDNS))
484 self.list.append(getConfigListEntry(_('Secondary DNS'), self.manualSecondaryDNS))
487 self.configStrings = None
488 for p in plugins.getPlugins(PluginDescriptor.WHERE_NETWORKSETUP):
489 callFnc = p.__call__["ifaceSupported"](self.iface)
490 if callFnc is not None:
491 if p.__call__.has_key("WlanPluginEntry"): # internally used only for WLAN Plugin
492 self.extended = callFnc
493 if p.__call__.has_key("configStrings"):
494 self.configStrings = p.__call__["configStrings"]
496 self.hiddenSSID = getConfigListEntry(_("Hidden network"), config.plugins.wlan.hiddenessid)
497 self.list.append(self.hiddenSSID)
498 self.wlanSSID = getConfigListEntry(_("Networkname (SSID)"), config.plugins.wlan.essid)
499 self.list.append(self.wlanSSID)
500 self.encryption = getConfigListEntry(_("Encryption"), config.plugins.wlan.encryption)
501 self.list.append(self.encryption)
503 self.encryptionType = getConfigListEntry(_("Encryption Keytype"), config.plugins.wlan.wepkeytype)
504 self.encryptionKey = getConfigListEntry(_("Encryption Key"), config.plugins.wlan.psk)
506 if config.plugins.wlan.encryption.value != "Unencrypted":
507 if config.plugins.wlan.encryption.value == 'WEP':
508 self.list.append(self.encryptionType)
509 self.list.append(self.encryptionKey)
510 self["config"].list = self.list
511 self["config"].l.setList(self.list)
514 if self["config"].getCurrent() == self.InterfaceEntry:
516 if self["config"].getCurrent() == self.dhcpEntry:
518 if self["config"].getCurrent() == self.gatewayEntry:
520 if self["config"].getCurrent() == self.DNSConfigEntry:
522 if iNetwork.isWirelessInterface(self.iface):
523 if self["config"].getCurrent() == self.encryption:
527 ConfigListScreen.keyLeft(self)
531 ConfigListScreen.keyRight(self)
536 if self["config"].isChanged():
537 self.session.openWithCallback(self.keySaveConfirm, MessageBox, (_("Are you sure you want to activate this network configuration?\n\n") + self.oktext ) )
544 def keySaveConfirm(self, ret = False):
546 num_configured_if = len(iNetwork.getConfiguredAdapters())
547 if num_configured_if >= 1:
548 if self.iface in iNetwork.getConfiguredAdapters():
549 self.applyConfig(True)
551 self.session.openWithCallback(self.secondIfaceFoundCB, MessageBox, _("A second configured interface has been found.\n\nDo you want to disable the second network interface?"), default = True)
553 self.applyConfig(True)
557 def secondIfaceFoundCB(self,data):
559 self.applyConfig(True)
561 configuredInterfaces = iNetwork.getConfiguredAdapters()
562 for interface in configuredInterfaces:
563 if interface == self.iface:
565 iNetwork.setAdapterAttribute(interface, "up", False)
566 iNetwork.deactivateInterface(configuredInterfaces,self.deactivateSecondInterfaceCB)
568 def deactivateSecondInterfaceCB(self, data):
570 self.applyConfig(True)
572 def applyConfig(self, ret = False):
574 self.applyConfigRef = None
575 iNetwork.setAdapterAttribute(self.iface, "up", self.activateInterfaceEntry.value)
576 iNetwork.setAdapterAttribute(self.iface, "dhcp", self.dhcpConfigEntry.value)
577 iNetwork.setAdapterAttribute(self.iface, "ip", self.ipConfigEntry.value)
578 iNetwork.setAdapterAttribute(self.iface, "netmask", self.netmaskConfigEntry.value)
579 if self.hasGatewayConfigEntry.value:
580 iNetwork.setAdapterAttribute(self.iface, "gateway", self.gatewayConfigEntry.value)
582 iNetwork.removeAdapterAttribute(self.iface, "gateway")
584 if self.hasDNSConfigEntry.value or not self.dhcpConfigEntry.value:
585 interfacesDnsLines = self.makeLineDnsNameservers([self.manualPrimaryDNS.value, self.manualSecondaryDNS.value])
586 if interfacesDnsLines == "" :
587 interfacesDnsLines = False
588 iNetwork.setAdapterAttribute(self.iface, "dns-nameservers", interfacesDnsLines)
590 iNetwork.setAdapterAttribute(self.iface, "dns-nameservers", False)
592 if (self.extended is not None and self.configStrings is not None):
593 iNetwork.setAdapterAttribute(self.iface, "configStrings", self.configStrings(self.iface))
594 self.ws.writeConfig(self.iface)
596 if self.activateInterfaceEntry.value is False:
597 iNetwork.deactivateInterface(self.iface,self.deactivateInterfaceCB)
598 iNetwork.writeNetworkConfig()
599 self.applyConfigRef = self.session.openWithCallback(self.applyConfigfinishedCB, MessageBox, _("Please wait for activation of your network configuration..."), type = MessageBox.TYPE_INFO, enable_input = False)
601 if self.oldInterfaceState is False:
602 iNetwork.activateInterface(self.iface,self.deactivateInterfaceCB)
604 iNetwork.deactivateInterface(self.iface,self.activateInterfaceCB)
605 iNetwork.writeNetworkConfig()
606 self.applyConfigRef = self.session.openWithCallback(self.applyConfigfinishedCB, MessageBox, _("Please wait for activation of your network configuration..."), type = MessageBox.TYPE_INFO, enable_input = False)
610 def deactivateInterfaceCB(self, data):
612 self.applyConfigDataAvail(True)
614 def activateInterfaceCB(self, data):
616 iNetwork.activateInterface(self.iface,self.applyConfigDataAvail)
618 def applyConfigDataAvail(self, data):
620 iNetwork.getInterfaces(self.getInterfacesDataAvail)
622 def getInterfacesDataAvail(self, data):
624 self.applyConfigRef.close(True)
626 def applyConfigfinishedCB(self,data):
629 self.session.openWithCallback(lambda x : self.finished_cb(), MessageBox, _("Your network configuration has been activated."), type = MessageBox.TYPE_INFO, timeout = 10)
631 self.session.openWithCallback(self.ConfigfinishedCB, MessageBox, _("Your network configuration has been activated."), type = MessageBox.TYPE_INFO, timeout = 10)
633 def ConfigfinishedCB(self,data):
638 def keyCancelConfirm(self, result):
641 if self.oldInterfaceState is False:
642 iNetwork.deactivateInterface(self.iface,self.keyCancelCB)
648 if self["config"].isChanged():
649 self.session.openWithCallback(self.keyCancelConfirm, MessageBox, _("Really close without saving settings?"))
653 def keyCancelCB(self,data):
658 def runAsync(self, finished_cb):
659 self.finished_cb = finished_cb
662 def NameserverSetupClosed(self, *ret):
663 iNetwork.loadNameserverConfig()
664 nameserver = (iNetwork.getNameserverList() + [[0,0,0,0]] * 2)[0:2]
665 self.primaryDNS = NoSave(ConfigIP(default=nameserver[0]))
666 self.secondaryDNS = NoSave(ConfigIP(default=nameserver[1]))
668 self.layoutFinished()
671 iNetwork.stopLinkStateConsole()
673 def hideInputHelp(self):
674 current = self["config"].getCurrent()
675 if self.wlanSSID is not None and current == self.wlanSSID:
676 if current[1].help_window.instance is not None:
677 current[1].help_window.instance.hide()
678 elif self.encryptionKey is not None and current == self.encryptionKey and config.plugins.wlan.encryption.value is not "Unencrypted":
679 if current[1].help_window.instance is not None:
680 current[1].help_window.instance.hide()
682 def makeLineDnsNameservers(self, nameservers = []):
684 entry = ' '.join([("%d.%d.%d.%d" % tuple(x)) for x in nameservers if x != [0, 0, 0, 0] ])
686 line+="\tdns-nameservers %s\n" % entry
689 class AdapterSetupConfiguration(Screen, HelpableScreen):
690 def __init__(self, session,iface):
691 Screen.__init__(self, session)
692 HelpableScreen.__init__(self)
693 self.session = session
695 self.restartLanRef = None
696 self.LinkState = None
697 self.mainmenu = self.genMainMenu()
698 self["menulist"] = MenuList(self.mainmenu)
699 self["key_red"] = StaticText(_("Close"))
700 self["description"] = StaticText()
701 self["IFtext"] = StaticText()
702 self["IF"] = StaticText()
703 self["Statustext"] = StaticText()
704 self["statuspic"] = MultiPixmap()
705 self["statuspic"].hide()
707 self.oktext = _("Press OK on your remote control to continue.")
708 self.reboottext = _("Your STB will restart after pressing OK on your remote control.")
709 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.")
710 self.missingwlanplugintxt = _("The wireless LAN plugin is not installed!\nPlease install it.")
712 self["WizardActions"] = HelpableActionMap(self, "WizardActions",
714 "up": (self.up, _("move up to previous entry")),
715 "down": (self.down, _("move down to next entry")),
716 "left": (self.left, _("move up to first entry")),
717 "right": (self.right, _("move down to last entry")),
720 self["OkCancelActions"] = HelpableActionMap(self, "OkCancelActions",
722 "cancel": (self.close, _("exit networkadapter setup menu")),
723 "ok": (self.ok, _("select menu entry")),
726 self["ColorActions"] = HelpableActionMap(self, "ColorActions",
728 "red": (self.close, _("exit networkadapter setup menu")),
731 self["actions"] = NumberActionMap(["WizardActions","ShortcutActions"],
742 self.updateStatusbar()
743 self.onLayoutFinish.append(self.layoutFinished)
744 self.onClose.append(self.cleanup)
747 def queryWirelessDevice(self,iface):
749 from pythonwifi.iwlibs import Wireless
755 ifobj = Wireless(iface) # a Wireless NIC Object
756 wlanresponse = ifobj.getAPaddr()
757 except IOError, (error_no, error_str):
758 if error_no in (errno.EOPNOTSUPP, errno.ENODEV, errno.EPERM):
761 print "error: ",error_no,error_str
768 if self["menulist"].getCurrent()[1] == 'edit':
769 if iNetwork.isWirelessInterface(self.iface):
771 from Plugins.SystemPlugins.WirelessLan.plugin import WlanScan
773 self.session.open(MessageBox, self.missingwlanplugintxt, type = MessageBox.TYPE_INFO,timeout = 10 )
775 if self.queryWirelessDevice(self.iface):
776 self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetup,self.iface)
778 self.showErrorMessage() # Display Wlan not available Message
780 self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetup,self.iface)
781 if self["menulist"].getCurrent()[1] == 'test':
782 self.session.open(NetworkAdapterTest,self.iface)
783 if self["menulist"].getCurrent()[1] == 'dns':
784 self.session.open(NameserverSetup)
785 if self["menulist"].getCurrent()[1] == 'scanwlan':
787 from Plugins.SystemPlugins.WirelessLan.plugin import WlanScan
789 self.session.open(MessageBox, self.missingwlanplugintxt, type = MessageBox.TYPE_INFO,timeout = 10 )
791 if self.queryWirelessDevice(self.iface):
792 self.session.openWithCallback(self.WlanScanClosed, WlanScan, self.iface)
794 self.showErrorMessage() # Display Wlan not available Message
795 if self["menulist"].getCurrent()[1] == 'wlanstatus':
797 from Plugins.SystemPlugins.WirelessLan.plugin import WlanStatus
799 self.session.open(MessageBox, self.missingwlanplugintxt, type = MessageBox.TYPE_INFO,timeout = 10 )
801 if self.queryWirelessDevice(self.iface):
802 self.session.openWithCallback(self.WlanStatusClosed, WlanStatus,self.iface)
804 self.showErrorMessage() # Display Wlan not available Message
805 if self["menulist"].getCurrent()[1] == 'lanrestart':
806 self.session.openWithCallback(self.restartLan, MessageBox, (_("Are you sure you want to restart your network interfaces?\n\n") + self.oktext ) )
807 if self["menulist"].getCurrent()[1] == 'openwizard':
808 from Plugins.SystemPlugins.NetworkWizard.NetworkWizard import NetworkWizard
809 self.session.openWithCallback(self.AdapterSetupClosed, NetworkWizard, self.iface)
810 if self["menulist"].getCurrent()[1][0] == 'extendedSetup':
811 self.extended = self["menulist"].getCurrent()[1][2]
812 self.extended(self.session, self.iface)
815 self["menulist"].up()
816 self.loadDescription()
819 self["menulist"].down()
820 self.loadDescription()
823 self["menulist"].pageUp()
824 self.loadDescription()
827 self["menulist"].pageDown()
828 self.loadDescription()
830 def layoutFinished(self):
832 self["menulist"].moveToIndex(idx)
833 self.loadDescription()
835 def loadDescription(self):
836 if self["menulist"].getCurrent()[1] == 'edit':
837 self["description"].setText(_("Edit the network configuration of your STB.\n" ) + self.oktext )
838 if self["menulist"].getCurrent()[1] == 'test':
839 self["description"].setText(_("Test the network configuration of your STB.\n" ) + self.oktext )
840 if self["menulist"].getCurrent()[1] == 'dns':
841 self["description"].setText(_("Edit the Nameserver configuration of your STB.\n" ) + self.oktext )
842 if self["menulist"].getCurrent()[1] == 'scanwlan':
843 self["description"].setText(_("Scan your network for wireless access points and connect to them using your selected wireless device.\n" ) + self.oktext )
844 if self["menulist"].getCurrent()[1] == 'wlanstatus':
845 self["description"].setText(_("Shows the state of your wireless LAN connection.\n" ) + self.oktext )
846 if self["menulist"].getCurrent()[1] == 'lanrestart':
847 self["description"].setText(_("Restart your network connection and interfaces.\n" ) + self.oktext )
848 if self["menulist"].getCurrent()[1] == 'openwizard':
849 self["description"].setText(_("Use the Networkwizard to configure your Network\n" ) + self.oktext )
850 if self["menulist"].getCurrent()[1][0] == 'extendedSetup':
851 self["description"].setText(_(self["menulist"].getCurrent()[1][1]) + self.oktext )
853 def updateStatusbar(self, data = None):
854 self.mainmenu = self.genMainMenu()
855 self["menulist"].l.setList(self.mainmenu)
856 self["IFtext"].setText(_("Network:"))
857 self["IF"].setText(iNetwork.getFriendlyAdapterName(self.iface))
858 self["Statustext"].setText(_("Link:"))
860 if iNetwork.isWirelessInterface(self.iface):
862 from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus
864 self["statuspic"].setPixmapNum(1)
865 self["statuspic"].show()
867 iStatus.getDataForInterface(self.iface,self.getInfoCB)
869 iNetwork.getLinkState(self.iface,self.dataAvail)
874 def genMainMenu(self):
876 menu.append((_("Adapter settings"), "edit"))
877 # menu.append((_("Nameserver settings"), "dns"))
878 menu.append((_("Network test"), "test"))
879 menu.append((_("Restart network"), "lanrestart"))
882 self.extendedSetup = None
883 for p in plugins.getPlugins(PluginDescriptor.WHERE_NETWORKSETUP):
884 callFnc = p.__call__["ifaceSupported"](self.iface)
885 if callFnc is not None:
886 self.extended = callFnc
887 if p.__call__.has_key("WlanPluginEntry"): # internally used only for WLAN Plugin
888 menu.append((_("Scan Wireless Networks"), "scanwlan"))
889 if iNetwork.getAdapterAttribute(self.iface, "up"):
890 menu.append((_("Show WLAN Status"), "wlanstatus"))
892 if p.__call__.has_key("menuEntryName"):
893 menuEntryName = p.__call__["menuEntryName"](self.iface)
895 menuEntryName = _('Extended Setup...')
896 if p.__call__.has_key("menuEntryDescription"):
897 menuEntryDescription = p.__call__["menuEntryDescription"](self.iface)
899 menuEntryDescription = _('Extended Networksetup Plugin...')
900 self.extendedSetup = ('extendedSetup',menuEntryDescription, self.extended)
901 menu.append((menuEntryName,self.extendedSetup))
903 if os_path.exists(resolveFilename(SCOPE_PLUGINS, "SystemPlugins/NetworkWizard/networkwizard.xml")):
904 menu.append((_("NetworkWizard"), "openwizard"))
908 def AdapterSetupClosed(self, *ret):
909 if ret is not None and len(ret):
910 if ret[0] == 'ok' and (iNetwork.isWirelessInterface(self.iface) and iNetwork.getAdapterAttribute(self.iface, "up") is True):
912 from Plugins.SystemPlugins.WirelessLan.plugin import WlanStatus
914 self.session.open(MessageBox, self.missingwlanplugintxt, type = MessageBox.TYPE_INFO,timeout = 10 )
916 if self.queryWirelessDevice(self.iface):
917 self.session.openWithCallback(self.WlanStatusClosed, WlanStatus,self.iface)
919 self.showErrorMessage() # Display Wlan not available Message
921 self.updateStatusbar()
923 self.updateStatusbar()
925 def WlanStatusClosed(self, *ret):
926 if ret is not None and len(ret):
927 from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus
928 iStatus.stopWlanConsole()
929 self.updateStatusbar()
931 def WlanScanClosed(self,*ret):
932 if ret[0] is not None:
933 self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetup, self.iface,ret[0])
935 from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus
936 iStatus.stopWlanConsole()
937 self.updateStatusbar()
939 def restartLan(self, ret = False):
941 iNetwork.restartNetwork(self.restartLanDataAvail)
942 self.restartLanRef = self.session.openWithCallback(self.restartfinishedCB, MessageBox, _("Please wait while your network is restarting..."), type = MessageBox.TYPE_INFO, enable_input = False)
944 def restartLanDataAvail(self, data):
946 iNetwork.getInterfaces(self.getInterfacesDataAvail)
948 def getInterfacesDataAvail(self, data):
950 self.restartLanRef.close(True)
952 def restartfinishedCB(self,data):
954 self.updateStatusbar()
955 self.session.open(MessageBox, _("Finished restarting your network"), type = MessageBox.TYPE_INFO, timeout = 10, default = False)
957 def dataAvail(self,data):
958 self.LinkState = None
959 for line in data.splitlines():
961 if 'Link detected:' in line:
963 self.LinkState = True
965 self.LinkState = False
966 if self.LinkState == True:
967 iNetwork.checkNetworkState(self.checkNetworkCB)
969 self["statuspic"].setPixmapNum(1)
970 self["statuspic"].show()
972 def showErrorMessage(self):
973 self.session.open(MessageBox, self.errortext, type = MessageBox.TYPE_INFO,timeout = 10 )
976 iNetwork.stopLinkStateConsole()
977 iNetwork.stopDeactivateInterfaceConsole()
978 iNetwork.stopActivateInterfaceConsole()
979 iNetwork.stopPingConsole()
981 from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus
985 iStatus.stopWlanConsole()
987 def getInfoCB(self,data,status):
988 self.LinkState = None
991 if status is not None:
992 if status[self.iface]["essid"] == "off" or status[self.iface]["accesspoint"] == "Not-Associated" or status[self.iface]["accesspoint"] == False:
993 self.LinkState = False
994 self["statuspic"].setPixmapNum(1)
995 self["statuspic"].show()
997 self.LinkState = True
998 iNetwork.checkNetworkState(self.checkNetworkCB)
1000 def checkNetworkCB(self,data):
1002 if iNetwork.getAdapterAttribute(self.iface, "up") is True:
1003 if self.LinkState is True:
1005 self["statuspic"].setPixmapNum(0)
1007 self["statuspic"].setPixmapNum(1)
1008 self["statuspic"].show()
1010 self["statuspic"].setPixmapNum(1)
1011 self["statuspic"].show()
1013 self["statuspic"].setPixmapNum(1)
1014 self["statuspic"].show()
1018 class NetworkAdapterTest(Screen):
1019 def __init__(self, session,iface):
1020 Screen.__init__(self, session)
1022 self.oldInterfaceState = iNetwork.getAdapterAttribute(self.iface, "up")
1024 self.onClose.append(self.cleanup)
1025 self.onHide.append(self.cleanup)
1027 self["updown_actions"] = NumberActionMap(["WizardActions","ShortcutActions"],
1031 "up": lambda: self.updownhandler('up'),
1032 "down": lambda: self.updownhandler('down'),
1036 self["shortcuts"] = ActionMap(["ShortcutActions","WizardActions"],
1039 "back": self.cancel,
1041 self["infoshortcuts"] = ActionMap(["ShortcutActions","WizardActions"],
1043 "red": self.closeInfo,
1044 "back": self.closeInfo,
1046 self["shortcutsgreen"] = ActionMap(["ShortcutActions"],
1048 "green": self.KeyGreen,
1050 self["shortcutsgreen_restart"] = ActionMap(["ShortcutActions"],
1052 "green": self.KeyGreenRestart,
1054 self["shortcutsyellow"] = ActionMap(["ShortcutActions"],
1056 "yellow": self.KeyYellow,
1059 self["shortcutsgreen_restart"].setEnabled(False)
1060 self["updown_actions"].setEnabled(False)
1061 self["infoshortcuts"].setEnabled(False)
1062 self.onClose.append(self.delTimer)
1063 self.onLayoutFinish.append(self.layoutFinished)
1064 self.steptimer = False
1066 self.activebutton = 0
1067 self.nextStepTimer = eTimer()
1068 self.nextStepTimer.callback.append(self.nextStepTimerFire)
1071 if self.oldInterfaceState is False:
1072 iNetwork.setAdapterAttribute(self.iface, "up", self.oldInterfaceState)
1073 iNetwork.deactivateInterface(self.iface)
1076 def closeInfo(self):
1077 self["shortcuts"].setEnabled(True)
1078 self["infoshortcuts"].setEnabled(False)
1079 self["InfoText"].hide()
1080 self["InfoTextBorder"].hide()
1081 self["key_red"].setText(_("Close"))
1085 del self.nextStepTimer
1087 def nextStepTimerFire(self):
1088 self.nextStepTimer.stop()
1089 self.steptimer = False
1092 def updownhandler(self,direction):
1093 if direction == 'up':
1094 if self.activebutton >=2:
1095 self.activebutton -= 1
1097 self.activebutton = 6
1098 self.setActiveButton(self.activebutton)
1099 if direction == 'down':
1100 if self.activebutton <=5:
1101 self.activebutton += 1
1103 self.activebutton = 1
1104 self.setActiveButton(self.activebutton)
1106 def setActiveButton(self,button):
1108 self["EditSettingsButton"].setPixmapNum(0)
1109 self["EditSettings_Text"].setForegroundColorNum(0)
1110 self["NetworkInfo"].setPixmapNum(0)
1111 self["NetworkInfo_Text"].setForegroundColorNum(1)
1112 self["AdapterInfo"].setPixmapNum(1) # active
1113 self["AdapterInfo_Text"].setForegroundColorNum(2) # active
1115 self["AdapterInfo_Text"].setForegroundColorNum(1)
1116 self["AdapterInfo"].setPixmapNum(0)
1117 self["DhcpInfo"].setPixmapNum(0)
1118 self["DhcpInfo_Text"].setForegroundColorNum(1)
1119 self["NetworkInfo"].setPixmapNum(1) # active
1120 self["NetworkInfo_Text"].setForegroundColorNum(2) # active
1122 self["NetworkInfo"].setPixmapNum(0)
1123 self["NetworkInfo_Text"].setForegroundColorNum(1)
1124 self["IPInfo"].setPixmapNum(0)
1125 self["IPInfo_Text"].setForegroundColorNum(1)
1126 self["DhcpInfo"].setPixmapNum(1) # active
1127 self["DhcpInfo_Text"].setForegroundColorNum(2) # active
1129 self["DhcpInfo"].setPixmapNum(0)
1130 self["DhcpInfo_Text"].setForegroundColorNum(1)
1131 self["DNSInfo"].setPixmapNum(0)
1132 self["DNSInfo_Text"].setForegroundColorNum(1)
1133 self["IPInfo"].setPixmapNum(1) # active
1134 self["IPInfo_Text"].setForegroundColorNum(2) # active
1136 self["IPInfo"].setPixmapNum(0)
1137 self["IPInfo_Text"].setForegroundColorNum(1)
1138 self["EditSettingsButton"].setPixmapNum(0)
1139 self["EditSettings_Text"].setForegroundColorNum(0)
1140 self["DNSInfo"].setPixmapNum(1) # active
1141 self["DNSInfo_Text"].setForegroundColorNum(2) # active
1143 self["DNSInfo"].setPixmapNum(0)
1144 self["DNSInfo_Text"].setForegroundColorNum(1)
1145 self["EditSettingsButton"].setPixmapNum(1) # active
1146 self["EditSettings_Text"].setForegroundColorNum(2) # active
1147 self["AdapterInfo"].setPixmapNum(0)
1148 self["AdapterInfo_Text"].setForegroundColorNum(1)
1151 next = self.nextstep
1167 self.steptimer = True
1168 self.nextStepTimer.start(3000)
1169 self["key_yellow"].setText(_("Stop test"))
1172 self["Adapter"].setText(iNetwork.getFriendlyAdapterName(self.iface))
1173 self["Adapter"].setForegroundColorNum(2)
1174 self["Adaptertext"].setForegroundColorNum(1)
1175 self["AdapterInfo_Text"].setForegroundColorNum(1)
1176 self["AdapterInfo_OK"].show()
1177 self.steptimer = True
1178 self.nextStepTimer.start(3000)
1181 self["Networktext"].setForegroundColorNum(1)
1182 self["Network"].setText(_("Please wait..."))
1183 self.getLinkState(self.iface)
1184 self["NetworkInfo_Text"].setForegroundColorNum(1)
1185 self.steptimer = True
1186 self.nextStepTimer.start(3000)
1189 self["Dhcptext"].setForegroundColorNum(1)
1190 if iNetwork.getAdapterAttribute(self.iface, 'dhcp') is True:
1191 self["Dhcp"].setForegroundColorNum(2)
1192 self["Dhcp"].setText(_("enabled"))
1193 self["DhcpInfo_Check"].setPixmapNum(0)
1195 self["Dhcp"].setForegroundColorNum(1)
1196 self["Dhcp"].setText(_("disabled"))
1197 self["DhcpInfo_Check"].setPixmapNum(1)
1198 self["DhcpInfo_Check"].show()
1199 self["DhcpInfo_Text"].setForegroundColorNum(1)
1200 self.steptimer = True
1201 self.nextStepTimer.start(3000)
1204 self["IPtext"].setForegroundColorNum(1)
1205 self["IP"].setText(_("Please wait..."))
1206 iNetwork.checkNetworkState(self.NetworkStatedataAvail)
1209 self.steptimer = False
1210 self.nextStepTimer.stop()
1211 self["DNStext"].setForegroundColorNum(1)
1212 self["DNS"].setText(_("Please wait..."))
1213 iNetwork.checkDNSLookup(self.DNSLookupdataAvail)
1216 self["shortcutsgreen"].setEnabled(False)
1217 self["shortcutsyellow"].setEnabled(True)
1218 self["updown_actions"].setEnabled(False)
1219 self["key_yellow"].setText("")
1220 self["key_green"].setText("")
1221 self.steptimer = True
1222 self.nextStepTimer.start(1000)
1224 def KeyGreenRestart(self):
1226 self.layoutFinished()
1227 self["Adapter"].setText((""))
1228 self["Network"].setText((""))
1229 self["Dhcp"].setText((""))
1230 self["IP"].setText((""))
1231 self["DNS"].setText((""))
1232 self["AdapterInfo_Text"].setForegroundColorNum(0)
1233 self["NetworkInfo_Text"].setForegroundColorNum(0)
1234 self["DhcpInfo_Text"].setForegroundColorNum(0)
1235 self["IPInfo_Text"].setForegroundColorNum(0)
1236 self["DNSInfo_Text"].setForegroundColorNum(0)
1237 self["shortcutsgreen_restart"].setEnabled(False)
1238 self["shortcutsgreen"].setEnabled(False)
1239 self["shortcutsyellow"].setEnabled(True)
1240 self["updown_actions"].setEnabled(False)
1241 self["key_yellow"].setText("")
1242 self["key_green"].setText("")
1243 self.steptimer = True
1244 self.nextStepTimer.start(1000)
1247 self["infoshortcuts"].setEnabled(True)
1248 self["shortcuts"].setEnabled(False)
1249 if self.activebutton == 1: # Adapter Check
1250 self["InfoText"].setText(_("This test detects your configured LAN-Adapter."))
1251 self["InfoTextBorder"].show()
1252 self["InfoText"].show()
1253 self["key_red"].setText(_("Back"))
1254 if self.activebutton == 2: #LAN Check
1255 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"))
1256 self["InfoTextBorder"].show()
1257 self["InfoText"].show()
1258 self["key_red"].setText(_("Back"))
1259 if self.activebutton == 3: #DHCP Check
1260 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."))
1261 self["InfoTextBorder"].show()
1262 self["InfoText"].show()
1263 self["key_red"].setText(_("Back"))
1264 if self.activebutton == 4: # IP Check
1265 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"))
1266 self["InfoTextBorder"].show()
1267 self["InfoText"].show()
1268 self["key_red"].setText(_("Back"))
1269 if self.activebutton == 5: # DNS Check
1270 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"))
1271 self["InfoTextBorder"].show()
1272 self["InfoText"].show()
1273 self["key_red"].setText(_("Back"))
1274 if self.activebutton == 6: # Edit Settings
1275 self.session.open(AdapterSetup,self.iface)
1277 def KeyYellow(self):
1279 self["shortcutsgreen_restart"].setEnabled(True)
1280 self["shortcutsgreen"].setEnabled(False)
1281 self["shortcutsyellow"].setEnabled(False)
1282 self["key_green"].setText(_("Restart test"))
1283 self["key_yellow"].setText("")
1284 self.steptimer = False
1285 self.nextStepTimer.stop()
1287 def layoutFinished(self):
1288 self.setTitle(_("Network test: ") + iNetwork.getFriendlyAdapterName(self.iface) )
1289 self["shortcutsyellow"].setEnabled(False)
1290 self["AdapterInfo_OK"].hide()
1291 self["NetworkInfo_Check"].hide()
1292 self["DhcpInfo_Check"].hide()
1293 self["IPInfo_Check"].hide()
1294 self["DNSInfo_Check"].hide()
1295 self["EditSettings_Text"].hide()
1296 self["EditSettingsButton"].hide()
1297 self["InfoText"].hide()
1298 self["InfoTextBorder"].hide()
1299 self["key_yellow"].setText("")
1301 def setLabels(self):
1302 self["Adaptertext"] = MultiColorLabel(_("LAN Adapter"))
1303 self["Adapter"] = MultiColorLabel()
1304 self["AdapterInfo"] = MultiPixmap()
1305 self["AdapterInfo_Text"] = MultiColorLabel(_("Show Info"))
1306 self["AdapterInfo_OK"] = Pixmap()
1308 if self.iface in iNetwork.wlan_interfaces:
1309 self["Networktext"] = MultiColorLabel(_("Wireless Network"))
1311 self["Networktext"] = MultiColorLabel(_("Local Network"))
1313 self["Network"] = MultiColorLabel()
1314 self["NetworkInfo"] = MultiPixmap()
1315 self["NetworkInfo_Text"] = MultiColorLabel(_("Show Info"))
1316 self["NetworkInfo_Check"] = MultiPixmap()
1318 self["Dhcptext"] = MultiColorLabel(_("DHCP"))
1319 self["Dhcp"] = MultiColorLabel()
1320 self["DhcpInfo"] = MultiPixmap()
1321 self["DhcpInfo_Text"] = MultiColorLabel(_("Show Info"))
1322 self["DhcpInfo_Check"] = MultiPixmap()
1324 self["IPtext"] = MultiColorLabel(_("IP Address"))
1325 self["IP"] = MultiColorLabel()
1326 self["IPInfo"] = MultiPixmap()
1327 self["IPInfo_Text"] = MultiColorLabel(_("Show Info"))
1328 self["IPInfo_Check"] = MultiPixmap()
1330 self["DNStext"] = MultiColorLabel(_("Nameserver"))
1331 self["DNS"] = MultiColorLabel()
1332 self["DNSInfo"] = MultiPixmap()
1333 self["DNSInfo_Text"] = MultiColorLabel(_("Show Info"))
1334 self["DNSInfo_Check"] = MultiPixmap()
1336 self["EditSettings_Text"] = MultiColorLabel(_("Edit settings"))
1337 self["EditSettingsButton"] = MultiPixmap()
1339 self["key_red"] = StaticText(_("Close"))
1340 self["key_green"] = StaticText(_("Start test"))
1341 self["key_yellow"] = StaticText(_("Stop test"))
1343 self["InfoTextBorder"] = Pixmap()
1344 self["InfoText"] = Label()
1346 def getLinkState(self,iface):
1347 if iface in iNetwork.wlan_interfaces:
1349 from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus
1351 self["Network"].setForegroundColorNum(1)
1352 self["Network"].setText(_("disconnected"))
1353 self["NetworkInfo_Check"].setPixmapNum(1)
1354 self["NetworkInfo_Check"].show()
1356 iStatus.getDataForInterface(self.iface,self.getInfoCB)
1358 iNetwork.getLinkState(iface,self.LinkStatedataAvail)
1360 def LinkStatedataAvail(self,data):
1361 self.output = data.strip()
1362 result = self.output.splitlines()
1363 pattern = re_compile("Link detected: yes")
1365 if re_search(pattern, item):
1366 self["Network"].setForegroundColorNum(2)
1367 self["Network"].setText(_("connected"))
1368 self["NetworkInfo_Check"].setPixmapNum(0)
1370 self["Network"].setForegroundColorNum(1)
1371 self["Network"].setText(_("disconnected"))
1372 self["NetworkInfo_Check"].setPixmapNum(1)
1373 self["NetworkInfo_Check"].show()
1375 def NetworkStatedataAvail(self,data):
1377 self["IP"].setForegroundColorNum(2)
1378 self["IP"].setText(_("confirmed"))
1379 self["IPInfo_Check"].setPixmapNum(0)
1381 self["IP"].setForegroundColorNum(1)
1382 self["IP"].setText(_("unconfirmed"))
1383 self["IPInfo_Check"].setPixmapNum(1)
1384 self["IPInfo_Check"].show()
1385 self["IPInfo_Text"].setForegroundColorNum(1)
1386 self.steptimer = True
1387 self.nextStepTimer.start(3000)
1389 def DNSLookupdataAvail(self,data):
1391 self["DNS"].setForegroundColorNum(2)
1392 self["DNS"].setText(_("confirmed"))
1393 self["DNSInfo_Check"].setPixmapNum(0)
1395 self["DNS"].setForegroundColorNum(1)
1396 self["DNS"].setText(_("unconfirmed"))
1397 self["DNSInfo_Check"].setPixmapNum(1)
1398 self["DNSInfo_Check"].show()
1399 self["DNSInfo_Text"].setForegroundColorNum(1)
1400 self["EditSettings_Text"].show()
1401 self["EditSettingsButton"].setPixmapNum(1)
1402 self["EditSettings_Text"].setForegroundColorNum(2) # active
1403 self["EditSettingsButton"].show()
1404 self["key_yellow"].setText("")
1405 self["key_green"].setText(_("Restart test"))
1406 self["shortcutsgreen"].setEnabled(False)
1407 self["shortcutsgreen_restart"].setEnabled(True)
1408 self["shortcutsyellow"].setEnabled(False)
1409 self["updown_actions"].setEnabled(True)
1410 self.activebutton = 6
1412 def getInfoCB(self,data,status):
1413 if data is not None:
1415 if status is not None:
1416 if status[self.iface]["essid"] == "off" or status[self.iface]["accesspoint"] == "Not-Associated" or status[self.iface]["accesspoint"] == False:
1417 self["Network"].setForegroundColorNum(1)
1418 self["Network"].setText(_("disconnected"))
1419 self["NetworkInfo_Check"].setPixmapNum(1)
1420 self["NetworkInfo_Check"].show()
1422 self["Network"].setForegroundColorNum(2)
1423 self["Network"].setText(_("connected"))
1424 self["NetworkInfo_Check"].setPixmapNum(0)
1425 self["NetworkInfo_Check"].show()
1428 iNetwork.stopLinkStateConsole()
1429 iNetwork.stopDNSConsole()
1431 from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus
1435 iStatus.stopWlanConsole()