add SNRdB, but requires proper frontend support
[enigma2.git] / lib / python / Components / Converter / ServiceName.py
1 # -*- coding: utf-8 -*-
2 from Components.Converter.Converter import Converter
3 from enigma import iServiceInformation, iPlayableService
4 from Components.Element import cached
5
6 class ServiceName(Converter, object):
7         NAME = 0
8         PROVIDER = 1
9
10         def __init__(self, type):
11                 Converter.__init__(self, type)
12                 if type == "Provider":
13                         self.type = self.PROVIDER
14                 else:
15                         self.type = self.NAME
16
17         def getServiceInfoValue(self, info, what):
18                 v = info.getInfo(what)
19                 if v != -2:
20                         return "N/A"
21                 return info.getInfoString(what)
22
23         @cached
24         def getText(self):
25                 service = self.source.service
26                 info = service and service.info()
27                 if info is None:
28                         return ""
29                 
30                 if self.type == self.NAME:
31                         return info.getName().replace('\xc2\x86', '').replace('\xc2\x87', '')
32                 elif self.type == self.PROVIDER:
33                         return self.getServiceInfoValue(info, iServiceInformation.sProvider)
34
35         text = property(getText)
36
37         def changed(self, what):
38                 if what[0] != self.CHANGED_SPECIFIC or what[1] in [iPlayableService.evStart]:
39                         Converter.changed(self, what)