diff options
author | Jochen Dolze <vdr@dolze.de> | 2011-01-22 20:45:06 +0100 |
---|---|---|
committer | Jochen Dolze <vdr@dolze.de> | 2011-01-22 20:45:06 +0100 |
commit | ba419b0b9694ba59869cbdf47d46d1b0a28e5c84 (patch) | |
tree | ea49e89eb8b16a0e18b3fcef179b8d1628465e1b | |
parent | a22fb8f9b2bef75dc5723cea2604f04133036076 (diff) | |
download | vdr-plugin-xmltv2vdr-ba419b0b9694ba59869cbdf47d46d1b0a28e5c84.tar.gz vdr-plugin-xmltv2vdr-ba419b0b9694ba59869cbdf47d46d1b0a28e5c84.tar.bz2 |
Added new option update on start
Removed -pedantic from Makefile
Fixed some minor bugs (missing EOL in file, etc. pp.)
Removed cEPGExecute and introduced cEPGExecutor
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | extpipe.h | 3 | ||||
-rw-r--r-- | po/de_DE.po | 5 | ||||
-rw-r--r-- | setup.cpp | 8 | ||||
-rw-r--r-- | setup.h | 1 | ||||
-rw-r--r-- | xmltv2vdr.cpp | 114 | ||||
-rw-r--r-- | xmltv2vdr.h | 66 |
7 files changed, 85 insertions, 114 deletions
@@ -18,7 +18,7 @@ VERSION = $(shell grep 'static const char \*VERSION *=' $(PLUGIN).h | awk '{ pri ### The C++ compiler and options: CXX ?= g++ -CXXFLAGS ?= -fPIC -g -O2 -Wall -Wextra -pedantic -Woverloaded-virtual -Wno-parentheses +CXXFLAGS ?= -fPIC -g -O2 -Wall -Wextra -Woverloaded-virtual -Wno-parentheses PKG-CONFIG ?= pkg-config ### The directory environment: @@ -20,4 +20,5 @@ public: int Close(int &status); }; -#endif
\ No newline at end of file +#endif + diff --git a/po/de_DE.po b/po/de_DE.po index 56c7aeb..5aad20b 100644 --- a/po/de_DE.po +++ b/po/de_DE.po @@ -4,7 +4,7 @@ msgid "" msgstr "" "Project-Id-Version: vdr\n" "Report-Msgid-Bugs-To: <see README>\n" -"POT-Creation-Date: 2011-01-03 20:10+0100\n" +"POT-Creation-Date: 2011-01-22 20:34+0100\n" "PO-Revision-Date: 2010-12-23 23:59+0100\n" "Last-Translator: Jochen Dolze <vdr@dolze.de>\n" "Language-Team: <vdr@linuxtv.org>\n" @@ -21,6 +21,9 @@ msgstr "automatisch Aufwachen" msgid "execution time" msgstr "Ausführung um" +msgid "update on start" +msgstr "ausführen beim Start" + msgid "text mapping" msgstr "Textzuordnungen" @@ -34,7 +34,8 @@ cMenuSetupXmltv2vdr::cMenuSetupXmltv2vdr(cPluginXmltv2vdr *Plugin) { baseplugin=Plugin; sourcesBegin=sourcesEnd=mappingBegin=mappingEnd=mappingEntry=0; - wakeup=baseplugin->wakeup; + wakeup=baseplugin->WakeUp; + upstart=baseplugin->UpStart; exectime=baseplugin->ExecTime(); Output(); } @@ -49,6 +50,7 @@ void cMenuSetupXmltv2vdr::Output(void) Add(new cMenuEditBoolItem(tr("automatic wakeup"),&wakeup),true); Add(new cMenuEditTimeItem(tr("execution time"),&exectime),true); + Add(new cMenuEditBoolItem(tr("update on start"),&upstart),true); Add(new cOsdItem(tr("text mapping")),true); mappingEntry=Current(); Add(newtitle(tr("epg sources")),true); @@ -170,8 +172,10 @@ void cMenuSetupXmltv2vdr::Store(void) { SetupStore("options.exectime",exectime); SetupStore("options.wakeup",wakeup); + SetupStore("options.upstart",upstart); - baseplugin->wakeup=wakeup; + baseplugin->UpStart=upstart; + baseplugin->WakeUp=wakeup; baseplugin->SetExecTime(exectime); } @@ -26,6 +26,7 @@ private: void generatesumchannellist(); int exectime; int wakeup; + int upstart; public: void Output(void); cMenuSetupXmltv2vdr(cPluginXmltv2vdr *Plugin); diff --git a/xmltv2vdr.cpp b/xmltv2vdr.cpp index bfcd1ca..ea9756d 100644 --- a/xmltv2vdr.cpp +++ b/xmltv2vdr.cpp @@ -39,7 +39,23 @@ int cEPGChannel::Compare(const cListObject &ListObject) const // ------------------------------------------------------------- -cEPGExecute::cEPGExecute(const char *Name, cEPGMappings *Maps, cTEXTMappings *Texts):cThread(Name) +cEPGExecutor::cEPGExecutor(cEPGSources *Sources) : cThread("xmltv2vdr importer") +{ + sources=Sources; +} + +void cEPGExecutor::Action() +{ + if (!sources) return; + for (cEPGSource *epgs=sources->First(); epgs; epgs=sources->Next(epgs)) + { + if (epgs->Execute()) break; // TODO: check if we must execute second/third source! + } +} + +// ------------------------------------------------------------- + +cEPGSource::cEPGSource(const char *Name, cEPGMappings *Maps, cTEXTMappings *Texts) { dsyslog("xmltv2vdr: added epgsource '%s'",Name); name=strdup(Name); @@ -49,14 +65,14 @@ cEPGExecute::cEPGExecute(const char *Name, cEPGMappings *Maps, cTEXTMappings *Te parse=new cParse(Name, Maps, Texts); } -cEPGExecute::~cEPGExecute() +cEPGSource::~cEPGSource() { - Stop(); - free((void*) name); + dsyslog("xmltv2vdr: removed epgsource '%s'",name); + free((void *) name); if (parse) delete parse; } -bool cEPGExecute::ReadConfig() +bool cEPGSource::ReadConfig() { dsyslog("xmltv2vdr: reading config of epgsource '%s'",name); char *fname=NULL; @@ -129,21 +145,14 @@ bool cEPGExecute::ReadConfig() return false; } -void cEPGExecute::SetChannelSelection(int *Selection) -{ - for (int i=0; i<channels.Count(); i++) - { - channels.Get(i)->SetUsage(Selection[i]); - } -} - -void cEPGExecute::Action() +bool cEPGSource::Execute() { - if (!ready2parse) return; - if (!parse) return; + if (!ready2parse) return false; + if (!parse) return false; char *result=NULL; int l=0; + bool ret=true; if (pipe) { cExtPipe p; @@ -167,11 +176,13 @@ void cEPGExecute::Action() if (!parse->Process(result,l)) { esyslog("xmltv2vdr: failed to parse output of '%s'",name); + ret=false; } } else { esyslog("xmltv2vdr: epgsource '%s' returned with %i",name,returncode); + ret=false; } } if (result) free(result); @@ -179,6 +190,7 @@ void cEPGExecute::Action() else { esyslog("xmltv2vdr: failed to open pipe for '%s'",name); + ret=false; } } else @@ -198,7 +210,11 @@ void cEPGExecute::Action() { if (read(fd,result,statbuf.st_size)==statbuf.st_size) { - parse->Process(result,l); + if (!parse->Process(result,l)) + { + esyslog("xmltv2vdr: failed to parse output of '%s'",name); + ret=false; + } } free(result); } @@ -208,30 +224,20 @@ void cEPGExecute::Action() else { esyslog("xmltv2vdr: failed to open file '%s' for '%s'",fname,name); + ret=false; } free(fname); } } + return ret; } -// ------------------------------------------------------------- - -cEPGSource::cEPGSource(const char *Name, cEPGMappings *Maps, cTEXTMappings *Texts):exec(Name,Maps,Texts) -{ - name=strdup(Name); -} - -cEPGSource::~cEPGSource() -{ - dsyslog("xmltv2vdr: removed epgsource '%s'",name); - free((void *) name); -} - -bool cEPGSource::Execute() +void cEPGSource::ChangeChannelSelection(int *Selection) { - if (exec.Active()) return false; - exec.Start(); - return true; + for (int i=0; i<channels.Count(); i++) + { + channels.Get(i)->SetUsage(Selection[i]); + } } void cEPGSource::Store(void) @@ -352,26 +358,6 @@ void cPluginXmltv2vdr::removeepgsources() } } -bool cPluginXmltv2vdr::epgsourcesactive() -{ - bool ret=false; - for (cEPGSource *epgs=epgsources.First(); epgs; epgs=epgsources.Next(epgs)) - { - ret|=epgs->Active(); - } - return ret; -} - -bool cPluginXmltv2vdr::executeepgsources() -{ - bool ret=false; - for (cEPGSource *epgs=epgsources.First(); epgs; epgs=epgsources.Next(epgs)) - { - ret|=epgs->Execute(); - } - return ret; -} - cEPGMapping *cPluginXmltv2vdr::EPGMapping(const char *ChannelName) { if (!epgmappings.Count()) return NULL; @@ -453,12 +439,13 @@ void cPluginXmltv2vdr::SetExecTime(int ExecTime) if (exectime_t<=time(NULL)) exectime_t+=86000; } -cPluginXmltv2vdr::cPluginXmltv2vdr(void) +cPluginXmltv2vdr::cPluginXmltv2vdr(void) : epgexecutor(&epgsources) { // Initialize any member variables here. // DON'T DO ANYTHING ELSE THAT MAY HAVE SIDE EFFECTS, REQUIRE GLOBAL // VDR OBJECTS TO EXIST OR PRODUCE ANY OUTPUT! - wakeup=0; + WakeUp=0; + UpStart=0; last_exectime_t=0; exectime=200; SetExecTime(exectime); @@ -506,6 +493,7 @@ bool cPluginXmltv2vdr::Start(void) // Start any background activities the plugin shall perform. cParse::InitLibXML(); ReadInEPGSources(); + if (UpStart) exectime_t=time(NULL)+30; return true; } @@ -531,7 +519,7 @@ void cPluginXmltv2vdr::MainThreadHook(void) if (((now>=exectime_t) && (now<(exectime_t+10))) && (last_exectime_t!=exectime_t)) { - executeepgsources(); + epgexecutor.Start(); last_exectime_t=exectime_t; SetExecTime(exectime); } @@ -540,7 +528,7 @@ void cPluginXmltv2vdr::MainThreadHook(void) cString cPluginXmltv2vdr::Active(void) { // Return a message string if shutdown should be postponed - if (epgsourcesactive()) + if (epgexecutor.Active()) { return tr("xmltv2vdr plugin still working"); } @@ -550,7 +538,7 @@ cString cPluginXmltv2vdr::Active(void) time_t cPluginXmltv2vdr::WakeupTime(void) { // Return custom wakeup time for shutdown script - if (wakeup) + if (WakeUp) { time_t Now=time(NULL); time_t Time=cTimer::SetTime(Now,cTimer::TimeToInt(exectime)); @@ -613,7 +601,11 @@ bool cPluginXmltv2vdr::SetupParse(const char *Name, const char *Value) } else if (!strcasecmp(Name,"options.wakeup")) { - wakeup=atoi(Value); + WakeUp=atoi(Value); + } + else if (!strcasecmp(Name,"options.upstart")) + { + UpStart=atoi(Value); } else return false; return true; @@ -651,7 +643,7 @@ cString cPluginXmltv2vdr::SVDRPCommand(const char *Command, const char *UNUSED(O } else { - if (executeepgsources()) + if (epgexecutor.Start()) { ReplyCode=250; output="Update started\n"; diff --git a/xmltv2vdr.h b/xmltv2vdr.h index 993e1e6..f90b57c 100644 --- a/xmltv2vdr.h +++ b/xmltv2vdr.h @@ -42,7 +42,7 @@ public: class cEPGChannels : public cList<cEPGChannel> {}; -class cEPGExecute : public cThread +class cEPGSource : public cListObject { private: const char *name; @@ -54,53 +54,22 @@ private: bool ReadConfig(); cEPGChannels channels; public: - cEPGExecute(const char *Name,cEPGMappings *Maps,cTEXTMappings *Texts); - ~cEPGExecute(); - cEPGChannels *GetChannelList() - { - return &channels; - } - int GetDaysMax() - { - return daysmax; - } - int GetDaysInAdvance() - { - return daysinadvance; - } - void SetDaysInAdvance(int NewDaysInAdvance) - { - daysinadvance=NewDaysInAdvance; - } - void SetChannelSelection(int *Selection); - virtual void Action(); - void Stop() - { - Cancel(3); - } -}; - -class cEPGSource : public cListObject -{ -private: - const char *name; - cEPGExecute exec; -public: cEPGSource(const char *Name,cEPGMappings *Maps,cTEXTMappings *Texts); ~cEPGSource(); bool Execute(); void Store(void); + void ChangeChannelSelection(int *Selection); cEPGChannels *ChannelList() { - return exec.GetChannelList(); + return &channels; } int DaysMax() { - return exec.GetDaysMax(); + return daysmax; } int DaysInAdvance() { - return exec.GetDaysInAdvance(); + return daysinadvance; } const char *Name() { @@ -108,31 +77,31 @@ public: } void ChangeDaysInAdvance(int NewDaysInAdvance) { - exec.SetDaysInAdvance(NewDaysInAdvance); - } - void ChangeChannelSelection(int *Selection) - { - exec.SetChannelSelection(Selection); - } - bool Active() - { - return exec.Active(); + daysinadvance=NewDaysInAdvance; } }; class cEPGSources : public cList<cEPGSource> {}; +class cEPGExecutor : public cThread +{ +private: + cEPGSources *sources; +public: + cEPGExecutor(cEPGSources *Sources); + virtual void Action(); +}; + class cPluginXmltv2vdr : public cPlugin { private: + cEPGExecutor epgexecutor; cEPGMappings epgmappings; cEPGSources epgsources; cTEXTMappings textmappings; void removeepgsources(); void removeepgmappings(); void removetextmappings(); - bool executeepgsources(); - bool epgsourcesactive(); bool epgsourceexists(const char *name); int exectime; time_t exectime_t,last_exectime_t; @@ -142,7 +111,8 @@ public: return exectime; } void SetExecTime(int ExecTime); - int wakeup; + bool UpStart; + bool WakeUp; void ReadInEPGSources(bool Reload=false); int EPGSourceCount() { |