more generic Components/Network.py for allowing other interface names (thx to Reichi)
[enigma2.git] / lib / python / Screens / ScanSetup.py
index ea8d0b0af8e26805204b6fcb6d2e516e496a17b4..445c71d8cf2b927b82e5472c47ca678b5c3d839a 100644 (file)
@@ -3,7 +3,7 @@ from ServiceScan import *
 from Components.config import config, ConfigSubsection, ConfigSelection, ConfigYesNo, ConfigInteger, getConfigListEntry, ConfigSlider, ConfigSatlist, ConfigEnableDisable
 from Components.ActionMap import NumberActionMap
 from Components.ConfigList import ConfigList, ConfigListScreen
 from Components.config import config, ConfigSubsection, ConfigSelection, ConfigYesNo, ConfigInteger, getConfigListEntry, ConfigSlider, ConfigSatlist, ConfigEnableDisable
 from Components.ActionMap import NumberActionMap
 from Components.ConfigList import ConfigList, ConfigListScreen
-from Components.NimManager import nimmanager
+from Components.NimManager import nimmanager, getConfigSatlist
 from Components.Label import Label
 from Screens.MessageBox import MessageBox
 from enigma import eTimer, eDVBFrontendParametersSatellite, eComponentScan, eDVBSatelliteEquipmentControl, eDVBFrontendParametersTerrestrial, eDVBFrontendParametersCable
 from Components.Label import Label
 from Screens.MessageBox import MessageBox
 from enigma import eTimer, eDVBFrontendParametersSatellite, eComponentScan, eDVBSatelliteEquipmentControl, eDVBFrontendParametersTerrestrial, eDVBFrontendParametersCable
@@ -135,12 +135,11 @@ class ScanSetup(ConfigListScreen, Screen):
                frontendData = None
                if self.service is not None:
                        self.feinfo = self.service.frontendInfo()
                frontendData = None
                if self.service is not None:
                        self.feinfo = self.service.frontendInfo()
-                       frontendData = self.feinfo and self.feinfo.getFrontendData(True)
+                       frontendData = self.feinfo and self.feinfo.getAll(True)
                self.createConfig(frontendData)
                del self.feinfo
                del self.service
 
                self.createConfig(frontendData)
                del self.feinfo
                del self.service
 
-
                self["actions"] = NumberActionMap(["SetupActions"],
                {
                        "ok": self.keyGo,
                self["actions"] = NumberActionMap(["SetupActions"],
                {
                        "ok": self.keyGo,
@@ -189,10 +188,10 @@ class ScanSetup(ConfigListScreen, Screen):
                        self.list.append(self.typeOfScanEntry)
 
                if nimmanager.getNimType(self.scan_nims.index) == nimmanager.nimType["DVB-S"]:
                        self.list.append(self.typeOfScanEntry)
 
                if nimmanager.getNimType(self.scan_nims.index) == nimmanager.nimType["DVB-S"]:
-
                        if self.scan_type.value == "single_transponder":
                        if self.scan_type.value == "single_transponder":
-                               self.systemEntry = getConfigListEntry(_('Transpondertype'), self.scan_sat.system)
-                               self.list.append(self.systemEntry)
+                               if nimmanager.getNimName(self.scan_nims.index).find("DVB-S2") != -1:
+                                       self.systemEntry = getConfigListEntry(_('Transpondertype'), self.scan_sat.system)
+                                       self.list.append(self.systemEntry)
                                self.list.append(getConfigListEntry(_('Satellite'), self.scan_satselection[self.scan_nims.index]))
                                self.list.append(getConfigListEntry(_('Frequency'), self.scan_sat.frequency))
                                self.list.append(getConfigListEntry(_('Inversion'), self.scan_sat.inversion))
                                self.list.append(getConfigListEntry(_('Satellite'), self.scan_satselection[self.scan_nims.index]))
                                self.list.append(getConfigListEntry(_('Frequency'), self.scan_sat.frequency))
                                self.list.append(getConfigListEntry(_('Inversion'), self.scan_sat.inversion))
@@ -316,21 +315,24 @@ class ScanSetup(ConfigListScreen, Screen):
                        defaultSat = { "orbpos": 192, "system": "dvb-s", "frequency": 11836, "inversion": "auto", "symbolrate": 27500, "polarization": "horizontal", "fec": "auto", "fec_s2": "9_10", "modulation": "qpsk" }
                        defaultCab = {"frequency": 466, "inversion": "auto", "modulation": "64qam", "fec": "auto", "symbolrate": 6900}
                        if frontendData is not None:
                        defaultSat = { "orbpos": 192, "system": "dvb-s", "frequency": 11836, "inversion": "auto", "symbolrate": 27500, "polarization": "horizontal", "fec": "auto", "fec_s2": "9_10", "modulation": "qpsk" }
                        defaultCab = {"frequency": 466, "inversion": "auto", "modulation": "64qam", "fec": "auto", "symbolrate": 6900}
                        if frontendData is not None:
-                               if frontendData["tuner_type"] == "DVB-S":
-                                       defaultSat["system"] = {"DVB-S": "dvb-s", "DVB-S2": "dvb-s2"}[frontendData["system"]]
-                                       defaultSat["frequency"] = int(frontendData["frequency"] / 1000)
-                                       defaultSat["inversion"] = {"INVERSION_OFF": "off", "INVERSION_ON": "on", "INVERSION_AUTO": "auto"}[frontendData["inversion"]]
-                                       defaultSat["symbolrate"] = int(frontendData["symbol_rate"] / 1000)
-                                       defaultSat["polarization"] = {"HORIZONTAL": "horizontal", "VERTICAL": "vertical", "CIRCULAR_LEFT": "circular_left", "CIRCULAR_RIGHT": "circular_right", "UNKNOWN": None}[frontendData["polarization"]]
-                                       defaultSat["fec"] = {"DVB-S": {"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"}, "DVB-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["system"]][frontendData["fec_inner"]]
-                                       defaultSat["modulation"] = {"QPSK": "qpsk", "8PSK": "8psk"}[frontendData["modulation"]]
-                                       defaultSat["orbpos"] = frontendData["orbital_position"]
-                               elif frontendData["tuner_type"] == "DVB-C":
-                                       defaultCab["frequency"] = int(frontendData["frequency"] / 1000)
-                                       defaultCab["symbolrate"] = int(frontendData["symbol_rate"] / 1000)
-                                       defaultSat["inversion"] = {"INVERSION_OFF": "off", "INVERSION_ON": "on", "INVERSION_AUTO": "auto"}[frontendData["inversion"]]
-                                       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_8_9": "8_9", "FEC_NONE": "none"}[frontendData["fec_inner"]]
-                                       defaultSat["modulation"] = {"QAM_AUTO": "auto", "QAM_16": "16qam", "QAM_32": "32qam", "QAM_64": "64qam", "QAM_128": "128qam", "QAM_256": "256qam"}[frontendData["modulation"]]
+                               ttype = frontendData.get("tuner_type", "UNKNOWN")
+                               if ttype == "DVB-S":
+                                       defaultSat["system"] = {"DVB-S": "dvb-s", "DVB-S2": "dvb-s2"}[frontendData.get("system", "DVB-S")]
+                                       defaultSat["frequency"] = int(frontendData.get("frequency", 0) / 1000)
+                                       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")]
+                                       defaultSat["fec"] = {"DVB-S": {"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"}, \
+                                                                               "DVB-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("system", "DVB-S")][frontendData.get("fec_inner", "FEC_AUTO")]
+                                       defaultSat["modulation"] = {"QPSK": "qpsk", "8PSK": "8psk"}[frontendData.get("modulation", "QPSK")]
+                                       defaultSat["orbpos"] = frontendData.get("orbital_position", 0)
+                               elif ttype == "DVB-C":
+                                       defaultCab["frequency"] = int(frontendData.get("frequency", 0) / 1000)
+                                       defaultCab["symbolrate"] = int(frontendData.get("symbol_rate", 0) / 1000)
+                                       defaultCab["inversion"] = {"INVERSION_OFF": "off", "INVERSION_ON": "on", "INVERSION_AUTO": "auto"}[frontendData.get("inversion", "INVERSION_AUTO")]
+                                       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")]
+                                       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")]
 
                        self.scan_sat = ConfigSubsection()
                        self.scan_cab = ConfigSubsection()
 
                        self.scan_sat = ConfigSubsection()
                        self.scan_cab = ConfigSubsection()
@@ -397,7 +399,7 @@ class ScanSetup(ConfigListScreen, Screen):
                        for slot in nimmanager.nimslots:
                                if (nimmanager.getNimType(slot.slotid) == nimmanager.nimType["DVB-S"]):
                                        print str(slot.slotid) + " : " + str(self.satList)
                        for slot in nimmanager.nimslots:
                                if (nimmanager.getNimType(slot.slotid) == nimmanager.nimType["DVB-S"]):
                                        print str(slot.slotid) + " : " + str(self.satList)
-                                       self.scan_satselection.append(ConfigSatlist(default = defaultSat["orbpos"], list = self.satList[slot.slotid]))
+                                       self.scan_satselection.append(getConfigSatlist(int(defaultSat["orbpos"]), self.satList[slot.slotid]))
                                else:
                                        self.scan_satselection.append(None)
 
                                else:
                                        self.scan_satselection.append(None)
 
@@ -590,6 +592,8 @@ class ScanSimple(ConfigListScreen, Screen):
                        nim.nim_index = 0
                        if nimtype == nimmanager.nimType["DVB-S"] and not len(nimmanager.getSatListForNim(0)):
                                scan_possible=False
                        nim.nim_index = 0
                        if nimtype == nimmanager.nimType["DVB-S"] and not len(nimmanager.getSatListForNim(0)):
                                scan_possible=False
+                       if nimtype == nimmanager.nimType["empty/unknown"]:
+                               scan_possible = False
                        if scan_possible:
                                self.list.append(getConfigListEntry(_("Scan NIM") + " 0 (" + nimmanager.getNimTypeName(0) + ")", nim))
 
                        if scan_possible:
                                self.list.append(getConfigListEntry(_("Scan NIM") + " 0 (" + nimmanager.getNimTypeName(0) + ")", nim))
 
@@ -680,6 +684,8 @@ class ScanSimple(ConfigListScreen, Screen):
                return 0
 
        def ScanNimTwoNeeded(self):
                return 0
 
        def ScanNimTwoNeeded(self):
+               if nimmanager.getNimType(1) == nimmanager.nimType["empty/unknown"]:
+                       return False
                if nimmanager.getNimType(0) != nimmanager.getNimType(1):
                        return True
                if nimmanager.getNimType(0) == nimmanager.nimType["DVB-S"]: #two dvb-s nims
                if nimmanager.getNimType(0) != nimmanager.getNimType(1):
                        return True
                if nimmanager.getNimType(0) == nimmanager.nimType["DVB-S"]: #two dvb-s nims