summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--HISTORY2
-rw-r--r--config.c13
-rw-r--r--config.h8
-rw-r--r--svdrp.c49
-rw-r--r--svdrp.h3
5 files changed, 67 insertions, 8 deletions
diff --git a/HISTORY b/HISTORY
index 8e917f19..e714ebe1 100644
--- a/HISTORY
+++ b/HISTORY
@@ -119,3 +119,5 @@ Video Disk Recorder Revision History
- Improved reaction on user input in fast/slow forward/back modes.
- No more upper limit for the value of 'Pnr'.
- Checking if the video card is really a DVB card.
+- New SVDRP command UPDT to update an existing timer (or add a new one if it
+ doesn't yet exist).
diff --git a/config.c b/config.c
index 8890c694..c144d6c0 100644
--- a/config.c
+++ b/config.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: config.c 1.16 2000/07/29 19:09:51 kls Exp $
+ * $Id: config.c 1.17 2000/08/06 12:27:38 kls Exp $
*/
#include "config.h"
@@ -473,3 +473,14 @@ cChannels Channels;
cTimers Timers;
+cTimer *cTimers::GetTimer(cTimer *Timer)
+{
+ cTimer *ti = (cTimer *)First();
+ while (ti) {
+ if (ti->channel == Timer->channel && ti->day == Timer->day && ti->start == Timer->start && ti->stop == Timer->stop)
+ return ti;
+ ti = (cTimer *)ti->Next();
+ }
+ return NULL;
+}
+
diff --git a/config.h b/config.h
index 1798fab5..1b21d341 100644
--- a/config.h
+++ b/config.h
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: config.h 1.13 2000/08/02 16:38:40 kls Exp $
+ * $Id: config.h 1.14 2000/08/06 12:22:52 kls Exp $
*/
#ifndef __CONFIG_H
@@ -183,7 +183,11 @@ public:
};
class cChannels : public cConfig<cChannel> {};
-class cTimers : public cConfig<cTimer> {};
+
+class cTimers : public cConfig<cTimer> {
+public:
+ cTimer *GetTimer(cTimer *Timer);
+ };
extern int CurrentChannel;
diff --git a/svdrp.c b/svdrp.c
index 1fa689b9..9fef1848 100644
--- a/svdrp.c
+++ b/svdrp.c
@@ -10,7 +10,7 @@
* and interact with the Video Disk Recorder - or write a full featured
* graphical interface that sits on top of an SVDRP connection.
*
- * $Id: svdrp.c 1.3 2000/07/29 18:19:49 kls Exp $
+ * $Id: svdrp.c 1.4 2000/08/06 12:52:04 kls Exp $
*/
#define _GNU_SOURCE
@@ -145,7 +145,12 @@ const char *HelpPages[] = {
" by the LSTC command.",
"NEWT <settings>\n"
" Create a new timer. Settings must be in the same format as returned\n"
- " by the LSTT command.",
+ " by the LSTT command. It is an error if a timer with the same channel,\n"
+ " day, start and stop time already exists.",
+ "UPDT <settings>\n"
+ " Updates a timer. Settings must be in the same format as returned\n"
+ " by the LSTT command. If a timer with the same channel, day, start\n"
+ " and stop time does not yet exists, it will be created.",
"QUIT\n"
" Exit vdr (SVDRP).\n"
" You can also hit Ctrl-D to exit.",
@@ -548,13 +553,48 @@ void cSVDRP::CmdNewt(const char *Option)
if (*Option) {
cTimer *timer = new cTimer;
if (timer->Parse(Option)) {
- Timers.Add(timer);
+ cTimer *t = Timers.GetTimer(timer);
+ if (!t) {
+ Timers.Add(timer);
+ Timers.Save();
+ isyslog(LOG_INFO, "timer %d added", timer->Index() + 1);
+ Reply(250, "%d %s", timer->Index() + 1, timer->ToText());
+ return;
+ }
+ else
+ Reply(550, "Timer already defined: %d %s", t->Index() + 1, t->ToText());
+ }
+ else
+ Reply(501, "Error in timer settings");
+ delete timer;
+ }
+ else
+ Reply(501, "Missing timer settings");
+}
+
+void cSVDRP::CmdUpdt(const char *Option)
+{
+ if (*Option) {
+ cTimer *timer = new cTimer;
+ if (timer->Parse(Option)) {
+ cTimer *t = Timers.GetTimer(timer);
+ if (t) {
+ t->Parse(Option);
+ delete timer;
+ timer = t;
+ isyslog(LOG_INFO, "timer %d updated", timer->Index() + 1);
+ }
+ else {
+ Timers.Add(timer);
+ isyslog(LOG_INFO, "timer %d added", timer->Index() + 1);
+ }
Timers.Save();
- isyslog(LOG_INFO, "timer %d added", timer->Index() + 1);
Reply(250, "%d %s", timer->Index() + 1, timer->ToText());
+ return;
}
else
Reply(501, "Error in timer settings");
+ delete timer;
}
else
Reply(501, "Missing timer settings");
@@ -583,6 +623,7 @@ void cSVDRP::Execute(char *Cmd)
else if (CMD("MOVT")) CmdMovt(s);
else if (CMD("NEWC")) CmdNewc(s);
else if (CMD("NEWT")) CmdNewt(s);
+ else if (CMD("UPDT")) CmdUpdt(s);
else if (CMD("QUIT")
|| CMD("\x04")) Close();
else Reply(500, "Command unrecognized: \"%s\"", Cmd);
diff --git a/svdrp.h b/svdrp.h
index c6385424..3c1cafa8 100644
--- a/svdrp.h
+++ b/svdrp.h
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: svdrp.h 1.1 2000/07/23 14:49:30 kls Exp $
+ * $Id: svdrp.h 1.2 2000/08/06 12:45:28 kls Exp $
*/
#ifndef __SVDRP_H
@@ -42,6 +42,7 @@ private:
void CmdMovt(const char *Option);
void CmdNewc(const char *Option);
void CmdNewt(const char *Option);
+ void CmdUpdt(const char *Option);
void Execute(char *Cmd);
public:
cSVDRP(int Port);