add Title to Zap URL
[enigma2-plugins.git] / webinterface / src / WebComponents / Sources / SwitchService.py
1 from Components.Sources.Source import Source
2 from Components.config import config
3 from enigma import eServiceReference
4
5 class SwitchService(Source):
6         def __init__(self, session):
7                 Source.__init__(self)
8                 self.session = session
9                 self.res = ( False, "Parameter sRef is missing" )
10         
11         def handleCommand(self, cmd):           
12                 self.res = self.switchService(cmd)
13                 
14         def switchService(self, cmd):
15                 print "[SwitchService] ref=%s" %cmd["sRef"]
16                 
17                 pc = config.ParentalControl.configured.value
18
19                 """
20                 #HACK
21                 switching config.ParentalControl.configured.value
22                 """             
23                 if pc:
24                         config.ParentalControl.configured.value = False
25                 if config.plugins.Webinterface.allowzapping.value:
26                         eref= eServiceReference(cmd["sRef"])
27                         if cmd["title"] is not None:
28                                 eref.setName(cmd["title"])
29                         self.session.nav.playService(eref)      
30                         if pc:
31                                 config.ParentalControl.configured.value = pc
32                         
33                         return ( True, "Active service switched to %s" %cmd["sRef"] )
34                 
35                 else:
36                         return ( False, "Zapping is disabled in WebInterface Configuration" )
37         
38         result = property(lambda self: self.res)
39