mirror of
https://github.com/VDR4Arch/vdr.git
synced 2023-10-10 13:36:52 +02:00
New SVDRP command UPDT
This commit is contained in:
parent
dd6bc9feea
commit
0d034bc582
2
HISTORY
2
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).
|
||||
|
13
config.c
13
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;
|
||||
}
|
||||
|
||||
|
8
config.h
8
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;
|
||||
|
||||
|
53
svdrp.c
53
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);
|
||||
Timers.Save();
|
||||
isyslog(LOG_INFO, "timer %d added", timer->Index() + 1);
|
||||
Reply(250, "%d %s", timer->Index() + 1, timer->ToText());
|
||||
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();
|
||||
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);
|
||||
|
3
svdrp.h
3
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);
|
||||
|
Loading…
Reference in New Issue
Block a user