fix linked tuners option in tuner config,
[enigma2.git] / lib / python / Components / Sources / ServiceList.py
1 from Source import Source
2 from enigma import eServiceCenter, eServiceReference
3
4 class ServiceList(Source):
5         def __init__(self, root, command_func = None):
6                 Source.__init__(self)
7                 self.root = root
8                 self.command_func = command_func
9
10         def getServicesAsList(self, format = "SN"):
11                 services = self.getServiceList()
12                 return services and services.getContent(format, True)
13
14         def getServiceList(self):
15                 serviceHandler = eServiceCenter.getInstance()
16                 return serviceHandler.list(self.root)
17
18         def validateReference(self, ref):
19                 return ref in self.getServicesAsList("S")
20
21         list = property(getServicesAsList)
22         lut = {"Reference": 0, "Name": 1}
23
24         def getRoot(self):
25                 return self.__root
26
27         def setRoot(self, root):
28                 assert isinstance(root, eServiceReference)
29                 self.__root = root
30                 self.changed()
31                 
32         root = property(getRoot, setRoot)
33
34         def handleCommand(self, cmd):
35                 print "ServiceList handle command"
36                 
37                 if not self.validateReference(cmd):
38                         print "Service reference did not validate!"
39                         return
40
41                 ref = eServiceReference(cmd)
42                 if self.command_func:
43                         self.command_func(ref)