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")
318 self["OkCancelActions"] = HelpableActionMap(self, "OkCancelActions",
320 "cancel": (self.keyCancel, _("exit network adapter configuration")),
321 "ok": (self.keySave, _("activate network adapter configuration")),
324 self["ColorActions"] = HelpableActionMap(self, "ColorActions",
326 "red": (self.keyCancel, _("exit network adapter configuration")),
327 "blue": (self.KeyBlue, _("open nameserver configuration")),
330 self["actions"] = NumberActionMap(["SetupActions"],
336 ConfigListScreen.__init__(self, self.list,session = self.session)
338 self.onLayoutFinish.append(self.layoutFinished)
339 self.onClose.append(self.cleanup)
341 self["DNS1text"] = StaticText(_("Primary DNS"))
342 self["DNS2text"] = StaticText(_("Secondary DNS"))
343 self["DNS1"] = StaticText()
344 self["DNS2"] = StaticText()
345 self["introduction"] = StaticText(_("Current settings:"))
347 self["IPtext"] = StaticText(_("IP Address"))
348 self["Netmasktext"] = StaticText(_("Netmask"))
349 self["Gatewaytext"] = StaticText(_("Gateway"))
351 self["IP"] = StaticText()
352 self["Mask"] = StaticText()
353 self["Gateway"] = StaticText()
355 self["Adaptertext"] = StaticText(_("Network:"))
356 self["Adapter"] = StaticText()
357 self["introduction2"] = StaticText(_("Press OK to activate the settings."))
358 self["key_red"] = StaticText(_("Cancel"))
359 self["key_blue"] = StaticText(_("Edit DNS"))
361 self["VKeyIcon"] = Boolean(False)
362 self["HelpWindow"] = Pixmap()
363 self["HelpWindow"].hide()
365 def layoutFinished(self):
366 self["DNS1"].setText(self.primaryDNS.getText())
367 self["DNS2"].setText(self.secondaryDNS.getText())
368 if self.ipConfigEntry.getText() is not None:
369 if self.ipConfigEntry.getText() == "0.0.0.0":
370 self["IP"].setText(_("N/A"))
372 self["IP"].setText(self.ipConfigEntry.getText())
374 self["IP"].setText(_("N/A"))
375 if self.netmaskConfigEntry.getText() is not None:
376 if self.netmaskConfigEntry.getText() == "0.0.0.0":
377 self["Mask"].setText(_("N/A"))
379 self["Mask"].setText(self.netmaskConfigEntry.getText())
381 self["IP"].setText(_("N/A"))
382 if iNetwork.getAdapterAttribute(self.iface, "gateway"):
383 if self.gatewayConfigEntry.getText() == "0.0.0.0":
384 self["Gatewaytext"].setText(_("Gateway"))
385 self["Gateway"].setText(_("N/A"))
387 self["Gatewaytext"].setText(_("Gateway"))
388 self["Gateway"].setText(self.gatewayConfigEntry.getText())
390 self["Gateway"].setText("")
391 self["Gatewaytext"].setText("")
392 self["Adapter"].setText(iNetwork.getFriendlyAdapterName(self.iface))
394 def createConfig(self):
395 self.InterfaceEntry = None
396 self.dhcpEntry = None
397 self.gatewayEntry = None
398 self.hiddenSSID = None
400 self.encryption = None
401 self.encryptionType = None
402 self.encryptionKey = None
403 self.encryptionlist = None
408 if iNetwork.isWirelessInterface(self.iface):
409 from Plugins.SystemPlugins.WirelessLan.Wlan import wpaSupplicant
410 self.ws = wpaSupplicant()
411 self.encryptionlist = []
412 self.encryptionlist.append(("Unencrypted", _("Unencrypted")))
413 self.encryptionlist.append(("WEP", _("WEP")))
414 self.encryptionlist.append(("WPA", _("WPA")))
415 self.encryptionlist.append(("WPA/WPA2", _("WPA or WPA2")))
416 self.encryptionlist.append(("WPA2", _("WPA2")))
418 self.weplist.append("ASCII")
419 self.weplist.append("HEX")
421 self.wsconfig = self.ws.loadConfig(self.iface)
422 if self.essid is None:
423 self.essid = self.wsconfig['ssid']
425 config.plugins.wlan.hiddenessid = NoSave(ConfigYesNo(default = self.wsconfig['hiddenessid']))
426 config.plugins.wlan.essid = NoSave(ConfigText(default = self.essid, visible_width = 50, fixed_size = False))
427 config.plugins.wlan.encryption = NoSave(ConfigSelection(self.encryptionlist, default = self.wsconfig['encryption'] ))
428 config.plugins.wlan.wepkeytype = NoSave(ConfigSelection(self.weplist, default = self.wsconfig['wepkeytype'] ))
429 config.plugins.wlan.psk = NoSave(ConfigPassword(default = self.wsconfig['key'], visible_width = 50, fixed_size = False))
431 self.activateInterfaceEntry = NoSave(ConfigYesNo(default=iNetwork.getAdapterAttribute(self.iface, "up") or False))
432 self.dhcpConfigEntry = NoSave(ConfigYesNo(default=iNetwork.getAdapterAttribute(self.iface, "dhcp") or False))
433 self.ipConfigEntry = NoSave(ConfigIP(default=iNetwork.getAdapterAttribute(self.iface, "ip")) or [0,0,0,0])
434 self.netmaskConfigEntry = NoSave(ConfigIP(default=iNetwork.getAdapterAttribute(self.iface, "netmask") or [255,0,0,0]))
435 if iNetwork.getAdapterAttribute(self.iface, "gateway"):
436 self.dhcpdefault=True
438 self.dhcpdefault=False
439 self.hasGatewayConfigEntry = NoSave(ConfigYesNo(default=self.dhcpdefault or False))
440 self.gatewayConfigEntry = NoSave(ConfigIP(default=iNetwork.getAdapterAttribute(self.iface, "gateway") or [0,0,0,0]))
441 nameserver = (iNetwork.getNameserverList() + [[0,0,0,0]] * 2)[0:2]
442 self.primaryDNS = NoSave(ConfigIP(default=nameserver[0]))
443 self.secondaryDNS = NoSave(ConfigIP(default=nameserver[1]))
445 def createSetup(self):
447 self.InterfaceEntry = getConfigListEntry(_("Use Interface"), self.activateInterfaceEntry)
449 self.list.append(self.InterfaceEntry)
450 if self.activateInterfaceEntry.value:
451 self.dhcpEntry = getConfigListEntry(_("Use DHCP"), self.dhcpConfigEntry)
452 self.list.append(self.dhcpEntry)
453 if not self.dhcpConfigEntry.value:
454 self.list.append(getConfigListEntry(_('IP Address'), self.ipConfigEntry))
455 self.list.append(getConfigListEntry(_('Netmask'), self.netmaskConfigEntry))
456 self.gatewayEntry = getConfigListEntry(_('Use a gateway'), self.hasGatewayConfigEntry)
457 self.list.append(self.gatewayEntry)
458 if self.hasGatewayConfigEntry.value:
459 self.list.append(getConfigListEntry(_('Gateway'), self.gatewayConfigEntry))
462 self.configStrings = None
463 for p in plugins.getPlugins(PluginDescriptor.WHERE_NETWORKSETUP):
464 callFnc = p.__call__["ifaceSupported"](self.iface)
465 if callFnc is not None:
466 if p.__call__.has_key("WlanPluginEntry"): # internally used only for WLAN Plugin
467 self.extended = callFnc
468 if p.__call__.has_key("configStrings"):
469 self.configStrings = p.__call__["configStrings"]
471 self.hiddenSSID = getConfigListEntry(_("Hidden network"), config.plugins.wlan.hiddenessid)
472 self.list.append(self.hiddenSSID)
473 self.wlanSSID = getConfigListEntry(_("Networkname (SSID)"), config.plugins.wlan.essid)
474 self.list.append(self.wlanSSID)
475 self.encryption = getConfigListEntry(_("Encryption"), config.plugins.wlan.encryption)
476 self.list.append(self.encryption)
478 self.encryptionType = getConfigListEntry(_("Encryption Keytype"), config.plugins.wlan.wepkeytype)
479 self.encryptionKey = getConfigListEntry(_("Encryption Key"), config.plugins.wlan.psk)
481 if config.plugins.wlan.encryption.value != "Unencrypted":
482 if config.plugins.wlan.encryption.value == 'WEP':
483 self.list.append(self.encryptionType)
484 self.list.append(self.encryptionKey)
485 self["config"].list = self.list
486 self["config"].l.setList(self.list)
489 self.session.openWithCallback(self.NameserverSetupClosed, NameserverSetup)
492 if self["config"].getCurrent() == self.InterfaceEntry:
494 if self["config"].getCurrent() == self.dhcpEntry:
496 if self["config"].getCurrent() == self.gatewayEntry:
498 if iNetwork.isWirelessInterface(self.iface):
499 if self["config"].getCurrent() == self.encryption:
503 ConfigListScreen.keyLeft(self)
507 ConfigListScreen.keyRight(self)
512 if self["config"].isChanged():
513 self.session.openWithCallback(self.keySaveConfirm, MessageBox, (_("Are you sure you want to activate this network configuration?\n\n") + self.oktext ) )
520 def keySaveConfirm(self, ret = False):
522 num_configured_if = len(iNetwork.getConfiguredAdapters())
523 if num_configured_if >= 1:
524 if self.iface in iNetwork.getConfiguredAdapters():
525 self.applyConfig(True)
527 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)
529 self.applyConfig(True)
533 def secondIfaceFoundCB(self,data):
535 self.applyConfig(True)
537 configuredInterfaces = iNetwork.getConfiguredAdapters()
538 for interface in configuredInterfaces:
539 if interface == self.iface:
541 iNetwork.setAdapterAttribute(interface, "up", False)
542 iNetwork.deactivateInterface(configuredInterfaces,self.deactivateSecondInterfaceCB)
544 def deactivateSecondInterfaceCB(self, data):
546 self.applyConfig(True)
548 def applyConfig(self, ret = False):
550 self.applyConfigRef = None
551 iNetwork.setAdapterAttribute(self.iface, "up", self.activateInterfaceEntry.value)
552 iNetwork.setAdapterAttribute(self.iface, "dhcp", self.dhcpConfigEntry.value)
553 iNetwork.setAdapterAttribute(self.iface, "ip", self.ipConfigEntry.value)
554 iNetwork.setAdapterAttribute(self.iface, "netmask", self.netmaskConfigEntry.value)
555 if self.hasGatewayConfigEntry.value:
556 iNetwork.setAdapterAttribute(self.iface, "gateway", self.gatewayConfigEntry.value)
558 iNetwork.removeAdapterAttribute(self.iface, "gateway")
560 if (self.extended is not None and self.configStrings is not None):
561 iNetwork.setAdapterAttribute(self.iface, "configStrings", self.configStrings(self.iface))
562 self.ws.writeConfig(self.iface)
564 if self.activateInterfaceEntry.value is False:
565 iNetwork.deactivateInterface(self.iface,self.deactivateInterfaceCB)
566 iNetwork.writeNetworkConfig()
567 self.applyConfigRef = self.session.openWithCallback(self.applyConfigfinishedCB, MessageBox, _("Please wait for activation of your network configuration..."), type = MessageBox.TYPE_INFO, enable_input = False)
569 if self.oldInterfaceState is False:
570 iNetwork.activateInterface(self.iface,self.deactivateInterfaceCB)
572 iNetwork.deactivateInterface(self.iface,self.activateInterfaceCB)
573 iNetwork.writeNetworkConfig()
574 self.applyConfigRef = self.session.openWithCallback(self.applyConfigfinishedCB, MessageBox, _("Please wait for activation of your network configuration..."), type = MessageBox.TYPE_INFO, enable_input = False)
578 def deactivateInterfaceCB(self, data):
580 self.applyConfigDataAvail(True)
582 def activateInterfaceCB(self, data):
584 iNetwork.activateInterface(self.iface,self.applyConfigDataAvail)
586 def applyConfigDataAvail(self, data):
588 iNetwork.getInterfaces(self.getInterfacesDataAvail)
590 def getInterfacesDataAvail(self, data):
592 self.applyConfigRef.close(True)
594 def applyConfigfinishedCB(self,data):
597 self.session.openWithCallback(lambda x : self.finished_cb(), MessageBox, _("Your network configuration has been activated."), type = MessageBox.TYPE_INFO, timeout = 10)
599 self.session.openWithCallback(self.ConfigfinishedCB, MessageBox, _("Your network configuration has been activated."), type = MessageBox.TYPE_INFO, timeout = 10)
601 def ConfigfinishedCB(self,data):
606 def keyCancelConfirm(self, result):
609 if self.oldInterfaceState is False:
610 iNetwork.deactivateInterface(self.iface,self.keyCancelCB)
616 if self["config"].isChanged():
617 self.session.openWithCallback(self.keyCancelConfirm, MessageBox, _("Really close without saving settings?"))
621 def keyCancelCB(self,data):
626 def runAsync(self, finished_cb):
627 self.finished_cb = finished_cb
630 def NameserverSetupClosed(self, *ret):
631 iNetwork.loadNameserverConfig()
632 nameserver = (iNetwork.getNameserverList() + [[0,0,0,0]] * 2)[0:2]
633 self.primaryDNS = NoSave(ConfigIP(default=nameserver[0]))
634 self.secondaryDNS = NoSave(ConfigIP(default=nameserver[1]))
636 self.layoutFinished()
639 iNetwork.stopLinkStateConsole()
641 def hideInputHelp(self):
642 current = self["config"].getCurrent()
643 if current == self.wlanSSID:
644 if current[1].help_window.instance is not None:
645 current[1].help_window.instance.hide()
646 elif current == self.encryptionKey and config.plugins.wlan.encryption.value is not "Unencrypted":
647 if current[1].help_window.instance is not None:
648 current[1].help_window.instance.hide()
651 class AdapterSetupConfiguration(Screen, HelpableScreen):
652 def __init__(self, session,iface):
653 Screen.__init__(self, session)
654 HelpableScreen.__init__(self)
655 self.session = session
657 self.restartLanRef = None
658 self.LinkState = None
659 self.mainmenu = self.genMainMenu()
660 self["menulist"] = MenuList(self.mainmenu)
661 self["key_red"] = StaticText(_("Close"))
662 self["description"] = StaticText()
663 self["IFtext"] = StaticText()
664 self["IF"] = StaticText()
665 self["Statustext"] = StaticText()
666 self["statuspic"] = MultiPixmap()
667 self["statuspic"].hide()
669 self.oktext = _("Press OK on your remote control to continue.")
670 self.reboottext = _("Your STB will restart after pressing OK on your remote control.")
671 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.")
672 self.missingwlanplugintxt = _("The wireless LAN plugin is not installed!\nPlease install it.")
674 self["WizardActions"] = HelpableActionMap(self, "WizardActions",
676 "up": (self.up, _("move up to previous entry")),
677 "down": (self.down, _("move down to next entry")),
678 "left": (self.left, _("move up to first entry")),
679 "right": (self.right, _("move down to last entry")),
682 self["OkCancelActions"] = HelpableActionMap(self, "OkCancelActions",
684 "cancel": (self.close, _("exit networkadapter setup menu")),
685 "ok": (self.ok, _("select menu entry")),
688 self["ColorActions"] = HelpableActionMap(self, "ColorActions",
690 "red": (self.close, _("exit networkadapter setup menu")),
693 self["actions"] = NumberActionMap(["WizardActions","ShortcutActions"],
704 self.updateStatusbar()
705 self.onLayoutFinish.append(self.layoutFinished)
706 self.onClose.append(self.cleanup)
709 def queryWirelessDevice(self,iface):
711 from pythonwifi.iwlibs import Wireless
717 ifobj = Wireless(iface) # a Wireless NIC Object
718 wlanresponse = ifobj.getAPaddr()
719 except IOError, (error_no, error_str):
720 if error_no in (errno.EOPNOTSUPP, errno.ENODEV, errno.EPERM):
723 print "error: ",error_no,error_str
730 if self["menulist"].getCurrent()[1] == 'edit':
731 if iNetwork.isWirelessInterface(self.iface):
733 from Plugins.SystemPlugins.WirelessLan.plugin import WlanScan
735 self.session.open(MessageBox, self.missingwlanplugintxt, type = MessageBox.TYPE_INFO,timeout = 10 )
737 if self.queryWirelessDevice(self.iface):
738 self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetup,self.iface)
740 self.showErrorMessage() # Display Wlan not available Message
742 self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetup,self.iface)
743 if self["menulist"].getCurrent()[1] == 'test':
744 self.session.open(NetworkAdapterTest,self.iface)
745 if self["menulist"].getCurrent()[1] == 'dns':
746 self.session.open(NameserverSetup)
747 if self["menulist"].getCurrent()[1] == 'scanwlan':
749 from Plugins.SystemPlugins.WirelessLan.plugin import WlanScan
751 self.session.open(MessageBox, self.missingwlanplugintxt, type = MessageBox.TYPE_INFO,timeout = 10 )
753 if self.queryWirelessDevice(self.iface):
754 self.session.openWithCallback(self.WlanScanClosed, WlanScan, self.iface)
756 self.showErrorMessage() # Display Wlan not available Message
757 if self["menulist"].getCurrent()[1] == 'wlanstatus':
759 from Plugins.SystemPlugins.WirelessLan.plugin import WlanStatus
761 self.session.open(MessageBox, self.missingwlanplugintxt, type = MessageBox.TYPE_INFO,timeout = 10 )
763 if self.queryWirelessDevice(self.iface):
764 self.session.openWithCallback(self.WlanStatusClosed, WlanStatus,self.iface)
766 self.showErrorMessage() # Display Wlan not available Message
767 if self["menulist"].getCurrent()[1] == 'lanrestart':
768 self.session.openWithCallback(self.restartLan, MessageBox, (_("Are you sure you want to restart your network interfaces?\n\n") + self.oktext ) )
769 if self["menulist"].getCurrent()[1] == 'openwizard':
770 from Plugins.SystemPlugins.NetworkWizard.NetworkWizard import NetworkWizard
771 self.session.openWithCallback(self.AdapterSetupClosed, NetworkWizard, self.iface)
772 if self["menulist"].getCurrent()[1][0] == 'extendedSetup':
773 self.extended = self["menulist"].getCurrent()[1][2]
774 self.extended(self.session, self.iface)
777 self["menulist"].up()
778 self.loadDescription()
781 self["menulist"].down()
782 self.loadDescription()
785 self["menulist"].pageUp()
786 self.loadDescription()
789 self["menulist"].pageDown()
790 self.loadDescription()
792 def layoutFinished(self):
794 self["menulist"].moveToIndex(idx)
795 self.loadDescription()
797 def loadDescription(self):
798 if self["menulist"].getCurrent()[1] == 'edit':
799 self["description"].setText(_("Edit the network configuration of your STB.\n" ) + self.oktext )
800 if self["menulist"].getCurrent()[1] == 'test':
801 self["description"].setText(_("Test the network configuration of your STB.\n" ) + self.oktext )
802 if self["menulist"].getCurrent()[1] == 'dns':
803 self["description"].setText(_("Edit the Nameserver configuration of your STB.\n" ) + self.oktext )
804 if self["menulist"].getCurrent()[1] == 'scanwlan':
805 self["description"].setText(_("Scan your network for wireless access points and connect to them using your selected wireless device.\n" ) + self.oktext )
806 if self["menulist"].getCurrent()[1] == 'wlanstatus':
807 self["description"].setText(_("Shows the state of your wireless LAN connection.\n" ) + self.oktext )
808 if self["menulist"].getCurrent()[1] == 'lanrestart':
809 self["description"].setText(_("Restart your network connection and interfaces.\n" ) + self.oktext )
810 if self["menulist"].getCurrent()[1] == 'openwizard':
811 self["description"].setText(_("Use the Networkwizard to configure your Network\n" ) + self.oktext )
812 if self["menulist"].getCurrent()[1][0] == 'extendedSetup':
813 self["description"].setText(_(self["menulist"].getCurrent()[1][1]) + self.oktext )
815 def updateStatusbar(self, data = None):
816 self.mainmenu = self.genMainMenu()
817 self["menulist"].l.setList(self.mainmenu)
818 self["IFtext"].setText(_("Network:"))
819 self["IF"].setText(iNetwork.getFriendlyAdapterName(self.iface))
820 self["Statustext"].setText(_("Link:"))
822 if iNetwork.isWirelessInterface(self.iface):
824 from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus
826 self["statuspic"].setPixmapNum(1)
827 self["statuspic"].show()
829 iStatus.getDataForInterface(self.iface,self.getInfoCB)
831 iNetwork.getLinkState(self.iface,self.dataAvail)
836 def genMainMenu(self):
838 menu.append((_("Adapter settings"), "edit"))
839 menu.append((_("Nameserver settings"), "dns"))
840 menu.append((_("Network test"), "test"))
841 menu.append((_("Restart network"), "lanrestart"))
844 self.extendedSetup = None
845 for p in plugins.getPlugins(PluginDescriptor.WHERE_NETWORKSETUP):
846 callFnc = p.__call__["ifaceSupported"](self.iface)
847 if callFnc is not None:
848 self.extended = callFnc
849 if p.__call__.has_key("WlanPluginEntry"): # internally used only for WLAN Plugin
850 menu.append((_("Scan Wireless Networks"), "scanwlan"))
851 if iNetwork.getAdapterAttribute(self.iface, "up"):
852 menu.append((_("Show WLAN Status"), "wlanstatus"))
854 if p.__call__.has_key("menuEntryName"):
855 menuEntryName = p.__call__["menuEntryName"](self.iface)
857 menuEntryName = _('Extended Setup...')
858 if p.__call__.has_key("menuEntryDescription"):
859 menuEntryDescription = p.__call__["menuEntryDescription"](self.iface)
861 menuEntryDescription = _('Extended Networksetup Plugin...')
862 self.extendedSetup = ('extendedSetup',menuEntryDescription, self.extended)
863 menu.append((menuEntryName,self.extendedSetup))
865 if os_path.exists(resolveFilename(SCOPE_PLUGINS, "SystemPlugins/NetworkWizard/networkwizard.xml")):
866 menu.append((_("NetworkWizard"), "openwizard"))
870 def AdapterSetupClosed(self, *ret):
871 if ret is not None and len(ret):
872 if ret[0] == 'ok' and (iNetwork.isWirelessInterface(self.iface) and iNetwork.getAdapterAttribute(self.iface, "up") is True):
874 from Plugins.SystemPlugins.WirelessLan.plugin import WlanStatus
876 self.session.open(MessageBox, self.missingwlanplugintxt, type = MessageBox.TYPE_INFO,timeout = 10 )
878 if self.queryWirelessDevice(self.iface):
879 self.session.openWithCallback(self.WlanStatusClosed, WlanStatus,self.iface)
881 self.showErrorMessage() # Display Wlan not available Message
883 self.updateStatusbar()
885 self.updateStatusbar()
887 def WlanStatusClosed(self, *ret):
888 if ret is not None and len(ret):
889 from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus
890 iStatus.stopWlanConsole()
891 self.updateStatusbar()
893 def WlanScanClosed(self,*ret):
894 if ret[0] is not None:
895 self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetup, self.iface,ret[0])
897 from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus
898 iStatus.stopWlanConsole()
899 self.updateStatusbar()
901 def restartLan(self, ret = False):
903 iNetwork.restartNetwork(self.restartLanDataAvail)
904 self.restartLanRef = self.session.openWithCallback(self.restartfinishedCB, MessageBox, _("Please wait while your network is restarting..."), type = MessageBox.TYPE_INFO, enable_input = False)
906 def restartLanDataAvail(self, data):
908 iNetwork.getInterfaces(self.getInterfacesDataAvail)
910 def getInterfacesDataAvail(self, data):
912 self.restartLanRef.close(True)
914 def restartfinishedCB(self,data):
916 self.updateStatusbar()
917 self.session.open(MessageBox, _("Finished restarting your network"), type = MessageBox.TYPE_INFO, timeout = 10, default = False)
919 def dataAvail(self,data):
920 self.LinkState = None
921 for line in data.splitlines():
923 if 'Link detected:' in line:
925 self.LinkState = True
927 self.LinkState = False
928 if self.LinkState == True:
929 iNetwork.checkNetworkState(self.checkNetworkCB)
931 self["statuspic"].setPixmapNum(1)
932 self["statuspic"].show()
934 def showErrorMessage(self):
935 self.session.open(MessageBox, self.errortext, type = MessageBox.TYPE_INFO,timeout = 10 )
938 iNetwork.stopLinkStateConsole()
939 iNetwork.stopDeactivateInterfaceConsole()
940 iNetwork.stopActivateInterfaceConsole()
941 iNetwork.stopPingConsole()
943 from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus
947 iStatus.stopWlanConsole()
949 def getInfoCB(self,data,status):
950 self.LinkState = None
953 if status is not None:
954 if status[self.iface]["essid"] == "off" or status[self.iface]["accesspoint"] == "Not-Associated" or status[self.iface]["accesspoint"] == False:
955 self.LinkState = False
956 self["statuspic"].setPixmapNum(1)
957 self["statuspic"].show()
959 self.LinkState = True
960 iNetwork.checkNetworkState(self.checkNetworkCB)
962 def checkNetworkCB(self,data):
964 if iNetwork.getAdapterAttribute(self.iface, "up") is True:
965 if self.LinkState is True:
967 self["statuspic"].setPixmapNum(0)
969 self["statuspic"].setPixmapNum(1)
970 self["statuspic"].show()
972 self["statuspic"].setPixmapNum(1)
973 self["statuspic"].show()
975 self["statuspic"].setPixmapNum(1)
976 self["statuspic"].show()
980 class NetworkAdapterTest(Screen):
981 def __init__(self, session,iface):
982 Screen.__init__(self, session)
984 self.oldInterfaceState = iNetwork.getAdapterAttribute(self.iface, "up")
986 self.onClose.append(self.cleanup)
987 self.onHide.append(self.cleanup)
989 self["updown_actions"] = NumberActionMap(["WizardActions","ShortcutActions"],
993 "up": lambda: self.updownhandler('up'),
994 "down": lambda: self.updownhandler('down'),
998 self["shortcuts"] = ActionMap(["ShortcutActions","WizardActions"],
1001 "back": self.cancel,
1003 self["infoshortcuts"] = ActionMap(["ShortcutActions","WizardActions"],
1005 "red": self.closeInfo,
1006 "back": self.closeInfo,
1008 self["shortcutsgreen"] = ActionMap(["ShortcutActions"],
1010 "green": self.KeyGreen,
1012 self["shortcutsgreen_restart"] = ActionMap(["ShortcutActions"],
1014 "green": self.KeyGreenRestart,
1016 self["shortcutsyellow"] = ActionMap(["ShortcutActions"],
1018 "yellow": self.KeyYellow,
1021 self["shortcutsgreen_restart"].setEnabled(False)
1022 self["updown_actions"].setEnabled(False)
1023 self["infoshortcuts"].setEnabled(False)
1024 self.onClose.append(self.delTimer)
1025 self.onLayoutFinish.append(self.layoutFinished)
1026 self.steptimer = False
1028 self.activebutton = 0
1029 self.nextStepTimer = eTimer()
1030 self.nextStepTimer.callback.append(self.nextStepTimerFire)
1033 if self.oldInterfaceState is False:
1034 iNetwork.setAdapterAttribute(self.iface, "up", self.oldInterfaceState)
1035 iNetwork.deactivateInterface(self.iface)
1038 def closeInfo(self):
1039 self["shortcuts"].setEnabled(True)
1040 self["infoshortcuts"].setEnabled(False)
1041 self["InfoText"].hide()
1042 self["InfoTextBorder"].hide()
1043 self["key_red"].setText(_("Close"))
1047 del self.nextStepTimer
1049 def nextStepTimerFire(self):
1050 self.nextStepTimer.stop()
1051 self.steptimer = False
1054 def updownhandler(self,direction):
1055 if direction == 'up':
1056 if self.activebutton >=2:
1057 self.activebutton -= 1
1059 self.activebutton = 6
1060 self.setActiveButton(self.activebutton)
1061 if direction == 'down':
1062 if self.activebutton <=5:
1063 self.activebutton += 1
1065 self.activebutton = 1
1066 self.setActiveButton(self.activebutton)
1068 def setActiveButton(self,button):
1070 self["EditSettingsButton"].setPixmapNum(0)
1071 self["EditSettings_Text"].setForegroundColorNum(0)
1072 self["NetworkInfo"].setPixmapNum(0)
1073 self["NetworkInfo_Text"].setForegroundColorNum(1)
1074 self["AdapterInfo"].setPixmapNum(1) # active
1075 self["AdapterInfo_Text"].setForegroundColorNum(2) # active
1077 self["AdapterInfo_Text"].setForegroundColorNum(1)
1078 self["AdapterInfo"].setPixmapNum(0)
1079 self["DhcpInfo"].setPixmapNum(0)
1080 self["DhcpInfo_Text"].setForegroundColorNum(1)
1081 self["NetworkInfo"].setPixmapNum(1) # active
1082 self["NetworkInfo_Text"].setForegroundColorNum(2) # active
1084 self["NetworkInfo"].setPixmapNum(0)
1085 self["NetworkInfo_Text"].setForegroundColorNum(1)
1086 self["IPInfo"].setPixmapNum(0)
1087 self["IPInfo_Text"].setForegroundColorNum(1)
1088 self["DhcpInfo"].setPixmapNum(1) # active
1089 self["DhcpInfo_Text"].setForegroundColorNum(2) # active
1091 self["DhcpInfo"].setPixmapNum(0)
1092 self["DhcpInfo_Text"].setForegroundColorNum(1)
1093 self["DNSInfo"].setPixmapNum(0)
1094 self["DNSInfo_Text"].setForegroundColorNum(1)
1095 self["IPInfo"].setPixmapNum(1) # active
1096 self["IPInfo_Text"].setForegroundColorNum(2) # active
1098 self["IPInfo"].setPixmapNum(0)
1099 self["IPInfo_Text"].setForegroundColorNum(1)
1100 self["EditSettingsButton"].setPixmapNum(0)
1101 self["EditSettings_Text"].setForegroundColorNum(0)
1102 self["DNSInfo"].setPixmapNum(1) # active
1103 self["DNSInfo_Text"].setForegroundColorNum(2) # active
1105 self["DNSInfo"].setPixmapNum(0)
1106 self["DNSInfo_Text"].setForegroundColorNum(1)
1107 self["EditSettingsButton"].setPixmapNum(1) # active
1108 self["EditSettings_Text"].setForegroundColorNum(2) # active
1109 self["AdapterInfo"].setPixmapNum(0)
1110 self["AdapterInfo_Text"].setForegroundColorNum(1)
1113 next = self.nextstep
1129 self.steptimer = True
1130 self.nextStepTimer.start(3000)
1131 self["key_yellow"].setText(_("Stop test"))
1134 self["Adapter"].setText(iNetwork.getFriendlyAdapterName(self.iface))
1135 self["Adapter"].setForegroundColorNum(2)
1136 self["Adaptertext"].setForegroundColorNum(1)
1137 self["AdapterInfo_Text"].setForegroundColorNum(1)
1138 self["AdapterInfo_OK"].show()
1139 self.steptimer = True
1140 self.nextStepTimer.start(3000)
1143 self["Networktext"].setForegroundColorNum(1)
1144 self["Network"].setText(_("Please wait..."))
1145 self.getLinkState(self.iface)
1146 self["NetworkInfo_Text"].setForegroundColorNum(1)
1147 self.steptimer = True
1148 self.nextStepTimer.start(3000)
1151 self["Dhcptext"].setForegroundColorNum(1)
1152 if iNetwork.getAdapterAttribute(self.iface, 'dhcp') is True:
1153 self["Dhcp"].setForegroundColorNum(2)
1154 self["Dhcp"].setText(_("enabled"))
1155 self["DhcpInfo_Check"].setPixmapNum(0)
1157 self["Dhcp"].setForegroundColorNum(1)
1158 self["Dhcp"].setText(_("disabled"))
1159 self["DhcpInfo_Check"].setPixmapNum(1)
1160 self["DhcpInfo_Check"].show()
1161 self["DhcpInfo_Text"].setForegroundColorNum(1)
1162 self.steptimer = True
1163 self.nextStepTimer.start(3000)
1166 self["IPtext"].setForegroundColorNum(1)
1167 self["IP"].setText(_("Please wait..."))
1168 iNetwork.checkNetworkState(self.NetworkStatedataAvail)
1171 self.steptimer = False
1172 self.nextStepTimer.stop()
1173 self["DNStext"].setForegroundColorNum(1)
1174 self["DNS"].setText(_("Please wait..."))
1175 iNetwork.checkDNSLookup(self.DNSLookupdataAvail)
1178 self["shortcutsgreen"].setEnabled(False)
1179 self["shortcutsyellow"].setEnabled(True)
1180 self["updown_actions"].setEnabled(False)
1181 self["key_yellow"].setText("")
1182 self["key_green"].setText("")
1183 self.steptimer = True
1184 self.nextStepTimer.start(1000)
1186 def KeyGreenRestart(self):
1188 self.layoutFinished()
1189 self["Adapter"].setText((""))
1190 self["Network"].setText((""))
1191 self["Dhcp"].setText((""))
1192 self["IP"].setText((""))
1193 self["DNS"].setText((""))
1194 self["AdapterInfo_Text"].setForegroundColorNum(0)
1195 self["NetworkInfo_Text"].setForegroundColorNum(0)
1196 self["DhcpInfo_Text"].setForegroundColorNum(0)
1197 self["IPInfo_Text"].setForegroundColorNum(0)
1198 self["DNSInfo_Text"].setForegroundColorNum(0)
1199 self["shortcutsgreen_restart"].setEnabled(False)
1200 self["shortcutsgreen"].setEnabled(False)
1201 self["shortcutsyellow"].setEnabled(True)
1202 self["updown_actions"].setEnabled(False)
1203 self["key_yellow"].setText("")
1204 self["key_green"].setText("")
1205 self.steptimer = True
1206 self.nextStepTimer.start(1000)
1209 self["infoshortcuts"].setEnabled(True)
1210 self["shortcuts"].setEnabled(False)
1211 if self.activebutton == 1: # Adapter Check
1212 self["InfoText"].setText(_("This test detects your configured LAN-Adapter."))
1213 self["InfoTextBorder"].show()
1214 self["InfoText"].show()
1215 self["key_red"].setText(_("Back"))
1216 if self.activebutton == 2: #LAN Check
1217 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"))
1218 self["InfoTextBorder"].show()
1219 self["InfoText"].show()
1220 self["key_red"].setText(_("Back"))
1221 if self.activebutton == 3: #DHCP Check
1222 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."))
1223 self["InfoTextBorder"].show()
1224 self["InfoText"].show()
1225 self["key_red"].setText(_("Back"))
1226 if self.activebutton == 4: # IP Check
1227 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"))
1228 self["InfoTextBorder"].show()
1229 self["InfoText"].show()
1230 self["key_red"].setText(_("Back"))
1231 if self.activebutton == 5: # DNS Check
1232 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"))
1233 self["InfoTextBorder"].show()
1234 self["InfoText"].show()
1235 self["key_red"].setText(_("Back"))
1236 if self.activebutton == 6: # Edit Settings
1237 self.session.open(AdapterSetup,self.iface)
1239 def KeyYellow(self):
1241 self["shortcutsgreen_restart"].setEnabled(True)
1242 self["shortcutsgreen"].setEnabled(False)
1243 self["shortcutsyellow"].setEnabled(False)
1244 self["key_green"].setText(_("Restart test"))
1245 self["key_yellow"].setText("")
1246 self.steptimer = False
1247 self.nextStepTimer.stop()
1249 def layoutFinished(self):
1250 self.setTitle(_("Network test: ") + iNetwork.getFriendlyAdapterName(self.iface) )
1251 self["shortcutsyellow"].setEnabled(False)
1252 self["AdapterInfo_OK"].hide()
1253 self["NetworkInfo_Check"].hide()
1254 self["DhcpInfo_Check"].hide()
1255 self["IPInfo_Check"].hide()
1256 self["DNSInfo_Check"].hide()
1257 self["EditSettings_Text"].hide()
1258 self["EditSettingsButton"].hide()
1259 self["InfoText"].hide()
1260 self["InfoTextBorder"].hide()
1261 self["key_yellow"].setText("")
1263 def setLabels(self):
1264 self["Adaptertext"] = MultiColorLabel(_("LAN Adapter"))
1265 self["Adapter"] = MultiColorLabel()
1266 self["AdapterInfo"] = MultiPixmap()
1267 self["AdapterInfo_Text"] = MultiColorLabel(_("Show Info"))
1268 self["AdapterInfo_OK"] = Pixmap()
1270 if self.iface in iNetwork.wlan_interfaces:
1271 self["Networktext"] = MultiColorLabel(_("Wireless Network"))
1273 self["Networktext"] = MultiColorLabel(_("Local Network"))
1275 self["Network"] = MultiColorLabel()
1276 self["NetworkInfo"] = MultiPixmap()
1277 self["NetworkInfo_Text"] = MultiColorLabel(_("Show Info"))
1278 self["NetworkInfo_Check"] = MultiPixmap()
1280 self["Dhcptext"] = MultiColorLabel(_("DHCP"))
1281 self["Dhcp"] = MultiColorLabel()
1282 self["DhcpInfo"] = MultiPixmap()
1283 self["DhcpInfo_Text"] = MultiColorLabel(_("Show Info"))
1284 self["DhcpInfo_Check"] = MultiPixmap()
1286 self["IPtext"] = MultiColorLabel(_("IP Address"))
1287 self["IP"] = MultiColorLabel()
1288 self["IPInfo"] = MultiPixmap()
1289 self["IPInfo_Text"] = MultiColorLabel(_("Show Info"))
1290 self["IPInfo_Check"] = MultiPixmap()
1292 self["DNStext"] = MultiColorLabel(_("Nameserver"))
1293 self["DNS"] = MultiColorLabel()
1294 self["DNSInfo"] = MultiPixmap()
1295 self["DNSInfo_Text"] = MultiColorLabel(_("Show Info"))
1296 self["DNSInfo_Check"] = MultiPixmap()
1298 self["EditSettings_Text"] = MultiColorLabel(_("Edit settings"))
1299 self["EditSettingsButton"] = MultiPixmap()
1301 self["key_red"] = StaticText(_("Close"))
1302 self["key_green"] = StaticText(_("Start test"))
1303 self["key_yellow"] = StaticText(_("Stop test"))
1305 self["InfoTextBorder"] = Pixmap()
1306 self["InfoText"] = Label()
1308 def getLinkState(self,iface):
1309 if iface in iNetwork.wlan_interfaces:
1311 from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus
1313 self["Network"].setForegroundColorNum(1)
1314 self["Network"].setText(_("disconnected"))
1315 self["NetworkInfo_Check"].setPixmapNum(1)
1316 self["NetworkInfo_Check"].show()
1318 iStatus.getDataForInterface(self.iface,self.getInfoCB)
1320 iNetwork.getLinkState(iface,self.LinkStatedataAvail)
1322 def LinkStatedataAvail(self,data):
1323 self.output = data.strip()
1324 result = self.output.splitlines()
1325 pattern = re_compile("Link detected: yes")
1327 if re_search(pattern, item):
1328 self["Network"].setForegroundColorNum(2)
1329 self["Network"].setText(_("connected"))
1330 self["NetworkInfo_Check"].setPixmapNum(0)
1332 self["Network"].setForegroundColorNum(1)
1333 self["Network"].setText(_("disconnected"))
1334 self["NetworkInfo_Check"].setPixmapNum(1)
1335 self["NetworkInfo_Check"].show()
1337 def NetworkStatedataAvail(self,data):
1339 self["IP"].setForegroundColorNum(2)
1340 self["IP"].setText(_("confirmed"))
1341 self["IPInfo_Check"].setPixmapNum(0)
1343 self["IP"].setForegroundColorNum(1)
1344 self["IP"].setText(_("unconfirmed"))
1345 self["IPInfo_Check"].setPixmapNum(1)
1346 self["IPInfo_Check"].show()
1347 self["IPInfo_Text"].setForegroundColorNum(1)
1348 self.steptimer = True
1349 self.nextStepTimer.start(3000)
1351 def DNSLookupdataAvail(self,data):
1353 self["DNS"].setForegroundColorNum(2)
1354 self["DNS"].setText(_("confirmed"))
1355 self["DNSInfo_Check"].setPixmapNum(0)
1357 self["DNS"].setForegroundColorNum(1)
1358 self["DNS"].setText(_("unconfirmed"))
1359 self["DNSInfo_Check"].setPixmapNum(1)
1360 self["DNSInfo_Check"].show()
1361 self["DNSInfo_Text"].setForegroundColorNum(1)
1362 self["EditSettings_Text"].show()
1363 self["EditSettingsButton"].setPixmapNum(1)
1364 self["EditSettings_Text"].setForegroundColorNum(2) # active
1365 self["EditSettingsButton"].show()
1366 self["key_yellow"].setText("")
1367 self["key_green"].setText(_("Restart test"))
1368 self["shortcutsgreen"].setEnabled(False)
1369 self["shortcutsgreen_restart"].setEnabled(True)
1370 self["shortcutsyellow"].setEnabled(False)
1371 self["updown_actions"].setEnabled(True)
1372 self.activebutton = 6
1374 def getInfoCB(self,data,status):
1375 if data is not None:
1377 if status is not None:
1378 if status[self.iface]["essid"] == "off" or status[self.iface]["accesspoint"] == "Not-Associated" or status[self.iface]["accesspoint"] == False:
1379 self["Network"].setForegroundColorNum(1)
1380 self["Network"].setText(_("disconnected"))
1381 self["NetworkInfo_Check"].setPixmapNum(1)
1382 self["NetworkInfo_Check"].show()
1384 self["Network"].setForegroundColorNum(2)
1385 self["Network"].setText(_("connected"))
1386 self["NetworkInfo_Check"].setPixmapNum(0)
1387 self["NetworkInfo_Check"].show()
1390 iNetwork.stopLinkStateConsole()
1391 iNetwork.stopDNSConsole()
1393 from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus
1397 iStatus.stopWlanConsole()