1 from enigma import eServiceCenter, eServiceReference, pNavigation, getBestPlayableServiceReference, iPlayableService
2 from Components.ParentalControl import parentalControl
3 from Tools.BoundFunction import boundFunction
4 from Tools.DreamboxHardware import setFPWakeuptime, getFPWakeuptime, getFPWasTimerWakeup, clearFPWasTimerWakeup
9 import NavigationInstance
10 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
31 self.RecordTimer = RecordTimer.RecordTimer()
32 if getFPWasTimerWakeup():
33 clearFPWasTimerWakeup()
34 if getFPWasTimerWakeup(): # sanity check to detect if the FP driver is working correct!
35 print "buggy fp driver detected!!! please update drivers.... ignore timer wakeup!"
37 elif len(self.getRecordings()) or abs(self.RecordTimer.getNextRecordingTime() - time()) <= 360:
38 setFPWakeuptime(0x89ABCDEF)
39 if getFPWakeuptime() != 0x89ABCDEF: # sanity check to detect if the FP Atmel Firmware is working correct!
40 print "buggy atmel firmware detected!! atmel update needed... ignore fp timer wakeup!"
42 elif not Screens.Standby.inTryQuitMainloop: # not a shutdown messagebox is open
43 RecordTimer.RecordTimerEntry.TryQuitMainloop(0) # start shutdown handling
45 self.SleepTimer = SleepTimer.SleepTimer()
47 def dispatchEvent(self, i):
50 if i == iPlayableService.evEnd:
51 self.currentlyPlayingServiceReference = None
52 self.currentlyPlayingService = None
54 def dispatchRecordEvent(self, rec_service, event):
55 # print "record_event", rec_service, event
56 for x in self.record_event:
59 def playService(self, ref, checkParentalControl = True):
60 oldref = self.currentlyPlayingServiceReference
61 if ref and oldref and ref == oldref:
62 print "ignore request to play already running service"
64 print "playing", ref and ref.toString()
68 if not checkParentalControl or parentalControl.isServicePlayable(ref, boundFunction(self.playService, checkParentalControl = False)):
69 if ref.flags & eServiceReference.isGroup:
71 oldref = eServiceReference()
72 playref = getBestPlayableServiceReference(ref, oldref)
73 if not playref or (checkParentalControl and not parentalControl.isServicePlayable(playref, boundFunction(self.playService, checkParentalControl = False))):
78 if self.pnav and not self.pnav.playService(playref):
79 self.currentlyPlayingServiceReference = playref
85 def getCurrentlyPlayingServiceReference(self):
86 return self.currentlyPlayingServiceReference
88 def recordService(self, ref):
90 print "recording service: %s" % (str(ref))
91 if isinstance(ref, ServiceReference.ServiceReference):
94 if ref.flags & eServiceReference.isGroup:
95 ref = getBestPlayableServiceReference(ref, eServiceReference())
96 service = ref and self.pnav and self.pnav.recordService(ref)
98 print "record returned non-zero"
101 def stopRecordService(self, service):
102 ret = self.pnav and self.pnav.stopRecordService(service)
105 def getRecordings(self):
106 return self.pnav and self.pnav.getRecordings()
108 def getCurrentService(self):
109 if not self.currentlyPlayingService:
110 self.currentlyPlayingService = self.pnav and self.pnav.getCurrentService()
111 return self.currentlyPlayingService
113 def stopService(self):
116 self.pnav.stopService()
119 return self.pnav and self.pnav.pause(p)
122 self.RecordTimer.shutdown()
123 self.ServiceHandler = None
126 def stopUserServices(self):