From 93c9aa9af073177d04e357d61fdd0292fd360129 Mon Sep 17 00:00:00 2001 From: schmirl Date: Fri, 29 Jan 2010 12:03:01 +0000 Subject: [PATCH] added DELT FORCE option to delete running timers (#554) --- CONTRIBUTORS | 1 + HISTORY | 1 + server/connectionVTP.c | 52 +++++++++++++++++++++++++++++++++--------- 3 files changed, 43 insertions(+), 11 deletions(-) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 9f5e570..6eb103d 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -126,6 +126,7 @@ Artem Makhutov Alwin Esch for adding XBMC support by extending VTP capabilities for adding VDR 1.7.11 parental rating support for VTP LSTE command + for adding the DELT FORCE option to delete running timers BBlack for reporting that updating recordings list on CmdPLAY is a bad idea diff --git a/HISTORY b/HISTORY index 49441fc..605ce4d 100644 --- a/HISTORY +++ b/HISTORY @@ -1,6 +1,7 @@ VDR Plugin 'streamdev' Revision History --------------------------------------- +- added DELT FORCE option to delete running timers (thanks to Alwin Esch) - added VDR 1.7.11 parental rating support for VTP LSTE command (thanks to Alwin Esch) - added Lithuanian translation (thanks to Valdemaras Pipiras) diff --git a/server/connectionVTP.c b/server/connectionVTP.c index 9cdaaca..7ff60e5 100644 --- a/server/connectionVTP.c +++ b/server/connectionVTP.c @@ -1,5 +1,5 @@ /* - * $Id: connectionVTP.c,v 1.26 2010/01/29 11:44:52 schmirl Exp $ + * $Id: connectionVTP.c,v 1.27 2010/01/29 12:03:02 schmirl Exp $ */ #include "server/connectionVTP.h" @@ -1406,22 +1406,52 @@ bool cConnectionVTP::CmdDELT(const char *Option) { INIT_WRAPPER(); if (*Option) { - if (isnumber(Option)) { - cTimer *timer = Timers.Get(strtol(Option, NULL, 10) - 1); + int number = 0; + bool force = false; + char buf[strlen(Option) + 1]; + strcpy(buf, Option); + const char *delim = " \t"; + char *strtok_next; + char *p = strtok_r(buf, delim, &strtok_next); + + if (isnumber(p)) { + number = strtol(p, NULL, 10) - 1; + } + else if (strcasecmp(p, "FORCE") == 0) { + force = true; + } + if ((p = strtok_r(NULL, delim, &strtok_next)) != NULL) { + if (isnumber(p)) { + number = strtol(p, NULL, 10) - 1; + } + else if (strcasecmp(p, "FORCE") == 0) { + force = true; + } + else { + Reply(501, "Timer not found or wrong syntax"); + } + } + + cTimer *timer = Timers.Get(number); if (timer) { - if (!timer->Recording()) { + if (timer->Recording()) { + if (force) { + timer->Skip(); + cRecordControls::Process(time(NULL)); + } + else { + Reply(550, "Timer \"%i\" is recording", number); + EXIT_WRAPPER(); + } + } isyslog("deleting timer %s", *timer->ToDescr()); Timers.Del(timer); Timers.SetModified(); - Reply(250, "Timer \"%s\" deleted", Option); + Reply(250, "Timer \"%i\" deleted", number); } else - Reply(550, "Timer \"%s\" is recording", Option); + Reply(501, "Timer \"%i\" not defined", number); } else - Reply(501, "Timer \"%s\" not defined", Option); - } else - Reply(501, "Error in timer number \"%s\"", Option); - } else - Reply(501, "Missing timer number"); + Reply(501, "Missing timer option"); EXIT_WRAPPER(); }