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
9 from Components.Label import Label,MultiColorLabel
10 from Components.Pixmap import Pixmap,MultiPixmap
11 from Components.MenuList import MenuList
12 from Components.config import config, ConfigYesNo, ConfigIP, NoSave, ConfigText, ConfigSelection, getConfigListEntry
13 from Components.PluginComponent import plugins
14 from Plugins.Plugin import PluginDescriptor
15 from enigma import eTimer
16 from os import path as os_path
17 from re import compile as re_compile, search as re_search
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):
46 if len(self.adapters) == 1:
49 def NetworkFallback(self):
50 if iNetwork.configuredInterfaces.has_key('wlan0') is True:
51 self.session.openWithCallback(self.ErrorMessageClosed, MessageBox, self.wlan_errortext, type = MessageBox.TYPE_INFO,timeout = 10)
52 if iNetwork.configuredInterfaces.has_key('ath0') is True:
53 self.session.openWithCallback(self.ErrorMessageClosed, MessageBox, self.wlan_errortext, type = MessageBox.TYPE_INFO,timeout = 10)
55 self.session.openWithCallback(self.ErrorMessageClosed, MessageBox, self.lan_errortext, type = MessageBox.TYPE_INFO,timeout = 10)
57 def ErrorMessageClosed(self, *ret):
58 if iNetwork.configuredInterfaces.has_key('wlan0') is True:
59 self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetupConfiguration, 'wlan0')
60 elif iNetwork.configuredInterfaces.has_key('ath0') is True:
61 self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetupConfiguration, 'ath0')
63 self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetupConfiguration, 'eth0')
65 class NameserverSetup(Screen, ConfigListScreen):
66 def __init__(self, session):
67 Screen.__init__(self, session)
68 iNetwork.getInterfaces()
69 self.backupNameserverList = iNetwork.getNameserverList()[:]
70 print "backup-list:", self.backupNameserverList
72 self["ButtonGreentext"] = Label(_("Add"))
73 self["ButtonYellowtext"] = Label(_("Delete"))
74 self["ButtonRedtext"] = Label(_("Close"))
75 self["introduction"] = Label(_("Press OK to activate the settings."))
78 self["actions"] = ActionMap(["OkCancelActions", "ColorActions"],
81 "cancel": self.cancel,
88 ConfigListScreen.__init__(self, self.list)
91 def createConfig(self):
92 self.nameservers = iNetwork.getNameserverList()
93 self.nameserverEntries = []
95 for nameserver in self.nameservers:
96 self.nameserverEntries.append(NoSave(ConfigIP(default=nameserver)))
98 def createSetup(self):
101 for i in range(len(self.nameserverEntries)):
102 self.list.append(getConfigListEntry(_("Nameserver %d") % (i + 1), self.nameserverEntries[i]))
104 self["config"].list = self.list
105 self["config"].l.setList(self.list)
108 iNetwork.clearNameservers()
109 for nameserver in self.nameserverEntries:
110 iNetwork.addNameserver(nameserver.value)
111 iNetwork.writeNameserverConfig()
115 iNetwork.clearNameservers()
116 print "backup-list:", self.backupNameserverList
117 for nameserver in self.backupNameserverList:
118 iNetwork.addNameserver(nameserver)
122 iNetwork.addNameserver([0,0,0,0])
127 print "currentIndex:", self["config"].getCurrentIndex()
129 index = self["config"].getCurrentIndex()
130 if index < len(self.nameservers):
131 iNetwork.removeNameserver(self.nameservers[index])
135 class AdapterSetup(Screen, ConfigListScreen):
136 def __init__(self, session, iface,essid=None, aplist=None):
137 Screen.__init__(self, session)
138 self.session = session
143 iNetwork.getInterfaces()
145 if self.iface == "wlan0" or self.iface == "ath0" :
146 from Plugins.SystemPlugins.WirelessLan.Wlan import wpaSupplicant,Wlan
147 self.ws = wpaSupplicant()
149 list.append(_("WEP"))
150 list.append(_("WPA"))
151 list.append(_("WPA2"))
152 if self.aplist is not None:
153 self.nwlist = self.aplist
154 self.nwlist.sort(key = lambda x: x[0])
160 self.w = Wlan(self.iface)
161 self.aps = self.w.getNetworkList()
162 if self.aps is not None:
163 print "[Wlan.py] got Accespoints!"
168 a['essid'] = a['bssid']
169 self.nwlist.append( a['essid'])
170 self.nwlist.sort(key = lambda x: x[0])
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))
183 self.activateInterfaceEntry = NoSave(ConfigYesNo(default=iNetwork.getAdapterAttribute(self.iface, "up") or False))
184 self.dhcpConfigEntry = NoSave(ConfigYesNo(default=iNetwork.getAdapterAttribute(self.iface, "dhcp") or False))
185 self.ipConfigEntry = NoSave(ConfigIP(default=iNetwork.getAdapterAttribute(self.iface, "ip")) or [0,0,0,0])
186 self.netmaskConfigEntry = NoSave(ConfigIP(default=iNetwork.getAdapterAttribute(self.iface, "netmask") or [255,0,0,0]))
187 if iNetwork.getAdapterAttribute(self.iface, "gateway"):
188 self.dhcpdefault=True
190 self.dhcpdefault=False
191 self.hasGatewayConfigEntry = NoSave(ConfigYesNo(default=self.dhcpdefault or False))
192 self.gatewayConfigEntry = NoSave(ConfigIP(default=iNetwork.getAdapterAttribute(self.iface, "gateway") or [0,0,0,0]))
193 nameserver = (iNetwork.getNameserverList() + [[0,0,0,0]] * 2)[0:2]
194 self.primaryDNS = NoSave(ConfigIP(default=nameserver[0]))
195 self.secondaryDNS = NoSave(ConfigIP(default=nameserver[1]))
197 self["actions"] = ActionMap(["SetupActions","ShortcutActions"],
200 "cancel": self.cancel,
202 "blue": self.KeyBlue,
206 ConfigListScreen.__init__(self, self.list)
208 self.onLayoutFinish.append(self.layoutFinished)
210 self["DNS1text"] = Label(_("Primary DNS"))
211 self["DNS2text"] = Label(_("Secondary DNS"))
212 self["DNS1"] = Label()
213 self["DNS2"] = Label()
215 self["introduction"] = Label(_("Current settings:"))
217 self["IPtext"] = Label(_("IP Address"))
218 self["Netmasktext"] = Label(_("Netmask"))
219 self["Gatewaytext"] = Label(_("Gateway"))
222 self["Mask"] = Label()
223 self["Gateway"] = Label()
225 self["BottomBG"] = Pixmap()
226 self["Adaptertext"] = Label(_("Network:"))
227 self["Adapter"] = Label()
228 self["introduction2"] = Label(_("Press OK to activate the settings."))
229 self["ButtonRed"] = Pixmap()
230 self["ButtonRedtext"] = Label(_("Close"))
231 self["ButtonBlue"] = Pixmap()
232 self["ButtonBluetext"] = Label(_("Edit DNS"))
234 def layoutFinished(self):
235 self["DNS1"].setText(self.primaryDNS.getText())
236 self["DNS2"].setText(self.secondaryDNS.getText())
237 if self.ipConfigEntry.getText() is not None:
238 self["IP"].setText(self.ipConfigEntry.getText())
240 self["IP"].setText([0,0,0,0])
241 self["Mask"].setText(self.netmaskConfigEntry.getText())
242 if iNetwork.getAdapterAttribute(self.iface, "gateway"):
243 self["Gateway"].setText(self.gatewayConfigEntry.getText())
245 self["Gateway"].hide()
246 self["Gatewaytext"].hide()
247 self["Adapter"].setText(iNetwork.getFriendlyAdapterName(self.iface))
250 def createSetup(self):
252 self.InterfaceEntry = getConfigListEntry(_("Use Interface"), self.activateInterfaceEntry)
253 self.list.append(self.InterfaceEntry)
254 if self.activateInterfaceEntry.value:
255 self.dhcpEntry = getConfigListEntry(_("Use DHCP"), self.dhcpConfigEntry)
256 self.list.append(self.dhcpEntry)
257 if not self.dhcpConfigEntry.value:
258 self.list.append(getConfigListEntry(_('IP Address'), self.ipConfigEntry))
259 self.list.append(getConfigListEntry(_('Netmask'), self.netmaskConfigEntry))
260 self.list.append(getConfigListEntry(_('Use a gateway'), self.hasGatewayConfigEntry))
261 if self.hasGatewayConfigEntry.value:
262 self.list.append(getConfigListEntry(_('Gateway'), self.gatewayConfigEntry))
264 for p in plugins.getPlugins(PluginDescriptor.WHERE_NETWORKSETUP):
265 callFnc = p.__call__["ifaceSupported"](self.iface)
266 if callFnc is not None:
267 self.extended = callFnc
268 if p.__call__.has_key("configStrings"):
269 self.configStrings = p.__call__["configStrings"]
271 self.configStrings = None
273 self.list.append(getConfigListEntry(_("Network SSID"), config.plugins.wlan.essid))
274 self.encryptionEnabled = getConfigListEntry(_("Encryption"), config.plugins.wlan.encryption.enabled)
275 self.list.append(self.encryptionEnabled)
277 if config.plugins.wlan.encryption.enabled.value:
278 self.list.append(getConfigListEntry(_("Encryption Type"), config.plugins.wlan.encryption.type))
279 self.list.append(getConfigListEntry(_("Encryption Key"), config.plugins.wlan.encryption.psk))
281 self["config"].list = self.list
282 self["config"].l.setList(self.list)
285 self.session.openWithCallback(self.NameserverSetupClosed, NameserverSetup)
288 print self["config"].getCurrent()
289 if self["config"].getCurrent() == self.dhcpEntry:
293 ConfigListScreen.keyLeft(self)
297 ConfigListScreen.keyRight(self)
301 iNetwork.setAdapterAttribute(self.iface, "up", self.activateInterfaceEntry.value)
302 if self.activateInterfaceEntry.value is True:
303 iNetwork.setAdapterAttribute(self.iface, "dhcp", self.dhcpConfigEntry.value)
304 iNetwork.setAdapterAttribute(self.iface, "ip", self.ipConfigEntry.value)
305 iNetwork.setAdapterAttribute(self.iface, "netmask", self.netmaskConfigEntry.value)
306 if self.hasGatewayConfigEntry.value:
307 iNetwork.setAdapterAttribute(self.iface, "gateway", self.gatewayConfigEntry.value)
309 iNetwork.removeAdapterAttribute(self.iface, "gateway")
311 if self.extended is not None and self.configStrings is not None:
312 iNetwork.setAdapterAttribute(self.iface, "configStrings", self.configStrings(self.iface))
313 self.ws.writeConfig()
315 iNetwork.removeAdapterAttribute(self.iface, "ip")
316 iNetwork.removeAdapterAttribute(self.iface, "netmask")
317 iNetwork.removeAdapterAttribute(self.iface, "gateway")
318 iNetwork.deactivateInterface(self.iface)
320 iNetwork.deactivateNetworkConfig()
321 iNetwork.writeNetworkConfig()
322 iNetwork.activateNetworkConfig()
326 if self.activateInterfaceEntry.value is False:
327 iNetwork.deactivateInterface(self.iface)
328 iNetwork.getInterfaces()
334 def NameserverSetupClosed(self, *ret):
335 iNetwork.loadNameserverConfig()
336 nameserver = (iNetwork.getNameserverList() + [[0,0,0,0]] * 2)[0:2]
337 self.primaryDNS = NoSave(ConfigIP(default=nameserver[0]))
338 self.secondaryDNS = NoSave(ConfigIP(default=nameserver[1]))
340 self.layoutFinished()
343 class AdapterSetupConfiguration(Screen):
344 def __init__(self, session,iface):
345 Screen.__init__(self, session)
346 self.session = session
348 self.mainmenu = self.genMainMenu()
349 self["menulist"] = MenuList(self.mainmenu)
350 self["description"] = Label()
351 self["IFtext"] = Label()
353 self["BottomBG"] = Label()
354 self["Statustext"] = Label()
355 self["statuspic"] = MultiPixmap()
356 self["statuspic"].hide()
357 self["BottomBG"] = Pixmap()
358 self["ButtonRed"] = Pixmap()
359 self["ButtonRedtext"] = Label(_("Close"))
361 self.oktext = _("Press OK on your remote control to continue.")
362 self.reboottext = _("Your Dreambox will restart after pressing OK on your remote control.")
363 self.errortext = _("No working wireless interface found.\n Please verify that you have attached a compatible WLAN device or enable you local network interface.")
365 self["actions"] = NumberActionMap(["WizardActions","ShortcutActions"],
376 iNetwork.getInterfaces()
377 self.onLayoutFinish.append(self.layoutFinished)
378 self.updateStatusbar()
381 print "SELF.iFACE im OK Klick",self.iface
382 print "self.menulist.getCurrent()[1]",self["menulist"].getCurrent()[1]
383 if self["menulist"].getCurrent()[1] == 'edit':
384 if self.iface == 'wlan0' or self.iface == 'ath0':
386 from Plugins.SystemPlugins.WirelessLan.plugin import WlanScan
387 from Plugins.SystemPlugins.WirelessLan.iwlibs import Wireless
389 self.session.open(MessageBox, _("The wireless LAN plugin is not installed!\nPlease install it."), type = MessageBox.TYPE_INFO,timeout = 10 )
391 ifobj = Wireless(self.iface) # a Wireless NIC Object
392 self.wlanresponse = ifobj.getStatistics()
393 if self.wlanresponse[0] != 19: # Wlan Interface found.
394 self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetup,self.iface)
396 # Display Wlan not available Message
397 self.showErrorMessage()
399 self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetup,self.iface)
400 if self["menulist"].getCurrent()[1] == 'test':
401 self.session.open(NetworkAdapterTest,self.iface)
402 if self["menulist"].getCurrent()[1] == 'dns':
403 self.session.open(NameserverSetup)
404 if self["menulist"].getCurrent()[1] == 'scanwlan':
406 from Plugins.SystemPlugins.WirelessLan.plugin import WlanScan
407 from Plugins.SystemPlugins.WirelessLan.iwlibs import Wireless
409 self.session.open(MessageBox, _("The wireless LAN plugin is not installed!\nPlease install it."), type = MessageBox.TYPE_INFO,timeout = 10 )
411 ifobj = Wireless(self.iface) # a Wireless NIC Object
412 self.wlanresponse = ifobj.getStatistics()
413 if self.wlanresponse[0] != 19:
414 self.session.openWithCallback(self.WlanScanClosed, WlanScan, self.iface)
416 # Display Wlan not available Message
417 self.showErrorMessage()
418 if self["menulist"].getCurrent()[1] == 'wlanstatus':
420 from Plugins.SystemPlugins.WirelessLan.plugin import WlanStatus
421 from Plugins.SystemPlugins.WirelessLan.iwlibs import Wireless
423 self.session.open(MessageBox, _("The wireless LAN plugin is not installed!\nPlease install it."), type = MessageBox.TYPE_INFO,timeout = 10 )
425 ifobj = Wireless(self.iface) # a Wireless NIC Object
426 self.wlanresponse = ifobj.getStatistics()
427 if self.wlanresponse[0] != 19:
428 self.session.open(WlanStatus,self.iface)
430 # Display Wlan not available Message
431 self.showErrorMessage()
432 if self["menulist"].getCurrent()[1] == 'lanrestart':
433 self.session.openWithCallback(self.restartLan, MessageBox, (_("Are you sure you want to restart your network interfaces?\n\n") + self.oktext ) )
434 if self["menulist"].getCurrent()[1] == 'openwizard':
435 from Plugins.SystemPlugins.NetworkWizard.NetworkWizard import NetworkWizard
436 self.session.openWithCallback(self.AdapterSetupClosed, NetworkWizard)
439 self["menulist"].up()
440 self.loadDescription()
443 self["menulist"].down()
444 self.loadDescription()
447 self["menulist"].pageUp()
448 self.loadDescription()
451 self["menulist"].pageDown()
452 self.loadDescription()
454 def layoutFinished(self):
456 self["menulist"].moveToIndex(idx)
457 self.loadDescription()
459 def loadDescription(self):
460 if self["menulist"].getCurrent()[1] == 'edit':
461 self["description"].setText(_("Edit the network configuration of your Dreambox.\n" ) + self.oktext )
462 if self["menulist"].getCurrent()[1] == 'test':
463 self["description"].setText(_("Test the network configuration of your Dreambox.\n" ) + self.oktext )
464 if self["menulist"].getCurrent()[1] == 'dns':
465 self["description"].setText(_("Edit the Nameserver configuration of your Dreambox.\n" ) + self.oktext )
466 if self["menulist"].getCurrent()[1] == 'scanwlan':
467 self["description"].setText(_("Scan your network for wireless Access Points and connect to them using your WLAN USB Stick\n" ) + self.oktext )
468 if self["menulist"].getCurrent()[1] == 'wlanstatus':
469 self["description"].setText(_("Shows the state of your wireless LAN connection.\n" ) + self.oktext )
470 if self["menulist"].getCurrent()[1] == 'lanrestart':
471 self["description"].setText(_("Restart your network connection and interfaces.\n" ) + self.oktext )
472 if self["menulist"].getCurrent()[1] == 'openwizard':
473 self["description"].setText(_("Use the Networkwizard to configure your Network\n" ) + self.oktext )
475 def updateStatusbar(self):
476 self["IFtext"].setText(_("Network:"))
477 self["IF"].setText(iNetwork.getFriendlyAdapterName(self.iface))
478 self["Statustext"].setText(_("Link:"))
480 if self.iface == 'wlan0' or self.iface == 'ath0':
482 from Plugins.SystemPlugins.WirelessLan.Wlan import Wlan
484 stats = w.getStatus()
485 if stats['BSSID'] == "00:00:00:00:00:00":
486 self["statuspic"].setPixmapNum(1)
488 self["statuspic"].setPixmapNum(0)
489 self["statuspic"].show()
491 self["statuspic"].setPixmapNum(1)
492 self["statuspic"].show()
494 self.getLinkState(self.iface)
499 def genMainMenu(self):
501 menu.append((_("Adapter settings"), "edit"))
502 menu.append((_("Nameserver settings"), "dns"))
503 menu.append((_("Network test"), "test"))
504 menu.append((_("Restart network"), "lanrestart"))
506 for p in plugins.getPlugins(PluginDescriptor.WHERE_NETWORKSETUP):
507 callFnc = p.__call__["ifaceSupported"](self.iface)
508 if callFnc is not None:
509 menu.append((_("Scan Wireless Networks"), "scanwlan"))
510 menu.append((_("Show WLAN Status"), "wlanstatus"))
512 if os_path.exists(resolveFilename(SCOPE_PLUGINS, "SystemPlugins/NetworkWizard/networkwizard.xml")):
513 menu.append((_("NetworkWizard"), "openwizard"));
516 def AdapterSetupClosed(self, *ret):
517 self.mainmenu = self.genMainMenu()
518 self["menulist"].l.setList(self.mainmenu)
519 iNetwork.getInterfaces()
520 self.updateStatusbar()
522 def WlanScanClosed(self,*ret):
523 if ret[0] is not None:
524 self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetup, self.iface,ret[0],ret[1])
526 self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetup, self.iface,None,ret[0])
529 def restartLan(self, ret = False):
531 iNetwork.restartNetwork()
533 def getLinkState(self,iface):
534 iNetwork.getLinkState(iface,self.dataAvail)
536 def dataAvail(self,data):
537 self.output = data.strip()
538 result = self.output.split('\n')
539 pattern = re_compile("Link detected: yes")
541 if re_search(pattern, item):
542 self["statuspic"].setPixmapNum(0)
544 self["statuspic"].setPixmapNum(1)
545 self["statuspic"].show()
547 def showErrorMessage(self):
548 self.session.open(MessageBox, self.errortext, type = MessageBox.TYPE_INFO,timeout = 10 )
551 class NetworkAdapterTest(Screen):
552 def __init__(self, session,iface):
553 Screen.__init__(self, session)
555 iNetwork.getInterfaces()
558 self["updown_actions"] = NumberActionMap(["WizardActions","ShortcutActions"],
562 "up": lambda: self.updownhandler('up'),
563 "down": lambda: self.updownhandler('down'),
567 self["shortcuts"] = ActionMap(["ShortcutActions","WizardActions"],
572 self["infoshortcuts"] = ActionMap(["ShortcutActions","WizardActions"],
574 "red": self.closeInfo,
575 "back": self.closeInfo,
577 self["shortcutsgreen"] = ActionMap(["ShortcutActions"],
579 "green": self.KeyGreen,
581 self["shortcutsgreen_restart"] = ActionMap(["ShortcutActions"],
583 "green": self.KeyGreenRestart,
585 self["shortcutsyellow"] = ActionMap(["ShortcutActions"],
587 "yellow": self.KeyYellow,
590 self["shortcutsgreen_restart"].setEnabled(False)
591 self["updown_actions"].setEnabled(False)
592 self["infoshortcuts"].setEnabled(False)
593 self.onClose.append(self.delTimer)
594 self.onLayoutFinish.append(self.layoutFinished)
595 self.steptimer = False
597 self.activebutton = 0
598 self.nextStepTimer = eTimer()
599 self.nextStepTimer.callback.append(self.nextStepTimerFire)
602 self["shortcuts"].setEnabled(True)
603 self["infoshortcuts"].setEnabled(False)
604 self["InfoText"].hide()
605 self["InfoTextBorder"].hide()
606 self["ButtonRedtext"].setText(_("Close"))
610 del self.nextStepTimer
612 def nextStepTimerFire(self):
613 self.nextStepTimer.stop()
614 self.steptimer = False
617 def updownhandler(self,direction):
618 if direction == 'up':
619 if self.activebutton >=2:
620 self.activebutton -= 1
622 self.activebutton = 6
623 self.setActiveButton(self.activebutton)
624 if direction == 'down':
625 if self.activebutton <=5:
626 self.activebutton += 1
628 self.activebutton = 1
629 self.setActiveButton(self.activebutton)
631 def setActiveButton(self,button):
633 self["EditSettingsButton"].setPixmapNum(0)
634 self["EditSettings_Text"].setForegroundColorNum(0)
635 self["NetworkInfo"].setPixmapNum(0)
636 self["NetworkInfo_Text"].setForegroundColorNum(1)
637 self["AdapterInfo"].setPixmapNum(1) # active
638 self["AdapterInfo_Text"].setForegroundColorNum(2) # active
640 self["AdapterInfo_Text"].setForegroundColorNum(1)
641 self["AdapterInfo"].setPixmapNum(0)
642 self["DhcpInfo"].setPixmapNum(0)
643 self["DhcpInfo_Text"].setForegroundColorNum(1)
644 self["NetworkInfo"].setPixmapNum(1) # active
645 self["NetworkInfo_Text"].setForegroundColorNum(2) # active
647 self["NetworkInfo"].setPixmapNum(0)
648 self["NetworkInfo_Text"].setForegroundColorNum(1)
649 self["IPInfo"].setPixmapNum(0)
650 self["IPInfo_Text"].setForegroundColorNum(1)
651 self["DhcpInfo"].setPixmapNum(1) # active
652 self["DhcpInfo_Text"].setForegroundColorNum(2) # active
654 self["DhcpInfo"].setPixmapNum(0)
655 self["DhcpInfo_Text"].setForegroundColorNum(1)
656 self["DNSInfo"].setPixmapNum(0)
657 self["DNSInfo_Text"].setForegroundColorNum(1)
658 self["IPInfo"].setPixmapNum(1) # active
659 self["IPInfo_Text"].setForegroundColorNum(2) # active
661 self["IPInfo"].setPixmapNum(0)
662 self["IPInfo_Text"].setForegroundColorNum(1)
663 self["EditSettingsButton"].setPixmapNum(0)
664 self["EditSettings_Text"].setForegroundColorNum(0)
665 self["DNSInfo"].setPixmapNum(1) # active
666 self["DNSInfo_Text"].setForegroundColorNum(2) # active
668 self["DNSInfo"].setPixmapNum(0)
669 self["DNSInfo_Text"].setForegroundColorNum(1)
670 self["EditSettingsButton"].setPixmapNum(1) # active
671 self["EditSettings_Text"].setForegroundColorNum(2) # active
672 self["AdapterInfo"].setPixmapNum(0)
673 self["AdapterInfo_Text"].setForegroundColorNum(1)
692 self.steptimer = True
693 self.nextStepTimer.start(3000)
696 self["Adapter"].setText(iNetwork.getFriendlyAdapterName(self.iface))
697 self["Adapter"].setForegroundColorNum(2)
698 self["Adaptertext"].setForegroundColorNum(1)
699 self["AdapterInfo_Text"].setForegroundColorNum(1)
700 self["AdapterInfo_OK"].show()
701 self.steptimer = True
702 self.nextStepTimer.start(3000)
705 self["Networktext"].setForegroundColorNum(1)
706 self.getLinkState(self.iface)
707 self["NetworkInfo_Text"].setForegroundColorNum(1)
708 self.steptimer = True
709 self.nextStepTimer.start(3000)
712 self["Dhcptext"].setForegroundColorNum(1)
713 if iNetwork.getAdapterAttribute(self.iface, 'dhcp') is True:
714 self["Dhcp"].setForegroundColorNum(2)
715 self["Dhcp"].setText(_("enabled"))
716 self["DhcpInfo_Check"].setPixmapNum(0)
718 self["Dhcp"].setForegroundColorNum(1)
719 self["Dhcp"].setText(_("disabled"))
720 self["DhcpInfo_Check"].setPixmapNum(1)
721 self["DhcpInfo_Check"].show()
722 self["DhcpInfo_Text"].setForegroundColorNum(1)
723 self.steptimer = True
724 self.nextStepTimer.start(3000)
727 self["IPtext"].setForegroundColorNum(1)
728 ret = iNetwork.checkNetworkState()
730 self["IP"].setForegroundColorNum(2)
731 self["IP"].setText(_("confirmed"))
732 self["IPInfo_Check"].setPixmapNum(0)
734 self["IP"].setForegroundColorNum(1)
735 self["IP"].setText(_("unconfirmed"))
736 self["IPInfo_Check"].setPixmapNum(1)
737 self["IPInfo_Check"].show()
738 self["IPInfo_Text"].setForegroundColorNum(1)
739 self.steptimer = True
740 self.nextStepTimer.start(3000)
743 self.steptimer = False
744 self.nextStepTimer.stop()
745 self["DNStext"].setForegroundColorNum(1)
746 ret = iNetwork.checkDNSLookup()
748 self["DNS"].setForegroundColorNum(2)
749 self["DNS"].setText(_("confirmed"))
750 self["DNSInfo_Check"].setPixmapNum(0)
752 self["DNS"].setForegroundColorNum(1)
753 self["DNS"].setText(_("unconfirmed"))
754 self["DNSInfo_Check"].setPixmapNum(1)
755 self["DNSInfo_Check"].show()
756 self["DNSInfo_Text"].setForegroundColorNum(1)
758 self["EditSettings_Text"].show()
759 self["EditSettingsButton"].setPixmapNum(1)
760 self["EditSettings_Text"].setForegroundColorNum(2) # active
761 self["EditSettingsButton"].show()
762 self["ButtonYellow_Check"].setPixmapNum(1)
763 self["ButtonGreentext"].setText(_("Restart test"))
764 self["ButtonGreen_Check"].setPixmapNum(0)
765 self["shortcutsgreen"].setEnabled(False)
766 self["shortcutsgreen_restart"].setEnabled(True)
767 self["shortcutsyellow"].setEnabled(False)
768 self["updown_actions"].setEnabled(True)
769 self.activebutton = 6
772 self["shortcutsgreen"].setEnabled(False)
773 self["shortcutsyellow"].setEnabled(True)
774 self["updown_actions"].setEnabled(False)
775 self["ButtonYellow_Check"].setPixmapNum(0)
776 self["ButtonGreen_Check"].setPixmapNum(1)
777 self.steptimer = True
778 self.nextStepTimer.start(1000)
780 def KeyGreenRestart(self):
782 self.layoutFinished()
783 self["Adapter"].setText((""))
784 self["Network"].setText((""))
785 self["Dhcp"].setText((""))
786 self["IP"].setText((""))
787 self["DNS"].setText((""))
788 self["AdapterInfo_Text"].setForegroundColorNum(0)
789 self["NetworkInfo_Text"].setForegroundColorNum(0)
790 self["DhcpInfo_Text"].setForegroundColorNum(0)
791 self["IPInfo_Text"].setForegroundColorNum(0)
792 self["DNSInfo_Text"].setForegroundColorNum(0)
793 self["shortcutsgreen_restart"].setEnabled(False)
794 self["shortcutsgreen"].setEnabled(False)
795 self["shortcutsyellow"].setEnabled(True)
796 self["updown_actions"].setEnabled(False)
797 self["ButtonYellow_Check"].setPixmapNum(0)
798 self["ButtonGreen_Check"].setPixmapNum(1)
799 self.steptimer = True
800 self.nextStepTimer.start(1000)
803 self["infoshortcuts"].setEnabled(True)
804 self["shortcuts"].setEnabled(False)
805 if self.activebutton == 1: # Adapter Check
806 self["InfoText"].setText(_("This test detects your configured LAN-Adapter."))
807 self["InfoTextBorder"].show()
808 self["InfoText"].show()
809 self["ButtonRedtext"].setText(_("Back"))
810 if self.activebutton == 2: #LAN Check
811 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"))
812 self["InfoTextBorder"].show()
813 self["InfoText"].show()
814 self["ButtonRedtext"].setText(_("Back"))
815 if self.activebutton == 3: #DHCP Check
816 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."))
817 self["InfoTextBorder"].show()
818 self["InfoText"].show()
819 self["ButtonRedtext"].setText(_("Back"))
820 if self.activebutton == 4: # IP Check
821 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"))
822 self["InfoTextBorder"].show()
823 self["InfoText"].show()
824 self["ButtonRedtext"].setText(_("Back"))
825 if self.activebutton == 5: # DNS Check
826 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"))
827 self["InfoTextBorder"].show()
828 self["InfoText"].show()
829 self["ButtonRedtext"].setText(_("Back"))
830 if self.activebutton == 6: # Edit Settings
831 self.session.open(AdapterSetup,self.iface)
835 self["shortcutsgreen_restart"].setEnabled(True)
836 self["shortcutsgreen"].setEnabled(False)
837 self["shortcutsyellow"].setEnabled(False)
838 self["ButtonGreentext"].setText(_("Restart test"))
839 self["ButtonYellow_Check"].setPixmapNum(1)
840 self["ButtonGreen_Check"].setPixmapNum(0)
841 self.steptimer = False
842 self.nextStepTimer.stop()
844 def layoutFinished(self):
845 self["shortcutsyellow"].setEnabled(False)
846 self["AdapterInfo_OK"].hide()
847 self["NetworkInfo_Check"].hide()
848 self["DhcpInfo_Check"].hide()
849 self["IPInfo_Check"].hide()
850 self["DNSInfo_Check"].hide()
851 self["EditSettings_Text"].hide()
852 self["EditSettingsButton"].hide()
853 self["InfoText"].hide()
854 self["InfoTextBorder"].hide()
857 self["Adaptertext"] = MultiColorLabel(_("LAN Adapter"))
858 self["Adapter"] = MultiColorLabel()
859 self["AdapterInfo"] = MultiPixmap()
860 self["AdapterInfo_Text"] = MultiColorLabel(_("Show Info"))
861 self["AdapterInfo_OK"] = Pixmap()
863 if self.iface == 'wlan0' or self.iface == 'ath0':
864 self["Networktext"] = MultiColorLabel(_("Wireless Network"))
866 self["Networktext"] = MultiColorLabel(_("Local Network"))
868 self["Network"] = MultiColorLabel()
869 self["NetworkInfo"] = MultiPixmap()
870 self["NetworkInfo_Text"] = MultiColorLabel(_("Show Info"))
871 self["NetworkInfo_Check"] = MultiPixmap()
873 self["Dhcptext"] = MultiColorLabel(_("DHCP"))
874 self["Dhcp"] = MultiColorLabel()
875 self["DhcpInfo"] = MultiPixmap()
876 self["DhcpInfo_Text"] = MultiColorLabel(_("Show Info"))
877 self["DhcpInfo_Check"] = MultiPixmap()
879 self["IPtext"] = MultiColorLabel(_("IP Address"))
880 self["IP"] = MultiColorLabel()
881 self["IPInfo"] = MultiPixmap()
882 self["IPInfo_Text"] = MultiColorLabel(_("Show Info"))
883 self["IPInfo_Check"] = MultiPixmap()
885 self["DNStext"] = MultiColorLabel(_("Nameserver"))
886 self["DNS"] = MultiColorLabel()
887 self["DNSInfo"] = MultiPixmap()
888 self["DNSInfo_Text"] = MultiColorLabel(_("Show Info"))
889 self["DNSInfo_Check"] = MultiPixmap()
891 self["EditSettings_Text"] = MultiColorLabel(_("Edit settings"))
892 self["EditSettingsButton"] = MultiPixmap()
894 self["ButtonRedtext"] = Label(_("Close"))
895 self["ButtonRed"] = Pixmap()
897 self["ButtonGreentext"] = Label(_("Start test"))
898 self["ButtonGreen_Check"] = MultiPixmap()
900 self["ButtonYellowtext"] = Label(_("Stop test"))
901 self["ButtonYellow_Check"] = MultiPixmap()
903 self["InfoTextBorder"] = Pixmap()
904 self["InfoText"] = Label()
906 def getLinkState(self,iface):
907 if iface == 'wlan0' or iface == 'ath0':
909 from Plugins.SystemPlugins.WirelessLan.Wlan import Wlan
911 stats = w.getStatus()
912 if stats['BSSID'] == "00:00:00:00:00:00":
913 self["Network"].setForegroundColorNum(1)
914 self["Network"].setText(_("disconnected"))
915 self["NetworkInfo_Check"].setPixmapNum(1)
916 self["NetworkInfo_Check"].show()
918 self["Network"].setForegroundColorNum(2)
919 self["Network"].setText(_("connected"))
920 self["NetworkInfo_Check"].setPixmapNum(0)
921 self["NetworkInfo_Check"].show()
923 self["Network"].setForegroundColorNum(1)
924 self["Network"].setText(_("disconnected"))
925 self["NetworkInfo_Check"].setPixmapNum(1)
926 self["NetworkInfo_Check"].show()
928 iNetwork.getLinkState(iface,self.dataAvail)
930 def dataAvail(self,data):
931 self.output = data.strip()
932 result = self.output.split('\n')
933 pattern = re_compile("Link detected: yes")
935 if re_search(pattern, item):
936 self["Network"].setForegroundColorNum(2)
937 self["Network"].setText(_("connected"))
938 self["NetworkInfo_Check"].setPixmapNum(0)
940 self["Network"].setForegroundColorNum(1)
941 self["Network"].setText(_("disconnected"))
942 self["NetworkInfo_Check"].setPixmapNum(1)
943 self["NetworkInfo_Check"].show()