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
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.adapters = [(iNetwork.getFriendlyAdapterName(x),x) for x in iNetwork.getAdapterList()]
48 self.adapterList=[(iNetwork.getFriendlyAdapterName(x),x) for x in iNetwork.getAdapterList()]
49 for x in self.adapterList:
50 if x[1].startswith('eth'):
51 self.adapters.append(x)
54 self.onFirstExecBegin.append(self.NetworkFallback)
56 self["OkCancelActions"] = HelpableActionMap(self, "OkCancelActions",
58 "cancel": (self.close, _("exit network interface list")),
59 "ok": (self.okbuttonClick, _("select interface")),
62 self["ColorActions"] = HelpableActionMap(self, "ColorActions",
64 "red": (self.close, _("exit network interface list")),
65 "green": (self.okbuttonClick, _("select interface")),
66 "blue": (self.openNetworkWizard, _("Use the Networkwizard to configure selected network adapter")),
69 self["DefaultInterfaceAction"] = HelpableActionMap(self, "ColorActions",
71 "yellow": (self.setDefaultInterface, [_("Set interface as default Interface"),_("* Only available if more than one interface is active.")] ),
75 self["list"] = List(self.list)
78 if len(self.adapters) == 1:
79 self.onFirstExecBegin.append(self.okbuttonClick)
80 self.onClose.append(self.cleanup)
82 def buildInterfaceList(self,iface,name,default,active ):
83 divpng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/div-h.png"))
89 if iface in iNetwork.lan_interfaces:
91 interfacepng = LoadPixmap(resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/icons/network_wired-active.png"))
93 interfacepng = LoadPixmap(resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/icons/network_wired-inactive.png"))
95 interfacepng = LoadPixmap(resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/icons/network_wired.png"))
96 elif iface in iNetwork.wlan_interfaces:
98 interfacepng = LoadPixmap(resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/icons/network_wireless-active.png"))
100 interfacepng = LoadPixmap(resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/icons/network_wireless-inactive.png"))
102 interfacepng = LoadPixmap(resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/icons/network_wireless.png"))
106 for x in iNetwork.getConfiguredAdapters():
107 if x.startswith('eth'):
108 num_configured_if=num_configured_if+1
109 # num_configured_if = len(iNetwork.getConfiguredAdapters())
110 if num_configured_if >= 2:
112 defaultpng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/buttons/button_blue.png"))
113 elif default is False:
114 defaultpng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/buttons/button_blue_off.png"))
116 activepng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/icons/lock_on.png"))
117 elif active is False:
118 activepng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/icons/lock_error.png"))
120 description = iNetwork.getFriendlyAdapterDescription(iface)
122 return((iface, name, description, interfacepng, defaultpng, activepng, divpng))
124 def updateList(self):
129 for x in iNetwork.getConfiguredAdapters():
130 if x.startswith('eth'):
131 num_configured_if=num_configured_if+1
133 # num_configured_if = len(iNetwork.getConfiguredAdapters())
134 if num_configured_if >= 2:
135 self["key_yellow"].setText(_("Default"))
136 self["introduction"].setText(self.defaulttext)
137 self["DefaultInterfaceAction"].setEnabled(True)
139 self["key_yellow"].setText("")
140 self["introduction"].setText(self.edittext)
141 self["DefaultInterfaceAction"].setEnabled(False)
143 if num_configured_if < 2 and os_path.exists("/etc/default_gw"):
144 unlink("/etc/default_gw")
146 if os_path.exists("/etc/default_gw"):
147 fp = file('/etc/default_gw', 'r')
152 if len(self.adapters) == 0: # no interface available => display only eth0
153 self.list.append(self.buildInterfaceList("eth0",iNetwork.getFriendlyAdapterName('eth0'),True,True ))
155 for x in self.adapters:
156 if x[1] == default_gw:
160 if iNetwork.getAdapterAttribute(x[1], 'up') is True:
164 self.list.append(self.buildInterfaceList(x[1],_(x[0]),default_int,active_int ))
166 if os_path.exists(resolveFilename(SCOPE_PLUGINS, "SystemPlugins/NetworkWizard/networkwizard.xml")):
167 self["key_blue"].setText(_("NetworkWizard"))
168 self["list"].setList(self.list)
170 def setDefaultInterface(self):
171 selection = self["list"].getCurrent()
172 num_if = len(self.list)
173 old_default_gw = None
176 for x in iNetwork.getConfiguredAdapters():
177 if x.startswith('eth'):
178 num_configured_if=num_configured_if+1
179 # num_configured_if = len(iNetwork.getConfiguredAdapters())
180 if os_path.exists("/etc/default_gw"):
181 fp = open('/etc/default_gw', 'r')
182 old_default_gw = fp.read()
184 if num_configured_if > 1 and (not old_default_gw or old_default_gw != selection[0]):
185 fp = open('/etc/default_gw', 'w+')
186 fp.write(selection[0])
189 elif old_default_gw and num_configured_if < 2:
190 unlink("/etc/default_gw")
193 def okbuttonClick(self):
194 selection = self["list"].getCurrent()
195 if selection is not None:
196 self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetupConfiguration, selection[0])
198 def AdapterSetupClosed(self, *ret):
199 if len(self.adapters) == 1:
204 def NetworkFallback(self):
205 if iNetwork.configuredNetworkAdapters.has_key('wlan0') is True:
206 self.session.openWithCallback(self.ErrorMessageClosed, MessageBox, self.wlan_errortext, type = MessageBox.TYPE_INFO,timeout = 10)
207 if iNetwork.configuredNetworkAdapters.has_key('ath0') is True:
208 self.session.openWithCallback(self.ErrorMessageClosed, MessageBox, self.wlan_errortext, type = MessageBox.TYPE_INFO,timeout = 10)
210 self.session.openWithCallback(self.ErrorMessageClosed, MessageBox, self.lan_errortext, type = MessageBox.TYPE_INFO,timeout = 10)
212 def ErrorMessageClosed(self, *ret):
213 if iNetwork.configuredNetworkAdapters.has_key('wlan0') is True:
214 self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetupConfiguration, 'wlan0')
215 elif iNetwork.configuredNetworkAdapters.has_key('ath0') is True:
216 self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetupConfiguration, 'ath0')
218 self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetupConfiguration, 'eth0')
221 iNetwork.stopLinkStateConsole()
222 iNetwork.stopRestartConsole()
223 iNetwork.stopGetInterfacesConsole()
225 def restartLan(self):
226 iNetwork.restartNetwork(self.restartLanDataAvail)
227 self.restartLanRef = self.session.openWithCallback(self.restartfinishedCB, MessageBox, _("Please wait while we configure your network..."), type = MessageBox.TYPE_INFO, enable_input = False)
229 def restartLanDataAvail(self, data):
231 iNetwork.getInterfaces(self.getInterfacesDataAvail)
233 def getInterfacesDataAvail(self, data):
235 self.restartLanRef.close(True)
237 def restartfinishedCB(self,data):
240 self.session.open(MessageBox, _("Finished configuring your network"), type = MessageBox.TYPE_INFO, timeout = 10, default = False)
242 def openNetworkWizard(self):
243 if os_path.exists(resolveFilename(SCOPE_PLUGINS, "SystemPlugins/NetworkWizard/networkwizard.xml")):
245 from Plugins.SystemPlugins.NetworkWizard.NetworkWizard import NetworkWizard
247 self.session.open(MessageBox, _("The NetworkWizard extension is not installed!\nPlease install it."), type = MessageBox.TYPE_INFO,timeout = 10 )
249 selection = self["list"].getCurrent()
250 if selection is not None:
251 self.session.openWithCallback(self.AdapterSetupClosed, NetworkWizard, selection[0])
254 class NameserverSetup(Screen, ConfigListScreen, HelpableScreen):
255 def __init__(self, session):
256 Screen.__init__(self, session)
257 HelpableScreen.__init__(self)
258 self.backupNameserverList = iNetwork.getNameserverList()[:]
259 print "backup-list:", self.backupNameserverList
261 self["key_red"] = StaticText(_("Cancel"))
262 self["key_green"] = StaticText(_("Add"))
263 self["key_yellow"] = StaticText(_("Delete"))
265 self["introduction"] = StaticText(_("Press OK to activate the settings."))
268 self["OkCancelActions"] = HelpableActionMap(self, "OkCancelActions",
270 "cancel": (self.cancel, _("exit nameserver configuration")),
271 "ok": (self.ok, _("activate current configuration")),
274 self["ColorActions"] = HelpableActionMap(self, "ColorActions",
276 "red": (self.cancel, _("exit nameserver configuration")),
277 "green": (self.add, _("add a nameserver entry")),
278 "yellow": (self.remove, _("remove a nameserver entry")),
281 self["actions"] = NumberActionMap(["SetupActions"],
287 ConfigListScreen.__init__(self, self.list)
290 def createConfig(self):
291 self.nameservers = iNetwork.getNameserverList()
292 self.nameserverEntries = [ NoSave(ConfigIP(default=nameserver)) for nameserver in self.nameservers]
294 def createSetup(self):
298 for x in self.nameserverEntries:
299 self.list.append(getConfigListEntry(_("Nameserver %d") % (i), x))
302 self["config"].list = self.list
303 self["config"].l.setList(self.list)
306 iNetwork.clearNameservers()
307 for nameserver in self.nameserverEntries:
308 iNetwork.addNameserver(nameserver.value)
309 iNetwork.writeNameserverConfig()
316 iNetwork.clearNameservers()
317 print "backup-list:", self.backupNameserverList
318 for nameserver in self.backupNameserverList:
319 iNetwork.addNameserver(nameserver)
323 iNetwork.addNameserver([0,0,0,0])
328 print "currentIndex:", self["config"].getCurrentIndex()
329 index = self["config"].getCurrentIndex()
330 if index < len(self.nameservers):
331 iNetwork.removeNameserver(self.nameservers[index])
336 class AdapterSetup(Screen, ConfigListScreen, HelpableScreen):
337 def __init__(self, session, networkinfo, essid=None, aplist=None):
338 Screen.__init__(self, session)
339 HelpableScreen.__init__(self)
340 self.session = session
341 if isinstance(networkinfo, (list, tuple)):
342 self.iface = networkinfo[0]
343 self.essid = networkinfo[1]
344 self.aplist = networkinfo[2]
346 self.iface = networkinfo
350 self.applyConfigRef = None
351 self.finished_cb = None
352 self.oktext = _("Press OK on your remote control to continue.")
353 self.oldInterfaceState = iNetwork.getAdapterAttribute(self.iface, "up")
357 self["OkCancelActions"] = HelpableActionMap(self, "OkCancelActions",
359 "cancel": (self.keyCancel, _("exit network adapter configuration")),
360 "ok": (self.keySave, _("activate network adapter configuration")),
363 self["ColorActions"] = HelpableActionMap(self, "ColorActions",
365 "red": (self.keyCancel, _("exit network adapter configuration")),
366 "blue": (self.KeyBlue, _("open nameserver configuration")),
369 self["actions"] = NumberActionMap(["SetupActions"],
375 ConfigListScreen.__init__(self, self.list,session = self.session)
377 self.onLayoutFinish.append(self.layoutFinished)
378 self.onClose.append(self.cleanup)
380 self["DNS1text"] = StaticText(_("Primary DNS"))
381 self["DNS2text"] = StaticText(_("Secondary DNS"))
382 self["DNS1"] = StaticText()
383 self["DNS2"] = StaticText()
384 self["introduction"] = StaticText(_("Current settings:"))
386 self["IPtext"] = StaticText(_("IP Address"))
387 self["Netmasktext"] = StaticText(_("Netmask"))
388 self["Gatewaytext"] = StaticText(_("Gateway"))
390 self["IP"] = StaticText()
391 self["Mask"] = StaticText()
392 self["Gateway"] = StaticText()
394 self["Adaptertext"] = StaticText(_("Network:"))
395 self["Adapter"] = StaticText()
396 self["introduction2"] = StaticText(_("Press OK to activate the settings."))
397 self["key_red"] = StaticText(_("Cancel"))
398 self["key_blue"] = StaticText(_("Edit DNS"))
400 self["VKeyIcon"] = Boolean(False)
401 self["HelpWindow"] = Pixmap()
402 self["HelpWindow"].hide()
404 def layoutFinished(self):
405 self["DNS1"].setText(self.primaryDNS.getText())
406 self["DNS2"].setText(self.secondaryDNS.getText())
407 if self.ipConfigEntry.getText() is not None:
408 if self.ipConfigEntry.getText() == "0.0.0.0":
409 self["IP"].setText(_("N/A"))
411 self["IP"].setText(self.ipConfigEntry.getText())
413 self["IP"].setText(_("N/A"))
414 if self.netmaskConfigEntry.getText() is not None:
415 if self.netmaskConfigEntry.getText() == "0.0.0.0":
416 self["Mask"].setText(_("N/A"))
418 self["Mask"].setText(self.netmaskConfigEntry.getText())
420 self["IP"].setText(_("N/A"))
421 if iNetwork.getAdapterAttribute(self.iface, "gateway"):
422 if self.gatewayConfigEntry.getText() == "0.0.0.0":
423 self["Gatewaytext"].setText(_("Gateway"))
424 self["Gateway"].setText(_("N/A"))
426 self["Gatewaytext"].setText(_("Gateway"))
427 self["Gateway"].setText(self.gatewayConfigEntry.getText())
429 self["Gateway"].setText("")
430 self["Gatewaytext"].setText("")
431 self["Adapter"].setText(iNetwork.getFriendlyAdapterName(self.iface))
433 def createConfig(self):
434 self.InterfaceEntry = None
435 self.dhcpEntry = None
436 self.gatewayEntry = None
437 self.hiddenSSID = None
439 self.encryptionEnabled = None
440 self.encryptionKey = None
441 self.encryptionType = None
443 self.encryptionlist = None
448 if self.iface in iNetwork.wlan_interfaces:
449 from Plugins.SystemPlugins.WirelessLan.Wlan import wpaSupplicant,Wlan
450 self.w = Wlan(self.iface)
451 self.ws = wpaSupplicant()
452 self.encryptionlist = []
453 self.encryptionlist.append(("WEP", _("WEP")))
454 self.encryptionlist.append(("WPA", _("WPA")))
455 self.encryptionlist.append(("WPA2", _("WPA2")))
456 self.encryptionlist.append(("WPA/WPA2", _("WPA or WPA2")))
458 self.weplist.append("ASCII")
459 self.weplist.append("HEX")
460 if self.aplist is not None:
461 self.nwlist = self.aplist
462 self.nwlist.sort(key = lambda x: x[0])
467 self.aps = self.w.getNetworkList()
468 if self.aps is not None:
473 self.nwlist.append((a['essid'],a['essid']))
474 self.nwlist.sort(key = lambda x: x[0])
476 self.nwlist.append(("No Networks found",_("No Networks found")))
478 self.wsconfig = self.ws.loadConfig()
479 if self.essid is not None: # ssid from wlan scan
480 self.default = self.essid
482 self.default = self.wsconfig['ssid']
484 if "hidden..." not in self.nwlist:
485 self.nwlist.append(("hidden...",_("enter hidden network SSID")))
486 if self.default not in self.nwlist:
487 self.nwlist.append((self.default,self.default))
488 config.plugins.wlan.essid = NoSave(ConfigSelection(self.nwlist, default = self.default ))
489 config.plugins.wlan.hiddenessid = NoSave(ConfigText(default = self.wsconfig['hiddenessid'], visible_width = 50, fixed_size = False))
491 config.plugins.wlan.encryption.enabled = NoSave(ConfigYesNo(default = self.wsconfig['encryption'] ))
492 config.plugins.wlan.encryption.type = NoSave(ConfigSelection(self.encryptionlist, default = self.wsconfig['encryption_type'] ))
493 config.plugins.wlan.encryption.wepkeytype = NoSave(ConfigSelection(self.weplist, default = self.wsconfig['encryption_wepkeytype'] ))
494 config.plugins.wlan.encryption.psk = NoSave(ConfigPassword(default = self.wsconfig['key'], visible_width = 50, fixed_size = False))
496 self.activateInterfaceEntry = NoSave(ConfigYesNo(default=iNetwork.getAdapterAttribute(self.iface, "up") or False))
497 self.dhcpConfigEntry = NoSave(ConfigYesNo(default=iNetwork.getAdapterAttribute(self.iface, "dhcp") or False))
498 self.ipConfigEntry = NoSave(ConfigIP(default=iNetwork.getAdapterAttribute(self.iface, "ip")) or [0,0,0,0])
499 self.netmaskConfigEntry = NoSave(ConfigIP(default=iNetwork.getAdapterAttribute(self.iface, "netmask") or [255,0,0,0]))
500 if iNetwork.getAdapterAttribute(self.iface, "gateway"):
501 self.dhcpdefault=True
503 self.dhcpdefault=False
504 self.hasGatewayConfigEntry = NoSave(ConfigYesNo(default=self.dhcpdefault or False))
505 self.gatewayConfigEntry = NoSave(ConfigIP(default=iNetwork.getAdapterAttribute(self.iface, "gateway") or [0,0,0,0]))
506 nameserver = (iNetwork.getNameserverList() + [[0,0,0,0]] * 2)[0:2]
507 self.primaryDNS = NoSave(ConfigIP(default=nameserver[0]))
508 self.secondaryDNS = NoSave(ConfigIP(default=nameserver[1]))
510 def createSetup(self):
512 self.InterfaceEntry = getConfigListEntry(_("Use Interface"), self.activateInterfaceEntry)
514 self.list.append(self.InterfaceEntry)
515 if self.activateInterfaceEntry.value:
516 self.dhcpEntry = getConfigListEntry(_("Use DHCP"), self.dhcpConfigEntry)
517 self.list.append(self.dhcpEntry)
518 if not self.dhcpConfigEntry.value:
519 self.list.append(getConfigListEntry(_('IP Address'), self.ipConfigEntry))
520 self.list.append(getConfigListEntry(_('Netmask'), self.netmaskConfigEntry))
521 self.gatewayEntry = getConfigListEntry(_('Use a gateway'), self.hasGatewayConfigEntry)
522 self.list.append(self.gatewayEntry)
523 if self.hasGatewayConfigEntry.value:
524 self.list.append(getConfigListEntry(_('Gateway'), self.gatewayConfigEntry))
527 for p in plugins.getPlugins(PluginDescriptor.WHERE_NETWORKSETUP):
528 callFnc = p.__call__["ifaceSupported"](self.iface)
529 if callFnc is not None:
530 if p.__call__.has_key("WlanPluginEntry"): # internally used only for WLAN Plugin
531 self.extended = callFnc
532 if p.__call__.has_key("configStrings"):
533 self.configStrings = p.__call__["configStrings"]
535 self.configStrings = None
536 if config.plugins.wlan.essid.value == 'hidden...':
537 self.wlanSSID = getConfigListEntry(_("Network SSID"), config.plugins.wlan.essid)
538 self.list.append(self.wlanSSID)
539 self.hiddenSSID = getConfigListEntry(_("Hidden network SSID"), config.plugins.wlan.hiddenessid)
540 self.list.append(self.hiddenSSID)
542 self.wlanSSID = getConfigListEntry(_("Network SSID"), config.plugins.wlan.essid)
543 self.list.append(self.wlanSSID)
544 self.encryptionEnabled = getConfigListEntry(_("Encryption"), config.plugins.wlan.encryption.enabled)
545 self.list.append(self.encryptionEnabled)
547 if config.plugins.wlan.encryption.enabled.value:
548 self.encryptionType = getConfigListEntry(_("Encryption Type"), config.plugins.wlan.encryption.type)
549 self.list.append(self.encryptionType)
550 if config.plugins.wlan.encryption.type.value == 'WEP':
551 self.list.append(getConfigListEntry(_("Encryption Keytype"), config.plugins.wlan.encryption.wepkeytype))
552 self.encryptionKey = getConfigListEntry(_("Encryption Key"), config.plugins.wlan.encryption.psk)
553 self.list.append(self.encryptionKey)
555 self.encryptionKey = getConfigListEntry(_("Encryption Key"), config.plugins.wlan.encryption.psk)
556 self.list.append(self.encryptionKey)
558 self["config"].list = self.list
559 self["config"].l.setList(self.list)
562 self.session.openWithCallback(self.NameserverSetupClosed, NameserverSetup)
565 if self["config"].getCurrent() == self.InterfaceEntry:
567 if self["config"].getCurrent() == self.dhcpEntry:
569 if self["config"].getCurrent() == self.gatewayEntry:
571 if self.iface in iNetwork.wlan_interfaces:
572 if self["config"].getCurrent() == self.wlanSSID:
574 if self["config"].getCurrent() == self.encryptionEnabled:
576 if self["config"].getCurrent() == self.encryptionType:
580 ConfigListScreen.keyLeft(self)
584 ConfigListScreen.keyRight(self)
589 if self["config"].isChanged():
590 self.session.openWithCallback(self.keySaveConfirm, MessageBox, (_("Are you sure you want to activate this network configuration?\n\n") + self.oktext ) )
597 def keySaveConfirm(self, ret = False):
599 num_configured_if = len(iNetwork.getConfiguredAdapters())
600 if num_configured_if >= 1:
601 if num_configured_if == 1 and self.iface in iNetwork.getConfiguredAdapters():
602 self.applyConfig(True)
604 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)
606 self.applyConfig(True)
610 def secondIfaceFoundCB(self,data):
612 self.applyConfig(True)
614 configuredInterfaces = iNetwork.getConfiguredAdapters()
615 for interface in configuredInterfaces:
616 if interface == self.iface:
618 iNetwork.setAdapterAttribute(interface, "up", False)
619 iNetwork.deactivateInterface(interface)
620 self.applyConfig(True)
622 def applyConfig(self, ret = False):
624 iNetwork.setAdapterAttribute(self.iface, "up", self.activateInterfaceEntry.value)
625 iNetwork.setAdapterAttribute(self.iface, "dhcp", self.dhcpConfigEntry.value)
626 iNetwork.setAdapterAttribute(self.iface, "ip", self.ipConfigEntry.value)
627 iNetwork.setAdapterAttribute(self.iface, "netmask", self.netmaskConfigEntry.value)
628 if self.hasGatewayConfigEntry.value:
629 iNetwork.setAdapterAttribute(self.iface, "gateway", self.gatewayConfigEntry.value)
631 iNetwork.removeAdapterAttribute(self.iface, "gateway")
632 if self.extended is not None and self.configStrings is not None:
633 iNetwork.setAdapterAttribute(self.iface, "configStrings", self.configStrings(self.iface))
634 self.ws.writeConfig()
635 if self.activateInterfaceEntry.value is False:
636 iNetwork.deactivateInterface(self.iface)
637 iNetwork.writeNetworkConfig()
638 iNetwork.restartNetwork(self.applyConfigDataAvail)
639 self.applyConfigRef = self.session.openWithCallback(self.applyConfigfinishedCB, MessageBox, _("Please wait for activation of your network configuration..."), type = MessageBox.TYPE_INFO, enable_input = False)
643 def applyConfigDataAvail(self, data):
645 iNetwork.getInterfaces(self.getInterfacesDataAvail)
647 def getInterfacesDataAvail(self, data):
649 self.applyConfigRef.close(True)
651 def applyConfigfinishedCB(self,data):
654 self.session.openWithCallback(lambda x : self.finished_cb(), MessageBox, _("Your network configuration has been activated."), type = MessageBox.TYPE_INFO, timeout = 10)
656 self.session.openWithCallback(self.ConfigfinishedCB, MessageBox, _("Your network configuration has been activated."), type = MessageBox.TYPE_INFO, timeout = 10)
658 def ConfigfinishedCB(self,data):
663 def keyCancelConfirm(self, result):
666 if self.oldInterfaceState is False:
667 iNetwork.deactivateInterface(self.iface,self.keyCancelCB)
673 if self["config"].isChanged():
674 self.session.openWithCallback(self.keyCancelConfirm, MessageBox, _("Really close without saving settings?"))
678 def keyCancelCB(self,data):
683 def runAsync(self, finished_cb):
684 self.finished_cb = finished_cb
687 def NameserverSetupClosed(self, *ret):
688 iNetwork.loadNameserverConfig()
689 nameserver = (iNetwork.getNameserverList() + [[0,0,0,0]] * 2)[0:2]
690 self.primaryDNS = NoSave(ConfigIP(default=nameserver[0]))
691 self.secondaryDNS = NoSave(ConfigIP(default=nameserver[1]))
693 self.layoutFinished()
696 iNetwork.stopLinkStateConsole()
698 def hideInputHelp(self):
699 current = self["config"].getCurrent()
700 if current == self.hiddenSSID and config.plugins.wlan.essid.value == 'hidden...':
701 if current[1].help_window.instance is not None:
702 current[1].help_window.instance.hide()
703 elif current == self.encryptionKey and config.plugins.wlan.encryption.enabled.value:
704 if current[1].help_window.instance is not None:
705 current[1].help_window.instance.hide()
708 class AdapterSetupConfiguration(Screen, HelpableScreen):
709 def __init__(self, session,iface):
710 Screen.__init__(self, session)
711 HelpableScreen.__init__(self)
712 self.session = session
714 self.restartLanRef = None
715 self.LinkState = None
716 self.mainmenu = self.genMainMenu()
717 self["menulist"] = MenuList(self.mainmenu)
718 self["key_red"] = StaticText(_("Close"))
719 self["description"] = StaticText()
720 self["IFtext"] = StaticText()
721 self["IF"] = StaticText()
722 self["Statustext"] = StaticText()
723 self["statuspic"] = MultiPixmap()
724 self["statuspic"].hide()
726 self.oktext = _("Press OK on your remote control to continue.")
727 self.reboottext = _("Your STB will restart after pressing OK on your remote control.")
728 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.")
730 self["WizardActions"] = HelpableActionMap(self, "WizardActions",
732 "up": (self.up, _("move up to previous entry")),
733 "down": (self.down, _("move down to next entry")),
734 "left": (self.left, _("move up to first entry")),
735 "right": (self.right, _("move down to last entry")),
738 self["OkCancelActions"] = HelpableActionMap(self, "OkCancelActions",
740 "cancel": (self.close, _("exit networkadapter setup menu")),
741 "ok": (self.ok, _("select menu entry")),
744 self["ColorActions"] = HelpableActionMap(self, "ColorActions",
746 "red": (self.close, _("exit networkadapter setup menu")),
749 self["actions"] = NumberActionMap(["WizardActions","ShortcutActions"],
760 self.updateStatusbar()
761 self.onLayoutFinish.append(self.layoutFinished)
762 self.onClose.append(self.cleanup)
766 if self["menulist"].getCurrent()[1] == 'edit':
767 if self.iface in iNetwork.wlan_interfaces:
769 from Plugins.SystemPlugins.WirelessLan.plugin import WlanScan
770 from pythonwifi.iwlibs import Wireless
772 self.session.open(MessageBox, _("The wireless LAN plugin is not installed!\nPlease install it."), type = MessageBox.TYPE_INFO,timeout = 10 )
774 ifobj = Wireless(self.iface) # a Wireless NIC Object
776 self.wlanresponse = ifobj.getAPaddr()
778 self.wlanresponse = ifobj.getStatistics()
779 if self.wlanresponse:
780 if self.wlanresponse[0] not in (19,95): # 19 = 'No such device', 95 = 'Operation not supported'
781 self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetup,self.iface)
783 # Display Wlan not available Message
784 self.showErrorMessage()
786 # Display Wlan not available Message
787 self.showErrorMessage()
789 self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetup,self.iface)
790 if self["menulist"].getCurrent()[1] == 'test':
791 self.session.open(NetworkAdapterTest,self.iface)
792 if self["menulist"].getCurrent()[1] == 'dns':
793 self.session.open(NameserverSetup)
794 if self["menulist"].getCurrent()[1] == 'scanwlan':
796 from Plugins.SystemPlugins.WirelessLan.plugin import WlanScan
797 from pythonwifi.iwlibs import Wireless
799 self.session.open(MessageBox, _("The wireless LAN plugin is not installed!\nPlease install it."), type = MessageBox.TYPE_INFO,timeout = 10 )
801 ifobj = Wireless(self.iface) # a Wireless NIC Object
803 self.wlanresponse = ifobj.getAPaddr()
805 self.wlanresponse = ifobj.getStatistics()
806 if self.wlanresponse:
807 if self.wlanresponse[0] not in (19,95): # 19 = 'No such device', 95 = 'Operation not supported'
808 self.session.openWithCallback(self.WlanScanClosed, WlanScan, self.iface)
810 # Display Wlan not available Message
811 self.showErrorMessage()
813 # Display Wlan not available Message
814 self.showErrorMessage()
815 if self["menulist"].getCurrent()[1] == 'wlanstatus':
817 from Plugins.SystemPlugins.WirelessLan.plugin import WlanStatus
818 from pythonwifi.iwlibs import Wireless
820 self.session.open(MessageBox, _("The wireless LAN plugin is not installed!\nPlease install it."), type = MessageBox.TYPE_INFO,timeout = 10 )
822 ifobj = Wireless(self.iface) # a Wireless NIC Object
824 self.wlanresponse = ifobj.getAPaddr()
826 self.wlanresponse = ifobj.getStatistics()
827 if self.wlanresponse:
828 if self.wlanresponse[0] not in (19,95): # 19 = 'No such device', 95 = 'Operation not supported'
829 self.session.openWithCallback(self.WlanStatusClosed, WlanStatus,self.iface)
831 # Display Wlan not available Message
832 self.showErrorMessage()
834 # Display Wlan not available Message
835 self.showErrorMessage()
836 if self["menulist"].getCurrent()[1] == 'lanrestart':
837 self.session.openWithCallback(self.restartLan, MessageBox, (_("Are you sure you want to restart your network interfaces?\n\n") + self.oktext ) )
838 if self["menulist"].getCurrent()[1] == 'openwizard':
839 from Plugins.SystemPlugins.NetworkWizard.NetworkWizard import NetworkWizard
840 self.session.openWithCallback(self.AdapterSetupClosed, NetworkWizard, self.iface)
841 if self["menulist"].getCurrent()[1][0] == 'extendedSetup':
842 self.extended = self["menulist"].getCurrent()[1][2]
843 self.extended(self.session, self.iface)
846 self["menulist"].up()
847 self.loadDescription()
850 self["menulist"].down()
851 self.loadDescription()
854 self["menulist"].pageUp()
855 self.loadDescription()
858 self["menulist"].pageDown()
859 self.loadDescription()
861 def layoutFinished(self):
863 self["menulist"].moveToIndex(idx)
864 self.loadDescription()
866 def loadDescription(self):
867 if self["menulist"].getCurrent()[1] == 'edit':
868 self["description"].setText(_("Edit the network configuration of your STB.\n" ) + self.oktext )
869 if self["menulist"].getCurrent()[1] == 'test':
870 self["description"].setText(_("Test the network configuration of your STB.\n" ) + self.oktext )
871 if self["menulist"].getCurrent()[1] == 'dns':
872 self["description"].setText(_("Edit the Nameserver configuration of your STB.\n" ) + self.oktext )
873 if self["menulist"].getCurrent()[1] == 'scanwlan':
874 self["description"].setText(_("Scan your network for wireless access points and connect to them using your selected wireless device.\n" ) + self.oktext )
875 if self["menulist"].getCurrent()[1] == 'wlanstatus':
876 self["description"].setText(_("Shows the state of your wireless LAN connection.\n" ) + self.oktext )
877 if self["menulist"].getCurrent()[1] == 'lanrestart':
878 self["description"].setText(_("Restart your network connection and interfaces.\n" ) + self.oktext )
879 if self["menulist"].getCurrent()[1] == 'openwizard':
880 self["description"].setText(_("Use the Networkwizard to configure your Network\n" ) + self.oktext )
881 if self["menulist"].getCurrent()[1][0] == 'extendedSetup':
882 self["description"].setText(_(self["menulist"].getCurrent()[1][1]) + self.oktext )
884 def updateStatusbar(self, data = None):
885 self.mainmenu = self.genMainMenu()
886 self["menulist"].l.setList(self.mainmenu)
887 self["IFtext"].setText(_("Network:"))
888 self["IF"].setText(iNetwork.getFriendlyAdapterName(self.iface))
889 self["Statustext"].setText(_("Link:"))
891 if self.iface in iNetwork.wlan_interfaces:
893 from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus
895 self["statuspic"].setPixmapNum(1)
896 self["statuspic"].show()
898 iStatus.getDataForInterface(self.iface,self.getInfoCB)
900 iNetwork.getLinkState(self.iface,self.dataAvail)
905 def genMainMenu(self):
907 menu.append((_("Adapter settings"), "edit"))
908 menu.append((_("Nameserver settings"), "dns"))
909 menu.append((_("Network test"), "test"))
910 menu.append((_("Restart network"), "lanrestart"))
913 self.extendedSetup = None
914 for p in plugins.getPlugins(PluginDescriptor.WHERE_NETWORKSETUP):
915 callFnc = p.__call__["ifaceSupported"](self.iface)
916 if callFnc is not None:
917 self.extended = callFnc
918 if p.__call__.has_key("WlanPluginEntry"): # internally used only for WLAN Plugin
919 menu.append((_("Scan Wireless Networks"), "scanwlan"))
920 if iNetwork.getAdapterAttribute(self.iface, "up"):
921 menu.append((_("Show WLAN Status"), "wlanstatus"))
923 if p.__call__.has_key("menuEntryName"):
924 menuEntryName = p.__call__["menuEntryName"](self.iface)
926 menuEntryName = _('Extended Setup...')
927 if p.__call__.has_key("menuEntryDescription"):
928 menuEntryDescription = p.__call__["menuEntryDescription"](self.iface)
930 menuEntryDescription = _('Extended Networksetup Plugin...')
931 self.extendedSetup = ('extendedSetup',menuEntryDescription, self.extended)
932 menu.append((menuEntryName,self.extendedSetup))
934 if os_path.exists(resolveFilename(SCOPE_PLUGINS, "SystemPlugins/NetworkWizard/networkwizard.xml")):
935 menu.append((_("NetworkWizard"), "openwizard"))
939 def AdapterSetupClosed(self, *ret):
940 if ret is not None and len(ret):
941 if ret[0] == 'ok' and (self.iface in iNetwork.wlan_interfaces) and iNetwork.getAdapterAttribute(self.iface, "up") is True:
943 from Plugins.SystemPlugins.WirelessLan.plugin import WlanStatus
944 from pythonwifi.iwlibs import Wireless
946 self.session.open(MessageBox, _("The wireless LAN plugin is not installed!\nPlease install it."), type = MessageBox.TYPE_INFO,timeout = 10 )
948 ifobj = Wireless(self.iface) # a Wireless NIC Object
950 self.wlanresponse = ifobj.getAPaddr()
952 self.wlanresponse = ifobj.getStatistics()
953 if self.wlanresponse:
954 if self.wlanresponse[0] not in (19,95): # 19 = 'No such device', 95 = 'Operation not supported'
955 self.session.openWithCallback(self.WlanStatusClosed, WlanStatus,self.iface)
957 # Display Wlan not available Message
958 self.showErrorMessage()
960 # Display Wlan not available Message
961 self.showErrorMessage()
963 self.updateStatusbar()
965 self.updateStatusbar()
967 def WlanStatusClosed(self, *ret):
968 if ret is not None and len(ret):
969 from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus
970 iStatus.stopWlanConsole()
971 self.updateStatusbar()
973 def WlanScanClosed(self,*ret):
974 if ret[0] is not None:
975 self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetup, self.iface,ret[0],ret[1])
977 from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus
978 iStatus.stopWlanConsole()
979 self.updateStatusbar()
981 def restartLan(self, ret = False):
983 iNetwork.restartNetwork(self.restartLanDataAvail)
984 self.restartLanRef = self.session.openWithCallback(self.restartfinishedCB, MessageBox, _("Please wait while your network is restarting..."), type = MessageBox.TYPE_INFO, enable_input = False)
986 def restartLanDataAvail(self, data):
988 iNetwork.getInterfaces(self.getInterfacesDataAvail)
990 def getInterfacesDataAvail(self, data):
992 self.restartLanRef.close(True)
994 def restartfinishedCB(self,data):
996 self.updateStatusbar()
997 self.session.open(MessageBox, _("Finished restarting your network"), type = MessageBox.TYPE_INFO, timeout = 10, default = False)
999 def dataAvail(self,data):
1000 self.LinkState = None
1001 for line in data.splitlines():
1003 if 'Link detected:' in line:
1005 self.LinkState = True
1007 self.LinkState = False
1008 if self.LinkState == True:
1009 iNetwork.checkNetworkState(self.checkNetworkCB)
1011 self["statuspic"].setPixmapNum(1)
1012 self["statuspic"].show()
1014 def showErrorMessage(self):
1015 self.session.open(MessageBox, self.errortext, type = MessageBox.TYPE_INFO,timeout = 10 )
1018 iNetwork.stopLinkStateConsole()
1019 iNetwork.stopDeactivateInterfaceConsole()
1020 iNetwork.stopPingConsole()
1022 from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus
1026 iStatus.stopWlanConsole()
1028 def getInfoCB(self,data,status):
1029 self.LinkState = None
1030 if data is not None:
1032 if status is not None:
1033 if status[self.iface]["acesspoint"] == "No Connection" or status[self.iface]["acesspoint"] == "Not-Associated" or status[self.iface]["acesspoint"] == False:
1034 self.LinkState = False
1035 self["statuspic"].setPixmapNum(1)
1036 self["statuspic"].show()
1038 self.LinkState = True
1039 iNetwork.checkNetworkState(self.checkNetworkCB)
1041 def checkNetworkCB(self,data):
1042 if iNetwork.getAdapterAttribute(self.iface, "up") is True:
1043 if self.LinkState is True:
1045 self["statuspic"].setPixmapNum(0)
1047 self["statuspic"].setPixmapNum(1)
1048 self["statuspic"].show()
1050 self["statuspic"].setPixmapNum(1)
1051 self["statuspic"].show()
1053 self["statuspic"].setPixmapNum(1)
1054 self["statuspic"].show()
1057 class NetworkAdapterTest(Screen):
1058 def __init__(self, session,iface):
1059 Screen.__init__(self, session)
1061 self.oldInterfaceState = iNetwork.getAdapterAttribute(self.iface, "up")
1063 self.onClose.append(self.cleanup)
1064 self.onHide.append(self.cleanup)
1066 self["updown_actions"] = NumberActionMap(["WizardActions","ShortcutActions"],
1070 "up": lambda: self.updownhandler('up'),
1071 "down": lambda: self.updownhandler('down'),
1075 self["shortcuts"] = ActionMap(["ShortcutActions","WizardActions"],
1078 "back": self.cancel,
1080 self["infoshortcuts"] = ActionMap(["ShortcutActions","WizardActions"],
1082 "red": self.closeInfo,
1083 "back": self.closeInfo,
1085 self["shortcutsgreen"] = ActionMap(["ShortcutActions"],
1087 "green": self.KeyGreen,
1089 self["shortcutsgreen_restart"] = ActionMap(["ShortcutActions"],
1091 "green": self.KeyGreenRestart,
1093 self["shortcutsyellow"] = ActionMap(["ShortcutActions"],
1095 "yellow": self.KeyYellow,
1098 self["shortcutsgreen_restart"].setEnabled(False)
1099 self["updown_actions"].setEnabled(False)
1100 self["infoshortcuts"].setEnabled(False)
1101 self.onClose.append(self.delTimer)
1102 self.onLayoutFinish.append(self.layoutFinished)
1103 self.steptimer = False
1105 self.activebutton = 0
1106 self.nextStepTimer = eTimer()
1107 self.nextStepTimer.callback.append(self.nextStepTimerFire)
1110 if self.oldInterfaceState is False:
1111 iNetwork.setAdapterAttribute(self.iface, "up", self.oldInterfaceState)
1112 iNetwork.deactivateInterface(self.iface)
1115 def closeInfo(self):
1116 self["shortcuts"].setEnabled(True)
1117 self["infoshortcuts"].setEnabled(False)
1118 self["InfoText"].hide()
1119 self["InfoTextBorder"].hide()
1120 self["key_red"].setText(_("Close"))
1124 del self.nextStepTimer
1126 def nextStepTimerFire(self):
1127 self.nextStepTimer.stop()
1128 self.steptimer = False
1131 def updownhandler(self,direction):
1132 if direction == 'up':
1133 if self.activebutton >=2:
1134 self.activebutton -= 1
1136 self.activebutton = 6
1137 self.setActiveButton(self.activebutton)
1138 if direction == 'down':
1139 if self.activebutton <=5:
1140 self.activebutton += 1
1142 self.activebutton = 1
1143 self.setActiveButton(self.activebutton)
1145 def setActiveButton(self,button):
1147 self["EditSettingsButton"].setPixmapNum(0)
1148 self["EditSettings_Text"].setForegroundColorNum(0)
1149 self["NetworkInfo"].setPixmapNum(0)
1150 self["NetworkInfo_Text"].setForegroundColorNum(1)
1151 self["AdapterInfo"].setPixmapNum(1) # active
1152 self["AdapterInfo_Text"].setForegroundColorNum(2) # active
1154 self["AdapterInfo_Text"].setForegroundColorNum(1)
1155 self["AdapterInfo"].setPixmapNum(0)
1156 self["DhcpInfo"].setPixmapNum(0)
1157 self["DhcpInfo_Text"].setForegroundColorNum(1)
1158 self["NetworkInfo"].setPixmapNum(1) # active
1159 self["NetworkInfo_Text"].setForegroundColorNum(2) # active
1161 self["NetworkInfo"].setPixmapNum(0)
1162 self["NetworkInfo_Text"].setForegroundColorNum(1)
1163 self["IPInfo"].setPixmapNum(0)
1164 self["IPInfo_Text"].setForegroundColorNum(1)
1165 self["DhcpInfo"].setPixmapNum(1) # active
1166 self["DhcpInfo_Text"].setForegroundColorNum(2) # active
1168 self["DhcpInfo"].setPixmapNum(0)
1169 self["DhcpInfo_Text"].setForegroundColorNum(1)
1170 self["DNSInfo"].setPixmapNum(0)
1171 self["DNSInfo_Text"].setForegroundColorNum(1)
1172 self["IPInfo"].setPixmapNum(1) # active
1173 self["IPInfo_Text"].setForegroundColorNum(2) # active
1175 self["IPInfo"].setPixmapNum(0)
1176 self["IPInfo_Text"].setForegroundColorNum(1)
1177 self["EditSettingsButton"].setPixmapNum(0)
1178 self["EditSettings_Text"].setForegroundColorNum(0)
1179 self["DNSInfo"].setPixmapNum(1) # active
1180 self["DNSInfo_Text"].setForegroundColorNum(2) # active
1182 self["DNSInfo"].setPixmapNum(0)
1183 self["DNSInfo_Text"].setForegroundColorNum(1)
1184 self["EditSettingsButton"].setPixmapNum(1) # active
1185 self["EditSettings_Text"].setForegroundColorNum(2) # active
1186 self["AdapterInfo"].setPixmapNum(0)
1187 self["AdapterInfo_Text"].setForegroundColorNum(1)
1190 next = self.nextstep
1206 self.steptimer = True
1207 self.nextStepTimer.start(3000)
1208 self["key_yellow"].setText(_("Stop test"))
1211 self["Adapter"].setText(iNetwork.getFriendlyAdapterName(self.iface))
1212 self["Adapter"].setForegroundColorNum(2)
1213 self["Adaptertext"].setForegroundColorNum(1)
1214 self["AdapterInfo_Text"].setForegroundColorNum(1)
1215 self["AdapterInfo_OK"].show()
1216 self.steptimer = True
1217 self.nextStepTimer.start(3000)
1220 self["Networktext"].setForegroundColorNum(1)
1221 self["Network"].setText(_("Please wait..."))
1222 self.getLinkState(self.iface)
1223 self["NetworkInfo_Text"].setForegroundColorNum(1)
1224 self.steptimer = True
1225 self.nextStepTimer.start(3000)
1228 self["Dhcptext"].setForegroundColorNum(1)
1229 if iNetwork.getAdapterAttribute(self.iface, 'dhcp') is True:
1230 self["Dhcp"].setForegroundColorNum(2)
1231 self["Dhcp"].setText(_("enabled"))
1232 self["DhcpInfo_Check"].setPixmapNum(0)
1234 self["Dhcp"].setForegroundColorNum(1)
1235 self["Dhcp"].setText(_("disabled"))
1236 self["DhcpInfo_Check"].setPixmapNum(1)
1237 self["DhcpInfo_Check"].show()
1238 self["DhcpInfo_Text"].setForegroundColorNum(1)
1239 self.steptimer = True
1240 self.nextStepTimer.start(3000)
1243 self["IPtext"].setForegroundColorNum(1)
1244 self["IP"].setText(_("Please wait..."))
1245 iNetwork.checkNetworkState(self.NetworkStatedataAvail)
1248 self.steptimer = False
1249 self.nextStepTimer.stop()
1250 self["DNStext"].setForegroundColorNum(1)
1251 self["DNS"].setText(_("Please wait..."))
1252 iNetwork.checkDNSLookup(self.DNSLookupdataAvail)
1255 self["shortcutsgreen"].setEnabled(False)
1256 self["shortcutsyellow"].setEnabled(True)
1257 self["updown_actions"].setEnabled(False)
1258 self["key_yellow"].setText("")
1259 self["key_green"].setText("")
1260 self.steptimer = True
1261 self.nextStepTimer.start(1000)
1263 def KeyGreenRestart(self):
1265 self.layoutFinished()
1266 self["Adapter"].setText((""))
1267 self["Network"].setText((""))
1268 self["Dhcp"].setText((""))
1269 self["IP"].setText((""))
1270 self["DNS"].setText((""))
1271 self["AdapterInfo_Text"].setForegroundColorNum(0)
1272 self["NetworkInfo_Text"].setForegroundColorNum(0)
1273 self["DhcpInfo_Text"].setForegroundColorNum(0)
1274 self["IPInfo_Text"].setForegroundColorNum(0)
1275 self["DNSInfo_Text"].setForegroundColorNum(0)
1276 self["shortcutsgreen_restart"].setEnabled(False)
1277 self["shortcutsgreen"].setEnabled(False)
1278 self["shortcutsyellow"].setEnabled(True)
1279 self["updown_actions"].setEnabled(False)
1280 self["key_yellow"].setText("")
1281 self["key_green"].setText("")
1282 self.steptimer = True
1283 self.nextStepTimer.start(1000)
1286 self["infoshortcuts"].setEnabled(True)
1287 self["shortcuts"].setEnabled(False)
1288 if self.activebutton == 1: # Adapter Check
1289 self["InfoText"].setText(_("This test detects your configured LAN-Adapter."))
1290 self["InfoTextBorder"].show()
1291 self["InfoText"].show()
1292 self["key_red"].setText(_("Back"))
1293 if self.activebutton == 2: #LAN Check
1294 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"))
1295 self["InfoTextBorder"].show()
1296 self["InfoText"].show()
1297 self["key_red"].setText(_("Back"))
1298 if self.activebutton == 3: #DHCP Check
1299 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."))
1300 self["InfoTextBorder"].show()
1301 self["InfoText"].show()
1302 self["key_red"].setText(_("Back"))
1303 if self.activebutton == 4: # IP Check
1304 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"))
1305 self["InfoTextBorder"].show()
1306 self["InfoText"].show()
1307 self["key_red"].setText(_("Back"))
1308 if self.activebutton == 5: # DNS Check
1309 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"))
1310 self["InfoTextBorder"].show()
1311 self["InfoText"].show()
1312 self["key_red"].setText(_("Back"))
1313 if self.activebutton == 6: # Edit Settings
1314 self.session.open(AdapterSetup,self.iface)
1316 def KeyYellow(self):
1318 self["shortcutsgreen_restart"].setEnabled(True)
1319 self["shortcutsgreen"].setEnabled(False)
1320 self["shortcutsyellow"].setEnabled(False)
1321 self["key_green"].setText(_("Restart test"))
1322 self["key_yellow"].setText("")
1323 self.steptimer = False
1324 self.nextStepTimer.stop()
1326 def layoutFinished(self):
1327 self.setTitle(_("Network test: ") + iNetwork.getFriendlyAdapterName(self.iface) )
1328 self["shortcutsyellow"].setEnabled(False)
1329 self["AdapterInfo_OK"].hide()
1330 self["NetworkInfo_Check"].hide()
1331 self["DhcpInfo_Check"].hide()
1332 self["IPInfo_Check"].hide()
1333 self["DNSInfo_Check"].hide()
1334 self["EditSettings_Text"].hide()
1335 self["EditSettingsButton"].hide()
1336 self["InfoText"].hide()
1337 self["InfoTextBorder"].hide()
1338 self["key_yellow"].setText("")
1340 def setLabels(self):
1341 self["Adaptertext"] = MultiColorLabel(_("LAN Adapter"))
1342 self["Adapter"] = MultiColorLabel()
1343 self["AdapterInfo"] = MultiPixmap()
1344 self["AdapterInfo_Text"] = MultiColorLabel(_("Show Info"))
1345 self["AdapterInfo_OK"] = Pixmap()
1347 if self.iface in iNetwork.wlan_interfaces:
1348 self["Networktext"] = MultiColorLabel(_("Wireless Network"))
1350 self["Networktext"] = MultiColorLabel(_("Local Network"))
1352 self["Network"] = MultiColorLabel()
1353 self["NetworkInfo"] = MultiPixmap()
1354 self["NetworkInfo_Text"] = MultiColorLabel(_("Show Info"))
1355 self["NetworkInfo_Check"] = MultiPixmap()
1357 self["Dhcptext"] = MultiColorLabel(_("DHCP"))
1358 self["Dhcp"] = MultiColorLabel()
1359 self["DhcpInfo"] = MultiPixmap()
1360 self["DhcpInfo_Text"] = MultiColorLabel(_("Show Info"))
1361 self["DhcpInfo_Check"] = MultiPixmap()
1363 self["IPtext"] = MultiColorLabel(_("IP Address"))
1364 self["IP"] = MultiColorLabel()
1365 self["IPInfo"] = MultiPixmap()
1366 self["IPInfo_Text"] = MultiColorLabel(_("Show Info"))
1367 self["IPInfo_Check"] = MultiPixmap()
1369 self["DNStext"] = MultiColorLabel(_("Nameserver"))
1370 self["DNS"] = MultiColorLabel()
1371 self["DNSInfo"] = MultiPixmap()
1372 self["DNSInfo_Text"] = MultiColorLabel(_("Show Info"))
1373 self["DNSInfo_Check"] = MultiPixmap()
1375 self["EditSettings_Text"] = MultiColorLabel(_("Edit settings"))
1376 self["EditSettingsButton"] = MultiPixmap()
1378 self["key_red"] = StaticText(_("Close"))
1379 self["key_green"] = StaticText(_("Start test"))
1380 self["key_yellow"] = StaticText(_("Stop test"))
1382 self["InfoTextBorder"] = Pixmap()
1383 self["InfoText"] = Label()
1385 def getLinkState(self,iface):
1386 if iface in iNetwork.wlan_interfaces:
1388 from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus
1390 self["Network"].setForegroundColorNum(1)
1391 self["Network"].setText(_("disconnected"))
1392 self["NetworkInfo_Check"].setPixmapNum(1)
1393 self["NetworkInfo_Check"].show()
1395 iStatus.getDataForInterface(self.iface,self.getInfoCB)
1397 iNetwork.getLinkState(iface,self.LinkStatedataAvail)
1399 def LinkStatedataAvail(self,data):
1400 self.output = data.strip()
1401 result = self.output.split('\n')
1402 pattern = re_compile("Link detected: yes")
1404 if re_search(pattern, item):
1405 self["Network"].setForegroundColorNum(2)
1406 self["Network"].setText(_("connected"))
1407 self["NetworkInfo_Check"].setPixmapNum(0)
1409 self["Network"].setForegroundColorNum(1)
1410 self["Network"].setText(_("disconnected"))
1411 self["NetworkInfo_Check"].setPixmapNum(1)
1412 self["NetworkInfo_Check"].show()
1414 def NetworkStatedataAvail(self,data):
1416 self["IP"].setForegroundColorNum(2)
1417 self["IP"].setText(_("confirmed"))
1418 self["IPInfo_Check"].setPixmapNum(0)
1420 self["IP"].setForegroundColorNum(1)
1421 self["IP"].setText(_("unconfirmed"))
1422 self["IPInfo_Check"].setPixmapNum(1)
1423 self["IPInfo_Check"].show()
1424 self["IPInfo_Text"].setForegroundColorNum(1)
1425 self.steptimer = True
1426 self.nextStepTimer.start(3000)
1428 def DNSLookupdataAvail(self,data):
1430 self["DNS"].setForegroundColorNum(2)
1431 self["DNS"].setText(_("confirmed"))
1432 self["DNSInfo_Check"].setPixmapNum(0)
1434 self["DNS"].setForegroundColorNum(1)
1435 self["DNS"].setText(_("unconfirmed"))
1436 self["DNSInfo_Check"].setPixmapNum(1)
1437 self["DNSInfo_Check"].show()
1438 self["DNSInfo_Text"].setForegroundColorNum(1)
1439 self["EditSettings_Text"].show()
1440 self["EditSettingsButton"].setPixmapNum(1)
1441 self["EditSettings_Text"].setForegroundColorNum(2) # active
1442 self["EditSettingsButton"].show()
1443 self["key_yellow"].setText("")
1444 self["key_green"].setText(_("Restart test"))
1445 self["shortcutsgreen"].setEnabled(False)
1446 self["shortcutsgreen_restart"].setEnabled(True)
1447 self["shortcutsyellow"].setEnabled(False)
1448 self["updown_actions"].setEnabled(True)
1449 self.activebutton = 6
1451 def getInfoCB(self,data,status):
1452 if data is not None:
1454 if status is not None:
1455 if status[self.iface]["acesspoint"] == "No Connection" or status[self.iface]["acesspoint"] == "Not-Associated" or status[self.iface]["acesspoint"] == False:
1456 self["Network"].setForegroundColorNum(1)
1457 self["Network"].setText(_("disconnected"))
1458 self["NetworkInfo_Check"].setPixmapNum(1)
1459 self["NetworkInfo_Check"].show()
1461 self["Network"].setForegroundColorNum(2)
1462 self["Network"].setText(_("connected"))
1463 self["NetworkInfo_Check"].setPixmapNum(0)
1464 self["NetworkInfo_Check"].show()
1467 iNetwork.stopLinkStateConsole()
1468 iNetwork.stopDNSConsole()
1470 from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus
1474 iStatus.stopWlanConsole()