1
0
mirror of https://github.com/VDR4Arch/vdr.git synced 2023-10-10 13:36:52 +02:00

Implemented GetNextActiveTimer()

This commit is contained in:
Klaus Schmidinger 2001-08-26 15:02:00 +02:00
parent 6f68910828
commit f4d75d4141
3 changed files with 33 additions and 28 deletions

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * 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" #include "config.h"
@ -422,13 +422,6 @@ int cTimer::TimeToInt(int t)
return (t / 100 * 60 + t % 100) * 60; 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) int cTimer::ParseDay(const char *s)
{ {
char *tail; char *tail;
@ -605,21 +598,6 @@ void cTimer::SetPending(bool Pending)
pending = 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 ------------------------------------------------------------- // --- cCommand -------------------------------------------------------------
char *cCommand::result = NULL; char *cCommand::result = NULL;
@ -783,6 +761,33 @@ cTimer *cTimers::GetTimer(cTimer *Timer)
return NULL; 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 -----------------------------------------------------------------
cSetup Setup; cSetup Setup;

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * 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 #ifndef __CONFIG_H
@ -152,9 +152,7 @@ public:
time_t StopTime(void); time_t StopTime(void);
void SetRecording(bool Recording); void SetRecording(bool Recording);
void SetPending(bool Pending); void SetPending(bool Pending);
static cTimer *GetMatch(void);
static int TimeToInt(int t); static int TimeToInt(int t);
static time_t Day(time_t t);
static int ParseDay(const char *s); static int ParseDay(const char *s);
static const char *PrintDay(int d); static const char *PrintDay(int d);
}; };
@ -257,6 +255,8 @@ public:
class cTimers : public cConfig<cTimer> { class cTimers : public cConfig<cTimer> {
public: public:
cTimer *GetTimer(cTimer *Timer); cTimer *GetTimer(cTimer *Timer);
cTimer *GetMatch(void);
cTimer *GetNextActiveTimer(void);
}; };
class cCommands : public cConfig<cCommand> {}; class cCommands : public cConfig<cCommand> {};

4
vdr.c
View File

@ -22,7 +22,7 @@
* *
* The project's page is at http://www.cadsoft.de/people/kls/vdr * 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> #include <getopt.h>
@ -323,7 +323,7 @@ int main(int argc, char *argv[])
} }
// Timers and Recordings: // Timers and Recordings:
if (!Menu) { if (!Menu) {
cTimer *Timer = cTimer::GetMatch(); cTimer *Timer = Timers.GetMatch();
if (Timer) { if (Timer) {
if (!cRecordControls::Start(Timer)) if (!cRecordControls::Start(Timer))
Timer->SetPending(true); Timer->SetPending(true);