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 if ref and oldref and ref == oldref:
46 print "ignore request to play already running service"
48 print "playing", ref and ref.toString()
49 self.currentlyPlayingServiceReference = None
50 self.currentlyPlayingService = None
54 if not checkParentalControl or parentalControl.isServicePlayable(ref, boundFunction(self.playService, checkParentalControl = False)):
55 if ref.flags & eServiceReference.isGroup:
57 oldref = eServiceReference()
58 playref = getBestPlayableServiceReference(ref, oldref)
59 if not playref or (checkParentalControl and not parentalControl.isServicePlayable(playref, boundFunction(self.playService, checkParentalControl = False))):
64 if self.pnav and not self.pnav.playService(playref):
65 self.currentlyPlayingServiceReference = playref
71 def getCurrentlyPlayingServiceReference(self):
72 return self.currentlyPlayingServiceReference
74 def recordService(self, ref):
76 print "recording service: %s" % (str(ref))
77 if isinstance(ref, ServiceReference.ServiceReference):
80 if ref.flags & eServiceReference.isGroup:
81 ref = getBestPlayableServiceReference(ref, eServiceReference())
82 service = ref and self.pnav and self.pnav.recordService(ref)
84 print "record returned non-zero"
87 def stopRecordService(self, service):
88 ret = self.pnav and self.pnav.stopRecordService(service)
91 def getRecordings(self):
92 return self.pnav and self.pnav.getRecordings()
94 def getCurrentService(self):
95 if not self.currentlyPlayingService:
96 self.currentlyPlayingService = self.pnav and self.pnav.getCurrentService()
97 return self.currentlyPlayingService
99 def stopService(self):
102 self.pnav.stopService()
103 self.currentlyPlayingService = None
104 self.currentlyPlayingServiceReference = None
107 return self.pnav and self.pnav.pause(p)
109 def recordWithTimer(self, ref, begin, end, name, description, eit):
110 if isinstance(ref, eServiceReference):
111 ref = ServiceReference.ServiceReference(ref)
112 entry = RecordTimer.RecordTimerEntry(ref, begin, end, name, description, eit)
113 self.RecordTimer.record(entry)
117 self.RecordTimer.shutdown()
118 self.ServiceHandler = None
121 def stopUserServices(self):