finally fix priorities: ConfigListScreen's action must be -1 to override eListbox...
[enigma2.git] / Navigation.py
1 from enigma import *
2 import RecordTimer
3
4 import NavigationInstance
5 import ServiceReference
6
7 from time import time
8
9 # TODO: remove pNavgation, eNavigation and rewrite this stuff in python.
10 class Navigation:
11         def __init__(self):
12                 if NavigationInstance.instance is not None:
13                         raise NavigationInstance.instance
14                 
15                 NavigationInstance.instance = self
16                 self.ServiceHandler = eServiceCenter.getInstance()
17
18                 import Navigation as Nav
19                 Nav.navcore = self
20                 
21                 self.pnav = pNavigation()
22                 self.pnav.m_event.get().append(self.callEvent)
23                 self.event = [ ]
24                 self.currentlyPlayingServiceReference = None
25                 self.currentlyPlayingService = None
26                 self.state = 0
27                 self.RecordTimer = RecordTimer.RecordTimer()
28
29         def callEvent(self, i):
30                 self.state = i != 1
31                 for x in self.event:
32                         x(i)
33
34         def playService(self, ref):
35                 print "playing", ref and ref.toString()
36                 self.currentlyPlayingServiceReference = None
37                 self.currentlyPlayingService = None
38                 if ref is None:
39                         self.stopService()
40                         return 0
41                 
42                 if self.pnav and not self.pnav.playService(ref):
43                         self.currentlyPlayingServiceReference = ref
44                         return 0
45                 return 1
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 and 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                 if self.state:
64                         if not self.currentlyPlayingService:
65                                 self.currentlyPlayingService = self.pnav and self.pnav.getCurrentService()
66                         return self.currentlyPlayingService
67                 return None
68
69         def stopService(self):
70                 print "stopService"
71                 if self.pnav:
72                         self.pnav.stopService()
73                 self.currentlyPlayingService = None
74                 self.currentlyPlayingServiceReference = None
75
76         def pause(self, p):
77                 return self.pnav and self.pnav.pause(p)
78
79         def recordWithTimer(self, ref, begin, end, name, description, eit):
80                 if isinstance(ref, eServiceReference):
81                         ref = ServiceReference.ServiceReference(ref)
82                 entry = RecordTimer.RecordTimerEntry(ref, begin, end, name, description, eit)
83                 self.RecordTimer.record(entry)
84                 return entry
85         
86         def shutdown(self):
87                 self.RecordTimer.shutdown()
88                 self.ServiceHandler = None
89                 self.pnav = None
90
91         def stopUserServices(self):
92                 self.stopService()