From bad9290d3d3cfd335fca6ac38d5eefbee976b33e Mon Sep 17 00:00:00 2001 From: Timo Eskola Date: Wed, 5 Sep 2018 09:03:20 +0300 Subject: Check for vanished recorgins in info menu. --- HISTORY | 1 + menu.c | 35 ++++++++++++++++++++++++++++++++--- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/HISTORY b/HISTORY index 8e5f989..9fdf195 100644 --- a/HISTORY +++ b/HISTORY @@ -8,6 +8,7 @@ VDR Plugin 'duplicates' Revision History - Added missing recordings lock release. - Simplified toggle hidden. - Fixed recordings locking sequence. +- Check for vanished recorgins in info menu. 2018-08-30: Version 0.2.1 diff --git a/menu.c b/menu.c index 2836fc7..348f4de 100644 --- a/menu.c +++ b/menu.c @@ -45,6 +45,11 @@ eOSState cDuplicatesReplayControl::ProcessKey(eKeys Key) { class cMenuDuplicate : public cOsdMenu { private: const cRecording *recording; +#if VDRVERSNUM >= 20301 + cString originalFileName; + cStateKey recordingsStateKey; + bool RefreshRecording(void); +#endif public: cMenuDuplicate(const cRecording *Recording); virtual void Display(void); @@ -57,9 +62,29 @@ cMenuDuplicate::cMenuDuplicate(const cRecording *Recording) SetMenuCategory(mcRecording); #endif recording = Recording; +#if VDRVERSNUM >= 20301 + originalFileName = recording->FileName(); +#endif SetHelp(trVDR("Button$Play")); } +#if VDRVERSNUM >= 20301 +bool cMenuDuplicate::RefreshRecording(void) +{ + if (const cRecordings *Recordings = cRecordings::GetRecordingsRead(recordingsStateKey)) { + if ((recording = Recordings->GetByName(originalFileName)) != NULL) + Display(); + else { + recordingsStateKey.Remove(); + Skins.Message(mtWarning, trVDR("Recording vanished!")); + return false; + } + recordingsStateKey.Remove(); + } + return true; +} +#endif + void cMenuDuplicate::Display(void) { cOsdMenu::Display(); DisplayMenu()->SetRecording(recording); @@ -67,8 +92,11 @@ void cMenuDuplicate::Display(void) { cStatus::MsgOsdTextItem(recording->Info()->Description()); } -eOSState cMenuDuplicate::ProcessKey(eKeys Key) -{ +eOSState cMenuDuplicate::ProcessKey(eKeys Key) { +#if VDRVERSNUM >= 20301 + if (!RefreshRecording()) + return osBack; // the recording has vanished, so close this menu +#endif switch (int(Key)) { case kUp|k_Repeat: case kUp: @@ -401,10 +429,11 @@ eOSState cMenuDuplicates::Info(void) { cRecording *recording = Recordings.GetByName(ri->FileName()); #endif if (recording && recording->Info()->Title()) { + cMenuDuplicate *MenuDuplicate = new cMenuDuplicate(recording); #if VDRVERSNUM >= 20301 stateKey.Remove(); #endif - return AddSubMenu(new cMenuDuplicate(recording)); + return AddSubMenu(MenuDuplicate); } #if VDRVERSNUM >= 20301 else -- cgit v1.2.3