fix automatic scan for DVB-T
[enigma2.git] / lib / python / Screens / ScanSetup.py
index 0b299f7a5075a4894981a896a2be729ed99fed99..f007f6f20d899c7df63e29187ab519c55127cbab 100644 (file)
@@ -112,12 +112,13 @@ def getInitialTerrestrialTransponderList(tlist, region):
                        # FIXME: we need to convert the other parameters...
                        
                                # convert terrestrial.xml bandwidth to our enum
-                       if x[2] in [0, 1]:
-                               bandwidth = [1, 0][x[2]]
-                       else:
-                               bandwidth = 3 # auto
-                       
-                       parm = buildTerTransponder(x[1], bandwidth = [1, 0][x[2]])
+                       #if x[2] in [0, 1]:
+                       #       bandwidth = [1, 0][x[2]]
+                       #else:
+                       #       bandwidth = 3 # auto
+                       #
+                       #parm = buildTerTransponder(x[1], bandwidth = [1, 0][x[2]])
+                       parm = buildTerTransponder(x[1], inversion = x[9], bandwidth = x[2])
                        tlist.append(parm)
 
 
@@ -390,20 +391,26 @@ class ScanSetup(Screen):
                flags = 0
                if (nimmanager.getNimType(config.scan.nims.value) == nimmanager.nimType["DVB-S"]):
                        if currentConfigSelectionElement(config.scan.type) == "single_transponder":
-
-                               self.addSatTransponder(tlist, config.scan.sat.frequency.value[0],
-                                                                                         config.scan.sat.symbolrate.value[0],
-                                                                                         config.scan.sat.polarization.value,
-                                                                                         config.scan.sat.fec.value,
-                                                                                         config.scan.sat.inversion.value,
-                                                                                         self.satList[config.scan.nims.value][config.scan.satselection[config.scan.nims.value].value][1])
+                               l = len(self.satList)
+                               if l and l > config.scan.nims.value:
+                                       nimsats=self.satList[config.scan.nims.value]
+                                       l = len(config.scan.satselection)
+                                       if l and l > config.scan.nims.value:
+                                               selsatidx=config.scan.satselection[config.scan.nims.value].value
+                                               l = len(nimsats)
+                                               if l and l > selsatidx:
+                                                       orbpos=nimsats[selsatidx][1]
+                                                       self.addSatTransponder(tlist, config.scan.sat.frequency.value[0],
+                                                                               config.scan.sat.symbolrate.value[0],
+                                                                               config.scan.sat.polarization.value,
+                                                                               config.scan.sat.fec.value,
+                                                                               config.scan.sat.inversion.value,
+                                                                               orbpos)
                        elif currentConfigSelectionElement(config.scan.type) == "single_satellite":
                                getInitialTransponderList(tlist, int(self.satList[config.scan.nims.value][config.scan.satselection[config.scan.nims.value].value][1]))
                                flags |= eComponentScan.scanNetworkSearch
-       
                        elif currentConfigSelectionElement(config.scan.type) == "multisat":
                                SatList = nimmanager.getSatListForNim(config.scan.nims.value)
-       
                                for x in self.multiscanlist:
                                        if x[1].parent.value == 0:
                                                print "   " + str(x[1].parent.configPath)
@@ -417,7 +424,7 @@ class ScanSetup(Screen):
                                                                                          config.scan.cab.modulation.value,
                                                                                          config.scan.cab.fec.value,
                                                                                          config.scan.cab.inversion.value)
-                               if  currentConfigSelectionElement(config.scan.cab.networkScan) == "yes":
+                               if currentConfigSelectionElement(config.scan.cab.networkScan) == "yes":
                                        flags |= eComponentScan.scanNetworkSearch
                        elif currentConfigSelectionElement(config.scan.typecable) == "complete":
                                getInitialCableTransponderList(tlist, nimmanager.getCableDescription(config.scan.nims.value))
@@ -444,11 +451,13 @@ class ScanSetup(Screen):
                for x in self["config"].list:
                        x[1].save()
 
-               feid = config.scan.nims.value
-               # flags |= eComponentScan.scanSearchBAT
-               self.session.openWithCallback(self.doNothing, ServiceScan, [{"transponders": tlist, "feid": feid, "flags": flags}])
+               if len(tlist):
+                       feid = config.scan.nims.value
+                       # flags |= eComponentScan.scanSearchBAT
+                       self.session.openWithCallback(self.doNothing, ServiceScan, [{"transponders": tlist, "feid": feid, "flags": flags}])
+               else:
+                       self.session.open(MessageBox, _("Nothing to scan!\nPlease setup your tuner settings before you start a service scan."), MessageBox.TYPE_ERROR)
 
-               #self.close()
        def doNothing(self):
                pass
 
@@ -495,10 +504,10 @@ class ScanSimple(Screen):
                                                        print sat
                                                        getInitialTransponderList(tlist, sat[1])
                                elif nimmanager.getNimType(x[1].parent.configPath) == nimmanager.nimType["DVB-C"]:
-                                       ScanPossible = True
+                                       scanPossible = True
                                        getInitialCableTransponderList(tlist, nimmanager.getCableDescription(slotid))
                                elif nimmanager.getNimType(x[1].parent.configPath) == nimmanager.nimType["DVB-T"]:
-                                       ScanPossible = True
+                                       scanPossible = True
                                        getInitialTerrestrialTransponderList(tlist, nimmanager.getTerrestrialDescription(slotid))
                                if scanPossible:
                                        scanList.append({"transponders": tlist, "feid": slotid, "flags": eComponentScan.scanNetworkSearch})
@@ -534,9 +543,13 @@ class ScanSimple(Screen):
                        sec = eDVBSatelliteEquipmentControl.getInstance()
                        if sec is not None:
                                exclusive_satellites = sec.get_exclusive_satellites(0,1)
-                               if len(exclusive_satellites) == 0:
+                               if len(exclusive_satellites) == 2:
                                        return False
-                       return True
+                               idx = exclusive_satellites[0]+1
+                               exclusive_nim_sats = exclusive_satellites[idx+1:idx+1+exclusive_satellites[idx]]
+                               if len(exclusive_nim_sats):
+                                       return True
+               return False # two -C or two -T tuners
 
        def __init__(self, session):
                Screen.__init__(self, session)