From 8a51dd3076c28c1dcfd9865e55ab899c4722ea81 Mon Sep 17 00:00:00 2001 From: Dave Date: Fri, 2 Sep 2011 14:52:50 +0100 Subject: Added auto-update of series links when new timer created. Setup menu (untested). --- plugin/HISTORY | 5 ++++ plugin/vdrtva.c | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++------- plugin/vdrtva.h | 33 +++++++++++++++++++++ 3 files changed, 120 insertions(+), 10 deletions(-) (limited to 'plugin') diff --git a/plugin/HISTORY b/plugin/HISTORY index b6f70dc..1efd82e 100644 --- a/plugin/HISTORY +++ b/plugin/HISTORY @@ -19,3 +19,8 @@ VDR Plugin 'vdrtva' Revision History - Major functions of Perl script built into plugin. - Auto-execution of series link updates. - Simplified internal data structures. + +2011-09-02: Version 0.0.5 + +- Added check for series links whenever a new timer is added. +- Added setup menu (not fully tested). diff --git a/plugin/vdrtva.c b/plugin/vdrtva.c index 95ad231..0946878 100644 --- a/plugin/vdrtva.c +++ b/plugin/vdrtva.c @@ -21,27 +21,30 @@ cChanDAs *ChanDAs; cEventCRIDs *EventCRIDs; cLinks *Links; -static const char *VERSION = "0.0.4"; +static const char *VERSION = "0.0.5"; static const char *DESCRIPTION = "TV-Anytime plugin"; static const char *MAINMENUENTRY = "vdrTva"; +int collectionperiod; // Time to collect all CRID data (default 10 minutes) +int lifetime; // Lifetime of series link recordings (default 99) +int priority; // Priority of series link recordings (default 99) +int seriesLifetime; // Expiry time of a series link (default 30 days) +int updatehours; // Time to carry out the series link update (default 03:00) +int updatemins; + + class cPluginvdrTva : public cPlugin { private: // Add any member variables or functions you may need here. int length; int size; - int seriesLifetime; - int priority; - int lifetime; int flags; - int collectionperiod; int state; time_t nextactiontime; - int updatehours; - int updatemins; char *buffer; char* configDir; cTvaFilter *Filter; + cTvaStatusMonitor *statusMonitor; bool Append(const char *Fmt, ...); bool AppendItems(const char* Option); const char* Reply(); @@ -105,6 +108,7 @@ cPluginvdrTva::cPluginvdrTva(void) cPluginvdrTva::~cPluginvdrTva() { // Clean up after yourself! + delete statusMonitor; } const char *cPluginvdrTva::CommandLineHelp(void) @@ -169,7 +173,7 @@ bool cPluginvdrTva::Start(void) // Start any background activities the plugin shall perform. configDir = strcpyrealloc(configDir, cPlugin::ConfigDirectory("vdrtva")); LoadLinksFile(); - + statusMonitor = new cTvaStatusMonitor; struct tm tm_r; char buff[32]; time_t now = time(NULL); @@ -197,6 +201,7 @@ void cPluginvdrTva::Housekeeping(void) { // Perform any cleanup or other regular tasks. if (nextactiontime < time(NULL)) { + statusMonitor->ClearTimerAdded(); // Ignore any timer changes while update is in progress switch (state) { case 0: StartDataCapture(); @@ -218,6 +223,11 @@ void cPluginvdrTva::Housekeeping(void) break; } } + else if (EventCRIDs && statusMonitor->GetTimerAddedDelta() > 60) { + Update(); + Check(); + statusMonitor->ClearTimerAdded(); + } } void cPluginvdrTva::MainThreadHook(void) @@ -247,13 +257,18 @@ cOsdObject *cPluginvdrTva::MainMenuAction(void) cMenuSetupPage *cPluginvdrTva::SetupMenu(void) { // Return a setup menu in case the plugin supports one. - return NULL; + return new cTvaMenuSetup; } bool cPluginvdrTva::SetupParse(const char *Name, const char *Value) { // Parse your own setup parameters and store their values. - return false; + if (!strcasecmp(Name, "CollectionPeriod")) collectionperiod = atoi(Value); + else if (!strcasecmp(Name, "SeriesLifetime")) seriesLifetime = atoi(Value); + else if (!strcasecmp(Name, "TimerLifetime")) lifetime = atoi(Value); + else if (!strcasecmp(Name, "TimerPriority")) priority = atoi(Value); + else return false; + return true; } bool cPluginvdrTva::Service(const char *Id, void *Data) @@ -683,6 +698,63 @@ void cPluginvdrTva::FindAlternatives(const cEvent *event) } +/* + cTvaStatusMonitor - callback for timer changes. +*/ + +cTvaStatusMonitor::cTvaStatusMonitor(void) +{ + timeradded = NULL; +} + +void cTvaStatusMonitor::TimerChange(const cTimer *Timer, eTimerChange Change) +{ + if (Change == tcAdd) timeradded = time(NULL); +} + +int cTvaStatusMonitor::GetTimerAddedDelta(void) +{ + if (timeradded) { + return (time(NULL) - timeradded); + } + return 0; +} + +void cTvaStatusMonitor::ClearTimerAdded(void) +{ + timeradded = NULL; + return; +} + + +/* + cTvaMenuSetup - setup menu function. +*/ + +cTvaMenuSetup::cTvaMenuSetup(void) +{ + newcollectionperiod = collectionperiod; + newlifetime = lifetime; + newpriority = priority; + newseriesLifetime = seriesLifetime; + newupdatehours = updatehours; + newupdatemins = updatemins; + Add(new cMenuEditIntItem(tr("Collection period (min)"), &newcollectionperiod)); + Add(new cMenuEditIntItem(tr("Series link lifetime (days)"), &newseriesLifetime)); + Add(new cMenuEditIntItem(tr("New timer lifetime"), &newlifetime)); + Add(new cMenuEditIntItem(tr("New timer priority"), &newpriority)); +} + +void cTvaMenuSetup::Store(void) +{ + SetupStore("CollectionPeriod", newcollectionperiod); + SetupStore("SeriesLifetime", newseriesLifetime); + SetupStore("TimerLifetime", newlifetime); + SetupStore("TimerPriority", newpriority); +} + + + /* cTvaFilter - capture the CRID data from EIT. */ diff --git a/plugin/vdrtva.h b/plugin/vdrtva.h index 785f846..4149b0c 100644 --- a/plugin/vdrtva.h +++ b/plugin/vdrtva.h @@ -1,5 +1,6 @@ #include #include +#include class cTvaFilter : public cFilter { private: @@ -11,6 +12,38 @@ public: cTvaFilter(void); }; +class cTvaStatusMonitor : public cStatus { + private: + time_t timeradded; + protected: + virtual void TimerChange(const cTimer *Timer, eTimerChange Change); + // Indicates a change in the timer settings. + // If Change is tcAdd or tcDel, Timer points to the timer that has + // been added or will be deleted, respectively. In case of tcMod, + // Timer is NULL; this indicates that some timer has been changed. + // Note that tcAdd and tcDel are always also followed by a tcMod. + public: + cTvaStatusMonitor(void); + int GetTimerAddedDelta(void); + void ClearTimerAdded(void); +}; + + +class cTvaMenuSetup : public cMenuSetupPage { +private: + int newcollectionperiod; + int newlifetime; + int newpriority; + int newseriesLifetime; + int newupdatehours; + int newupdatemins; +protected: + virtual void Store(void); +public: + cTvaMenuSetup(void); +}; + + class cChanDA : public cListObject { private: int cid; -- cgit v1.2.3