support for arbitrary number of skinfiles
[enigma2.git] / timer.py
index 5500c34..a98481c 100644 (file)
--- a/timer.py
+++ b/timer.py
@@ -16,6 +16,8 @@ class TimerEntry:
                self.resetRepeated()
                self.backoff = 0
                
+               self.disabled = False
+               
        def resetRepeated(self):
                self.repeated = int(0)
 
@@ -111,8 +113,13 @@ class Timer:
                for f in self.on_state_change:
                        f(entry)
                        
+       def getNextRecordingTime(self):
+               if len(self.timer_list) > 0:
+                       return self.timer_list[0].begin
+               return -1
+                       
        def cleanup(self):
-               self.processed_timers = []
+               self.processed_timers = [entry for entry in self.processed_timers if entry.disabled]
        
        def addTimerEntry(self, entry, noRecalc=0):
                entry.processRepeated()
@@ -120,7 +127,7 @@ class Timer:
                # when the timer has not yet started, and is already passed,
                # don't go trough waiting/running/end-states, but sort it
                # right into the processedTimers.
-               if entry.shouldSkip() or entry.state == TimerEntry.StateEnded:
+               if entry.shouldSkip() or entry.state == TimerEntry.StateEnded or (entry.state == TimerEntry.StateWaiting and entry.disabled):
                        print "already passed, skipping"
                        bisect.insort(self.processed_timers, entry)
                        entry.state = TimerEntry.StateEnded
@@ -161,7 +168,10 @@ class Timer:
        
        def timeChanged(self, timer):
                timer.timeChanged()
-               self.timer_list.remove(timer)
+               if timer.state == TimerEntry.StateEnded:
+                       self.processed_timers.remove(timer)
+               else:
+                       self.timer_list.remove(timer)
 
                self.addTimerEntry(timer)
        
@@ -171,8 +181,7 @@ class Timer:
                # when activating a timer which has already passed,
                # simply abort the timer. don't run trough all the stages.
                if w.shouldSkip():
-                       w.abort()
-                       bisect.insort(self.processed_timers, w)
+                       w.state = TimerEntry.StateEnded
                else:
                        # when active returns true, this means "accepted".
                        # otherwise, the current state is kept.