diff options
author | kamel5 <vdr.kamel5 (at) gmx (dot) net> | 2019-07-10 16:14:13 +0200 |
---|---|---|
committer | kamel5 <vdr.kamel5 (at) gmx (dot) net> | 2019-07-10 16:14:13 +0200 |
commit | 00036c92b1a6a5326d1f35f66a856f1b54514f69 (patch) | |
tree | b09816a25e281cf2660dbb0d49ff70483c0c1348 | |
parent | a0e63f5941a69d4a40d0399656171788da28a83c (diff) | |
download | vdr-plugin-tvguideng-00036c92b1a6a5326d1f35f66a856f1b54514f69.tar.gz vdr-plugin-tvguideng-00036c92b1a6a5326d1f35f66a856f1b54514f69.tar.bz2 |
Cosmetic changes
-rw-r--r-- | recmanager.c | 148 |
1 files changed, 65 insertions, 83 deletions
diff --git a/recmanager.c b/recmanager.c index 387ac31..2ef1d67 100644 --- a/recmanager.c +++ b/recmanager.c @@ -68,7 +68,7 @@ const cTimer *cRecManager::GetTimerForEvent(const cEvent *event) { pRemoteTimers->Service("RemoteTimers::GetMatch-v1.0", &rtMatch); timer = rtMatch.timer; return timer; - } + } #if defined (APIVERSNUM) && (APIVERSNUM >= 20301) LOCK_TIMERS_READ; @@ -76,7 +76,6 @@ const cTimer *cRecManager::GetTimerForEvent(const cEvent *event) { #else timer = Timers.GetMatch(event); #endif - return timer; } @@ -91,8 +90,7 @@ cTimer *cRecManager::createTimer(const cEvent *event, std::string path) { } cTimer *cRecManager::createLocalTimer(const cEvent *event, std::string path) { - cTimer *timer = new cTimer(event); - + cTimer *timer = new cTimer(event); #if defined (APIVERSNUM) && (APIVERSNUM >= 20301) if (Setup.SVDRPPeering && *Setup.SVDRPDefaultHost) ((cTimer*)timer)->SetRemote(Setup.SVDRPDefaultHost); @@ -101,15 +99,14 @@ cTimer *cRecManager::createLocalTimer(const cEvent *event, std::string path) { #else cTimers* timers = &Timers; #endif - cTimer* t = timers->GetTimer(timer); - if (t) { t->OnOff(); - - // #TODO ist das richtig? - t->SetEvent(event); // t->SetEventFromSchedule(); - +#if VDRVERSNUM >= 20301 + t->SetEvent(event); +#else + t->SetEventFromSchedule(); +#endif delete timer; timer = t; isyslog("timer %s reactivated", *t->ToDescr()); @@ -151,7 +148,7 @@ void cRecManager::SetTimerPath(cTimer *timer, const cEvent *event, std::string p std::string newFileName = epgSearch->handler->Evaluate(recDir, event); if (strchr(newFileName.c_str(), '%') == NULL) // only set directory to new value if all categories could have been replaced timer->SetFile(newFileName.c_str()); - else + else esyslog("tvguide: timer path not set because replacing variable was not successfull: %s", newFileName.c_str()); } } else { @@ -200,42 +197,40 @@ void cRecManager::DeleteTimer(const cEvent *event) { } void cRecManager::DeleteLocalTimer(const cEvent *event) { - const cTimer *t; + const cTimer *t; #if defined (APIVERSNUM) && (APIVERSNUM >= 20301) - { - LOCK_TIMERS_READ; - t = Timers->GetMatch(event); - } + { + LOCK_TIMERS_READ; + t = Timers->GetMatch(event); + } #else - t = Timers.GetMatch(event); + t = Timers.GetMatch(event); #endif - if (!t) return; DeleteTimer(t); } - void cRecManager::DeleteTimer(const cTimer *timer) { #if defined (APIVERSNUM) && (APIVERSNUM >= 20301) - LOCK_TIMERS_WRITE; - cTimers* timers = Timers; - cTimer* t = timers->GetTimer(timer); + LOCK_TIMERS_WRITE; + cTimers* timers = Timers; + cTimer* t = timers->GetTimer(timer); #else - cTimers* timers = &Timers; - cTimer* t = timers->GetTimer((cTimer*)timer); + cTimers* timers = &Timers; + cTimer* t = timers->GetTimer((cTimer*)timer); #endif - if (!t) - return; - if (t->Recording()) { - t->Skip(); + if (!t) + return; + if (t->Recording()) { + t->Skip(); #if defined (APIVERSNUM) && (APIVERSNUM >= 20301) - cRecordControls::Process(timers, time(NULL)); + cRecordControls::Process(timers, time(NULL)); #else - cRecordControls::Process(time(NULL)); + cRecordControls::Process(time(NULL)); #endif - } - isyslog("timer %s deleted", *timer->ToDescr()); + } + isyslog("timer %s deleted", *t->ToDescr()); timers->Del(t, true); timers->SetModified(); } @@ -246,7 +241,7 @@ void cRecManager::DeleteRemoteTimer(const cEvent *event) { pRemoteTimers->Service("RemoteTimers::GetMatch-v1.0", &rtMatch); if (rtMatch.timer) { RemoteTimers_Timer_v1_0 rt; - rt.timer = (cTimer*)rtMatch.timer; // #TODO - dirty cast + rt.timer = rtMatch.timer; isyslog("remotetimer %s deleted", *rt.timer->ToDescr()); if (!pRemoteTimers->Service("RemoteTimers::DelTimer-v1.0", &rt)) isyslog("remotetimer error"); @@ -257,7 +252,7 @@ void cRecManager::DeleteRemoteTimer(const cEvent *event) { void cRecManager::SaveTimer(const cTimer *t, cTimer newTimerSettings) { if (!t) return; - + #if VDRVERSNUM >= 20301 LOCK_TIMERS_WRITE; cTimer *timer = Timers->GetTimer(t); @@ -284,7 +279,7 @@ void cRecManager::SaveTimer(const cTimer *t, cTimer newTimerSettings) { timer->ClrFlags(tfActive); else if (!timer->HasFlags(tfActive) && active) timer->SetFlags(tfActive); - + #if VDRVERSNUM < 20300 timer->SetEventFromSchedule(); #endif @@ -300,7 +295,7 @@ void cRecManager::SaveTimer(const cTimer *t, cTimer newTimerSettings) { #else Timers.SetModified(); #endif - } + } } bool cRecManager::IsRecorded(const cEvent *event) { @@ -347,14 +342,13 @@ void cRecManager::CreateSeriesTimer(cTimer *seriesTimer) { RefreshRemoteTimers(); } else { #if defined (APIVERSNUM) && (APIVERSNUM >= 20301) - LOCK_TIMERS_WRITE; - cTimers* timers = Timers; + LOCK_TIMERS_WRITE; + cTimers* timers = Timers; #else - cTimers* timers = &Timers; + cTimers* timers = &Timers; #endif - - timers->Add(seriesTimer); - timers->SetModified(); + timers->Add(seriesTimer); + timers->SetModified(); } } @@ -401,15 +395,14 @@ const cEvent **cRecManager::PerformSearchTimerSearch(std::string epgSearchString numResults = results.size(); if (numResults > 0) { searchResults = new const cEvent *[numResults]; - + const cSchedules *schedules; #if defined (APIVERSNUM) && (APIVERSNUM >= 20301) LOCK_SCHEDULES_READ; - const cSchedules* schedules = Schedules; + schedules = Schedules; #else cSchedulesLock schedulesLock; - const cSchedules* schedules = (cSchedules*)cSchedules::Schedules(schedulesLock); + schedules = cSchedules::Schedules(schedulesLock); #endif - const cEvent *event = NULL; int index=0; for (std::list<std::string>::iterator it=results.begin(); it != results.end(); ++it) { @@ -433,7 +426,7 @@ const cEvent **cRecManager::PerformSearchTimerSearch(std::string epgSearchString Schedule = schedules->GetSchedule(channel); event = Schedule->GetEvent(eventID); if (event) { - searchResults[index] = event; + searchResults[index] = event; } else return NULL; } else @@ -534,17 +527,17 @@ void cRecManager::DeleteSearchTimer(cTVGuideSearchTimer *searchTimer, bool delTi return; int searchTimerID = searchTimer->GetID(); if (delTimers) { - cTimers* timers; + cTimers* timers; #if defined (APIVERSNUM) && (APIVERSNUM >= 20301) - { - LOCK_TIMERS_WRITE; - timers = Timers; - } + { + LOCK_TIMERS_WRITE; + timers = Timers; + } #else - timers = &Timers; + timers = &Timers; #endif - cTimer *timer = timers->First(); - while (timer) { + cTimer *timer = timers->First(); + while (timer) { if (!timer->Recording()) { char* searchID = GetAuxValue(timer, "s-id"); if (searchID) { @@ -572,7 +565,7 @@ void cRecManager::DeleteSearchTimer(cTVGuideSearchTimer *searchTimer, bool delTi } else { esyslog("tvguide: error deleting search timer \"%s\"", searchTimer->SearchString().c_str()); } - } + } } void cRecManager::UpdateSearchTimers(void) { @@ -614,7 +607,7 @@ void cRecManager::DeleteSwitchTimer(const cEvent *event) { } const cRecording **cRecManager::SearchForRecordings(std::string searchString, int &numResults) { - + const cRecording **matchingRecordings = NULL; int num = 0; numResults = 0; @@ -625,17 +618,17 @@ const cRecording **cRecManager::SearchForRecordings(std::string searchString, in #else const cRecordings* recordings = &Recordings; #endif - + for (const cRecording *recording = recordings->First(); recording; recording = recordings->Next(recording)) { std::string s1 = recording->Name(); std::string s2 = searchString; if (s1.empty() || s2.empty()) continue; - + // tolerance for fuzzy searching: 90% of the shorter text length, but at least 1 - int tolerance = std::max(1, (int)std::min(s1.size(), s2.size()) / 10); + int tolerance = std::max(1, (int)std::min(s1.size(), s2.size()) / 10); bool match = FindIgnoreCase(s1, s2) >= 0 || FindIgnoreCase(s2, s1) >= 0; - + if (!match) { AFUZZY af = { NULL, NULL, NULL, NULL, NULL, NULL, { 0 }, { 0 }, 0, 0, 0, 0, 0, 0 }; if (s1.size() > 32) s1 = s1.substr(0, 32); @@ -645,7 +638,7 @@ const cRecording **cRecManager::SearchForRecordings(std::string searchString, in afuzzy_free(&af); match = (res > 0); } - + if (!match) { AFUZZY af = { NULL, NULL, NULL, NULL, NULL, NULL, { 0 }, { 0 }, 0, 0, 0, 0, 0, 0 }; if (s2.size() > 32) s2 = s2.substr(0, 32); @@ -655,7 +648,7 @@ const cRecording **cRecManager::SearchForRecordings(std::string searchString, in afuzzy_free(&af); match = (res > 0); } - + if (match) { matchingRecordings = (const cRecording **)realloc(matchingRecordings, (num + 1) * sizeof(cRecording *)); matchingRecordings[num++] = recording; @@ -687,7 +680,7 @@ const cEvent **cRecManager::LoadReruns(const cEvent *event, int &numResults) { data.channelNr = 0; data.useTitle = true; data.useDescription = false; - + if (epgSearchPlugin->Service("Epgsearch-searchresults-v1.0", &data)) { cList<Epgsearch_searchresults_v1_0::cServiceSearchResult>* list = data.pResultList; if (!list) @@ -734,22 +727,16 @@ void cRecManager::GetFavorites(std::vector<cTVGuideSearchTimer> *favorites) { const cEvent **cRecManager::WhatsOnNow(bool nowOrNext, int &numResults) { std::vector<const cEvent*> tmpResults; - -#if defined (APIVERSNUM) && (APIVERSNUM >= 20301) - LOCK_CHANNELS_READ; - const cChannels* channels = Channels; -#else - cChannels* channels = &Channels; -#endif - #if defined (APIVERSNUM) && (APIVERSNUM >= 20301) + LOCK_CHANNELS_READ; + const cChannels* channels = Channels; LOCK_SCHEDULES_READ; const cSchedules* schedules = Schedules; #else + cChannels* channels = &Channels; cSchedulesLock schedulesLock; - const cSchedules* schedules = (cSchedules*)cSchedules::Schedules(schedulesLock); + const cSchedules* schedules = cSchedules::Schedules(schedulesLock); #endif - const cChannel *startChannel = NULL, *stopChannel = NULL; if (config.favLimitChannels) { startChannel = channels->GetByNumber(config.favStartChannel); @@ -777,7 +764,7 @@ const cEvent **cRecManager::WhatsOnNow(bool nowOrNext, int &numResults) { numResults = tmpResults.size(); const cEvent **results = new const cEvent *[numResults]; for (int i=0; i<numResults; i++) { - results[i] = tmpResults[i]; + results[i] = tmpResults[i]; } return results; @@ -811,18 +798,13 @@ const cEvent **cRecManager::UserDefinedTime(int userTime, int &numResults) { #if defined (APIVERSNUM) && (APIVERSNUM >= 20301) LOCK_CHANNELS_READ; const cChannels* channels = Channels; -#else - cChannels* channels = &Channels; -#endif - -#if defined (APIVERSNUM) && (APIVERSNUM >= 20301) LOCK_SCHEDULES_READ; const cSchedules* schedules = Schedules; #else + cChannels* channels = &Channels; cSchedulesLock schedulesLock; - const cSchedules* schedules = (cSchedules*)cSchedules::Schedules(schedulesLock); + const cSchedules* schedules = cSchedules::Schedules(schedulesLock); #endif - const cChannel *startChannel = NULL, *stopChannel = NULL; if (config.favLimitChannels) { startChannel = channels->GetByNumber(config.favStartChannel); @@ -850,7 +832,7 @@ const cEvent **cRecManager::UserDefinedTime(int userTime, int &numResults) { numResults = tmpResults.size(); const cEvent **results = new const cEvent *[numResults]; for (int i=0; i<numResults; i++) { - results[i] = tmpResults[i]; + results[i] = tmpResults[i]; } return results; } |