do nothing when old and new service is equal
[enigma2.git] / lib / python / Components / Sources / ServiceEvent.py
1 from Components.VariableText import VariableText
2 from Components.Element import cached
3 from Components.GUIComponent import GUIComponent
4 from enigma import eEPGCache, eServiceReference as Ref, eLabel
5 from Source import Source
6
7 class ServiceEvent(VariableText, GUIComponent, Source, object):
8         def __init__(self):
9                 Source.__init__(self)
10                 GUIComponent.__init__(self)
11                 VariableText.__init__(self)
12                 self.cur_ref = None
13
14         GUI_WIDGET = eLabel
15
16 #TODO Add a timer to get every minute the actual event..
17 #but this just make sense when the Servicelist do the same thing..
18         @cached
19         def getCurrentEvent(self):
20                 epg = eEPGCache.getInstance()
21                 return epg and self.cur_ref and epg.startTimeQuery(self.cur_ref) != -1 and epg.getNextTimeEntry() or None
22
23         event = property(getCurrentEvent)
24
25         def newService(self, ref):
26                 if not self.cur_ref or self.cur_ref != ref:
27                         self.cur_ref = ref
28                         if not ref or (ref.flags & Ref.flagDirectory) == Ref.flagDirectory or ref.flags & Ref.isMarker:
29                                 self.changed((self.CHANGED_CLEAR,))
30                         else:
31                                 self.changed((self.CHANGED_ALL,))