diff options
-rw-r--r-- | blacklist.c | 1 | ||||
-rw-r--r-- | charset.h | 1 | ||||
-rw-r--r-- | config.c | 3 | ||||
-rw-r--r-- | config.h | 1 | ||||
-rw-r--r-- | epgclone.h | 1 | ||||
-rw-r--r-- | epghandler.h | 1 | ||||
-rw-r--r-- | regexp.h | 3 | ||||
-rw-r--r-- | setup_menu.c | 6 | ||||
-rw-r--r-- | setup_menu.h | 2 | ||||
-rw-r--r-- | tools.c | 9 | ||||
-rw-r--r-- | tools.h | 122 |
11 files changed, 83 insertions, 67 deletions
diff --git a/blacklist.c b/blacklist.c index 786ef87..0ad1121 100644 --- a/blacklist.c +++ b/blacklist.c @@ -10,7 +10,6 @@ /* Global instance */ cEpgfixerList<cBlacklist, cChannel> EpgfixerBlacklists; - bool cBlacklist::Apply(cChannel *Channel) { if (enabled && IsActive(Channel->GetChannelID())) @@ -16,6 +16,7 @@ class cCharSet : public cListItem private: char *origcharset; char *realcharset; + public: cCharSet(); virtual ~cCharSet(); @@ -36,7 +36,6 @@ bool cEpgfixerSetup::ProcessArg(const char *Name, const char *Value) return false; } - bool cEpgfixerSetup::ProcessArgs(int argc, char *argv[]) { return true; @@ -60,7 +59,7 @@ bool cEpgfixerSetup::SetupParse(const char *Name, const char *Value) else if (!strcasecmp(Name, "PreventEqualShortTextAndDescription")) equalshorttextanddescription = atoi(Value); else if (!strcasecmp(Name, "ReplaceBackticksWithSingleQuotes")) nobackticks = atoi(Value); else if (!strcasecmp(Name, "FixStreamComponentDescriptions")) components = atoi(Value); - else if (!strcasecmp(Name, "StripHTMLEntities")) striphtml = atoi(Value); + else if (!strcasecmp(Name, "StripHTMLEntities")) striphtml = atoi(Value); else return false; @@ -23,7 +23,6 @@ public: int nobackticks; int components; int striphtml; - cEpgfixerSetup(); bool SetupParse(const char *Name, const char *Value); bool ProcessArgs(int argc, char *argv[]); @@ -17,6 +17,7 @@ private: int dest_num; char *dest_str; void CloneEvent(cEvent *Source, cEvent *Dest); + public: cEpgClone(); virtual ~cEpgClone(); diff --git a/epghandler.h b/epghandler.h index 657fffc..2e03d25 100644 --- a/epghandler.h +++ b/epghandler.h @@ -17,6 +17,7 @@ private: bool FixCharSets(cEvent *Event); bool FixBugs(cEvent *Event); void StripHTML(cEvent *Event); + public: cEpgfixerEpgHandler(void) {}; virtual bool HandleEvent(cEvent *Event); @@ -15,7 +15,7 @@ #include <pcre.h> #endif -typedef enum { REGEXP_TITLE,REGEXP_SHORTTEXT,REGEXP_DESCRIPTION,REGEXP_UNDEFINED } sources; +typedef enum { REGEXP_TITLE, REGEXP_SHORTTEXT, REGEXP_DESCRIPTION, REGEXP_UNDEFINED } sources; class cRegexp : public cListItem { @@ -30,6 +30,7 @@ private: void Compile(); void FreeCompiled(); void ParseRegexp(char *restring); + public: cRegexp(); virtual ~cRegexp(); diff --git a/setup_menu.c b/setup_menu.c index 2719115..cecae25 100644 --- a/setup_menu.c +++ b/setup_menu.c @@ -71,7 +71,7 @@ protected: int i = 0; LISTITEM *item = (LISTITEM *)list->First(); while (i < list->Count()) { - item->SetFromString(lines[i], item->Enabled()); + item->SetFromString(lines[i], item->IsEnabled()); item = (LISTITEM *)item->Next(); ++i; } @@ -82,7 +82,7 @@ protected: int i = 0; LISTITEM *item = (LISTITEM *)list->First(); while (i < list->Count()) { - Add(new cMenuEditStrItem(item->Enabled() ? "+" : "-", lines[i], MAXREGEXPLENGTH, tr(RegexpChars))); + Add(new cMenuEditStrItem(item->IsEnabled() ? "+" : "-", lines[i], MAXREGEXPLENGTH, tr(RegexpChars))); item = (LISTITEM *)item->Next(); ++i; } @@ -223,7 +223,7 @@ void cMenuSetupEpgfixer::Store(void) SetupStore("PreventEqualShortTextAndDescription", EpgfixerSetup.equalshorttextanddescription); SetupStore("ReplaceBackticksWithSingleQuotes", EpgfixerSetup.nobackticks); SetupStore("FixStreamComponentDescriptions", EpgfixerSetup.components); - SetupStore("StripHTMLentities", EpgfixerSetup.striphtml); + SetupStore("StripHTMLentities", EpgfixerSetup.striphtml); Setup.Save(); } diff --git a/setup_menu.h b/setup_menu.h index 4e12ac2..6eef26f 100644 --- a/setup_menu.h +++ b/setup_menu.h @@ -17,9 +17,11 @@ class cMenuSetupEpgfixer : public cMenuSetupPage private: cEpgfixerSetup newconfig; cVector<const char*> help; + protected: virtual void Store(void); void Set(void); + public: cMenuSetupEpgfixer(void); virtual eOSState ProcessKey(eKeys Key); @@ -153,13 +153,14 @@ char *striphtml(char *str) return NULL; } -// --- cAddEventThread ---------------------------------------- +// --- cAddEventThread -------------------------------------------------- class cAddEventListItem : public cListObject { protected: cEvent *event; tChannelID channelID; + public: cAddEventListItem(cEvent *Event, tChannelID ChannelID) { event = Event; channelID = ChannelID; } tChannelID GetChannelID() { return channelID; } @@ -173,8 +174,10 @@ private: cTimeMs LastHandleEvent; cList<cAddEventListItem> *list; enum { INSERT_TIMEOUT_IN_MS = 10000 }; + protected: virtual void Action(void); + public: cAddEventThread(void); ~cAddEventThread(void); @@ -223,7 +226,7 @@ void cAddEventThread::AddEvent(cEvent *Event, tChannelID ChannelID) static cAddEventThread AddEventThread; -// --- +// --- Add event to schedule -------------------------------------------- void AddEvent(cEvent *Event, tChannelID ChannelID) { @@ -232,7 +235,7 @@ void AddEvent(cEvent *Event, tChannelID ChannelID) AddEventThread.Start(); } -// --- Listitem ---------------------------------------- +// --- Listitem --------------------------------------------------------- cListItem::cListItem() { @@ -17,6 +17,8 @@ #define FREE(x) { free(x); x = NULL; } +// --- Add event to schedule -------------------------------------------- + void AddEvent(cEvent *event, tChannelID ChannelID); char *striphtml(char *str); @@ -34,6 +36,7 @@ protected: int GetChannelNum(int index); int LoadChannelsFromString(const char *string); bool IsActive(tChannelID ChannelID); + public: cListItem(); virtual ~cListItem(); @@ -41,77 +44,84 @@ public: virtual bool Apply(cEvent *Event) { return 0; } void SetFromString(char *string, bool Enabled); const char *GetString() { return string; } - bool Enabled(void) { return enabled; } + bool IsEnabled(void) { return enabled; } void ToggleEnabled(void); void PrintConfigLineToFile(FILE *f); }; +// --- cEpgfixerList ---------------------------------------------------- + template<class LISTITEM, class PARAMETER> class cEpgfixerList : public cList<LISTITEM> { protected: char *fileName; - bool LoadConfigFile(bool AllowComments = true) - { - bool result = false; - if (fileName && access(fileName, F_OK) == 0) { - FILE *f = fopen(fileName, "r"); - if (f) { - char *s; - int line = 0; - int count = 0; - cReadLine ReadLine; - cString logmsg(""); - logmsg = cString::sprintf("%s%s loaded. Active lines:", *logmsg, fileName); - while ((s = ReadLine.Read(f)) != NULL) { - ++line; - if (!isempty(s)) { - this->Add(new LISTITEM()); - cList<LISTITEM>::Last()->LISTITEM::SetFromString(s, true); - if (cList<LISTITEM>::Last()->Enabled()) { - ++count; - logmsg = cString::sprintf("%s%s%i", *logmsg, count == 1 ? " " : ",", line); - } - } - } - fclose(f); - if (count == 0) - logmsg = cString::sprintf("%s none", *logmsg); - isyslog("%s", *logmsg); - } - else { - LOG_ERROR_STR(fileName); - result = false; - } - } - ; - return result; - } + bool LoadConfigFile(bool AllowComments = true); public: cEpgfixerList() { fileName = NULL; } ~cEpgfixerList() { free(fileName); } void Clear(void) { cList<LISTITEM>::Clear(); } - bool ReloadConfigFile(bool AllowComments = true) - { - Clear(); - return LoadConfigFile(AllowComments); - } - bool Apply(PARAMETER *Parameter) - { - int res = false; - LISTITEM *item = (LISTITEM *)(cList<LISTITEM>::First()); - while (item) { - if (item->Enabled()) { - int ret = item->LISTITEM::Apply(Parameter); - if (ret && !res) - res = true; - } - item = (LISTITEM *)(item->Next()); - } - return res; - } + bool ReloadConfigFile(bool AllowComments = true); + bool Apply(PARAMETER *Parameter); void SetConfigFile(const char *FileName) { fileName = strdup(FileName); } const char *GetConfigFile() { return fileName; } }; +template<class LISTITEM, class PARAMETER> bool cEpgfixerList<LISTITEM, PARAMETER>::LoadConfigFile(bool AllowComments) +{ + bool result = false; + if (fileName && access(fileName, F_OK) == 0) { + FILE *f = fopen(fileName, "r"); + if (f) { + char *s; + int line = 0; + int count = 0; + cReadLine ReadLine; + cString logmsg(""); + logmsg = cString::sprintf("%s%s loaded. Active lines:", *logmsg, fileName); + while ((s = ReadLine.Read(f)) != NULL) { + ++line; + if (!isempty(s)) { + this->Add(new LISTITEM()); + cList<LISTITEM>::Last()->LISTITEM::SetFromString(s, true); + if (cList<LISTITEM>::Last()->IsEnabled()) { + ++count; + logmsg = cString::sprintf("%s%s%i", *logmsg, count == 1 ? " " : ",", line); + } + } + } + fclose(f); + if (count == 0) + logmsg = cString::sprintf("%s none", *logmsg); + isyslog("%s", *logmsg); + } + else { + LOG_ERROR_STR(fileName); + result = false; + } + } + return result; +} + +template<class LISTITEM, class PARAMETER> bool cEpgfixerList<LISTITEM, PARAMETER>::ReloadConfigFile(bool AllowComments) +{ + Clear(); + return LoadConfigFile(AllowComments); +} + +template<class LISTITEM, class PARAMETER> bool cEpgfixerList<LISTITEM, PARAMETER>::Apply(PARAMETER *Parameter) +{ + int res = false; + LISTITEM *item = (LISTITEM *)(cList<LISTITEM>::First()); + while (item) { + if (item->IsEnabled()) { + int ret = item->LISTITEM::Apply(Parameter); + if (ret && !res) + res = true; + } + item = (LISTITEM *)(item->Next()); + } + return res; +} + #endif //__EPGFIXER_TOOLS_H_ |