add servicelist source
authorFelix Domke <tmbinc@elitedvb.net>
Fri, 22 Sep 2006 16:47:27 +0000 (16:47 +0000)
committerFelix Domke <tmbinc@elitedvb.net>
Fri, 22 Sep 2006 16:47:27 +0000 (16:47 +0000)
lib/python/Components/Sources/ServiceList.py [new file with mode: 0644]

diff --git a/lib/python/Components/Sources/ServiceList.py b/lib/python/Components/Sources/ServiceList.py
new file mode 100644 (file)
index 0000000..4d18415
--- /dev/null
@@ -0,0 +1,43 @@
+from Source import Source
+from enigma import eServiceCenter, eServiceReference
+
+class ServiceList(Source):
+       def __init__(self, root, command_func = None):
+               Source.__init__(self)
+               self.root = root
+               self.command_func = command_func
+
+       def getServicesAsList(self, format = "SN"):
+               services = self.getServiceList()
+               return services and services.getContent(format, True)
+
+       def getServiceList(self):
+               serviceHandler = eServiceCenter.getInstance()
+               return serviceHandler.list(self.root)
+
+       def validateReference(self, ref):
+               return ref in self.getServicesAsList("S")
+
+       list = property(getServicesAsList)
+       lut = {"Reference": 0, "Name": 1}
+
+       def getRoot(self):
+               return self.__root
+
+       def setRoot(self, root):
+               assert isinstance(root, eServiceReference)
+               self.__root = root
+               self.changed()
+               
+       root = property(getRoot, setRoot)
+
+       def handleCommand(self, cmd):
+               print "ServiceList handle command"
+               
+               if not self.validateReference(cmd):
+                       print "Service reference did not validate!"
+                       return
+
+               ref = eServiceReference(cmd)
+               if self.command_func:
+                       self.command_func(ref)