diff options
author | kamel5 <vdr.kamel5 (at) gmx (dot) net> | 2020-07-15 17:03:38 +0200 |
---|---|---|
committer | kamel5 <vdr.kamel5 (at) gmx (dot) net> | 2020-07-15 17:38:01 +0200 |
commit | 0400ff1b029baee8900e465712903b5ddf6c5f07 (patch) | |
tree | 9b77c798904b21949c9469799b917b4ff0257788 /recmanager.c | |
parent | a1619348198d1b485aaebc91176403c15dbec47d (diff) | |
download | vdr-plugin-tvguideng-0400ff1b029baee8900e465712903b5ddf6c5f07.tar.gz vdr-plugin-tvguideng-0400ff1b029baee8900e465712903b5ddf6c5f07.tar.bz2 |
Fixed a remote timer problem
Diffstat (limited to 'recmanager.c')
-rw-r--r-- | recmanager.c | 112 |
1 files changed, 76 insertions, 36 deletions
diff --git a/recmanager.c b/recmanager.c index 2ef1d67..9465176 100644 --- a/recmanager.c +++ b/recmanager.c @@ -6,6 +6,10 @@ #include <algorithm> #include <vdr/menu.h> +#include "services/remotetimers.h" +#include "helpers.h" +#include "switchtimer.h" +#include "timerconflict.h" #include <vdr/timers.h> #include "recmanager.h" @@ -39,7 +43,7 @@ bool cRecManager::RefreshRemoteTimers(void) { bool cRecManager::CheckEventForTimer(const cEvent *event) { bool hasTimer = false; - + if (config.useRemoteTimers && pRemoteTimers) { RemoteTimers_GetMatch_v1_0 rtMatch; rtMatch.event = event; @@ -47,7 +51,7 @@ bool cRecManager::CheckEventForTimer(const cEvent *event) { if (rtMatch.timerMatch == tmFull) hasTimer = true; } else { -#if VDRVERSNUM >= 20301 +#if defined (APIVERSNUM) && (APIVERSNUM >= 20301) eTimerMatch TimerMatch = tmNone; LOCK_TIMERS_READ; const cTimers *timers = Timers; @@ -92,17 +96,18 @@ cTimer *cRecManager::createTimer(const cEvent *event, std::string path) { cTimer *cRecManager::createLocalTimer(const cEvent *event, std::string path) { cTimer *timer = new cTimer(event); #if defined (APIVERSNUM) && (APIVERSNUM >= 20301) - if (Setup.SVDRPPeering && *Setup.SVDRPDefaultHost) - ((cTimer*)timer)->SetRemote(Setup.SVDRPDefaultHost); LOCK_TIMERS_WRITE; cTimers* timers = Timers; + timers->SetExplicitModify(); + if (Setup.SVDRPPeering && *Setup.SVDRPDefaultHost) + timer->SetRemote(Setup.SVDRPDefaultHost); #else cTimers* timers = &Timers; #endif - cTimer* t = timers->GetTimer(timer); + cTimer *t = timers->GetTimer(timer); if (t) { t->OnOff(); -#if VDRVERSNUM >= 20301 +#if defined (APIVERSNUM) && (APIVERSNUM >= 20301) t->SetEvent(event); #else t->SetEventFromSchedule(); @@ -111,12 +116,21 @@ cTimer *cRecManager::createLocalTimer(const cEvent *event, std::string path) { timer = t; isyslog("timer %s reactivated", *t->ToDescr()); } else { + SetTimerPath(timer, event, path); timers->Add(timer); + timers->SetModified(); +#if defined (APIVERSNUM) && (APIVERSNUM >= 20301) + if (!HandleRemoteTimerModifications(timer)) { + timers->Del(timer); + esyslog(tr("tvguide: RemoteTimerModifications failed")); + } else { + isyslog("timer %s added (active)", *timer->ToDescr()); + } +#else isyslog("timer %s added (active)", *timer->ToDescr()); +#endif } - SetTimerPath(timer, event, path); - timers->SetModified(); - return timer; + return timers->GetTimer(timer); } cTimer *cRecManager::createRemoteTimer(const cEvent *event, std::string path) { @@ -161,12 +175,25 @@ void cRecManager::SetTimerPath(cTimer *timer, const cEvent *event, std::string p return; } //Set choosen path + bool addSubtitle = false; + if (!isempty(event->ShortText())) { // add subtitle if present + addSubtitle = (config.addSubtitleToTimer != addSubtitleNever); + if (config.addSubtitleToTimer == addSubtitleSmart) + if (event->Duration() > 80 * 60) + addSubtitle = false; + } cString newFileName; if (path.size() > 0) { std::replace(path.begin(), path.end(), '/', '~'); - newFileName = cString::sprintf("%s~%s", path.c_str(), timer->File()); + if (addSubtitle) + newFileName = cString::sprintf("%s~%s~%s", path.c_str(), event->Title(), event->ShortText()); + else + newFileName = cString::sprintf("%s~%s", path.c_str(), timer->File()); } else { - newFileName = event->Title(); + if (addSubtitle) + newFileName = cString::sprintf("%s~%s", event->Title(), event->ShortText()); + else + newFileName = event->Title(); } timer->SetFile(*newFileName); } @@ -215,6 +242,12 @@ void cRecManager::DeleteTimer(const cTimer *timer) { #if defined (APIVERSNUM) && (APIVERSNUM >= 20301) LOCK_TIMERS_WRITE; cTimers* timers = Timers; + if (timer && timer->Remote() && !timer->Recording()) { + if (HandleRemoteTimerModifications(NULL, (cTimer*)timer)) { + timers->Del((cTimer*)timer); + } + timers->SetModified(); + } cTimer* t = timers->GetTimer(timer); #else cTimers* timers = &Timers; @@ -249,24 +282,34 @@ void cRecManager::DeleteRemoteTimer(const cEvent *event) { } } -void cRecManager::SaveTimer(const cTimer *t, cTimer newTimerSettings) { +void cRecManager::SaveTimer(const cTimer *t, cTimer *newTimerSettings) { if (!t) return; -#if VDRVERSNUM >= 20301 +#if defined (APIVERSNUM) && (APIVERSNUM >= 20301) LOCK_TIMERS_WRITE; - cTimer *timer = Timers->GetTimer(t); + cTimers* timers = Timers; + timers->SetExplicitModify(); + if (t && t->Remote()) { + if (!HandleRemoteTimerModifications(newTimerSettings, (cTimer *)t)) { + esyslog(tr("tvguide: RemoteTimerModifications failed")); + } + } + cTimer *timer = timers->GetTimer(t); #else - cTimer *timer = Timers.GetTimer((cTimer*)t); + cTimers* timers = &Timers; + cTimer *timer = timers->GetTimer((cTimer *)t); #endif - - bool active = newTimerSettings.HasFlags(tfActive); - int prio = newTimerSettings.Priority(); - int lifetime = newTimerSettings.Lifetime(); - time_t day = newTimerSettings.Day(); - int start = newTimerSettings.Start(); - int stop = newTimerSettings.Stop(); - std::string fileName = newTimerSettings.File(); + if (!timer) { + return; + } + bool active = newTimerSettings->HasFlags(tfActive); + int prio = newTimerSettings->Priority(); + int lifetime = newTimerSettings->Lifetime(); + time_t day = newTimerSettings->Day(); + int start = newTimerSettings->Start(); + int stop = newTimerSettings->Stop(); + std::string fileName = newTimerSettings->File(); timer->SetDay(day); timer->SetStart(start); @@ -275,10 +318,10 @@ void cRecManager::SaveTimer(const cTimer *t, cTimer newTimerSettings) { timer->SetLifetime(lifetime); timer->SetFile(fileName.c_str()); - if (timer->HasFlags(tfActive) && !active) - timer->ClrFlags(tfActive); - else if (!timer->HasFlags(tfActive) && active) - timer->SetFlags(tfActive); + if (active) + timer->SetFlags(tfActive); + else + timer->ClrFlags(tfActive); #if VDRVERSNUM < 20300 timer->SetEventFromSchedule(); @@ -290,22 +333,17 @@ void cRecManager::SaveTimer(const cTimer *t, cTimer newTimerSettings) { rt.timer = NULL; RefreshRemoteTimers(); } else { -#if defined (APIVERSNUM) && (APIVERSNUM >= 20301) - Timers->SetModified(); -#else - Timers.SetModified(); -#endif + timers->SetModified(); } } bool cRecManager::IsRecorded(const cEvent *event) { #if defined (APIVERSNUM) && (APIVERSNUM >= 20301) - LOCK_TIMERS_WRITE; - cTimers* timers = Timers; + LOCK_TIMERS_WRITE; + cTimer *timer = Timers->GetMatch(event); #else - cTimers* timers = &Timers; + cTimer *timer = Timers.GetMatch(event); #endif - cTimer *timer = timers->GetMatch(event); if (!timer) return false; return timer->Recording(); @@ -397,8 +435,10 @@ const cEvent **cRecManager::PerformSearchTimerSearch(std::string epgSearchString searchResults = new const cEvent *[numResults]; const cSchedules *schedules; #if defined (APIVERSNUM) && (APIVERSNUM >= 20301) + { LOCK_SCHEDULES_READ; schedules = Schedules; + } #else cSchedulesLock schedulesLock; schedules = cSchedules::Schedules(schedulesLock); |