4.2.5r2
[enigma2.git] / usr / lib / enigma2 / python / Plugins / SystemPlugins / NetworkManager / NetworkWizard.py
1 from enigma import eNetworkManager
2
3 from Components.Label import Label
4 from Components.Pixmap import Pixmap
5 from Components.Sources.Boolean import Boolean
6 from Screens.WizardLanguage import WizardLanguage
7 from Screens.Rc import Rc
8 from Tools.Directories import resolveFilename, SCOPE_PLUGINS
9 from NetworkConfig import NetworkConfigGeneral, ServiceIPConfiguration, ServiceNSConfiguration
10
11 class NetworkWizardNew(NetworkConfigGeneral):
12         def __init__(self):
13                 NetworkConfigGeneral.__init__(self)
14
15                 self._services = self["list"]
16
17                 self.__updateStateText()
18                 self.showState(False)
19
20                 self.addLanguageUpdateCallback(self.__updateNetworkLanguageTexts)
21
22                 self._ipconfig = None
23                 self._nsconfig = None
24
25         def __updateNetworkLanguageTexts(self):
26                 self.__updateStateText()
27                 self.checkButtons()
28
29         def __updateStateText(self):
30                 self["state_label"].setText(_("Connection State:"))
31                 self["state"].setText(NetworkConfigGeneral.translateState(self._nm.state()))
32
33         def _buildListEntry(self, *args, **kwargs):
34                 return (args[1], args[0])
35
36         def green(self):
37                 service = self["list"].getCurrent()
38                 if service:
39                         service = service[1]
40                         state = service.state()
41                         if state in (eNetworkManager.STATE_IDLE, eNetworkManager.STATE_FAILURE):
42                                 service.requestDisconnect()
43                                 service.requestConnect()
44                                 service.setAutoConnect(True)
45                         else:
46                                 service.requestDisconnect()
47
48         def yellow(self):
49                 if self.isCurrentStepID("services"):
50                         self._rescan()
51
52         def checkButtons(self):
53                 if self.isCurrentStepID("services"):
54                         self["button_yellow_text"].setText(_("Rescan"))
55                         service = self._currentService
56                         if service:
57                                 if not service.state() in (eNetworkManager.STATE_IDLE, eNetworkManager.STATE_FAILURE):
58                                         self["button_green_text"].setText(_("Disconnect"))
59                                 else:
60                                         self["button_green_text"].setText(_("Connect"))
61
62         def selChanged(self):
63                 WizardLanguage.selChanged(self)
64                 self.checkButtons()
65
66         def _technologiesChanged(self):
67                 if self.isCurrentStepID("technologies"):
68                         self["config"].list = self.getTechnologyConfig()
69
70         def _techPoweredChanged(self, powered):
71                 if self.isCurrentStepID("technologies"):
72                         self["config"].list = self.getTechnologyConfig()
73
74         def technologiesSet(self):
75                 pass
76
77         def _servicesChanged(self, *args):
78                 self["state"].setText( NetworkConfigGeneral.translateState( self._nm.state() ) )
79                 if self.isCurrentStepID("services"):
80                         self["list"].updateList( self.getServiceList() )
81                         self.checkButtons()
82
83         def ipConfigurationRequired(self):
84                 return not self.isOnline()
85
86         def isNetworkConnected(self):
87                 return self.isOnline()
88
89         def getAddressConfig(self):
90                 self._ipconfig = ServiceIPConfiguration(self._nm.getServices()[0])
91                 self._ipconfig.reload()
92                 return self._ipconfig.getList()
93
94         def _reloadAddressConfig(self):
95                 self["config"].list = self._ipconfig.getList()
96
97         def saveAddressConfig(self):
98                 self._ipconfig.save()
99
100         def isOnline(self):
101                 return self._nm.online()
102
103         def getNameserverConfig(self):
104                 self._nsconfig = ServiceNSConfiguration( self._nm.getServices()[0] )
105
106         def saveNameserverConfig(self):
107                 self._nsconfig.save()