add subtitle widget
[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 = eServiceCenter.getInstance()
15
16                 import Navigation as Nav
17                 Nav.navcore = self
18                 
19                 self.pnav = pNavigation()
20                 self.pnav.m_event.get().append(self.callEvent)
21                 self.event = [ ]
22                 self.currentlyPlayingService = None
23                 self.currentlyPlayingServiceReference = None
24                 
25                 self.RecordTimer = RecordTimer.RecordTimer()
26
27         def callEvent(self, i):
28                 for x in self.event:
29                         x(i)
30         
31         def playService(self, ref):
32                 print "playing", ref
33                 self.currentlyPlayingServiceReference = None
34                 if ref is None:
35                         self.stopService()
36                         return 0
37                 
38                 if not self.pnav.playService(ref):
39                         self.currentlyPlayingServiceReference = ref
40                         return 0
41                 return 1
42         
43         def getCurrentlyPlayingServiceReference(self):
44                 return self.currentlyPlayingServiceReference
45         
46         def recordService(self, ref):
47                 print "recording service: %s" % (str(ref))
48                 if isinstance(ref, ServiceReference.ServiceReference):
49                         ref = ref.ref
50                 service = self.pnav.recordService(ref)
51                 
52                 if service is None:
53                         print "record returned non-zero"
54                         return None
55                 else:
56                         return service
57         
58         def getCurrentService(self):
59                 service = self.pnav.getCurrentService()
60                 
61                 if service is None:
62                         return None
63                 
64                 return service
65         
66         def stopService(self):
67                 self.pnav.stopService()
68         
69         def pause(self, p):
70                 return self.pnav.pause(p)
71         
72         def recordWithTimer(self, ref, begin, end, name, description, eit):
73                 if isinstance(ref, eServiceReference):
74                         ref = ServiceReference.ServiceReference(ref)
75                 entry = RecordTimer.RecordTimerEntry(ref, begin, end, name, description, eit)
76                 self.RecordTimer.record(entry)
77                 return entry
78         
79         def shutdown(self):
80                 self.RecordTimer.shutdown()
81                 del self.pnav
82
83         def stopUserServices(self):
84                 self.stopService()