diff options
author | horchi <vdr@jwendel.de> | 2018-03-09 17:38:03 +0100 |
---|---|---|
committer | horchi <vdr@jwendel.de> | 2018-03-09 17:38:03 +0100 |
commit | bc845e984ba0790bb160c80578ed8ddde2637735 (patch) | |
tree | fd0634486fac759ec9a44e3a58795258a6cc2519 /lib | |
parent | f7db728bcfa4d1663b07873bfa364ccbb9bfb1ce (diff) | |
download | vdr-plugin-epg2vdr-1.1.93.tar.gz vdr-plugin-epg2vdr-1.1.93.tar.bz2 |
2018-03-09 version 1.1.93 (horchi)\n - added: Menu for matching 'jobs' (timersdone) of search timer results, with delete option\n - added: some german translations\n - added: optional (configurable) osd notification on timer change\n\n1.1.93
Diffstat (limited to 'lib')
-rw-r--r-- | lib/db.c | 102 | ||||
-rw-r--r-- | lib/db.h | 4 | ||||
-rw-r--r-- | lib/dbdict.h | 68 | ||||
-rw-r--r-- | lib/searchtimer.c | 74 | ||||
-rw-r--r-- | lib/searchtimer.h | 1 |
5 files changed, 114 insertions, 135 deletions
@@ -13,6 +13,57 @@ #include "db.h" //*************************************************************************** +// Copy Values +//*************************************************************************** + +void cDbRow::copyValues(const cDbRow* rowFrom, int typesFilter) +{ + std::map<std::string, cDbFieldDef*>::iterator f; + + for (f = tableDef->dfields.begin(); f != tableDef->dfields.end(); f++) + { + cDbFieldDef* fld = f->second; + + if (rowFrom->isNull(fld)) // skip where source field is NULL + continue; + + if (!(typesFilter & fld->getType())) // Filter + continue; + + switch (fld->getFormat()) + { + case ffAscii: + case ffText: + case ffMText: + case ffMlob: + setValue(fld, rowFrom->getStrValue(fld)); + break; + + case ffFloat: + setValue(fld, rowFrom->getFloatValue(fld)); + break; + + case ffDateTime: + setValue(fld, rowFrom->getTimeValue(fld)); + break; + + case ffBigInt: + case ffUBigInt: + setBigintValue(fld, rowFrom->getBigintValue(fld)); + break; + + case ffInt: + case ffUInt: + setValue(fld, rowFrom->getIntValue(fld)); + break; + + default: + tell(0, "Fatal: Unhandled field type %d", fld->getFormat()); + } + } +} + +//*************************************************************************** // DB Statement //*************************************************************************** @@ -1310,57 +1361,6 @@ int cDbTable::checkIndex(const char* idxName, int& fieldCount) } //*************************************************************************** -// Copy Values -//*************************************************************************** - -void cDbTable::copyValues(cDbRow* r, int typesFilter) -{ - std::map<std::string, cDbFieldDef*>::iterator f; - - for (f = tableDef->dfields.begin(); f != tableDef->dfields.end(); f++) - { - cDbFieldDef* fld = f->second; - - if (r->isNull(fld)) // skip where source field is NULL - continue; - - if (!(typesFilter & fld->getType())) // Filter - continue; - - switch (fld->getFormat()) - { - case ffAscii: - case ffText: - case ffMText: - case ffMlob: - row->setValue(fld, r->getStrValue(fld)); - break; - - case ffFloat: - row->setValue(fld, r->getFloatValue(fld)); - break; - - case ffDateTime: - row->setValue(fld, r->getTimeValue(fld)); - break; - - case ffBigInt: - case ffUBigInt: - row->setBigintValue(fld, r->getBigintValue(fld)); - break; - - case ffInt: - case ffUInt: - row->setValue(fld, r->getIntValue(fld)); - break; - - default: - tell(0, "Fatal unhandled field type %d", fld->getFormat()); - } - } -} - -//*************************************************************************** // SQL Error //*************************************************************************** @@ -644,6 +644,8 @@ class cDbRow : public cDbService return s; } + void copyValues(const cDbRow* rFrom, int types = ftData); + virtual cDbFieldDef* getField(int id) { return tableDef->getField(id); } virtual cDbFieldDef* getField(const char* name) { return tableDef->getField(name); } virtual cDbFieldDef* getFieldByDbName(const char* dbname) { return tableDef->getFieldByDbName(dbname); } @@ -1133,7 +1135,7 @@ class cDbTable : public cDbService void setBigintValue(const char* n, int64_t value) { row->setBigintValue(n, value); } void setCharValue(const char* n, char value) { row->setCharValue(n, value); } - void copyValues(cDbRow* r, int types = ftData); + // void copyValues(cDbRow* r, int types = ftData); int hasValue(cDbFieldDef* f, const char* value) { return row->hasValue(f, value); } int hasCharValue(cDbFieldDef* f, char value) { return row->hasCharValue(f, value); } diff --git a/lib/dbdict.h b/lib/dbdict.h index 2999390..94aab67 100644 --- a/lib/dbdict.h +++ b/lib/dbdict.h @@ -25,10 +25,10 @@ typedef int (*FilterFromName)(const char* name); class _casecmp_ { public: - + bool operator() (const std::string& a, const std::string& b) const - { - return strcasecmp(a.c_str(), b.c_str()) < 0; + { + return strcasecmp(a.c_str(), b.c_str()) < 0; } }; @@ -85,7 +85,7 @@ class cDbService enum ProcType { - ptProcedure, + ptProcedure, ptFunction }; @@ -100,7 +100,7 @@ class cDbService static const char* formats[]; static const char* dictFormats[]; - static int toType(const char* type); + static int toType(const char* type); static const char* toName(FieldType type, char* buf); static TypeDef types[]; }; @@ -117,8 +117,8 @@ class cDbFieldDef : public cDbService friend class cDbDict; - cDbFieldDef() - { + cDbFieldDef() + { name = 0; dbname = 0, format = ffUnknown; @@ -131,7 +131,7 @@ class cDbFieldDef : public cDbService } cDbFieldDef(const char* n, const char* dn, FieldFormat f, int s, int t, int flt = 0xFFFF) - { + { name = strdup(n); dbname = strdup(dn); format = f; @@ -144,13 +144,13 @@ class cDbFieldDef : public cDbService } ~cDbFieldDef() { free(name); free(dbname); free(description); free(dbdescription); free(def); } - + int getIndex() { return index; } const char* getName() { return name; } int hasName(const char* n) { return strcasecmp(n, name) == 0; } int hasDbName(const char* n) { return strcasecmp(n, dbname) == 0; } - const char* getDescription() { return description; } - const char* getDbDescription() { return dbdescription; } + const char* getDescription() { return description; } + const char* getDbDescription() { return dbdescription; } const char* getDbName() { return dbname; } int getSize() { return size; } FieldFormat getFormat() { return format; } @@ -161,7 +161,7 @@ class cDbFieldDef : public cDbService int hasType(int types) { return types & type; } int hasFormat(int f) { return format == f; } - int isString() { return format == ffAscii || format == ffText || + int isString() { return format == ffAscii || format == ffText || format == ffMText || format == ffMlob; } int isInt() { return format == ffInt || format == ffUInt; } int isBigInt() { return format == ffBigInt || format == ffUBigInt; } @@ -178,9 +178,9 @@ class cDbFieldDef : public cDbService { if (!buf) return 0; - + sprintf(buf, "%s", toString(format)); - + if (format != ffMlob) { if (!size) @@ -192,16 +192,16 @@ class cDbFieldDef : public cDbService else if (format == ffFloat) size = 10; } - + if (format == ffFloat) sprintf(eos(buf), "(%d,%d)", size/10 + size%10, size%10); // 62 -> 8,2 else if (format == ffInt || format == ffUInt || format == ffBigInt || format == ffUBigInt || format == ffAscii) sprintf(eos(buf), "(%d)", size); - + if (format == ffUInt || format == ffUBigInt) sprintf(eos(buf), " unsigned"); } - + return buf; } @@ -216,16 +216,16 @@ class cDbFieldDef : public cDbService return yes; } - void show() - { - char colFmt[100]; + void show() + { + char colFmt[100]; char fType[100]; char tmp[100]; sprintf(fType, "(%s)", toName((FieldType)type, tmp)); - - tell(0, "%-20s %-25s %-17s %-20s (0x%04X) default '%s' '%s'", name, dbname, - toColumnFormat(colFmt), fType, filter, notNull(def, ""), description); + + tell(0, "%-20s %-25s %-17s %-20s (0x%04X) default '%s' '%s'", name, dbname, + toColumnFormat(colFmt), fType, filter, notNull(def, ""), description); } protected: @@ -270,7 +270,7 @@ class cDbIndexDef for (uint i = 0; i < dfields.size(); i++) s += dfields[i]->getName() + std::string(" "); - s.erase(s.find_last_not_of(' ')+1); + s.erase(s.find_last_not_of(' ')+1); tell(0, "Index %-25s (%s)", getName(), s.c_str()); } @@ -296,8 +296,8 @@ class cDbTableDef : public cDbService cDbTableDef(const char* n) { name = strdup(n); } - ~cDbTableDef() - { + ~cDbTableDef() + { for (uint i = 0; i < indices.size(); i++) delete indices[i]; @@ -307,17 +307,17 @@ class cDbTableDef : public cDbService clear(); } - const char* getName() { return name; } + const char* getName() { return name; } int fieldCount() { return dfields.size(); } cDbFieldDef* getField(int id) { return _dfields[id]; } - cDbFieldDef* getField(const char* fname, int silent = no) - { + cDbFieldDef* getField(const char* fname, int silent = no) + { std::map<std::string, cDbFieldDef*, _casecmp_>::iterator f; if ((f = dfields.find(fname)) != dfields.end()) return f->second; - + if (!silent) tell(0, "Fatal: Missing definition of field '%s.%s' in dictionary!", name, fname); @@ -325,7 +325,7 @@ class cDbTableDef : public cDbService } cDbFieldDef* getFieldByDbName(const char* dbname) - { + { std::map<std::string, cDbFieldDef*, _casecmp_>::iterator it; for (it = dfields.begin(); it != dfields.end(); it++) @@ -333,7 +333,7 @@ class cDbTableDef : public cDbService if (it->second->hasDbName(dbname)) return it->second; } - + tell(5, "Fatal: Missing definition of field '%s.%s' in dictionary!", name, dbname); return 0; @@ -362,7 +362,7 @@ class cDbTableDef : public cDbService { if (f->second) delete f->second; - + dfields.erase(f); } } @@ -422,7 +422,7 @@ class cDbDict : public cDbService dtFormat, dtSize, dtType, - + dtCount }; diff --git a/lib/searchtimer.c b/lib/searchtimer.c index 971230f..f0c32d5 100644 --- a/lib/searchtimer.c +++ b/lib/searchtimer.c @@ -911,65 +911,41 @@ int cSearchTimer::prepareDoneSelect(cDbRow* useeventsRow, int repeatfields, cDbS selectDoneTimer->build(" from %s where ", timersDoneDb->TableName()); // retry only 'F'ailed and re'J'ected timers, don't retry 'D'eleted timers sice they are deleted by user + /* + select id, state, title,comptitle, shorttext,compshorttext from timersdone where + state not in ('F','J') + and + (field('DERSTAATSANWALTDASLUDER', ifnull(comptitle,''),ifnull(episodecompshortname,'')) > 0 + or field('',ifnull(comptitle,''),ifnull(episodecompshortname,'NoShortnameAvailable')) > 0) + and + (field('',ifnull(compshorttext,''),ifnull(episodecomppartname,'')) > 0 + or field('',ifnull(compshorttext,''),ifnull(episodecomppartname,'')) > 0); + */ selectDoneTimer->build(" %s not in ('F','J')", // mysql ignoring case by default! timersDoneDb->getField("STATE")->getDbName()); - for (int i = 0; repeadCheckField[i]; i++) + if (repeatfields & sfTitle || repeatfields & sfFolge) // 'Folge' vergelichen und 'Titel' nicht macht keinen Sinn { - const char* fieldName = repeadCheckFieldName[i]; - - if (!timersDoneDb->getField(fieldName)) - tell(0, "AUTOTIMER: Search (for 'done' check) field '%s' not known!", - fieldName); - - else if (repeatfields & repeadCheckField[i]) - { - // specical handling for episode, use EPISODECOMPSHORTNAME instead (if not null)! - - if (repeadCheckField[i] == sfTitle) - { - if (!useeventsRow->getValue("EPISODECOMPSHORTNAME")->isNull()) - fieldName = "EPISODECOMPSHORTNAME"; - if (!useeventsRow->getValue("EPISODECOMPPARTNAME")->isNull()) - fieldName = "EPISODECOMPPARTNAME"; - } - - if (repeadCheckField[i] == sfFolge) - { - if (!useeventsRow->getValue("EPISODECOMPSHORTNAME")->isNull()) - fieldName = "EPISODECOMPSHORTNAME"; - } - - selectDoneTimer->bind(timersDoneDb->getField(fieldName), - cDBS::bndIn | cDBS::bndSet, " and "); + selectDoneTimer->build(" and (field('%s', ifnull(comptitle,''),ifnull(episodecompshortname,'')) > 0" + " or field('%s',ifnull(comptitle,''),ifnull(episodecompshortname,'NoShortnameAvailable')) > 0)", + useeventsRow->getStrValue("COMPTITLE"), useeventsRow->getStrValue("EPISODECOMPSHORTNAME")); + } - chkFields += " " + std::string(fieldName); - } + if (repeatfields & sfFolge) + { + selectDoneTimer->build(" and (field('%s',ifnull(compshorttext,'NoShortnameAvailable'),ifnull(episodecomppartname,'NoShortnameAvailable')) > 0" + " or field('%s',ifnull(compshorttext,'NoShortnameAvailable'),ifnull(episodecomppartname,'NoShortnameAvailable')) > 0)", + useeventsRow->getStrValue("COMPSHORTTEXT"), useeventsRow->getStrValue("EPISODECOMPPARTNAME")); } if (selectDoneTimer->prepare() != success) { - tell(0, "AUTOTIMER: Prepare of statement for 'done' check failed, skipping"); - return fail; + tell(0, "Error: AUTOTIMER: Prepare of statement for 'done' check failed, skipping"); + return yes; } timersDoneDb->clear(); - timersDoneDb->setValue("COMPTITLE", useeventsRow->getStrValue("COMPTITLE")); - - if (!useeventsRow->getValue("COMPSHORTTEXT")->isEmpty()) - timersDoneDb->setValue("COMPSHORTTEXT", useeventsRow->getStrValue("COMPSHORTTEXT")); - - if (!useeventsRow->getValue("EPISODECOMPNAME")->isEmpty()) - timersDoneDb->setValue("EPISODECOMPNAME", useeventsRow->getStrValue("EPISODECOMPNAME")); - if (!useeventsRow->getValue("EPISODECOMPSHORTNAME")->isEmpty()) - timersDoneDb->setValue("EPISODECOMPSHORTNAME", useeventsRow->getStrValue("EPISODECOMPSHORTNAME")); - - if (!useeventsRow->getValue("EPISODECOMPPARTNAME")->isEmpty()) - timersDoneDb->setValue("EPISODECOMPPARTNAME", useeventsRow->getStrValue("EPISODECOMPPARTNAME")); - - if (!useeventsRow->getValue("COMPLONGDESCRIPTION")->isEmpty()) - timersDoneDb->setValue("COMPLONGDESCRIPTION", useeventsRow->getStrValue("COMPLONGDESCRIPTION")); select = selectDoneTimer; @@ -1140,7 +1116,7 @@ int cSearchTimer::modifyCreateTimer(cDbRow* timerRow, int& newid) if (knownTimer) { - timerDb->copyValues(timerRow, cDBS::ftPrimary); + timerDb->getRow()->copyValues(timerRow, cDBS::ftPrimary); if (!timerDb->find()) { @@ -1176,7 +1152,7 @@ int cSearchTimer::modifyCreateTimer(cDbRow* timerRow, int& newid) // create new on other vdr - timerDb->copyValues(timerRow, cDBS::ftData); // takeover all data (can be modified by user) + timerDb->getRow()->copyValues(timerRow, cDBS::ftData); // takeover all data (can be modified by user) timerDb->setValue("ID", 0); timerDb->setCharValue("ACTION", taCreate); status += timerDb->insert(); @@ -1190,7 +1166,7 @@ int cSearchTimer::modifyCreateTimer(cDbRow* timerRow, int& newid) { // create 'C'reate oder 'M'odify request ... - timerDb->copyValues(timerRow, cDBS::ftData); + timerDb->getRow()->copyValues(timerRow, cDBS::ftData); timerDb->setCharValue("ACTION", knownTimer ? taModify : taCreate); diff --git a/lib/searchtimer.h b/lib/searchtimer.h index c99bc6b..07e841a 100644 --- a/lib/searchtimer.h +++ b/lib/searchtimer.h @@ -41,6 +41,7 @@ class cSearchTimer int prepareDoneSelect(cDbRow* useeventsRow, int repeatfields, cDbStatement*& select); cDbStatement* prepareSearchStatement(cDbRow* searchTimer, cDbTable* db); int matchCriterias(cDbRow* searchTimer, cDbRow* event); + cDbTable* getTimersDoneDb() { return timersDoneDb; } private: |