From 403f126e5da6d1811d981d5773d0a0772b99acc1 Mon Sep 17 00:00:00 2001 From: horchi Date: Wed, 20 Dec 2017 07:57:05 +0100 Subject: 2017-12-19 version 1.1.74 (horchi)\n - added: recording detail query to service interface\n\n --- HISTORY.h | 9 +++++--- epg2vdr.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- epg2vdr.h | 2 ++ lib/xml.h | 6 ++++++ recinfofile.c | 28 +++++++++++++++++++++--- recording.c | 6 +++--- service.h | 17 ++++++++++++--- update.h | 3 +++ 8 files changed, 126 insertions(+), 13 deletions(-) diff --git a/HISTORY.h b/HISTORY.h index eeace8b..451689c 100644 --- a/HISTORY.h +++ b/HISTORY.h @@ -5,8 +5,8 @@ * */ -#define _VERSION "1.1.73" -#define VERSION_DATE "22.06.2017" +#define _VERSION "1.1.74" +#define VERSION_DATE "19.12.2017" #define DB_API 4 @@ -19,6 +19,9 @@ /* * ------------------------------------ +2017-12-19 version 1.1.74 (horchi) + - added: recording detail query to service interface + 2017-06-23 version 1.1.73 (horchi) - bugfix: Fixed compile with VDR 2.2.0 - bugfix: Fixed problem with unknown channels @@ -318,7 +321,7 @@ - bugfix: added missing table init 2016-04-23: version 1.0.27 (horchi) - - change: added totoal count dor service interface (ForEachTimer) + - change: added totoal count for service interface (ForEachTimer) 2016-04-22: version 1.0.26 (horchi) - bugfix: fixed set of scrnew on info.epg2vdr changes diff --git a/epg2vdr.c b/epg2vdr.c index 369da42..46f5658 100644 --- a/epg2vdr.c +++ b/epg2vdr.c @@ -423,6 +423,7 @@ cPluginEPG2VDR::cPluginEPG2VDR() useeventsDb = 0; selectTimers = 0; selectEventById = 0; + recordingListDb = 0; } cPluginEPG2VDR::~cPluginEPG2VDR() @@ -448,6 +449,9 @@ int cPluginEPG2VDR::initDb() useeventsDb = new cDbTable(connection, "useevents"); if (useeventsDb->open() != success) return fail; + recordingListDb = new cDbTable(connection, "recordinglist"); + if (recordingListDb->open() != success) return fail; + // ---------- // select // t.*, @@ -509,6 +513,7 @@ int cPluginEPG2VDR::exitDb() delete useeventsDb; useeventsDb = 0; delete timerDb; timerDb = 0; delete vdrDb; vdrDb = 0; + delete recordingListDb; recordingListDb = 0; delete connection; connection = 0; } @@ -864,7 +869,7 @@ bool cPluginEPG2VDR::Service(const char* id, void* data) return true; } - if (strcmp(id, EPG2VDR_TIMER_SERVICE) == 0) // || ..... + if (strcmp(id, EPG2VDR_TIMER_SERVICE) == 0 || strcmp(id, EPG2VDR_REC_DETAIL_SERVICE) == 0) { // Services with direct db access @@ -879,6 +884,13 @@ bool cPluginEPG2VDR::Service(const char* id, void* data) if (ts) return timerService(ts); } + else if (strcmp(id, EPG2VDR_REC_DETAIL_SERVICE) == 0) + { + cEpgRecording_Details_Service_V1* rd = (cEpgRecording_Details_Service_V1*)data; + + if (rd) + return recordingDetails(rd); + } exitDb(); } @@ -919,6 +931,60 @@ int cPluginEPG2VDR::timerService(cEpgTimer_Service_V1* ts) return true; } +//*************************************************************************** +// Recording Details +//*************************************************************************** + +#include + +int cPluginEPG2VDR::recordingDetails(cEpgRecording_Details_Service_V1* rd) +{ + const char* videoBasePath = cVideoDirectory::Name(); + md5Buf md5path; + const cRecording* recording; + int pathOffset = 0; + +#if defined (APIVERSNUM) && (APIVERSNUM >= 20301) + LOCK_RECORDINGS_READ; + const cRecordings* recordings = Recordings; +#else + const cRecordings* recordings = &Recordings; +#endif + + if (!(recording = recordings->GetById(rd->id))) + return false; + + if (strncmp(recording->FileName(), videoBasePath, strlen(videoBasePath)) == 0) + { + pathOffset = strlen(videoBasePath); + + if (*(recording->FileName()+pathOffset) == '/') + pathOffset++; + } + + createMd5(recording->FileName()+pathOffset, md5path); + + recordingListDb->clear(); + + recordingListDb->setValue("MD5PATH", md5path); + recordingListDb->setValue("STARTTIME", recording->Start()); + recordingListDb->setValue("OWNER", Epg2VdrConfig.useCommonRecFolder ? "" : Epg2VdrConfig.uuid); + + cXml xml; + int found = recordingListDb->find(); + + xml.create("epg2vdr"); + + if (found) + cEventDetails::row2Xml(recordingListDb->getRow(), &xml); + + rd->details = xml.toText(); + + recordingListDb->reset(); + + return found; +} + //*************************************************************************** // Initialize //*************************************************************************** diff --git a/epg2vdr.h b/epg2vdr.h index 20b7bf3..a34376a 100644 --- a/epg2vdr.h +++ b/epg2vdr.h @@ -64,6 +64,7 @@ class cPluginEPG2VDR : public cPlugin int exitDb(); int timerService(cEpgTimer_Service_V1* ts); + int recordingDetails(cEpgRecording_Details_Service_V1* rd); private: @@ -72,6 +73,7 @@ class cPluginEPG2VDR : public cPlugin cDbTable* timerDb; cDbTable* vdrDb; cDbTable* useeventsDb; + cDbTable* recordingListDb; cDbStatement* selectTimers; cDbStatement* selectEventById; cMutex mutexTimerService; diff --git a/lib/xml.h b/lib/xml.h index ae4a628..c611d74 100644 --- a/lib/xml.h +++ b/lib/xml.h @@ -8,6 +8,9 @@ * GNU GENERAL PUBLIC LICENSE. See the file COPYING for details. */ +#ifndef __XML_H +#define __XML_H + //*************************************************************************** // Include //*************************************************************************** @@ -46,3 +49,6 @@ class cXml XMLNode* root; XMLPrinter printer; }; + +//*************************************************************************** +#endif // __XML_H diff --git a/recinfofile.c b/recinfofile.c index 6c1b00c..9c48609 100644 --- a/recinfofile.c +++ b/recinfofile.c @@ -118,6 +118,28 @@ int cEventDetails::updateByRow(cDbRow* row) return success; } +//*************************************************************************** +// Row To Xml +//*************************************************************************** + +int cEventDetails::row2Xml(cDbRow* row, cXml* xml) +{ + for (int i = 0; fields[i]; i++) + { + cDbValue* value = row->getValue(fields[i]); + + if (!value || value->isEmpty()) + continue; + + if (value->getField()->hasFormat(cDBS::ffAscii) || value->getField()->hasFormat(cDBS::ffText) || value->getField()->hasFormat(cDBS::ffMText)) + xml->appendElement(fields[i], value->getStrValue()); + else + xml->appendElement(fields[i], value->getIntValue()); + } + + return success; +} + //*************************************************************************** // Update To Row //*************************************************************************** @@ -128,6 +150,9 @@ int cEventDetails::updateToRow(cDbRow* row) for (it = values.begin(); it != values.end(); it++) { + if (!it->first.length()) + continue; + cDbValue* value = row->getValue(it->first.c_str()); if (!value) @@ -136,9 +161,6 @@ int cEventDetails::updateToRow(cDbRow* row) continue; } - if (!it->first.length()) - continue; - if (value->getField()->isString()) value->setValue(it->second.c_str()); else if (value->getField()->isInt()) diff --git a/recording.c b/recording.c index 03d5e66..d22205c 100644 --- a/recording.c +++ b/recording.c @@ -333,8 +333,8 @@ int cUpdate::updateRecordingTable(int fullReload) #endif #if defined (APIVERSNUM) && (APIVERSNUM >= 20301) - LOCK_RECORDINGS_READ; - const cRecordings* recordings = Recordings; + LOCK_RECORDINGS_WRITE; + cRecordings* recordings = Recordings; // cRecordingsLock recordingsLock(false); // const cRecordings* recordings = recordingsLock.Recordings(); #else @@ -352,7 +352,7 @@ int cUpdate::updateRecordingTable(int fullReload) // ---------------- // update ... - for (const cRecording* rec = recordings->First(); rec; rec = recordings->Next(rec)) + for (cRecording* rec = recordings->First(); rec; rec = recordings->Next(rec)) { int insert; int fsk; diff --git a/service.h b/service.h index 0cc14c0..ffe4072 100644 --- a/service.h +++ b/service.h @@ -58,7 +58,7 @@ class cEpgTimer_Interface_V1 : public cTimer }; //*************************************************************************** -// Timer Service Interfaces +// Timer Service Interface //*************************************************************************** struct cEpgTimer_Service_V1 @@ -66,8 +66,19 @@ struct cEpgTimer_Service_V1 std::list epgTimers; }; -#define EPG2VDR_TIMER_UPDATED "Epg2Vdr_Timer_Updated-v1.0" -#define EPG2VDR_TIMER_SERVICE "Epg2Vdr_Timer_Service-v1.0" +//*************************************************************************** +// Recording Detail Service Interface +//*************************************************************************** + +struct cEpgRecording_Details_Service_V1 +{ + int id; + std::string details; +}; + +#define EPG2VDR_TIMER_UPDATED "Epg2Vdr_Timer_Updated-v1.0" +#define EPG2VDR_TIMER_SERVICE "Epg2Vdr_Timer_Service-v1.0" +#define EPG2VDR_REC_DETAIL_SERVICE "Epg2Vdr_RecDetail_Service-v1.0" #ifdef EPG2VDR diff --git a/update.h b/update.h index fe3b796..af90767 100644 --- a/update.h +++ b/update.h @@ -17,6 +17,7 @@ #include "lib/db.h" #include "lib/epgservice.h" #include "lib/vdrlocks.h" +#include "lib/xml.h" #include "epg2vdr.h" #include "parameters.h" @@ -87,6 +88,8 @@ class cEventDetails int updateByRow(cDbRow* row); int updateToRow(cDbRow* row); + static int row2Xml(cDbRow* row, cXml* xml); + private: int changes; -- cgit v1.2.3