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