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 oldref = self.currentlyPlayingServiceReference
47 print "playing", ref and ref.toString()
48 self.currentlyPlayingServiceReference = None
49 self.currentlyPlayingService = None
53 if not checkParentalControl or parentalControl.isServicePlayable(ref.toCompareString(), boundFunction(self.playService, checkParentalControl = False)):
54 if ref.flags & eServiceReference.isGroup:
56 oldref = eServiceReference()
57 playref = getBestPlayableServiceReference(ref, oldref)
58 if not playref or (checkParentalControl and not parentalControl.isServicePlayable(playref.toCompareString(), boundFunction(self.playService, checkParentalControl = False))):
63 if self.pnav and not self.pnav.playService(playref):
64 self.currentlyPlayingServiceReference = ref
70 def getCurrentlyPlayingServiceReference(self):
71 return self.currentlyPlayingServiceReference
73 def recordService(self, ref):
75 print "recording service: %s" % (str(ref))
76 if isinstance(ref, ServiceReference.ServiceReference):
79 if ref.flags & eServiceReference.isGroup:
80 ref = getBestPlayableServiceReference(ref, eServiceReference())
81 service = ref and self.pnav and self.pnav.recordService(ref)
83 print "record returned non-zero"
86 def stopRecordService(self, service):
87 ret = self.pnav and self.pnav.stopRecordService(service)
90 def getRecordings(self):
91 return self.pnav and self.pnav.getRecordings()
93 def getCurrentService(self):
95 if not self.currentlyPlayingService:
96 self.currentlyPlayingService = self.pnav and self.pnav.getCurrentService()
97 return self.currentlyPlayingService
100 def stopService(self):
103 self.pnav.stopService()
104 self.currentlyPlayingService = None
105 self.currentlyPlayingServiceReference = None
108 return self.pnav and self.pnav.pause(p)
110 def recordWithTimer(self, ref, begin, end, name, description, eit):
111 if isinstance(ref, eServiceReference):
112 ref = ServiceReference.ServiceReference(ref)
113 entry = RecordTimer.RecordTimerEntry(ref, begin, end, name, description, eit)
114 self.RecordTimer.record(entry)
118 self.RecordTimer.shutdown()
119 self.ServiceHandler = None
122 def stopUserServices(self):