39 time_t t = time(NULL);
41 struct tm *now = localtime_r(&t, &tm_r);
44 start = now->tm_hour * 100 + now->tm_min;
50 if (
const cEvent *
Event = Schedule->GetPresentEvent()) {
62 struct tm *time = localtime_r(&tstart, &tm_r);
63 start = time->tm_hour * 100 + time->tm_min;
64 time = localtime_r(&tstop, &tm_r);
65 stop = time->tm_hour * 100 + time->tm_min;
97 time_t tstop = tstart + Event->
Duration();
103 struct tm *time = localtime_r(&tstart, &tm_r);
106 start = time->tm_hour * 100 + time->tm_min;
107 time = localtime_r(&tstop, &tm_r);
108 stop = time->tm_hour * 100 + time->tm_min;
113 const char *Title = Event->
Title();
135 if (&Timer !=
this) {
154 aux = Timer.
aux ? strdup(Timer.
aux) : NULL;
174 cString buffer =
cString::sprintf(
"%u:%s:%s:%04d:%04d:%d:%d:%s:%s\n",
flags, UseChannelID ? *
Channel()->GetChannelID().ToString() : *
itoa(
Channel()->Number()), *
PrintDay(
day,
weekdays,
true),
start,
stop,
priority,
lifetime,
file,
aux ?
aux :
"");
186 return (t / 100 * 60 + t % 100) * 60;
203 const char *a = strchr(s,
'@');
204 const char *d = a ? a + 1 : isdigit(*s) ? s : NULL;
206 if (strlen(d) == 10) {
208 if (3 == sscanf(d,
"%d-%d-%d", &tm_r.tm_year, &tm_r.tm_mon, &tm_r.tm_mday)) {
209 tm_r.tm_year -= 1900;
211 tm_r.tm_hour = tm_r.tm_min = tm_r.tm_sec = 0;
221 int day = strtol(d, &tail, 10);
222 if (tail && *tail || day < 1 || day > 31)
224 time_t t = time(NULL);
225 int DaysToCheck = 61;
226 for (
int i = -1; i <= DaysToCheck; i++) {
235 if (a || !isdigit(*s)) {
236 if ((a && a - s == 7) || strlen(s) == 7) {
237 for (
const char *p = s + 6; p >= s; p--) {
239 WeekDays |= (*p !=
'-');
250 #define DAYBUFFERSIZE 64 255 const char *w =
trNOOP(
"MTWTFSS");
256 if (!SingleByteChars)
261 for (
int i = 0; i < sl; i++)
275 localtime_r(&Day, &tm_r);
276 b += strftime(b,
DAYBUFFERSIZE - (b - buffer),
"%Y-%m-%d", &tm_r);
294 char *channelbuffer = NULL;
295 char *daybuffer = NULL;
296 char *filebuffer = NULL;
307 while (l2 > 0 && isspace(s[l2 - 1]))
309 if (s[l2 - 1] ==
':') {
310 s2 =
MALLOC(
char, l2 + 3);
311 strcat(
strn0cpy(s2, s, l2 + 1),
" \n");
315 if (8 <= sscanf(s,
"%u :%m[^:]:%m[^:]:%d :%d :%d :%d :%m[^:\n]:%m[^\n]", &
flags, &channelbuffer, &daybuffer, &
start, &
stop, &
priority, &
lifetime, &filebuffer, &
aux)) {
330 esyslog(
"ERROR: channel %s not defined", channelbuffer);
343 return fprintf(f,
"%s", *
ToText(
true)) > 0;
354 return localtime_r(&t, &tm_r)->tm_mday;
360 int weekday = localtime_r(&t, &tm_r)->tm_wday;
361 return weekday == 0 ? 6 : weekday - 1;
372 tm tm = *localtime_r(&t, &tm_r);
384 tm tm = *localtime_r(&t, &tm_r);
385 tm.tm_hour = SecondsFromMidnight / 3600;
386 tm.tm_min = (SecondsFromMidnight % 3600) / 60;
387 tm.tm_sec = SecondsFromMidnight % 60;
398 #define EITPRESENTFOLLOWINGRATE 10 // max. seconds between two occurrences of the "EIT present/following table for the actual multiplex" (2s by the standard, using some more for safety) 416 for (
int i = -1; i <= 7; i++) {
420 time_t b = a + length;
421 if ((!
day || a >=
day) && t < b) {
440 if (Margin || !Directly) {
457 #define FULLMATCH 1000 490 #define EXPIRELATENCY 60 // seconds (just in case there's a short glitch in the VPS signal) 511 #define EPGLIMITBEFORE (1 * 3600) // Time in seconds before a timer's start time and 512 #define EPGLIMITAFTER (1 * 3600) // after its stop time within which EPG events will be taken into consideration. 524 time_t now = time(NULL);
532 if (now <= event->EndTime() ||
Matches(0,
true))
555 if (e->EndTime() < TimeFrameBegin)
557 if (e->StartTime() > TimeFrameEnd)
561 if (overlap && overlap >= Overlap) {
576 if (
event != Event) {
701 lastDeleteExpired = 0;
706 for (
cTimer *ti = First(); ti; ti =
Next(ti)) {
707 if (ti->Channel() == Timer->
Channel() &&
708 (ti->WeekDays() && ti->WeekDays() == Timer->
WeekDays() || !ti->WeekDays() && ti->Day() == Timer->
Day()) &&
709 ti->Start() == Timer->
Start() &&
710 ti->Stop() == Timer->
Stop())
718 static int LastPending = -1;
720 for (
cTimer *ti = First(); ti; ti =
Next(ti)) {
721 if (!ti->Recording() && ti->Matches(t)) {
723 if (ti->Index() > LastPending) {
724 LastPending = ti->
Index();
743 for (
cTimer *ti = First(); ti; ti =
Next(ti)) {
760 for (
cTimer *ti = First(); ti; ti =
Next(ti)) {
762 if ((ti->HasFlags(
tfActive)) && (!t0 || ti->
StopTime() > time(NULL) && ti->Compare(*t0) < 0))
794 bool Result = state != State;
801 if (time(NULL) - lastSetEvents < 5)
806 if (!lastSetEvents || Schedules->
Modified() >= lastSetEvents) {
807 for (
cTimer *ti = First(); ti; ti =
Next(ti)) {
810 ti->SetEventFromSchedule(Schedules);
814 lastSetEvents = time(NULL);
819 if (time(NULL) - lastDeleteExpired < 30)
831 lastDeleteExpired = time(NULL);
838 return (*(
const cTimer **)a)->Compare(**(
const cTimer **)b);
844 for (
const cTimer *Timer = Timers.
First(); Timer; Timer = Timers.
Next(Timer))
void SetWeekDays(int WeekDays)
static tChannelID FromString(const char *s)
time_t EndTime(void) const
void SetRecording(bool Recording)
void SetEvent(const cEvent *Event)
void Add(cListObject *Object, cListObject *After=NULL)
cString ToDescr(void) const
static int TimeToInt(int t)
const cSchedule * Schedule(void) const
static cString sprintf(const char *fmt,...) __attribute__((format(printf
virtual void Append(const cTimer * Data)
bool DayMatches(time_t t) const
cString PrintFirstDay(void) const
cTimer * GetMatch(time_t t)
const cEvent * Event(void) const
bool Matches(time_t t=0, bool Directly=false, int Margin=0) const
bool Parse(const char *s)
void SetInVpsMargin(bool InVpsMargin)
#define EITPRESENTFOLLOWINGRATE
void SetPending(bool Pending)
time_t StartTime(void) const
int weekdays
bitmask, lowest bits: SSFTWTM (the 'M' is the LSB)
time_t StartTime(void) const
cTimer * GetNextActiveTimer(void)
void Add(cTimer *Timer, cTimer *After=NULL)
bool PresentSeenWithin(int Seconds) const
static const cSchedules * Schedules(cSchedulesLock &SchedulesLock)
Caller must provide a cSchedulesLock which has to survive the entire time the returned cSchedules is ...
const cChannel * Channel(void) const
virtual int Compare(const cListObject &ListObject) const
Must return 0 if this object is equal to ListObject, a positive value if it is "greater", and a negative value if it is "smaller".
static time_t SetTime(time_t t, int SecondsFromMidnight)
void SetEventFromSchedule(const cSchedules *Schedules=NULL)
bool Recording(void) const
cTimer * GetTimer(cTimer *Timer)
static int CurrentChannel(void)
Returns the number of the current channel on the primary device.
const char * Name(void) const
T * Next(const T *object) const
bool Modified(int &State)
Returns true if any of the timers have been modified, which is detected by State being different than...
static time_t Modified(void)
void Ins(cTimer *Timer, cTimer *Before=NULL)
cListObject * Next(void) const
tChannelID ChannelID(void) const
static int GetMDay(time_t t)
bool HasFlags(uint Flags) const
const cList< cEvent > * Events(void) const
void Ins(cListObject *Object, cListObject *Before=NULL)
void SetLifetime(int Lifetime)
static int Utf8CharLen(const char *s)
tChannelID GetChannelID(void) const
time_t Modified(void) const
static bool HasKeys(void)
void Sort(__compar_fn_t Compare)
void SetAux(const char *Aux)
cTimer & operator=(const cTimer &Timer)
time_t day
midnight of the day this timer shall hit, or of the first day it shall hit in case of a repeating tim...
static time_t IncDay(time_t t, int Days)
bool InVpsMargin(void) const
cChannel * GetByChannelID(tChannelID ChannelID, bool TryWithoutRid=false, bool TryWithoutPolarization=false)
static int GetWDay(time_t t)
const char * Title(void) const
void SetPriority(int Priority)
time_t deferred
Matches(time_t, ...) will return false if the current time is before this value.
const cSchedule * GetSchedule(tChannelID ChannelID) const
cString ToDescr(void) const
void Del(cListObject *Object, bool DeleteObject=true)
time_t StopTime(void) const
void InvFlags(uint Flags)
cChannel * GetByNumber(int Number, int SkipGap=0)
void SetFlags(uint Flags)
void SetDeferred(int Seconds)
static void MsgTimerChange(const cTimer *Timer, eTimerChange Change)
const char * File(void) const
bool IsSingleEvent(void) const
cTimer(bool Instant=false, bool Pause=false, cChannel *Channel=NULL)
static bool ParseDay(const char *s, time_t &Day, int &WeekDays)
void ClrFlags(uint Flags)
char NameInstantRecord[NAME_MAX+1]
bool IsRunning(bool OrAboutToStart=false) const
cString ToText(bool UseChannelID=false) const
static int CompareTimers(const void *a, const void *b)
void Del(cTimer *Timer, bool DeleteObject=true)
const char * Aux(void) const
void SetFile(const char *File)
static cString PrintDay(time_t Day, int WeekDays, bool SingleByteChars)