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