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.
14 def __init__(self, nextRecordTimerAfterEventActionAuto=False):
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!"
36 elif nextRecordTimerAfterEventActionAuto and (len(self.getRecordings()) or abs(self.RecordTimer.getNextRecordingTime() - time()) <= 360):
37 if not Screens.Standby.inTryQuitMainloop: # not a shutdown messagebox is open
38 RecordTimer.RecordTimerEntry.TryQuitMainloop(False) # start shutdown handling
39 self.SleepTimer = SleepTimer.SleepTimer()
41 def dispatchEvent(self, i):
44 if i == iPlayableService.evEnd:
45 self.currentlyPlayingServiceReference = None
46 self.currentlyPlayingService = None
48 def dispatchRecordEvent(self, rec_service, event):
49 # print "record_event", rec_service, event
50 for x in self.record_event:
53 def playService(self, ref, checkParentalControl = True, forceRestart = False):
54 oldref = self.currentlyPlayingServiceReference
55 if ref and oldref and ref == oldref and not forceRestart:
56 print "ignore request to play already running service(1)"
58 #print "playing", ref and ref.toString()
59 print "playing service.."
63 if not checkParentalControl or parentalControl.isServicePlayable(ref, boundFunction(self.playService, checkParentalControl = False)):
64 if ref.flags & eServiceReference.isGroup:
66 oldref = eServiceReference()
67 playref = getBestPlayableServiceReference(ref, oldref)
68 print "playref", playref
69 if playref and oldref and playref == oldref and not forceRestart:
70 print "ignore request to play already running service(2)"
72 if not playref or (checkParentalControl and not parentalControl.isServicePlayable(playref, boundFunction(self.playService, checkParentalControl = False))):
77 if self.pnav and not self.pnav.playService(playref):
78 self.currentlyPlayingServiceReference = playref
84 def getCurrentlyPlayingServiceReference(self):
85 return self.currentlyPlayingServiceReference
87 def recordService(self, ref, simulate=False):
89 print "recording service: %s" % (str(ref))
90 if isinstance(ref, ServiceReference.ServiceReference):
93 if ref.flags & eServiceReference.isGroup:
94 ref = getBestPlayableServiceReference(ref, eServiceReference(), simulate)
95 service = ref and self.pnav and self.pnav.recordService(ref, simulate)
97 print "record returned non-zero"
100 def stopRecordService(self, service):
101 ret = self.pnav and self.pnav.stopRecordService(service)
104 def getRecordings(self, simulate=False):
105 return self.pnav and self.pnav.getRecordings(simulate)
107 def getCurrentService(self):
108 if not self.currentlyPlayingService:
109 self.currentlyPlayingService = self.pnav and self.pnav.getCurrentService()
110 return self.currentlyPlayingService
112 def stopService(self):
115 self.pnav.stopService()
118 return self.pnav and self.pnav.pause(p)
121 self.RecordTimer.shutdown()
122 self.ServiceHandler = None
125 def stopUserServices(self):