(ralfk) make cuesheet actions translatable
[enigma2.git] / lib / python / Screens / ScanSetup.py
index d15e0bd14e098dcd5d3baf95469b514b1985ae68..351b421b1df7ea75d7faa420d253429e3a213995 100644 (file)
@@ -158,14 +158,14 @@ class CableTransponderSearchSupport:
                print "cableTransponderSearchSessionClosed, val", val
                self.cable_search_container = None
                self.cable_search_session = None
                print "cableTransponderSearchSessionClosed, val", val
                self.cable_search_container = None
                self.cable_search_session = None
-               if val and len(val) and not val[0]:
+               if val and len(val) and val[0]:
                        self.setCableTransponderSearchResult(self.__tlist)
                self.__tlist = None
                self.cableTransponderSearchFinished()
 
        def cableTransponderSearchClosed(self, retval):
                print "cableTransponderSearch finished", retval
                        self.setCableTransponderSearchResult(self.__tlist)
                self.__tlist = None
                self.cableTransponderSearchFinished()
 
        def cableTransponderSearchClosed(self, retval):
                print "cableTransponderSearch finished", retval
-               self.cable_search_session.close(0)
+               self.cable_search_session.close(True)
 
        def getCableTransponderData(self, str):
                data = str.split()
 
        def getCableTransponderData(self, str):
                data = str.split()
@@ -204,10 +204,17 @@ class CableTransponderSearchSupport:
                self.cable_search_container.appClosed.get().append(self.cableTransponderSearchClosed)
                self.cable_search_container.dataAvail.get().append(self.getCableTransponderData)
                cableConfig = config.Nims[nim_idx].cable
                self.cable_search_container.appClosed.get().append(self.cableTransponderSearchClosed)
                self.cable_search_container.dataAvail.get().append(self.getCableTransponderData)
                cableConfig = config.Nims[nim_idx].cable
-               cmd = "tda1002x --scan --verbose --wakeup --bus="
-               cmd += str(nim_idx)
+               cmd = "tda1002x --init --scan --verbose --wakeup --inv 2 --bus "
+               #FIXMEEEEEE hardcoded i2c devices for dm7025 and dm8000
+               if nim_idx < 2:
+                       cmd += str(nim_idx)
+               else:
+                       if nim_idx == 2:
+                               cmd += "2" # first nim socket on DM8000 use /dev/i2c/2
+                       else:
+                               cmd += "4" # second nim socket on DM8000 use /dev/i2c/4
                if cableConfig.scan_type.value == "bands":
                if cableConfig.scan_type.value == "bands":
-                       cmd += " --scan_bands="
+                       cmd += " --scan-bands "
                        bands = 0
                        if cableConfig.scan_band_EU_VHF_I.value:
                                bands |= cable_bands["DVBC_BAND_EU_VHF_I"]
                        bands = 0
                        if cableConfig.scan_band_EU_VHF_I.value:
                                bands |= cable_bands["DVBC_BAND_EU_VHF_I"]
@@ -235,7 +242,7 @@ class CableTransponderSearchSupport:
                                bands |= cable_bands["DVBC_BAND_US_HYPER"]
                        cmd += str(bands)
                else:
                                bands |= cable_bands["DVBC_BAND_US_HYPER"]
                        cmd += str(bands)
                else:
-                       cmd += " --scan_stepsize="
+                       cmd += " --scan-stepsize "
                        cmd += str(cableConfig.scan_frequency_steps.value)
                if cableConfig.scan_mod_qam16.value:
                        cmd += " --mod 16"
                        cmd += str(cableConfig.scan_frequency_steps.value)
                if cableConfig.scan_mod_qam16.value:
                        cmd += " --mod 16"
@@ -251,11 +258,11 @@ class CableTransponderSearchSupport:
                        cmd += " --sr 6900000"
                if cableConfig.scan_sr_6875.value:
                        cmd += " --sr 6875000"
                        cmd += " --sr 6900000"
                if cableConfig.scan_sr_6875.value:
                        cmd += " --sr 6875000"
-               if cableConfig.scan_sr_ext1.value > 1000:
+               if cableConfig.scan_sr_ext1.value > 450:
                        cmd += " --sr "
                        cmd += str(cableConfig.scan_sr_ext1.value)
                        cmd += "000"
                        cmd += " --sr "
                        cmd += str(cableConfig.scan_sr_ext1.value)
                        cmd += "000"
-               if cableConfig.scan_sr_ext2.value > 1000:
+               if cableConfig.scan_sr_ext2.value > 450:
                        cmd += " --sr "
                        cmd += str(cableConfig.scan_sr_ext2.value)
                        cmd += "000"
                        cmd += " --sr "
                        cmd += str(cableConfig.scan_sr_ext2.value)
                        cmd += "000"
@@ -270,6 +277,7 @@ class ScanSetup(ConfigListScreen, Screen, CableTransponderSearchSupport):
        def __init__(self, session):
                Screen.__init__(self, session)
 
        def __init__(self, session):
                Screen.__init__(self, session)
 
+               self.finished_cb = None
                self.updateSatList()
                self.service = session.nav.getCurrentService()
                self.feinfo = None
                self.updateSatList()
                self.service = session.nav.getCurrentService()
                self.feinfo = None
@@ -299,7 +307,8 @@ class ScanSetup(ConfigListScreen, Screen, CableTransponderSearchSupport):
 
                self["introduction"] = Label(_("Press OK to start the scan"))
 
 
                self["introduction"] = Label(_("Press OK to start the scan"))
 
-       def run(self):
+       def runAsync(self, finished_cb):
+               self.finished_cb = finished_cb
                self.keyGo()
 
        def updateSatList(self):
                self.keyGo()
 
        def updateSatList(self):
@@ -378,7 +387,7 @@ class ScanSetup(ConfigListScreen, Screen, CableTransponderSearchSupport):
                elif nim.isCompatible("DVB-C"):
                        if self.scan_typecable.value == "single_transponder":
                                self.list.append(getConfigListEntry(_("Frequency"), self.scan_cab.frequency))
                elif nim.isCompatible("DVB-C"):
                        if self.scan_typecable.value == "single_transponder":
                                self.list.append(getConfigListEntry(_("Frequency"), self.scan_cab.frequency))
-                               self.list.append(getConfigListEntry(_("Inversions"), self.scan_cab.inversion))
+                               self.list.append(getConfigListEntry(_("Inversion"), self.scan_cab.inversion))
                                self.list.append(getConfigListEntry(_("Symbol Rate"), self.scan_cab.symbolrate))
                                self.list.append(getConfigListEntry(_("Modulation"), self.scan_cab.modulation))
                                self.list.append(getConfigListEntry(_("FEC"), self.scan_cab.fec))
                                self.list.append(getConfigListEntry(_("Symbol Rate"), self.scan_cab.symbolrate))
                                self.list.append(getConfigListEntry(_("Modulation"), self.scan_cab.modulation))
                                self.list.append(getConfigListEntry(_("FEC"), self.scan_cab.fec))
@@ -728,9 +737,15 @@ class ScanSetup(ConfigListScreen, Screen, CableTransponderSearchSupport):
        def startScan(self, tlist, flags, feid):
                if len(tlist):
                        # flags |= eComponentScan.scanSearchBAT
        def startScan(self, tlist, flags, feid):
                if len(tlist):
                        # flags |= eComponentScan.scanSearchBAT
-                       self.session.open(ServiceScan, [{"transponders": tlist, "feid": feid, "flags": flags}])
+                       if self.finished_cb:
+                               self.session.openWithCallback(self.finished_cb, ServiceScan, [{"transponders": tlist, "feid": feid, "flags": flags}])
+                       else:
+                               self.session.open(ServiceScan, [{"transponders": tlist, "feid": feid, "flags": flags}])
                else:
                else:
-                       self.session.open(MessageBox, _("Nothing to scan!\nPlease setup your tuner settings before you start a service scan."), MessageBox.TYPE_ERROR)
+                       if self.finished_cb:
+                               self.session.openWithCallback(self.finished_cb, MessageBox, _("Nothing to scan!\nPlease setup your tuner settings before you start a service scan."), MessageBox.TYPE_ERROR)
+                       else:
+                               self.session.open(MessageBox, _("Nothing to scan!\nPlease setup your tuner settings before you start a service scan."), MessageBox.TYPE_ERROR)
 
        def keyCancel(self):
                for x in self["config"].list:
 
        def keyCancel(self):
                for x in self["config"].list:
@@ -774,6 +789,7 @@ class ScanSimple(ConfigListScreen, Screen, CableTransponderSearchSupport):
 
                known_networks = [ ]
                nims_to_scan = [ ]
 
                known_networks = [ ]
                nims_to_scan = [ ]
+               self.finished_cb = None
 
                for nim in nimmanager.nim_slots:
                        # collect networks provided by this tuner
 
                for nim in nimmanager.nim_slots:
                        # collect networks provided by this tuner
@@ -812,7 +828,8 @@ class ScanSimple(ConfigListScreen, Screen, CableTransponderSearchSupport):
                self["header"] = Label(_("Automatic Scan"))
                self["footer"] = Label(_("Press OK to scan"))
 
                self["header"] = Label(_("Automatic Scan"))
                self["footer"] = Label(_("Press OK to scan"))
 
-       def run(self):
+       def runAsync(self, finished_cb):
+               self.finished_cb = finished_cb
                self.keyGo()
 
        def keyGo(self):
                self.keyGo()
 
        def keyGo(self):
@@ -825,15 +842,12 @@ class ScanSimple(ConfigListScreen, Screen, CableTransponderSearchSupport):
                APPEND_NOW = 0
                SEARCH_CABLE_TRANSPONDERS = 1
                action = APPEND_NOW
                APPEND_NOW = 0
                SEARCH_CABLE_TRANSPONDERS = 1
                action = APPEND_NOW
-               
-               skip = self.nim_iter
-               self.nim_iter = 0
-               
-               for n in self.nim_enable:
-                       self.nim_iter += 1
-                       if skip > 0:
-                               skip -= 1
-                       elif n.value: # check if nim is enabled
+
+               n = self.nim_iter < len(self.nim_enable) and self.nim_enable[self.nim_iter] or None
+               self.nim_iter += 1
+               if n:
+                       if n.value: # check if nim is enabled
+                               flags = 0
                                nim = nimmanager.nim_slots[n.nim_index]
                                networks = set(self.getNetworksForNim(nim))
 
                                nim = nimmanager.nim_slots[n.nim_index]
                                networks = set(self.getNetworksForNim(nim))
 
@@ -855,7 +869,7 @@ class ScanSimple(ConfigListScreen, Screen, CableTransponderSearchSupport):
                                else:
                                        assert False
 
                                else:
                                        assert False
 
-                               flags |= eComponentScan.scanNetworkSearch
+                               flags |= eComponentScan.scanNetworkSearch #FIXMEEE.. use flags from cables / satellites / terrestrial.xml
                                tmp = self.scan_clearallservices.value
                                if tmp == "yes":
                                        flags |= eComponentScan.scanRemoveServices
                                tmp = self.scan_clearallservices.value
                                if tmp == "yes":
                                        flags |= eComponentScan.scanRemoveServices
@@ -872,13 +886,24 @@ class ScanSimple(ConfigListScreen, Screen, CableTransponderSearchSupport):
                                        return
                                else:
                                        assert False
                                        return
                                else:
                                        assert False
+
+                       self.buildTransponderList() # recursive call of this function !!!
+                       return
+               # when we are here, then the recursion is finished and all enabled nims are checked
+               # so we now start the real transponder scan
                self.startScan(self.scanList)
 
        def startScan(self, scanList):
                if len(scanList):
                self.startScan(self.scanList)
 
        def startScan(self, scanList):
                if len(scanList):
-                       self.session.openWithCallback(self.doNothing, ServiceScan, scanList = scanList)
+                       if self.finished_cb:
+                               self.session.openWithCallback(self.finished_cb, ServiceScan, scanList = scanList)
+                       else:
+                               self.session.open(ServiceScan, scanList = scanList)
                else:
                else:
-                       self.session.open(MessageBox, _("Nothing to scan!\nPlease setup your tuner settings before you start a service scan."), MessageBox.TYPE_ERROR)
+                       if self.finished_cb:
+                               self.session.openWithCallback(self.finished_cb, MessageBox, _("Nothing to scan!\nPlease setup your tuner settings before you start a service scan."), MessageBox.TYPE_ERROR)
+                       else:
+                               self.session.open(MessageBox, _("Nothing to scan!\nPlease setup your tuner settings before you start a service scan."), MessageBox.TYPE_ERROR)
 
        def setCableTransponderSearchResult(self, tlist):
                self.scanList.append({"transponders": tlist, "feid": self.feid, "flags": self.flags})
 
        def setCableTransponderSearchResult(self, tlist):
                self.scanList.append({"transponders": tlist, "feid": self.feid, "flags": self.flags})
@@ -886,9 +911,6 @@ class ScanSimple(ConfigListScreen, Screen, CableTransponderSearchSupport):
        def cableTransponderSearchFinished(self):
                self.buildTransponderList()
 
        def cableTransponderSearchFinished(self):
                self.buildTransponderList()
 
-       def doNothing(self):
-               pass
-
        def keyCancel(self):
                self.close()
 
        def keyCancel(self):
                self.close()