diff options
author | Klaus Schmidinger <vdr@tvdr.de> | 2001-08-26 15:02:00 +0200 |
---|---|---|
committer | Klaus Schmidinger <vdr@tvdr.de> | 2001-08-26 15:02:00 +0200 |
commit | f4d75d4141c9cb09dc09688cbc5f4a79015a318e (patch) | |
tree | 39ca3d175521f520f5ae9ed2f018102d73acb3d3 | |
parent | 6f6891082885d6c68f1a7efd80f99a0c907a9a4b (diff) | |
download | vdr-f4d75d4141c9cb09dc09688cbc5f4a79015a318e.tar.gz vdr-f4d75d4141c9cb09dc09688cbc5f4a79015a318e.tar.bz2 |
Implemented GetNextActiveTimer()
-rw-r--r-- | config.c | 51 | ||||
-rw-r--r-- | config.h | 6 | ||||
-rw-r--r-- | vdr.c | 4 |
3 files changed, 33 insertions, 28 deletions
@@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: config.c 1.58 2001/08/26 14:11:29 kls Exp $ + * $Id: config.c 1.59 2001/08/26 14:46:43 kls Exp $ */ #include "config.h" @@ -422,13 +422,6 @@ int cTimer::TimeToInt(int t) return (t / 100 * 60 + t % 100) * 60; } -time_t cTimer::Day(time_t t) -{ - struct tm d = *localtime(&t); - d.tm_hour = d.tm_min = d.tm_sec = 0; - return mktime(&d); -} - int cTimer::ParseDay(const char *s) { char *tail; @@ -605,21 +598,6 @@ void cTimer::SetPending(bool Pending) pending = Pending; } -cTimer *cTimer::GetMatch(void) -{ - time_t t = time(NULL); // all timers must be checked against the exact same time to correctly handle Priority! - cTimer *t0 = NULL; - cTimer *ti = (cTimer *)Timers.First(); - while (ti) { - if (!ti->recording && ti->Matches(t)) { - if (!t0 || ti->priority > t0->priority) - t0 = ti; - } - ti = (cTimer *)ti->Next(); - } - return t0; -} - // --- cCommand ------------------------------------------------------------- char *cCommand::result = NULL; @@ -783,6 +761,33 @@ cTimer *cTimers::GetTimer(cTimer *Timer) return NULL; } +cTimer *cTimers::GetMatch(void) +{ + time_t t = time(NULL); // all timers must be checked against the exact same time to correctly handle Priority! + cTimer *t0 = NULL; + cTimer *ti = First(); + while (ti) { + if (!ti->recording && ti->Matches(t)) { + if (!t0 || ti->priority > t0->priority) + t0 = ti; + } + ti = (cTimer *)ti->Next(); + } + return t0; +} + +cTimer *cTimers::GetNextActiveTimer(void) +{ + cTimer *t0 = NULL; + cTimer *ti = First(); + while (ti) { + if (ti->active && (!t0 || *ti < *t0)) + t0 = ti; + ti = (cTimer *)ti->Next(); + } + return t0; +} + // -- cSetup ----------------------------------------------------------------- cSetup Setup; @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: config.h 1.65 2001/08/26 14:08:23 kls Exp $ + * $Id: config.h 1.66 2001/08/26 14:46:53 kls Exp $ */ #ifndef __CONFIG_H @@ -152,9 +152,7 @@ public: time_t StopTime(void); void SetRecording(bool Recording); void SetPending(bool Pending); - static cTimer *GetMatch(void); static int TimeToInt(int t); - static time_t Day(time_t t); static int ParseDay(const char *s); static const char *PrintDay(int d); }; @@ -257,6 +255,8 @@ public: class cTimers : public cConfig<cTimer> { public: cTimer *GetTimer(cTimer *Timer); + cTimer *GetMatch(void); + cTimer *GetNextActiveTimer(void); }; class cCommands : public cConfig<cCommand> {}; @@ -22,7 +22,7 @@ * * The project's page is at http://www.cadsoft.de/people/kls/vdr * - * $Id: vdr.c 1.63 2001/08/11 15:33:30 kls Exp $ + * $Id: vdr.c 1.64 2001/08/26 15:02:00 kls Exp $ */ #include <getopt.h> @@ -323,7 +323,7 @@ int main(int argc, char *argv[]) } // Timers and Recordings: if (!Menu) { - cTimer *Timer = cTimer::GetMatch(); + cTimer *Timer = Timers.GetMatch(); if (Timer) { if (!cRecordControls::Start(Timer)) Timer->SetPending(true); |