summaryrefslogtreecommitdiff
path: root/tools.h
diff options
context:
space:
mode:
authorMatti Lehtimäki <matti.lehtimaki@gmail.com>2012-05-12 14:42:01 +0300
committerMatti Lehtimäki <matti.lehtimaki@gmail.com>2012-05-12 14:42:01 +0300
commit6b488dcedf24cf9b4890505eba992d683eedecac (patch)
tree51347d76c4b2891568e54348d9ce0ab99304bd0b /tools.h
parent548e0a6bc35d4c776039f7467c0d67eabf9ef46a (diff)
downloadvdr-plugin-epgfixer-6b488dcedf24cf9b4890505eba992d683eedecac.tar.gz
vdr-plugin-epgfixer-6b488dcedf24cf9b4890505eba992d683eedecac.tar.bz2
Support for ignoring and copying EPG data. Bug fixes.
Fix character set conversion for selected channels. Fix and improve Makefile (thanks to Ville Skyttä and Rolf Ahrenberg). Fix compiling with g++-4.7.
Diffstat (limited to 'tools.h')
-rw-r--r--tools.h44
1 files changed, 30 insertions, 14 deletions
diff --git a/tools.h b/tools.h
index bf49fac..ebeeb76 100644
--- a/tools.h
+++ b/tools.h
@@ -17,6 +17,8 @@
#define FREE(x) { free(x); x = NULL; }
+void AddEvent(cEvent *event, tChannelID ChannelID);
+
char *striphtml(char *str);
class cListItem : public cListObject
@@ -35,62 +37,76 @@ protected:
public:
cListItem();
virtual ~cListItem();
+ virtual bool Apply(cChannel *Channel) { return 0; }
virtual bool Apply(cEvent *Event) { return 0; }
void SetFromString(char *string, bool Enabled);
const char *GetString() { return string; }
bool Enabled(void) { return enabled; }
void ToggleEnabled(void);
- virtual void PrintConfigLineToFIle(FILE *f) {}
+ void PrintConfigLineToFile(FILE *f);
};
-template<class T> class cEpgfixerList : public cList<T>
+template<class LISTITEM, class PARAMETER> class cEpgfixerList : public cList<LISTITEM>
{
protected:
char *fileName;
- bool LoadConfigFile(const char *FileName = NULL, bool AllowComments = true)
+ bool LoadConfigFile(bool AllowComments = true)
{
bool result = false;
- if (FileName && access(FileName, F_OK) == 0) {
- FILE *f = fopen(FileName, "r");
+ 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 T());
- cList<T>::Last()->SetFromString(s, true);
+ this->Add(new LISTITEM());
+ cList<LISTITEM>::Last()->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);
+ LOG_ERROR_STR(fileName);
result = false;
}
}
+ ;
return result;
}
public:
cEpgfixerList() { fileName = NULL; }
~cEpgfixerList() { free(fileName); }
- void Clear(void) { cList<T>::Clear(); }
+ void Clear(void) { cList<LISTITEM>::Clear(); }
bool ReloadConfigFile(bool AllowComments = true)
{
Clear();
- return LoadConfigFile(fileName, AllowComments);
+ return LoadConfigFile(AllowComments);
}
- bool Apply(cEvent *Event)
+ bool Apply(PARAMETER *Parameter)
{
int res = false;
- T *item = (T *)(cList<T>::First());
+ LISTITEM *item = (LISTITEM *)(cList<LISTITEM>::First());
while (item) {
if (item->Enabled()) {
- int ret = item->Apply(Event);
+ int ret = item->LISTITEM::Apply(Parameter);
if (ret && !res)
res = true;
}
- item = (T *)(item->Next());
+ item = (LISTITEM *)(item->Next());
}
return res;
}