better fix for previous commit
[enigma2.git] / mytest.py
index 2169857f13ecbe273d967be2aa3ec14030fa3ff9..098675b60ea423334cb083faf5e999a0d0b29d2e 100644 (file)
--- a/mytest.py
+++ b/mytest.py
@@ -1,6 +1,6 @@
-from Tools import RedirectOutput
+from Tools import RedirectOutput, RedirectTime
 from enigma import runMainloop, eDVBDB, eTimer, quitMainloop, eDVBVolumecontrol, \
-       getDesktop, ePythonConfigQuery, eAVSwitch, eWindow
+       getDesktop, ePythonConfigQuery, eAVSwitch, eWindow, eServiceEvent
 from tools import *
 
 from Components.Language import language
@@ -155,11 +155,11 @@ class Session:
                if callback is not None:
                        callback(*retval)
 
-       def execBegin(self, first=True):
+       def execBegin(self, first=True, do_show = True):
                assert not self.in_exec 
                self.in_exec = True
                c = self.current_dialog
-               
+
                # when this is an execbegin after a execend of a "higher" dialog,
                # popSummary already did the right thing.
                if first:
@@ -172,7 +172,7 @@ class Session:
                c.execBegin()
 
                # when execBegin opened a new dialog, don't bother showing the old one.
-               if c == self.current_dialog:
+               if c == self.current_dialog and do_show:
                        c.show()
                
        def execEnd(self, last=True):
@@ -246,13 +246,13 @@ class Session:
         
        def pushCurrent(self):
                if self.current_dialog is not None:
-                       self.dialog_stack.append(self.current_dialog)
+                       self.dialog_stack.append((self.current_dialog, self.current_dialog.shown))
                        self.execEnd(last=False)
-       
+
        def popCurrent(self):
                if len(self.dialog_stack):
-                       self.current_dialog = self.dialog_stack.pop()
-                       self.execBegin(first=False)
+                       (self.current_dialog, do_show) = self.dialog_stack.pop()
+                       self.execBegin(first=False, do_show=do_show)
                else:
                        self.current_dialog = None
 
@@ -387,7 +387,7 @@ class VolumeControl:
                                self.muteDialog.hide()
                                self.volumeDialog.setValue(vol)
 
-from Screens.Standby import Standby, inStandby, TryQuitMainloop, inTryQuitMainloop
+import Screens.Standby
 
 class PowerKey:
        """ PowerKey stuff - handles the powerkey press and powerkey release actions"""
@@ -409,9 +409,8 @@ class PowerKey:
 
        def powertimer(self):   
                print "PowerOff - Now!"
-               global inTryQuitMainloop
-               if not inTryQuitMainloop:
-                       self.session.open(TryQuitMainloop, 1)
+               if not Screens.Standby.inTryQuitMainloop:
+                       self.session.open(Screens.Standby.TryQuitMainloop, 1)
        
        def powerdown(self):
                self.standbyblocked = 0
@@ -424,9 +423,8 @@ class PowerKey:
                        self.standby()
 
        def standby(self):
-               global inStandby
-               if not inStandby and self.session.current_dialog and self.session.current_dialog.ALLOW_SUSPEND:
-                       self.session.open(Standby)
+               if not Screens.Standby.inStandby and self.session.current_dialog and self.session.current_dialog.ALLOW_SUSPEND:
+                       self.session.open(Screens.Standby.Standby)
 
 from Screens.Scart import Scart
 
@@ -495,13 +493,21 @@ def runScreenTest():
 
        from time import time
        from Tools.DreamboxHardware import setFPWakeuptime
+       #get next record timer start time
        nextRecordingTime = session.nav.RecordTimer.getNextRecordingTime()
-       if nextRecordingTime != -1:
-               if (nextRecordingTime - time() < 330): # no time to switch box back on
-                       setFPWakeuptime(time() + 30) # so switch back on in 30 seconds
+       #get next zap timer start time
+       nextZapTime = session.nav.RecordTimer.getNextZapTime()
+       #get currentTime
+       nowTime = time()
+       if nextZapTime != -1 and nextRecordingTime != -1:
+               startTime = nextZapTime < nextRecordingTime and nextZapTime or nextRecordingTime
+       else:
+               startTime = nextZapTime != -1 and nextZapTime or nextRecordingTime
+       if startTime != -1:
+               if (startTime - nowTime < 330): # no time to switch box back on
+                       setFPWakeuptime(nowTime + 30) # so switch back on in 30 seconds
                else:
-                       setFPWakeuptime(nextRecordingTime - (300))
-       
+                       setFPWakeuptime(startTime - 300)
        session.nav.stopService()
        session.nav.shutdown()