better tabs?
[enigma2.git] / RecordTimer.py
index aa48415a7babcb1c45467f64f884d922c3ecbc0b..d893382a228b8b132e8d8d03ea12143db9bd68dd 100644 (file)
@@ -86,9 +86,12 @@ def createTimer(xml):
        end = int(xml.getAttribute("end"))
        serviceref = ServiceReference(str(xml.getAttribute("serviceref")))
        description = xml.getAttribute("description")
+       repeated = xml.getAttribute("repeated")
        epgdata = xml.getAttribute("epgdata")
        #filename = xml.getAttribute("filename")
-       return RecordTimerEntry(begin, end, serviceref, epgdata, description)
+       entry = RecordTimerEntry(begin, end, serviceref, epgdata, description)
+       entry.repeated = int(repeated)
+       return entry
 
 class RecordTimer(timer.Timer):
        def __init__(self):
@@ -100,6 +103,13 @@ class RecordTimer(timer.Timer):
                        self.loadTimer()
                except:
                        print "unable to load timers from file!"
+                       
+       def isRecording(self):
+               isRunning = False
+               for timer in self.timer_list:
+                       if timer.isRunning():
+                               isRunning = True
+               return isRunning
        
        def loadTimer(self):
                # TODO: PATH!
@@ -126,6 +136,7 @@ class RecordTimer(timer.Timer):
                        t.setAttribute("begin", str(timer.begin))
                        t.setAttribute("end", str(timer.end))
                        t.setAttribute("serviceref", str(timer.service_ref))
+                       t.setAttribute("repeated", str(timer.repeated))                 
                        #t.setAttribute("epgdata", timer.)
                        t.setAttribute("description", timer.description)
                        root_element.appendChild(t)
@@ -138,21 +149,34 @@ class RecordTimer(timer.Timer):
                file.close()
        
        def record(self, entry):
+               print "[Timer] Record " + str(entry)
                entry.Timer = self
                self.addTimerEntry(entry)
 
        def removeEntry(self, entry):
+               print "[Timer] Remove " + str(entry)
+               
+               entry.repeated = False
+
                if entry.state == timer.TimerEntry.StateRunning:
+                       print "remove running timer."
                        entry.end = time.time()
                        self.timeChanged(entry)
                elif entry.state != timer.TimerEntry.StateEnded:
                        entry.activate(timer.TimerEntry.EventAbort)
                        self.timer_list.remove(entry)
+
                        self.calcNextActivation()
                        print "timer did not yet start - removing"
+
+                       # the timer was aborted, and removed.
+                       return
                else:
                        print "timer did already end - doing nothing."
                
+               print "state: ", entry.state
+               print "in processed: ", entry in self.processed_timers
+               print "in running: ", entry in self.timer_list
                # now the timer should be in the processed_timers list. remove it from there.
                self.processed_timers.remove(entry)