add ability to list all events for a specific start time/date (press Dream/Menu)
[enigma2.git] / lib / python / Screens / Satconfig.py
1 from Screen import Screen
2 from Components.ActionMap import NumberActionMap
3 from Components.ActionMap import ActionMap
4 from Components.ConfigList import ConfigList
5 from Components.config import *
6 from Components.MenuList import MenuList
7 from Components.NimManager import nimmanager
8 from Components.config import getConfigListEntry
9
10 class NimSetup(Screen):
11         def createSimpleSetup(self, list, mode):
12                 if mode == 0:                   #single Sat
13                         list.append(getConfigListEntry(_("Satellite"), self.nimConfig.diseqcA))
14                 else:                                                   # > 1 Sats
15                         list.append(getConfigListEntry(_("Port A"), self.nimConfig.diseqcA))
16
17                 if mode >= 1:                   # > 1 Sats
18                         list.append(getConfigListEntry(_("Port B"), self.nimConfig.diseqcB))
19                         if mode >= 3:           # > 2 Sats
20                                 list.append(getConfigListEntry(_("Port C"), self.nimConfig.diseqcC))
21                                 list.append(getConfigListEntry(_("Port D"), self.nimConfig.diseqcD))
22
23         def createPositionerSetup(self, list):
24 #               list.append(getConfigListEntry(_("Positioner mode"), self.nimConfig.positionerMode))
25 #               if (currentConfigSelectionElement(self.nimConfig.positionerMode) == "usals"): # USALS
26                 list.append(getConfigListEntry(_("Longitude"), self.nimConfig.longitude))
27                 list.append(getConfigListEntry(" ", self.nimConfig.longitudeOrientation))
28                 list.append(getConfigListEntry(_("Latitude"), self.nimConfig.latitude))
29                 list.append(getConfigListEntry(" ", self.nimConfig.latitudeOrientation))
30 #               elif (currentConfigSelectionElement(self.nimConfig.positionerMode) == "manual"): # manual
31 #                       pass
32
33         def createSetup(self):
34                 print "Creating setup"
35                 self.list = [ ]
36
37                 self.configMode = None
38                 self.diseqcModeEntry = None
39                 self.advancedSatsEntry = None
40                 self.advancedLnbsEntry = None
41                 self.advancedDiseqcMode = None
42                 self.advancedUsalsEntry = None
43                 self.advancedLof = None
44                 self.advancedPowerMeasurement = None
45                 
46                 self.nim_type = nimmanager.getNimType(self.nim.slotid)
47
48                 if self.nim_type == nimmanager.nimType["DVB-S"]:
49                         self.configMode = getConfigListEntry(_("Configuration Mode"), self.nimConfig.configMode)
50                         self.list.append(self.configMode)
51
52                         if currentConfigSelectionElement(self.nimConfig.configMode) == "simple":                        #simple setup
53                                 self.diseqcModeEntry = getConfigListEntry(_("DiSEqC Mode"), self.nimConfig.diseqcMode)
54                                 self.list.append(self.diseqcModeEntry)
55                                 if (0 <= self.nimConfig.diseqcMode.value < 4):
56                                         self.createSimpleSetup(self.list, self.nimConfig.diseqcMode.value)
57                                 if (self.nimConfig.diseqcMode.value == 4):
58                                         self.createPositionerSetup(self.list)
59                         elif currentConfigSelectionElement(self.nimConfig.configMode) in ["loopthrough", "satposdepends", "nothing", "equal"]:
60                                 pass
61                         elif currentConfigSelectionElement(self.nimConfig.configMode) == "advanced": # advanced
62                                 # SATs
63                                 self.advancedSatsEntry = getConfigListEntry(_("Satellite"), self.nimConfig.advanced.sats)
64                                 self.list.append(self.advancedSatsEntry)
65                                 currSat = self.nimConfig.advanced.sat[nimmanager.satList[self.nimConfig.advanced.sats.value][1]]
66                                 self.fillListWithAdvancedSatEntrys(currSat)
67                         self.have_advanced = True
68                 elif self.nim_type == nimmanager.nimType["DVB-C"]:
69                         self.list.append(getConfigListEntry(_("Cable provider"), self.nimConfig.cable))
70                         self.have_advanced = False
71                 elif self.nim_type == nimmanager.nimType["DVB-T"]:
72                         self.have_advanced = False
73                         self.list.append(getConfigListEntry(_("Terrestrial provider"), self.nimConfig.terrestrial))
74
75                 self["config"].list = self.list
76                 self["config"].l.setList(self.list)
77
78         def newConfig(self):
79                 checkList = (self.configMode, self.diseqcModeEntry, self.advancedSatsEntry, self.advancedLnbsEntry, self.advancedDiseqcMode, self.advancedUsalsEntry, self.advancedLof, self.advancedPowerMeasurement)
80                 for x in checkList:
81                         if self["config"].getCurrent() == x:
82                                 self.createSetup()
83
84         def keyLeft(self):
85                 self["config"].handleKey(config.key["prevElement"])
86                 self.newConfig()
87
88         def keyRight(self):
89                 self["config"].handleKey(config.key["nextElement"])
90                 self.newConfig()
91
92         def keyNumberGlobal(self, number):
93                 print "You pressed number " + str(number)
94                 if (self["config"].getCurrent()[1].parent.enabled == True):
95                         self["config"].handleKey(config.key[str(number)])
96
97         def run(self):
98                 if self.have_advanced and currentConfigSelectionElement(config.Nims[self.nim.slotid].configMode) == "advanced":
99                         self.fillAdvancedList()
100                 for x in self["config"].list:
101                         x[1].save()
102                 nimmanager.sec.update()
103
104         def fillListWithAdvancedSatEntrys(self, Sat):
105                 currLnb = self.nimConfig.advanced.lnb[Sat.lnb.value]
106
107                 self.list.append(getConfigListEntry(_("Voltage mode"), Sat.voltage))
108                 self.list.append(getConfigListEntry(_("Tone mode"), Sat.tonemode))
109                 if (currLnb != 0 and currentConfigSelectionElement(currLnb.diseqcMode) == "1_2"):
110                         self.advancedUsalsEntry = getConfigListEntry(_("Use usals for this sat"), Sat.usals)
111                         self.list.append(self.advancedUsalsEntry)
112                         if (currentConfigSelectionElement(Sat.usals) == "no"):
113                                 self.list.append(getConfigListEntry(_("Stored position"), Sat.rotorposition))
114
115                 # LNBs
116                 self.advancedLnbsEntry = getConfigListEntry(_("LNB"), Sat.lnb)
117                 self.list.append(self.advancedLnbsEntry)
118                 if currLnb != 0:
119                         self.advancedDiseqcMode = getConfigListEntry(_("DiSEqC mode"), currLnb.diseqcMode)
120                         self.list.append(self.advancedDiseqcMode)
121                         if currentConfigSelectionElement(currLnb.diseqcMode) != "none":
122                                 self.list.append(getConfigListEntry(_("Toneburst"), currLnb.toneburst))
123                                 self.list.append(getConfigListEntry(_("Committed DiSEqC command"), currLnb.commitedDiseqcCommand))
124                                 self.list.append(getConfigListEntry(_("Fast DiSEqC"), currLnb.fastDiseqc))
125                                 self.list.append(getConfigListEntry(_("Sequence repeat"), currLnb.sequenceRepeat))
126                                 if currentConfigSelectionElement(currLnb.diseqcMode) == "1_0":
127                                         self.list.append(getConfigListEntry(_("Command order"), currLnb.commandOrder1_0))
128                                 else:
129                                         self.list.append(getConfigListEntry(_("Command order"), currLnb.commandOrder))
130                                         self.list.append(getConfigListEntry(_("Uncommitted DiSEqC command"), currLnb.uncommittedDiseqcCommand))
131                                         self.list.append(getConfigListEntry(_("DiSEqC repeats"), currLnb.diseqcRepeats))
132                                 if currentConfigSelectionElement(currLnb.diseqcMode) == "1_2":
133                                         self.list.append(getConfigListEntry(_("Longitude"), currLnb.longitude))
134                                         self.list.append(getConfigListEntry(" ", currLnb.longitudeOrientation))
135                                         self.list.append(getConfigListEntry(_("Latitude"), currLnb.latitude))
136                                         self.list.append(getConfigListEntry(" ", currLnb.latitudeOrientation))
137                                         self.advancedPowerMeasurement = getConfigListEntry("Use Power Measurement", currLnb.powerMeasurement)
138                                         self.list.append(self.advancedPowerMeasurement)
139                                         if currentConfigSelectionElement(currLnb.powerMeasurement) == "yes":
140                                                 self.list.append(getConfigListEntry("Power Threshold in mA", currLnb.powerThreshold))
141                         self.advancedLof = getConfigListEntry(_("LOF"), currLnb.lof)
142                         self.list.append(self.advancedLof)
143                         if currentConfigSelectionElement(currLnb.lof) == "user_defined":
144                                 self.list.append(getConfigListEntry(_("LOF/L"), currLnb.lofl))
145                                 self.list.append(getConfigListEntry(_("LOF/H"), currLnb.lofh))
146                                 self.list.append(getConfigListEntry(_("Threshold"), currLnb.threshold))
147                         self.list.append(getConfigListEntry(_("12V Output"), currLnb.output_12v))
148                         self.list.append(getConfigListEntry(_("Increased voltage"), currLnb.increased_voltage))
149
150         def fillAdvancedList(self):
151                 self.list = [ ]
152                 self.configMode = getConfigListEntry(_("Configuration Mode"), self.nimConfig.configMode)
153                 self.list.append(self.configMode)
154                 self.advancedSatsEntry = getConfigListEntry(_("Satellite"), self.nimConfig.advanced.sats)
155                 self.list.append(self.advancedSatsEntry)
156                 for x in nimmanager.satList:
157                         Sat = self.nimConfig.advanced.sat[x[1]]
158                         self.fillListWithAdvancedSatEntrys(Sat)
159                 self["config"].list = self.list
160
161         def keySave(self):
162                 self.run()
163                 self.close()
164
165         def keyCancel(self):
166                 for x in self["config"].list:
167                         x[1].cancel()
168                 self.close()
169
170         def __init__(self, session, slotid):
171                 Screen.__init__(self, session)
172
173                 self["actions"] = NumberActionMap(["SetupActions"],
174                 {
175                         "ok": self.keySave,
176                         "cancel": self.keyCancel,
177                         "left": self.keyLeft,
178                         "right": self.keyRight,
179                         "1": self.keyNumberGlobal,
180                         "2": self.keyNumberGlobal,
181                         "3": self.keyNumberGlobal,
182                         "4": self.keyNumberGlobal,
183                         "5": self.keyNumberGlobal,
184                         "6": self.keyNumberGlobal,
185                         "7": self.keyNumberGlobal,
186                         "8": self.keyNumberGlobal,
187                         "9": self.keyNumberGlobal,
188                         "0": self.keyNumberGlobal
189                 }, -1)
190
191                 self.nim = nimmanager.nimList()[slotid][1]
192                 self.nimConfig = config.Nims[self.nim.slotid]
193                 self.list = [ ]
194                 self["config"] = ConfigList(self.list)
195                 self.createSetup()
196
197 class NimSelection(Screen):
198         def __init__(self, session):
199                 Screen.__init__(self, session)
200
201                 self["nimlist"] = MenuList(nimmanager.nimList())
202
203                 self["actions"] = ActionMap(["OkCancelActions"],
204                 {
205                         "ok": self.okbuttonClick ,
206                         "cancel": self.close
207                 }, -1)
208
209         def okbuttonClick(self):
210                 selection = self["nimlist"].getCurrent()
211                 if selection[1].nimType != -1:  #unknown/empty
212                         self.session.open(NimSetup, selection[1].slotid)
213