vdr
1.7.27
|
00001 /* 00002 * timers.h: Timer handling 00003 * 00004 * See the main source file 'vdr.c' for copyright information and 00005 * how to reach the author. 00006 * 00007 * $Id: timers.h 2.3 2012/02/20 15:52:57 kls Exp $ 00008 */ 00009 00010 #ifndef __TIMERS_H 00011 #define __TIMERS_H 00012 00013 #include "channels.h" 00014 #include "config.h" 00015 #include "epg.h" 00016 #include "tools.h" 00017 00018 enum eTimerFlags { tfNone = 0x0000, 00019 tfActive = 0x0001, 00020 tfInstant = 0x0002, 00021 tfVps = 0x0004, 00022 tfRecording = 0x0008, 00023 tfAll = 0xFFFF, 00024 }; 00025 enum eTimerMatch { tmNone, tmPartial, tmFull }; 00026 00027 class cTimer : public cListObject { 00028 friend class cMenuEditTimer; 00029 private: 00030 mutable time_t startTime, stopTime; 00031 time_t lastSetEvent; 00032 mutable time_t deferred; 00033 bool recording, pending, inVpsMargin; 00034 uint flags; 00035 cChannel *channel; 00036 mutable time_t day; 00037 int weekdays; 00038 int start; 00039 int stop; 00040 int priority; 00041 int lifetime; 00042 mutable char file[MaxFileName]; 00043 char *aux; 00044 const cEvent *event; 00045 public: 00046 cTimer(bool Instant = false, bool Pause = false, cChannel *Channel = NULL); 00047 cTimer(const cEvent *Event); 00048 cTimer(const cTimer &Timer); 00049 virtual ~cTimer(); 00050 cTimer& operator= (const cTimer &Timer); 00051 virtual int Compare(const cListObject &ListObject) const; 00052 bool Recording(void) const { return recording; } 00053 bool Pending(void) const { return pending; } 00054 bool InVpsMargin(void) const { return inVpsMargin; } 00055 uint Flags(void) const { return flags; } 00056 const cChannel *Channel(void) const { return channel; } 00057 time_t Day(void) const { return day; } 00058 int WeekDays(void) const { return weekdays; } 00059 int Start(void) const { return start; } 00060 int Stop(void) const { return stop; } 00061 int Priority(void) const { return priority; } 00062 int Lifetime(void) const { return lifetime; } 00063 const char *File(void) const { return file; } 00064 time_t FirstDay(void) const { return weekdays ? day : 0; } 00065 const char *Aux(void) const { return aux; } 00066 time_t Deferred(void) const { return deferred; } 00067 cString ToText(bool UseChannelID = false) const; 00068 cString ToDescr(void) const; 00069 const cEvent *Event(void) const { return event; } 00070 bool Parse(const char *s); 00071 bool Save(FILE *f); 00072 bool IsSingleEvent(void) const; 00073 static int GetMDay(time_t t); 00074 static int GetWDay(time_t t); 00075 bool DayMatches(time_t t) const; 00076 static time_t IncDay(time_t t, int Days); 00077 static time_t SetTime(time_t t, int SecondsFromMidnight); 00078 void SetFile(const char *File); 00079 bool Matches(time_t t = 0, bool Directly = false, int Margin = 0) const; 00080 int Matches(const cEvent *Event, int *Overlap = NULL) const; 00081 bool Expired(void) const; 00082 time_t StartTime(void) const; 00083 time_t StopTime(void) const; 00084 void SetEventFromSchedule(const cSchedules *Schedules = NULL); 00085 void SetEvent(const cEvent *Event); 00086 void SetRecording(bool Recording); 00087 void SetPending(bool Pending); 00088 void SetInVpsMargin(bool InVpsMargin); 00089 void SetDay(time_t Day); 00090 void SetWeekDays(int WeekDays); 00091 void SetStart(int Start); 00092 void SetStop(int Stop); 00093 void SetPriority(int Priority); 00094 void SetLifetime(int Lifetime); 00095 void SetAux(const char *Aux); 00096 void SetDeferred(int Seconds); 00097 void SetFlags(uint Flags); 00098 void ClrFlags(uint Flags); 00099 void InvFlags(uint Flags); 00100 bool HasFlags(uint Flags) const; 00101 void Skip(void); 00102 void OnOff(void); 00103 cString PrintFirstDay(void) const; 00104 static int TimeToInt(int t); 00105 static bool ParseDay(const char *s, time_t &Day, int &WeekDays); 00106 static cString PrintDay(time_t Day, int WeekDays, bool SingleByteChars); 00107 }; 00108 00109 class cTimers : public cConfig<cTimer> { 00110 private: 00111 int state; 00112 int beingEdited; 00113 time_t lastSetEvents; 00114 time_t lastDeleteExpired; 00115 public: 00116 cTimers(void); 00117 cTimer *GetTimer(cTimer *Timer); 00118 cTimer *GetMatch(time_t t); 00119 cTimer *GetMatch(const cEvent *Event, int *Match = NULL); 00120 cTimer *GetNextActiveTimer(void); 00121 int BeingEdited(void) { return beingEdited; } 00122 void IncBeingEdited(void) { beingEdited++; } 00123 void DecBeingEdited(void) { if (!--beingEdited) lastSetEvents = 0; } 00124 void SetModified(void); 00125 bool Modified(int &State); 00129 void SetEvents(void); 00130 void DeleteExpired(void); 00131 void Add(cTimer *Timer, cTimer *After = NULL); 00132 void Ins(cTimer *Timer, cTimer *Before = NULL); 00133 void Del(cTimer *Timer, bool DeleteObject = true); 00134 }; 00135 00136 extern cTimers Timers; 00137 00138 #endif //__TIMERS_H