Streamline behavior for recordings coming from deep standby
authorLittlesat <littlesat99@yahoo.com>
Wed, 4 Sep 2013 09:01:52 +0000 (11:01 +0200)
committerLittlesat <littlesat99@yahoo.com>
Wed, 4 Sep 2013 09:01:52 +0000 (11:01 +0200)
Navigation.py
RecordTimer.py
lib/python/Screens/InfoBarGenerics.py
lib/python/Screens/Standby.py
mytest.py

index 558c759..75e7c91 100644 (file)
@@ -2,6 +2,7 @@ from enigma import eServiceCenter, eServiceReference, eTimer, pNavigation, getBe
 from Components.ParentalControl import parentalControl
 from Tools.BoundFunction import boundFunction
 from Tools.StbHardware import setFPWakeuptime, getFPWakeuptime, getFPWasTimerWakeup
 from Components.ParentalControl import parentalControl
 from Tools.BoundFunction import boundFunction
 from Tools.StbHardware import setFPWakeuptime, getFPWakeuptime, getFPWasTimerWakeup
+from Tools import Notifications
 from time import time
 import RecordTimer
 import Screens.Standby
 from time import time
 import RecordTimer
 import Screens.Standby
@@ -11,7 +12,7 @@ from Screens.InfoBar import InfoBar
 
 # TODO: remove pNavgation, eNavigation and rewrite this stuff in python.
 class Navigation:
 
 # TODO: remove pNavgation, eNavigation and rewrite this stuff in python.
 class Navigation:
-       def __init__(self, nextRecordTimerAfterEventActionAuto=False):
+       def __init__(self):
                if NavigationInstance.instance is not None:
                        raise NavigationInstance.instance
 
                if NavigationInstance.instance is not None:
                        raise NavigationInstance.instance
 
@@ -30,25 +31,13 @@ class Navigation:
                self.currentlyPlayingServiceOrGroup = None
                self.currentlyPlayingService = None
                self.RecordTimer = RecordTimer.RecordTimer()
                self.currentlyPlayingServiceOrGroup = None
                self.currentlyPlayingService = None
                self.RecordTimer = RecordTimer.RecordTimer()
-               self.__wasTimerWakeup = False
-               if getFPWasTimerWakeup():
-                       self.__wasTimerWakeup = True
-                       if nextRecordTimerAfterEventActionAuto:
-                               # We need to give the systemclock the chance to sync with the transponder time,
-                               # before we will make the decision about whether or not we need to shutdown
-                               # after the upcoming recording has completed
-                               self.recordshutdowntimer = eTimer()
-                               self.recordshutdowntimer.callback.append(self.checkShutdownAfterRecording)
-                               self.recordshutdowntimer.start(30000, True)
+               self.__wasTimerWakeup = getFPWasTimerWakeup()
+               if self.__wasTimerWakeup:
+                       Notifications.AddNotification(Screens.Standby.Standby)
 
        def wasTimerWakeup(self):
                return self.__wasTimerWakeup
 
 
        def wasTimerWakeup(self):
                return self.__wasTimerWakeup
 
-       def checkShutdownAfterRecording(self):
-               if len(self.getRecordings()) or abs(self.RecordTimer.getNextRecordingTime() - time()) <= 360:
-                       if not Screens.Standby.inTryQuitMainloop: # not a shutdown messagebox is open
-                               RecordTimer.RecordTimerEntry.TryQuitMainloop(False) # start shutdown handling
-
        def dispatchEvent(self, i):
                for x in self.event:
                        x(i)
        def dispatchEvent(self, i):
                for x in self.event:
                        x(i)
index 8d0690f..f951fc9 100644 (file)
@@ -99,16 +99,14 @@ class RecordTimerEntry(timer.TimerEntry, object):
                RecordTimerEntry.receiveRecordEvents = False
 
        @staticmethod
                RecordTimerEntry.receiveRecordEvents = False
 
        @staticmethod
-       def TryQuitMainloop(default_yes = True):
-               if not RecordTimerEntry.receiveRecordEvents:
+       def TryQuitMainloop():
+               if not RecordTimerEntry.receiveRecordEvents and Screens.Standby.inStandby:
                        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)
                        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.AddNotificationWithID("RecordTimerQuitMainloop", 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.AUTO, checkOldTimers = False, dirname = None, tags = None, descramble = True, record_ecm = False, always_zap = False):
 #################################################################
 
        def __init__(self, serviceref, begin, end, name, description, eit, disabled = False, justplay = False, afterEvent = AFTEREVENT.AUTO, checkOldTimers = False, dirname = None, tags = None, descramble = True, record_ecm = False, always_zap = False):
@@ -302,9 +300,11 @@ class RecordTimerEntry(timer.TimerEntry, object):
                                self.first_try_prepare = False
                                cur_ref = NavigationInstance.instance.getCurrentlyPlayingServiceReference()
                                if cur_ref and not cur_ref.getPath():
                                self.first_try_prepare = False
                                cur_ref = NavigationInstance.instance.getCurrentlyPlayingServiceReference()
                                if cur_ref and not cur_ref.getPath():
-                                       if not config.recording.asktozap.value:
+                                       if Screens.Standby.inStandby:
+                                               self.failureCB(True)
+                                       elif not config.recording.asktozap.value:
                                                self.log(8, "asking user to zap away")
                                                self.log(8, "asking user to zap away")
-                                               Notifications.AddNotificationWithCallback(self.failureCB, MessageBox, _("A timer failed to record!\nDisable TV and try again?\n"), timeout=20)
+                                               Notifications.AddNotificationWithCallback(self.failureCB, MessageBox, _("A timer failed to record!\nDisable TV and try again?\n"), timeout=20, default=True)
                                        else: # zap without asking
                                                self.log(9, "zap without asking")
                                                Notifications.AddNotification(MessageBox, _("In order to record a timer, the TV was switched to the recording service!\n"), type=MessageBox.TYPE_INFO, timeout=20)
                                        else: # zap without asking
                                                self.log(9, "zap without asking")
                                                Notifications.AddNotification(MessageBox, _("In order to record a timer, the TV was switched to the recording service!\n"), type=MessageBox.TYPE_INFO, timeout=20)
@@ -359,16 +359,16 @@ class RecordTimerEntry(timer.TimerEntry, object):
                        if not self.justplay:
                                NavigationInstance.instance.stopRecordService(self.record_service)
                                self.record_service = None
                        if not self.justplay:
                                NavigationInstance.instance.stopRecordService(self.record_service)
                                self.record_service = None
-                       if self.afterEvent == AFTEREVENT.STANDBY or self.wasInStandby:
-                               self.keypress() #this unbinds the keypress detection
-                               if not Screens.Standby.inStandby: # not already in standby
-                                       Notifications.AddNotificationWithCallback(self.sendStandbyNotification, MessageBox, _("A finished record timer wants to set your\nreceiver to standby. Do that now?"), timeout = 20)
-                       elif self.afterEvent == AFTEREVENT.DEEPSTANDBY:
+                       if self.afterEvent == AFTEREVENT.DEEPSTANDBY or (Screens.Standby.inStandby or self.wasInStandby) and NavigationInstance.instance.wasTimerWakeup() and config.misc.standbyCounter.value == 1:
                                if not Screens.Standby.inTryQuitMainloop: # not a shutdown messagebox is open
                                        if Screens.Standby.inStandby: # in standby
                                                RecordTimerEntry.TryQuitMainloop() # start shutdown handling without screen
                                        else:
                                if not Screens.Standby.inTryQuitMainloop: # not a shutdown messagebox is open
                                        if Screens.Standby.inStandby: # in standby
                                                RecordTimerEntry.TryQuitMainloop() # start shutdown handling without screen
                                        else:
-                                               Notifications.AddNotificationWithCallback(self.sendTryQuitMainloopNotification, MessageBox, _("A finished record timer wants to shut down\nyour receiver. Shutdown now?"), timeout = 20)
+                                               Notifications.AddNotificationWithCallback(self.sendTryQuitMainloopNotification, MessageBox, _("A finished record timer wants to shut down\nyour receiver. Shutdown now?"), timeout=20, default=True)
+                       elif self.afterEvent == AFTEREVENT.STANDBY or self.wasInStandby:
+                               if not Screens.Standby.inStandby: # not already in standby
+                                       Notifications.AddNotificationWithCallback(self.sendStandbyNotification, MessageBox, _("A finished record timer wants to set your\nreceiver to standby. Do that now?"), timeout=20, default=True)
+                       self.keypress() #this ensures to unbind the keypress detection
                        return True
 
        def keypress(self, key=None, flag=1):
                        return True
 
        def keypress(self, key=None, flag=1):
index 2db57c5..5ae340e 100644 (file)
@@ -2929,7 +2929,7 @@ class InfoBarPowersaver:
                if value < 0:
                        if Screens.Standby.inStandby:
                                print "[InfoBarPowersaver] already in standby now shut down"
                if value < 0:
                        if Screens.Standby.inStandby:
                                print "[InfoBarPowersaver] already in standby now shut down"
-                               RecordTimerEntry.TryQuitMainloop(True)
+                               RecordTimerEntry.TryQuitMainloop()
                        elif not Screens.Standby.inTryQuitMainloop:
                                print "[InfoBarPowersaver] goto shutdown"
                                self.session.open(Screens.Standby.TryQuitMainloop, 1)
                        elif not Screens.Standby.inTryQuitMainloop:
                                print "[InfoBarPowersaver] goto shutdown"
                                self.session.open(Screens.Standby.TryQuitMainloop, 1)
index b298c5d..db6d004 100644 (file)
@@ -87,7 +87,6 @@ class Standby(Screen):
                self.session.screen["Standby"].boolean = False
                globalActionMap.setEnabled(True)
                if RecordTimer.RecordTimerEntry.receiveRecordEvents:
                self.session.screen["Standby"].boolean = False
                globalActionMap.setEnabled(True)
                if RecordTimer.RecordTimerEntry.receiveRecordEvents:
-                       Notifications.RemovePopup(id = "RecordTimerQuitMainloop")
                        RecordTimer.RecordTimerEntry.stopTryQuitMainloop()
 
        def __onFirstExecBegin(self):
                        RecordTimer.RecordTimerEntry.stopTryQuitMainloop()
 
        def __onFirstExecBegin(self):
@@ -101,7 +100,7 @@ class Standby(Screen):
 
        def standbyTimeout(self):
                from RecordTimer import RecordTimerEntry
 
        def standbyTimeout(self):
                from RecordTimer import RecordTimerEntry
-               RecordTimerEntry.TryQuitMainloop(True)
+               RecordTimerEntry.TryQuitMainloop()
 
 class StandbySummary(Screen):
        skin = """
 
 class StandbySummary(Screen):
        skin = """
index d6af183..c31aa31 100644 (file)
--- a/mytest.py
+++ b/mytest.py
@@ -438,7 +438,7 @@ def runScreenTest():
        plugins.readPluginList(resolveFilename(SCOPE_PLUGINS))
 
        profile("Init:Session")
        plugins.readPluginList(resolveFilename(SCOPE_PLUGINS))
 
        profile("Init:Session")
-       nav = Navigation(config.misc.isNextRecordTimerAfterEventActionAuto.value)
+       nav = Navigation()
        session = Session(desktop = enigma.getDesktop(0), summary_desktop = enigma.getDesktop(1), navigation = nav)
 
        CiHandler.setSession(session)
        session = Session(desktop = enigma.getDesktop(0), summary_desktop = enigma.getDesktop(1), navigation = nav)
 
        CiHandler.setSession(session)