diff options
-rw-r--r-- | Make.config | 2 | ||||
-rw-r--r-- | configs/epg.dat | 2 | ||||
-rw-r--r-- | menu.c | 21 | ||||
-rw-r--r-- | menu.h | 6 | ||||
-rw-r--r-- | menusched.c | 81 | ||||
-rw-r--r-- | service.h | 21 |
6 files changed, 113 insertions, 20 deletions
diff --git a/Make.config b/Make.config index 5d52c29..a7e2c8b 100644 --- a/Make.config +++ b/Make.config @@ -33,7 +33,7 @@ CXXFLAGS += -fPIC -Wreturn-type -Wall -Wno-parentheses -Wformat -pedantic \ -Wunused-value -Wunused-but-set-variable -Wunused-function -Wno-variadic-macros \ -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -CXXFLAGS += -D__STDC_FORMAT_MACROS +CXXFLAGS += -std=c++11 -D__STDC_FORMAT_MACROS CFLAGS += $(CXXFLAGS) diff --git a/configs/epg.dat b/configs/epg.dat index 7338ee0..c9ca2f2 100644 --- a/configs/epg.dat +++ b/configs/epg.dat @@ -437,7 +437,7 @@ Table useevents PRODUCER "" sub_producer Text 1000 Data, OTHER "" sub_other Text 2000 Data, DIRECTOR "" sub_director Text 1000 Data, - COMMENTATOR "" sub_commentator Ascii 200 Data, + COMMENTATOR "" sub_commentator Ascii 200 Data, SCREENPLAY "" sub_screenplay Ascii 500 Data, CAMERA "" sub_camera Text 1000 Data, MUSIC "" sub_music Ascii 250 Data, @@ -34,6 +34,7 @@ cMenuDb::cMenuDb() useeventsDb = 0; selectTimers = 0; + selectEventById = 0; selectMaxUpdSp = 0; selectTimerById = 0; selectActiveVdrs = 0; @@ -165,6 +166,25 @@ int cMenuDb::initDb() status += selectTimers->prepare(); + // select event by useid + + selectEventById = new cDbStatement(useeventsDb); + + // select * from eventsview + // where useid = ? + // and updflg in (.....) + + 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(); + + // select // t.*, // t.day + t.starttime div 100 * 60 * 60 + t.starttime % 100 * 60, @@ -403,6 +423,7 @@ int cMenuDb::exitDb() cParameters::exitDb(); delete timerDb; timerDb = 0; + delete selectEventById; selectEventById = 0; delete vdrDb; vdrDb = 0; delete timerDoneDb; timerDoneDb = 0; delete userDb; userDb = 0; @@ -58,6 +58,7 @@ class cMenuDb : public cParameters friend class cMenuEpgMatchRecordings; friend class cEpgMenuSearchResult; friend class cMenuSetupEPG2VDR; + friend class cMenuEpgScheduleItem; public: @@ -116,6 +117,7 @@ class cMenuDb : public cParameters cDbTable* useeventsDb; cDbStatement* selectTimers; + cDbStatement* selectEventById; cDbStatement* selectMaxUpdSp; cDbStatement* selectTimerById; cDbStatement* selectActiveVdrs; @@ -410,7 +412,7 @@ class cMenuEpgScheduleItem : public cOsdItem virtual bool Update(bool Force = false); virtual void SetMenuItem(cSkinDisplayMenu *DisplayMenu, int Index, bool Current, bool Selectable); - const cEvent* event; + cEpgEvent* event; const cChannel* channel; bool withDate; int timerMatch; @@ -418,7 +420,7 @@ class cMenuEpgScheduleItem : public cOsdItem private: cMenuDb* menuDb; - cEpgEvent* ownEvent; + int eventReady; static eScheduleSortMode sortMode; }; diff --git a/menusched.c b/menusched.c index 82f4a31..8ed2b64 100644 --- a/menusched.c +++ b/menusched.c @@ -196,7 +196,8 @@ cMenuEpgScheduleItem::eScheduleSortMode cMenuEpgScheduleItem::sortMode = ssmAllT cMenuEpgScheduleItem::cMenuEpgScheduleItem(cMenuDb* db, const cEvent* Event, const cChannel* Channel, bool WithDate) { - ownEvent = 0; + event = 0; + eventReady = no; menuDb = db; if (Event) @@ -211,17 +212,13 @@ cMenuEpgScheduleItem::cMenuEpgScheduleItem(cMenuDb* db, const cEvent* Event, fflush(inMem); fclose(inMem); - ownEvent = new cEpgEvent(Event->EventID()); + event = new cEpgEvent(Event->EventID()); inMem = fmemopen(bp, strlen(bp), "r"); - ownEvent->Read(inMem); + event->Read(inMem); fclose(inMem); - - ownEvent->setImageCount(1); } } - event = ownEvent ? ownEvent : Event; - channel = Channel; withDate = WithDate; timerMatch = tmNone; @@ -230,7 +227,7 @@ cMenuEpgScheduleItem::cMenuEpgScheduleItem(cMenuDb* db, const cEvent* Event, cMenuEpgScheduleItem::~cMenuEpgScheduleItem() { - delete ownEvent; + delete event; } //*************************************************************************** @@ -306,12 +303,78 @@ bool cMenuEpgScheduleItem::Update(bool Force) } //*************************************************************************** -// SetMenuItem +// Set Menu Item //*************************************************************************** void cMenuEpgScheduleItem::SetMenuItem(cSkinDisplayMenu* DisplayMenu, int Index, bool Current, bool Selectable) { + if (event && !eventReady) + { + // lookup and enrich event with data of events table + + 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(); + eventReady = yes; + } + if (!DisplayMenu->SetItemEvent(event, Index, Current, Selectable, channel, withDate, (eTimerMatch)timerMatch)) { @@ -12,23 +12,24 @@ #include <vdr/epg.h> #include <list> +#include <map> //*************************************************************************** -// Timer - Skin Interface +// Event - Skin Interface //*************************************************************************** class cEpgEvent_Interface_V1 : public cEvent { public: - cEpgEvent_Interface_V1(tEventID EventID) - : cEvent(EventID) { imageCount = 0; } + cEpgEvent_Interface_V1(tEventID EventID) : cEvent(EventID) {} - int getImageCount() const { return imageCount; } + const char* getValue(const char* name) { return epg2vdrData[name].c_str(); } + const std::map<std::string,std::string>* getValues() const { return &epg2vdrData; } protected: - int imageCount; + std::map<std::string,std::string> epg2vdrData; }; //*************************************************************************** @@ -75,7 +76,7 @@ class cEpgTimer_Interface_V1 : public cTimer }; //*************************************************************************** -// Timer - Service Interface +// Service Interface //*************************************************************************** struct cEpgTimer_Service_V1 @@ -89,6 +90,10 @@ struct cEpgTimer_Service_V1 #ifdef EPG2VDR //*************************************************************************** +// Internal +//*************************************************************************** + +//*************************************************************************** // Class cEpgEvent //*************************************************************************** @@ -100,7 +105,9 @@ class cEpgEvent : public cEpgEvent_Interface_V1 virtual ~cEpgEvent() {} bool Read(FILE *f); - void setImageCount(int count) { imageCount = count; } + + void setValue(const char* name, const char* value) { epg2vdrData[name] = value; } + void setValue(const char* name, long value) { epg2vdrData[name] = std::to_string(value); } }; //*************************************************************************** |