From 674719294af7449c52d93b1969aeebbaa9117cbe Mon Sep 17 00:00:00 2001 From: Andreas Monzner Date: Sun, 7 Jan 2007 01:00:31 +0000 Subject: take care of running recording before realy shutdown e2 --- .../Plugins/SystemPlugins/SkinSelector/plugin.py | 5 +- lib/python/Screens/Menu.py | 2 - lib/python/Screens/Standby.py | 79 +++++++++++++++++++++- lib/python/Screens/TimerEntry.py | 2 +- 4 files changed, 79 insertions(+), 9 deletions(-) (limited to 'lib/python') diff --git a/lib/python/Plugins/SystemPlugins/SkinSelector/plugin.py b/lib/python/Plugins/SystemPlugins/SkinSelector/plugin.py index b0418de0..adeff071 100755 --- a/lib/python/Plugins/SystemPlugins/SkinSelector/plugin.py +++ b/lib/python/Plugins/SystemPlugins/SkinSelector/plugin.py @@ -2,6 +2,7 @@ # (c) 2006 Stephan Reichholf # This Software is Free, use it where you want, when you want for whatever you want and modify it if you want but don't remove my copyright! from Screens.Screen import Screen +from Screens.Standby import TryQuitMainloop from Screens.MessageBox import MessageBox from Components.ActionMap import NumberActionMap from Components.Pixmap import Pixmap @@ -12,7 +13,6 @@ from Tools.Directories import SCOPE_SKIN from Components.config import config from os import path, walk -from enigma import quitMainloop class SkinSelector(Screen): # for i18n: @@ -33,7 +33,6 @@ class SkinSelector(Screen): Screen.__init__(self, session) self.skinlist = [] - self.session = session self.previewPath = "" path.walk(self.root, self.find, "") @@ -114,7 +113,7 @@ class SkinSelector(Screen): def restartGUI(self, answer): if answer is True: - quitMainloop(3) + self.session.open(TryQuitMainloop, 3) def SkinSelMain(session, **kwargs): session.open(SkinSelector) diff --git a/lib/python/Screens/Menu.py b/lib/python/Screens/Menu.py index a038cdf0..113eeb6d 100644 --- a/lib/python/Screens/Menu.py +++ b/lib/python/Screens/Menu.py @@ -11,8 +11,6 @@ from Components.PluginComponent import plugins from Tools.Directories import resolveFilename, SCOPE_SKIN -from enigma import quitMainloop - import xml.dom.minidom from xml.dom import EMPTY_NAMESPACE from skin import elementsWithTag diff --git a/lib/python/Screens/Standby.py b/lib/python/Screens/Standby.py index 06c44703..cb0a957e 100644 --- a/lib/python/Screens/Standby.py +++ b/lib/python/Screens/Standby.py @@ -5,6 +5,7 @@ from Components.AVSwitch import AVSwitch from enigma import eDVBVolumecontrol, eDBoxLCD, eServiceReference from Components.Sources.Clock import Clock +inStandby = False class Standby(Screen): def Power(self): @@ -19,7 +20,7 @@ class Standby(Screen): #set brightness of lcd eDBoxLCD.getInstance().setLCDBrightness(config.lcd.bright.value * 20) #kill me - self.close() + self.close(True) def setMute(self): if (eDVBVolumecontrol.getInstance().isMuted()): @@ -33,9 +34,8 @@ class Standby(Screen): if self.wasMuted == 0: eDVBVolumecontrol.getInstance().volumeToggleMute() - def __init__(self, session, infobar): + def __init__(self, session): Screen.__init__(self, session) - self.infobar = infobar self.avswitch = AVSwitch() print "enter standby" @@ -55,10 +55,21 @@ class Standby(Screen): self.avswitch.setInput("SCART") #set lcd brightness to standby value eDBoxLCD.getInstance().setLCDBrightness(config.lcd.standby.value * 20) + self.onShow.append(self.__onShow) + self.onHide.append(self.__onHide) def createSummary(self): return StandbySummary + def __onShow(self): + global inStandby + inStandby = True + + def __onHide(self): + global inStandby + inStandby = False + + class StandbySummary(Screen): skin = """ @@ -70,3 +81,65 @@ class StandbySummary(Screen): def __init__(self, session, parent): Screen.__init__(self, session) self["CurrentTime"] = Clock() + +from enigma import quitMainloop, iRecordableService +from Screens.MessageBox import MessageBox +from time import time + +inTryQuitMainloop = False + +class TryQuitMainloop(MessageBox): + def __init__(self, session, retvalue=1): + self.retval=retvalue + recordings = len(session.nav.getRecordings()) + self.connected = False + next_rec_time = -1 + if not recordings: + next_rec_time = session.nav.RecordTimer.getNextRecordingTime() + if recordings or (next_rec_time > 0 and (next_rec_time - time()) < 360): + if retvalue == 1: + MessageBox.__init__(self, session, _("Recording(s) are in progress or comming up in few seconds... really shutdown now?"), type = MessageBox.TYPE_YESNO, timeout = -1, close_on_any_key = False) + elif retvalue == 2: + MessageBox.__init__(self, session, _("Recording(s) are in progress or comming up in few seconds... really reboot now?"), type = MessageBox.TYPE_YESNO, timeout = -1, close_on_any_key = False) + elif retvalue == 4: + pass + else: + MessageBox.__init__(self, session, _("Recording(s) are in progress or comming up in few seconds... really restart now?"), type = MessageBox.TYPE_YESNO, timeout = -1, close_on_any_key = False) + self.skinName = "MessageBox" + session.nav.record_event.append(self.getRecordEvent) + self.connected = True + self.onShow.append(self.__onShow) + self.onHide.append(self.__onHide) + else: + self.skin = """""" + Screen.__init__(self, session) + self.close(True) + + def getRecordEvent(self, recservice, event): + if event == iRecordableService.evEnd: + recordings = self.session.nav.getRecordings() + if not len(recordings): # no more recordings exist + rec_time = self.session.nav.RecordTimer.getNextRecordingTime() + if rec_time > 0 and (rec_time - time()) < 360: + self.initTimeout(360) # wait for next starting timer + else: + self.close(True) # immediate shutdown + elif event == iRecordableService.evStart: + self.stopTimer() + + def close(self, value): + if self.connected: + self.conntected=False + self.session.nav.record_event.remove(self.getRecordEvent) + if value: + quitMainloop(self.retval) + else: + MessageBox.close(self, True) + + def __onShow(self): + global inTryQuitMainloop + inTryQuitMainloop = True + + def __onHide(self): + global inTryQuitMainloop + inTryQuitMainloop = False diff --git a/lib/python/Screens/TimerEntry.py b/lib/python/Screens/TimerEntry.py index 2a572714..fc4158da 100644 --- a/lib/python/Screens/TimerEntry.py +++ b/lib/python/Screens/TimerEntry.py @@ -84,7 +84,7 @@ class TimerEntry(Screen, ConfigListScreen): day[weekday] = 1 self.timerentry_justplay = ConfigSelection(choices = [("zap", _("zap")), ("record", _("record"))], default = {0: "record", 1: "zap"}[justplay]) - self.timerentry_afterevent = ConfigSelection(choices = [("nothing", _("do nothing")), ("deepstandby", _("go to deep standby"))], default = afterevent) + self.timerentry_afterevent = ConfigSelection(choices = [("nothing", _("do nothing")), ("standby", _("go to standby")), ("deepstandby", _("go to deep standby"))], default = afterevent) self.timerentry_type = ConfigSelection(choices = [("once",_("once")), ("repeated", _("repeated"))], default = type) self.timerentry_name = ConfigText(default = self.timer.name, fixed_size = False) self.timerentry_description = ConfigText(default = self.timer.description, fixed_size = False) -- cgit v1.2.3