+# ok, for descriptions etc we have:
+# service reference (to get the service name)
+# name (title)
+# description (description)
+# event data (ONLY for time adjustments etc.)
+
+
+# parses an event, and gives out a (begin, end, name, duration, eit)-tuple.
+# begin and end will be corrected
+def parseEvent(ev, description = True):
+ if description:
+ name = ev.getEventName()
+ description = ev.getShortDescription()
+ else:
+ name = ""
+ description = ""
+ begin = ev.getBeginTime()
+ end = begin + ev.getDuration()
+ eit = ev.getEventId()
+ begin -= config.recording.margin_before.value * 60
+ end += config.recording.margin_after.value * 60
+ return (begin, end, name, description, eit)
+
+class AFTEREVENT:
+ NONE = 0
+ STANDBY = 1
+ DEEPSTANDBY = 2
+
+# please do not translate log messages
+class RecordTimerEntry(timer.TimerEntry, object):
+######### the following static methods and members are only in use when the box is in (soft) standby
+ receiveRecordEvents = False
+
+ @staticmethod
+ def shutdown():
+ quitMainloop(1)
+
+ @staticmethod
+ def staticGotRecordEvent(recservice, event):
+ if event == iRecordableService.evEnd:
+ print "RecordTimer.staticGotRecordEvent(iRecordableService.evEnd)"
+ recordings = NavigationInstance.instance.getRecordings()
+ if not len(recordings): # no more recordings exist
+ rec_time = NavigationInstance.instance.RecordTimer.getNextRecordingTime()
+ if rec_time > 0 and (rec_time - time.time()) < 360:
+ print "another recording starts in", rec_time - time.time(), "seconds... do not shutdown yet"
+ else:
+ print "no starting records in the next 360 seconds... immediate shutdown"
+ RecordTimerEntry.shutdown() # immediate shutdown
+ elif event == iRecordableService.evStart:
+ print "RecordTimer.staticGotRecordEvent(iRecordableService.evStart)"
+
+ @staticmethod
+ def stopTryQuitMainloop():
+ print "RecordTimer.stopTryQuitMainloop"
+ NavigationInstance.instance.record_event.remove(RecordTimerEntry.staticGotRecordEvent)
+ RecordTimerEntry.receiveRecordEvents = False
+
+ @staticmethod
+ def TryQuitMainloop(default_yes = True):
+ if not RecordTimerEntry.receiveRecordEvents:
+ print "RecordTimer.TryQuitMainloop"
+ NavigationInstance.instance.record_event.append(RecordTimerEntry.staticGotRecordEvent)
+ RecordTimerEntry.receiveRecordEvents = True
+ # send fake event.. to check if another recordings are running or
+ # other timers start in a few seconds
+ RecordTimerEntry.staticGotRecordEvent(None, iRecordableService.evEnd)
+ # send normal notification for the case the user leave the standby now..
+ Notifications.AddNotification(Screens.Standby.TryQuitMainloop, 1, onSessionOpenCallback=RecordTimerEntry.stopTryQuitMainloop, default_yes = default_yes)
+#################################################################
+
+ def __init__(self, serviceref, begin, end, name, description, eit, disabled = False, justplay = False, afterEvent = AFTEREVENT.NONE, checkOldTimers = False, dirname = None, tags = None):