2 from Components.ParentalControl import parentalControl
3 from Tools.BoundFunction import boundFunction
7 import NavigationInstance
8 import ServiceReference
12 # TODO: remove pNavgation, eNavigation and rewrite this stuff in python.
15 if NavigationInstance.instance is not None:
16 raise NavigationInstance.instance
18 NavigationInstance.instance = self
19 self.ServiceHandler = eServiceCenter.getInstance()
21 import Navigation as Nav
24 self.pnav = pNavigation()
25 self.pnav.m_event.get().append(self.dispatchEvent)
26 self.pnav.m_record_event.get().append(self.dispatchRecordEvent)
28 self.record_event = [ ]
29 self.currentlyPlayingServiceReference = None
30 self.currentlyPlayingService = None
32 self.RecordTimer = RecordTimer.RecordTimer()
33 self.SleepTimer = SleepTimer.SleepTimer()
35 def dispatchEvent(self, i):
40 def dispatchRecordEvent(self, rec_service, event):
41 # print "record_event", rec_service, event
42 for x in self.record_event:
45 def playService(self, ref, checkParentalControl = True):
46 print "playing", ref and ref.toString()
47 self.currentlyPlayingServiceReference = None
48 self.currentlyPlayingService = None
53 if not checkParentalControl or parentalControl.isServicePlayable(ref.toCompareString(), boundFunction(self.playService, checkParentalControl = False)):
54 if self.pnav and not self.pnav.playService(ref):
55 self.currentlyPlayingServiceReference = ref
61 def getCurrentlyPlayingServiceReference(self):
62 return self.currentlyPlayingServiceReference
64 def recordService(self, ref):
65 print "recording service: %s" % (str(ref))
66 if isinstance(ref, ServiceReference.ServiceReference):
68 service = self.pnav and self.pnav.recordService(ref)
71 print "record returned non-zero"
76 def stopRecordService(self, service):
77 ret = self.pnav and self.pnav.stopRecordService(service)
80 def getRecordings(self):
81 return self.pnav and self.pnav.getRecordings()
83 def getCurrentService(self):
85 if not self.currentlyPlayingService:
86 self.currentlyPlayingService = self.pnav and self.pnav.getCurrentService()
87 return self.currentlyPlayingService
90 def stopService(self):
93 self.pnav.stopService()
94 self.currentlyPlayingService = None
95 self.currentlyPlayingServiceReference = None
98 return self.pnav and self.pnav.pause(p)
100 def recordWithTimer(self, ref, begin, end, name, description, eit):
101 if isinstance(ref, eServiceReference):
102 ref = ServiceReference.ServiceReference(ref)
103 entry = RecordTimer.RecordTimerEntry(ref, begin, end, name, description, eit)
104 self.RecordTimer.record(entry)
108 self.RecordTimer.shutdown()
109 self.ServiceHandler = None
112 def stopUserServices(self):