From 8564e12bb661f01a2de996263051d3fc4a5c7e30 Mon Sep 17 00:00:00 2001 From: horchi Date: Thu, 31 Oct 2019 12:17:44 +0100 Subject: dev --- menu.c | 34 ++++++++-------- menu.h | 42 ++++++++++--------- menurec.c | 138 +++++++++++++++++++++++++++++++++++++++++++------------------- 3 files changed, 138 insertions(+), 76 deletions(-) diff --git a/menu.c b/menu.c index a1ae23f..ab286bb 100644 --- a/menu.c +++ b/menu.c @@ -34,22 +34,6 @@ cMenuDb::cMenuDb() recordingListDb = 0; useeventsDb = 0; - selectTimers = 0; - selectEventById = 0; - selectMaxUpdSp = 0; - selectTimerById = 0; - selectActiveVdrs = 0; - selectAllVdrs = 0; - selectAllUser = 0; - selectSearchTimers = 0; - selectSearchTimerByName = 0; - - selectDoneTimerByStateTitleOrder = 0; - selectDoneTimerByStateTimeOrder = 0; - selectRecordingForEvent = 0; - selectRecordingForEventByLv = 0; - selectChannelFromMap = 0; - webLoginEnabled = no; user = "@"; startWithSched = no; @@ -330,6 +314,23 @@ int cMenuDb::initDb() status += selectDoneTimerByStateTimeOrder->prepare(); + // select * + // from recordinglist where + // (state <> 'D' or state is null) + // order by starttime + + selectRecordings = new cDbStatement(recordingListDb); + + selectRecordings->build("select "); + selectRecordings->bindAllOut(); + selectRecordings->build(" from %s where ", recordingListDb->TableName()); + selectRecordings->build(" (%s <> 'D' or %s is null)", + recordingListDb->getField("STATE")->getDbName(), + recordingListDb->getField("STATE")->getDbName()); + selectRecordings->build(" order by %s", recordingListDb->getField("STARTTIME")->getDbName()); + + status += selectRecordings->prepare(); + // select * // from recordinglist where // (state <> 'D' or state is null) @@ -464,6 +465,7 @@ int cMenuDb::exitDb() delete selectDoneTimerByStateTimeOrder; selectDoneTimerByStateTimeOrder = 0; delete selectRecordingForEvent; selectRecordingForEvent = 0; delete selectRecordingForEventByLv; selectRecordingForEventByLv = 0; + delete selectRecordings; selectRecordings = 0; delete selectChannelFromMap; selectChannelFromMap = 0; delete connection; connection = 0; diff --git a/menu.h b/menu.h index 5cb10d2..5553b66 100644 --- a/menu.h +++ b/menu.h @@ -59,6 +59,7 @@ class cMenuDb : public cParameters friend class cEpgMenuSearchResult; friend class cMenuSetupEPG2VDR; friend class cMenuEpgScheduleItem; + friend class cMenuDbRecordings; public: @@ -118,23 +119,24 @@ class cMenuDb : public cParameters cDbTable* recordingListDb; cDbTable* useeventsDb; - cDbStatement* selectTimers; - cDbStatement* selectEventById; - cDbStatement* selectMaxUpdSp; - cDbStatement* selectTimerById; - cDbStatement* selectActiveVdrs; - cDbStatement* selectAllVdrs; - cDbStatement* selectDoneTimerByState; - cDbStatement* selectAllUser; - cDbStatement* selectSearchTimers; - cDbStatement* selectSearchTimerByName; - cDbStatement* selectDoneTimerByStateTitleOrder; - cDbStatement* selectDoneTimerByStateTimeOrder; - cDbStatement* selectRecordingForEvent; - cDbStatement* selectRecordingForEventByLv; - cDbStatement* selectChannelFromMap; - - cSearchTimer* search; + cDbStatement* selectTimers {nullptr}; + cDbStatement* selectEventById {nullptr}; + cDbStatement* selectMaxUpdSp {nullptr}; + cDbStatement* selectTimerById {nullptr}; + cDbStatement* selectActiveVdrs {nullptr}; + cDbStatement* selectAllVdrs {nullptr}; + cDbStatement* selectDoneTimerByState {nullptr}; + cDbStatement* selectAllUser {nullptr}; + cDbStatement* selectSearchTimers {nullptr}; + cDbStatement* selectSearchTimerByName {nullptr}; + cDbStatement* selectDoneTimerByStateTitleOrder {nullptr}; + cDbStatement* selectDoneTimerByStateTimeOrder {nullptr}; + cDbStatement* selectRecordingForEvent {nullptr}; + cDbStatement* selectRecordingForEventByLv {nullptr}; + cDbStatement* selectRecordings {nullptr}; + cDbStatement* selectChannelFromMap {nullptr}; + + cSearchTimer* search {nullptr}; cDbValue valueStartTime; cDbValue timerState; @@ -572,11 +574,11 @@ class cMenuDbRecordings : public cOsdMenu private: - char *base; + char* base; int level; cStateKey recordingsStateKey; int helpKeys; - const cRecordingFilter *filter; + const cRecordingFilter* filter; static cString path; static cString fileName; void SetHelpKeys(void); @@ -588,4 +590,6 @@ class cMenuDbRecordings : public cOsdMenu // eOSState Info(void); eOSState Sort(void); eOSState Commands(eKeys Key = kNone); + + cMenuDb* menuDb {nullptr}; }; diff --git a/menurec.c b/menurec.c index 9837090..11951bb 100644 --- a/menurec.c +++ b/menurec.c @@ -25,45 +25,47 @@ class cMenuDbRecordingItem : public cOsdItem { public: - cMenuDbRecordingItem(const cRecording *Recording, int Level); - ~cMenuDbRecordingItem(); + cMenuDbRecordingItem(cMenuDb* db, const cRecording* Recording, int Level); + virtual ~cMenuDbRecordingItem(); + void IncrementCounter(bool New); const char* Name() const { return name; } int Level() const { return level; } const cRecording* Recording() const { return recording; } - bool IsDirectory() const { return name != NULL; } - void SetRecording(const cRecording *Recording) { recording = Recording; } - virtual void SetMenuItem(cSkinDisplayMenu *DisplayMenu, int Index, bool Current, bool Selectable); + bool IsDirectory() const { return name; } + void SetRecording(const cRecording* Recording) { recording = Recording; } + virtual void SetMenuItem(cSkinDisplayMenu* DisplayMenu, int Index, bool Current, bool Selectable); private: - const cRecording *recording; + const cRecording* recording {nullptr}; int level; - char *name; + char* name {nullptr}; int totalEntries, newEntries; + cMenuDb* menuDb {nullptr}; }; -cMenuDbRecordingItem::cMenuDbRecordingItem(const cRecording* Recording, int Level) +cMenuDbRecordingItem::cMenuDbRecordingItem(cMenuDb* db, const cRecording* Recording, int Level) { - recording = Recording; - level = Level; - name = NULL; - totalEntries = newEntries = 0; - SetText(Recording->Title('\t', true, Level)); + menuDb = db; + recording = Recording; + level = Level; + totalEntries = newEntries = 0; + SetText(Recording->Title('\t', true, Level)); - // a folder? + // a folder? - if (*Text() == '\t') - name = strdup(Text() + 2); // 'Text() + 2' to skip the two '\t' - else - { - // -> actual recording + if (*Text() == '\t') + name = strdup(Text() + 2); // 'Text() + 2' to skip the two '\t' + else + { + // -> actual recording - int Usage = Recording->IsInUse(); + int Usage = Recording->IsInUse(); - if ((Usage & ruDst) != 0 && (Usage & (ruMove | ruCopy)) != 0) - SetSelectable(false); - } + if ((Usage & ruDst) != 0 && (Usage & (ruMove | ruCopy)) != 0) + SetSelectable(false); + } } cMenuDbRecordingItem::~cMenuDbRecordingItem() @@ -95,25 +97,31 @@ cString cMenuDbRecordings::fileName; cMenuDbRecordings::cMenuDbRecordings(const char* Base, int Level, bool OpenSubMenus, const cRecordingFilter* Filter) : cOsdMenu(Base ? Base : tr("Recordings"), 9, 6, 6) { + menuDb = new cMenuDb; + SetMenuCategory(mcRecording); base = Base ? strdup(Base) : NULL; level = Setup.RecordingDirs ? Level : -1; filter = Filter; helpKeys = -1; Display(); // this keeps the higher level menus from showing up briefly when pressing 'Back' during replay - Set(); + + if (menuDb->dbConnected()) + { + Set(); + } if (Current() < 0) SetCurrent(First()); - else if (OpenSubMenus && (cReplayControl::LastReplayed() || *path || *fileName)) - { - if (!*path || Level < strcountchr(path, FOLDERDELIMCHAR)) - { - if (Open(true)) - return; - } - } + // else if (OpenSubMenus && (cReplayControl::LastReplayed() || *path || *fileName)) + // { + // if (!*path || Level < strcountchr(path, FOLDERDELIMCHAR)) + // { + // if (Open(true)) + // return; + // } + // } Display(); SetHelpKeys(); @@ -123,15 +131,18 @@ cMenuDbRecordings::~cMenuDbRecordings() { cMenuDbRecordingItem* ri = (cMenuDbRecordingItem*)Get(Current()); - if (ri) - { - if (!ri->IsDirectory()) - SetRecording(ri->Recording()->FileName()); - } + if (ri && !ri->IsDirectory()) + SetRecording(ri->Recording()->FileName()); + + delete menuDb; free(base); } +//*************************************************************************** +// +//*************************************************************************** + void cMenuDbRecordings::SetHelpKeys(void) { cMenuDbRecordingItem* ri = (cMenuDbRecordingItem*)Get(Current()); @@ -159,14 +170,54 @@ void cMenuDbRecordings::SetHelpKeys(void) } } +//*************************************************************************** +// +//*************************************************************************** + void cMenuDbRecordings::Set(bool Refresh) { if (!cRecordings::GetRecordingsRead(recordingsStateKey)) return ; recordingsStateKey.Remove(); - const char *CurrentRecording = *fileName ? *fileName : cReplayControl::LastReplayed(); - cRecordings *Recordings = cRecordings::GetRecordingsWrite(recordingsStateKey); // write access is necessary for sorting! + cRecordings* Recordings = cRecordings::GetRecordingsWrite(recordingsStateKey); // write access is necessary for sorting! + + Clear(); + + menuDb->recordingListDb->clear(); + + for (int res = menuDb->selectRecordings->find(); res; res = menuDb->selectRecordings->fetch()) + { + char* fileName {nullptr}; + asprintf(&fileName, "%s/%s", cVideoDirectory::Name(), menuDb->recordingListDb->getStrValue("PATH")); + const cRecording* recording = Recordings->GetByName(fileName); + + if (recording) + Add(new cMenuDbRecordingItem(menuDb, recording, 0)); + else + tell(0, "Fatal: Recording for file '%s' not found", fileName); + + free(fileName); + } + + menuDb->selectRecordings->freeResult(); + + recordingsStateKey.Remove(false); // sorting doesn't count as a real modification + + if (Refresh) + Display(); + + return ; + + /* + // ------------------------------------------------------ + + if (!cRecordings::GetRecordingsRead(recordingsStateKey)) + return ; + + recordingsStateKey.Remove(); + const char* CurrentRecording = *fileName ? *fileName : cReplayControl::LastReplayed(); + cRecordings* Recordings = cRecordings::GetRecordingsWrite(recordingsStateKey); // write access is necessary for sorting! cMenuDbRecordingItem *LastItem = NULL; if (!CurrentRecording) @@ -236,16 +287,21 @@ void cMenuDbRecordings::Set(bool Refresh) if (Refresh) Display(); + */ } +//*************************************************************************** +// +//*************************************************************************** + void cMenuDbRecordings::SetPath(const char *Path) { - path = Path; + path = Path; } void cMenuDbRecordings::SetRecording(const char *FileName) { - fileName = FileName; + fileName = FileName; } cString cMenuDbRecordings::DirectoryName(void) -- cgit v1.2.3