fixes bug #556
[enigma2.git] / lib / python / Screens / ServiceInfo.py
index 01cfc61aac6ad4898dc55dcb09429333620ef9ee..fa2f4474fc5d827406ef4eaa8c0dfc4ca716d811 100644 (file)
@@ -5,6 +5,7 @@ from Components.ActionMap import ActionMap
 from Components.Label import Label
 from ServiceReference import ServiceReference
 from enigma import eListboxPythonMultiContent, eListbox, gFont, iServiceInformation, eServiceCenter
+from Tools.Transponder import ConvertToHumanReadable
 
 RT_HALIGN_LEFT = 0
 
@@ -14,26 +15,27 @@ TYPE_VALUE_DEC = 2
 TYPE_VALUE_HEX_DEC = 3
 TYPE_SLIDER = 4
 
-def ServiceInfoListEntry(a, b, valueType=TYPE_TEXT, param=4):
-       res = [ ]
+def to_unsigned(x):
+       return x & 0xFFFFFFFF
 
-       #PyObject *type, *px, *py, *pwidth, *pheight, *pfnt, *pstring, *pflags;
-       res.append((eListboxPythonMultiContent.TYPE_TEXT, 0, 0, 200, 30, 0, RT_HALIGN_LEFT, ""))
-       res.append((eListboxPythonMultiContent.TYPE_TEXT, 0, 0, 200, 25, 0, RT_HALIGN_LEFT, a))
+def ServiceInfoListEntry(a, b, valueType=TYPE_TEXT, param=4):
        print "b:", b
-       if type(b) is not str:
+       if not isinstance(b, str):
                if valueType == TYPE_VALUE_HEX:
-                       b = ("0x%0" + str(param) + "x") % b
+                       b = ("0x%0" + str(param) + "x") % to_unsigned(b)
                elif valueType == TYPE_VALUE_DEC:
                        b = str(b)
                elif valueType == TYPE_VALUE_HEX_DEC:
-                       b = ("0x%0" + str(param) + "x (%dd)") % (b, b)
+                       b = ("0x%0" + str(param) + "x (%dd)") % (to_unsigned(b), b)
                else:
                        b = str(b)
-       
-       res.append((eListboxPythonMultiContent.TYPE_TEXT, 220, 0, 350, 25, 0, RT_HALIGN_LEFT, b))
 
-       return res
+       return [
+               #PyObject *type, *px, *py, *pwidth, *pheight, *pfnt, *pstring, *pflags;
+               (eListboxPythonMultiContent.TYPE_TEXT, 0, 0, 200, 30, 0, RT_HALIGN_LEFT, ""),
+               (eListboxPythonMultiContent.TYPE_TEXT, 0, 0, 200, 25, 0, RT_HALIGN_LEFT, a),
+               (eListboxPythonMultiContent.TYPE_TEXT, 220, 0, 350, 25, 0, RT_HALIGN_LEFT, b)
+       ]
 
 class ServiceInfoList(HTMLComponent, GUIComponent):
        def __init__(self, source):
@@ -101,8 +103,10 @@ class ServiceInfo(Screen):
                if self.type == TYPE_SERVICE_INFO:
                        if self.session.nav.getCurrentlyPlayingServiceReference():
                                name = ServiceReference(self.session.nav.getCurrentlyPlayingServiceReference()).getServiceName()
+                               refstr = self.session.nav.getCurrentlyPlayingServiceReference().toString()
                        else:
                                name = "N/A"
+                               refstr = "N/A"
                        aspect = self.getServiceInfoValue(iServiceInformation.sAspect)
                        if aspect in ( 1, 2, 5, 6, 9, 0xA, 0xD, 0xE ):
                                aspect = "4:3"
@@ -115,35 +119,37 @@ class ServiceInfo(Screen):
                                                   ("Provider", self.getServiceInfoValue(iServiceInformation.sProvider), TYPE_TEXT),
                                                   ("Videoformat", aspect, TYPE_TEXT),
                                                   ("Videosize", "%dx%d" %(width, height), TYPE_TEXT),
-                                                  ("Namespace", self.getServiceInfoValue(iServiceInformation.sNamespace), TYPE_VALUE_HEX, 8))
+                                                  ("Namespace", self.getServiceInfoValue(iServiceInformation.sNamespace), TYPE_VALUE_HEX, 8),
+                                                  ("Service Reference", refstr, TYPE_TEXT))
                        else:
                                Labels = ( ("Name", name, TYPE_TEXT),
                                                   ("Provider", self.getServiceInfoValue(iServiceInformation.sProvider), TYPE_TEXT),
                                                   ("Videoformat", aspect, TYPE_TEXT),
-                                                  ("Namespace", self.getServiceInfoValue(iServiceInformation.sNamespace), TYPE_VALUE_HEX, 8))
+                                                  ("Namespace", self.getServiceInfoValue(iServiceInformation.sNamespace), TYPE_VALUE_HEX, 8),
+                                                  ("Service Reference", refstr, TYPE_TEXT))
                        self.fillList(Labels)
                else:
                        if self.transponder_info:
-                               conv = { "type"                         : _("Transponder Type"),
-                                                "frequency"            : _("Frequency"),
-                                                "symbolrate"           : _("Symbolrate"),
-                                                "orbital position" : _("Orbital Position"),
-                                                "inversion"            : _("Inversion"),
-                                                "fec inner"            : _("FEC"),
-                                                "modulation"           : _("Modulation"),
-                                                "polarization"         : _("Polarization"),
-                                                "roll off"                     : _("Rolloff"),
+                               tp_info = ConvertToHumanReadable(self.transponder_info)
+                               conv = { "tuner_type"           : _("Transponder Type"),
                                                 "system"                       : _("System"),
+                                                "modulation"           : _("Modulation"),
+                                                "orbital_position" : _("Orbital Position"),
+                                                "frequency"            : _("Frequency"),
+                                                "symbol_rate"          : _("Symbolrate"),
                                                 "bandwidth"            : _("Bandwidth"),
-                                                "code rate lp"         : _("Coderate LP"),
-                                                "code rate hp"         : _("Coderate HP"),
+                                                "polarization"         : _("Polarization"),
+                                                "inversion"            : _("Inversion"),
+                                                "pilot"                        : _("Pilot"),
+                                                "rolloff"                      : _("Rolloff"),
+                                                "fec_inner"            : _("FEC"),
+                                                "code_rate_lp"         : _("Coderate LP"),
+                                                "code_rate_hp"         : _("Coderate HP"),
                                                 "constellation"        : _("Constellation"),
-                                                "transmission mode": _("Transmission Mode"),
-                                                "guard interval"       : _("Guard Interval"),
-                                                "hierarchy"            : _("Hierarchy Information") }
-                               Labels = [ ]
-                               for i in self.transponder_info.keys():
-                                       Labels.append( (conv[i], self.transponder_info[i], TYPE_TEXT) )
+                                                "transmission_mode": _("Transmission Mode"),
+                                                "guard_interval"       : _("Guard Interval"),
+                                                "hierarchy_information": _("Hierarchy Information") }
+                               Labels = [(conv[i], tp_info[i], TYPE_VALUE_DEC) for i in tp_info.keys()]
                                self.fillList(Labels)
 
        def pids(self):
@@ -172,10 +178,11 @@ class ServiceInfo(Screen):
                if self.type == TYPE_SERVICE_INFO:
                        self.showFrontendData(False)
 
-       def getFEData(self, frontendData):
-               if frontendData and len(frontendData):
-                       if frontendData["tuner_type"] == "DVB-S":
-                               return (("NIM", ['A', 'B', 'C', 'D'][frontendData["tuner_number"]], TYPE_TEXT),
+       def getFEData(self, frontendDataOrg):
+               if frontendDataOrg and len(frontendDataOrg):
+                       frontendData = ConvertToHumanReadable(frontendDataOrg)
+                       if frontendDataOrg["tuner_type"] == "DVB-S":
+                               return (("NIM", ('A', 'B', 'C', 'D')[frontendData["tuner_number"]], TYPE_TEXT),
                                                        ("Type", frontendData["system"], TYPE_TEXT),
                                                        ("Modulation", frontendData["modulation"], TYPE_TEXT),
                                                        ("Orbital position", frontendData["orbital_position"], TYPE_VALUE_DEC),
@@ -183,17 +190,19 @@ class ServiceInfo(Screen):
                                                        ("Symbolrate", frontendData["symbol_rate"], TYPE_VALUE_DEC),
                                                        ("Polarization", frontendData["polarization"], TYPE_TEXT),
                                                        ("Inversion", frontendData["inversion"], TYPE_TEXT),
-                                                       ("FEC inner", frontendData["fec_inner"], TYPE_TEXT))
-                       elif frontendData["tuner_type"] == "DVB-C":
-                               return (("NIM", ['A', 'B', 'C', 'D'][frontendData["tuner_number"]], TYPE_TEXT),
+                                                       ("FEC inner", frontendData["fec_inner"], TYPE_TEXT),
+                                                       ("Pilot", frontendData.get("pilot", None), TYPE_TEXT),
+                                                       ("Rolloff", frontendData.get("rolloff", None), TYPE_TEXT))
+                       elif frontendDataOrg["tuner_type"] == "DVB-C":
+                               return (("NIM", ('A', 'B', 'C', 'D')[frontendData["tuner_number"]], TYPE_TEXT),
                                                ("Type", frontendData["tuner_type"], TYPE_TEXT),
                                                ("Frequency", frontendData["frequency"], TYPE_VALUE_DEC),
                                                ("Symbolrate", frontendData["symbol_rate"], TYPE_VALUE_DEC),
                                                ("Modulation", frontendData["modulation"], TYPE_TEXT),
                                                ("Inversion", frontendData["inversion"], TYPE_TEXT),
                                                ("FEC inner", frontendData["fec_inner"], TYPE_TEXT))
-                       elif frontendData["tuner_type"] == "DVB-T":
-                               return (("NIM", ['A', 'B', 'C', 'D'][frontendData["tuner_number"]], TYPE_TEXT),
+                       elif frontendDataOrg["tuner_type"] == "DVB-T":
+                               return (("NIM", ('A', 'B', 'C', 'D')[frontendData["tuner_number"]], TYPE_TEXT),
                                                ("Type", frontendData["tuner_type"], TYPE_TEXT),
                                                ("Frequency", frontendData["frequency"], TYPE_VALUE_DEC),
                                                ("Inversion", frontendData["inversion"], TYPE_TEXT),
@@ -210,6 +219,8 @@ class ServiceInfo(Screen):
                tlist = [ ]
 
                for item in Labels:
+                       if item[1] is None:
+                               continue;
                        value = item[1]
                        if len(item) < 4:
                                tlist.append(ServiceInfoListEntry(item[0]+":", value, item[2]))