diff options
Diffstat (limited to 'svdrp.c')
-rw-r--r-- | svdrp.c | 94 |
1 files changed, 73 insertions, 21 deletions
@@ -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 3.1 2013/09/10 13:21:38 kls Exp $ + * $Id: svdrp.c 3.2 2013/10/10 12:18:12 kls Exp $ */ #include "svdrp.h" @@ -28,7 +28,6 @@ #include <unistd.h> #include "channels.h" #include "config.h" -#include "cutter.h" #include "device.h" #include "eitscan.h" #include "keys.h" @@ -305,6 +304,11 @@ const char *HelpPages[] = { "REMO [ on | off ]\n" " Turns the remote control on or off. Without a parameter, the current\n" " status of the remote control is reported.", + "RENR <number> <new name>\n" + " Rename the recording with the given number. Before a recording can be\n" + " renamed, an LSTR command must have been executed in order to retrieve\n" + " the recording numbers. The numbers don't change during subsequent RENR\n" + " commands.n", "SCAN\n" " Forces an EPG scan. If this is a single DVB device system, the scan\n" " will be done on the primary device unless it is currently recording.", @@ -659,27 +663,38 @@ void cSVDRP::CmdDELC(const char *Option) Reply(501, "Missing channel number"); } +static cString RecordingInUseMessage(int Reason, const char *RecordingId, cRecording *Recording) +{ + cRecordControl *rc; + if ((Reason & ruTimer) != 0 && (rc = cRecordControls::GetRecordControl(Recording->FileName())) != NULL) + return cString::sprintf("Recording \"%s\" is in use by timer %d", RecordingId, rc->Timer()->Index() + 1); + else if ((Reason & ruReplay) != 0) + return cString::sprintf("Recording \"%s\" is being replayed", RecordingId); + else if ((Reason & ruCut) != 0) + return cString::sprintf("Recording \"%s\" is being edited", RecordingId); + else if ((Reason & (ruMove | ruCopy)) != 0) + return cString::sprintf("Recording \"%s\" is being copied/moved", RecordingId); + else if (Reason) + return cString::sprintf("Recording \"%s\" is in use", RecordingId); + return NULL; +} + void cSVDRP::CmdDELR(const char *Option) { if (*Option) { if (isnumber(Option)) { cRecording *recording = recordings.Get(strtol(Option, NULL, 10) - 1); if (recording) { - cRecordControl *rc = cRecordControls::GetRecordControl(recording->FileName()); - if (!rc) { - if (!cCutter::Active(recording->FileName())) { - if (recording->Delete()) { - Reply(250, "Recording \"%s\" deleted", Option); - Recordings.DelByName(recording->FileName()); - } - else - Reply(554, "Error while deleting recording!"); + if (int RecordingInUse = recording->IsInUse()) + Reply(550, RecordingInUseMessage(RecordingInUse, Option, recording)); + else { + if (recording->Delete()) { + Reply(250, "Recording \"%s\" deleted", Option); + Recordings.DelByName(recording->FileName()); } else - Reply(550, "Recording \"%s\" is being edited", Option); + Reply(554, "Error while deleting recording!"); } - else - Reply(550, "Recording \"%s\" is in use by timer %d", Option, rc->Timer()->Index() + 1); } else Reply(550, "Recording \"%s\" not found%s", Option, recordings.Count() ? "" : " (use LSTR before deleting)"); @@ -728,14 +743,10 @@ void cSVDRP::CmdEDIT(const char *Option) if (recording) { cMarks Marks; if (Marks.Load(recording->FileName(), recording->FramesPerSecond(), recording->IsPesRecording()) && Marks.Count()) { - if (!cCutter::Active()) { - if (cCutter::Start(recording->FileName())) - Reply(250, "Editing recording \"%s\" [%s]", Option, recording->Title()); - else - Reply(554, "Can't start editing process"); - } + if (RecordingsHandler.Add(ruCut, recording->FileName())) + Reply(250, "Editing recording \"%s\" [%s]", Option, recording->Title()); else - Reply(554, "Editing process already active"); + Reply(554, "Can't start editing process"); } else Reply(554, "No editing marks defined"); @@ -1539,6 +1550,46 @@ void cSVDRP::CmdREMO(const char *Option) Reply(250, "Remote control is %s", cRemote::Enabled() ? "enabled" : "disabled"); } +void cSVDRP::CmdRENR(const char *Option) +{ + if (*Option) { + char *opt = strdup(Option); + char *num = skipspace(opt); + char *option = num; + while (*option && !isspace(*option)) + option++; + char c = *option; + *option = 0; + if (isnumber(num)) { + cRecording *recording = recordings.Get(strtol(num, NULL, 10) - 1); + if (recording) { + if (int RecordingInUse = recording->IsInUse()) + Reply(550, RecordingInUseMessage(RecordingInUse, Option, recording)); + else { + if (c) + option = skipspace(++option); + if (*option) { + cString oldName = recording->Name(); + if (recording->ChangeName(option)) + Reply(250, "Recording \"%s\" renamed to \"%s\"", *oldName, recording->Name()); + else + Reply(554, "Error while renaming recording \"%s\" to \"%s\"!", *oldName, option); + } + else + Reply(501, "Missing new recording name"); + } + } + else + Reply(550, "Recording \"%s\" not found%s", num, recordings.Count() ? "" : " (use LSTR before renaming)"); + } + else + Reply(501, "Error in recording number \"%s\"", num); + free(opt); + } + else + Reply(501, "Missing recording number"); +} + void cSVDRP::CmdSCAN(const char *Option) { EITScanner.ForceScan(); @@ -1666,6 +1717,7 @@ void cSVDRP::Execute(char *Cmd) else if (CMD("PLUG")) CmdPLUG(s); else if (CMD("PUTE")) CmdPUTE(s); else if (CMD("REMO")) CmdREMO(s); + else if (CMD("RENR")) CmdRENR(s); else if (CMD("SCAN")) CmdSCAN(s); else if (CMD("STAT")) CmdSTAT(s); else if (CMD("UPDR")) CmdUPDR(s); |