1 from enigma import eServiceCenter, eServiceReference, pNavigation, getBestPlayableServiceReference
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
31 self.RecordTimer = RecordTimer.RecordTimer()
32 self.SleepTimer = SleepTimer.SleepTimer()
34 def dispatchEvent(self, i):
38 def dispatchRecordEvent(self, rec_service, event):
39 # print "record_event", rec_service, event
40 for x in self.record_event:
43 def playService(self, ref, checkParentalControl = True):
44 oldref = self.currentlyPlayingServiceReference
45 print "playing", ref and ref.toString()
46 self.currentlyPlayingServiceReference = None
47 self.currentlyPlayingService = None
51 if not checkParentalControl or parentalControl.isServicePlayable(ref.toCompareString(), boundFunction(self.playService, checkParentalControl = False)):
52 if ref.flags & eServiceReference.isGroup:
54 oldref = eServiceReference()
55 playref = getBestPlayableServiceReference(ref, oldref)
56 if not playref or (checkParentalControl and not parentalControl.isServicePlayable(playref.toCompareString(), boundFunction(self.playService, checkParentalControl = False))):
61 if self.pnav and not self.pnav.playService(playref):
62 self.currentlyPlayingServiceReference = ref
68 def getCurrentlyPlayingServiceReference(self):
69 return self.currentlyPlayingServiceReference
71 def recordService(self, ref):
73 print "recording service: %s" % (str(ref))
74 if isinstance(ref, ServiceReference.ServiceReference):
77 if ref.flags & eServiceReference.isGroup:
78 ref = getBestPlayableServiceReference(ref, eServiceReference())
79 service = ref and self.pnav and self.pnav.recordService(ref)
81 print "record returned non-zero"
84 def stopRecordService(self, service):
85 ret = self.pnav and self.pnav.stopRecordService(service)
88 def getRecordings(self):
89 return self.pnav and self.pnav.getRecordings()
91 def getCurrentService(self):
92 if not self.currentlyPlayingService:
93 self.currentlyPlayingService = self.pnav and self.pnav.getCurrentService()
94 return self.currentlyPlayingService
96 def stopService(self):
99 self.pnav.stopService()
100 self.currentlyPlayingService = None
101 self.currentlyPlayingServiceReference = None
104 return self.pnav and self.pnav.pause(p)
106 def recordWithTimer(self, ref, begin, end, name, description, eit):
107 if isinstance(ref, eServiceReference):
108 ref = ServiceReference.ServiceReference(ref)
109 entry = RecordTimer.RecordTimerEntry(ref, begin, end, name, description, eit)
110 self.RecordTimer.record(entry)
114 self.RecordTimer.shutdown()
115 self.ServiceHandler = None
118 def stopUserServices(self):