another change of policy (with correct aspect ratio)
[enigma2.git] / lib / python / Screens / ScanSetup.py
1 from Screen import Screen
2 from ServiceScan import ServiceScan
3 from Components.config import config, ConfigSubsection, ConfigSelection, \
4         ConfigYesNo, ConfigInteger, getConfigListEntry, ConfigSlider, ConfigEnableDisable
5 from Components.ActionMap import NumberActionMap, ActionMap
6 from Components.ConfigList import ConfigListScreen
7 from Components.NimManager import nimmanager, getConfigSatlist
8 from Components.Label import Label
9 from Screens.MessageBox import MessageBox
10 from enigma import eTimer, eDVBFrontendParametersSatellite, eComponentScan, \
11         eDVBSatelliteEquipmentControl, eDVBFrontendParametersTerrestrial, \
12         eDVBFrontendParametersCable, eConsoleAppContainer, eDVBResourceManager
13
14 def buildTerTransponder(frequency, 
15                 inversion=2, bandwidth = 3, fechigh = 6, feclow = 6,
16                 modulation = 2, transmission = 2, guard = 4,
17                 hierarchy = 4):
18
19 #       print "freq", frequency, "inv", inversion, "bw", bandwidth, "fech", fechigh, "fecl", feclow, "mod", modulation, "tm", transmission, "guard", guard, "hierarchy", hierarchy
20
21         # WARNING: normally, enums are working directly.
22         # Don't copy this (very bad)!! Instead either fix swig (good) or
23         # move this into a central place.
24         Bw8MHz = 0
25         Bw7MHz = 1
26         Bw6MHz = 2
27         #Bw5MHz = 3 #not implemented for e1 compatibilty
28         BwAuto = 3
29         
30         f1_2 = 0
31         f2_3 = 1
32         f3_4 = 2
33         f5_6 = 3
34         f7_8 = 4
35         fAuto = 5
36         
37         TM2k = 0
38         TM8k = 1
39         #TM4k = 2  #not implemented for e1 compatibilty
40         TMAuto = 2
41         
42         GI_1_32 = 0
43         GI_1_16 = 1
44         GI_1_8 = 2
45         GI_1_4 = 3
46         GI_Auto = 4
47         
48         HNone = 0
49         H1 = 1
50         H2 = 2
51         H4 = 3
52         HAuto = 4
53
54         QPSK = 0
55         QAM16 = 1
56         QAM64 = 2
57         Auto = 3
58         
59         Off = 0
60         On = 1
61         Unknown = 2
62
63         parm = eDVBFrontendParametersTerrestrial()
64
65         parm.frequency = frequency
66
67         parm.inversion = [Off, On, Unknown][inversion]
68         parm.bandwidth = [Bw8MHz, Bw7MHz, Bw6MHz, BwAuto][bandwidth] # Bw5MHz unsupported
69         parm.code_rate_HP = [f1_2, f2_3, f3_4, f5_6, f7_8, fAuto][fechigh]
70         parm.code_rate_LP = [f1_2, f2_3, f3_4, f5_6, f7_8, fAuto][feclow]
71         parm.modulation = [QPSK, QAM16, QAM64, Auto][modulation]
72         parm.transmission_mode = [TM2k, TM8k, TMAuto][transmission] # TM4k unsupported
73         parm.guard_interval = [GI_1_32, GI_1_16, GI_1_8, GI_1_4, GI_Auto][guard]
74         parm.hierarchy = [HNone, H1, H2, H4, HAuto][hierarchy]
75         
76         return parm
77
78 def getInitialTransponderList(tlist, pos):
79         list = nimmanager.getTransponders(pos)
80         for x in list:
81                 if x[0] == 0:           #SAT
82                         parm = eDVBFrontendParametersSatellite()
83                         parm.frequency = x[1]
84                         parm.symbol_rate = x[2]
85                         parm.polarisation = x[3]
86                         parm.fec = x[4]
87                         parm.inversion = 2 # AUTO
88                         parm.orbital_position = pos
89                         parm.system = x[5]
90                         parm.modulation = x[6]
91                         tlist.append(parm)
92
93 def getInitialCableTransponderList(tlist, nim):
94         list = nimmanager.getTranspondersCable(nim)
95         for x in list:
96                 if x[0] == 1: #CABLE
97                         parm = eDVBFrontendParametersCable()
98                         parm.frequency = x[1]
99                         parm.symbol_rate = x[2]
100                         parm.modulation = x[3]
101                         parm.fec_inner = x[4]
102                         parm.inversion = 2 # AUTO
103                         #print "frequency:", x[1]
104                         #print "symbol_rate:", x[2]
105                         #print "modulation:", x[3]
106                         #print "fec_inner:", x[4]
107                         #print "inversion:", 2
108                         tlist.append(parm)
109
110 def getInitialTerrestrialTransponderList(tlist, region):
111         list = nimmanager.getTranspondersTerrestrial(region)
112
113         #self.transponders[self.parsedTer].append((2,freq,bw,const,crh,crl,guard,transm,hierarchy,inv))
114
115         #def buildTerTransponder(frequency, inversion = 2, bandwidth = 3, fechigh = 6, feclow = 6,
116                                 #modulation = 2, transmission = 2, guard = 4, hierarchy = 4):
117
118         for x in list:
119                 if x[0] == 2: #TERRESTRIAL
120                         parm = buildTerTransponder(x[1], x[9], x[2], x[4], x[5], x[3], x[7], x[6], x[8])
121                         tlist.append(parm)
122
123 cable_bands = {
124         "DVBC_BAND_EU_VHF_I" : 1 << 0,
125         "DVBC_BAND_EU_MID" : 1 << 1,
126         "DVBC_BAND_EU_VHF_III" : 1 << 2,
127         "DVBC_BAND_EU_SUPER" : 1 << 3,
128         "DVBC_BAND_EU_HYPER" : 1 << 4,
129         "DVBC_BAND_EU_UHF_IV" : 1 << 5,
130         "DVBC_BAND_EU_UHF_V" : 1 << 6,
131         "DVBC_BAND_US_LO" : 1 << 7,
132         "DVBC_BAND_US_MID" : 1 << 8,
133         "DVBC_BAND_US_HI" : 1 << 9,
134         "DVBC_BAND_US_SUPER" : 1 << 10,
135         "DVBC_BAND_US_HYPER" : 1 << 11,
136 }
137
138 class CableTransponderSearchSupport:
139 #       def setCableTransponderSearchResult(self, tlist):
140 #               pass
141
142 #       def cableTransponderSearchFinished(self):
143 #               pass
144
145         def tryGetRawFrontend(self, feid):
146                 res_mgr = eDVBResourceManager.getInstance()
147                 if res_mgr:
148                         raw_channel = res_mgr.allocateRawChannel(self.feid)
149                         if raw_channel:
150                                 frontend = raw_channel.getFrontend()
151                                 if frontend:
152                                         del frontend
153                                         del raw_channel
154                                         return True
155                 return False
156
157         def cableTransponderSearchSessionClosed(self, *val):
158                 print "cableTransponderSearchSessionClosed, val", val
159                 self.cable_search_container.appClosed.get().remove(self.cableTransponderSearchClosed)
160                 self.cable_search_container.dataAvail.get().remove(self.getCableTransponderData)
161                 self.cable_search_container = None
162                 self.cable_search_session = None
163                 if val and len(val) and val[0]:
164                         self.setCableTransponderSearchResult(self.__tlist)
165                 self.__tlist = None
166                 self.cableTransponderSearchFinished()
167
168         def cableTransponderSearchClosed(self, retval):
169                 print "cableTransponderSearch finished", retval
170                 self.cable_search_session.close(True)
171
172         def getCableTransponderData(self, str):
173                 data = str.split()
174                 if len(data):
175                         if data[0] == 'OK':
176                                 print str
177                                 qam = { "QAM16" : 1, "QAM32" : 2, "QAM64" : 3, "QAM128" : 4, "QAM256" : 5 }
178                                 inv = { "INVERSION_OFF" : 0, "INVERSION_ON" : 1 }
179                                 fec = { "FEC_AUTO" : 0, "FEC_1_2" : 1, "FEC_2_3" : 2, "FEC_3_4" : 3, "FEC_5_6": 4, "FEC_7_8" : 5, "FEC_8_9" : 6, "FEC_NONE" : 15 }
180                                 parm = eDVBFrontendParametersCable()
181                                 parm.frequency = int(data[1])
182                                 parm.symbol_rate = int(data[2])
183                                 parm.fec_inner = fec[data[3]]
184                                 parm.modulation = qam[data[4]]
185                                 parm.inversion = inv[data[5]]
186                                 self.__tlist.append(parm)
187                 tmpstr = _("Try to find used Transponders in cable network.. please wait...")
188                 tmpstr += "\n\n"
189                 tmpstr += data[1]
190                 tmpstr += " kHz "
191                 tmpstr += data[0]
192                 self.cable_search_session["text"].setText(tmpstr)
193
194         def startCableTransponderSearch(self, nim_idx):
195                 if not self.tryGetRawFrontend(nim_idx):
196                         self.session.nav.stopService()
197                         if not self.tryGetRawFrontend(nim_idx):
198                                 if self.session.pipshown: # try to disable pip
199                                         self.session.pipshown = False
200                                         del self.session.pip
201                                 if not self.tryGetRawFrontend(nim_idx):
202                                         self.cableTransponderSearchFinished()
203                                         return
204                 self.__tlist = [ ]
205                 self.cable_search_container = eConsoleAppContainer()
206                 self.cable_search_container.appClosed.get().append(self.cableTransponderSearchClosed)
207                 self.cable_search_container.dataAvail.get().append(self.getCableTransponderData)
208                 cableConfig = config.Nims[nim_idx].cable
209                 cmd = "tda1002x --init --scan --verbose --wakeup --inv 2 --bus "
210                 #FIXMEEEEEE hardcoded i2c devices for dm7025 and dm8000
211                 if nim_idx < 2:
212                         cmd += str(nim_idx)
213                 else:
214                         if nim_idx == 2:
215                                 cmd += "2" # first nim socket on DM8000 use /dev/i2c/2
216                         else:
217                                 cmd += "4" # second nim socket on DM8000 use /dev/i2c/4
218                 if cableConfig.scan_type.value == "bands":
219                         cmd += " --scan-bands "
220                         bands = 0
221                         if cableConfig.scan_band_EU_VHF_I.value:
222                                 bands |= cable_bands["DVBC_BAND_EU_VHF_I"]
223                         if cableConfig.scan_band_EU_MID.value:
224                                 bands |= cable_bands["DVBC_BAND_EU_MID"]
225                         if cableConfig.scan_band_EU_VHF_III.value:
226                                 bands |= cable_bands["DVBC_BAND_EU_VHF_III"]
227                         if cableConfig.scan_band_EU_UHF_IV.value:
228                                 bands |= cable_bands["DVBC_BAND_EU_UHF_IV"]
229                         if cableConfig.scan_band_EU_UHF_V.value:
230                                 bands |= cable_bands["DVBC_BAND_EU_UHF_V"]
231                         if cableConfig.scan_band_EU_SUPER.value:
232                                 bands |= cable_bands["DVBC_BAND_EU_SUPER"]
233                         if cableConfig.scan_band_EU_HYPER.value:
234                                 bands |= cable_bands["DVBC_BAND_EU_HYPER"]
235                         if cableConfig.scan_band_US_LOW.value:
236                                 bands |= cable_bands["DVBC_BAND_US_LO"]
237                         if cableConfig.scan_band_US_MID.value:
238                                 bands |= cable_bands["DVBC_BAND_US_MID"]
239                         if cableConfig.scan_band_US_HIGH.value:
240                                 bands |= cable_bands["DVBC_BAND_US_HI"]
241                         if cableConfig.scan_band_US_SUPER.value:
242                                 bands |= cable_bands["DVBC_BAND_US_SUPER"]
243                         if cableConfig.scan_band_US_HYPER.value:
244                                 bands |= cable_bands["DVBC_BAND_US_HYPER"]
245                         cmd += str(bands)
246                 else:
247                         cmd += " --scan-stepsize "
248                         cmd += str(cableConfig.scan_frequency_steps.value)
249                 if cableConfig.scan_mod_qam16.value:
250                         cmd += " --mod 16"
251                 if cableConfig.scan_mod_qam32.value:
252                         cmd += " --mod 32"
253                 if cableConfig.scan_mod_qam64.value:
254                         cmd += " --mod 64"
255                 if cableConfig.scan_mod_qam128.value:
256                         cmd += " --mod 128"
257                 if cableConfig.scan_mod_qam256.value:
258                         cmd += " --mod 256"
259                 if cableConfig.scan_sr_6900.value:
260                         cmd += " --sr 6900000"
261                 if cableConfig.scan_sr_6875.value:
262                         cmd += " --sr 6875000"
263                 if cableConfig.scan_sr_ext1.value > 450:
264                         cmd += " --sr "
265                         cmd += str(cableConfig.scan_sr_ext1.value)
266                         cmd += "000"
267                 if cableConfig.scan_sr_ext2.value > 450:
268                         cmd += " --sr "
269                         cmd += str(cableConfig.scan_sr_ext2.value)
270                         cmd += "000"
271                 print "TDA1002x CMD is", cmd
272
273                 self.cable_search_container.execute(cmd)
274                 tmpstr = _("Try to find used transponders in cable network.. please wait...")
275                 tmpstr += "\n\n..."
276                 self.cable_search_session = self.session.openWithCallback(self.cableTransponderSearchSessionClosed, MessageBox, tmpstr, MessageBox.TYPE_INFO)
277
278 class ScanSetup(ConfigListScreen, Screen, CableTransponderSearchSupport):
279         def __init__(self, session):
280                 Screen.__init__(self, session)
281
282                 self.finished_cb = None
283                 self.updateSatList()
284                 self.service = session.nav.getCurrentService()
285                 self.feinfo = None
286                 frontendData = None
287                 if self.service is not None:
288                         self.feinfo = self.service.frontendInfo()
289                         frontendData = self.feinfo and self.feinfo.getAll(True)
290                 
291                 self.createConfig(frontendData)
292
293                 del self.feinfo
294                 del self.service
295
296                 self["actions"] = NumberActionMap(["SetupActions"],
297                 {
298                         "ok": self.keyGo,
299                         "cancel": self.keyCancel,
300                 }, -2)
301
302                 self.statusTimer = eTimer()
303                 self.statusTimer.callback.append(self.updateStatus)
304                 #self.statusTimer.start(5000, True)
305
306                 self.list = []
307                 ConfigListScreen.__init__(self, self.list)
308                 self.createSetup()
309
310                 self["introduction"] = Label(_("Press OK to start the scan"))
311
312         def runAsync(self, finished_cb):
313                 self.finished_cb = finished_cb
314                 self.keyGo()
315
316         def updateSatList(self):
317                 self.satList = []
318                 for slot in nimmanager.nim_slots:
319                         if slot.isCompatible("DVB-S"):
320                                 self.satList.append(nimmanager.getSatListForNim(slot.slot))
321                         else:
322                                 self.satList.append(None)
323
324         def createSetup(self):
325                 self.list = []
326                 self.multiscanlist = []
327                 index_to_scan = int(self.scan_nims.value)
328                 print "ID: ", index_to_scan
329
330                 self.tunerEntry = getConfigListEntry(_("Tuner"), self.scan_nims)
331                 self.list.append(self.tunerEntry)
332                 
333                 if self.scan_nims == [ ]:
334                         return
335                 
336                 self.typeOfScanEntry = None
337                 self.systemEntry = None
338                 nim = nimmanager.nim_slots[index_to_scan]
339                 if nim.isCompatible("DVB-S"):
340                         self.typeOfScanEntry = getConfigListEntry(_("Type of scan"), self.scan_type)
341                         self.list.append(self.typeOfScanEntry)
342                 elif nim.isCompatible("DVB-C"):
343                         self.typeOfScanEntry = getConfigListEntry(_("Type of scan"), self.scan_typecable)
344                         self.list.append(self.typeOfScanEntry)
345                 elif nim.isCompatible("DVB-T"):
346                         self.typeOfScanEntry = getConfigListEntry(_("Type of scan"), self.scan_typeterrestrial)
347                         self.list.append(self.typeOfScanEntry)
348
349                 if nim.isCompatible("DVB-S"):
350                         if self.scan_type.value == "single_transponder":
351                                 self.updateSatList()
352                                 if nim.isCompatible("DVB-S2"):
353                                         self.systemEntry = getConfigListEntry(_('System'), self.scan_sat.system)
354                                         self.list.append(self.systemEntry)
355                                 else:
356                                         # downgrade to dvb-s, in case a -s2 config was active
357                                         self.scan_sat.system.value = "dvb-s"
358                                 self.list.append(getConfigListEntry(_('Satellite'), self.scan_satselection[index_to_scan]))
359                                 self.list.append(getConfigListEntry(_('Frequency'), self.scan_sat.frequency))
360                                 self.list.append(getConfigListEntry(_('Inversion'), self.scan_sat.inversion))
361                                 self.list.append(getConfigListEntry(_('Symbol Rate'), self.scan_sat.symbolrate))
362                                 self.list.append(getConfigListEntry(_("Polarity"), self.scan_sat.polarization))
363                                 if self.scan_sat.system.value == "dvb-s":
364                                         self.list.append(getConfigListEntry(_("FEC"), self.scan_sat.fec))
365                                 elif self.scan_sat.system.value == "dvb-s2":
366                                         self.list.append(getConfigListEntry(_("FEC"), self.scan_sat.fec_s2))
367                                         self.list.append(getConfigListEntry(_('Modulation'), self.scan_sat.modulation))
368                                 self.list.append(getConfigListEntry(_("Network scan"), self.scan_networkScan))
369                         elif self.scan_type.value == "single_satellite":
370                                 self.updateSatList()
371                                 print self.scan_satselection[index_to_scan]
372                                 self.list.append(getConfigListEntry(_("Satellite"), self.scan_satselection[index_to_scan]))
373                                 self.list.append(getConfigListEntry(_("Clear before scan"), self.scan_clearallservices))
374                         elif self.scan_type.value == "multisat":
375                                 # if (norotor)
376                                 tlist = []
377                                 SatList = nimmanager.getSatListForNim(index_to_scan)
378                                 self.list.append(getConfigListEntry(_("Clear before scan"), self.scan_clearallservices))
379                                 for x in SatList:
380                                         if self.Satexists(tlist, x[0]) == 0:
381                                                 tlist.append(x[0])
382                                                 sat = ConfigEnableDisable(default = True)
383                                                 configEntry = getConfigListEntry(nimmanager.getSatDescription(x[0]), sat)
384                                                 self.list.append(configEntry)
385                                                 self.multiscanlist.append((x[0], sat))
386                                 # if (rotor):
387                            # for sat in nimmanager.satList:
388                                 #       self.list.append(getConfigListEntry(sat[1], self.scan_scansat[sat[0]]))
389                 elif nim.isCompatible("DVB-C"):
390                         if self.scan_typecable.value == "single_transponder":
391                                 self.list.append(getConfigListEntry(_("Frequency"), self.scan_cab.frequency))
392                                 self.list.append(getConfigListEntry(_("Inversion"), self.scan_cab.inversion))
393                                 self.list.append(getConfigListEntry(_("Symbol Rate"), self.scan_cab.symbolrate))
394                                 self.list.append(getConfigListEntry(_("Modulation"), self.scan_cab.modulation))
395                                 self.list.append(getConfigListEntry(_("FEC"), self.scan_cab.fec))
396                                 self.list.append(getConfigListEntry(_("Network scan"), self.scan_networkScan))
397                         elif self.scan_typecable.value == "complete":
398                                 self.list.append(getConfigListEntry(_("Clear before scan"), self.scan_clearallservices))
399                 elif nim.isCompatible("DVB-T"):
400                         if self.scan_typeterrestrial.value == "single_transponder":
401                                 self.list.append(getConfigListEntry(_("Frequency"), self.scan_ter.frequency))
402                                 self.list.append(getConfigListEntry(_("Inversion"), self.scan_ter.inversion))
403                                 self.list.append(getConfigListEntry(_("Bandwidth"), self.scan_ter.bandwidth))
404                                 self.list.append(getConfigListEntry(_("Code rate high"), self.scan_ter.fechigh))
405                                 self.list.append(getConfigListEntry(_("Code rate low"), self.scan_ter.feclow))
406                                 self.list.append(getConfigListEntry(_("Modulation"), self.scan_ter.modulation))
407                                 self.list.append(getConfigListEntry(_("Transmission mode"), self.scan_ter.transmission))
408                                 self.list.append(getConfigListEntry(_("Guard interval mode"), self.scan_ter.guard))
409                                 self.list.append(getConfigListEntry(_("Hierarchy mode"), self.scan_ter.hierarchy))
410                                 self.list.append(getConfigListEntry(_("Network scan"), self.scan_networkScan))
411                         elif self.scan_typeterrestrial.value == "complete":
412                                 self.list.append(getConfigListEntry(_("Clear before scan"), self.scan_clearallservices))
413
414 #               if (nim.isCompatible("DVB-S") and self.scan_type.type == "single_transponder") or \
415 #                       (nim.isCompatbile("DVB-C") and self.scan_typecable.type == "single_transponder") or \
416 #                       (nim.isCompatible("DVB-T") and self.scan_typeterrestrial.type == "single_transponder"):
417 #                               self.configElementSNR = getConfigListEntry(_("SNR"), self.scan_snr)
418 #                               self.list.append(self.configElementSNR)
419 #                               self.configElementACG = getConfigListEntry(_("AGC"), self.scan_agc)
420 #                               self.list.append(self.configElementACG)
421 #                               self.configElementBER = getConfigListEntry(_("BER"), self.scan_ber)
422 #                               self.list.append(self.configElementBER)
423 #                               self.statusTimer.start(500, False)
424 #               else:
425 #                       self.statusTimer.stop()
426
427                 self["config"].list = self.list
428                 self["config"].l.setList(self.list)
429
430         def Satexists(self, tlist, pos):
431                 for x in tlist:
432                         if x == pos:
433                                 return 1
434                 return 0
435
436         def newConfig(self):
437                 cur = self["config"].getCurrent()
438                 print "cur is", cur
439                 if cur == self.typeOfScanEntry or \
440                         cur == self.tunerEntry or \
441                         cur == self.systemEntry:
442                         self.createSetup()
443
444         def createConfig(self, frontendData):
445                                                            #("Type", frontendData["system"], TYPE_TEXT),
446                                            #("Modulation", frontendData["modulation"], TYPE_TEXT),
447                                            #("Orbital position", frontendData["orbital_position"], TYPE_VALUE_DEC),
448                                            #("Frequency", frontendData["frequency"], TYPE_VALUE_DEC),
449                                            #("Symbolrate", frontendData["symbol_rate"], TYPE_VALUE_DEC),
450                                            #("Polarization", frontendData["polarization"], TYPE_TEXT),
451                                            #("Inversion", frontendData["inversion"], TYPE_TEXT),
452                                            #("FEC inner", frontendData["fec_inner"], TYPE_TEXT),
453                                                 #)
454                 #elif frontendData["tuner_type"] == "DVB-C":
455                         #return ( ("NIM", ['A', 'B', 'C', 'D'][frontendData["tuner_number"]], TYPE_TEXT),
456                                            #("Type", frontendData["tuner_type"], TYPE_TEXT),
457                                            #("Frequency", frontendData["frequency"], TYPE_VALUE_DEC),
458                                            #("Symbolrate", frontendData["symbol_rate"], TYPE_VALUE_DEC),
459                                            #("Modulation", frontendData["modulation"], TYPE_TEXT),
460                                            #("Inversion", frontendData["inversion"], TYPE_TEXT),
461                         #                  ("FEC inner", frontendData["fec_inner"], TYPE_TEXT),
462                                                 #)
463                 #elif frontendData["tuner_type"] == "DVB-T":
464                         #return ( ("NIM", ['A', 'B', 'C', 'D'][frontendData["tuner_number"]], TYPE_TEXT),
465                                            #("Type", frontendData["tuner_type"], TYPE_TEXT),
466                                            #("Frequency", frontendData["frequency"], TYPE_VALUE_DEC),
467                                            #("Inversion", frontendData["inversion"], TYPE_TEXT),
468                                            #("Bandwidth", frontendData["bandwidth"], TYPE_VALUE_DEC),
469                                            #("CodeRateLP", frontendData["code_rate_lp"], TYPE_TEXT),
470                                            #("CodeRateHP", frontendData["code_rate_hp"], TYPE_TEXT),
471                                            #("Constellation", frontendData["constellation"], TYPE_TEXT),
472                                            #("Transmission Mode", frontendData["transmission_mode"], TYPE_TEXT),
473                                            #("Guard Interval", frontendData["guard_interval"], TYPE_TEXT),
474                                            #("Hierarchy Inform.", frontendData["hierarchy_information"], TYPE_TEXT),
475                         defaultSat = { "orbpos": 192, "system": "dvb-s", "frequency": 11836, "inversion": "auto", "symbolrate": 27500, "polarization": "horizontal", "fec": "auto", "fec_s2": "9_10", "modulation": "qpsk" }
476                         defaultCab = {"frequency": 466, "inversion": "auto", "modulation": "64qam", "fec": "auto", "symbolrate": 6900}
477                         if frontendData is not None:
478                                 ttype = frontendData.get("tuner_type", "UNKNOWN")
479                                 if ttype == "DVB-S":
480                                         defaultSat["system"] = {"DVB-S": "dvb-s", "DVB-S2": "dvb-s2"}[frontendData.get("system", "DVB-S")]
481                                         defaultSat["frequency"] = int(frontendData.get("frequency", 0) / 1000)
482                                         defaultSat["inversion"] = {"INVERSION_OFF": "off", "INVERSION_ON": "on", "INVERSION_AUTO": "auto"}[frontendData.get("inversion", "INVERSION_AUTO")]
483                                         defaultSat["symbolrate"] = int(frontendData.get("symbol_rate", 0) / 1000)
484                                         defaultSat["polarization"] = {"HORIZONTAL": "horizontal", "VERTICAL": "vertical", "CIRCULAR_LEFT": "circular_left", "CIRCULAR_RIGHT": "circular_right", "UNKNOWN": None}[frontendData.get("polarization", "HORIZONTAL")]
485                                         
486                                         if frontendData.get("system", "DVB-S") == "DVB-S2":
487                                                 defaultSat["fec_s2"] = {"FEC_1_2": "1_2", "FEC_2_3": "2_3", "FEC_3_4": "3_4", "FEC_4_5": "4_5", "FEC_5_6": "5_6", "FEC_7_8": "7_8", "FEC_8_9": "8_9", "FEC_9_10": "9_10"} \
488                                                                                         [frontendData.get("fec_inner", "FEC_AUTO")]
489                                         else:
490                                                 defaultSat["fec"] = {"FEC_AUTO": "auto", "FEC_1_2": "1_2", "FEC_2_3": "2_3", "FEC_3_4": "3_4", "FEC_5_6": "5_6", "FEC_7_8": "7_8", "FEC_NONE": "none"} \
491                                                         [frontendData.get("fec_inner", "FEC_AUTO")]
492
493                                         defaultSat["modulation"] = {"QPSK": "qpsk", "8PSK": "8psk"}[frontendData.get("modulation", "QPSK")]
494                                         defaultSat["orbpos"] = frontendData.get("orbital_position", 0)
495                                 elif ttype == "DVB-C":
496                                         defaultCab["frequency"] = int(frontendData.get("frequency", 0) / 1000)
497                                         defaultCab["symbolrate"] = int(frontendData.get("symbol_rate", 0) / 1000)
498                                         defaultCab["inversion"] = {"INVERSION_OFF": "off", "INVERSION_ON": "on", "INVERSION_AUTO": "auto"}[frontendData.get("inversion", "INVERSION_AUTO")]
499                                         defaultCab["fec"] = {"FEC_AUTO": "auto", "FEC_1_2": "1_2", "FEC_2_3": "2_3", "FEC_3_4": "3_4", "FEC_5_6": "5_6", "FEC_7_8": "7_8", "FEC_8_9": "8_9", "FEC_NONE": "none"}[frontendData.get("fec_inner", "FEC_AUTO")]
500                                         defaultCab["modulation"] = {"QAM_AUTO": "auto", "QAM_16": "16qam", "QAM_32": "32qam", "QAM_64": "64qam", "QAM_128": "128qam", "QAM_256": "256qam"}[frontendData.get("modulation", "QAM_16")]
501
502                         self.scan_sat = ConfigSubsection()
503                         self.scan_cab = ConfigSubsection()
504                         self.scan_ter = ConfigSubsection()
505
506                         self.scan_type = ConfigSelection(default = "single_transponder", choices = [("single_transponder", _("Single transponder")), ("single_satellite", _("Single satellite")), ("multisat", _("Multisat"))])
507                         self.scan_typecable = ConfigSelection(default = "single_transponder", choices = [("single_transponder", _("Single transponder")), ("complete", _("Complete"))])
508                         self.scan_typeterrestrial = ConfigSelection(default = "single_transponder", choices = [("single_transponder", _("Single transponder")), ("complete", _("Complete"))])
509                         self.scan_clearallservices = ConfigSelection(default = "no", choices = [("no", _("no")), ("yes", _("yes")), ("yes_hold_feeds", _("yes (keep feeds)"))])
510                         self.scan_networkScan = ConfigYesNo(default = False)
511
512                         nim_list = []
513                         # collect all nims which are *not* set to "nothing"
514                         for n in nimmanager.nim_slots:
515                                 if n.config_mode != "nothing":
516                                         nim_list.append((str(n.slot), n.friendly_full_description))
517
518                         self.scan_nims = ConfigSelection(choices = nim_list)
519
520                         # status
521                         self.scan_snr = ConfigSlider()
522                         self.scan_snr.enabled = False
523                         self.scan_agc = ConfigSlider()
524                         self.scan_agc.enabled = False
525                         self.scan_ber = ConfigSlider()
526                         self.scan_ber.enabled = False
527
528                         # sat
529                         self.scan_sat.system = ConfigSelection(default = defaultSat["system"], choices = [("dvb-s", _("DVB-S")), ("dvb-s2", _("DVB-S2"))])
530                         self.scan_sat.frequency = ConfigInteger(default = defaultSat["frequency"], limits = (1, 99999))
531                         self.scan_sat.inversion = ConfigSelection(default = defaultSat["inversion"], choices = [("off", _("off")), ("on", _("on")), ("auto", _("Auto"))])
532                         self.scan_sat.symbolrate = ConfigInteger(default = defaultSat["symbolrate"], limits = (1, 99999))
533                         self.scan_sat.polarization = ConfigSelection(default = defaultSat["polarization"], choices = [("horizontal", _("horizontal")), ("vertical", _("vertical")),  ("circular_left", _("circular left")), ("circular_right", _("circular right"))])
534                         self.scan_sat.fec = ConfigSelection(default = defaultSat["fec"], choices = [("auto", _("Auto")), ("1_2", "1/2"), ("2_3", "2/3"), ("3_4", "3/4"), ("5_6", "5/6"), ("7_8", "7/8"), ("none", _("None"))])
535                         self.scan_sat.fec_s2 = ConfigSelection(default = defaultSat["fec_s2"], choices = [("1_2", "1/2"), ("2_3", "2/3"), ("3_4", "3/4"), ("3_5", "3/5"), ("4_5", "4/5"), ("5_6", "5/6"), ("7_8", "7/8"), ("8_9", "8/9"), ("9_10", "9/10")])
536                         self.scan_sat.modulation = ConfigSelection(default = defaultSat["modulation"], choices = [("qpsk", "QPSK"), ("8psk", "8PSK")])
537
538                         # cable
539                         self.scan_cab.frequency = ConfigInteger(default = defaultCab["frequency"], limits = (50, 999))
540                         self.scan_cab.inversion = ConfigSelection(default = defaultCab["inversion"], choices = [("off", _("off")), ("on", _("on")), ("auto", _("Auto"))])
541                         self.scan_cab.modulation = ConfigSelection(default = defaultCab["modulation"], choices = [("16qam", "16-QAM"), ("32qam", "32-QAM"), ("64qam", "64-QAM"), ("128qam", "128-QAM"), ("256qam", "256-QAM")])
542                         self.scan_cab.fec = ConfigSelection(default = defaultCab["fec"], choices = [("auto", _("Auto")), ("1_2", "1/2"), ("2_3", "2/3"), ("3_4", "3/4"), ("5_6", "5/6"), ("7_8", "7/8"), ("8_9", "8/9"), ("none", _("None"))])
543                         self.scan_cab.symbolrate = ConfigInteger(default = defaultCab["symbolrate"], limits = (1, 99999))
544
545                         # terrestial
546                         self.scan_ter.frequency = ConfigInteger(default = 466000, limits = (50000, 999000))
547                         self.scan_ter.inversion = ConfigSelection(default = "auto", choices = [("off", _("off")), ("on", _("on")), ("auto", _("Auto"))])
548                         # WORKAROUND: we can't use BW-auto
549                         self.scan_ter.bandwidth = ConfigSelection(default = "8MHz", choices = [("8MHz", "8MHz"), ("7MHz", "7MHz"), ("6MHz", "6MHz")])
550                         #, ("auto", _("Auto"))))
551                         self.scan_ter.fechigh = ConfigSelection(default = "auto", choices = [("1_2", "1/2"), ("2_3", "2/3"), ("3_4", "3/4"), ("5_6", "5/6"), ("7_8", "7/8"), ("auto", _("Auto"))])
552                         self.scan_ter.feclow = ConfigSelection(default = "auto", choices = [("1_2", "1/2"), ("2_3", "2/3"), ("3_4", "3/4"), ("5_6", "5/6"), ("7_8", "7/8"), ("auto", _("Auto"))])
553                         self.scan_ter.modulation = ConfigSelection(default = "auto", choices = [("qpsk", "QPSK"), ("qam16", "QAM16"), ("qam64", "QAM64"), ("auto", _("Auto"))])
554                         self.scan_ter.transmission = ConfigSelection(default = "auto", choices = [("2k", "2K"), ("8k", "8K"), ("auto", _("Auto"))])
555                         self.scan_ter.guard = ConfigSelection(default = "auto", choices = [("1_32", "1/32"), ("1_16", "1/16"), ("1_8", "1/8"), ("1_4", "1/4"), ("auto", _("Auto"))])
556                         self.scan_ter.hierarchy = ConfigSelection(default = "auto", choices = [("none", _("None")), ("1", "1"), ("2", "2"), ("4", "4"), ("auto", _("Auto"))])
557
558                         self.scan_scansat = {}
559                         for sat in nimmanager.satList:
560                                 #print sat[1]
561                                 self.scan_scansat[sat[0]] = ConfigYesNo(default = False)
562
563                         self.scan_satselection = []
564                         for slot in nimmanager.nim_slots:
565                                 if slot.isCompatible("DVB-S"):
566                                         self.scan_satselection.append(getConfigSatlist(int(defaultSat["orbpos"]), self.satList[slot.slot]))
567                                 else:
568                                         self.scan_satselection.append(None)
569
570                         return True
571
572         def keyLeft(self):
573                 ConfigListScreen.keyLeft(self)
574                 self.newConfig()
575
576         def keyRight(self):
577                 ConfigListScreen.keyRight(self)
578                 self.newConfig()
579
580         def updateStatus(self):
581                 print "updatestatus"
582
583         fecmap = { "auto": 0,
584                            "1_2": 1,
585                            "2_3": 2,
586                            "3_4": 3,
587                            "5_6": 4,
588                            "7_8": 5,
589                            "8_9": 6,
590                            "3_5": 7,
591                            "4_5": 8,
592                            "9_10": 9,
593                            "none": 15
594                            }
595
596         def addSatTransponder(self, tlist, frequency, symbol_rate, polarisation, fec, inversion, orbital_position, system, modulation):
597                 print "Add Sat: frequ: " + str(frequency) + " symbol: " + str(symbol_rate) + " pol: " + str(polarisation) + " fec: " + str(self.fecmap[fec]) + " inversion: " + str(inversion) + " modulation: " + str(modulation) + " system: " + str(system)
598                 print "orbpos: " + str(orbital_position)
599                 parm = eDVBFrontendParametersSatellite()
600                 if modulation == 1:
601                         parm.modulation = 2 # eDVBFrontendParametersSatellite.Modulation.8PSK
602                 else:
603                         parm.modulation = 1 # eDVBFrontendParametersSatellite.Modulation.QPSK
604                 parm.system = system
605                 parm.frequency = frequency * 1000
606                 parm.symbol_rate = symbol_rate * 1000
607                 parm.polarisation = polarisation
608                 parm.fec = self.fecmap[fec]
609                 parm.inversion = inversion
610                 parm.orbital_position = int(orbital_position)
611                 tlist.append(parm)
612
613         def addCabTransponder(self, tlist, frequency, symbol_rate, modulation, fec, inversion):
614                 print "Add Cab: frequ: " + str(frequency) + " symbol: " + str(symbol_rate) + " pol: " + str(modulation) + " fec: " + str(fec) + " inversion: " + str(inversion)
615                 parm = eDVBFrontendParametersCable()
616                 parm.frequency = frequency * 1000
617                 parm.symbol_rate = symbol_rate * 1000
618                 parm.modulation = modulation
619                 parm.fec = self.fecmap[fec]
620                 parm.inversion = inversion
621                 tlist.append(parm)
622
623         def addTerTransponder(self, tlist, *args, **kwargs):
624                 tlist.append(buildTerTransponder(*args, **kwargs))
625
626         def keyGo(self):
627                 tlist = []
628                 flags = None
629                 extFlags = True
630                 
631                 startScan = True
632                 index_to_scan = int(self.scan_nims.value)
633                 
634                 if self.scan_nims == [ ]:
635                         self.session.open(MessageBox, _("No tuner is enabled!\nPlease setup your tuner settings before you start a service scan."), MessageBox.TYPE_ERROR)
636                         return
637
638                 nim = nimmanager.nim_slots[index_to_scan]
639                 print "nim", nim.slot
640                 if nim.isCompatible("DVB-S"):
641                         print "is compatible with DVB-S"
642                         if self.scan_type.value == "single_transponder":
643                                 # these lists are generated for each tuner, so this has work.
644                                 assert len(self.satList) > index_to_scan
645                                 assert len(self.scan_satselection) > index_to_scan
646                                 
647                                 nimsats = self.satList[index_to_scan]
648                                 selsatidx = self.scan_satselection[index_to_scan].index
649
650                                 # however, the satList itself could be empty. in that case, "index" is 0 (for "None").
651                                 if len(nimsats):
652                                         orbpos = nimsats[selsatidx][0]
653                                         if self.scan_sat.system.value == "dvb-s":
654                                                 fec = self.scan_sat.fec.value
655                                         else:
656                                                 fec = self.scan_sat.fec_s2.value
657                                         print "add sat transponder"
658                                         self.addSatTransponder(tlist, self.scan_sat.frequency.value,
659                                                                 self.scan_sat.symbolrate.value,
660                                                                 self.scan_sat.polarization.index,
661                                                                 fec,
662                                                                 self.scan_sat.inversion.index,
663                                                                 orbpos,
664                                                                 self.scan_sat.system.index,
665                                                                 self.scan_sat.modulation.index)
666                                 flags = self.scan_networkScan.value and eComponentScan.scanNetworkSearch or 0
667                                 extFlags = False
668                         elif self.scan_type.value == "single_satellite":
669                                 sat = self.satList[index_to_scan][self.scan_satselection[index_to_scan].index]
670                                 getInitialTransponderList(tlist, sat[0])
671                         elif self.scan_type.value == "multisat":
672                                 SatList = nimmanager.getSatListForNim(index_to_scan)
673                                 for x in self.multiscanlist:
674                                         if x[1].value:
675                                                 print "   " + str(x[0])
676                                                 getInitialTransponderList(tlist, x[0])
677
678                 elif nim.isCompatible("DVB-C"):
679                         if self.scan_typecable.value == "single_transponder":
680                                 fec = self.scan_cab.fec.value
681                                 self.addCabTransponder(tlist, self.scan_cab.frequency.value,
682                                                                                           self.scan_cab.symbolrate.value,
683                                                                                           self.scan_cab.modulation.index + 1,
684                                                                                           fec,
685                                                                                           self.scan_cab.inversion.index)
686                                 flags = self.scan_networkScan.value and eComponentScan.scanNetworkSearch or 0
687                                 extFlags = False
688                         elif self.scan_typecable.value == "complete":
689                                 if config.Nims[index_to_scan].cable.scan_type.value == "provider":
690                                         getInitialCableTransponderList(tlist, index_to_scan)
691                                 else:
692                                         startScan = False
693
694                 elif nim.isCompatible("DVB-T"):
695                         if self.scan_typeterrestrial.value == "single_transponder":
696                                 self.addTerTransponder(tlist,
697                                                 self.scan_ter.frequency.value * 1000,
698                                                 inversion = self.scan_ter.inversion.index,
699                                                 bandwidth = self.scan_ter.bandwidth.index,
700                                                 fechigh = self.scan_ter.fechigh.index,
701                                                 feclow = self.scan_ter.feclow.index,
702                                                 modulation = self.scan_ter.modulation.index,
703                                                 transmission = self.scan_ter.transmission.index,
704                                                 guard = self.scan_ter.guard.index,
705                                                 hierarchy = self.scan_ter.hierarchy.index)
706                                 flags = self.scan_networkScan.value and eComponentScan.scanNetworkSearch or 0
707                                 extFlags = False
708                         elif self.scan_typeterrestrial.value == "complete":
709                                 getInitialTerrestrialTransponderList(tlist, nimmanager.getTerrestrialDescription(index_to_scan))
710
711                 if flags is None:
712                         flags = eComponentScan.scanNetworkSearch
713
714                 if extFlags:
715                         tmp = self.scan_clearallservices.value
716                         if tmp == "yes":
717                                 flags |= eComponentScan.scanRemoveServices
718                         elif tmp == "yes_hold_feeds":
719                                 flags |= eComponentScan.scanRemoveServices
720                                 flags |= eComponentScan.scanDontRemoveFeeds
721
722                 for x in self["config"].list:
723                         x[1].save()
724
725                 if startScan:
726                         self.startScan(tlist, flags, index_to_scan)
727                 else:
728                         self.flags = flags
729                         self.feid = index_to_scan
730                         self.tlist = []
731                         self.startCableTransponderSearch(self.feid)
732
733         def setCableTransponderSearchResult(self, tlist):
734                 self.tlist = tlist
735
736         def cableTransponderSearchFinished(self):
737                 self.startScan(self.tlist, self.flags, self.feid)
738
739         def startScan(self, tlist, flags, feid):
740                 if len(tlist):
741                         # flags |= eComponentScan.scanSearchBAT
742                         if self.finished_cb:
743                                 self.session.openWithCallback(self.finished_cb, ServiceScan, [{"transponders": tlist, "feid": feid, "flags": flags}])
744                         else:
745                                 self.session.open(ServiceScan, [{"transponders": tlist, "feid": feid, "flags": flags}])
746                 else:
747                         if self.finished_cb:
748                                 self.session.openWithCallback(self.finished_cb, MessageBox, _("Nothing to scan!\nPlease setup your tuner settings before you start a service scan."), MessageBox.TYPE_ERROR)
749                         else:
750                                 self.session.open(MessageBox, _("Nothing to scan!\nPlease setup your tuner settings before you start a service scan."), MessageBox.TYPE_ERROR)
751
752         def keyCancel(self):
753                 for x in self["config"].list:
754                         x[1].cancel()
755                 self.close()
756
757 class ScanSimple(ConfigListScreen, Screen, CableTransponderSearchSupport):
758         def getNetworksForNim(self, nim):
759                 if nim.isCompatible("DVB-S"):
760                         networks = nimmanager.getSatListForNim(nim.slot)
761 # the original code took "loopthrough" etc. into account. Do we need this?
762 #                       if nimmanager.getNimConfigMode(1) in ["loopthrough", "satposdepends", "equal", "nothing"]:
763 #                               return False
764 #                       sec = eDVBSatelliteEquipmentControl.getInstance()
765 #                       if sec is not None:
766 #                               exclusive_satellites = sec.get_exclusive_satellites(0,1)
767 #                               if len(exclusive_satellites) == 2:
768 #                                       return False
769 #                               idx = exclusive_satellites[0]+1
770 #                               exclusive_nim_sats = exclusive_satellites[idx+1:idx+1+exclusive_satellites[idx]]
771 #                               if len(exclusive_nim_sats):
772 #                                       return True
773                 elif not nim.empty:
774                         networks = [ nim.type ] # "DVB-C" or "DVB-T". TODO: seperate networks for different C/T tuners, if we want to support that.
775                 else:
776                         # empty tuners provide no networks.
777                         networks = [ ]
778                 return networks
779
780         def __init__(self, session):
781                 Screen.__init__(self, session)
782
783                 self["actions"] = ActionMap(["SetupActions"],
784                 {
785                         "ok": self.keyGo,
786                         "cancel": self.keyCancel,
787                 }, -2)
788
789                 self.list = []
790                 tlist = []
791
792                 known_networks = [ ]
793                 nims_to_scan = [ ]
794                 self.finished_cb = None
795
796                 for nim in nimmanager.nim_slots:
797                         # collect networks provided by this tuner
798
799                         need_scan = False
800                         networks = self.getNetworksForNim(nim)
801                         
802                         print "nim %d provides" % nim.slot, networks
803                         print "known:", known_networks
804
805                         # we only need to scan on the first tuner which provides a network.
806                         # this gives the first tuner for each network priority for scanning.
807                         for x in networks:
808                                 if x not in known_networks:
809                                         need_scan = True
810                                         print x, "not in ", known_networks
811                                         known_networks.append(x)
812
813                         if need_scan:
814                                 nims_to_scan.append(nim)
815
816                 # we save the config elements to use them on keyGo
817                 self.nim_enable = [ ]
818
819                 if len(nims_to_scan):
820                         self.scan_clearallservices = ConfigSelection(default = "yes", choices = [("no", _("no")), ("yes", _("yes")), ("yes_hold_feeds", _("yes (keep feeds)"))])
821                         self.list.append(getConfigListEntry(_("Clear before scan"), self.scan_clearallservices))
822
823                         for nim in nims_to_scan:
824                                 nimconfig = ConfigYesNo(default = True)
825                                 nimconfig.nim_index = nim.slot
826                                 self.nim_enable.append(nimconfig)
827                                 self.list.append(getConfigListEntry(_("Scan ") + nim.slot_name + " (" + nim.friendly_type + ")", nimconfig))
828
829                 ConfigListScreen.__init__(self, self.list)
830                 self["header"] = Label(_("Automatic Scan"))
831                 self["footer"] = Label(_("Press OK to scan"))
832
833         def runAsync(self, finished_cb):
834                 self.finished_cb = finished_cb
835                 self.keyGo()
836
837         def keyGo(self):
838                 self.scanList = []
839                 self.known_networks = set()
840                 self.nim_iter=0
841                 self.buildTransponderList()
842
843         def buildTransponderList(self): # this method is called multiple times because of asynchronous stuff
844                 APPEND_NOW = 0
845                 SEARCH_CABLE_TRANSPONDERS = 1
846                 action = APPEND_NOW
847
848                 n = self.nim_iter < len(self.nim_enable) and self.nim_enable[self.nim_iter] or None
849                 self.nim_iter += 1
850                 if n:
851                         if n.value: # check if nim is enabled
852                                 flags = 0
853                                 nim = nimmanager.nim_slots[n.nim_index]
854                                 networks = set(self.getNetworksForNim(nim))
855
856                                 # don't scan anything twice
857                                 networks.discard(self.known_networks)
858
859                                 tlist = [ ]
860                                 if nim.isCompatible("DVB-S"):
861                                         # get initial transponders for each satellite to be scanned
862                                         for sat in networks:
863                                                 getInitialTransponderList(tlist, sat[0])
864                                 elif nim.isCompatible("DVB-C"):
865                                         if config.Nims[nim.slot].cable.scan_type.value == "provider":
866                                                 getInitialCableTransponderList(tlist, nim.slot)
867                                         else:
868                                                 action = SEARCH_CABLE_TRANSPONDERS
869                                 elif nim.isCompatible("DVB-T"):
870                                         getInitialTerrestrialTransponderList(tlist, nimmanager.getTerrestrialDescription(nim.slot))
871                                 else:
872                                         assert False
873
874                                 flags |= eComponentScan.scanNetworkSearch #FIXMEEE.. use flags from cables / satellites / terrestrial.xml
875                                 tmp = self.scan_clearallservices.value
876                                 if tmp == "yes":
877                                         flags |= eComponentScan.scanRemoveServices
878                                 elif tmp == "yes_hold_feeds":
879                                         flags |= eComponentScan.scanRemoveServices
880                                         flags |= eComponentScan.scanDontRemoveFeeds
881
882                                 if action == APPEND_NOW:
883                                         self.scanList.append({"transponders": tlist, "feid": nim.slot, "flags": flags})
884                                 elif action == SEARCH_CABLE_TRANSPONDERS:
885                                         self.flags = flags
886                                         self.feid = nim.slot
887                                         self.startCableTransponderSearch(nim.slot)
888                                         return
889                                 else:
890                                         assert False
891
892                         self.buildTransponderList() # recursive call of this function !!!
893                         return
894                 # when we are here, then the recursion is finished and all enabled nims are checked
895                 # so we now start the real transponder scan
896                 self.startScan(self.scanList)
897
898         def startScan(self, scanList):
899                 if len(scanList):
900                         if self.finished_cb:
901                                 self.session.openWithCallback(self.finished_cb, ServiceScan, scanList = scanList)
902                         else:
903                                 self.session.open(ServiceScan, scanList = scanList)
904                 else:
905                         if self.finished_cb:
906                                 self.session.openWithCallback(self.finished_cb, MessageBox, _("Nothing to scan!\nPlease setup your tuner settings before you start a service scan."), MessageBox.TYPE_ERROR)
907                         else:
908                                 self.session.open(MessageBox, _("Nothing to scan!\nPlease setup your tuner settings before you start a service scan."), MessageBox.TYPE_ERROR)
909
910         def setCableTransponderSearchResult(self, tlist):
911                 self.scanList.append({"transponders": tlist, "feid": self.feid, "flags": self.flags})
912
913         def cableTransponderSearchFinished(self):
914                 self.buildTransponderList()
915
916         def keyCancel(self):
917                 self.close()
918
919         def Satexists(self, tlist, pos):
920                 for x in tlist:
921                         if x == pos:
922                                 return 1
923                 return 0
924