provide source/converter for current service name, current service provider
authorFelix Domke <tmbinc@elitedvb.net>
Mon, 26 Jun 2006 16:31:52 +0000 (16:31 +0000)
committerFelix Domke <tmbinc@elitedvb.net>
Mon, 26 Jun 2006 16:31:52 +0000 (16:31 +0000)
lib/python/Components/Converter/Makefile.am
lib/python/Components/Converter/ServiceName.py [new file with mode: 0644]
lib/python/Components/Sources/CurrentService.py [new file with mode: 0644]
lib/python/Components/Sources/Makefile.am

index 5b55ac4..d449bcc 100644 (file)
@@ -2,5 +2,6 @@ installdir = $(LIBDIR)/enigma2/python/Components/Converter
 
 install_PYTHON = \
        __init__.py ClockToText.py Converter.py EventName.py StaticText.py EventTime.py \
-       Poll.py RemainingToText.py StringList.py
+       Poll.py RemainingToText.py StringList.py ServiceName.py
+
 
diff --git a/lib/python/Components/Converter/ServiceName.py b/lib/python/Components/Converter/ServiceName.py
new file mode 100644 (file)
index 0000000..79e0c99
--- /dev/null
@@ -0,0 +1,32 @@
+from Components.Converter.Converter import Converter
+from enigma import iServiceInformation
+
+class ServiceName(Converter, object):
+       NAME = 0
+       PROVIDER = 1
+
+       def __init__(self, type, *args, **kwargs):
+               Converter.__init__(self)
+               if type == "Provider":
+                       self.type = self.PROVIDER
+               else:
+                       self.type = self.NAME
+
+       def getServiceInfoValue(self, info, what):
+               v = info.getInfo(what)
+               if v != -2:
+                       return "N/A"
+               return info.getInfoString(what)
+
+       def getText(self):
+               service = self.source.service
+               info = service and service.info()
+               if info is None:
+                       return ""
+               
+               if self.type == self.NAME:
+                       return service.getName()
+               elif self.type == self.PROVIDER:
+                       return self.getServiceInfoValue(info, iServiceInformation.sProvider)
+
+       text = property(getText)
diff --git a/lib/python/Components/Sources/CurrentService.py b/lib/python/Components/Sources/CurrentService.py
new file mode 100644 (file)
index 0000000..bec6d2d
--- /dev/null
@@ -0,0 +1,22 @@
+from Components.PerServiceDisplay import PerServiceBase
+from enigma import iPlayableService
+from Source import Source
+
+class CurrentService(PerServiceBase, Source):
+       def __init__(self, navcore):
+               Source.__init__(self)
+               PerServiceBase.__init__(self, navcore, 
+                       { 
+                               iPlayableService.evStart: self.changed,
+                               iPlayableService.evEnd: self.changed 
+                       })
+               self.navcore = navcore
+
+       def getCurrentService(self):
+               service = self.navcore.getCurrentService()
+               return service
+
+       def stopEvent(self):
+               self.changed()
+
+       service = property(getCurrentService)
index 9e15112..a7d5ae9 100644 (file)
@@ -1,5 +1,6 @@
 installdir = $(LIBDIR)/enigma2/python/Components/Sources
 
 install_PYTHON = \
-       __init__.py Clock.py EventInfo.py Source.py MenuList.py
+       __init__.py Clock.py EventInfo.py Source.py MenuList.py CurrentService.py
+