summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--HISTORY.h9
-rw-r--r--epg2vdr.c65
-rw-r--r--epg2vdr.h17
-rw-r--r--menu.c5
-rw-r--r--menusched.c57
-rw-r--r--service.h42
-rw-r--r--ttools.c93
-rw-r--r--ttools.h3
8 files changed, 208 insertions, 83 deletions
diff --git a/HISTORY.h b/HISTORY.h
index 860be1f..f9f355f 100644
--- a/HISTORY.h
+++ b/HISTORY.h
@@ -5,8 +5,8 @@
*
*/
-#define _VERSION "1.1.47"
-#define VERSION_DATE "14.03.2017"
+#define _VERSION "1.1.48"
+#define VERSION_DATE "16.03.2017"
#define DB_API 4
@@ -19,7 +19,10 @@
/*
* ------------------------------------
-2017-03-146: version 1.1.47 (horchi)
+2017-03-16: version 1.1.48 (horchi)
+ - added: Further improvement of extended skins interface
+
+2017-03-14: version 1.1.47 (horchi)
- added: Started extended event interface for skins
2017-03-06: version 1.1.46 (horchi)
diff --git a/epg2vdr.c b/epg2vdr.c
index 6858d8d..cb1d6ee 100644
--- a/epg2vdr.c
+++ b/epg2vdr.c
@@ -415,6 +415,9 @@ cPluginEPG2VDR::cPluginEPG2VDR()
connection = 0;
timerDb = 0;
vdrDb = 0;
+ useeventsDb = 0;
+ selectTimers = 0;
+ selectEventById = 0;
}
cPluginEPG2VDR::~cPluginEPG2VDR()
@@ -437,6 +440,9 @@ int cPluginEPG2VDR::initDb()
vdrDb = new cDbTable(connection, "vdrs");
if (vdrDb->open() != success) return fail;
+ useeventsDb = new cDbTable(connection, "useevents");
+ if (useeventsDb->open() != success) return fail;
+
// ----------
// select
// t.*,
@@ -466,6 +472,23 @@ int cPluginEPG2VDR::initDb()
status += selectTimers->prepare();
+ // select event by useid
+ // select * from eventsview
+ // where useid = ?
+ // and updflg in (.....)
+
+ selectEventById = new cDbStatement(useeventsDb);
+
+ selectEventById->build("select ");
+ selectEventById->bindAllOut();
+ selectEventById->build(" from %s where ", useeventsDb->TableName());
+ selectEventById->bind("USEID", cDBS::bndIn | cDBS::bndSet);
+ selectEventById->build(" and %s in (%s)",
+ useeventsDb->getField("UPDFLG")->getDbName(),
+ Us::getNeeded());
+
+ status += selectEventById->prepare();
+
return status;
}
@@ -473,8 +496,13 @@ int cPluginEPG2VDR::exitDb()
{
if (connection)
{
+ delete selectEventById; selectEventById = 0;
+ delete selectTimers; selectTimers = 0;
+
+ delete useeventsDb; useeventsDb = 0;
delete timerDb; timerDb = 0;
delete vdrDb; vdrDb = 0;
+
delete connection; connection = 0;
}
@@ -831,6 +859,14 @@ bool cPluginEPG2VDR::Service(const char* id, void* data)
return timerService(ts);
}
+ else if (strcmp(id, EPG2VDR_EVENT_SERVICE) == 0)
+ {
+ cEpgEvent_Service_V1* es = (cEpgEvent_Service_V1*)data;
+
+ if (es)
+ return eventService(es);
+ }
+
return false;
}
@@ -872,6 +908,35 @@ int cPluginEPG2VDR::timerService(cEpgTimer_Service_V1* ts)
}
//***************************************************************************
+// Event Service
+//***************************************************************************
+
+int cPluginEPG2VDR::eventService(cEpgEvent_Service_V1* es)
+{
+ int status = false;
+
+ es->out = 0;
+
+ if (!es->in)
+ return false;
+
+ if ((status = initDb()) == success)
+ {
+ es->out = createEventCopy(es->in);
+
+ useeventsDb->clear();
+ useeventsDb->setValue("USEID", (int)es->in->EventID());
+
+ enrichEvent((cEpgEvent*)es->out, useeventsDb, selectEventById);
+ status = true;
+ }
+
+ exitDb();
+
+ return status;
+}
+
+//***************************************************************************
// Initialize
//***************************************************************************
diff --git a/epg2vdr.h b/epg2vdr.h
index d2f05a2..c4e341b 100644
--- a/epg2vdr.h
+++ b/epg2vdr.h
@@ -32,9 +32,9 @@ static const char* MAINMENUENTRY = tr("EPG and Timer Service");
// cPluginEPG2VDR
//***************************************************************************
-cOsdMenu* newWathsOn();
+// cOsdMenu* newWathsOn();
-class cPluginEPG2VDR : public cPlugin
+class cPluginEPG2VDR : public cPlugin
{
public:
@@ -51,7 +51,7 @@ class cPluginEPG2VDR : public cPlugin
virtual bool Initialize(void);
virtual bool Start(void);
virtual cString Active(void);
- virtual const char* MainMenuEntry(void)
+ virtual const char* MainMenuEntry(void)
{ return Epg2VdrConfig.mainmenuVisible ? MAINMENUENTRY : 0; }
virtual cOsdObject* MainMenuAction(void);
virtual cMenuSetupPage* SetupMenu(void);
@@ -59,20 +59,23 @@ class cPluginEPG2VDR : public cPlugin
virtual void Stop();
virtual void DisplayMessage(const char* s);
virtual time_t WakeupTime(void);
-
+
protected:
-
+
int initDb();
int exitDb();
int timerService(cEpgTimer_Service_V1* ts);
-
+ int eventService(cEpgEvent_Service_V1* es);
+
private:
-
+
cDbConnection* connection;
cDbTable* timerDb;
cDbTable* vdrDb;
+ cDbTable* useeventsDb;
cDbStatement* selectTimers;
+ cDbStatement* selectEventById;
cMutex mutexTimerService;
};
diff --git a/menu.c b/menu.c
index e44043c..248dc71 100644
--- a/menu.c
+++ b/menu.c
@@ -167,13 +167,12 @@ int cMenuDb::initDb()
status += selectTimers->prepare();
// select event by useid
-
- selectEventById = new cDbStatement(useeventsDb);
-
// select * from eventsview
// where useid = ?
// and updflg in (.....)
+ selectEventById = new cDbStatement(useeventsDb);
+
selectEventById->build("select ");
selectEventById->bindAllOut();
selectEventById->build(" from %s where ", useeventsDb->TableName());
diff --git a/menusched.c b/menusched.c
index 8ed2b64..6a8005b 100644
--- a/menusched.c
+++ b/menusched.c
@@ -316,62 +316,7 @@ void cMenuEpgScheduleItem::SetMenuItem(cSkinDisplayMenu* DisplayMenu,
menuDb->useeventsDb->clear();
menuDb->useeventsDb->setValue("USEID", (int)event->EventID());
- if (menuDb->selectEventById->find())
- {
- const char* fields[] =
- {
- "imagecount", // int
- "numrating", // int
- "year", // ascii 10
- "category", // ascii 50
- "country", // ascii 50
- "audio", // ascii 50
-
- "txtrating", // ascii 100
- "genre", // ascii 100
- "flags", // ascii 100
- "commentator", // ascii 200
- "tipp", // ascii 250
- "rating", // ascii 250
- "moderator", // ascii 250
- "music", // ascii 250
- "screenplay", // ascii 500
- "shortreview", // ascii 500
-
- "guest", // text 1000
- "producer", // text 1000
- "camera", // text 1000
- "director", // text 1000
- "topic", // ascii 1000
-
- "other", // text 2000
- "shortdescription", // mtext 3000
- "actor", // mtext 5000
- "longdescription", // mtext 25000
- "cntlongdescription", // MText 25000
-
- 0
- };
-
- for (int i = 0; fields[i]; i++)
- {
- cDbValue* value = menuDb->useeventsDb->getValue(fields[i]);
-
- if (!value || value->isEmpty())
- continue;
-
- if (value->getField()->hasFormat(cDBS::ffAscii) || value->getField()->hasFormat(cDBS::ffText) || value->getField()->hasFormat(cDBS::ffMText))
- event->setValue(fields[i], value->getStrValue());
- else
- event->setValue(fields[i], value->getIntValue());
- }
- }
- else
- {
- tell(0, "Info: Event (%d) not found", event->EventID());
- }
-
- menuDb->selectEventById->freeResult();
+ enrichEvent(event, menuDb->useeventsDb, menuDb->selectEventById);
eventReady = yes;
}
diff --git a/service.h b/service.h
index 122986f..7f60415 100644
--- a/service.h
+++ b/service.h
@@ -47,18 +47,18 @@ class cEpgTimer_Interface_V1 : public cTimer
: cTimer(Instant, Pause, (cChannel*)Channel) {}
#endif
- long TimerId() { return timerid; }
- long EventId() { return eventid; }
- const char* VdrName() { return vdrName ? vdrName : ""; }
- const char* VdrUuid() { return vdrUuid ? vdrUuid : ""; }
- int isVdrRunning() { return vdrRunning; }
- int isLocal() { return local; }
- int isRemote() { return !isLocal(); }
-
- char State() { return state; }
- int hasState(char s) const { return state == s; }
- const char* StateInfo() { return stateInfo ? stateInfo : ""; }
- char Action() { return action; }
+ long TimerId() const { return timerid; }
+ long EventId() const { return eventid; }
+ const char* VdrName() const { return vdrName ? vdrName : ""; }
+ const char* VdrUuid() const { return vdrUuid ? vdrUuid : ""; }
+ int isVdrRunning() const { return vdrRunning; }
+ int isLocal() const { return local; }
+ int isRemote() const { return !isLocal(); }
+
+ char State() const { return state; }
+ int hasState(char s) const { return state == s; }
+ const char* StateInfo() const { return stateInfo ? stateInfo : ""; }
+ char Action() const { return action; }
protected:
@@ -76,7 +76,7 @@ class cEpgTimer_Interface_V1 : public cTimer
};
//***************************************************************************
-// Service Interface
+// Timer Service Interfaces
//***************************************************************************
struct cEpgTimer_Service_V1
@@ -87,10 +87,24 @@ struct cEpgTimer_Service_V1
#define EPG2VDR_TIMER_UPDATED "Epg2Vdr_Timer_Updated-v1.0"
#define EPG2VDR_TIMER_SERVICE "Epg2Vdr_Timer_Service-v1.0"
+//***************************************************************************
+// Event Service Interfaces
+//***************************************************************************
+
+struct cEpgEvent_Service_V1
+{
+ const cEvent* in;
+ cEpgEvent_Interface_V1* out;
+};
+
+#define EPG2VDR_EVENT_SERVICE "Epg2Vdr_Event_Service-v1.0"
+
#ifdef EPG2VDR
//***************************************************************************
-// Internal
+//***************************************************************************
+//***************************************************************************
+// Internal Stuff
//***************************************************************************
//***************************************************************************
diff --git a/ttools.c b/ttools.c
index c30f960..0f2e686 100644
--- a/ttools.c
+++ b/ttools.c
@@ -581,3 +581,96 @@ int updateTimerObjectFromRow(cTimer* timer, cDbRow* timerRow, const cEvent* even
return done;
}
+
+//***************************************************************************
+// Enrich Event
+//***************************************************************************
+
+int enrichEvent(cEpgEvent* event, cDbTable* table, cDbStatement* select)
+{
+ if (select->find())
+ {
+ const char* fields[] =
+ {
+ "imagecount", // int
+ "numrating", // int
+ "year", // ascii 10
+ "category", // ascii 50
+ "country", // ascii 50
+ "audio", // ascii 50
+
+ "txtrating", // ascii 100
+ "genre", // ascii 100
+ "flags", // ascii 100
+ "commentator", // ascii 200
+ "tipp", // ascii 250
+ "rating", // ascii 250
+ "moderator", // ascii 250
+ "music", // ascii 250
+ "screenplay", // ascii 500
+ "shortreview", // ascii 500
+
+ "guest", // text 1000
+ "producer", // text 1000
+ "camera", // text 1000
+ "director", // text 1000
+ "topic", // ascii 1000
+
+ "other", // text 2000
+ "shortdescription", // mtext 3000
+ "actor", // mtext 5000
+ "longdescription", // mtext 25000
+ "cntlongdescription", // MText 25000
+
+ 0
+ };
+
+ for (int i = 0; fields[i]; i++)
+ {
+ cDbValue* value = table->getValue(fields[i]);
+
+ if (!value || value->isEmpty())
+ continue;
+
+ if (value->getField()->hasFormat(cDBS::ffAscii) || value->getField()->hasFormat(cDBS::ffText) || value->getField()->hasFormat(cDBS::ffMText))
+ event->setValue(fields[i], value->getStrValue());
+ else
+ event->setValue(fields[i], value->getIntValue());
+ }
+ }
+ else
+ {
+ tell(0, "Info: Event (%d) not found", event->EventID());
+ }
+
+ select->freeResult();
+
+ return done;
+}
+
+//***************************************************************************
+// Copy Event
+//***************************************************************************
+
+cEpgEvent* createEventCopy(const cEvent* event)
+{
+ FILE* inMem = 0;
+ char* bp;
+ size_t size;
+
+ if (inMem = open_memstream(&bp, &size))
+ {
+ event->Dump(inMem, "", yes);
+ fflush(inMem);
+ fclose(inMem);
+
+ cEpgEvent* epgEvent = new cEpgEvent(event->EventID());
+ inMem = fmemopen(bp, strlen(bp), "r");
+ epgEvent->Read(inMem);
+ fclose(inMem);
+
+ return epgEvent;
+ }
+
+ return 0;
+}
diff --git a/ttools.h b/ttools.h
index 07f9382..9ee7171 100644
--- a/ttools.h
+++ b/ttools.h
@@ -37,6 +37,9 @@ int updateRowByTimer(cDbRow* timerDb, const cTimer* t);
cEpgTimer* newTimerObjectFromRow(cDbRow* timerRow, cDbRow* vdrRow);
int updateTimerObjectFromRow(cTimer* timer, cDbRow* timerRow, const cEvent* event);
+int enrichEvent(cEpgEvent* event, cDbTable* table, cDbStatement* select);
+cEpgEvent* createEventCopy(const cEvent* event);
+
//***************************************************************************
#endif // _TTOOLS_H_