remove never used playlist stuff
[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 = 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                 self.lastServiceRef = None
25                 
26                 self.RecordTimer = RecordTimer.RecordTimer()
27
28         def callEvent(self, i):
29                 for x in self.event:
30                         x(i)
31         
32         def playService(self, ref):
33                 self.lastServiceRef = self.currentlyPlayingServiceReference
34                 self.currentlyPlayingServiceReference = None
35                 if ref is None:
36                         self.stopService()
37                         return 0
38                 
39                 if not self.pnav.playService(ref):
40                         self.currentlyPlayingServiceReference = ref
41                         return 0
42                 return 1
43         
44         def zapLast(self):
45                 return self.playService(self.lastServiceRef)
46         
47         def getCurrentlyPlayingServiceReference(self):
48                 return self.currentlyPlayingServiceReference
49         
50         def recordService(self, ref):
51                 print "recording service: %s" % (str(ref))
52                 if isinstance(ref, ServiceReference.ServiceReference):
53                         ref = ref.ref
54                 service = self.pnav.recordService(ref)
55                 
56                 if service is None:
57                         print "record returned non-zero"
58                         return None
59                 else:
60                         return service
61         
62         def getCurrentService(self):
63                 service = self.pnav.getCurrentService()
64                 
65                 if service is None:
66                         return None
67                 
68                 return service
69         
70         def stopService(self):
71                 self.pnav.stopService()
72         
73         def pause(self, p):
74                 return self.pnav.pause(p)
75         
76         def recordWithTimer(self, ref, begin, end, name, description, eit):
77                 if isinstance(ref, eServiceReference):
78                         ref = ServiceReference.ServiceReference(ref)
79                 entry = RecordTimer.RecordTimerEntry(ref, begin, end, name, description, eit)
80                 self.RecordTimer.record(entry)
81                 return entry
82         
83         def shutdown(self):
84                 self.RecordTimer.shutdown()
85
86         def stopUserServices(self):
87                 self.stopService()