use capital letters in translation of instant record choice box
[enigma2.git] / RecordTimer.py
index 08ea85900c90e052502eed5418256694922ebf33..f41a485737b0bb45bde349ad55e6862ccda1c0ea 100644 (file)
@@ -10,8 +10,9 @@ import xml.dom.minidom
 from Screens.MessageBox import MessageBox
 from Screens.SubserviceSelection import SubserviceSelection
 import NavigationInstance
+from time import localtime
 
-from Tools.XMLTools import elementsWithTag, mergeText
+from Tools.XMLTools import elementsWithTag, mergeText, stringToXML
 from ServiceReference import ServiceReference
 
 # ok, for descriptions etc we have:
@@ -237,9 +238,6 @@ class RecordTimer(timer.Timer):
                for timer in elementsWithTag(root.childNodes, "timer"):
                        self.record(createTimer(timer))
 
-       def strToXML(self, str):
-               return str.replace('&', '&amp;').replace('<', '&lt;').replace('>', '&gt;').replace("'", '&apos;'). replace('"', '&qout;')
-
        def saveTimer(self):
                #doc = xml.dom.minidom.Document()
                #root_element = doc.createElement('timers')
@@ -295,20 +293,20 @@ class RecordTimer(timer.Timer):
                        list.append(' end="' + str(int(timer.end)) + '"')
                        list.append(' serviceref="' + str(timer.service_ref) + '"')
                        list.append(' repeated="' + str(int(timer.repeated)) + '"')
-                       list.append(' name="' + str(self.strToXML(timer.name)) + '"')
-                       list.append(' description="' + str(self.strToXML(timer.description)) + '"')
+                       list.append(' name="' + str(stringToXML(timer.name)) + '"')
+                       list.append(' description="' + str(stringToXML(timer.description)) + '"')
                        if timer.eit is not None:
                                list.append(' eit="' + str(timer.eit) + '"')
                        list.append(' disabled="' + str(int(timer.disabled)) + '"')
                        list.append('>\n')
                        
-                       for time, code, msg in timer.log_entries:
-                               list.append('<log')
-                               list.append(' code="' + str(code) + '"')
-                               list.append(' time="' + str(time) + '"')
-                               list.append('>')
-                               list.append(str(msg))
-                               list.append('</log>\n')
+                       #for time, code, msg in timer.log_entries:
+                               #list.append('<log')
+                               #list.append(' code="' + str(code) + '"')
+                               #list.append(' time="' + str(time) + '"')
+                               #list.append('>')
+                               #list.append(str(msg))
+                               #list.append('</log>\n')
 
                        
                        list.append('</timer>\n')
@@ -325,6 +323,40 @@ class RecordTimer(timer.Timer):
                print "[Timer] Record " + str(entry)
                entry.Timer = self
                self.addTimerEntry(entry)
+               
+       def isInTimer(self, eventid, begin, duration, service):
+               time_match = 0
+               for x in self.timer_list:
+                       if str(x.service_ref) == str(service):
+                               #if x.eit is not None and x.repeated == 0:
+                               #       if x.eit == eventid:
+                               #               return duration
+                               if x.repeated != 0:
+                                       chktime = localtime(begin)
+                                       time = localtime(x.begin)
+                                       chktimecmp = chktime.tm_wday * 1440 + chktime.tm_hour * 60 + chktime.tm_min
+                                       for y in range(7):
+                                               if x.repeated & (2 ** y):
+                                                       timecmp = y * 1440 + time.tm_hour * 60 + time.tm_min
+                                                       if timecmp <= chktimecmp < (timecmp + ((x.end - x.begin) / 60)):
+                                                               time_match = ((timecmp + ((x.end - x.begin) / 60)) - chktimecmp) * 60
+                                                       elif chktimecmp <= timecmp < (chktimecmp + (duration / 60)):
+                                                               time_match = ((chktimecmp + (duration / 60)) - timecmp) * 60
+                               else: #if x.eit is None:
+                                       end = begin + duration
+                                       if begin <= x.begin <= end:
+                                               diff = end - x.begin
+                                               if time_match < diff:
+                                                       time_match = diff
+                                       elif x.begin <= begin <= x.end:
+                                               diff = x.end - begin
+                                               if time_match < diff:
+                                                       time_match = diff
+               return time_match
+                                                       
+                                               
+                                               
+                       
 
        def removeEntry(self, entry):
                print "[Timer] Remove " + str(entry)