summaryrefslogtreecommitdiff
path: root/menu.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2018-02-13 09:33:41 +0100
committerKlaus Schmidinger <vdr@tvdr.de>2018-02-13 09:33:41 +0100
commit3090d8146fb9cbd2267f97e604bc3c376325686a (patch)
tree33d063b1c0bfda84ed5f0ceb8b92b2a500b554f9 /menu.c
parent78831a72d540444a3c2dc733d1c563c9f0788810 (diff)
downloadvdr-3090d8146fb9cbd2267f97e604bc3c376325686a.tar.gz
vdr-3090d8146fb9cbd2267f97e604bc3c376325686a.tar.bz2
Implemented storing timer id in .timer
Diffstat (limited to 'menu.c')
-rw-r--r--menu.c67
1 files changed, 53 insertions, 14 deletions
diff --git a/menu.c b/menu.c
index c767f357..1759670d 100644
--- a/menu.c
+++ b/menu.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: menu.c 4.60 2018/02/10 12:45:36 kls Exp $
+ * $Id: menu.c 4.61 2018/02/13 09:25:43 kls Exp $
*/
#include "menu.h"
@@ -3111,28 +3111,65 @@ eOSState cMenuRecordings::Rewind(void)
return osContinue;
}
-eOSState cMenuRecordings::Delete(void)
+static bool TimerStillRecording(const char *FileName)
{
- if (HasSubMenu() || Count() == 0)
- return osContinue;
- cMenuRecordingItem *ri = (cMenuRecordingItem *)Get(Current());
- if (ri && !ri->IsDirectory()) {
- if (Interface->Confirm(tr("Delete recording?"))) {
- if (cRecordControl *rc = cRecordControls::GetRecordControl(ri->Recording()->FileName())) {
+ if (cRecordControl *rc = cRecordControls::GetRecordControl(FileName)) {
+ // local timer
+ if (Interface->Confirm(tr("Timer still recording - really delete?"))) {
+ LOCK_TIMERS_WRITE;
+ if (cTimer *Timer = rc->Timer()) {
+ Timer->Skip();
+ cRecordControls::Process(Timers, time(NULL));
+ if (Timer->IsSingleEvent()) {
+ Timers->Del(Timer);
+ isyslog("deleted timer %s", *Timer->ToDescr());
+ }
+ }
+ }
+ else
+ return true; // user didn't confirm deletion
+ }
+ else {
+ // remote timer
+ cString TimerId = GetRecordingTimerId(FileName);
+ if (*TimerId) {
+ int Id;
+ char *RemoteBuf = NULL;
+ cString Remote;
+ if (2 == sscanf(TimerId, "%d@%m[^ \n]", &Id, &RemoteBuf)) {
+ Remote = RemoteBuf;
+ free(RemoteBuf);
if (Interface->Confirm(tr("Timer still recording - really delete?"))) {
- if (cTimer *Timer = rc->Timer()) {
- LOCK_TIMERS_WRITE;
+ LOCK_TIMERS_WRITE;
+ if (cTimer *Timer = Timers->GetById(Id, Remote)) {
Timer->Skip();
- cRecordControls::Process(Timers, time(NULL));
if (Timer->IsSingleEvent()) {
- Timers->Del(Timer);
- isyslog("deleted timer %s", *Timer->ToDescr());
+ if (HandleRemoteModifications(NULL, Timer))
+ Timers->Del(Timer);
+ else
+ return true; // error while deleting remote timer
}
+ else if (!HandleRemoteModifications(Timer))
+ return true; // error while modifying remote timer
}
}
else
- return osContinue;
+ return true; // user didn't confirm deletion
}
+ }
+ }
+ return false;
+}
+
+eOSState cMenuRecordings::Delete(void)
+{
+ if (HasSubMenu() || Count() == 0)
+ return osContinue;
+ cMenuRecordingItem *ri = (cMenuRecordingItem *)Get(Current());
+ if (ri && !ri->IsDirectory()) {
+ if (Interface->Confirm(tr("Delete recording?"))) {
+ if (TimerStillRecording(ri->Recording()->FileName()))
+ return osContinue;
cString FileName;
{
LOCK_RECORDINGS_READ;
@@ -5198,6 +5235,7 @@ cRecordControl::cRecordControl(cDevice *Device, cTimers *Timers, cTimer *Timer,
SchedulesStateKey.Remove();
LOCK_RECORDINGS_WRITE;
Recordings->AddByName(fileName);
+ SetRecordingTimerId(fileName, cString::sprintf("%d@%s", Timer->Id(), Setup.SVDRPHostName));
return;
}
else
@@ -5250,6 +5288,7 @@ void cRecordControl::Stop(bool ExecuteUserCommand)
DELETENULL(recorder);
timer->SetRecording(false);
timer = NULL;
+ SetRecordingTimerId(fileName, NULL);
cStatus::MsgRecording(device, NULL, fileName, false);
if (ExecuteUserCommand)
cRecordingUserCommand::InvokeCommand(RUC_AFTERRECORDING, fileName);