diff options
-rw-r--r-- | infosatepg.cpp | 16 | ||||
-rw-r--r-- | infosatepg.h | 2 | ||||
-rw-r--r-- | process.cpp | 10 | ||||
-rw-r--r-- | process.h | 231 |
4 files changed, 179 insertions, 80 deletions
diff --git a/infosatepg.cpp b/infosatepg.cpp index 74f029b..2c1b974 100644 --- a/infosatepg.cpp +++ b/infosatepg.cpp @@ -26,6 +26,7 @@ cPluginInfosatepg::cPluginInfosatepg(void) // VDR OBJECTS TO EXIST OR PRODUCE ANY OUTPUT! statusMonitor=NULL; global=new cGlobalInfosatepg; + process=new cProcessInfosatepg(); pmac=EPG_FIRST_DAY_MAC; } @@ -33,6 +34,7 @@ cPluginInfosatepg::~cPluginInfosatepg() { // Clean up after yourself! if (statusMonitor) delete statusMonitor; + delete process; delete global; } @@ -104,13 +106,13 @@ bool cPluginInfosatepg::Start(void) isyslog("infosatepg: failed to load plugin status"); } statusMonitor = new cStatusInfosatepg(global); - return true; } void cPluginInfosatepg::Stop(void) { // Stop any background activities the plugin is performing. + process->Stop(); if (global->Save()==-1) { isyslog("infosatepg: failed to save plugin status"); @@ -131,10 +133,14 @@ void cPluginInfosatepg::MainThreadHook(void) { if (!global->Infosatdata[pmac].Processed) { - isyslog ("infosatepg: found data to be processed: day=%i month=%i", - global->Infosatdata[pmac].Day(),global->Infosatdata[pmac].Month()); - cProcessInfosatepg process(pmac,global); - process.Start(); + if (!process->Active()) + { + isyslog ("infosatepg: found data to be processed: day=%i month=%i", + global->Infosatdata[pmac].Day(),global->Infosatdata[pmac].Month()); + + process->SetInfo(pmac,global); + process->Start(); + } } else { diff --git a/infosatepg.h b/infosatepg.h index b7c9f3b..48e5c5f 100644 --- a/infosatepg.h +++ b/infosatepg.h @@ -11,6 +11,7 @@ #include "global.h" #include "status.h" +#include "process.h" static const char *VERSION = "0.0.8"; static const char *DESCRIPTION = trNOOP("Read EPG info from infosat"); @@ -20,6 +21,7 @@ private: // Add any member variables or functions you may need here. cGlobalInfosatepg *global; cStatusInfosatepg *statusMonitor; + cProcessInfosatepg *process; int pmac; public: cPluginInfosatepg(void); diff --git a/process.cpp b/process.cpp index ee168ef..9e8cd9e 100644 --- a/process.cpp +++ b/process.cpp @@ -611,15 +611,23 @@ const char *cInfosatevent::ExtEPG(void) } // --- cProcessInfosatepg -cProcessInfosatepg::cProcessInfosatepg(int Mac, cGlobalInfosatepg *Global) +cProcessInfosatepg::cProcessInfosatepg() :cThread("infosatepg") { + mac=-1; + global=NULL; +} + +void cProcessInfosatepg::SetInfo(int Mac, cGlobalInfosatepg *Global) +{ mac=Mac; global=Global; } void cProcessInfosatepg::Action() { + if ((mac<EPG_FIRST_DAY_MAC) || (mac>EPG_LAST_DAY_MAC)) return; + FILE *f; const char *file = global->Infosatdata[mac].GetFile(); f=fopen(file,"r"); @@ -28,88 +28,171 @@ class cInfosatevent #define EVCONTENTMASK_USERDEFINED 0xF0 private: - int duration; - time_t startTime; - char *title; - char *shorttext; - char *description; - char *announcement; - char *country; - char *genre; - char *original; - char *episode; - char *category; - char *extepg; - char *addition; - char *rating; - int content; - int fsk; - int year; - int usage; - int days; - tEventID eventID; + int duration; + time_t startTime; + char *title; + char *shorttext; + char *description; + char *announcement; + char *country; + char *genre; + char *original; + char *episode; + char *category; + char *extepg; + char *addition; + char *rating; + int content; + int fsk; + int year; + int usage; + int days; + tEventID eventID; public: - cInfosatevent(); - ~cInfosatevent(); - void SetTitle(const char *Title); - void SetShortText(const char *ShortText); - void SetDescription(const char *Description); - void SetStartTime(time_t StartTime) { startTime=StartTime; } - void SetDuration(int Duration) { duration=Duration; } - void SetEventUsage(int Usage) { usage=Usage; } - void SetEventDays(int Days) { days=Days; } - void SetYear(int Year) { year=Year; } - void SetEventID(tEventID EventID) { eventID=EventID; } - void SetContentDescriptor(int Content) { content=Content; } - void SetFSK(int FSK) { fsk=FSK; } - void SetRating(const char *Rating); - void SetAnnouncement(const char *Announcement); - void SetCountry(const char *Country); - void SetCategory(const char *Category); - void SetCategoryByID(int i); - void SetGenre(const char *Genre); - void SetGenreByID(int i); - void SetOriginal(const char *Original); - void SetEpisode(const char *Episode); - void SetAddition(const char *Addition); - const char *Description(void) const { return description; } - const char *Title(void) const { return title; } - const char *ShortText(void) const { return shorttext; } - const char *Announcement(void) const { return announcement; } - const char *Category(void) const { return category; } - const char *Genre(void) const { return genre; } - const char *Country(void) const { return country; } - const char *Original(void) const { return original; } - const char *Episode(void) const { return episode; } - const char *Addition(void) const { return addition; } - const char *Rating(void) const { return rating; } - int Content(void) const { return content; } - int Year(void) const { return year; } - int Duration(void) const { return duration; } - int FSK(void) const { return fsk; } - time_t StartTime(void) const { return startTime; } - int Usage() { return usage; } - int Days() { return days; } - tEventID EventID(void) const { return eventID; } - const char *ExtEPG(void); + cInfosatevent(); + ~cInfosatevent(); + void SetTitle(const char *Title); + void SetShortText(const char *ShortText); + void SetDescription(const char *Description); + void SetStartTime(time_t StartTime) + { + startTime=StartTime; + } + void SetDuration(int Duration) + { + duration=Duration; + } + void SetEventUsage(int Usage) + { + usage=Usage; + } + void SetEventDays(int Days) + { + days=Days; + } + void SetYear(int Year) + { + year=Year; + } + void SetEventID(tEventID EventID) + { + eventID=EventID; + } + void SetContentDescriptor(int Content) + { + content=Content; + } + void SetFSK(int FSK) + { + fsk=FSK; + } + void SetRating(const char *Rating); + void SetAnnouncement(const char *Announcement); + void SetCountry(const char *Country); + void SetCategory(const char *Category); + void SetCategoryByID(int i); + void SetGenre(const char *Genre); + void SetGenreByID(int i); + void SetOriginal(const char *Original); + void SetEpisode(const char *Episode); + void SetAddition(const char *Addition); + const char *Description(void) const + { + return description; + } + const char *Title(void) const + { + return title; + } + const char *ShortText(void) const + { + return shorttext; + } + const char *Announcement(void) const + { + return announcement; + } + const char *Category(void) const + { + return category; + } + const char *Genre(void) const + { + return genre; + } + const char *Country(void) const + { + return country; + } + const char *Original(void) const + { + return original; + } + const char *Episode(void) const + { + return episode; + } + const char *Addition(void) const + { + return addition; + } + const char *Rating(void) const + { + return rating; + } + int Content(void) const + { + return content; + } + int Year(void) const + { + return year; + } + int Duration(void) const + { + return duration; + } + int FSK(void) const + { + return fsk; + } + time_t StartTime(void) const + { + return startTime; + } + int Usage() + { + return usage; + } + int Days() + { + return days; + } + tEventID EventID(void) const + { + return eventID; + } + const char *ExtEPG(void); }; // --- cProcessInfosatepg class cProcessInfosatepg : public cThread { private: - cGlobalInfosatepg *global; - int mac; - bool AddInfosatEvent(cChannel *channel, cInfosatevent *iEvent); - bool CheckOriginal_and_Episode(char **s,cInfosatevent *iEvent,cCharSetConv *conv); - bool CheckAnnouncement(char *s,cInfosatevent *iEvent); - bool ParseInfosatepg(FILE *f,time_t *firststarttime); - cChannel *GetVDRChannel(int frequency, int sid); - u_long DoSum(u_long sum, const char *buf, int nBytes); - cEvent *SearchEvent(cSchedule* Schedule, cInfosatevent *iEvent); + cGlobalInfosatepg *global; + int mac; + bool AddInfosatEvent(cChannel *channel, cInfosatevent *iEvent); + bool CheckOriginal_and_Episode(char **s,cInfosatevent *iEvent,cCharSetConv *conv); + bool CheckAnnouncement(char *s,cInfosatevent *iEvent); + bool ParseInfosatepg(FILE *f,time_t *firststarttime); + cChannel *GetVDRChannel(int frequency, int sid); + u_long DoSum(u_long sum, const char *buf, int nBytes); + cEvent *SearchEvent(cSchedule* Schedule, cInfosatevent *iEvent); public: - cProcessInfosatepg(int Mac, cGlobalInfosatepg *Global); - virtual void Action(); + cProcessInfosatepg(); + void SetInfo(int Mac, cGlobalInfosatepg *Global); + void Stop() { Cancel(3); } + virtual void Action(); }; #endif |