fix typo
[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                 self.currentlyPlayingServiceReference = None
33                 if ref is None:
34                         self.stopService()
35                         return 0
36                 
37                 if not self.pnav.playService(ref):
38                         self.currentlyPlayingServiceReference = ref
39                         return 0
40                 return 1
41         
42         def getCurrentlyPlayingServiceReference(self):
43                 return self.currentlyPlayingServiceReference
44         
45         def recordService(self, ref):
46                 print "recording service: %s" % (str(ref))
47                 if isinstance(ref, ServiceReference.ServiceReference):
48                         ref = ref.ref
49                 service = self.pnav.recordService(ref)
50                 
51                 if service is None:
52                         print "record returned non-zero"
53                         return None
54                 else:
55                         return service
56         
57         def getCurrentService(self):
58                 service = self.pnav.getCurrentService()
59                 
60                 if service is None:
61                         return None
62                 
63                 return service
64         
65         def stopService(self):
66                 self.pnav.stopService()
67         
68         def pause(self, p):
69                 return self.pnav.pause(p)
70         
71         def recordWithTimer(self, ref, begin, end, name, description, eit):
72                 if isinstance(ref, eServiceReference):
73                         ref = ServiceReference.ServiceReference(ref)
74                 entry = RecordTimer.RecordTimerEntry(ref, begin, end, name, description, eit)
75                 self.RecordTimer.record(entry)
76                 return entry
77         
78         def shutdown(self):
79                 self.RecordTimer.shutdown()
80                 del self.pnav
81
82         def stopUserServices(self):
83                 self.stopService()