fixes
[enigma2.git] / lib / python / Screens / NetworkSetup.py
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.Network import iNetwork
6 from Components.Label import Label,MultiColorLabel
7 from Components.Pixmap import Pixmap,MultiPixmap
8 from Components.MenuList import MenuList
9 from Components.config import config, ConfigYesNo, ConfigIP, NoSave, ConfigText, ConfigSelection, getConfigListEntry
10 from Components.ConfigList import ConfigListScreen
11 from Components.PluginComponent import plugins
12 from Components.MultiContent import MultiContentEntryText, MultiContentEntryPixmapAlphaTest
13 from Plugins.Plugin import PluginDescriptor
14 from enigma import eTimer
15 from os import path as os_path, system as os_system, unlink
16 from re import compile as re_compile, search as re_search
17 from Tools.Directories import resolveFilename, SCOPE_PLUGINS
18
19 from Tools.Directories import SCOPE_SKIN_IMAGE,SCOPE_PLUGINS, resolveFilename
20 from Tools.LoadPixmap import LoadPixmap
21 from enigma import RT_HALIGN_LEFT, eListboxPythonMultiContent, gFont
22
23 class InterfaceList(MenuList):
24         def __init__(self, list, enableWrapAround=False):
25                 MenuList.__init__(self, list, enableWrapAround, eListboxPythonMultiContent)
26                 self.l.setFont(0, gFont("Regular", 20))
27                 self.l.setItemHeight(30)
28
29 def InterfaceEntryComponent(index,name,default,active ):
30         res = [ (index) ]
31         res.append(MultiContentEntryText(pos=(80, 5), size=(430, 25), font=0, text=name))
32         if default is True:
33                 png = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/buttons/button_blue.png"))
34         if default is False:
35                 png = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/buttons/button_blue_off.png"))
36         res.append(MultiContentEntryPixmapAlphaTest(pos=(10, 5), size=(25, 25), png = png))
37         if active is True:
38                 png2 = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/icons/lock_on.png"))
39         if active is False:
40                 png2 = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/icons/lock_error.png"))
41         res.append(MultiContentEntryPixmapAlphaTest(pos=(40, 1), size=(25, 25), png = png2))
42         return res
43
44
45 class NetworkAdapterSelection(Screen):
46         def __init__(self, session):
47                 Screen.__init__(self, session)
48
49                 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.")
50                 self.lan_errortext = _("No working local networkadapter found.\nPlease verify that you have attached a network cable and your Network is configured correctly.")
51                 
52                 self["ButtonBluetext"] = Label(_("Set as default Interface"))
53                 self["ButtonRedtext"] = Label(_("Close"))
54                 self["introduction"] = Label(_("Press OK to edit the settings."))
55                 
56                 self.adapters = [(iNetwork.getFriendlyAdapterName(x),x) for x in iNetwork.getAdapterList()]
57
58                 if len(self.adapters) == 0:
59                         self.onFirstExecBegin.append(self.NetworkFallback)
60
61                 self.list = []
62                 self["list"] = InterfaceList(self.list)
63                 self.updateList()
64                 self["actions"] = ActionMap(["OkCancelActions", "ColorActions"],
65                 {
66                         "ok": self.okbuttonClick,
67                         "cancel": self.close,
68                         "blue": self.setDefaultInterface,                       
69                         "red": self.close
70                 }, -2)
71
72                 if len(self.adapters) == 1:
73                         self.onFirstExecBegin.append(self.okbuttonClick)
74
75         def updateList(self):
76                 print "update list"
77                 iNetwork.getInterfaces()
78                 self.list = []
79                 default_gw = None
80                 num_configured_if = len(iNetwork.configuredInterfaces)
81                 print "num_configured_if :",num_configured_if 
82                 if num_configured_if < 2 and os_path.exists("/etc/default_gw"):
83                         unlink("/etc/default_gw")
84                         
85                 if os_path.exists("/etc/default_gw"):
86                         fp = file('/etc/default_gw', 'r')
87                         result = fp.read()
88                         fp.close()
89                         default_gw = result
90
91                 if len(self.adapters) == 0: # no interface available => display only eth0
92                         self.list.append(InterfaceEntryComponent("eth0",iNetwork.getFriendlyAdapterName('eth0'),True,True ))
93                 else:
94                         for x in self.adapters:
95                                 if x[1] == default_gw:
96                                         default_int = True
97                                 else:
98                                         default_int = False
99                                 if iNetwork.getAdapterAttribute(x[1], 'up') is True:
100                                         active_int = True
101                                 else:
102                                         active_int = False
103                                 self.list.append(InterfaceEntryComponent(index = x[1],name = _(x[0]),default=default_int,active=active_int ))
104                 self["list"].l.setList(self.list)
105
106         def setDefaultInterface(self):
107                 selection = self["list"].getCurrent()
108                 num_if = len(self.list)
109                 old_default_gw = None
110                 if os_path.exists("/etc/default_gw"):
111                         fp = open('/etc/default_gw', 'r')
112                         old_default_gw = fp.read()
113                         fp.close()
114                 if num_if > 1 and (not old_default_gw or old_default_gw != selection[0]):
115                         fp = open('/etc/default_gw', 'w+')
116                         fp.write(selection[0])
117                         fp.close()
118                         iNetwork.restartNetwork()
119                         self.updateList()
120                 elif old_default_gw and num_if < 2:
121                         unlink("/etc/default_gw")
122                         iNetwork.restartNetwork()
123                         self.updateList()
124
125         def okbuttonClick(self):
126                 selection = self["list"].getCurrent()
127                 print "selection",selection
128                 if selection is not None:
129                         self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetupConfiguration, selection[0])
130
131         def AdapterSetupClosed(self, *ret):
132                 if len(self.adapters) == 1:
133                         self.close()
134                 else:
135                         self.updateList()
136
137         def NetworkFallback(self):
138                 if iNetwork.configuredInterfaces.has_key('wlan0') is True:
139                         self.session.openWithCallback(self.ErrorMessageClosed, MessageBox, self.wlan_errortext, type = MessageBox.TYPE_INFO,timeout = 10)
140                 if iNetwork.configuredInterfaces.has_key('ath0') is True:
141                         self.session.openWithCallback(self.ErrorMessageClosed, MessageBox, self.wlan_errortext, type = MessageBox.TYPE_INFO,timeout = 10)
142                 else:
143                         self.session.openWithCallback(self.ErrorMessageClosed, MessageBox, self.lan_errortext, type = MessageBox.TYPE_INFO,timeout = 10)
144
145         def ErrorMessageClosed(self, *ret):
146                 if iNetwork.configuredInterfaces.has_key('wlan0') is True:
147                         self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetupConfiguration, 'wlan0')
148                 elif iNetwork.configuredInterfaces.has_key('ath0') is True:
149                         self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetupConfiguration, 'ath0')
150                 else:
151                         self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetupConfiguration, 'eth0')
152
153 class NameserverSetup(Screen, ConfigListScreen):
154         def __init__(self, session):
155                 Screen.__init__(self, session)
156                 iNetwork.getInterfaces()
157                 self.backupNameserverList = iNetwork.getNameserverList()[:]
158                 print "backup-list:", self.backupNameserverList
159                 
160                 self["ButtonGreentext"] = Label(_("Add"))
161                 self["ButtonYellowtext"] = Label(_("Delete"))
162                 self["ButtonRedtext"] = Label(_("Close"))
163                 self["introduction"] = Label(_("Press OK to activate the settings."))
164                 self.createConfig()
165                 
166                 self["actions"] = ActionMap(["OkCancelActions", "ColorActions"],
167                 {
168                         "ok": self.ok,
169                         "cancel": self.cancel,
170                         "red": self.cancel,
171                         "green": self.add,
172                         "yellow": self.remove
173                 }, -2)
174                 
175                 self.list = []
176                 ConfigListScreen.__init__(self, self.list)
177                 self.createSetup()
178
179         def createConfig(self):
180                 self.nameservers = iNetwork.getNameserverList()
181                 self.nameserverEntries = []
182                 
183                 for nameserver in self.nameservers:
184                         self.nameserverEntries.append(NoSave(ConfigIP(default=nameserver)))
185
186         def createSetup(self):
187                 self.list = []
188                 
189                 for i in range(len(self.nameserverEntries)):
190                         self.list.append(getConfigListEntry(_("Nameserver %d") % (i + 1), self.nameserverEntries[i]))
191                 
192                 self["config"].list = self.list
193                 self["config"].l.setList(self.list)
194
195         def ok(self):
196                 iNetwork.clearNameservers()
197                 for nameserver in self.nameserverEntries:
198                         iNetwork.addNameserver(nameserver.value)
199                 iNetwork.writeNameserverConfig()
200                 self.close()
201
202         def run(self):
203                 self.ok()
204
205         def cancel(self):
206                 iNetwork.clearNameservers()
207                 print "backup-list:", self.backupNameserverList
208                 for nameserver in self.backupNameserverList:
209                         iNetwork.addNameserver(nameserver)
210                 self.close()
211
212         def add(self):
213                 iNetwork.addNameserver([0,0,0,0])
214                 self.createConfig()
215                 self.createSetup()
216
217         def remove(self):
218                 print "currentIndex:", self["config"].getCurrentIndex()
219                 
220                 index = self["config"].getCurrentIndex()
221                 if index < len(self.nameservers):
222                         iNetwork.removeNameserver(self.nameservers[index])
223                         self.createConfig()
224                         self.createSetup()
225         
226 class AdapterSetup(Screen, ConfigListScreen):
227         def __init__(self, session, iface,essid=None, aplist=None):
228                 Screen.__init__(self, session)
229                 self.session = session
230                 self.iface = iface
231                 self.essid = essid
232                 self.aplist = aplist
233                 self.extended = None
234                 iNetwork.getInterfaces()
235
236                 if self.iface == "wlan0" or self.iface == "ath0" :
237                         from Plugins.SystemPlugins.WirelessLan.Wlan import wpaSupplicant,Wlan
238                         self.ws = wpaSupplicant()
239                         list = []
240                         list.append(_("WEP"))
241                         list.append(_("WPA"))
242                         list.append(_("WPA2"))
243                         if self.aplist is not None:
244                                 self.nwlist = self.aplist
245                                 self.nwlist.sort(key = lambda x: x[0])
246                         else:
247                                 self.nwlist = []
248                                 self.w = None
249                                 self.aps = None
250                                 try:
251                                         self.w = Wlan(self.iface)
252                                         self.aps = self.w.getNetworkList()
253                                         if self.aps is not None:
254                                                 print "[Wlan.py] got Accespoints!"
255                                                 for ap in aps:
256                                                         a = aps[ap]
257                                                         if a['active']:
258                                                                 if a['essid'] == "":
259                                                                         a['essid'] = a['bssid']
260                                                                 self.nwlist.append( a['essid'])
261                                         self.nwlist.sort(key = lambda x: x[0])
262                                 except:
263                                         self.nwlist.append("No Networks found")
264
265                         wsconfig = self.ws.loadConfig()
266                         default = self.essid or wsconfig['ssid']
267                         if default not in self.nwlist:
268                                 self.nwlist.append(default)
269                         config.plugins.wlan.essid = NoSave(ConfigSelection(self.nwlist, default = default ))
270                         config.plugins.wlan.encryption.enabled = NoSave(ConfigYesNo(default = wsconfig['encryption'] ))
271                         config.plugins.wlan.encryption.type = NoSave(ConfigSelection(list, default = wsconfig['encryption_type'] ))
272                         config.plugins.wlan.encryption.psk = NoSave(ConfigText(default = wsconfig['key'], fixed_size = False,visible_width = 30))
273                 
274                 self.activateInterfaceEntry = NoSave(ConfigYesNo(default=iNetwork.getAdapterAttribute(self.iface, "up") or False))
275                 self.dhcpConfigEntry = NoSave(ConfigYesNo(default=iNetwork.getAdapterAttribute(self.iface, "dhcp") or False))
276                 self.ipConfigEntry = NoSave(ConfigIP(default=iNetwork.getAdapterAttribute(self.iface, "ip")) or [0,0,0,0])
277                 self.netmaskConfigEntry = NoSave(ConfigIP(default=iNetwork.getAdapterAttribute(self.iface, "netmask") or [255,0,0,0]))
278                 if iNetwork.getAdapterAttribute(self.iface, "gateway"):
279                         self.dhcpdefault=True
280                 else:
281                         self.dhcpdefault=False
282                 self.hasGatewayConfigEntry = NoSave(ConfigYesNo(default=self.dhcpdefault or False))
283                 self.gatewayConfigEntry = NoSave(ConfigIP(default=iNetwork.getAdapterAttribute(self.iface, "gateway") or [0,0,0,0]))
284                 nameserver = (iNetwork.getNameserverList() + [[0,0,0,0]] * 2)[0:2]
285                 self.primaryDNS = NoSave(ConfigIP(default=nameserver[0]))
286                 self.secondaryDNS = NoSave(ConfigIP(default=nameserver[1]))
287                 
288                 self["actions"] = ActionMap(["SetupActions","ShortcutActions"],
289                 {
290                         "ok": self.ok,
291                         "cancel": self.cancel,
292                         "red": self.cancel,
293                         "blue": self.KeyBlue,
294                 }, -2)
295                 
296                 self.list = []
297                 ConfigListScreen.__init__(self, self.list)
298                 self.createSetup()
299                 self.onLayoutFinish.append(self.layoutFinished)
300                 
301                 self["DNS1text"] = Label(_("Primary DNS"))
302                 self["DNS2text"] = Label(_("Secondary DNS"))
303                 self["DNS1"] = Label()
304                 self["DNS2"] = Label()
305                 
306                 self["introduction"] = Label(_("Current settings:"))
307                 
308                 self["IPtext"] = Label(_("IP Address"))
309                 self["Netmasktext"] = Label(_("Netmask"))
310                 self["Gatewaytext"] = Label(_("Gateway"))
311                 
312                 self["IP"] = Label()
313                 self["Mask"] = Label()
314                 self["Gateway"] = Label()
315                 
316                 self["BottomBG"] = Pixmap()
317                 self["Adaptertext"] = Label(_("Network:"))
318                 self["Adapter"] = Label()
319                 self["introduction2"] = Label(_("Press OK to activate the settings."))
320                 self["ButtonRed"] = Pixmap()
321                 self["ButtonRedtext"] = Label(_("Close"))
322                 self["ButtonBlue"] = Pixmap()
323                 self["ButtonBluetext"] = Label(_("Edit DNS"))
324
325         def layoutFinished(self):
326                 self["DNS1"].setText(self.primaryDNS.getText())
327                 self["DNS2"].setText(self.secondaryDNS.getText())
328                 if self.ipConfigEntry.getText() is not None:
329                         self["IP"].setText(self.ipConfigEntry.getText())
330                 else:
331                         self["IP"].setText([0,0,0,0])
332                 self["Mask"].setText(self.netmaskConfigEntry.getText())
333                 if iNetwork.getAdapterAttribute(self.iface, "gateway"):
334                         self["Gateway"].setText(self.gatewayConfigEntry.getText())
335                 else:
336                         self["Gateway"].hide()
337                         self["Gatewaytext"].hide()
338                 self["Adapter"].setText(iNetwork.getFriendlyAdapterName(self.iface))
339
340
341         def createSetup(self):
342                 self.list = []
343                 self.InterfaceEntry = getConfigListEntry(_("Use Interface"), self.activateInterfaceEntry)
344                 self.list.append(self.InterfaceEntry)
345                 if self.activateInterfaceEntry.value:
346                         self.dhcpEntry = getConfigListEntry(_("Use DHCP"), self.dhcpConfigEntry)
347                         self.list.append(self.dhcpEntry)
348                         if not self.dhcpConfigEntry.value:
349                                 self.list.append(getConfigListEntry(_('IP Address'), self.ipConfigEntry))
350                                 self.list.append(getConfigListEntry(_('Netmask'), self.netmaskConfigEntry))
351                                 self.list.append(getConfigListEntry(_('Use a gateway'), self.hasGatewayConfigEntry))
352                                 if self.hasGatewayConfigEntry.value:
353                                         self.list.append(getConfigListEntry(_('Gateway'), self.gatewayConfigEntry))
354                                         
355                         for p in plugins.getPlugins(PluginDescriptor.WHERE_NETWORKSETUP):
356                                 callFnc = p.__call__["ifaceSupported"](self.iface)
357                                 if callFnc is not None:
358                                         self.extended = callFnc
359                                         if p.__call__.has_key("configStrings"):
360                                                 self.configStrings = p.__call__["configStrings"]
361                                         else:
362                                                 self.configStrings = None
363                                                 
364                                         self.list.append(getConfigListEntry(_("Network SSID"), config.plugins.wlan.essid))
365                                         self.encryptionEnabled = getConfigListEntry(_("Encryption"), config.plugins.wlan.encryption.enabled)
366                                         self.list.append(self.encryptionEnabled)
367                                         
368                                         if config.plugins.wlan.encryption.enabled.value:
369                                                 self.list.append(getConfigListEntry(_("Encryption Type"), config.plugins.wlan.encryption.type))
370                                                 self.list.append(getConfigListEntry(_("Encryption Key"), config.plugins.wlan.encryption.psk))
371                 
372                 self["config"].list = self.list
373                 self["config"].l.setList(self.list)
374
375         def KeyBlue(self):
376                 self.session.openWithCallback(self.NameserverSetupClosed, NameserverSetup)
377
378         def newConfig(self):
379                 print self["config"].getCurrent()
380                 if self["config"].getCurrent() == self.dhcpEntry:
381                         self.createSetup()
382
383         def keyLeft(self):
384                 ConfigListScreen.keyLeft(self)
385                 self.createSetup()
386
387         def keyRight(self):
388                 ConfigListScreen.keyRight(self)
389                 self.createSetup()
390
391         def ok(self):
392                 iNetwork.setAdapterAttribute(self.iface, "up", self.activateInterfaceEntry.value)
393                 #if self.activateInterfaceEntry.value is True:
394                 iNetwork.setAdapterAttribute(self.iface, "dhcp", self.dhcpConfigEntry.value)
395                 iNetwork.setAdapterAttribute(self.iface, "ip", self.ipConfigEntry.value)
396                 iNetwork.setAdapterAttribute(self.iface, "netmask", self.netmaskConfigEntry.value)
397                 if self.hasGatewayConfigEntry.value:
398                         iNetwork.setAdapterAttribute(self.iface, "gateway", self.gatewayConfigEntry.value)
399                 else:
400                         iNetwork.removeAdapterAttribute(self.iface, "gateway")
401                 if self.extended is not None and self.configStrings is not None:
402                         iNetwork.setAdapterAttribute(self.iface, "configStrings", self.configStrings(self.iface))
403                         self.ws.writeConfig()
404                 #else:
405                 #       iNetwork.removeAdapterAttribute(self.iface, "ip")
406                 #       iNetwork.removeAdapterAttribute(self.iface, "netmask")
407                 #       iNetwork.removeAdapterAttribute(self.iface, "gateway")
408                 #       iNetwork.deactivateInterface(self.iface)
409                 if self.activateInterfaceEntry.value is False:
410                         iNetwork.deactivateInterface(self.iface)
411                 iNetwork.deactivateNetworkConfig()
412                 iNetwork.writeNetworkConfig()
413                 iNetwork.activateNetworkConfig()
414                 self.close()
415
416         def cancel(self):
417                 if self.activateInterfaceEntry.value is False:
418                         iNetwork.deactivateInterface(self.iface)
419                 iNetwork.getInterfaces()
420                 self.close()
421
422         def run(self):
423                 self.ok()
424
425         def NameserverSetupClosed(self, *ret):
426                 iNetwork.loadNameserverConfig()
427                 nameserver = (iNetwork.getNameserverList() + [[0,0,0,0]] * 2)[0:2]
428                 self.primaryDNS = NoSave(ConfigIP(default=nameserver[0]))
429                 self.secondaryDNS = NoSave(ConfigIP(default=nameserver[1]))
430                 self.createSetup()
431                 self.layoutFinished()
432         
433
434 class AdapterSetupConfiguration(Screen):
435         def __init__(self, session,iface):
436                 Screen.__init__(self, session)
437                 self.session = session
438                 self.iface = iface
439                 self.mainmenu = self.genMainMenu()
440                 self["menulist"] = MenuList(self.mainmenu)
441                 self["description"] = Label()
442                 self["IFtext"] = Label()
443                 self["IF"] = Label()
444                 self["BottomBG"] = Label()
445                 self["Statustext"] = Label()
446                 self["statuspic"] = MultiPixmap()
447                 self["statuspic"].hide()
448                 self["BottomBG"] = Pixmap()
449                 self["ButtonRed"] = Pixmap()
450                 self["ButtonRedtext"] = Label(_("Close"))
451                 
452                 self.oktext = _("Press OK on your remote control to continue.")
453                 self.reboottext = _("Your Dreambox will restart after pressing OK on your remote control.")
454                 self.errortext = _("No working wireless interface found.\n Please verify that you have attached a compatible WLAN device or enable you local network interface.")       
455                 
456                 self["actions"] = NumberActionMap(["WizardActions","ShortcutActions"],
457                 {
458                         "ok": self.ok,
459                         "back": self.close,
460                         "up": self.up,
461                         "down": self.down,
462                         "red": self.close,
463                         "left": self.left,
464                         "right": self.right,
465                 }, -2)
466                 
467                 iNetwork.getInterfaces()
468                 self.onLayoutFinish.append(self.layoutFinished)
469                 self.updateStatusbar()
470
471         def ok(self):
472                 print "SELF.iFACE im OK Klick",self.iface
473                 print "self.menulist.getCurrent()[1]",self["menulist"].getCurrent()[1]
474                 if self["menulist"].getCurrent()[1] == 'edit':
475                         if self.iface == 'wlan0' or self.iface == 'ath0':
476                                 try:
477                                         from Plugins.SystemPlugins.WirelessLan.plugin import WlanScan
478                                         from Plugins.SystemPlugins.WirelessLan.iwlibs import Wireless
479                                 except ImportError:
480                                         self.session.open(MessageBox, _("The wireless LAN plugin is not installed!\nPlease install it."), type = MessageBox.TYPE_INFO,timeout = 10 )
481                                 else:
482                                         ifobj = Wireless(self.iface) # a Wireless NIC Object
483                                         self.wlanresponse = ifobj.getStatistics()
484                                         if self.wlanresponse[0] != 19: # Wlan Interface found.
485                                                 self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetup,self.iface)
486                                         else:
487                                                 # Display Wlan not available Message
488                                                 self.showErrorMessage()
489                         else:
490                                 self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetup,self.iface)
491                 if self["menulist"].getCurrent()[1] == 'test':
492                         self.session.open(NetworkAdapterTest,self.iface)
493                 if self["menulist"].getCurrent()[1] == 'dns':
494                         self.session.open(NameserverSetup)
495                 if self["menulist"].getCurrent()[1] == 'scanwlan':
496                         try:
497                                 from Plugins.SystemPlugins.WirelessLan.plugin import WlanScan
498                                 from Plugins.SystemPlugins.WirelessLan.iwlibs import Wireless
499                         except ImportError:
500                                 self.session.open(MessageBox, _("The wireless LAN plugin is not installed!\nPlease install it."), type = MessageBox.TYPE_INFO,timeout = 10 )
501                         else:
502                                 ifobj = Wireless(self.iface) # a Wireless NIC Object
503                                 self.wlanresponse = ifobj.getStatistics()
504                                 if self.wlanresponse[0] != 19:
505                                         self.session.openWithCallback(self.WlanScanClosed, WlanScan, self.iface)
506                                 else:
507                                         # Display Wlan not available Message
508                                         self.showErrorMessage()
509                 if self["menulist"].getCurrent()[1] == 'wlanstatus':
510                         try:
511                                 from Plugins.SystemPlugins.WirelessLan.plugin import WlanStatus
512                                 from Plugins.SystemPlugins.WirelessLan.iwlibs import Wireless
513                         except ImportError:
514                                 self.session.open(MessageBox, _("The wireless LAN plugin is not installed!\nPlease install it."), type = MessageBox.TYPE_INFO,timeout = 10 )
515                         else:   
516                                 ifobj = Wireless(self.iface) # a Wireless NIC Object
517                                 self.wlanresponse = ifobj.getStatistics()
518                                 if self.wlanresponse[0] != 19:
519                                         self.session.open(WlanStatus,self.iface)
520                                 else:
521                                         # Display Wlan not available Message
522                                         self.showErrorMessage()
523                 if self["menulist"].getCurrent()[1] == 'lanrestart':
524                         self.session.openWithCallback(self.restartLan, MessageBox, (_("Are you sure you want to restart your network interfaces?\n\n") + self.oktext ) )
525                 if self["menulist"].getCurrent()[1] == 'openwizard':
526                         from Plugins.SystemPlugins.NetworkWizard.NetworkWizard import NetworkWizard
527                         self.session.openWithCallback(self.AdapterSetupClosed, NetworkWizard)
528         
529         def up(self):
530                 self["menulist"].up()
531                 self.loadDescription()
532
533         def down(self):
534                 self["menulist"].down()
535                 self.loadDescription()
536
537         def left(self):
538                 self["menulist"].pageUp()
539                 self.loadDescription()
540
541         def right(self):
542                 self["menulist"].pageDown()
543                 self.loadDescription()
544
545         def layoutFinished(self):
546                 idx = 0
547                 self["menulist"].moveToIndex(idx)
548                 self.loadDescription()
549
550         def loadDescription(self):
551                 if self["menulist"].getCurrent()[1] == 'edit':
552                         self["description"].setText(_("Edit the network configuration of your Dreambox.\n" ) + self.oktext )
553                 if self["menulist"].getCurrent()[1] == 'test':
554                         self["description"].setText(_("Test the network configuration of your Dreambox.\n" ) + self.oktext )
555                 if self["menulist"].getCurrent()[1] == 'dns':
556                         self["description"].setText(_("Edit the Nameserver configuration of your Dreambox.\n" ) + self.oktext )
557                 if self["menulist"].getCurrent()[1] == 'scanwlan':
558                         self["description"].setText(_("Scan your network for wireless Access Points and connect to them using your WLAN USB Stick\n" ) + self.oktext )
559                 if self["menulist"].getCurrent()[1] == 'wlanstatus':
560                         self["description"].setText(_("Shows the state of your wireless LAN connection.\n" ) + self.oktext )
561                 if self["menulist"].getCurrent()[1] == 'lanrestart':
562                         self["description"].setText(_("Restart your network connection and interfaces.\n" ) + self.oktext )
563                 if self["menulist"].getCurrent()[1] == 'openwizard':
564                         self["description"].setText(_("Use the Networkwizard to configure your Network\n" ) + self.oktext )
565
566         def updateStatusbar(self):
567                 self["IFtext"].setText(_("Network:"))
568                 self["IF"].setText(iNetwork.getFriendlyAdapterName(self.iface))
569                 self["Statustext"].setText(_("Link:"))
570                 
571                 if self.iface == 'wlan0' or self.iface == 'ath0':
572                         try:
573                                 from Plugins.SystemPlugins.WirelessLan.Wlan import Wlan
574                                 w = Wlan(self.iface)
575                                 stats = w.getStatus()
576                                 if stats['BSSID'] == "00:00:00:00:00:00":
577                                         self["statuspic"].setPixmapNum(1)
578                                 else:
579                                         self["statuspic"].setPixmapNum(0)
580                                 self["statuspic"].show()
581                         except:
582                                         self["statuspic"].setPixmapNum(1)
583                                         self["statuspic"].show()
584                 else:
585                         self.getLinkState(self.iface)
586
587         def doNothing(self):
588                 pass
589
590         def genMainMenu(self):
591                 menu = []
592                 menu.append((_("Adapter settings"), "edit"))
593                 menu.append((_("Nameserver settings"), "dns"))
594                 menu.append((_("Network test"), "test"))
595                 menu.append((_("Restart network"), "lanrestart"))
596                 
597                 for p in plugins.getPlugins(PluginDescriptor.WHERE_NETWORKSETUP):
598                         callFnc = p.__call__["ifaceSupported"](self.iface)
599                         if callFnc is not None:
600                                 menu.append((_("Scan Wireless Networks"), "scanwlan"))
601                                 if iNetwork.getAdapterAttribute(self.iface, "up"):
602                                         menu.append((_("Show WLAN Status"), "wlanstatus"))
603                                 
604                 if os_path.exists(resolveFilename(SCOPE_PLUGINS, "SystemPlugins/NetworkWizard/networkwizard.xml")):
605                         menu.append((_("NetworkWizard"), "openwizard"));
606                 return menu
607
608         def AdapterSetupClosed(self, *ret):
609                 self.mainmenu = self.genMainMenu()
610                 self["menulist"].l.setList(self.mainmenu)
611                 iNetwork.getInterfaces()
612                 self.updateStatusbar()
613
614         def WlanScanClosed(self,*ret):
615                 if ret[0] is not None:
616                         self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetup, self.iface,ret[0],ret[1])
617                 else:
618                         self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetup, self.iface,None,ret[0])
619
620
621         def restartLan(self, ret = False):
622                 if (ret == True):
623                         iNetwork.restartNetwork()
624
625         def getLinkState(self,iface):
626                 iNetwork.getLinkState(iface,self.dataAvail)
627
628         def dataAvail(self,data):
629                 self.output = data.strip()
630                 result = self.output.split('\n')
631                 pattern = re_compile("Link detected: yes")
632                 for item in result:
633                         if re_search(pattern, item):
634                                 self["statuspic"].setPixmapNum(0)
635                         else:
636                                 self["statuspic"].setPixmapNum(1)
637                 self["statuspic"].show()
638
639         def showErrorMessage(self):
640                 self.session.open(MessageBox, self.errortext, type = MessageBox.TYPE_INFO,timeout = 10 )
641
642
643 class NetworkAdapterTest(Screen):       
644         def __init__(self, session,iface):
645                 Screen.__init__(self, session)
646                 self.iface = iface
647                 iNetwork.getInterfaces()
648                 self.setLabels()
649                 
650                 self["updown_actions"] = NumberActionMap(["WizardActions","ShortcutActions"],
651                 {
652                         "ok": self.KeyOK,
653                         "blue": self.KeyOK,
654                         "up": lambda: self.updownhandler('up'),
655                         "down": lambda: self.updownhandler('down'),
656                 
657                 }, -2)
658                 
659                 self["shortcuts"] = ActionMap(["ShortcutActions","WizardActions"],
660                 {
661                         "red": self.close,
662                         "back": self.close,
663                 }, -2)
664                 self["infoshortcuts"] = ActionMap(["ShortcutActions","WizardActions"],
665                 {
666                         "red": self.closeInfo,
667                         "back": self.closeInfo,
668                 }, -2)
669                 self["shortcutsgreen"] = ActionMap(["ShortcutActions"],
670                 {
671                         "green": self.KeyGreen,
672                 }, -2)
673                 self["shortcutsgreen_restart"] = ActionMap(["ShortcutActions"],
674                 {
675                         "green": self.KeyGreenRestart,
676                 }, -2)
677                 self["shortcutsyellow"] = ActionMap(["ShortcutActions"],
678                 {
679                         "yellow": self.KeyYellow,
680                 }, -2)
681                 
682                 self["shortcutsgreen_restart"].setEnabled(False)
683                 self["updown_actions"].setEnabled(False)
684                 self["infoshortcuts"].setEnabled(False)
685                 self.onClose.append(self.delTimer)      
686                 self.onLayoutFinish.append(self.layoutFinished)
687                 self.steptimer = False
688                 self.nextstep = 0
689                 self.activebutton = 0
690                 self.nextStepTimer = eTimer()
691                 self.nextStepTimer.callback.append(self.nextStepTimerFire)
692
693         def closeInfo(self):
694                 self["shortcuts"].setEnabled(True)              
695                 self["infoshortcuts"].setEnabled(False)
696                 self["InfoText"].hide()
697                 self["InfoTextBorder"].hide()
698                 self["ButtonRedtext"].setText(_("Close"))
699
700         def delTimer(self):
701                 del self.steptimer
702                 del self.nextStepTimer
703
704         def nextStepTimerFire(self):
705                 self.nextStepTimer.stop()
706                 self.steptimer = False
707                 self.runTest()
708
709         def updownhandler(self,direction):
710                 if direction == 'up':
711                         if self.activebutton >=2:
712                                 self.activebutton -= 1
713                         else:
714                                 self.activebutton = 6
715                         self.setActiveButton(self.activebutton)
716                 if direction == 'down':
717                         if self.activebutton <=5:
718                                 self.activebutton += 1
719                         else:
720                                 self.activebutton = 1
721                         self.setActiveButton(self.activebutton)
722
723         def setActiveButton(self,button):
724                 if button == 1:
725                         self["EditSettingsButton"].setPixmapNum(0)
726                         self["EditSettings_Text"].setForegroundColorNum(0)
727                         self["NetworkInfo"].setPixmapNum(0)
728                         self["NetworkInfo_Text"].setForegroundColorNum(1)
729                         self["AdapterInfo"].setPixmapNum(1)               # active
730                         self["AdapterInfo_Text"].setForegroundColorNum(2) # active
731                 if button == 2:
732                         self["AdapterInfo_Text"].setForegroundColorNum(1)
733                         self["AdapterInfo"].setPixmapNum(0)
734                         self["DhcpInfo"].setPixmapNum(0)
735                         self["DhcpInfo_Text"].setForegroundColorNum(1)
736                         self["NetworkInfo"].setPixmapNum(1)               # active
737                         self["NetworkInfo_Text"].setForegroundColorNum(2) # active
738                 if button == 3:
739                         self["NetworkInfo"].setPixmapNum(0)
740                         self["NetworkInfo_Text"].setForegroundColorNum(1)
741                         self["IPInfo"].setPixmapNum(0)
742                         self["IPInfo_Text"].setForegroundColorNum(1)
743                         self["DhcpInfo"].setPixmapNum(1)                  # active
744                         self["DhcpInfo_Text"].setForegroundColorNum(2)    # active
745                 if button == 4:
746                         self["DhcpInfo"].setPixmapNum(0)
747                         self["DhcpInfo_Text"].setForegroundColorNum(1)
748                         self["DNSInfo"].setPixmapNum(0)
749                         self["DNSInfo_Text"].setForegroundColorNum(1)
750                         self["IPInfo"].setPixmapNum(1)                  # active
751                         self["IPInfo_Text"].setForegroundColorNum(2)    # active                
752                 if button == 5:
753                         self["IPInfo"].setPixmapNum(0)
754                         self["IPInfo_Text"].setForegroundColorNum(1)
755                         self["EditSettingsButton"].setPixmapNum(0)
756                         self["EditSettings_Text"].setForegroundColorNum(0)
757                         self["DNSInfo"].setPixmapNum(1)                 # active
758                         self["DNSInfo_Text"].setForegroundColorNum(2)   # active
759                 if button == 6:
760                         self["DNSInfo"].setPixmapNum(0)
761                         self["DNSInfo_Text"].setForegroundColorNum(1)
762                         self["EditSettingsButton"].setPixmapNum(1)         # active
763                         self["EditSettings_Text"].setForegroundColorNum(2) # active
764                         self["AdapterInfo"].setPixmapNum(0)
765                         self["AdapterInfo_Text"].setForegroundColorNum(1)
766                         
767         def runTest(self):
768                 next = self.nextstep
769                 if next == 0:
770                         self.doStep1()
771                 elif next == 1:
772                         self.doStep2()
773                 elif next == 2:
774                         self.doStep3()
775                 elif next == 3:
776                         self.doStep4()
777                 elif next == 4:
778                         self.doStep5()
779                 elif next == 5:
780                         self.doStep6()
781                 self.nextstep += 1
782
783         def doStep1(self):
784                 self.steptimer = True
785                 self.nextStepTimer.start(3000)
786
787         def doStep2(self):
788                 self["Adapter"].setText(iNetwork.getFriendlyAdapterName(self.iface))
789                 self["Adapter"].setForegroundColorNum(2)
790                 self["Adaptertext"].setForegroundColorNum(1)
791                 self["AdapterInfo_Text"].setForegroundColorNum(1)
792                 self["AdapterInfo_OK"].show()
793                 self.steptimer = True
794                 self.nextStepTimer.start(3000)
795
796         def doStep3(self):
797                 self["Networktext"].setForegroundColorNum(1)
798                 self.getLinkState(self.iface)
799                 self["NetworkInfo_Text"].setForegroundColorNum(1)
800                 self.steptimer = True
801                 self.nextStepTimer.start(3000)
802
803         def doStep4(self):
804                 self["Dhcptext"].setForegroundColorNum(1)
805                 if iNetwork.getAdapterAttribute(self.iface, 'dhcp') is True:
806                         self["Dhcp"].setForegroundColorNum(2)
807                         self["Dhcp"].setText(_("enabled"))
808                         self["DhcpInfo_Check"].setPixmapNum(0)
809                 else:
810                         self["Dhcp"].setForegroundColorNum(1)
811                         self["Dhcp"].setText(_("disabled"))
812                         self["DhcpInfo_Check"].setPixmapNum(1)
813                 self["DhcpInfo_Check"].show()
814                 self["DhcpInfo_Text"].setForegroundColorNum(1)
815                 self.steptimer = True
816                 self.nextStepTimer.start(3000)
817
818         def doStep5(self):
819                 self["IPtext"].setForegroundColorNum(1)
820                 ret = iNetwork.checkNetworkState()
821                 if ret == True:
822                         self["IP"].setForegroundColorNum(2)
823                         self["IP"].setText(_("confirmed"))
824                         self["IPInfo_Check"].setPixmapNum(0)
825                 else:
826                         self["IP"].setForegroundColorNum(1)
827                         self["IP"].setText(_("unconfirmed"))
828                         self["IPInfo_Check"].setPixmapNum(1)
829                 self["IPInfo_Check"].show()
830                 self["IPInfo_Text"].setForegroundColorNum(1)
831                 self.steptimer = True
832                 self.nextStepTimer.start(3000)
833
834         def doStep6(self):
835                 self.steptimer = False
836                 self.nextStepTimer.stop()
837                 self["DNStext"].setForegroundColorNum(1)
838                 ret = iNetwork.checkDNSLookup()
839                 if ret == True:
840                         self["DNS"].setForegroundColorNum(2)
841                         self["DNS"].setText(_("confirmed"))
842                         self["DNSInfo_Check"].setPixmapNum(0)
843                 else:
844                         self["DNS"].setForegroundColorNum(1)
845                         self["DNS"].setText(_("unconfirmed"))
846                         self["DNSInfo_Check"].setPixmapNum(1)
847                 self["DNSInfo_Check"].show()
848                 self["DNSInfo_Text"].setForegroundColorNum(1)
849                 
850                 self["EditSettings_Text"].show()
851                 self["EditSettingsButton"].setPixmapNum(1)
852                 self["EditSettings_Text"].setForegroundColorNum(2) # active
853                 self["EditSettingsButton"].show()
854                 self["ButtonYellow_Check"].setPixmapNum(1)
855                 self["ButtonGreentext"].setText(_("Restart test"))
856                 self["ButtonGreen_Check"].setPixmapNum(0)
857                 self["shortcutsgreen"].setEnabled(False)
858                 self["shortcutsgreen_restart"].setEnabled(True)
859                 self["shortcutsyellow"].setEnabled(False)
860                 self["updown_actions"].setEnabled(True)
861                 self.activebutton = 6
862
863         def KeyGreen(self):
864                 self["shortcutsgreen"].setEnabled(False)
865                 self["shortcutsyellow"].setEnabled(True)
866                 self["updown_actions"].setEnabled(False)
867                 self["ButtonYellow_Check"].setPixmapNum(0)
868                 self["ButtonGreen_Check"].setPixmapNum(1)
869                 self.steptimer = True
870                 self.nextStepTimer.start(1000)
871
872         def KeyGreenRestart(self):
873                 self.nextstep = 0
874                 self.layoutFinished()
875                 self["Adapter"].setText((""))
876                 self["Network"].setText((""))
877                 self["Dhcp"].setText((""))
878                 self["IP"].setText((""))
879                 self["DNS"].setText((""))
880                 self["AdapterInfo_Text"].setForegroundColorNum(0)
881                 self["NetworkInfo_Text"].setForegroundColorNum(0)
882                 self["DhcpInfo_Text"].setForegroundColorNum(0)
883                 self["IPInfo_Text"].setForegroundColorNum(0)
884                 self["DNSInfo_Text"].setForegroundColorNum(0)
885                 self["shortcutsgreen_restart"].setEnabled(False)
886                 self["shortcutsgreen"].setEnabled(False)
887                 self["shortcutsyellow"].setEnabled(True)
888                 self["updown_actions"].setEnabled(False)
889                 self["ButtonYellow_Check"].setPixmapNum(0)
890                 self["ButtonGreen_Check"].setPixmapNum(1)
891                 self.steptimer = True
892                 self.nextStepTimer.start(1000)
893
894         def KeyOK(self):
895                 self["infoshortcuts"].setEnabled(True)
896                 self["shortcuts"].setEnabled(False)
897                 if self.activebutton == 1: # Adapter Check
898                         self["InfoText"].setText(_("This test detects your configured LAN-Adapter."))
899                         self["InfoTextBorder"].show()
900                         self["InfoText"].show()
901                         self["ButtonRedtext"].setText(_("Back"))
902                 if self.activebutton == 2: #LAN Check
903                         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"))
904                         self["InfoTextBorder"].show()
905                         self["InfoText"].show()
906                         self["ButtonRedtext"].setText(_("Back"))
907                 if self.activebutton == 3: #DHCP Check
908                         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."))
909                         self["InfoTextBorder"].show()
910                         self["InfoText"].show()
911                         self["ButtonRedtext"].setText(_("Back"))
912                 if self.activebutton == 4: # IP Check
913                         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"))
914                         self["InfoTextBorder"].show()
915                         self["InfoText"].show()
916                         self["ButtonRedtext"].setText(_("Back"))
917                 if self.activebutton == 5: # DNS Check
918                         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"))
919                         self["InfoTextBorder"].show()
920                         self["InfoText"].show()
921                         self["ButtonRedtext"].setText(_("Back"))
922                 if self.activebutton == 6: # Edit Settings
923                         self.session.open(AdapterSetup,self.iface)
924
925         def KeyYellow(self):
926                 self.nextstep = 0
927                 self["shortcutsgreen_restart"].setEnabled(True)
928                 self["shortcutsgreen"].setEnabled(False)
929                 self["shortcutsyellow"].setEnabled(False)
930                 self["ButtonGreentext"].setText(_("Restart test"))
931                 self["ButtonYellow_Check"].setPixmapNum(1)
932                 self["ButtonGreen_Check"].setPixmapNum(0)
933                 self.steptimer = False
934                 self.nextStepTimer.stop()
935
936         def layoutFinished(self):
937                 self["shortcutsyellow"].setEnabled(False)
938                 self["AdapterInfo_OK"].hide()
939                 self["NetworkInfo_Check"].hide()
940                 self["DhcpInfo_Check"].hide()
941                 self["IPInfo_Check"].hide()
942                 self["DNSInfo_Check"].hide()
943                 self["EditSettings_Text"].hide()
944                 self["EditSettingsButton"].hide()
945                 self["InfoText"].hide()
946                 self["InfoTextBorder"].hide()
947
948         def setLabels(self):
949                 self["Adaptertext"] = MultiColorLabel(_("LAN Adapter"))
950                 self["Adapter"] = MultiColorLabel()
951                 self["AdapterInfo"] = MultiPixmap()
952                 self["AdapterInfo_Text"] = MultiColorLabel(_("Show Info"))
953                 self["AdapterInfo_OK"] = Pixmap()
954                 
955                 if self.iface == 'wlan0' or self.iface == 'ath0':
956                         self["Networktext"] = MultiColorLabel(_("Wireless Network"))
957                 else:
958                         self["Networktext"] = MultiColorLabel(_("Local Network"))
959                 
960                 self["Network"] = MultiColorLabel()
961                 self["NetworkInfo"] = MultiPixmap()
962                 self["NetworkInfo_Text"] = MultiColorLabel(_("Show Info"))
963                 self["NetworkInfo_Check"] = MultiPixmap()
964                 
965                 self["Dhcptext"] = MultiColorLabel(_("DHCP"))
966                 self["Dhcp"] = MultiColorLabel()
967                 self["DhcpInfo"] = MultiPixmap()
968                 self["DhcpInfo_Text"] = MultiColorLabel(_("Show Info"))
969                 self["DhcpInfo_Check"] = MultiPixmap()
970                 
971                 self["IPtext"] = MultiColorLabel(_("IP Address"))
972                 self["IP"] = MultiColorLabel()
973                 self["IPInfo"] = MultiPixmap()
974                 self["IPInfo_Text"] = MultiColorLabel(_("Show Info"))
975                 self["IPInfo_Check"] = MultiPixmap()
976                 
977                 self["DNStext"] = MultiColorLabel(_("Nameserver"))
978                 self["DNS"] = MultiColorLabel()
979                 self["DNSInfo"] = MultiPixmap()
980                 self["DNSInfo_Text"] = MultiColorLabel(_("Show Info"))
981                 self["DNSInfo_Check"] = MultiPixmap()
982                 
983                 self["EditSettings_Text"] = MultiColorLabel(_("Edit settings"))
984                 self["EditSettingsButton"] = MultiPixmap()
985                 
986                 self["ButtonRedtext"] = Label(_("Close"))
987                 self["ButtonRed"] = Pixmap()
988
989                 self["ButtonGreentext"] = Label(_("Start test"))
990                 self["ButtonGreen_Check"] = MultiPixmap()
991                 
992                 self["ButtonYellowtext"] = Label(_("Stop test"))
993                 self["ButtonYellow_Check"] = MultiPixmap()
994                 
995                 self["InfoTextBorder"] = Pixmap()
996                 self["InfoText"] = Label()
997
998         def getLinkState(self,iface):
999                 if iface == 'wlan0' or iface == 'ath0':
1000                         try:
1001                                 from Plugins.SystemPlugins.WirelessLan.Wlan import Wlan
1002                                 w = Wlan(iface)
1003                                 stats = w.getStatus()
1004                                 if stats['BSSID'] == "00:00:00:00:00:00":
1005                                         self["Network"].setForegroundColorNum(1)
1006                                         self["Network"].setText(_("disconnected"))
1007                                         self["NetworkInfo_Check"].setPixmapNum(1)
1008                                         self["NetworkInfo_Check"].show()
1009                                 else:
1010                                         self["Network"].setForegroundColorNum(2)
1011                                         self["Network"].setText(_("connected"))
1012                                         self["NetworkInfo_Check"].setPixmapNum(0)
1013                                         self["NetworkInfo_Check"].show()
1014                         except:
1015                                         self["Network"].setForegroundColorNum(1)
1016                                         self["Network"].setText(_("disconnected"))
1017                                         self["NetworkInfo_Check"].setPixmapNum(1)
1018                                         self["NetworkInfo_Check"].show()
1019                 else:
1020                         iNetwork.getLinkState(iface,self.dataAvail)
1021
1022         def dataAvail(self,data):
1023                 self.output = data.strip()
1024                 result = self.output.split('\n')
1025                 pattern = re_compile("Link detected: yes")
1026                 for item in result:
1027                         if re_search(pattern, item):
1028                                 self["Network"].setForegroundColorNum(2)
1029                                 self["Network"].setText(_("connected"))
1030                                 self["NetworkInfo_Check"].setPixmapNum(0)
1031                         else:
1032                                 self["Network"].setForegroundColorNum(1)
1033                                 self["Network"].setText(_("disconnected"))
1034                                 self["NetworkInfo_Check"].setPixmapNum(1)
1035                 self["NetworkInfo_Check"].show()
1036
1037