summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--eepg.c97
-rw-r--r--log.h9
-rw-r--r--setupeepg.c36
-rw-r--r--setupeepg.h35
5 files changed, 110 insertions, 69 deletions
diff --git a/Makefile b/Makefile
index 0bebc82..a2d413e 100644
--- a/Makefile
+++ b/Makefile
@@ -65,7 +65,7 @@ DEFINES += -D_GNU_SOURCE -DPLUGIN_NAME_I18N='"$(PLUGIN)"'
### The object files (add further files here):
-OBJS = $(PLUGIN).o dish.o epghandler.o
+OBJS = $(PLUGIN).o dish.o epghandler.o setupeepg.o
ifdef DBG
CXXFLAGS += -g
diff --git a/eepg.c b/eepg.c
index 22ee520..902c271 100644
--- a/eepg.c
+++ b/eepg.c
@@ -40,6 +40,7 @@
#include "dish.h"
#include "epghandler.h"
#include "log.h"
+#include "setupeepg.h"
#include <map>
#include <string>
@@ -75,8 +76,6 @@ static const char *DESCRIPTION = trNOOP ("Parses Extended EPG data");
using namespace std;
-// --- cSetupEEPG -------------------------------------------------------
-
const char *optPats[] = {
"%s",
"%s (Option %d)",
@@ -101,45 +100,15 @@ char *cs_hexdump (int m, const uchar * buf, int n)
return (dump);
}
-class cSetupEEPG
-{
-public:
- int OptPat;
- int OrderInfo;
- int RatingInfo;
- int FixEpg;
- int DisplayMessage;
- int ProcessEIT;
-#ifdef DEBUG
- int LogLevel;
-#endif
-
-public:
- cSetupEEPG (void);
-};
-
-cSetupEEPG SetupPE;
+cSetupEEPG* SetupPE = cSetupEEPG::getInstance();
-cSetupEEPG::cSetupEEPG (void)
-{
- OptPat = 1;
- OrderInfo = 1;
- RatingInfo = 1;
- FixEpg = 0;
- DisplayMessage = 1;
- ProcessEIT = 0;
-#ifdef DEBUG
- LogLevel = 0;
-#endif
-
-}
// --- cMenuSetupPremiereEpg ------------------------------------------------------------
class cMenuSetupPremiereEpg:public cMenuSetupPage
{
private:
- cSetupEEPG data;
+ cSetupEEPG* data;
const char *optDisp[NUM_PATS];
char buff[NUM_PATS][32];
protected:
@@ -150,35 +119,35 @@ public:
cMenuSetupPremiereEpg::cMenuSetupPremiereEpg (void)
{
- data = SetupPE;
+ data = cSetupEEPG::getInstance();
SetSection (tr ("PremiereEPG"));
optDisp[0] = tr ("off");
for (unsigned int i = 1; i < NUM_PATS; i++) {
snprintf (buff[i], sizeof (buff[i]), optPats[i], "Event", 1);
optDisp[i] = buff[i];
}
- Add (new cMenuEditStraItem (tr ("Tag option events"), &data.OptPat, NUM_PATS, optDisp));
- Add (new cMenuEditBoolItem (tr ("Show order information"), &data.OrderInfo));
- Add (new cMenuEditBoolItem (tr ("Show rating information"), &data.RatingInfo));
- Add (new cMenuEditBoolItem (tr ("Fix EPG data"), &data.FixEpg));
- Add (new cMenuEditBoolItem (tr ("Display summary message"), &data.DisplayMessage));
+ Add (new cMenuEditStraItem (tr ("Tag option events"), &data->OptPat, NUM_PATS, optDisp));
+ Add (new cMenuEditBoolItem (tr ("Show order information"), &data->OrderInfo));
+ Add (new cMenuEditBoolItem (tr ("Show rating information"), &data->RatingInfo));
+ Add (new cMenuEditBoolItem (tr ("Fix EPG data"), &data->FixEpg));
+ Add (new cMenuEditBoolItem (tr ("Display summary message"), &data->DisplayMessage));
#ifdef DEBUG
- Add (new cMenuEditIntItem (tr ("Level of logging verbosity"), &data.LogLevel, 0, 5));
- Add (new cMenuEditBoolItem (tr ("Process EIT info with EEPG"), &data.ProcessEIT));
+ Add (new cMenuEditIntItem (tr ("Level of logging verbosity"), &data->LogLevel, 0, 5));
+ Add (new cMenuEditBoolItem (tr ("Process EIT info with EEPG"), &data->ProcessEIT));
#endif
}
void cMenuSetupPremiereEpg::Store (void)
{
- SetupPE = data;
- SetupStore ("OptionPattern", SetupPE.OptPat);
- SetupStore ("OrderInfo", SetupPE.OrderInfo);
- SetupStore ("RatingInfo", SetupPE.RatingInfo);
- SetupStore ("FixEpg", SetupPE.FixEpg);
- SetupStore ("DisplayMessage", SetupPE.DisplayMessage);
+ //SetupPE = data;
+ SetupStore ("OptionPattern", SetupPE->OptPat);
+ SetupStore ("OrderInfo", SetupPE->OrderInfo);
+ SetupStore ("RatingInfo", SetupPE->RatingInfo);
+ SetupStore ("FixEpg", SetupPE->FixEpg);
+ SetupStore ("DisplayMessage", SetupPE->DisplayMessage);
#ifdef DEBUG
- SetupStore ("LogLevel", SetupPE.LogLevel);
- SetupStore ("ProcessEIT", SetupPE.ProcessEIT);
+ SetupStore ("LogLevel", SetupPE->LogLevel);
+ SetupStore ("ProcessEIT", SetupPE->ProcessEIT);
#endif
}
@@ -2990,7 +2959,7 @@ cEIT2::cEIT2 (cSchedules * Schedules, int Source, u_char Tid, const u_char * Dat
: SI::EIT (Data, false)
{
//LogD(2, prep("cEIT2::cEIT2"));
- if (Tid > 0 && (Format == DISH_BEV || (SetupPE.ProcessEIT && isEITPid))) Tid--;
+ if (Tid > 0 && (Format == DISH_BEV || (SetupPE->ProcessEIT && isEITPid))) Tid--;
if (!CheckCRCAndParse ()) {
LogD(2, prep("!CheckCRCAndParse ()"));
@@ -3604,7 +3573,7 @@ void cFilterEEPG::ProcessNextFormat (bool FirstTime = false)
isyslog ("EEPG: written %i summaries", SummaryCounter);
isyslog ("EEPG: rejected %i titles/summaries because of higher TableId", RejectTableId);
//Send message when finished
- if (SetupPE.DisplayMessage) {
+ if (SetupPE->DisplayMessage) {
char *mesg;
Asprintf(&mesg, "EEPG: written %i summaries", SummaryCounter);
Skins.QueueMessage(mtInfo, mesg, 2);
@@ -3634,7 +3603,7 @@ void cFilterEEPG::ProcessNextFormat (bool FirstTime = false)
FreeSummaries ();
// Enable EIT scan for all except DISH_BEV since it is already enabled
- if (SetupPE.ProcessEIT && !UnprocessedFormat[EIT]
+ if (SetupPE->ProcessEIT && !UnprocessedFormat[EIT]
&& !UnprocessedFormat[FREEVIEW] && !UnprocessedFormat[DISH_BEV]) {
UnprocessedFormat[EIT] = EIT_PID;
loadEquivalentChannelMap();
@@ -4162,7 +4131,7 @@ void cFilterEEPG::ProcessPremiere(const u_char *& Data)
nDescriptorTag = d->getDescriptorTag ();
switch (nDescriptorTag) {
case 0xF0: // order information
- if (SetupPE.OrderInfo) {
+ if (SetupPE->OrderInfo) {
static const char *text[] = {
trNOOP ("Ordernumber"),
trNOOP ("Price"),
@@ -4184,7 +4153,7 @@ void cFilterEEPG::ProcessPremiere(const u_char *& Data)
}
break;
case 0xF1: // parental rating
- if (SetupPE.RatingInfo) {
+ if (SetupPE->RatingInfo) {
char buff[512];
int p = 0;
const unsigned char *data = d->getData ().getData () + 2;
@@ -4264,7 +4233,7 @@ void cFilterEEPG::ProcessPremiere(const u_char *& Data)
int nid = pct->getOriginalNetworkId ();
int tid = pct->getTransportStreamId ();
int sid = pct->getServiceId ();
- if (SetupPE.FixEpg) {
+ if (SetupPE->FixEpg) {
if (nid == 133) {
if (tid == 0x03 && sid == 0xf0) {
tid = 0x02;
@@ -4358,7 +4327,7 @@ void cFilterEEPG::ProcessPremiere(const u_char *& Data)
ShortEventDescriptor->name.getText (buffer, sizeof (buffer));
if (isOpt) {
char buffer2[sizeof (buffer) + 32];
- snprintf (buffer2, sizeof (buffer2), optPats[SetupPE.OptPat], buffer, optCount);
+ snprintf (buffer2, sizeof (buffer2), optPats[SetupPE->OptPat], buffer, optCount);
pEvent->SetTitle (buffer2);
} else
pEvent->SetTitle (buffer);
@@ -4568,20 +4537,20 @@ bool cPluginEEPG::SetupParse (const char *Name, const char *Value)
if (!strcasecmp (Name, "OptionPattern"))
- SetupPE.OptPat = atoi (Value);
+ SetupPE->OptPat = atoi (Value);
else if (!strcasecmp (Name, "OrderInfo"))
- SetupPE.OrderInfo = atoi (Value);
+ SetupPE->OrderInfo = atoi (Value);
else if (!strcasecmp (Name, "RatingInfo"))
- SetupPE.RatingInfo = atoi (Value);
+ SetupPE->RatingInfo = atoi (Value);
else if (!strcasecmp (Name, "FixEpg"))
- SetupPE.FixEpg = atoi (Value);
+ SetupPE->FixEpg = atoi (Value);
else if (!strcasecmp (Name, "DisplayMessage"))
- SetupPE.DisplayMessage = atoi (Value);
+ SetupPE->DisplayMessage = atoi (Value);
#ifdef DEBUG
else if (!strcasecmp (Name, "LogLevel"))
- SetupPE.LogLevel = atoi (Value);
+ SetupPE->LogLevel = atoi (Value);
else if (!strcasecmp (Name, "ProcessEIT"))
- SetupPE.ProcessEIT = atoi (Value);
+ SetupPE->ProcessEIT = atoi (Value);
#endif
else
return false;
diff --git a/log.h b/log.h
index 900aed6..35942d3 100644
--- a/log.h
+++ b/log.h
@@ -10,16 +10,17 @@
#include <string>
#include <stdarg.h>
+#include "setupeepg.h"
#define VERBOSE 1
/* 0 = only print errors, 1 = print channels and themes, 2 = print channels, themes, titles, summaries 3 = debug mode */
/* all is logged into /var/log/syslog */
-bool CheckLevel(int level)
+inline bool CheckLevel(int level)
{
#ifdef DEBUG
- if (SetupPE.LogLevel >= level)
+ if (cSetupEEPG::getInstance()->LogLevel >= level)
#else
if (VERBOSE >= level)
#endif
@@ -29,7 +30,7 @@ bool CheckLevel(int level)
return false;
}
-const char* PrepareLog(std::string message)
+inline const char* PrepareLog(std::string message)
{
message = "EEPG: " + message;
return message.c_str();
@@ -38,7 +39,7 @@ const char* PrepareLog(std::string message)
#define MAXSYSLOGBUF 256
//void LogVsyslog(int errLevel, const char * message, ...)
-void LogVsyslog(int errLevel, int const& lineNum, const char * function, const char * message, ...)
+inline void LogVsyslog(int errLevel, int const& lineNum, const char * function, const char * message, ...)
{
va_list ap;
char fmt[MAXSYSLOGBUF];
diff --git a/setupeepg.c b/setupeepg.c
new file mode 100644
index 0000000..3738227
--- /dev/null
+++ b/setupeepg.c
@@ -0,0 +1,36 @@
+/*
+ * setupeepg.c
+ *
+ * Created on: 08.5.2012
+ * Author: d.petrovski
+ */
+
+#include <stddef.h>
+#include "setupeepg.h"
+
+// --- cSetupEEPG -------------------------------------------------------
+
+cSetupEEPG* cSetupEEPG::_setupEEPG = NULL;
+
+cSetupEEPG::cSetupEEPG (void)
+{
+ OptPat = 1;
+ OrderInfo = 1;
+ RatingInfo = 1;
+ FixEpg = 0;
+ DisplayMessage = 1;
+ ProcessEIT = 0;
+#ifdef DEBUG
+ LogLevel = 0;
+#endif
+
+}
+
+cSetupEEPG* cSetupEEPG::getInstance()
+{
+ if (!_setupEEPG)
+ _setupEEPG = new cSetupEEPG();
+
+ return _setupEEPG;
+}
+
diff --git a/setupeepg.h b/setupeepg.h
new file mode 100644
index 0000000..f5e342a
--- /dev/null
+++ b/setupeepg.h
@@ -0,0 +1,35 @@
+/*
+ * setupeepg.h
+ *
+ * Created on: 08.5.2012
+ * Author: d.petrovski
+ */
+
+#ifndef SETUPEEPG_H_
+#define SETUPEEPG_H_
+
+class cSetupEEPG
+{
+public:
+ int OptPat;
+ int OrderInfo;
+ int RatingInfo;
+ int FixEpg;
+ int DisplayMessage;
+ int ProcessEIT;
+#ifdef DEBUG
+ int LogLevel;
+#endif
+
+public:
+ static cSetupEEPG* getInstance();
+
+private:
+ cSetupEEPG (void);
+ cSetupEEPG(cSetupEEPG const&); // copy constructor is private
+ cSetupEEPG& operator=(cSetupEEPG const&); // assignment operator is private
+ static cSetupEEPG* _setupEEPG;
+
+};
+
+#endif /* SETUPEEPG_H_ */