main/Makefile.am: fix code to generate version.h code is now als able to handle git...
[enigma2.git] / lib / python / Screens / Satconfig.py
1 from enigma import eDVBDB
2 from Screen import Screen
3 from Components.SystemInfo import SystemInfo
4 from Components.ActionMap import ActionMap
5 from Components.ConfigList import ConfigListScreen
6 from Components.MenuList import MenuList
7 from Components.NimManager import nimmanager
8 from Components.config import getConfigListEntry, config, ConfigNothing, ConfigSelection, updateConfigElement
9 from Components.Sources.List import List
10 from Screens.MessageBox import MessageBox
11
12 from time import mktime, localtime
13 from datetime import datetime
14
15 class NimSetup(Screen, ConfigListScreen):
16         def createSimpleSetup(self, list, mode):
17                 nim = self.nimConfig
18                 if mode == "single":
19                         list.append(getConfigListEntry(_("Satellite"), nim.diseqcA))
20                         list.append(getConfigListEntry(_("Send DiSEqC"), nim.simpleSingleSendDiSEqC))
21                 else:
22                         list.append(getConfigListEntry(_("Port A"), nim.diseqcA))
23
24                 if mode in ("toneburst_a_b", "diseqc_a_b", "diseqc_a_b_c_d"):
25                         list.append(getConfigListEntry(_("Port B"), nim.diseqcB))
26                         if mode == "diseqc_a_b_c_d":
27                                 list.append(getConfigListEntry(_("Port C"), nim.diseqcC))
28                                 list.append(getConfigListEntry(_("Port D"), nim.diseqcD))
29                         if mode != "toneburst_a_b":
30                                 list.append(getConfigListEntry(_("Set Voltage and 22KHz"), nim.simpleDiSEqCSetVoltageTone))
31                                 list.append(getConfigListEntry(_("Send DiSEqC only on satellite change"), nim.simpleDiSEqCOnlyOnSatChange))
32
33         def createPositionerSetup(self, list):
34                 nim = self.nimConfig
35                 list.append(getConfigListEntry(_("Longitude"), nim.longitude))
36                 list.append(getConfigListEntry(" ", nim.longitudeOrientation))
37                 list.append(getConfigListEntry(_("Latitude"), nim.latitude))
38                 list.append(getConfigListEntry(" ", nim.latitudeOrientation))
39                 if SystemInfo["CanMeasureFrontendInputPower"]:
40                         self.advancedPowerMeasurement = getConfigListEntry(_("Use Power Measurement"), nim.powerMeasurement)
41                         list.append(self.advancedPowerMeasurement)
42                         if nim.powerMeasurement.value:
43                                 list.append(getConfigListEntry(_("Power threshold in mA"), nim.powerThreshold))
44                                 self.turningSpeed = getConfigListEntry(_("Rotor turning speed"), nim.turningSpeed)
45                                 list.append(self.turningSpeed)
46                                 if nim.turningSpeed.value == "fast epoch":
47                                         self.turnFastEpochBegin = getConfigListEntry(_("Begin time"), nim.fastTurningBegin)
48                                         self.turnFastEpochEnd = getConfigListEntry(_("End time"), nim.fastTurningEnd)
49                                         list.append(self.turnFastEpochBegin)
50                                         list.append(self.turnFastEpochEnd)
51                 else:
52                         if nim.powerMeasurement.value:
53                                 nim.powerMeasurement.value = False
54                                 nim.powerMeasurement.save()
55                 
56         def createConfigMode(self):
57                 if self.nim.isCompatible("DVB-S"):
58                         choices = { "nothing": _("nothing connected"),
59                                                 "simple": _("simple"),
60                                                 "advanced": _("advanced")}
61                         #if len(nimmanager.getNimListOfType(nimmanager.getNimType(self.slotid), exception = x)) > 0:
62                         #       choices["equal"] = _("equal to")
63                         #       choices["satposdepends"] = _("second cable of motorized LNB")
64                         if len(nimmanager.canEqualTo(self.slotid)) > 0:
65                                 choices["equal"] = _("equal to")
66                         if len(nimmanager.canDependOn(self.slotid)) > 0:
67                                 choices["satposdepends"] = _("second cable of motorized LNB")
68                         if len(nimmanager.canConnectTo(self.slotid)) > 0:
69                                 choices["loopthrough"] = _("loopthrough to")
70                         self.nimConfig.configMode.setChoices(choices, default = "nothing")
71
72         def createSetup(self):
73                 print "Creating setup"
74                 self.list = [ ]
75
76                 self.configMode = None
77                 self.diseqcModeEntry = None
78                 self.advancedSatsEntry = None
79                 self.advancedLnbsEntry = None
80                 self.advancedDiseqcMode = None
81                 self.advancedUsalsEntry = None
82                 self.advancedLof = None
83                 self.advancedPowerMeasurement = None
84                 self.turningSpeed = None
85                 self.turnFastEpochBegin = None
86                 self.turnFastEpochEnd = None
87                 self.uncommittedDiseqcCommand = None
88                 self.cableScanType = None
89                 self.have_advanced = False
90                 self.advancedUnicable = None
91                 self.advancedType = None
92                 self.advancedManufacturer = None
93                 self.advancedSCR = None
94
95                 if self.nim.isCompatible("DVB-S"):
96                         self.configMode = getConfigListEntry(_("Configuration Mode"), self.nimConfig.configMode)
97                         self.list.append(self.configMode)
98
99                         if self.nimConfig.configMode.value == "simple":                 #simple setup
100                                 self.diseqcModeEntry = getConfigListEntry(_("Mode"), self.nimConfig.diseqcMode)
101                                 self.list.append(self.diseqcModeEntry)
102                                 if self.nimConfig.diseqcMode.value in ("single", "toneburst_a_b", "diseqc_a_b", "diseqc_a_b_c_d"):
103                                         self.createSimpleSetup(self.list, self.nimConfig.diseqcMode.value)
104                                 if self.nimConfig.diseqcMode.value == "positioner":
105                                         self.createPositionerSetup(self.list)
106                         elif self.nimConfig.configMode.value == "equal":
107                                 choices = []
108                                 nimlist = nimmanager.canEqualTo(self.nim.slot)
109                                 for id in nimlist:
110                                         #choices.append((str(id), str(chr(65 + id))))
111                                         choices.append((str(id), nimmanager.getNimDescription(id)))
112                                 self.nimConfig.connectedTo.setChoices(choices)
113                                 #self.nimConfig.connectedTo = updateConfigElement(self.nimConfig.connectedTo, ConfigSelection(choices = choices))
114                                 self.list.append(getConfigListEntry(_("Tuner"), self.nimConfig.connectedTo))
115                         elif self.nimConfig.configMode.value == "satposdepends":
116                                 choices = []
117                                 nimlist = nimmanager.canDependOn(self.nim.slot)
118                                 for id in nimlist:
119                                         #choices.append((str(id), str(chr(65 + id))))
120                                         choices.append((str(id), nimmanager.getNimDescription(id)))
121                                 self.nimConfig.connectedTo.setChoices(choices)
122                                 #self.nimConfig.connectedTo = updateConfigElement(self.nimConfig.connectedTo, ConfigSelection(choices = choices))
123                                 self.list.append(getConfigListEntry(_("Tuner"), self.nimConfig.connectedTo))
124                         elif self.nimConfig.configMode.value == "loopthrough":
125                                 choices = []
126                                 print "connectable to:", nimmanager.canConnectTo(self.slotid)
127                                 connectable = nimmanager.canConnectTo(self.slotid)
128                                 for id in connectable:
129                                         choices.append((str(id), nimmanager.getNimDescription(id)))
130                                 self.nimConfig.connectedTo.setChoices(choices)
131                                 #self.nimConfig.connectedTo = updateConfigElement(self.nimConfig.connectedTo, ConfigSelection(choices = choices))
132                                 self.list.append(getConfigListEntry(_("Connected to"), self.nimConfig.connectedTo))
133                         elif self.nimConfig.configMode.value == "nothing":
134                                 pass
135                         elif self.nimConfig.configMode.value == "advanced": # advanced
136                                 # SATs
137                                 self.advancedSatsEntry = getConfigListEntry(_("Satellite"), self.nimConfig.advanced.sats)
138                                 self.list.append(self.advancedSatsEntry)
139                                 cur_orb_pos = self.nimConfig.advanced.sats.orbital_position
140                                 satlist = self.nimConfig.advanced.sat.keys()
141                                 if cur_orb_pos is not None:
142                                         if cur_orb_pos not in satlist:
143                                                 cur_orb_pos = satlist[0]
144                                         currSat = self.nimConfig.advanced.sat[cur_orb_pos]
145                                         self.fillListWithAdvancedSatEntrys(currSat)
146                                 self.have_advanced = True
147                 elif self.nim.isCompatible("DVB-C"):
148                         self.configMode = getConfigListEntry(_("Configuration Mode"), self.nimConfig.configMode)
149                         self.list.append(self.configMode)
150                         if self.nimConfig.configMode.value == "enabled":
151                                 self.cableScanType=getConfigListEntry(_("Used service scan type"), self.nimConfig.cable.scan_type)
152                                 self.list.append(self.cableScanType)
153                                 if self.nimConfig.cable.scan_type.value == "provider":
154                                         self.list.append(getConfigListEntry(_("Provider to scan"), self.nimConfig.cable.scan_provider))
155                                 else:
156                                         if self.nimConfig.cable.scan_type.value == "bands":
157                                                 self.list.append(getConfigListEntry(_("Scan band EU VHF I"), self.nimConfig.cable.scan_band_EU_VHF_I))
158                                                 self.list.append(getConfigListEntry(_("Scan band EU MID"), self.nimConfig.cable.scan_band_EU_MID))
159                                                 self.list.append(getConfigListEntry(_("Scan band EU VHF III"), self.nimConfig.cable.scan_band_EU_VHF_III))
160                                                 self.list.append(getConfigListEntry(_("Scan band EU UHF IV"), self.nimConfig.cable.scan_band_EU_UHF_IV))
161                                                 self.list.append(getConfigListEntry(_("Scan band EU UHF V"), self.nimConfig.cable.scan_band_EU_UHF_V))
162                                                 self.list.append(getConfigListEntry(_("Scan band EU SUPER"), self.nimConfig.cable.scan_band_EU_SUPER))
163                                                 self.list.append(getConfigListEntry(_("Scan band EU HYPER"), self.nimConfig.cable.scan_band_EU_HYPER))
164                                                 self.list.append(getConfigListEntry(_("Scan band US LOW"), self.nimConfig.cable.scan_band_US_LOW))
165                                                 self.list.append(getConfigListEntry(_("Scan band US MID"), self.nimConfig.cable.scan_band_US_MID))
166                                                 self.list.append(getConfigListEntry(_("Scan band US HIGH"), self.nimConfig.cable.scan_band_US_HIGH))
167                                                 self.list.append(getConfigListEntry(_("Scan band US SUPER"), self.nimConfig.cable.scan_band_US_SUPER))
168                                                 self.list.append(getConfigListEntry(_("Scan band US HYPER"), self.nimConfig.cable.scan_band_US_HYPER))
169                                         elif self.nimConfig.cable.scan_type.value == "steps":
170                                                 self.list.append(getConfigListEntry(_("Frequency scan step size(khz)"), self.nimConfig.cable.scan_frequency_steps))
171                                         self.list.append(getConfigListEntry(_("Scan QAM16"), self.nimConfig.cable.scan_mod_qam16))
172                                         self.list.append(getConfigListEntry(_("Scan QAM32"), self.nimConfig.cable.scan_mod_qam32))
173                                         self.list.append(getConfigListEntry(_("Scan QAM64"), self.nimConfig.cable.scan_mod_qam64))
174                                         self.list.append(getConfigListEntry(_("Scan QAM128"), self.nimConfig.cable.scan_mod_qam128))
175                                         self.list.append(getConfigListEntry(_("Scan QAM256"), self.nimConfig.cable.scan_mod_qam256))
176                                         self.list.append(getConfigListEntry(_("Scan SR6900"), self.nimConfig.cable.scan_sr_6900))
177                                         self.list.append(getConfigListEntry(_("Scan SR6875"), self.nimConfig.cable.scan_sr_6875))
178                                         self.list.append(getConfigListEntry(_("Scan additional SR"), self.nimConfig.cable.scan_sr_ext1))
179                                         self.list.append(getConfigListEntry(_("Scan additional SR"), self.nimConfig.cable.scan_sr_ext2))
180                         self.have_advanced = False
181                 elif self.nim.isCompatible("DVB-T"):
182                         self.configMode = getConfigListEntry(_("Configuration Mode"), self.nimConfig.configMode)
183                         self.list.append(self.configMode)
184                         self.have_advanced = False
185                         if self.nimConfig.configMode.value == "enabled":
186                                 self.list.append(getConfigListEntry(_("Terrestrial provider"), self.nimConfig.terrestrial))
187                                 self.list.append(getConfigListEntry(_("Enable 5V for active antenna"), self.nimConfig.terrestrial_5V))
188                 else:
189                         self.have_advanced = False
190                 self["config"].list = self.list
191                 self["config"].l.setList(self.list)
192
193         def newConfig(self):
194                 checkList = (self.configMode, self.diseqcModeEntry, self.advancedSatsEntry, \
195                         self.advancedLnbsEntry, self.advancedDiseqcMode, self.advancedUsalsEntry, \
196                         self.advancedLof, self.advancedPowerMeasurement, self.turningSpeed, \
197                         self.advancedType, self.advancedSCR, self.advancedManufacturer, self.advancedUnicable, \
198                         self.uncommittedDiseqcCommand, self.cableScanType)
199                 for x in checkList:
200                         if self["config"].getCurrent() == x:
201                                 self.createSetup()
202
203         def run(self):
204                 if self.have_advanced and self.nim.config_mode == "advanced":
205                         self.fillAdvancedList()
206                 for x in self.list:
207                         if x in (self.turnFastEpochBegin, self.turnFastEpochEnd):
208                                 # workaround for storing only hour*3600+min*60 value in configfile
209                                 # not really needed.. just for cosmetics..
210                                 tm = localtime(x[1].value)
211                                 dt = datetime(1970, 1, 1, tm.tm_hour, tm.tm_min)
212                                 x[1].value = int(mktime(dt.timetuple()))
213                         x[1].save()
214                 nimmanager.sec.update()
215                 self.saveAll()
216
217         def fillListWithAdvancedSatEntrys(self, Sat):
218                 lnbnum = int(Sat.lnb.value)
219                 currLnb = self.nimConfig.advanced.lnb[lnbnum]
220                 
221                 if isinstance(currLnb, ConfigNothing):
222                         currLnb = None
223
224                 # LNBs
225                 self.advancedLnbsEntry = getConfigListEntry(_("LNB"), Sat.lnb)
226                 self.list.append(self.advancedLnbsEntry)
227
228                 if currLnb:
229                         self.list.append(getConfigListEntry(_("Priority"), currLnb.prio))
230                         self.advancedLof = getConfigListEntry(_("LOF"), currLnb.lof)
231                         self.list.append(self.advancedLof)
232                         if currLnb.lof.value == "user_defined":
233                                 self.list.append(getConfigListEntry(_("LOF/L"), currLnb.lofl))
234                                 self.list.append(getConfigListEntry(_("LOF/H"), currLnb.lofh))
235                                 self.list.append(getConfigListEntry(_("Threshold"), currLnb.threshold))
236 #                       self.list.append(getConfigListEntry(_("12V Output"), currLnb.output_12v))
237                         
238                         if currLnb.lof.value == "unicable":
239                                 self.advancedUnicable = getConfigListEntry("Unicable "+_("Configuration Mode"), currLnb.unicable)
240                                 self.list.append(self.advancedUnicable)
241                                 if currLnb.unicable.value == "unicable_user":
242                                         self.advancedSCR = getConfigListEntry(_("Channel"), currLnb.satcruser)
243                                         self.list.append(self.advancedSCR)
244                                         self.list.append(getConfigListEntry(_("Frequency"), currLnb.satcrvcouser[currLnb.satcruser.index]))
245                                         self.list.append(getConfigListEntry(_("LOF/L"), currLnb.lofl))
246                                         self.list.append(getConfigListEntry(_("LOF/H"), currLnb.lofh))
247                                         self.list.append(getConfigListEntry(_("Threshold"), currLnb.threshold))
248                                 elif currLnb.unicable.value == "unicable_matrix":
249                                         manufacturer_name = currLnb.unicableMatrixManufacturer.value
250                                         manufacturer = currLnb.unicableMatrix[manufacturer_name]
251                                         product_name = manufacturer.product.value
252                                         self.advancedManufacturer = getConfigListEntry(_("Manufacturer"), currLnb.unicableMatrixManufacturer)
253                                         self.advancedType = getConfigListEntry(_("Type"), manufacturer.product)
254                                         self.advancedSCR = getConfigListEntry(_("Channel"), manufacturer.scr[product_name])
255                                         self.list.append(self.advancedManufacturer)
256                                         self.list.append(self.advancedType)
257                                         self.list.append(self.advancedSCR)
258                                         self.list.append(getConfigListEntry(_("Frequency"), manufacturer.vco[product_name][manufacturer.scr[product_name].index])) 
259                                 elif currLnb.unicable.value == "unicable_lnb":
260                                         manufacturer_name = currLnb.unicableLnbManufacturer.value
261                                         manufacturer = currLnb.unicableLnb[manufacturer_name]
262                                         product_name = manufacturer.product.value
263                                         self.advancedManufacturer = getConfigListEntry(_("Manufacturer"), currLnb.unicableLnbManufacturer)
264                                         self.advancedType = getConfigListEntry(_("Type"), manufacturer.product)
265                                         self.advancedSCR = getConfigListEntry(_("Channel"), manufacturer.scr[product_name])
266                                         self.list.append(self.advancedManufacturer)
267                                         self.list.append(self.advancedType)
268                                         self.list.append(self.advancedSCR)
269                                         self.list.append(getConfigListEntry(_("Frequency"), manufacturer.vco[product_name][manufacturer.scr[product_name].index])) 
270                         else:   #kein Unicable
271                                 self.list.append(getConfigListEntry(_("Voltage mode"), Sat.voltage))
272                                 self.list.append(getConfigListEntry(_("Increased voltage"), currLnb.increased_voltage))
273                                 self.list.append(getConfigListEntry(_("Tone mode"), Sat.tonemode))
274
275                         if lnbnum < 33:
276                                 self.advancedDiseqcMode = getConfigListEntry(_("DiSEqC mode"), currLnb.diseqcMode)
277                                 self.list.append(self.advancedDiseqcMode)
278                         if currLnb.diseqcMode.value != "none":
279                                 self.list.append(getConfigListEntry(_("Toneburst"), currLnb.toneburst))
280                                 self.list.append(getConfigListEntry(_("Committed DiSEqC command"), currLnb.commitedDiseqcCommand))
281                                 self.list.append(getConfigListEntry(_("Fast DiSEqC"), currLnb.fastDiseqc))
282                                 self.list.append(getConfigListEntry(_("Sequence repeat"), currLnb.sequenceRepeat))
283                                 if currLnb.diseqcMode.value == "1_0":
284                                         self.list.append(getConfigListEntry(_("Command order"), currLnb.commandOrder1_0))
285                                 else:
286                                         if currLnb.uncommittedDiseqcCommand.index:
287                                                 if currLnb.commandOrder.value == "ct":
288                                                         currLnb.commandOrder.value = "cut"
289                                                 elif currLnb.commandOrder.value == "tc":
290                                                         currLnb.commandOrder.value = "tcu"
291                                         else:
292                                                 if currLnb.commandOrder.index & 1:
293                                                         currLnb.commandOrder.value = "tc"
294                                                 else:
295                                                         currLnb.commandOrder.value = "ct"
296                                         self.list.append(getConfigListEntry(_("Command order"), currLnb.commandOrder))
297                                         self.uncommittedDiseqcCommand = getConfigListEntry(_("Uncommitted DiSEqC command"), currLnb.uncommittedDiseqcCommand)
298                                         self.list.append(self.uncommittedDiseqcCommand)
299                                         self.list.append(getConfigListEntry(_("DiSEqC repeats"), currLnb.diseqcRepeats))
300                                 if currLnb.diseqcMode.value == "1_2":
301                                         self.list.append(getConfigListEntry(_("Longitude"), currLnb.longitude))
302                                         self.list.append(getConfigListEntry(" ", currLnb.longitudeOrientation))
303                                         self.list.append(getConfigListEntry(_("Latitude"), currLnb.latitude))
304                                         self.list.append(getConfigListEntry(" ", currLnb.latitudeOrientation))
305                                         if SystemInfo["CanMeasureFrontendInputPower"]:
306                                                 self.advancedPowerMeasurement = getConfigListEntry(_("Use Power Measurement"), currLnb.powerMeasurement)
307                                                 self.list.append(self.advancedPowerMeasurement)
308                                                 if currLnb.powerMeasurement.value:
309                                                         self.list.append(getConfigListEntry(_("Power threshold in mA"), currLnb.powerThreshold))
310                                                         self.turningSpeed = getConfigListEntry(_("Rotor turning speed"), currLnb.turningSpeed)
311                                                         self.list.append(self.turningSpeed)
312                                                         if currLnb.turningSpeed.value == "fast epoch":
313                                                                 self.turnFastEpochBegin = getConfigListEntry(_("Begin time"), currLnb.fastTurningBegin)
314                                                                 self.turnFastEpochEnd = getConfigListEntry(_("End time"), currLnb.fastTurningEnd)
315                                                                 self.list.append(self.turnFastEpochBegin)
316                                                                 self.list.append(self.turnFastEpochEnd)
317                                         else:
318                                                 if currLnb.powerMeasurement.value:
319                                                         currLnb.powerMeasurement.value = False
320                                                         currLnb.powerMeasurement.save()
321                                         self.advancedUsalsEntry = getConfigListEntry(_("Use usals for this sat"), Sat.usals)
322                                         self.list.append(self.advancedUsalsEntry)
323                                         if not Sat.usals.value:
324                                                 self.list.append(getConfigListEntry(_("Stored position"), Sat.rotorposition))
325
326         
327
328         def fillAdvancedList(self):
329                 self.list = [ ]
330                 self.configMode = getConfigListEntry(_("Configuration Mode"), self.nimConfig.configMode)
331                 self.list.append(self.configMode)
332                 self.advancedSatsEntry = getConfigListEntry(_("Satellite"), self.nimConfig.advanced.sats)
333                 self.list.append(self.advancedSatsEntry)
334                 for x in self.nimConfig.advanced.sat.keys():
335                         Sat = self.nimConfig.advanced.sat[x]
336                         self.fillListWithAdvancedSatEntrys(Sat)
337                 self["config"].list = self.list
338
339         def keySave(self):
340                 old_configured_sats = nimmanager.getConfiguredSats()
341                 self.run()
342                 new_configured_sats = nimmanager.getConfiguredSats()
343                 self.unconfed_sats = old_configured_sats - new_configured_sats
344                 self.satpos_to_remove = None
345                 self.deleteConfirmed(False)
346
347         def deleteConfirmed(self, confirmed):
348                 if confirmed:
349                         eDVBDB.getInstance().removeServices(-1, -1, -1, self.satpos_to_remove)
350
351                 if self.satpos_to_remove is not None:
352                         self.unconfed_sats.remove(self.satpos_to_remove)
353
354                 self.satpos_to_remove = None
355                 for orbpos in self.unconfed_sats:
356                         self.satpos_to_remove = orbpos
357                         orbpos = self.satpos_to_remove
358                         try:
359                                 # why we need this cast?
360                                 sat_name = str(nimmanager.getSatDescription(orbpos))
361                         except:
362                                 if orbpos > 1800: # west
363                                         orbpos = 3600 - orbpos
364                                         h = _("W")
365                                 else:
366                                         h = _("E")
367                                 sat_name = ("%d.%d" + h) % (orbpos / 10, orbpos % 10)
368                         self.session.openWithCallback(self.deleteConfirmed, MessageBox, _("Delete no more configured satellite\n%s?") %(sat_name))
369                         break
370                 if not self.satpos_to_remove:
371                         self.close()
372
373         def __init__(self, session, slotid):
374                 Screen.__init__(self, session)
375                 self.list = [ ]
376
377                 ConfigListScreen.__init__(self, self.list)
378
379                 self["actions"] = ActionMap(["SetupActions"],
380                 {
381                         "ok": self.keySave,
382                         "cancel": self.keyCancel,
383                 }, -2)
384
385                 self.slotid = slotid
386                 self.nim = nimmanager.nim_slots[slotid]
387                 self.nimConfig = self.nim.config
388                 self.createConfigMode()
389                 self.createSetup()
390
391         def keyLeft(self):
392                 ConfigListScreen.keyLeft(self)
393                 self.newConfig()
394
395         def keyRight(self):
396                 ConfigListScreen.keyRight(self)
397                 self.newConfig()
398                 
399         def saveAll(self):
400                 if self.nim.isCompatible("DVB-S"):
401                         # reset connectedTo to all choices to properly store the default value
402                         choices = []
403                         nimlist = nimmanager.getNimListOfType("DVB-S", self.slotid)
404                         for id in nimlist:
405                                 choices.append((str(id), nimmanager.getNimDescription(id)))
406                         self.nimConfig.connectedTo.setChoices(choices)
407                 for x in self["config"].list:
408                         x[1].save()
409                         
410         def cancelConfirm(self, result):
411                 if not result:
412                         return
413
414                 for x in self["config"].list:
415                         x[1].cancel()
416                 # we need to call saveAll to reset the connectedTo choices
417                 self.saveAll()
418                 self.close()
419                         
420 class NimSelection(Screen):
421         def __init__(self, session):
422                 Screen.__init__(self, session)
423                 
424                 self.list = [None] * nimmanager.getSlotCount()
425                 self["nimlist"] = List(self.list)
426                 self.updateList()
427                 
428                 self.setResultClass()
429
430                 self["actions"] = ActionMap(["OkCancelActions"],
431                 {
432                         "ok": self.okbuttonClick ,
433                         "cancel": self.close
434                 }, -2)
435                 
436         def setResultClass(self):
437                 self.resultclass = NimSetup
438
439         def okbuttonClick(self):
440                 nim = self["nimlist"].getCurrent()
441                 nim = nim and nim[3]
442                 if nim is not None and not nim.empty:
443                         self.session.openWithCallback(self.updateList, self.resultclass, nim.slot)
444                         
445         def showNim(self, nim):
446                 return True
447
448         def updateList(self):
449                 self.list = [ ]
450                 for x in nimmanager.nim_slots:
451                         slotid = x.slot
452                         nimConfig = nimmanager.getNimConfig(x.slot)
453                         text = nimConfig.configMode.value
454                         if self.showNim(x):
455                                 if x.isCompatible("DVB-S"):
456                                         if nimConfig.configMode.value in ("loopthrough", "equal", "satposdepends"):
457                                                 text = { "loopthrough": _("loopthrough to"),
458                                                                  "equal": _("equal to"),
459                                                                  "satposdepends": _("second cable of motorized LNB") } [nimConfig.configMode.value]
460                                                 text += " " + _("Tuner") + " " + ["A", "B", "C", "D"][int(nimConfig.connectedTo.value)]
461                                         elif nimConfig.configMode.value == "nothing":
462                                                 text = _("nothing connected")
463                                         elif nimConfig.configMode.value == "simple":
464                                                 if nimConfig.diseqcMode.value in ("single", "toneburst_a_b", "diseqc_a_b", "diseqc_a_b_c_d"):
465                                                         text = _("Sats") + ": " 
466                                                         if nimConfig.diseqcA.orbital_position != 3601:
467                                                                 text += nimmanager.getSatName(int(nimConfig.diseqcA.value))
468                                                         if nimConfig.diseqcMode.value in ("toneburst_a_b", "diseqc_a_b", "diseqc_a_b_c_d"):
469                                                                 if nimConfig.diseqcB.orbital_position != 3601:
470                                                                         text += "," + nimmanager.getSatName(int(nimConfig.diseqcB.value))
471                                                         if nimConfig.diseqcMode.value == "diseqc_a_b_c_d":
472                                                                 if nimConfig.diseqcC.orbital_position != 3601:
473                                                                         text += "," + nimmanager.getSatName(int(nimConfig.diseqcC.value))
474                                                                 if nimConfig.diseqcD.orbital_position != 3601:
475                                                                         text += "," + nimmanager.getSatName(int(nimConfig.diseqcD.value))
476                                                 elif nimConfig.diseqcMode.value == "positioner":
477                                                         text = _("Positioner") + ":"
478                                                         if nimConfig.positionerMode.value == "usals":
479                                                                 text += _("USALS")
480                                                         elif nimConfig.positionerMode.value == "manual":
481                                                                 text += _("manual")
482                                                 else:   
483                                                         text = _("simple")
484                                         elif nimConfig.configMode.value == "advanced":
485                                                 text = _("advanced")
486                                 elif x.isCompatible("DVB-T") or x.isCompatible("DVB-C"):
487                                         if nimConfig.configMode.value == "nothing":
488                                                 text = _("nothing connected")
489                                         elif nimConfig.configMode.value == "enabled":
490                                                 text = _("enabled")
491                                         
492                                 self.list.append((slotid, x.friendly_full_description, text, x))
493                 self["nimlist"].setList(self.list)
494                 self["nimlist"].updateList(self.list)