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