|
SASC-NG
DVBSoftCAM
|
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 1.30 2007/06/03 13:24:58 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 bool recording, pending, inVpsMargin; 00033 uint flags; 00034 cChannel *channel; 00035 mutable time_t day; 00036 int weekdays; 00037 int start; 00038 int stop; 00039 int priority; 00040 int lifetime; 00041 char file[MaxFileName]; 00042 char *aux; 00043 const cEvent *event; 00044 public: 00045 cTimer(bool Instant = false, bool Pause = false, cChannel *Channel = NULL); 00046 cTimer(const cEvent *Event); 00047 cTimer(const cTimer &Timer); 00048 virtual ~cTimer(); 00049 cTimer& operator= (const cTimer &Timer); 00050 virtual int Compare(const cListObject &ListObject) const; 00051 bool Recording(void) const { return recording; } 00052 bool Pending(void) const { return pending; } 00053 bool InVpsMargin(void) const { return inVpsMargin; } 00054 uint Flags(void) const { return flags; } 00055 const cChannel *Channel(void) const { return channel; } 00056 time_t Day(void) const { return day; } 00057 int WeekDays(void) const { return weekdays; } 00058 int Start(void) const { return start; } 00059 int Stop(void) const { return stop; } 00060 int Priority(void) const { return priority; } 00061 int Lifetime(void) const { return lifetime; } 00062 const char *File(void) const { return file; } 00063 time_t FirstDay(void) const { return weekdays ? day : 0; } 00064 const char *Aux(void) const { return aux; } 00065 cString ToText(bool UseChannelID = false); 00066 cString ToDescr(void) const; 00067 const cEvent *Event(void) const { return event; } 00068 bool Parse(const char *s); 00069 bool Save(FILE *f); 00070 bool IsSingleEvent(void) const; 00071 static int GetMDay(time_t t); 00072 static int GetWDay(time_t t); 00073 bool DayMatches(time_t t) const; 00074 static time_t IncDay(time_t t, int Days); 00075 static time_t SetTime(time_t t, int SecondsFromMidnight); 00076 char *SetFile(const char *File); 00077 bool Matches(time_t t = 0, bool Directly = false, int Margin = 0) const; 00078 int Matches(const cEvent *Event, int *Overlap = NULL) const; 00079 bool Expired(void) const; 00080 time_t StartTime(void) const; 00081 time_t StopTime(void) const; 00082 void SetEventFromSchedule(const cSchedules *Schedules = NULL); 00083 void SetEvent(const cEvent *Event); 00084 void SetRecording(bool Recording); 00085 void SetPending(bool Pending); 00086 void SetInVpsMargin(bool InVpsMargin); 00087 void SetPriority(int Priority); 00088 void SetFlags(uint Flags); 00089 void ClrFlags(uint Flags); 00090 void InvFlags(uint Flags); 00091 bool HasFlags(uint Flags) const; 00092 void Skip(void); 00093 void OnOff(void); 00094 cString PrintFirstDay(void) const; 00095 static int TimeToInt(int t); 00096 static bool ParseDay(const char *s, time_t &Day, int &WeekDays); 00097 static cString PrintDay(time_t Day, int WeekDays, bool SingleByteChars); 00098 }; 00099 00100 class cTimers : public cConfig<cTimer> { 00101 private: 00102 int state; 00103 int beingEdited; 00104 time_t lastSetEvents; 00105 time_t lastDeleteExpired; 00106 public: 00107 cTimers(void); 00108 cTimer *GetTimer(cTimer *Timer); 00109 cTimer *GetMatch(time_t t); 00110 cTimer *GetMatch(const cEvent *Event, int *Match = NULL); 00111 cTimer *GetNextActiveTimer(void); 00112 int BeingEdited(void) { return beingEdited; } 00113 void IncBeingEdited(void) { beingEdited++; } 00114 void DecBeingEdited(void) { if (!--beingEdited) lastSetEvents = 0; } 00115 void SetModified(void); 00116 bool Modified(int &State); 00120 void SetEvents(void); 00121 void DeleteExpired(void); 00122 }; 00123 00124 extern cTimers Timers; 00125 00126 #endif //__TIMERS_H