timers can now have after events. currently only working events: "do nothing" and...
authorStefan Pluecken <stefan.pluecken@multimedia-labs.de>
Wed, 26 Apr 2006 16:09:30 +0000 (16:09 +0000)
committerStefan Pluecken <stefan.pluecken@multimedia-labs.de>
Wed, 26 Apr 2006 16:09:30 +0000 (16:09 +0000)
RecordTimer.py
lib/python/Screens/TimerEntry.py

index dfddb73..1198643 100644 (file)
@@ -7,6 +7,8 @@ from Components.config import config
 import timer
 import xml.dom.minidom
 
 import timer
 import xml.dom.minidom
 
+from enigma import quitMainloop
+
 from Screens.MessageBox import MessageBox
 from Screens.SubserviceSelection import SubserviceSelection
 import NavigationInstance
 from Screens.MessageBox import MessageBox
 from Screens.SubserviceSelection import SubserviceSelection
 import NavigationInstance
@@ -34,9 +36,14 @@ def parseEvent(ev):
        end += config.recording.margin_after.value[0] * 60
        return (begin, end, name, description, eit)
 
        end += config.recording.margin_after.value[0] * 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):
 # please do not translate log messages
 class RecordTimerEntry(timer.TimerEntry):
-       def __init__(self, serviceref, begin, end, name, description, eit, disabled = False, justplay = False):
+       def __init__(self, serviceref, begin, end, name, description, eit, disabled = False, justplay = False, afterEvent = AFTEREVENT.NONE):
                timer.TimerEntry.__init__(self, int(begin), int(end))
                
                assert isinstance(serviceref, ServiceReference)
                timer.TimerEntry.__init__(self, int(begin), int(end))
                
                assert isinstance(serviceref, ServiceReference)
@@ -51,6 +58,8 @@ class RecordTimerEntry(timer.TimerEntry):
                self.record_service = None
                self.start_prepare = 0
                self.justplay = justplay
                self.record_service = None
                self.start_prepare = 0
                self.justplay = justplay
+               self.afterEvent = afterEvent
+               self.session = None
                
                self.log_entries = []
                self.resetState()
                
                self.log_entries = []
                self.resetState()
@@ -174,6 +183,11 @@ class RecordTimerEntry(timer.TimerEntry):
                        if not self.justplay:
                                self.record_service.stop()
                                self.record_service = None
                        if not self.justplay:
                                self.record_service.stop()
                                self.record_service = None
+                       if self.afterEvent == AFTEREVENT.STANDBY:
+                               if self.session is not None:
+                                       self.session.open(Standby, self)
+                       elif self.afterEvent == AFTEREVENT.DEEPSTANDBY:
+                               quitMainloop(1)
                        return True
 
        def getNextActivation(self):
                        return True
 
        def getNextActivation(self):
@@ -210,6 +224,8 @@ def createTimer(xml):
        repeated = xml.getAttribute("repeated").encode("utf-8")
        disabled = long(xml.getAttribute("disabled") or "0")
        justplay = long(xml.getAttribute("justplay") or "0")
        repeated = xml.getAttribute("repeated").encode("utf-8")
        disabled = long(xml.getAttribute("disabled") or "0")
        justplay = long(xml.getAttribute("justplay") or "0")
+       afterevent = str(xml.getAttribute("afterevent") or "nothing")
+       afterevent = { "nothing": AFTEREVENT.NONE, "standby": AFTEREVENT.STANDBY, "deepstandby": AFTEREVENT.DEEPSTANDBY }[afterevent]
        if xml.hasAttribute("eit") and xml.getAttribute("eit") != "None":
                eit = long(xml.getAttribute("eit"))
        else:
        if xml.hasAttribute("eit") and xml.getAttribute("eit") != "None":
                eit = long(xml.getAttribute("eit"))
        else:
@@ -217,7 +233,7 @@ def createTimer(xml):
        
        name = xml.getAttribute("name").encode("utf-8")
        #filename = xml.getAttribute("filename").encode("utf-8")
        
        name = xml.getAttribute("name").encode("utf-8")
        #filename = xml.getAttribute("filename").encode("utf-8")
-       entry = RecordTimerEntry(serviceref, begin, end, name, description, eit, disabled, justplay)
+       entry = RecordTimerEntry(serviceref, begin, end, name, description, eit, disabled, justplay, afterevent)
        entry.repeated = int(repeated)
        
        for l in elementsWithTag(xml.childNodes, "log"):
        entry.repeated = int(repeated)
        
        for l in elementsWithTag(xml.childNodes, "log"):
@@ -311,6 +327,7 @@ class RecordTimer(timer.Timer):
                        list.append(' repeated="' + str(int(timer.repeated)) + '"')
                        list.append(' name="' + str(stringToXML(timer.name)) + '"')
                        list.append(' description="' + str(stringToXML(timer.description)) + '"')
                        list.append(' repeated="' + str(int(timer.repeated)) + '"')
                        list.append(' name="' + str(stringToXML(timer.name)) + '"')
                        list.append(' description="' + str(stringToXML(timer.description)) + '"')
+                       list.append(' afterevent="' + str(stringToXML({ AFTEREVENT.NONE: "nothing", AFTEREVENT.STANDBY: "standby", AFTEREVENT.DEEPSTANDBY: "deepstandby" }[timer.afterEvent])) + '"')
                        if timer.eit is not None:
                                list.append(' eit="' + str(timer.eit) + '"')
                        list.append(' disabled="' + str(int(timer.disabled)) + '"')
                        if timer.eit is not None:
                                list.append(' eit="' + str(timer.eit) + '"')
                        list.append(' disabled="' + str(int(timer.disabled)) + '"')
index 0e557a6..fb560a7 100644 (file)
@@ -11,6 +11,7 @@ from Components.Label import Label
 from Components.Pixmap import Pixmap
 from Screens.SubserviceSelection import SubserviceSelection
 from Screens.MessageBox import MessageBox
 from Components.Pixmap import Pixmap
 from Screens.SubserviceSelection import SubserviceSelection
 from Screens.MessageBox import MessageBox
+from RecordTimer import AFTEREVENT
 from enigma import eEPGCache
 import time
 import datetime
 from enigma import eEPGCache
 import time
 import datetime
@@ -59,6 +60,8 @@ class TimerEntry(Screen):
                        else:
                                justplay = 1
                                
                        else:
                                justplay = 1
                                
+                       afterevent = { AFTEREVENT.NONE: 0, AFTEREVENT.DEEPSTANDBY: 1, AFTEREVENT.STANDBY: 2}[self.timer.afterEvent]
+
                        # calculate default values
                        day = []
                        weekday = 0
                        # calculate default values
                        day = []
                        weekday = 0
@@ -93,6 +96,7 @@ class TimerEntry(Screen):
                                day[weekday] = 0
                        
                        config.timerentry.justplay = configElement_nonSave("config.timerentry.justplay", configSelection, justplay, (("zap", _("zap")), ("record", _("record"))))
                                day[weekday] = 0
                        
                        config.timerentry.justplay = configElement_nonSave("config.timerentry.justplay", configSelection, justplay, (("zap", _("zap")), ("record", _("record"))))
+                       config.timerentry.afterevent = configElement_nonSave("config.timerentry.afterevent", configSelection, afterevent, (("nothing", _("do nothing")), ("deepstandby", _("go to deep standby"))))
                        config.timerentry.type = configElement_nonSave("config.timerentry.type", configSelection, type, (_("once"), _("repeated")))
                        config.timerentry.name = configElement_nonSave("config.timerentry.name", configText, self.timer.name, (configText.extendableSize, self.keyRightCallback))
                        config.timerentry.description = configElement_nonSave("config.timerentry.description", configText, self.timer.description, (configText.extendableSize, self.keyRightCallback))
                        config.timerentry.type = configElement_nonSave("config.timerentry.type", configSelection, type, (_("once"), _("repeated")))
                        config.timerentry.name = configElement_nonSave("config.timerentry.name", configText, self.timer.name, (configText.extendableSize, self.keyRightCallback))
                        config.timerentry.description = configElement_nonSave("config.timerentry.description", configText, self.timer.description, (configText.extendableSize, self.keyRightCallback))
@@ -187,6 +191,9 @@ class TimerEntry(Screen):
                        if currentConfigSelectionElement(config.timerentry.justplay) != "zap":
                                self.list.append(getConfigListEntry(_("EndTime"), config.timerentry.endtime))
 
                        if currentConfigSelectionElement(config.timerentry.justplay) != "zap":
                                self.list.append(getConfigListEntry(_("EndTime"), config.timerentry.endtime))
 
+               if currentConfigSelectionElement(config.timerentry.justplay) != "zap":
+                       self.list.append(getConfigListEntry(_("After event"), config.timerentry.afterevent))
+
                self.channelEntry = getConfigListEntry(_("Channel"), config.timerentry.service)
                self.list.append(self.channelEntry)
 
                self.channelEntry = getConfigListEntry(_("Channel"), config.timerentry.service)
                self.list.append(self.channelEntry)
 
@@ -252,6 +259,7 @@ class TimerEntry(Screen):
                self.timer.description = config.timerentry.description.value
                self.timer.justplay = (currentConfigSelectionElement(config.timerentry.justplay) == "zap")
                self.timer.resetRepeated()
                self.timer.description = config.timerentry.description.value
                self.timer.justplay = (currentConfigSelectionElement(config.timerentry.justplay) == "zap")
                self.timer.resetRepeated()
+               self.timer.afterEvent = { 0: AFTEREVENT.NONE, 1: AFTEREVENT.DEEPSTANDBY, 2: AFTEREVENT.STANDBY}[config.timerentry.afterevent.value]
                
                if (config.timerentry.type.value == 0): # once
                        self.timer.begin = self.getTimestamp(config.timerentry.startdate.value, config.timerentry.starttime.value)
                
                if (config.timerentry.type.value == 0): # once
                        self.timer.begin = self.getTimestamp(config.timerentry.startdate.value, config.timerentry.starttime.value)