d06690b2ab5e98de8cddda0f048db1594b3dba5b
[openblackhole/openblackhole-enigma2.git] / lib / python / Components / Sources / CurrentService.py
1 from Components.PerServiceDisplay import PerServiceBase
2 from enigma import iPlayableService
3 from Source import Source
4 from Components.Element import cached
5 import NavigationInstance
6
7 class CurrentService(PerServiceBase, Source):
8         def __init__(self, navcore):
9                 Source.__init__(self)
10                 PerServiceBase.__init__(self, navcore,
11                         {
12                                 iPlayableService.evStart: self.serviceEvent,
13                                 iPlayableService.evEnd: self.serviceEvent,
14                                 # FIXME: we should check 'interesting_events'
15                                 # which is not always provided.
16                                 iPlayableService.evUpdatedInfo: self.serviceEvent,
17                                 iPlayableService.evUpdatedEventInfo: self.serviceEvent,
18                                 iPlayableService.evNewProgramInfo: self.serviceEvent,
19                                 iPlayableService.evCuesheetChanged: self.serviceEvent,
20                                 iPlayableService.evVideoSizeChanged: self.serviceEvent,
21                                 iPlayableService.evHBBTVInfo: self.serviceEvent
22                         }, with_event=True)
23                 self.navcore = navcore
24
25         def serviceEvent(self, event):
26                 self.changed((self.CHANGED_SPECIFIC, event))
27
28         @cached
29         def getCurrentService(self):
30                 return self.navcore.getCurrentService()
31
32         service = property(getCurrentService)
33
34         @cached
35         def getCurrentServiceRef(self):
36                 if NavigationInstance.instance is not None:
37                         return NavigationInstance.instance.getCurrentlyPlayingServiceOrGroup()
38                 return None
39
40         serviceref = property(getCurrentServiceRef)
41
42         def destroy(self):
43                 PerServiceBase.destroy(self)
44                 Source.destroy(self)
45