From f1494502a736ef07cd37786f63a9478d5ed89341 Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Sun, 20 Mar 2005 15:15:42 +0100 Subject: [PATCH] All log entries regarding timers now contain a short description of the timer --- HISTORY | 1 + menu.c | 18 ++++++++---------- svdrp.c | 12 ++++++------ timers.c | 25 ++++++++++++++++--------- timers.h | 43 ++++++++++++++++++++++--------------------- tools.c | 4 ++-- tools.h | 4 ++-- 7 files changed, 57 insertions(+), 50 deletions(-) diff --git a/HISTORY b/HISTORY index 81c68c05..e5eaa4e1 100644 --- a/HISTORY +++ b/HISTORY @@ -3472,3 +3472,4 @@ Video Disk Recorder Revision History - Improved falling back to normal recording if the VPS data hasn't been seen for more than 30 seconds. - Added a missing cMutexLock to cRemote::HasKeys() (thanks to Wolfgang Rohdewald). +- All log entries regarding timers now contain a short description of the timer. diff --git a/menu.c b/menu.c index 7abd0b19..30183dfc 100644 --- a/menu.c +++ b/menu.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: menu.c 1.347 2005/03/20 11:26:00 kls Exp $ + * $Id: menu.c 1.348 2005/03/20 15:14:51 kls Exp $ */ #include "menu.h" @@ -690,7 +690,7 @@ eOSState cMenuEditTimer::ProcessKey(eKeys Key) Timers.Add(timer); timer->Matches(); Timers.SetModified(); - isyslog("timer %d %s (%s)", timer->Index() + 1, addIfConfirmed ? "added" : "modified", timer->HasFlags(tfActive) ? "active" : "inactive"); + isyslog("timer %s %s (%s)", *timer->ToDescr(), addIfConfirmed ? "added" : "modified", timer->HasFlags(tfActive) ? "active" : "inactive"); addIfConfirmed = false; } } @@ -809,9 +809,9 @@ eOSState cMenuTimers::OnOff(void) RefreshCurrent(); DisplayCurrent(true); if (timer->FirstDay()) - isyslog("timer %d first day set to %s", timer->Index() + 1, *timer->PrintFirstDay()); + isyslog("timer %s first day set to %s", *timer->ToDescr(), *timer->PrintFirstDay()); else - isyslog("timer %d %sactivated", timer->Index() + 1, timer->HasFlags(tfActive) ? "" : "de"); + isyslog("timer %s %sactivated", *timer->ToDescr(), timer->HasFlags(tfActive) ? "" : "de"); Timers.SetModified(); } return osContinue; @@ -821,7 +821,7 @@ eOSState cMenuTimers::Edit(void) { if (HasSubMenu() || Count() == 0) return osContinue; - isyslog("editing timer %d", CurrentTimer()->Index() + 1); + isyslog("editing timer %s", *CurrentTimer()->ToDescr()); return AddSubMenu(new cMenuEditTimer(CurrentTimer())); } @@ -846,12 +846,11 @@ eOSState cMenuTimers::Delete(void) else return osContinue; } - int Index = ti->Index(); + isyslog("deleting timer %s", *ti->ToDescr()); Timers.Del(ti); cOsdMenu::Del(Current()); Timers.SetModified(); Display(); - isyslog("timer %d deleted", Index + 1); } } return osContinue; @@ -1617,9 +1616,8 @@ eOSState cMenuRecordings::Delete(void) timer->Skip(); cRecordControls::Process(time(NULL)); if (timer->IsSingleEvent()) { - int Index = timer->Index(); + isyslog("deleting timer %s", *timer->ToDescr()); Timers.Del(timer); - isyslog("timer %d deleted", Index + 1); } Timers.SetModified(); } @@ -3172,7 +3170,7 @@ void cRecordControls::Stop(const char *InstantId) cTimer *timer = RecordControls[i]->Timer(); RecordControls[i]->Stop(); if (timer) { - isyslog("deleting timer %d", timer->Index() + 1); + isyslog("deleting timer %s", *timer->ToDescr()); Timers.Del(timer); Timers.SetModified(); } diff --git a/svdrp.c b/svdrp.c index be7d161b..71015023 100644 --- a/svdrp.c +++ b/svdrp.c @@ -10,7 +10,7 @@ * and interact with the Video Disk Recorder - or write a full featured * graphical interface that sits on top of an SVDRP connection. * - * $Id: svdrp.c 1.68 2005/03/19 16:05:33 kls Exp $ + * $Id: svdrp.c 1.69 2005/03/20 15:04:00 kls Exp $ */ #include "svdrp.h" @@ -529,9 +529,9 @@ void cSVDRP::CmdDELT(const char *Option) cTimer *timer = Timers.Get(strtol(Option, NULL, 10) - 1); if (timer) { if (!timer->Recording()) { + isyslog("deleting timer %s", *timer->ToDescr()); Timers.Del(timer); Timers.SetModified(); - isyslog("timer %s deleted", Option); Reply(250, "Timer \"%s\" deleted", Option); } else @@ -919,7 +919,7 @@ void cSVDRP::CmdMODT(const char *Option) } *timer = t; Timers.SetModified(); - isyslog("timer %d modified (%s)", timer->Index() + 1, timer->HasFlags(tfActive) ? "active" : "inactive"); + isyslog("timer %s modified (%s)", *timer->ToDescr(), timer->HasFlags(tfActive) ? "active" : "inactive"); Reply(250, "%d %s", timer->Index() + 1, *timer->ToText()); } else @@ -977,7 +977,7 @@ void cSVDRP::CmdNEWT(const char *Option) if (!t) { Timers.Add(timer); Timers.SetModified(); - isyslog("timer %d added", timer->Index() + 1); + isyslog("timer %s added", *timer->ToDescr()); Reply(250, "%d %s", timer->Index() + 1, *timer->ToText()); return; } @@ -1051,11 +1051,11 @@ void cSVDRP::CmdUPDT(const char *Option) t->Parse(Option); delete timer; timer = t; - isyslog("timer %d updated", timer->Index() + 1); + isyslog("timer %s updated", *timer->ToDescr()); } else { Timers.Add(timer); - isyslog("timer %d added", timer->Index() + 1); + isyslog("timer %s added", *timer->ToDescr()); } Timers.SetModified(); Reply(250, "%d %s", timer->Index() + 1, *timer->ToText()); diff --git a/timers.c b/timers.c index 964dfcba..2dded66e 100644 --- a/timers.c +++ b/timers.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: timers.c 1.29 2005/03/20 14:18:04 kls Exp $ + * $Id: timers.c 1.30 2005/03/20 14:50:37 kls Exp $ */ #include "timers.h" @@ -115,6 +115,13 @@ cString cTimer::ToText(bool UseChannelID) return cString(buffer, true); } +cString cTimer::ToDescr(void) const +{ + char *buffer; + asprintf(&buffer, "%d (%d %04d-%04d '%s')", Index() + 1, Channel()->Number(), start, stop, file); + return cString(buffer, true); +} + int cTimer::TimeToInt(int t) { return (t / 100 * 60 + t % 100) * 60; @@ -203,7 +210,7 @@ cString cTimer::PrintDay(time_t Day, int WeekDays) return buffer; } -cString cTimer::PrintFirstDay(void) +cString cTimer::PrintFirstDay(void) const { if (weekdays) { cString s = PrintDay(day, weekdays); @@ -367,7 +374,7 @@ bool cTimer::Matches(time_t t, bool Directly) const #define FULLMATCH 1000 -int cTimer::Matches(const cEvent *Event, int *Overlap) +int cTimer::Matches(const cEvent *Event, int *Overlap) const { // Overlap is the percentage of the Event's duration that is covered by // this timer (based on FULLMATCH for finer granularity than just 100). @@ -396,7 +403,7 @@ int cTimer::Matches(const cEvent *Event, int *Overlap) #define EXPIRELATENCY 60 // seconds (just in case there's a short glitch in the VPS signal) -bool cTimer::Expired(void) +bool cTimer::Expired(void) const { return IsSingleEvent() && !Recording() && StopTime() + EXPIRELATENCY <= time(NULL); } @@ -422,10 +429,10 @@ void cTimer::SetEvent(const cSchedule *Schedule, const cEvent *Event) char vpsbuf[64] = ""; if (Event->Vps()) sprintf(vpsbuf, "(VPS: %s) ", *Event->GetVpsString()); - isyslog("timer %d (%d %04d-%04d '%s') set to event %s %s-%s %s'%s'", Index() + 1, Channel()->Number(), start, stop, file, *Event->GetDateString(), *Event->GetTimeString(), *Event->GetEndTimeString(), vpsbuf, Event->Title()); + isyslog("timer %s set to event %s %s-%s %s'%s'", *ToDescr(), *Event->GetDateString(), *Event->GetTimeString(), *Event->GetEndTimeString(), vpsbuf, Event->Title()); } else - isyslog("timer %d (%d %04d-%04d '%s') set to no event", Index() + 1, Channel()->Number(), start, stop, file); + isyslog("timer %s set to no event", *ToDescr()); schedule = Event ? Schedule : NULL; event = Event; } @@ -434,7 +441,7 @@ void cTimer::SetEvent(const cSchedule *Schedule, const cEvent *Event) void cTimer::SetRecording(bool Recording) { recording = Recording; - isyslog("timer %d (%d %04d-%04d '%s') %s", Index() + 1, Channel()->Number(), start, stop, file, recording ? "start" : "stop"); + isyslog("timer %s %s", *ToDescr(), recording ? "start" : "stop"); } void cTimer::SetPending(bool Pending) @@ -445,7 +452,7 @@ void cTimer::SetPending(bool Pending) void cTimer::SetInVpsMargin(bool InVpsMargin) { if (InVpsMargin && !inVpsMargin) - isyslog("timer %d (%d %04d-%04d '%s') entered VPS margin", Index() + 1, Channel()->Number(), start, stop, file); + isyslog("timer %s entered VPS margin", *ToDescr()); inVpsMargin = InVpsMargin; } @@ -627,7 +634,7 @@ void cTimers::DeleteExpired(void) while (ti) { cTimer *next = Next(ti); if (ti->Expired()) { - isyslog("deleting timer %d", ti->Index() + 1); + isyslog("deleting timer %s", *ti->ToDescr()); Del(ti); SetModified(); } diff --git a/timers.h b/timers.h index 17a1d6d1..ae83f5b6 100644 --- a/timers.h +++ b/timers.h @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: timers.h 1.17 2005/03/20 12:36:25 kls Exp $ + * $Id: timers.h 1.18 2005/03/20 14:47:45 kls Exp $ */ #ifndef __TIMERS_H @@ -30,8 +30,8 @@ private: bool recording, pending, inVpsMargin; int flags; cChannel *channel; - 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) + 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) int start; int stop; int priority; @@ -46,22 +46,23 @@ public: virtual ~cTimer(); cTimer& operator= (const cTimer &Timer); virtual int Compare(const cListObject &ListObject) const; - bool Recording(void) { return recording; } - bool Pending(void) { return pending; } - bool InVpsMargin(void) { return inVpsMargin; } - int Flags(void) { return flags; } - const cChannel *Channel(void) { return channel; } - time_t Day(void) { return day; } - int WeekDays(void) { return weekdays; } - int Start(void) { return start; } - int Stop(void) { return stop; } - int Priority(void) { return priority; } - int Lifetime(void) { return lifetime; } - const char *File(void) { return file; } - time_t FirstDay(void) { return weekdays ? day : 0; } - const char *Summary(void) { return summary; } + bool Recording(void) const { return recording; } + bool Pending(void) const { return pending; } + bool InVpsMargin(void) const { return inVpsMargin; } + int Flags(void) const { return flags; } + 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; } + const char *Summary(void) const { return summary; } cString ToText(bool UseChannelID = false); - const cEvent *Event(void) { return event; } + cString ToDescr(void) const; + const cEvent *Event(void) const { return event; } bool Parse(const char *s); bool Save(FILE *f); bool IsSingleEvent(void) const; @@ -72,8 +73,8 @@ public: static time_t SetTime(time_t t, int SecondsFromMidnight); char *SetFile(const char *File); bool Matches(time_t t = 0, bool Directly = false) const; - int Matches(const cEvent *Event, int *Overlap = NULL); - bool Expired(void); + int Matches(const cEvent *Event, int *Overlap = NULL) const; + bool Expired(void) const; time_t StartTime(void) const; time_t StopTime(void) const; void SetEvent(const cSchedule *Schedule, const cEvent *Event); @@ -86,7 +87,7 @@ public: bool HasFlags(int Flags) const; void Skip(void); void OnOff(void); - cString PrintFirstDay(void); + cString PrintFirstDay(void) const; static int TimeToInt(int t); static bool ParseDay(const char *s, time_t &Day, int &WeekDays); static cString PrintDay(time_t Day, int WeekDays); diff --git a/tools.c b/tools.c index aee71ecf..28ea2afc 100644 --- a/tools.c +++ b/tools.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: tools.c 1.90 2005/02/19 13:43:03 kls Exp $ + * $Id: tools.c 1.91 2005/03/20 14:44:33 kls Exp $ */ #include "tools.h" @@ -896,7 +896,7 @@ void cListObject::Unlink(void) next = prev = NULL; } -int cListObject::Index(void) +int cListObject::Index(void) const { cListObject *p = prev; int i = 0; diff --git a/tools.h b/tools.h index be8782bf..d9e85f3e 100644 --- a/tools.h +++ b/tools.h @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: tools.h 1.67 2005/02/12 10:17:14 kls Exp $ + * $Id: tools.h 1.68 2005/03/20 14:44:24 kls Exp $ */ #ifndef __TOOLS_H @@ -202,7 +202,7 @@ public: void Append(cListObject *Object); void Insert(cListObject *Object); void Unlink(void); - int Index(void); + int Index(void) const; cListObject *Prev(void) const { return prev; } cListObject *Next(void) const { return next; } };