1 from Source import Source
2 from enigma import eServiceCenter, eServiceReference
4 class ServiceList(Source):
5 def __init__(self, root, command_func = None, validate_commands = True):
8 self.command_func = command_func
9 self.validate_commands = validate_commands
11 def getServicesAsList(self, format = "SN"):
12 services = self.getServiceList()
13 return services and services.getContent(format, True)
15 def getServiceList(self):
16 serviceHandler = eServiceCenter.getInstance()
17 return serviceHandler.list(self.root)
19 def validateReference(self, ref):
20 return ref in self.getServicesAsList("S")
22 list = property(getServicesAsList)
23 lut = {"Reference": 0, "Name": 1}
28 def setRoot(self, root):
29 assert isinstance(root, eServiceReference)
33 root = property(getRoot, setRoot)
35 def handleCommand(self, cmd):
36 print "ServiceList handle command"
38 if self.validate_commands and not self.validateReference(cmd):
39 print "Service reference did not validate!"
42 ref = eServiceReference(cmd)
44 self.command_func(ref)