From d4c326ff3537c63c2a7fac1fec98fb08bed0f0ee Mon Sep 17 00:00:00 2001 From: Felix Domke Date: Fri, 22 Sep 2006 16:47:27 +0000 Subject: add servicelist source --- lib/python/Components/Sources/ServiceList.py | 43 ++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 lib/python/Components/Sources/ServiceList.py (limited to 'lib/python/Components/Sources') diff --git a/lib/python/Components/Sources/ServiceList.py b/lib/python/Components/Sources/ServiceList.py new file mode 100644 index 00000000..4d184152 --- /dev/null +++ b/lib/python/Components/Sources/ServiceList.py @@ -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) -- cgit v1.2.3