1 from Screen import Screen
2 from Components.ActionMap import ActionMap,NumberActionMap
3 from Screens.MessageBox import MessageBox
4 from Screens.Standby import *
5 from Components.ConfigList import ConfigListScreen
6 from Components.config import config, getConfigListEntry
7 from Components.Network import iNetwork
8 from Tools.Directories import resolveFilename, SCOPE_SKIN_IMAGE
9 from Components.Label import Label,MultiColorLabel
10 from Components.Pixmap import Pixmap,MultiPixmap
11 from Tools.LoadPixmap import LoadPixmap
12 from Components.MenuList import MenuList
13 from Components.config import config, ConfigYesNo, ConfigIP, NoSave, ConfigNothing, ConfigSubsection, ConfigText, ConfigSelection, getConfigListEntry
14 from Components.PluginComponent import plugins
15 from Plugins.Plugin import PluginDescriptor
16 from enigma import eTimer, eConsoleAppContainer,gRGB
18 from Tools.Directories import resolveFilename, SCOPE_PLUGINS
20 class NetworkAdapterSelection(Screen):
21 def __init__(self, session):
22 Screen.__init__(self, session)
23 iNetwork.getInterfaces()
24 self.wlan_errortext = _("No working wireless networkadapter found.\nPlease verify that you have attached a compatible WLAN USB Stick and your Network is configured correctly.")
25 self.lan_errortext = _("No working local networkadapter found.\nPlease verify that you have attached a network cable and your Network is configured correctly.")
26 self.adapters = [(iNetwork.getFriendlyAdapterName(x),x) for x in iNetwork.getAdapterList()]
27 if len(self.adapters) == 0:
28 self.onFirstExecBegin.append(self.NetworkFallback)
30 self["adapterlist"] = MenuList(self.adapters)
31 self["actions"] = ActionMap(["OkCancelActions"],
33 "ok": self.okbuttonClick,
37 if len(self.adapters) == 1:
38 self.onFirstExecBegin.append(self.okbuttonClick)
40 def okbuttonClick(self):
41 selection = self["adapterlist"].getCurrent()
42 if selection is not None:
43 self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetupConfiguration, selection[1])
45 def AdapterSetupClosed(self, *ret):
48 def NetworkFallback(self):
49 if iNetwork.configuredInterfaces.has_key('wlan0') is True:
50 self.session.openWithCallback(self.ErrorMessageClosed, MessageBox, self.wlan_errortext, type = MessageBox.TYPE_INFO,timeout = 10)
52 self.session.openWithCallback(self.ErrorMessageClosed, MessageBox, self.lan_errortext, type = MessageBox.TYPE_INFO,timeout = 10)
54 def ErrorMessageClosed(self, *ret):
55 if iNetwork.configuredInterfaces.has_key('wlan0') is True:
56 self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetupConfiguration, 'wlan0')
58 self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetupConfiguration, 'eth0')
60 class NameserverSetup(Screen, ConfigListScreen):
61 def __init__(self, session):
62 Screen.__init__(self, session)
63 iNetwork.getInterfaces()
64 self.backupNameserverList = iNetwork.getNameserverList()[:]
65 print "backup-list:", self.backupNameserverList
67 self["ButtonGreentext"] = Label(_("Add"))
68 self["ButtonYellowtext"] = Label(_("Delete"))
69 self["ButtonRedtext"] = Label(_("Close"))
72 self["actions"] = ActionMap(["OkCancelActions", "ColorActions"],
75 "cancel": self.cancel,
82 ConfigListScreen.__init__(self, self.list)
85 def createConfig(self):
86 self.nameservers = iNetwork.getNameserverList()
87 self.nameserverEntries = []
89 for nameserver in self.nameservers:
90 self.nameserverEntries.append(NoSave(ConfigIP(default=nameserver)))
92 def createSetup(self):
95 for i in range(len(self.nameserverEntries)):
96 self.list.append(getConfigListEntry(_("Nameserver %d") % (i + 1), self.nameserverEntries[i]))
98 self["config"].list = self.list
99 self["config"].l.setList(self.list)
102 iNetwork.clearNameservers()
103 for nameserver in self.nameserverEntries:
104 iNetwork.addNameserver(nameserver.value)
105 iNetwork.writeNameserverConfig()
109 iNetwork.clearNameservers()
110 print "backup-list:", self.backupNameserverList
111 for nameserver in self.backupNameserverList:
112 iNetwork.addNameserver(nameserver)
116 iNetwork.addNameserver([0,0,0,0])
121 print "currentIndex:", self["config"].getCurrentIndex()
123 index = self["config"].getCurrentIndex()
124 if index < len(self.nameservers):
125 iNetwork.removeNameserver(self.nameservers[index])
129 class AdapterSetup(Screen, ConfigListScreen):
130 def __init__(self, session, iface,essid=None, aplist=None):
131 Screen.__init__(self, session)
132 self.session = session
133 iNetwork.getInterfaces()
136 ## FIXME , workaround against current wizzard not able to send arguments
144 if self.iface == 'wlan0':
145 from Plugins.SystemPlugins.WirelessLan.Wlan import wpaSupplicant,Wlan
146 self.ws = wpaSupplicant()
148 list.append(_("WEP"))
149 list.append(_("WPA"))
150 list.append(_("WPA2"))
151 if self.aplist is not None:
152 self.nwlist = self.aplist
153 self.nwlist.sort(key = lambda x: x[0])
155 if iNetwork.getAdapterAttribute('wlan0', 'up') is True:
158 self.w = Wlan('wlan0')
159 aps = self.w.getNetworkList()
161 print "[Wlan.py] got Accespoints!"
166 a['essid'] = a['bssid']
167 self.nwlist.append( a['essid'])
168 self.nwlist.sort(key = lambda x: x[0])
170 self.nwlist.append("No Networks found")
172 self.nwlist.append("No Networks found")
174 wsconfig = self.ws.loadConfig()
175 default = self.essid or wsconfig['ssid']
176 if default not in self.nwlist:
177 self.nwlist.append(default)
178 config.plugins.wlan.essid = NoSave(ConfigSelection(self.nwlist, default = default ))
179 config.plugins.wlan.encryption.enabled = NoSave(ConfigYesNo(default = wsconfig['encryption'] ))
180 config.plugins.wlan.encryption.type = NoSave(ConfigSelection(list, default = wsconfig['encryption_type'] ))
181 config.plugins.wlan.encryption.psk = NoSave(ConfigText(default = wsconfig['key'], fixed_size = False,visible_width = 30))
182 #self.ws.loadConfig()
184 self.dhcpConfigEntry = NoSave(ConfigYesNo(default=iNetwork.getAdapterAttribute(self.iface, "dhcp") or False))
185 self.hasGatewayConfigEntry = NoSave(ConfigYesNo(default=True))
186 self.ipConfigEntry = NoSave(ConfigIP(default=iNetwork.getAdapterAttribute(self.iface, "ip")) or [0,0,0,0])
187 self.netmaskConfigEntry = NoSave(ConfigIP(default=iNetwork.getAdapterAttribute(self.iface, "netmask") or [255,0,0,0]))
188 self.gatewayConfigEntry = NoSave(ConfigIP(default=iNetwork.getAdapterAttribute(self.iface, "gateway") or [0,0,0,0]))
189 nameserver = (iNetwork.getNameserverList() + [[0,0,0,0]] * 2)[0:2]
190 self.primaryDNS = NoSave(ConfigIP(default=nameserver[0]))
191 self.secondaryDNS = NoSave(ConfigIP(default=nameserver[1]))
193 self["actions"] = ActionMap(["SetupActions","ShortcutActions"],
196 "cancel": self.cancel,
198 "blue": self.KeyBlue,
202 ConfigListScreen.__init__(self, self.list)
204 self.onLayoutFinish.append(self.layoutFinished)
206 self["DNS1text"] = Label(_("Primary DNS"))
207 self["DNS2text"] = Label(_("Secondary DNS"))
208 self["DNS1"] = Label()
209 self["DNS2"] = Label()
211 self["introduction"] = Label(_("Current settings:"))
213 self["IPtext"] = Label(_("IP Address"))
214 self["Netmasktext"] = Label(_("Netmask"))
215 self["Gatewaytext"] = Label(_("Gateway"))
218 self["Mask"] = Label()
219 self["Gateway"] = Label()
221 self["BottomBG"] = Pixmap()
222 self["Adaptertext"] = Label(_("Network:"))
223 self["Adapter"] = Label()
224 self["introduction2"] = Label(_("Press OK to activate the settings."))
225 self["ButtonRed"] = Pixmap()
226 self["ButtonRedtext"] = Label(_("Close"))
227 self["ButtonBlue"] = Pixmap()
228 self["ButtonBluetext"] = Label(_("Edit DNS"))
230 def layoutFinished(self):
231 self["DNS1"].setText(self.primaryDNS.getText())
232 self["DNS2"].setText(self.secondaryDNS.getText())
233 if self.ipConfigEntry.getText() is not None:
234 self["IP"].setText(self.ipConfigEntry.getText())
236 self["IP"].setText([0,0,0,0])
237 self["Mask"].setText(self.netmaskConfigEntry.getText())
238 self["Gateway"].setText(self.gatewayConfigEntry.getText())
239 self["Adapter"].setText(iNetwork.getFriendlyAdapterName(self.iface))
241 def createSetup(self):
244 self.dhcpEntry = getConfigListEntry(_("Use DHCP"), self.dhcpConfigEntry)
245 self.list.append(self.dhcpEntry)
246 if not self.dhcpConfigEntry.value:
247 self.list.append(getConfigListEntry(_('IP Address'), self.ipConfigEntry))
248 self.list.append(getConfigListEntry(_('Netmask'), self.netmaskConfigEntry))
249 self.list.append(getConfigListEntry(_('Use a gateway'), self.hasGatewayConfigEntry))
250 if self.hasGatewayConfigEntry.value:
251 self.list.append(getConfigListEntry(_('Gateway'), self.gatewayConfigEntry))
254 self.extendedSetup = None
255 for p in plugins.getPlugins(PluginDescriptor.WHERE_NETWORKSETUP):
256 callFnc = p.__call__["ifaceSupported"](self.iface)
257 if callFnc is not None:
258 self.extended = callFnc
260 if p.__call__.has_key("configStrings"):
261 self.configStrings = p.__call__["configStrings"]
263 self.configStrings = None
265 self.list.append(getConfigListEntry(_("Network SSID"), config.plugins.wlan.essid))
266 self.encryptionEnabled = getConfigListEntry(_("Encryption"), config.plugins.wlan.encryption.enabled)
267 self.list.append(self.encryptionEnabled)
269 if config.plugins.wlan.encryption.enabled.value:
270 self.list.append(getConfigListEntry(_("Encryption Type"), config.plugins.wlan.encryption.type))
271 self.list.append(getConfigListEntry(_("Encryption Key"), config.plugins.wlan.encryption.psk))
273 self["config"].list = self.list
274 self["config"].l.setList(self.list)
277 self.session.open(NameserverSetup)
280 print self["config"].getCurrent()
281 if self["config"].getCurrent() == self.dhcpEntry:
285 ConfigListScreen.keyLeft(self)
289 ConfigListScreen.keyRight(self)
293 selection = self["config"].getCurrent()
294 if selection == self.extendedSetup:
295 self.extended(self.session, self.iface)
297 iNetwork.setAdapterAttribute(self.iface, "dhcp", self.dhcpConfigEntry.value)
298 iNetwork.setAdapterAttribute(self.iface, "ip", self.ipConfigEntry.value)
299 iNetwork.setAdapterAttribute(self.iface, "netmask", self.netmaskConfigEntry.value)
300 if self.hasGatewayConfigEntry.value:
301 iNetwork.setAdapterAttribute(self.iface, "gateway", self.gatewayConfigEntry.value)
303 iNetwork.removeAdapterAttribute(self.iface, "gateway")
305 if self.extended is not None and self.configStrings is not None:
306 iNetwork.setAdapterAttribute(self.iface, "configStrings", self.configStrings(self.iface))
307 self.ws.writeConfig()
309 iNetwork.deactivateNetworkConfig()
310 iNetwork.writeNetworkConfig()
311 iNetwork.activateNetworkConfig()
315 iNetwork.getInterfaces()
322 class AdapterSetupConfiguration(Screen):
323 def __init__(self, session,iface):
324 Screen.__init__(self, session)
326 self.session = session
327 self.mainmenu = self.genMainMenu()
328 self["menulist"] = MenuList(self.mainmenu)
329 self["description"] = Label()
330 self["IFtext"] = Label()
332 self["BottomBG"] = Label()
333 self["Statustext"] = Label()
334 self["statuspic"] = MultiPixmap()
335 self["statuspic"].hide()
336 self["BottomBG"] = Pixmap()
337 self["ButtonRed"] = Pixmap()
338 self["ButtonRedtext"] = Label(_("Close"))
340 self.oktext = _("Press OK on your remote control to continue.")
341 self.reboottext = _("Your Dreambox will restart after pressing OK on your remote control.")
342 self.errortext = _("No working wireless interface found.\n Please verify that you have attached a compatible WLAN USB Stick or enable you local network interface.")
344 self["actions"] = NumberActionMap(["WizardActions","ShortcutActions"],
355 iNetwork.getInterfaces()
356 self.onLayoutFinish.append(self.layoutFinished)
357 self.updateStatusbar()
360 if self["menulist"].getCurrent()[1] == 'edit':
361 if self.iface == 'wlan0':
362 from Plugins.SystemPlugins.WirelessLan.iwlibs import Wireless
363 ifobj = Wireless(self.iface) # a Wireless NIC Object
364 self.wlanresponse = ifobj.getStatistics()
365 if self.wlanresponse[0] != 19: # Wlan Interface found.
366 self.session.open(AdapterSetup,self.iface)
368 # Display Wlan not available Message
369 self.showErrorMessage()
371 self.session.open(AdapterSetup,self.iface)
372 if self["menulist"].getCurrent()[1] == 'test':
373 self.session.open(NetworkAdapterTest,self.iface)
374 if self["menulist"].getCurrent()[1] == 'dns':
375 self.session.open(NameserverSetup)
376 if self["menulist"].getCurrent()[1] == 'scanwlan':
377 from Plugins.SystemPlugins.WirelessLan.iwlibs import Wireless
378 ifobj = Wireless(self.iface) # a Wireless NIC Object
379 self.wlanresponse = ifobj.getStatistics()
380 if self.wlanresponse[0] != 19:
381 from Plugins.SystemPlugins.WirelessLan.plugin import WlanScan
382 self.session.openWithCallback(self.WlanScanClosed, WlanScan, self.iface)
384 # Display Wlan not available Message
385 self.showErrorMessage()
386 if self["menulist"].getCurrent()[1] == 'wlanstatus':
387 from Plugins.SystemPlugins.WirelessLan.iwlibs import Wireless
388 ifobj = Wireless(self.iface) # a Wireless NIC Object
389 self.wlanresponse = ifobj.getStatistics()
390 if self.wlanresponse[0] != 19:
391 from Plugins.SystemPlugins.WirelessLan.plugin import WlanStatus
392 self.session.open(WlanStatus,self.iface)
394 # Display Wlan not available Message
395 self.showErrorMessage()
396 if self["menulist"].getCurrent()[1] == 'lanrestart':
397 self.session.openWithCallback(self.restartLan, MessageBox, (_("Are you sure you want to restart your network interfaces?\n\n") + self.oktext ) )
398 if self["menulist"].getCurrent()[1] == 'enablewlan':
399 self.session.openWithCallback(self.enableWlan, MessageBox, _("Are you sure you want to enable WLAN support?\nConnect your Wlan USB Stick to your Dreambox and press OK.\n\n") )
400 if self["menulist"].getCurrent()[1] == 'enablelan':
401 self.session.openWithCallback(self.enableLan, MessageBox, (_("Are you sure you want to enable your local network?\n\n") + self.oktext ) )
402 if self["menulist"].getCurrent()[1] == 'openwizard':
403 from Plugins.SystemPlugins.NetworkWizard.NetworkWizard import NetworkWizard
404 self.session.openWithCallback(self.AdapterSetupClosed, NetworkWizard)
407 self["menulist"].up()
408 self.loadDescription()
411 self["menulist"].down()
412 self.loadDescription()
415 self["menulist"].pageUp()
416 self.loadDescription()
419 self["menulist"].pageDown()
420 self.loadDescription()
422 def layoutFinished(self):
424 self["menulist"].moveToIndex(idx)
425 self.loadDescription()
427 def loadDescription(self):
428 if self["menulist"].getCurrent()[1] == 'edit':
429 self["description"].setText(_("Edit the network configuration of your Dreambox.\n" ) + self.oktext )
430 if self["menulist"].getCurrent()[1] == 'test':
431 self["description"].setText(_("Test the network configuration of your Dreambox.\n" ) + self.oktext )
432 if self["menulist"].getCurrent()[1] == 'enablelan':
433 self["description"].setText(_("Enable the local network of your Dreambox.\n\n" ) + self.oktext )
434 if self["menulist"].getCurrent()[1] == 'dns':
435 self["description"].setText(_("Edit the Nameserver configuration of your Dreambox.\n" ) + self.oktext )
436 if self["menulist"].getCurrent()[1] == 'scanwlan':
437 self["description"].setText(_("Scan your network for wireless Access Points and connect to them using your WLAN USB Stick\n" ) + self.oktext )
438 if self["menulist"].getCurrent()[1] == 'wlanstatus':
439 self["description"].setText(_("Shows the state of your wireless LAN connection.\n" ) + self.oktext )
440 if self["menulist"].getCurrent()[1] == 'lanrestart':
441 self["description"].setText(_("Restart your network connection and interfaces.\n" ) + self.oktext )
442 if self["menulist"].getCurrent()[1] == 'enablewlan':
443 self["description"].setText(_("Pressing OK enables the built in wireless LAN support of your Dreambox.\nWlan USB Sticks with Zydas ZD1211B and RAlink RT73 Chipset are supported.\nConnect your Wlan USB Stick to your Dreambox before pressing OK.\n\n" ) + self.reboottext )
444 if self["menulist"].getCurrent()[1] == 'openwizard':
445 self["description"].setText(_("Use the Networkwizard to configure your Network\n" ) + self.oktext )
447 def updateStatusbar(self):
448 self["IFtext"].setText(_("Network:"))
449 self["IF"].setText(iNetwork.getFriendlyAdapterName(self.iface))
450 self["Statustext"].setText(_("Link:"))
452 if self.iface == 'wlan0':
454 from Plugins.SystemPlugins.WirelessLan.Wlan import Wlan
456 stats = w.getStatus()
457 if stats['BSSID'] == "00:00:00:00:00:00":
458 self["statuspic"].setPixmapNum(1)
460 self["statuspic"].setPixmapNum(0)
461 self["statuspic"].show()
463 self["statuspic"].setPixmapNum(1)
464 self["statuspic"].show()
466 self.getLinkState(self.iface)
471 def genMainMenu(self):
473 menu.append((_("Adapter settings"), "edit"))
474 menu.append((_("Nameserver settings"), "dns"))
475 menu.append((_("Network test"), "test"))
476 menu.append((_("Restart network"), "lanrestart"))
479 self.extendedSetup = None
480 for p in plugins.getPlugins(PluginDescriptor.WHERE_NETWORKSETUP):
481 callFnc = p.__call__["ifaceSupported"](self.iface)
482 if callFnc is not None:
483 menu.append((_("Scan Wireless Networks"), "scanwlan"))
484 menu.append((_("Show WLAN Status"), "wlanstatus"))
485 menu.append((_("Enable LAN"), "enablelan"))
486 if callFnc is None and iNetwork.ifaces.has_key('wlan0') is False:
487 menu.append((_("Enable WLAN"), "enablewlan"))
488 if callFnc is None and iNetwork.ifaces.has_key('wlan0') is True:
489 menu.append((_("Enable LAN"), "enablelan"))
491 if os.path.exists(resolveFilename(SCOPE_PLUGINS, "SystemPlugins/NetworkWizard/networkwizard.xml")):
492 menu.append((_("NetworkWizard"), "openwizard"));
495 def AdapterSetupClosed(self, *ret):
496 self.mainmenu = self.genMainMenu()
497 self["menulist"].l.setList(self.mainmenu)
498 self.updateStatusbar()
500 def WlanScanClosed(self,*ret):
501 if ret[0] is not None:
502 self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetup, 'wlan0',ret[0],ret[1])
504 self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetup, 'wlan0',None,ret[0])
506 def enableWlan(self, ret = False):
508 iNetwork.resetNetworkConfig('wlan')
509 iNetwork.getInterfaces()
510 if iNetwork.getAdapterAttribute('wlan0', 'up') is True:
513 from Plugins.SystemPlugins.WirelessLan.plugin import WlanScan
515 self.session.open(MessageBox, _("The wireless LAN plugin is not installed!\nPlease install it."), type = MessageBox.TYPE_INFO,timeout = 10 )
517 self.session.openWithCallback(self.WlanScanClosed, WlanScan, self.iface)
519 self.session.openWithCallback(self.restartDreambox, MessageBox, _("Your wireless LAN Adapter could not be started.\nDo you want to reboot your Dreambox to apply the new configuration?\n"))
521 def enableLan(self, ret = False):
523 iNetwork.resetNetworkConfig('lan')
524 iNetwork.getInterfaces()
525 if iNetwork.getAdapterAttribute('eth0', 'up') is True:
527 self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetup, 'eth0')
529 self.session.openWithCallback(self.restartDreambox, MessageBox, _("Your wired LAN Adapter could not be started.\nDo you want to reboot your Dreambox to apply the new configuration?\n"))
531 def restartLan(self, ret = False):
533 iNetwork.restartNetwork()
535 def restartDreambox(self, ret = False):
537 TryQuitMainloop(self.session,2)
539 def getLinkState(self,iface):
540 iNetwork.getLinkState(iface,self.dataAvail)
542 def dataAvail(self,data):
543 self.output = data.strip()
544 result = self.output.split('\n')
545 pattern = re.compile("Link detected: yes")
547 if re.search(pattern, item):
548 self["statuspic"].setPixmapNum(0)
550 self["statuspic"].setPixmapNum(1)
551 self["statuspic"].show()
553 def showErrorMessage(self):
554 self.session.open(MessageBox, self.errortext, type = MessageBox.TYPE_INFO,timeout = 10 )
557 class NetworkAdapterTest(Screen):
558 def __init__(self, session,iface):
559 Screen.__init__(self, session)
561 iNetwork.getInterfaces()
564 self["updown_actions"] = NumberActionMap(["WizardActions","ShortcutActions"],
568 "up": lambda: self.updownhandler('up'),
569 "down": lambda: self.updownhandler('down'),
573 self["shortcuts"] = ActionMap(["ShortcutActions","WizardActions"],
578 self["infoshortcuts"] = ActionMap(["ShortcutActions","WizardActions"],
580 "red": self.closeInfo,
581 "back": self.closeInfo,
583 self["shortcutsgreen"] = ActionMap(["ShortcutActions"],
585 "green": self.KeyGreen,
587 self["shortcutsgreen_restart"] = ActionMap(["ShortcutActions"],
589 "green": self.KeyGreenRestart,
591 self["shortcutsyellow"] = ActionMap(["ShortcutActions"],
593 "yellow": self.KeyYellow,
596 self["shortcutsgreen_restart"].setEnabled(False)
597 self["updown_actions"].setEnabled(False)
598 self["infoshortcuts"].setEnabled(False)
599 self.onClose.append(self.delTimer)
600 self.onLayoutFinish.append(self.layoutFinished)
601 self.steptimer = False
603 self.activebutton = 0
604 self.nextStepTimer = eTimer()
605 self.nextStepTimer.callback.append(self.nextStepTimerFire)
608 self["shortcuts"].setEnabled(True)
609 self["infoshortcuts"].setEnabled(False)
610 self["InfoText"].hide()
611 self["InfoTextBorder"].hide()
612 self["ButtonRedtext"].setText(_("Close"))
616 del self.nextStepTimer
618 def nextStepTimerFire(self):
619 self.nextStepTimer.stop()
620 self.steptimer = False
623 def updownhandler(self,direction):
624 if direction == 'up':
625 if self.activebutton >=2:
626 self.activebutton -= 1
628 self.activebutton = 6
629 self.setActiveButton(self.activebutton)
630 if direction == 'down':
631 if self.activebutton <=5:
632 self.activebutton += 1
634 self.activebutton = 1
635 self.setActiveButton(self.activebutton)
637 def setActiveButton(self,button):
639 self["EditSettingsButton"].setPixmapNum(0)
640 self["EditSettings_Text"].setForegroundColorNum(0)
641 self["NetworkInfo"].setPixmapNum(0)
642 self["NetworkInfo_Text"].setForegroundColorNum(1)
643 self["AdapterInfo"].setPixmapNum(1) # active
644 self["AdapterInfo_Text"].setForegroundColorNum(2) # active
646 self["AdapterInfo_Text"].setForegroundColorNum(1)
647 self["AdapterInfo"].setPixmapNum(0)
648 self["DhcpInfo"].setPixmapNum(0)
649 self["DhcpInfo_Text"].setForegroundColorNum(1)
650 self["NetworkInfo"].setPixmapNum(1) # active
651 self["NetworkInfo_Text"].setForegroundColorNum(2) # active
653 self["NetworkInfo"].setPixmapNum(0)
654 self["NetworkInfo_Text"].setForegroundColorNum(1)
655 self["IPInfo"].setPixmapNum(0)
656 self["IPInfo_Text"].setForegroundColorNum(1)
657 self["DhcpInfo"].setPixmapNum(1) # active
658 self["DhcpInfo_Text"].setForegroundColorNum(2) # active
660 self["DhcpInfo"].setPixmapNum(0)
661 self["DhcpInfo_Text"].setForegroundColorNum(1)
662 self["DNSInfo"].setPixmapNum(0)
663 self["DNSInfo_Text"].setForegroundColorNum(1)
664 self["IPInfo"].setPixmapNum(1) # active
665 self["IPInfo_Text"].setForegroundColorNum(2) # active
667 self["IPInfo"].setPixmapNum(0)
668 self["IPInfo_Text"].setForegroundColorNum(1)
669 self["EditSettingsButton"].setPixmapNum(0)
670 self["EditSettings_Text"].setForegroundColorNum(0)
671 self["DNSInfo"].setPixmapNum(1) # active
672 self["DNSInfo_Text"].setForegroundColorNum(2) # active
674 self["DNSInfo"].setPixmapNum(0)
675 self["DNSInfo_Text"].setForegroundColorNum(1)
676 self["EditSettingsButton"].setPixmapNum(1) # active
677 self["EditSettings_Text"].setForegroundColorNum(2) # active
678 self["AdapterInfo"].setPixmapNum(0)
679 self["AdapterInfo_Text"].setForegroundColorNum(1)
698 self.steptimer = True
699 self.nextStepTimer.start(3000)
702 self["Adapter"].setText(iNetwork.getFriendlyAdapterName(self.iface))
703 self["Adapter"].setForegroundColorNum(2)
704 self["Adaptertext"].setForegroundColorNum(1)
705 self["AdapterInfo_Text"].setForegroundColorNum(1)
706 self["AdapterInfo_OK"].show()
707 self.steptimer = True
708 self.nextStepTimer.start(3000)
711 self["Networktext"].setForegroundColorNum(1)
712 self.getLinkState(self.iface)
713 self["NetworkInfo_Text"].setForegroundColorNum(1)
714 self.steptimer = True
715 self.nextStepTimer.start(3000)
718 self["Dhcptext"].setForegroundColorNum(1)
719 if iNetwork.getAdapterAttribute(self.iface, 'dhcp') is True:
720 self["Dhcp"].setForegroundColorNum(2)
721 self["Dhcp"].setText(_("enabled"))
722 self["DhcpInfo_Check"].setPixmapNum(0)
724 self["Dhcp"].setForegroundColorNum(1)
725 self["Dhcp"].setText(_("disabled"))
726 self["DhcpInfo_Check"].setPixmapNum(1)
727 self["DhcpInfo_Check"].show()
728 self["DhcpInfo_Text"].setForegroundColorNum(1)
729 self.steptimer = True
730 self.nextStepTimer.start(3000)
733 self["IPtext"].setForegroundColorNum(1)
734 ret = iNetwork.checkNetworkState()
736 self["IP"].setForegroundColorNum(2)
737 self["IP"].setText(_("confirmed"))
738 self["IPInfo_Check"].setPixmapNum(0)
740 self["IP"].setForegroundColorNum(1)
741 self["IP"].setText(_("unconfirmed"))
742 self["IPInfo_Check"].setPixmapNum(1)
743 self["IPInfo_Check"].show()
744 self["IPInfo_Text"].setForegroundColorNum(1)
745 self.steptimer = True
746 self.nextStepTimer.start(3000)
749 self.steptimer = False
750 self.nextStepTimer.stop()
751 self["DNStext"].setForegroundColorNum(1)
752 ret = iNetwork.checkDNSLookup()
754 self["DNS"].setForegroundColorNum(2)
755 self["DNS"].setText(_("confirmed"))
756 self["DNSInfo_Check"].setPixmapNum(0)
758 self["DNS"].setForegroundColorNum(1)
759 self["DNS"].setText(_("unconfirmed"))
760 self["DNSInfo_Check"].setPixmapNum(1)
761 self["DNSInfo_Check"].show()
762 self["DNSInfo_Text"].setForegroundColorNum(1)
764 self["EditSettings_Text"].show()
765 self["EditSettingsButton"].setPixmapNum(1)
766 self["EditSettings_Text"].setForegroundColorNum(2) # active
767 self["EditSettingsButton"].show()
768 self["ButtonYellow_Check"].setPixmapNum(1)
769 self["ButtonGreentext"].setText(_("Restart test"))
770 self["ButtonGreen_Check"].setPixmapNum(0)
771 self["shortcutsgreen"].setEnabled(False)
772 self["shortcutsgreen_restart"].setEnabled(True)
773 self["shortcutsyellow"].setEnabled(False)
774 self["updown_actions"].setEnabled(True)
775 self.activebutton = 6
778 self["shortcutsgreen"].setEnabled(False)
779 self["shortcutsyellow"].setEnabled(True)
780 self["updown_actions"].setEnabled(False)
781 self["ButtonYellow_Check"].setPixmapNum(0)
782 self["ButtonGreen_Check"].setPixmapNum(1)
783 self.steptimer = True
784 self.nextStepTimer.start(1000)
786 def KeyGreenRestart(self):
788 self.layoutFinished()
789 self["Adapter"].setText((""))
790 self["Network"].setText((""))
791 self["Dhcp"].setText((""))
792 self["IP"].setText((""))
793 self["DNS"].setText((""))
794 self["AdapterInfo_Text"].setForegroundColorNum(0)
795 self["NetworkInfo_Text"].setForegroundColorNum(0)
796 self["DhcpInfo_Text"].setForegroundColorNum(0)
797 self["IPInfo_Text"].setForegroundColorNum(0)
798 self["DNSInfo_Text"].setForegroundColorNum(0)
799 self["shortcutsgreen_restart"].setEnabled(False)
800 self["shortcutsgreen"].setEnabled(False)
801 self["shortcutsyellow"].setEnabled(True)
802 self["updown_actions"].setEnabled(False)
803 self["ButtonYellow_Check"].setPixmapNum(0)
804 self["ButtonGreen_Check"].setPixmapNum(1)
805 self.steptimer = True
806 self.nextStepTimer.start(1000)
809 self["infoshortcuts"].setEnabled(True)
810 self["shortcuts"].setEnabled(False)
811 if self.activebutton == 1: # Adapter Check
812 self["InfoText"].setText(_("This test detects your configured LAN-Adapter."))
813 self["InfoTextBorder"].show()
814 self["InfoText"].show()
815 self["ButtonRedtext"].setText(_("Back"))
816 if self.activebutton == 2: #LAN Check
817 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"))
818 self["InfoTextBorder"].show()
819 self["InfoText"].show()
820 self["ButtonRedtext"].setText(_("Back"))
821 if self.activebutton == 3: #DHCP Check
822 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."))
823 self["InfoTextBorder"].show()
824 self["InfoText"].show()
825 self["ButtonRedtext"].setText(_("Back"))
826 if self.activebutton == 4: # IP Check
827 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"))
828 self["InfoTextBorder"].show()
829 self["InfoText"].show()
830 self["ButtonRedtext"].setText(_("Back"))
831 if self.activebutton == 5: # DNS Check
832 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"))
833 self["InfoTextBorder"].show()
834 self["InfoText"].show()
835 self["ButtonRedtext"].setText(_("Back"))
836 if self.activebutton == 6: # Edit Settings
837 self.session.open(AdapterSetup,self.iface)
841 self["shortcutsgreen_restart"].setEnabled(True)
842 self["shortcutsgreen"].setEnabled(False)
843 self["shortcutsyellow"].setEnabled(False)
844 self["ButtonGreentext"].setText(_("Restart test"))
845 self["ButtonYellow_Check"].setPixmapNum(1)
846 self["ButtonGreen_Check"].setPixmapNum(0)
847 self.steptimer = False
848 self.nextStepTimer.stop()
850 def layoutFinished(self):
851 self["shortcutsyellow"].setEnabled(False)
852 self["AdapterInfo_OK"].hide()
853 self["NetworkInfo_Check"].hide()
854 self["DhcpInfo_Check"].hide()
855 self["IPInfo_Check"].hide()
856 self["DNSInfo_Check"].hide()
857 self["EditSettings_Text"].hide()
858 self["EditSettingsButton"].hide()
859 self["InfoText"].hide()
860 self["InfoTextBorder"].hide()
863 self["Adaptertext"] = MultiColorLabel(_("LAN Adapter"))
864 self["Adapter"] = MultiColorLabel()
865 self["AdapterInfo"] = MultiPixmap()
866 self["AdapterInfo_Text"] = MultiColorLabel(_("Show Info"))
867 self["AdapterInfo_OK"] = Pixmap()
869 if self.iface == 'wlan0':
870 self["Networktext"] = MultiColorLabel(_("Wireless Network"))
872 self["Networktext"] = MultiColorLabel(_("Local Network"))
874 self["Network"] = MultiColorLabel()
875 self["NetworkInfo"] = MultiPixmap()
876 self["NetworkInfo_Text"] = MultiColorLabel(_("Show Info"))
877 self["NetworkInfo_Check"] = MultiPixmap()
879 self["Dhcptext"] = MultiColorLabel(_("DHCP"))
880 self["Dhcp"] = MultiColorLabel()
881 self["DhcpInfo"] = MultiPixmap()
882 self["DhcpInfo_Text"] = MultiColorLabel(_("Show Info"))
883 self["DhcpInfo_Check"] = MultiPixmap()
885 self["IPtext"] = MultiColorLabel(_("IP Address"))
886 self["IP"] = MultiColorLabel()
887 self["IPInfo"] = MultiPixmap()
888 self["IPInfo_Text"] = MultiColorLabel(_("Show Info"))
889 self["IPInfo_Check"] = MultiPixmap()
891 self["DNStext"] = MultiColorLabel(_("Nameserver"))
892 self["DNS"] = MultiColorLabel()
893 self["DNSInfo"] = MultiPixmap()
894 self["DNSInfo_Text"] = MultiColorLabel(_("Show Info"))
895 self["DNSInfo_Check"] = MultiPixmap()
897 self["EditSettings_Text"] = MultiColorLabel(_("Edit settings"))
898 self["EditSettingsButton"] = MultiPixmap()
900 self["ButtonRedtext"] = Label(_("Close"))
901 self["ButtonRed"] = Pixmap()
903 self["ButtonGreentext"] = Label(_("Start test"))
904 self["ButtonGreen_Check"] = MultiPixmap()
906 self["ButtonYellowtext"] = Label(_("Stop test"))
907 self["ButtonYellow_Check"] = MultiPixmap()
909 self["InfoTextBorder"] = Pixmap()
910 self["InfoText"] = Label()
912 def getLinkState(self,iface):
915 from Plugins.SystemPlugins.WirelessLan.Wlan import Wlan
917 stats = w.getStatus()
918 if stats['BSSID'] == "00:00:00:00:00:00":
919 self["Network"].setForegroundColorNum(1)
920 self["Network"].setText(_("disconnected"))
921 self["NetworkInfo_Check"].setPixmapNum(1)
922 self["NetworkInfo_Check"].show()
924 self["Network"].setForegroundColorNum(2)
925 self["Network"].setText(_("connected"))
926 self["NetworkInfo_Check"].setPixmapNum(0)
927 self["NetworkInfo_Check"].show()
929 self["Network"].setForegroundColorNum(1)
930 self["Network"].setText(_("disconnected"))
931 self["NetworkInfo_Check"].setPixmapNum(1)
932 self["NetworkInfo_Check"].show()
934 iNetwork.getLinkState(iface,self.dataAvail)
936 def dataAvail(self,data):
937 self.output = data.strip()
938 result = self.output.split('\n')
939 pattern = re.compile("Link detected: yes")
941 if re.search(pattern, item):
942 self["Network"].setForegroundColorNum(2)
943 self["Network"].setText(_("connected"))
944 self["NetworkInfo_Check"].setPixmapNum(0)
946 self["Network"].setForegroundColorNum(1)
947 self["Network"].setText(_("disconnected"))
948 self["NetworkInfo_Check"].setPixmapNum(1)
949 self["NetworkInfo_Check"].show()