- add description for timer entries
[openblackhole/openblackhole-enigma2.git] / Navigation.py
1 from enigma import *
2 import RecordTimer
3
4 import NavigationInstance
5 import ServiceReference
6
7 # TODO: remove pNavgation, eNavigation and rewrite this stuff in python.
8 class Navigation:
9         def __init__(self):
10                 if NavigationInstance.instance is not None:
11                         raise NavigationInstance.instance
12                 
13                 NavigationInstance.instance = self
14                 self.ServiceHandler = eServiceCenterPtr()
15                 eServiceCenter.getInstance(self.ServiceHandler)
16
17                 import Navigation as Nav
18                 Nav.navcore = self
19                 
20                 print "Navcore instance set!"
21                 print Nav.navcore
22                 
23                 self.pnav = pNavigation()
24                 self.pnav.m_event.get().append(self.callEvent)
25                 self.event = [ ]
26                 self.currentlyPlayingService = None
27                 
28                 self.RecordTimer = RecordTimer.RecordTimer()
29
30         def callEvent(self, i):
31                 for x in self.event:
32                         x(i)
33         
34         def playService(self, ref):
35                 self.currentlyPlayingServiceReference = None
36                 if not self.pnav.playService(ref):
37                         self.currentlyPlayingServiceReference = ref
38                         return 0
39                 return 1
40         
41         def getCurrentlyPlayingServiceReference(self):
42                 return self.currentlyPlayingServiceReference
43         
44         def recordService(self, ref):
45                 print "recording service: %s" % (str(ref))
46                 if isinstance(ref, ServiceReference.ServiceReference):
47                         ref = ref.ref
48                 service = iRecordableServicePtr()
49                 if self.pnav.recordService(ref, service):
50                         print "record returned non-zero"
51                         return None
52                 else:
53                         print "ok, recordService didn't fail"
54                         return service
55         
56         def enqueueService(self, ref):
57                 return self.pnav.enqueueService(ref)
58         
59         def getCurrentService(self):
60                 service = iPlayableServicePtr()
61                 if self.pnav.getCurrentService(service):
62                         return None
63                 return service
64         
65         def getPlaylist(self):
66                 playlist = ePlaylistPtr()
67                 if self.pnav.getPlaylist(playlist):
68                         return None
69                 return playlist
70         
71         def pause(self, p):
72                 return self.pnav.pause(p)
73         
74         def recordWithTimer(self, begin, end, ref, epg, description):
75                 if isinstance(ref, eServiceReference):
76                         ref = ServiceReference.ServiceReference(ref)
77                 entry = RecordTimer.RecordTimerEntry(begin, end, ref, epg, description)
78                 self.RecordTimer.record(entry)
79                 return entry
80         
81         def shutdown(self):
82                 self.RecordTimer.shutdown()