remove no more needed function
[enigma2.git] / lib / python / Screens / ScanSetup.py
index 9845be9543223abb3070b23227d23acf8df6276f..b14c7e7482b219e84431274d662415b512b90be5 100644 (file)
@@ -1,11 +1,13 @@
 from Screen import Screen
-from ServiceScan import *
+from Screens.DefaultWizard import DefaultWizard
+from ServiceScan import ServiceScan
 from Components.config import config, ConfigSubsection, ConfigSelection, \
-       ConfigYesNo, ConfigInteger, getConfigListEntry, ConfigSlider, ConfigSatlist, ConfigEnableDisable
-from Components.ActionMap import NumberActionMap
-from Components.ConfigList import ConfigList, ConfigListScreen
+       ConfigYesNo, ConfigInteger, getConfigListEntry, ConfigSlider, ConfigEnableDisable
+from Components.ActionMap import NumberActionMap, ActionMap
+from Components.ConfigList import ConfigListScreen
 from Components.NimManager import nimmanager, getConfigSatlist
 from Components.Label import Label
+from Tools.Directories import resolveFilename, SCOPE_DEFAULTPARTITIONMOUNTDIR, SCOPE_DEFAULTDIR, SCOPE_DEFAULTPARTITION
 from Screens.MessageBox import MessageBox
 from enigma import eTimer, eDVBFrontendParametersSatellite, eComponentScan, \
        eDVBSatelliteEquipmentControl, eDVBFrontendParametersTerrestrial, \
@@ -84,10 +86,12 @@ def getInitialTransponderList(tlist, pos):
                        parm.symbol_rate = x[2]
                        parm.polarisation = x[3]
                        parm.fec = x[4]
-                       parm.inversion = 2 # AUTO
+                       parm.inversion = x[7]
                        parm.orbital_position = pos
                        parm.system = x[5]
                        parm.modulation = x[6]
+                       parm.rolloff = x[8]
+                       parm.pilot = x[9]
                        tlist.append(parm)
 
 def getInitialCableTransponderList(tlist, nim):
@@ -156,6 +160,8 @@ class CableTransponderSearchSupport:
 
        def cableTransponderSearchSessionClosed(self, *val):
                print "cableTransponderSearchSessionClosed, val", val
+               self.cable_search_container.appClosed.get().remove(self.cableTransponderSearchClosed)
+               self.cable_search_container.dataAvail.get().remove(self.getCableTransponderData)
                self.cable_search_container = None
                self.cable_search_session = None
                if val and len(val) and val[0]:
@@ -204,10 +210,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
-               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":
-                       cmd += " --scan-bands="
+                       cmd += " --scan-bands "
                        bands = 0
                        if cableConfig.scan_band_EU_VHF_I.value:
                                bands |= cable_bands["DVBC_BAND_EU_VHF_I"]
@@ -235,7 +248,7 @@ class CableTransponderSearchSupport:
                                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"
@@ -266,10 +279,32 @@ class CableTransponderSearchSupport:
                tmpstr += "\n\n..."
                self.cable_search_session = self.session.openWithCallback(self.cableTransponderSearchSessionClosed, MessageBox, tmpstr, MessageBox.TYPE_INFO)
 
+class DefaultSatLists(DefaultWizard):
+       def __init__(self, session, silent = True, showSteps = False):
+               self.xmlfile = "defaultsatlists.xml"
+               DefaultWizard.__init__(self, session, silent, showSteps, neededTag = "services")
+               print "configuredSats:", nimmanager.getConfiguredSats()
+
+       def setDirectory(self):
+               self.directory = []
+               self.directory.append(resolveFilename(SCOPE_DEFAULTDIR))
+               import os
+               os.system("mount %s %s" % (resolveFilename(SCOPE_DEFAULTPARTITION), resolveFilename(SCOPE_DEFAULTPARTITIONMOUNTDIR)))
+               self.directory.append(resolveFilename(SCOPE_DEFAULTPARTITIONMOUNTDIR))
+                               
+       def statusCallback(self, status, progress):
+               print "statusCallback:", status, progress
+               from Components.DreamInfoHandler import DreamInfoHandler
+               if status == DreamInfoHandler.STATUS_DONE:
+                       self["text"].setText(_("The installation of the default services lists is finished.") + "\n\n" + _("Please press OK to continue."))
+                       self.markDone()
+                       self.disableKeys = False        
+
 class ScanSetup(ConfigListScreen, Screen, CableTransponderSearchSupport):
        def __init__(self, session):
                Screen.__init__(self, session)
 
+               self.finished_cb = None
                self.updateSatList()
                self.service = session.nav.getCurrentService()
                self.feinfo = None
@@ -290,7 +325,7 @@ class ScanSetup(ConfigListScreen, Screen, CableTransponderSearchSupport):
                }, -2)
 
                self.statusTimer = eTimer()
-               self.statusTimer.timeout.get().append(self.updateStatus)
+               self.statusTimer.callback.append(self.updateStatus)
                #self.statusTimer.start(5000, True)
 
                self.list = []
@@ -299,7 +334,8 @@ class ScanSetup(ConfigListScreen, Screen, CableTransponderSearchSupport):
 
                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):
@@ -324,6 +360,7 @@ class ScanSetup(ConfigListScreen, Screen, CableTransponderSearchSupport):
                
                self.typeOfScanEntry = None
                self.systemEntry = None
+               self.modulationEntry = None
                nim = nimmanager.nim_slots[index_to_scan]
                if nim.isCompatible("DVB-S"):
                        self.typeOfScanEntry = getConfigListEntry(_("Type of scan"), self.scan_type)
@@ -353,7 +390,11 @@ class ScanSetup(ConfigListScreen, Screen, CableTransponderSearchSupport):
                                        self.list.append(getConfigListEntry(_("FEC"), self.scan_sat.fec))
                                elif self.scan_sat.system.value == "dvb-s2":
                                        self.list.append(getConfigListEntry(_("FEC"), self.scan_sat.fec_s2))
-                                       self.list.append(getConfigListEntry(_('Modulation'), self.scan_sat.modulation))
+                                       self.modulationEntry = getConfigListEntry(_('Modulation'), self.scan_sat.modulation)
+                                       self.list.append(self.modulationEntry)
+                                       self.list.append(getConfigListEntry(_('Rolloff'), self.scan_sat.rolloff))
+                                       if self.scan_sat.modulation.value == "8psk":
+                                               self.list.append(getConfigListEntry(_('Pilot'), self.scan_sat.pilot))
                                self.list.append(getConfigListEntry(_("Network scan"), self.scan_networkScan))
                        elif self.scan_type.value == "single_satellite":
                                self.updateSatList()
@@ -378,7 +419,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))
-                               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))
@@ -427,7 +468,8 @@ class ScanSetup(ConfigListScreen, Screen, CableTransponderSearchSupport):
                print "cur is", cur
                if cur == self.typeOfScanEntry or \
                        cur == self.tunerEntry or \
-                       cur == self.systemEntry:
+                       cur == self.systemEntry or \
+                       (self.modulationEntry and self.systemEntry[1].value == "dvb-s2" and cur == self.modulationEntry):
                        self.createSetup()
 
        def createConfig(self, frontendData):
@@ -471,10 +513,12 @@ class ScanSetup(ConfigListScreen, Screen, CableTransponderSearchSupport):
                                        defaultSat["inversion"] = {"INVERSION_OFF": "off", "INVERSION_ON": "on", "INVERSION_AUTO": "auto"}[frontendData.get("inversion", "INVERSION_AUTO")]
                                        defaultSat["symbolrate"] = int(frontendData.get("symbol_rate", 0) / 1000)
                                        defaultSat["polarization"] = {"HORIZONTAL": "horizontal", "VERTICAL": "vertical", "CIRCULAR_LEFT": "circular_left", "CIRCULAR_RIGHT": "circular_right", "UNKNOWN": None}[frontendData.get("polarization", "HORIZONTAL")]
-                                       
+
                                        if frontendData.get("system", "DVB-S") == "DVB-S2":
                                                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"} \
                                                                                        [frontendData.get("fec_inner", "FEC_AUTO")]
+                                               defaultSat["rolloff"] = {"ROLLOFF_0_35" : "0_35", "ROLLOFF_0_25" : "0_25", "ROLLOFF_0_20" : "0_20"}[frontendData.get("rolloff", "ROLLOFF_0_35")]
+                                               defaultSat["pilot"] = {"PILOT_ON" : "on", "PILOT_OFF" : "off", "PILOT_AUTO" : "auto"}[frontendData.get("pilot", "PILOT_AUTO")]
                                        else:
                                                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"} \
                                                        [frontendData.get("fec_inner", "FEC_AUTO")]
@@ -523,6 +567,8 @@ class ScanSetup(ConfigListScreen, Screen, CableTransponderSearchSupport):
                        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"))])
                        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")])
                        self.scan_sat.modulation = ConfigSelection(default = defaultSat["modulation"], choices = [("qpsk", "QPSK"), ("8psk", "8PSK")])
+                       self.scan_sat.rolloff = ConfigSelection(default = defaultSat.get("rolloff", "0_35"), choices = [("0_35", "0.35"), ("0_25", "0.25"), ("0_20", "0.20")])
+                       self.scan_sat.pilot = ConfigSelection(default = defaultSat.get("pilot", "auto"), choices = [("off", _("off")), ("on", _("on")), ("auto", _("Auto"))])
 
                        # cable
                        self.scan_cab.frequency = ConfigInteger(default = defaultCab["frequency"], limits = (50, 999))
@@ -582,8 +628,8 @@ class ScanSetup(ConfigListScreen, Screen, CableTransponderSearchSupport):
                           "none": 15
                           }
 
-       def addSatTransponder(self, tlist, frequency, symbol_rate, polarisation, fec, inversion, orbital_position, system, modulation):
-               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)
+       def addSatTransponder(self, tlist, frequency, symbol_rate, polarisation, fec, inversion, orbital_position, system, modulation, rolloff, pilot):
+               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) + " rolloff" + str(rolloff) + " pilot" + str(pilot)
                print "orbpos: " + str(orbital_position)
                parm = eDVBFrontendParametersSatellite()
                if modulation == 1:
@@ -597,6 +643,8 @@ class ScanSetup(ConfigListScreen, Screen, CableTransponderSearchSupport):
                parm.fec = self.fecmap[fec]
                parm.inversion = inversion
                parm.orbital_position = int(orbital_position)
+               parm.rolloff = int(rolloff)
+               parm.pilot = int(pilot)
                tlist.append(parm)
 
        def addCabTransponder(self, tlist, frequency, symbol_rate, modulation, fec, inversion):
@@ -651,7 +699,9 @@ class ScanSetup(ConfigListScreen, Screen, CableTransponderSearchSupport):
                                                                self.scan_sat.inversion.index,
                                                                orbpos,
                                                                self.scan_sat.system.index,
-                                                               self.scan_sat.modulation.index)
+                                                               self.scan_sat.modulation.index,
+                                                               self.scan_sat.rolloff.index,
+                                                               self.scan_sat.pilot.index)
                                flags = self.scan_networkScan.value and eComponentScan.scanNetworkSearch or 0
                                extFlags = False
                        elif self.scan_type.value == "single_satellite":
@@ -728,9 +778,15 @@ class ScanSetup(ConfigListScreen, Screen, CableTransponderSearchSupport):
        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:
-                       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:
@@ -741,18 +797,6 @@ class ScanSimple(ConfigListScreen, Screen, CableTransponderSearchSupport):
        def getNetworksForNim(self, nim):
                if nim.isCompatible("DVB-S"):
                        networks = nimmanager.getSatListForNim(nim.slot)
-# the original code took "loopthrough" etc. into account. Do we need this?
-#                      if nimmanager.getNimConfigMode(1) in ["loopthrough", "satposdepends", "equal", "nothing"]:
-#                              return False
-#                      sec = eDVBSatelliteEquipmentControl.getInstance()
-#                      if sec is not None:
-#                              exclusive_satellites = sec.get_exclusive_satellites(0,1)
-#                              if len(exclusive_satellites) == 2:
-#                                      return False
-#                              idx = exclusive_satellites[0]+1
-#                              exclusive_nim_sats = exclusive_satellites[idx+1:idx+1+exclusive_satellites[idx]]
-#                              if len(exclusive_nim_sats):
-#                                      return True
                elif not nim.empty:
                        networks = [ nim.type ] # "DVB-C" or "DVB-T". TODO: seperate networks for different C/T tuners, if we want to support that.
                else:
@@ -774,6 +818,7 @@ class ScanSimple(ConfigListScreen, Screen, CableTransponderSearchSupport):
 
                known_networks = [ ]
                nims_to_scan = [ ]
+               self.finished_cb = None
 
                for nim in nimmanager.nim_slots:
                        # collect networks provided by this tuner
@@ -812,7 +857,8 @@ class ScanSimple(ConfigListScreen, Screen, CableTransponderSearchSupport):
                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):
@@ -828,46 +874,48 @@ class ScanSimple(ConfigListScreen, Screen, CableTransponderSearchSupport):
 
                n = self.nim_iter < len(self.nim_enable) and self.nim_enable[self.nim_iter] or None
                self.nim_iter += 1
-               if n and n.value: # check if nim is enabled
-                       flags = 0
-                       nim = nimmanager.nim_slots[n.nim_index]
-                       networks = set(self.getNetworksForNim(nim))
-
-                       # don't scan anything twice
-                       networks.discard(self.known_networks)
-
-                       tlist = [ ]
-                       if nim.isCompatible("DVB-S"):
-                               # get initial transponders for each satellite to be scanned
-                               for sat in networks:
-                                       getInitialTransponderList(tlist, sat[0])
-                       elif nim.isCompatible("DVB-C"):
-                               if config.Nims[nim.slot].cable.scan_type.value == "provider":
-                                       getInitialCableTransponderList(tlist, nim.slot)
+               if n:
+                       if n.value: # check if nim is enabled
+                               flags = 0
+                               nim = nimmanager.nim_slots[n.nim_index]
+                               networks = set(self.getNetworksForNim(nim))
+
+                               # don't scan anything twice
+                               networks.discard(self.known_networks)
+
+                               tlist = [ ]
+                               if nim.isCompatible("DVB-S"):
+                                       # get initial transponders for each satellite to be scanned
+                                       for sat in networks:
+                                               getInitialTransponderList(tlist, sat[0])
+                               elif nim.isCompatible("DVB-C"):
+                                       if config.Nims[nim.slot].cable.scan_type.value == "provider":
+                                               getInitialCableTransponderList(tlist, nim.slot)
+                                       else:
+                                               action = SEARCH_CABLE_TRANSPONDERS
+                               elif nim.isCompatible("DVB-T"):
+                                       getInitialTerrestrialTransponderList(tlist, nimmanager.getTerrestrialDescription(nim.slot))
                                else:
-                                       action = SEARCH_CABLE_TRANSPONDERS
-                       elif nim.isCompatible("DVB-T"):
-                               getInitialTerrestrialTransponderList(tlist, nimmanager.getTerrestrialDescription(nim.slot))
-                       else:
-                               assert False
-
-                       flags |= eComponentScan.scanNetworkSearch #FIXMEEE.. use flags from cables / satellites / terrestrial.xml
-                       tmp = self.scan_clearallservices.value
-                       if tmp == "yes":
-                               flags |= eComponentScan.scanRemoveServices
-                       elif tmp == "yes_hold_feeds":
-                               flags |= eComponentScan.scanRemoveServices
-                               flags |= eComponentScan.scanDontRemoveFeeds
+                                       assert False
+
+                               flags |= eComponentScan.scanNetworkSearch #FIXMEEE.. use flags from cables / satellites / terrestrial.xml
+                               tmp = self.scan_clearallservices.value
+                               if tmp == "yes":
+                                       flags |= eComponentScan.scanRemoveServices
+                               elif tmp == "yes_hold_feeds":
+                                       flags |= eComponentScan.scanRemoveServices
+                                       flags |= eComponentScan.scanDontRemoveFeeds
+
+                               if action == APPEND_NOW:
+                                       self.scanList.append({"transponders": tlist, "feid": nim.slot, "flags": flags})
+                               elif action == SEARCH_CABLE_TRANSPONDERS:
+                                       self.flags = flags
+                                       self.feid = nim.slot
+                                       self.startCableTransponderSearch(nim.slot)
+                                       return
+                               else:
+                                       assert False
 
-                       if action == APPEND_NOW:
-                               self.scanList.append({"transponders": tlist, "feid": nim.slot, "flags": flags})
-                       elif action == SEARCH_CABLE_TRANSPONDERS:
-                               self.flags = flags
-                               self.feid = nim.slot
-                               self.startCableTransponderSearch(nim.slot)
-                               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
@@ -876,9 +924,15 @@ class ScanSimple(ConfigListScreen, Screen, CableTransponderSearchSupport):
 
        def startScan(self, scanList):
                if len(scanList):
-                       self.session.open(ServiceScan, scanList = scanList)
+                       if self.finished_cb:
+                               self.session.openWithCallback(self.finished_cb, ServiceScan, scanList = scanList)
+                       else:
+                               self.session.open(ServiceScan, scanList = scanList)
                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})