2002-10-20 12:28:55 +02:00
|
|
|
/*
|
|
|
|
* timers.h: Timer handling
|
|
|
|
*
|
|
|
|
* See the main source file 'vdr.c' for copyright information and
|
|
|
|
* how to reach the author.
|
|
|
|
*
|
2013-02-08 09:24:55 +01:00
|
|
|
* $Id: timers.h 2.6 2013/02/05 11:23:24 kls Exp $
|
2002-10-20 12:28:55 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __TIMERS_H
|
|
|
|
#define __TIMERS_H
|
|
|
|
|
|
|
|
#include "channels.h"
|
|
|
|
#include "config.h"
|
2003-12-22 13:29:24 +01:00
|
|
|
#include "epg.h"
|
2002-10-20 12:28:55 +02:00
|
|
|
#include "tools.h"
|
|
|
|
|
2004-02-29 14:21:22 +01:00
|
|
|
enum eTimerFlags { tfNone = 0x0000,
|
|
|
|
tfActive = 0x0001,
|
|
|
|
tfInstant = 0x0002,
|
|
|
|
tfVps = 0x0004,
|
2005-05-07 11:10:56 +02:00
|
|
|
tfRecording = 0x0008,
|
2004-02-29 14:21:22 +01:00
|
|
|
tfAll = 0xFFFF,
|
|
|
|
};
|
|
|
|
enum eTimerMatch { tmNone, tmPartial, tmFull };
|
2002-10-20 12:28:55 +02:00
|
|
|
|
|
|
|
class cTimer : public cListObject {
|
|
|
|
friend class cMenuEditTimer;
|
|
|
|
private:
|
2004-11-01 10:40:38 +01:00
|
|
|
mutable time_t startTime, stopTime;
|
2006-02-25 15:57:56 +01:00
|
|
|
time_t lastSetEvent;
|
2011-08-06 13:20:07 +02:00
|
|
|
mutable time_t deferred; ///< Matches(time_t, ...) will return false if the current time is before this value
|
2004-02-29 14:21:22 +01:00
|
|
|
bool recording, pending, inVpsMargin;
|
2006-01-06 14:31:57 +01:00
|
|
|
uint flags;
|
2002-10-20 12:28:55 +02:00
|
|
|
cChannel *channel;
|
2005-03-20 15:15:42 +01:00
|
|
|
mutable time_t day; ///< midnight of the day this timer shall hit, or of the first day it shall hit in case of a repeating timer
|
|
|
|
int weekdays; ///< bitmask, lowest bits: SSFTWTM (the 'M' is the LSB)
|
2002-10-20 12:28:55 +02:00
|
|
|
int start;
|
|
|
|
int stop;
|
|
|
|
int priority;
|
|
|
|
int lifetime;
|
2013-02-08 09:24:55 +01:00
|
|
|
mutable char file[NAME_MAX * 2]; // *2 to be able to hold 'title' and 'episode', which can each be up to 255 characters long
|
2006-02-25 12:09:22 +01:00
|
|
|
char *aux;
|
2004-02-29 14:21:22 +01:00
|
|
|
const cEvent *event;
|
2002-10-20 12:28:55 +02:00
|
|
|
public:
|
2006-01-01 15:44:29 +01:00
|
|
|
cTimer(bool Instant = false, bool Pause = false, cChannel *Channel = NULL);
|
2003-12-22 13:29:24 +01:00
|
|
|
cTimer(const cEvent *Event);
|
2006-09-08 15:06:09 +02:00
|
|
|
cTimer(const cTimer &Timer);
|
2002-10-20 12:28:55 +02:00
|
|
|
virtual ~cTimer();
|
|
|
|
cTimer& operator= (const cTimer &Timer);
|
2004-11-01 10:40:38 +01:00
|
|
|
virtual int Compare(const cListObject &ListObject) const;
|
2005-03-20 15:15:42 +01:00
|
|
|
bool Recording(void) const { return recording; }
|
|
|
|
bool Pending(void) const { return pending; }
|
|
|
|
bool InVpsMargin(void) const { return inVpsMargin; }
|
2006-01-06 14:31:57 +01:00
|
|
|
uint Flags(void) const { return flags; }
|
2005-03-20 15:15:42 +01:00
|
|
|
const cChannel *Channel(void) const { return channel; }
|
|
|
|
time_t Day(void) const { return day; }
|
|
|
|
int WeekDays(void) const { return weekdays; }
|
|
|
|
int Start(void) const { return start; }
|
|
|
|
int Stop(void) const { return stop; }
|
|
|
|
int Priority(void) const { return priority; }
|
|
|
|
int Lifetime(void) const { return lifetime; }
|
|
|
|
const char *File(void) const { return file; }
|
|
|
|
time_t FirstDay(void) const { return weekdays ? day : 0; }
|
2006-02-25 12:09:22 +01:00
|
|
|
const char *Aux(void) const { return aux; }
|
2011-08-06 13:20:07 +02:00
|
|
|
time_t Deferred(void) const { return deferred; }
|
2008-02-16 15:04:49 +01:00
|
|
|
cString ToText(bool UseChannelID = false) const;
|
2005-03-20 15:15:42 +01:00
|
|
|
cString ToDescr(void) const;
|
|
|
|
const cEvent *Event(void) const { return event; }
|
2002-10-20 12:28:55 +02:00
|
|
|
bool Parse(const char *s);
|
|
|
|
bool Save(FILE *f);
|
2004-11-01 10:40:38 +01:00
|
|
|
bool IsSingleEvent(void) const;
|
2004-11-14 16:27:27 +01:00
|
|
|
static int GetMDay(time_t t);
|
|
|
|
static int GetWDay(time_t t);
|
2004-11-01 10:40:38 +01:00
|
|
|
bool DayMatches(time_t t) const;
|
2002-10-20 12:28:55 +02:00
|
|
|
static time_t IncDay(time_t t, int Days);
|
|
|
|
static time_t SetTime(time_t t, int SecondsFromMidnight);
|
2012-02-20 15:53:33 +01:00
|
|
|
void SetFile(const char *File);
|
2006-04-09 09:12:47 +02:00
|
|
|
bool Matches(time_t t = 0, bool Directly = false, int Margin = 0) const;
|
2012-12-08 11:05:39 +01:00
|
|
|
eTimerMatch Matches(const cEvent *Event, int *Overlap = NULL) const;
|
2005-03-20 15:15:42 +01:00
|
|
|
bool Expired(void) const;
|
2004-11-01 10:40:38 +01:00
|
|
|
time_t StartTime(void) const;
|
|
|
|
time_t StopTime(void) const;
|
2006-02-25 15:57:56 +01:00
|
|
|
void SetEventFromSchedule(const cSchedules *Schedules = NULL);
|
2005-12-27 14:39:14 +01:00
|
|
|
void SetEvent(const cEvent *Event);
|
2002-10-20 12:28:55 +02:00
|
|
|
void SetRecording(bool Recording);
|
|
|
|
void SetPending(bool Pending);
|
2004-02-29 14:21:22 +01:00
|
|
|
void SetInVpsMargin(bool InVpsMargin);
|
2012-02-20 15:37:01 +01:00
|
|
|
void SetDay(time_t Day);
|
|
|
|
void SetWeekDays(int WeekDays);
|
|
|
|
void SetStart(int Start);
|
|
|
|
void SetStop(int Stop);
|
2006-01-03 11:46:57 +01:00
|
|
|
void SetPriority(int Priority);
|
2012-02-20 15:37:01 +01:00
|
|
|
void SetLifetime(int Lifetime);
|
|
|
|
void SetAux(const char *Aux);
|
2011-08-06 13:20:07 +02:00
|
|
|
void SetDeferred(int Seconds);
|
2006-01-06 14:31:57 +01:00
|
|
|
void SetFlags(uint Flags);
|
|
|
|
void ClrFlags(uint Flags);
|
|
|
|
void InvFlags(uint Flags);
|
|
|
|
bool HasFlags(uint Flags) const;
|
2002-10-20 12:28:55 +02:00
|
|
|
void Skip(void);
|
|
|
|
void OnOff(void);
|
2005-03-20 15:15:42 +01:00
|
|
|
cString PrintFirstDay(void) const;
|
2002-10-20 12:28:55 +02:00
|
|
|
static int TimeToInt(int t);
|
2005-03-19 15:38:43 +01:00
|
|
|
static bool ParseDay(const char *s, time_t &Day, int &WeekDays);
|
2007-06-10 13:02:43 +02:00
|
|
|
static cString PrintDay(time_t Day, int WeekDays, bool SingleByteChars);
|
2002-10-20 12:28:55 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class cTimers : public cConfig<cTimer> {
|
2003-02-09 13:14:44 +01:00
|
|
|
private:
|
2006-01-15 13:44:55 +01:00
|
|
|
int state;
|
2003-02-09 13:14:44 +01:00
|
|
|
int beingEdited;
|
2004-10-24 15:01:50 +02:00
|
|
|
time_t lastSetEvents;
|
2006-03-26 14:38:46 +02:00
|
|
|
time_t lastDeleteExpired;
|
2002-10-20 12:28:55 +02:00
|
|
|
public:
|
2004-10-24 15:01:50 +02:00
|
|
|
cTimers(void);
|
2002-10-20 12:28:55 +02:00
|
|
|
cTimer *GetTimer(cTimer *Timer);
|
|
|
|
cTimer *GetMatch(time_t t);
|
2012-12-08 11:05:39 +01:00
|
|
|
cTimer *GetMatch(const cEvent *Event, eTimerMatch *Match = NULL);
|
2002-10-20 12:28:55 +02:00
|
|
|
cTimer *GetNextActiveTimer(void);
|
2003-02-09 13:14:44 +01:00
|
|
|
int BeingEdited(void) { return beingEdited; }
|
|
|
|
void IncBeingEdited(void) { beingEdited++; }
|
2004-10-24 15:01:50 +02:00
|
|
|
void DecBeingEdited(void) { if (!--beingEdited) lastSetEvents = 0; }
|
2004-10-31 10:22:32 +01:00
|
|
|
void SetModified(void);
|
2006-01-15 13:44:55 +01:00
|
|
|
bool Modified(int &State);
|
|
|
|
///< Returns true if any of the timers have been modified, which
|
|
|
|
///< is detected by State being different than the internal state.
|
|
|
|
///< Upon return the internal state will be stored in State.
|
2004-02-29 14:21:22 +01:00
|
|
|
void SetEvents(void);
|
2005-03-20 11:19:36 +01:00
|
|
|
void DeleteExpired(void);
|
2008-02-16 15:04:49 +01:00
|
|
|
void Add(cTimer *Timer, cTimer *After = NULL);
|
|
|
|
void Ins(cTimer *Timer, cTimer *Before = NULL);
|
|
|
|
void Del(cTimer *Timer, bool DeleteObject = true);
|
2002-10-20 12:28:55 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
extern cTimers Timers;
|
|
|
|
|
2012-06-02 12:10:36 +02:00
|
|
|
class cSortedTimers : public cVector<const cTimer *> {
|
|
|
|
public:
|
|
|
|
cSortedTimers(void);
|
|
|
|
};
|
|
|
|
|
2002-10-20 12:28:55 +02:00
|
|
|
#endif //__TIMERS_H
|