summaryrefslogtreecommitdiff
path: root/epgsearchext.c
diff options
context:
space:
mode:
authorFrank Neumann <fnu@yavdr.org>2017-05-01 11:02:21 +0200
committerFrank Neumann <fnu@yavdr.org>2017-05-01 11:02:21 +0200
commita46c7161bddc00b5b11bda0f8a14066b5f837302 (patch)
tree48e50b78f0efb1120b39bfb07f3612aabb1541e6 /epgsearchext.c
parent0b09f90f361454d1d422cc750ee84359f11bd378 (diff)
downloadvdr-plugin-epgsearch-a46c7161bddc00b5b11bda0f8a14066b5f837302.tar.gz
vdr-plugin-epgsearch-a46c7161bddc00b5b11bda0f8a14066b5f837302.tar.bz2
Add compatibility for VDR 2.3.2+ (thx kamel5, mini73 & TomJoad)
Diffstat (limited to 'epgsearchext.c')
-rw-r--r--epgsearchext.c101
1 files changed, 77 insertions, 24 deletions
diff --git a/epgsearchext.c b/epgsearchext.c
index 9d11c3b..9b793f6 100644
--- a/epgsearchext.c
+++ b/epgsearchext.c
@@ -58,8 +58,14 @@ cSearchExt::cSearchExt(void)
startTime = 0000;
stopTime = 2359;
useChannel = false;
- channelMin = Channels.GetByNumber(cDevice::CurrentChannel());
- channelMax = Channels.GetByNumber(cDevice::CurrentChannel());
+#if VDRVERSNUM > 20300
+ LOCK_CHANNELS_READ;
+ const cChannels *vdrchannels = Channels;
+#else
+ cChannels *vdrchannels = &Channels;
+#endif
+ channelMin = vdrchannels->GetByNumber(cDevice::CurrentChannel());
+ channelMax = vdrchannels->GetByNumber(cDevice::CurrentChannel());
channelGroup = NULL;
useCase = false;
mode = 0;
@@ -228,7 +234,7 @@ cSearchExt& cSearchExt::operator= (const cSearchExt &SearchExt)
recordingsKeep = templ->recordingsKeep;
blacklistMode = templ->blacklistMode;
blacklists.Clear();
- cBlacklistObject* blacklistObj = templ->blacklists.First();
+ const cBlacklistObject* blacklistObj = templ->blacklists.First();
while(blacklistObj)
{
blacklists.Add(new cBlacklistObject(blacklistObj->blacklist));
@@ -480,7 +486,13 @@ bool cSearchExt::Parse(const char *s)
char *channelMaxbuffer = NULL;
int channels = sscanf(value, "%m[^|]|%m[^|]", &channelMinbuffer, &channelMaxbuffer);
#endif
- channelMin = Channels.GetByChannelID(tChannelID::FromString(channelMinbuffer), true, true);
+#if VDRVERSNUM > 20300
+ LOCK_CHANNELS_READ;
+ const cChannels *vdrchannels = Channels;
+#else
+ cChannels *vdrchannels = &Channels;
+#endif
+ channelMin = vdrchannels->GetByChannelID(tChannelID::FromString(channelMinbuffer), true, true);
if (!channelMin)
{
LogFile.eSysLog("ERROR: channel '%s' not defined", channelMinbuffer);
@@ -492,7 +504,7 @@ bool cSearchExt::Parse(const char *s)
channelMax = channelMin;
else
{
- channelMax = Channels.GetByChannelID(tChannelID::FromString(channelMaxbuffer), true, true);
+ channelMax = vdrchannels->GetByChannelID(tChannelID::FromString(channelMaxbuffer), true, true);
if (!channelMax)
{
LogFile.eSysLog("ERROR: channel '%s' not defined", channelMaxbuffer);
@@ -858,12 +870,12 @@ bool cSearchExt::Save(FILE *f)
return fprintf(f, "%s\n", ToText()) > 0;
}
-cEvent * cSearchExt::GetEventBySearchExt(const cSchedule *schedules, const cEvent *Start, bool inspectTimerMargin)
+const cEvent * cSearchExt::GetEventBySearchExt(const cSchedule *schedules, const cEvent *Start, bool inspectTimerMargin)
{
if (!schedules) return NULL;
- cEvent *pe = NULL;
- cEvent *p1 = NULL;
+ const cEvent *pe = NULL;
+ const cEvent *p1 = NULL;
const cList<cEvent>* Events = schedules->Events();
if (Start)
@@ -893,7 +905,7 @@ cEvent * cSearchExt::GetEventBySearchExt(const cSchedule *schedules, const cEven
if (!useCase)
ToLower(searchText);
- for (cEvent *p = p1; p; p = Events->Next(p))
+ for (const cEvent *p = p1; p; p = Events->Next(p))
{
if(!p)
{
@@ -1011,9 +1023,14 @@ cSearchResults* cSearchExt::Run(int PayTVMode, bool inspectTimerMargin, int eval
{
LogFile.Log(3,"start search for search timer '%s'", search);
- cSchedulesLock schedulesLock;
const cSchedules *schedules;
+#if VDRVERSNUM > 20300
+ LOCK_SCHEDULES_READ;
+ schedules = Schedules;
+#else
+ cSchedulesLock schedulesLock;
schedules = cSchedules::Schedules(schedulesLock);
+#endif
if(!schedules) {
LogFile.Log(1,"schedules are currently locked! try again later.");
return NULL;
@@ -1031,8 +1048,14 @@ cSearchResults* cSearchExt::Run(int PayTVMode, bool inspectTimerMargin, int eval
cSearchResults* pBlacklistResults = GetBlacklistEvents(inspectTimerMargin?MarginStop:0);
int counter = 0;
+#if VDRVERSNUM > 20300
+ LOCK_CHANNELS_READ;
+ const cChannels *vdrchannels = Channels;
+#else
+ cChannels *vdrchannels = &Channels;
+#endif
while (Schedule) {
- cChannel* channel = Channels.GetByChannelID(Schedule->ChannelID(),true,true);
+ const cChannel* channel = vdrchannels->GetByChannelID(Schedule->ChannelID(),true,true);
if (!channel)
{
Schedule = (const cSchedule *)schedules->Next(Schedule);
@@ -1084,7 +1107,7 @@ cSearchResults* cSearchExt::Run(int PayTVMode, bool inspectTimerMargin, int eval
if (tNow + evalLimitMins*60 <= event->EndTime())
break;
}
- if (event && Channels.GetByChannelID(event->ChannelID(),true,true))
+ if (event && vdrchannels->GetByChannelID(event->ChannelID(),true,true))
{
if (pBlacklistResults && pBlacklistResults->Lookup(event))
{
@@ -1165,6 +1188,12 @@ void cSearchExt::CheckRepeatTimers(cSearchResults* pResults)
}
cSearchResult* pResultObj = NULL;
+#if VDRVERSNUM > 20300
+ LOCK_TIMERS_READ;
+ const cTimers* vdrtimers = Timers;
+#else
+ cTimers* vdrtimers = &Timers;
+#endif
for (pResultObj = pResults->First(); pResultObj; pResultObj = pResults->Next(pResultObj))
{
if (action != searchTimerActionRecord) // only announce if there is no timer for the event
@@ -1253,7 +1282,7 @@ void cSearchExt::CheckRepeatTimers(cSearchResults* pResults)
}
}
bool dummy;
- cTimer* timer = cSearchTimerThread::GetTimer(this, pEvent, dummy);
+ const cTimer* timer = cSearchTimerThread::GetTimer(vdrtimers, this, pEvent, dummy);
if (timer && !timer->HasFlags(tfActive))
{
LogFile.Log(3,"skip '%s~%s' (%s - %s, channel %d), existing timer disabled", pEvent->Title()?pEvent->Title():"no title", pEvent->ShortText()?pEvent->ShortText():"no subtitle", GETDATESTRING(pEvent), GETTIMESTRING(pEvent), ChannelNrFromEvent(pEvent));
@@ -1278,7 +1307,8 @@ void cSearchExt::CheckExistingRecordings(cSearchResults* pResults)
LogFile.Log(3,"analysing existing recordings for search timer '%s'...", search);
// how many recordings do we already have?
- int num = GetCountRecordings();
+ cRecordings *vdrrecordings = NULL;
+ int num = GetCountRecordings(vdrrecordings);
cSearchResult* pResultObj = NULL;
int remain = pauseOnNrRecordings - num;
@@ -1337,39 +1367,54 @@ bool cSearchExt::MatchesExtEPGInfo(const cEvent* e)
void cSearchExt::OnOffTimers(bool bOn)
{
- for (cTimer *ti = Timers.First(); ti; ti = Timers.Next(ti))
+#if VDRVERSNUM > 20300
+ LOCK_TIMERS_WRITE;
+ cTimers *vdrtimers = Timers;
+#else
+ cTimers *vdrtimers = &Timers;
+#endif
+ for (cTimer *ti = vdrtimers->First(); ti; ti = vdrtimers->Next(ti))
{
if (((!bOn && ti->HasFlags(tfActive)) || (bOn && !ti->HasFlags(tfActive))) && TriggeredFromSearchTimerID(ti) == ID)
ti->OnOff();
}
+#if VDRVERSNUM < 20300
Timers.SetModified();
+#endif
}
void cSearchExt::DeleteAllTimers()
{
cList<cTimerObj> DelTimers;
- cTimer *ti = Timers.First();
+#if VDRVERSNUM > 20300
+ LOCK_TIMERS_WRITE;
+ Timers->SetExplicitModify();
+ cTimers *vdrtimers = Timers;
+#else
+ cTimers *vdrtimers = &Timers;
+#endif
+ cTimer *ti = vdrtimers->First();
while(ti)
{
if (!ti->Recording() && TriggeredFromSearchTimerID(ti) == ID)
{
- cTimer* tiNext = Timers.Next(ti);
+ cTimer* tiNext = vdrtimers->Next(ti);
LogFile.iSysLog("deleting timer %s", *ti->ToDescr());
- Timers.Del(ti);
- Timers.SetModified();
+ vdrtimers->Del(ti);
+ vdrtimers->SetModified();
ti = tiNext;
}
else
- ti = Timers.Next(ti);
+ ti = vdrtimers->Next(ti);
};
}
-cTimerObjList* cSearchExt::GetTimerList(cTimerObjList* timerList)
+cTimerObjList* cSearchExt::GetTimerList(const cTimers* vdrtimers, cTimerObjList* timerList)
{
if (!timerList)
timerList = new cTimerObjList;
- for (cTimer *ti = Timers.First(); ti; ti = Timers.Next(ti))
+ for (const cTimer *ti = vdrtimers->First(); ti; ti = vdrtimers->Next(ti))
{
if (TriggeredFromSearchTimerID(ti) == ID)
{
@@ -1391,11 +1436,19 @@ cTimerObjList* cSearchExt::GetTimerList(cTimerObjList* timerList)
}
// counts the currently existent recordings triggered by this search timer
-int cSearchExt::GetCountRecordings()
+int cSearchExt::GetCountRecordings(cRecordings *vdrrecordings)
{
int countRecs = 0;
- for (cRecording *recording = Recordings.First(); recording; recording = Recordings.Next(recording))
+#if VDRVERSNUM > 20300
+ if (!vdrrecordings) {
+ LOCK_RECORDINGS_READ;
+ vdrrecordings = (cRecordings *)Recordings;
+ }
+#else
+ vdrrecordings = &Recordings;
+#endif
+ for (const cRecording *recording = vdrrecordings->First(); recording; recording = vdrrecordings->Next(recording))
{
if (recording->IsEdited()) continue; // ignore recordings edited
if (!recording->Info()) continue;