summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJochen Dolze <vdr@dolze.de>2017-03-13 18:44:47 +0100
committerJochen Dolze <vdr@dolze.de>2017-03-13 18:44:47 +0100
commit05bd94edbff42a5cc688b129706abeb1d31dba10 (patch)
tree4beeda1b823beffe4c82a9ed264e57ec5a7a64e7
parentb48e0bec3c87531c872da028d4fb87c65f3e050e (diff)
downloadvdr-plugin-xmltv2vdr-05bd94edbff42a5cc688b129706abeb1d31dba10.tar.gz
vdr-plugin-xmltv2vdr-05bd94edbff42a5cc688b129706abeb1d31dba10.tar.bz2
Added compatibility for VDR >= 2.3.1
-rw-r--r--import.cpp122
-rw-r--r--maps.cpp126
-rw-r--r--setup.cpp96
-rw-r--r--xmltv2vdr.cpp113
-rw-r--r--xmltv2vdr.h4
5 files changed, 334 insertions, 127 deletions
diff --git a/import.cpp b/import.cpp
index 4fcf6a3..d320bcf 100644
--- a/import.cpp
+++ b/import.cpp
@@ -103,7 +103,7 @@ cEvent *cImport::SearchVDREventByTitle(cEPGSource *source, cSchedule* schedule,
if (Duration && eventTimeDiff>=Duration) eventTimeDiff/=3;
if (eventTimeDiff<100) eventTimeDiff=100;
- for (cEvent *p = schedule->Events()->First(); p; p = schedule->Events()->Next(p))
+ for (cEvent *p =(cEvent *) schedule->Events()->First(); p; p = (cEvent *) schedule->Events()->Next(p))
{
int diff=abs((int) difftime(p->StartTime(),StartTime));
if (diff<=eventTimeDiff)
@@ -208,9 +208,9 @@ cEvent *cImport::GetEventBefore(cSchedule* schedule, time_t start)
if (!schedule) return NULL;
if (!schedule->Events()) return NULL;
if (!schedule->Events()->Count()) return NULL;
- cEvent *last=schedule->Events()->Last();
+ cEvent *last=(cEvent *) schedule->Events()->Last();
if ((last) && (last->StartTime()<start)) return last;
- for (cEvent *p=schedule->Events()->First(); p; p=schedule->Events()->Next(p))
+ for (cEvent *p=(cEvent *) schedule->Events()->First(); p; p=(cEvent *) schedule->Events()->Next(p))
{
if (p->StartTime()>start)
{
@@ -1734,12 +1734,12 @@ int cImport::Process(cEPGSource *Source, cEPGExecutor &myExecutor)
time_t endoneday=begin+86400;
#endif
+ const cSchedules *schedules=NULL;
+ int l=0;
+#if VDRVERSNUM<20301
Timers.IncBeingEdited(); // prevent Timers.DeleteExpired() to execute
-
cSchedulesLock *schedulesLock=NULL;
- const cSchedules *schedules=NULL;
- int l=0;
while (l<300)
{
if (schedulesLock) delete schedulesLock;
@@ -1755,14 +1755,39 @@ int cImport::Process(cEPGSource *Source, cEPGExecutor &myExecutor)
if (schedules) break;
l++;
}
+#else
+ cStateKey StateKey;
+ while (l<300)
+ {
+ schedules=cSchedules::GetSchedulesWrite(StateKey,200);
+ if (!myExecutor.StillRunning())
+ {
+ if (schedules) StateKey.Remove();
+ isyslogs(Source,"request to stop from vdr");
+ return 0;
+ }
+ if (schedules) break;
+ l++;
+ }
+#endif
+
+ if (!schedules)
+ {
+ esyslogs(Source,"failed to get schedules lock");
+ return 141;
+ }
dsyslogs(Source,"importing from db");
sqlite3 *db=NULL;
if (sqlite3_open_v2(g->EPGFile(),&db,SQLITE_OPEN_READWRITE,NULL)!=SQLITE_OK)
{
esyslogs(Source,"failed to open %s",g->EPGFile());
+#if VDRVERSNUM<20301
delete schedulesLock;
Timers.DecBeingEdited();
+#else
+ StateKey.Remove();
+#endif
return 141;
}
@@ -1775,8 +1800,12 @@ int cImport::Process(cEPGSource *Source, cEPGExecutor &myExecutor)
{
sqlite3_close(db);
esyslogs(Source,"out of memory");
+#if VDRVERSNUM<20301
delete schedulesLock;
Timers.DecBeingEdited();
+#else
+ StateKey.Remove();
+#endif
return 134;
}
@@ -1787,8 +1816,12 @@ int cImport::Process(cEPGSource *Source, cEPGExecutor &myExecutor)
esyslogs(Source,"%i %s (p)",ret,sqlite3_errmsg(db));
sqlite3_close(db);
free(sql);
+#if VDRVERSNUM<20301
delete schedulesLock;
Timers.DecBeingEdited();
+#else
+ StateKey.Remove();
+#endif
return 141;
}
free(sql);
@@ -1826,38 +1859,57 @@ int cImport::Process(cEPGSource *Source, cEPGExecutor &myExecutor)
bool addevents=false;
if ((flags & OPT_APPEND)==OPT_APPEND) addevents=true;
- cChannel *channel=Channels.GetByChannelID(tChannelID::FromString(xevent.ChannelID()));
- if (!channel)
+#if VDRVERSNUM>=20301
+ cStateKey StateKeyChan;
+ const cChannels *Channels=cChannels::GetChannelsRead(StateKeyChan);
+ if (Channels)
{
- if (lerr!=IMPORT_NOCHANNEL)
- esyslogs(Source,"channel %s not found in channels.conf",
- xevent.ChannelID());
- lerr=IMPORT_NOCHANNEL;
- if (lastChannelID)
+ const cChannel *channel=Channels->GetByChannelID(tChannelID::FromString(xevent.ChannelID()));
+#else
+
+ cChannel *channel=Channels.GetByChannelID(tChannelID::FromString(xevent.ChannelID()));
+#endif
+ if (!channel)
{
- free(lastChannelID);
- lastChannelID=NULL;
+ if (lerr!=IMPORT_NOCHANNEL)
+ esyslogs(Source,"channel %s not found in channels.conf",
+ xevent.ChannelID());
+ lerr=IMPORT_NOCHANNEL;
+ if (lastChannelID)
+ {
+ free(lastChannelID);
+ lastChannelID=NULL;
+ }
+#if VDRVERSNUM>=20301
+ StateKeyChan.Remove();
+#endif
+ continue;
}
- continue;
- }
- schedule = (cSchedule *) schedules->GetSchedule(channel,addevents);
- if (!schedule)
- {
- if (lerr!=IMPORT_NOSCHEDULE)
- esyslogs(Source,"cannot get schedule for channel %s%s",
- channel->Name(),addevents ? "" : " - try add option");
- lerr=IMPORT_NOSCHEDULE;
- if (lastChannelID)
+ schedule = (cSchedule *) schedules->GetSchedule(channel,addevents);
+ if (!schedule)
{
- free(lastChannelID);
- lastChannelID=NULL;
+ if (lerr!=IMPORT_NOSCHEDULE)
+ esyslogs(Source,"cannot get schedule for channel %s%s",
+ channel->Name(),addevents ? "" : " - try add option");
+ lerr=IMPORT_NOSCHEDULE;
+ if (lastChannelID)
+ {
+ free(lastChannelID);
+ lastChannelID=NULL;
+ }
+#if VDRVERSNUM>=20301
+ StateKeyChan.Remove();
+#endif
+ continue;
}
- continue;
+ if (lastChannelID) free(lastChannelID);
+ lastChannelID=strdup(xevent.ChannelID());
+ hint=0;
+#if VDRVERSNUM>=20301
+ StateKeyChan.Remove();
}
- if (lastChannelID) free(lastChannelID);
- lastChannelID=strdup(xevent.ChannelID());
- hint=0;
+#endif
}
cEvent *event=SearchVDREvent(Source, schedule, &xevent, addevents, hint);
@@ -1889,7 +1941,11 @@ int cImport::Process(cEPGSource *Source, cEPGExecutor &myExecutor)
#endif
if (PutEvent(Source, db, schedule, event, &xevent, flags))
{
+#if VDRVERSNUM>=20301
+ schedule->SetModified();
+#else
schedules->SetModified(schedule);
+#endif
cnt++;
}
}
@@ -1928,9 +1984,13 @@ int cImport::Process(cEPGSource *Source, cEPGExecutor &myExecutor)
sqlite3_finalize(stmt);
sqlite3_close(db);
+#if VDRVERSNUM<20301
delete schedulesLock;
Timers.SetEvents();
Timers.DecBeingEdited();
+#else
+ StateKey.Remove();
+#endif
return 0;
}
diff --git a/maps.cpp b/maps.cpp
index a21b0b8..065e805 100644
--- a/maps.cpp
+++ b/maps.cpp
@@ -182,20 +182,40 @@ int cEPGMapping::compare(const void *a, const void *b)
{
num1=INT_MAX;
}
- else
- {
- cChannel *c1=Channels.GetByChannelID(*v1);
- if (c1) num1=c1->Number();
- }
if (*v2==tChannelID::InvalidID)
{
num2=INT_MAX;
}
- else
+
+#if VDRVERSNUM>=20301
+ cStateKey StateKeyChan;
+ const cChannels *Channels=cChannels::GetChannelsRead(StateKeyChan);
+ if (Channels)
{
- cChannel *c2=Channels.GetByChannelID(*v2);
- if (c2) num2=c2->Number();
+#endif
+
+ if (!num1)
+ {
+#if VDRVERSNUM>=20301
+ const cChannel *c1=Channels->GetByChannelID(*v1);
+#else
+ cChannel *c1=Channels.GetByChannelID(*v1);
+#endif
+ if (c1) num1=c1->Number();
+ }
+ if (!num2)
+ {
+#if VDRVERSNUM>=20301
+ const cChannel *c2=Channels->GetByChannelID(*v2);
+#else
+ cChannel *c2=Channels.GetByChannelID(*v2);
+#endif
+ if (c2) num2=c2->Number();
+ }
+#if VDRVERSNUM>=20301
+ StateKeyChan.Remove();
}
+#endif
if (num1>num2) return 1;
else return -1;
}
@@ -230,30 +250,42 @@ void cEPGMapping::addchannels(const char *channels)
void cEPGMapping::AddChannel(int ChannelNumber)
{
- cChannel *chan=Channels.GetByNumber(ChannelNumber);
- if (chan)
+#if VDRVERSNUM>=20301
+ cStateKey StateKeyChan;
+ const cChannels *Channels=cChannels::GetChannelsRead(StateKeyChan);
+ if (Channels)
{
- bool found=false;
- for (int i=0; i<numchannelids; i++)
+ const cChannel *chan=Channels->GetByNumber(ChannelNumber);
+#else
+ cChannel *chan=Channels.GetByNumber(ChannelNumber);
+#endif
+ if (chan)
{
- if (channelids[i]==chan->GetChannelID())
+ bool found=false;
+ for (int i=0; i<numchannelids; i++)
{
- found=true;
- break;
+ if (channelids[i]==chan->GetChannelID())
+ {
+ found=true;
+ break;
+ }
}
- }
- if (!found)
- {
- tChannelID *tmp_channelids=static_cast<tChannelID *>(realloc(channelids,(numchannelids+1)*sizeof(struct tChannelID)));
- if (tmp_channelids)
+ if (!found)
{
- channelids=tmp_channelids;
- channelids[numchannelids]=chan->GetChannelID();
- numchannelids++;
- qsort(channelids,numchannelids,sizeof(tChannelID),compare);
+ tChannelID *tmp_channelids=static_cast<tChannelID *>(realloc(channelids,(numchannelids+1)*sizeof(struct tChannelID)));
+ if (tmp_channelids)
+ {
+ channelids=tmp_channelids;
+ channelids[numchannelids]=chan->GetChannelID();
+ numchannelids++;
+ qsort(channelids,numchannelids,sizeof(tChannelID),compare);
+ }
}
}
+#if VDRVERSNUM>=20301
+ StateKeyChan.Remove();
}
+#endif
}
void cEPGMapping::ReplaceChannels(int NumChannelIDs, tChannelID *ChannelIDs)
@@ -316,26 +348,42 @@ void cEPGMapping::RemoveChannel(tChannelID ChannelID, bool MarkOnly)
void cEPGMapping::RemoveChannel(int ChannelNumber, bool MarkOnly)
{
if (!ChannelNumber) return;
+#if VDRVERSNUM>=20301
+ cStateKey StateKeyChan;
+ const cChannels *Channels=cChannels::GetChannelsRead(StateKeyChan);
+ if (Channels)
+ {
+ const cChannel *chan=Channels->GetByNumber(ChannelNumber);
+ if (!chan)
+ {
+ StateKeyChan.Remove();
+ return;
+ }
+#else
cChannel *chan=Channels.GetByNumber(ChannelNumber);
if (!chan) return;
-
- bool found=false;
- int i;
- for (i=0; i<numchannelids; i++)
- {
- if (channelids[i]==chan->GetChannelID())
+#endif
+ bool found=false;
+ int i;
+ for (i=0; i<numchannelids; i++)
{
- found=true;
- break;
+ if (channelids[i]==chan->GetChannelID())
+ {
+ found=true;
+ break;
+ }
}
- }
- if (found)
- {
- channelids[i]=tChannelID::InvalidID;
- if (!MarkOnly)
+ if (found)
{
- qsort(channelids,numchannelids,sizeof(tChannelID),compare);
- numchannelids--;
+ channelids[i]=tChannelID::InvalidID;
+ if (!MarkOnly)
+ {
+ qsort(channelids,numchannelids,sizeof(tChannelID),compare);
+ numchannelids--;
+ }
}
+#if VDRVERSNUM>=20301
+ StateKeyChan.Remove();
}
+#endif
}
diff --git a/setup.cpp b/setup.cpp
index 4038c8c..b64c8c0 100644
--- a/setup.cpp
+++ b/setup.cpp
@@ -11,7 +11,11 @@
#include <vdr/i18n.h>
#include <time.h>
+#if VDRVERSNUM>=20301
+#define CHNUMWIDTH (numdigits(cChannels::MaxNumber())+1)
+#else
#define CHNUMWIDTH (numdigits(Channels.MaxNumber())+1)
+#endif
#define NewTitle(x) new cOsdItem(cString::sprintf("%s%s%s", "---- ",x," ----"),osUnknown,false)
@@ -149,16 +153,28 @@ void cMenuSetupXmltv2vdr::Output(void)
{
for (int x=0; x<map->NumChannelIDs(); x++)
{
- cChannel *chan=Channels.GetByChannelID(map->ChannelIDs()[x]);
- if (chan)
- {
- mapped=true;
- }
- else
+#if VDRVERSNUM>=20301
+ cStateKey StateKeyChan;
+ const cChannels *Channels=cChannels::GetChannelsRead(StateKeyChan);
+ if (Channels)
{
- // invalid channelid? remove from list
- map->RemoveChannel(map->ChannelIDs()[x],true);
+ const cChannel *chan=Channels->GetByChannelID(map->ChannelIDs()[x]);
+#else
+ cChannel *chan=Channels.GetByChannelID(map->ChannelIDs()[x]);
+#endif
+ if (chan)
+ {
+ mapped=true;
+ }
+ else
+ {
+ // invalid channelid? remove from list
+ map->RemoveChannel(map->ChannelIDs()[x],true);
+ }
+#if VDRVERSNUM>=20301
+ StateKeyChan.Remove();
}
+#endif
}
}
cString buffer = cString::sprintf("%s:\t%s",channels[i],mapped ? tr("mapped") : "");
@@ -1126,19 +1142,31 @@ void cMenuSetupXmltv2vdrChannelMap::output(void)
Add(NewTitle(tr("epg source channel mappings")),true);
for (int i=0; i<lmap->NumChannelIDs(); i++)
{
- cChannel *chan=Channels.GetByChannelID(lmap->ChannelIDs()[i]);
- if (chan)
+#if VDRVERSNUM>=20301
+ cStateKey StateKeyChan;
+ const cChannels *Channels=cChannels::GetChannelsRead(StateKeyChan);
+ if (Channels)
{
- cString buffer = cString::sprintf("%-*i %s", CHNUMWIDTH, chan->Number(),chan->Name());
- Add(new cOsdItem(buffer),true);
- if (!hasmaps) cm=Current();
- hasmaps=true;
- }
- else
- {
- // invalid channelid? remove from list
- lmap->RemoveChannel(lmap->ChannelIDs()[i],true);
+ const cChannel *chan=Channels->GetByChannelID(lmap->ChannelIDs()[i]);
+#else
+ cChannel *chan=Channels.GetByChannelID(lmap->ChannelIDs()[i]);
+#endif
+ if (chan)
+ {
+ cString buffer = cString::sprintf("%-*i %s", CHNUMWIDTH, chan->Number(),chan->Name());
+ Add(new cOsdItem(buffer),true);
+ if (!hasmaps) cm=Current();
+ hasmaps=true;
+ }
+ else
+ {
+ // invalid channelid? remove from list
+ lmap->RemoveChannel(lmap->ChannelIDs()[i],true);
+ }
+#if VDRVERSNUM>=20301
+ StateKeyChan.Remove();
}
+#endif
}
lmap->RemoveInvalidChannels();
if (!hasmaps)
@@ -1338,21 +1366,33 @@ cMenuSetupXmltv2vdrChannelsVDR::cMenuSetupXmltv2vdrChannelsVDR(cGlobals *Global,
SetHelp(NULL,NULL,tr("Button$Choose"));
SetTitle(Title);
- for (cChannel *channel = Channels.First(); channel; channel=Channels.Next(channel))
+#if VDRVERSNUM>=20301
+ cStateKey StateKeyChan;
+ const cChannels *Channels=cChannels::GetChannelsRead(StateKeyChan);
+ if (Channels)
{
- if (!channel->GroupSep())
+ for (const cChannel *channel=Channels->First(); channel; channel=Channels->Next(channel))
+#else
+ for (cChannel *channel = Channels.First(); channel; channel=Channels.Next(channel))
+#endif
{
- cString buf= cString::sprintf("%d\t%s",channel->Number(),channel->Name());
- if ((epgmappingexists(channel->GetChannelID(),Channel)) || (map->EPGMappingExists(channel->GetChannelID())))
+ if (!channel->GroupSep())
{
- Add(new cOsdItem(buf,osUnknown,false));
- }
- else
- {
- Add(new cOsdItem(buf));
+ cString buf= cString::sprintf("%d\t%s",channel->Number(),channel->Name());
+ if ((epgmappingexists(channel->GetChannelID(),Channel)) || (map->EPGMappingExists(channel->GetChannelID())))
+ {
+ Add(new cOsdItem(buf,osUnknown,false));
+ }
+ else
+ {
+ Add(new cOsdItem(buf));
+ }
}
}
+#if VDRVERSNUM>=20301
+ StateKeyChan.Remove();
}
+#endif
}
bool cMenuSetupXmltv2vdrChannelsVDR::epgmappingexists(tChannelID channelid, const char *channel2ignore)
diff --git a/xmltv2vdr.cpp b/xmltv2vdr.cpp
index 893c465..1b810ff 100644
--- a/xmltv2vdr.cpp
+++ b/xmltv2vdr.cpp
@@ -596,10 +596,10 @@ bool cEPGHandler::IgnoreChannel(const cChannel* Channel)
return maps->IgnoreChannel(Channel);
}
-bool cEPGHandler::check4proc(cEvent *event, cTimer **timer, cEPGMapping **map)
+bool cEPGHandler::check4proc(cEvent *event, char **timerdescr, cEPGMapping **map)
{
if (map) *map=NULL;
- if (timer) *timer=NULL;
+ if (timerdescr) *timerdescr=NULL;
if (!event) return false;
if (now>(event->StartTime()+event->Duration())) return false; // event in the past?
if (!maps) return false;
@@ -610,19 +610,29 @@ bool cEPGHandler::check4proc(cEvent *event, cTimer **timer, cEPGMapping **map)
{
if (!epall) return false;
if (!event->ShortText()) return false;
- if (!timer) return false;
+ if (!timerdescr) return false;
#if VDRVERSNUM <= 10732
int TimerMatch = tmNone;
#else
eTimerMatch TimerMatch = tmNone;
#endif
- *timer=Timers.GetMatch(event,&TimerMatch);
- if (!*timer) return false;
- if (TimerMatch!=tmFull)
+
+#if VDRVERSNUM>=20301
+ cStateKey StateKey;
+ if (const cTimers *Timers=cTimers::GetTimersRead(StateKey))
{
- *timer=NULL;
- return false;
+ const cTimer *Timer=Timers->GetMatch(event,&TimerMatch);
+ if ((Timer) && (TimerMatch==tmFull))
+ {
+ *timerdescr=strdup(Timer->ToDescr());
+ }
+ StateKey.Remove();
}
+#else
+ cTimer *timer=Timers.GetMatch(event,&TimerMatch);
+ if ((!timer) || (TimerMatch!=tmFull)) return false;
+ *timerdescr=strdup(timer->ToDescr());
+#endif
}
if (map) *map=t_map;
return true;
@@ -649,45 +659,70 @@ bool cEPGHandler::SetShortText(cEvent* Event, const char* ShortText)
bool cEPGHandler::SetDescription(cEvent* Event, const char* Description)
{
- cTimer *timer;
- if (!check4proc(Event,&timer,NULL)) return false;
+ //cTimer *timer;
+ char *timerdescr;
+ if (!check4proc(Event,&timerdescr,NULL))
+ {
+ if (timerdescr) free(timerdescr);
+ return false;
+ }
if (import.WasChanged(Event))
{
// ok we already changed this event!
- if (!Description) return true; // prevent setting nothing to description
+ if (!Description)
+ {
+ if (timerdescr) free(timerdescr);
+ return true; // prevent setting nothing to description
+ }
int len=strlen(Description);
- if (!len) return true; // prevent setting nothing to description
+ if (!len)
+ {
+ if (timerdescr) free(timerdescr);
+ return true; // prevent setting nothing to description
+ }
if (!strcasestr(Event->Description(),Description))
{
// eit description changed -> set it
- tsyslog("{%5i} %schanging descr of '%s'",Event->EventID(),timer ? "*" : "",
+ tsyslog("{%5i} %schanging descr of '%s'",Event->EventID(),timerdescr ? "*" : "",
Event->Title());
+ if (timerdescr) free(timerdescr);
return false;
}
#ifdef VDRDEBUG
- tsyslog("{%5i} %salready seen descr '%s'",Event->EventID(),timer ? "*" : "",
+ tsyslog("{%5i} %salready seen descr '%s'",Event->EventID(),timerdescr ? "*" : "",
Event->Title());
#endif
+ if (timerdescr) free(timerdescr);
return true;
}
- tsyslog("{%5i} %ssetting descr of '%s'",Event->EventID(),timer ? "*" : "",
+ tsyslog("{%5i} %ssetting descr of '%s'",Event->EventID(),timerdescr ? "*" : "",
Event->Title());
+ if (timerdescr) free(timerdescr);
return false;
}
bool cEPGHandler::HandleEvent(cEvent* Event)
{
- cTimer *timer;
+ //cTimer *timer;
+ char *timerdescr;
cEPGMapping *map;
- if (!check4proc(Event,&timer,&map)) return false;
+ if (!check4proc(Event,&timerdescr,&map))
+ {
+ if (timerdescr) free(timerdescr);
+ return false;
+ }
int Flags=0;
const char *ChannelID=strdup(*Event->ChannelID().ToString());
- if (!ChannelID) return false;
+ if (!ChannelID)
+ {
+ if (timerdescr) free(timerdescr);
+ return false;
+ }
- if (timer)
+ if (timerdescr)
{
Flags=USE_SEASON;
}
@@ -704,16 +739,19 @@ bool cEPGHandler::HandleEvent(cEvent* Event)
if (!epall)
{
free((void*)ChannelID);
+ if (timerdescr) free(timerdescr);
return false;
}
- if (!timer)
+ if (!timerdescr)
{
free((void*)ChannelID);
+ if (timerdescr) free(timerdescr);
return false;
}
if (db && sqlite3_errcode(db)!=SQLITE_OK)
{
free((void*)ChannelID);
+ if (timerdescr) free(timerdescr);
return false;
}
@@ -726,11 +764,12 @@ bool cEPGHandler::HandleEvent(cEvent* Event)
if (!xevent)
{
free((void*)ChannelID);
+ if (timerdescr) free(timerdescr);
return false;
}
else
{
- tsyslog("{%5i} *adding '%s'/'%s' (%s)",Event->EventID(),xevent->Title(),xevent->ShortText(),*timer->ToDescr());
+ tsyslog("{%5i} *adding '%s'/'%s' (%s)",Event->EventID(),xevent->Title(),xevent->ShortText(),timerdescr);
}
}
else
@@ -738,6 +777,7 @@ bool cEPGHandler::HandleEvent(cEvent* Event)
source=sources->GetSource(xevent->Source());
}
free((void*)ChannelID);
+ if (timerdescr) free(timerdescr);
if (!source)
{
tsyslog("no source for %s",xevent->Source());
@@ -813,19 +853,29 @@ void cEPGTimer::Action()
{
if (!import.DBExists()) return; // no database? -> exit immediately
+#if VDRVERSNUM<20301
cSchedulesLock schedulesLock(true,10); // wait 10ms for lock!
const cSchedules *schedules = cSchedules::Schedules(schedulesLock);
if (!schedules) return;
if (Timers.BeingEdited()) return;
Timers.IncBeingEdited();
+#endif
sqlite3 *db=NULL;
cEPGSource *source=sources->GetSource(EITSOURCE);
bool useeptext=((epall & EPLIST_USE_STEXTITLE)==EPLIST_USE_STEXTITLE);
int Flags=USE_SEASON;
if (useeptext) Flags|=(USE_SHORTTEXT|OPT_SEASON_STEXTITLE);
+
+#if VDRVERSNUM<20301
for (cTimer *Timer = Timers.First(); Timer; Timer = Timers.Next(Timer))
+#else
+ cStateKey StateKey;
+ if (const cTimers *Timers=cTimers::GetTimersRead(StateKey))
+ {
+ for (const cTimer *Timer=Timers->First(); Timer; Timer=Timers->Next(Timer))
+#endif
{
if (Timer->Recording()) continue; // to late ;)
cEvent *event=(cEvent *) Timer->Event();
@@ -873,12 +923,19 @@ void cEPGTimer::Action()
import.PutEvent(source,db,NULL,event,xevent,Flags);
delete xevent;
}
- if (db)
- {
- import.Commit(source,db);
- sqlite3_close(db);
- }
- Timers.DecBeingEdited();
+#if VDRVERSNUM>=20301
+ StateKey.Remove();
+}
+#endif
+if (db)
+{
+ import.Commit(source,db);
+ sqlite3_close(db);
+}
+
+#if VDRVERSNUM<20301
+Timers.DecBeingEdited();
+#endif
}
// -------------------------------------------------------------
@@ -969,9 +1026,11 @@ void cHouseKeeping::Action()
if (!global->DBExists()) return;
+#if APIVERSNUM<20301
cSchedulesLock schedulesLock(true,10); // wait 10ms for lock!
const cSchedules *schedules = cSchedules::Schedules(schedulesLock);
if (!schedules) return;
+#endif
sqlite3 *db=NULL;
if (sqlite3_open_v2(global->EPGFile(),&db,SQLITE_OPEN_READWRITE,NULL)==SQLITE_OK)
diff --git a/xmltv2vdr.h b/xmltv2vdr.h
index 2818089..fc474e1 100644
--- a/xmltv2vdr.h
+++ b/xmltv2vdr.h
@@ -21,7 +21,7 @@
#define UNUSED(x) x
#endif
-static const char *VERSION = "0.2.0pre";
+static const char *VERSION = "0.2.1";
static const char *DESCRIPTION = trNOOP("Imports xmltv epg into vdr");
int ioprio_set(int which, int who, int ioprio);
@@ -117,7 +117,7 @@ private:
int epall;
sqlite3 *db;
time_t now;
- bool check4proc(cEvent *event, cTimer **timer, cEPGMapping **map);
+ bool check4proc(cEvent *event, char **timerdescr, cEPGMapping **map);
public:
cEPGHandler(cGlobals *Global);
void SetEPAll(int Value)