fix caching
[enigma2.git] / lib / python / Components / Sources / EventInfo.py
1 from Components.PerServiceDisplay import PerServiceBase
2 from Components.Element import cached
3 from Tools.Event import Event
4 from enigma import iPlayableService
5 from Source import Source
6
7 from time import time
8
9 class EventInfo(PerServiceBase, Source, object):
10         NOW = 0
11         NEXT = 1
12         
13         def __init__(self, navcore, now_or_next):
14                 Source.__init__(self)
15                 PerServiceBase.__init__(self, navcore, 
16                         { 
17                                 iPlayableService.evStart: self.gotEvent,
18                                 iPlayableService.evUpdatedEventInfo: self.gotEvent,
19                                 iPlayableService.evEnd: self.gotEvent
20                         }, with_event=True)
21                 
22                 self.now_or_next = now_or_next
23
24         @cached
25         def getEvent(self):
26                 service = self.navcore.getCurrentService()
27                 info = service and service.info()
28                 return info and info.getEvent(self.now_or_next)
29
30         event = property(getEvent)
31
32         def gotEvent(self, what):
33                 if what in [iPlayableService.evStart, iPlayableService.evEnd]:
34                         self.changed((self.CHANGED_CLEAR,))
35                 else:
36                         self.changed((self.CHANGED_ALL,))