diff options
Diffstat (limited to 'svdrp.c')
-rw-r--r-- | svdrp.c | 79 |
1 files changed, 40 insertions, 39 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 4.40 2020/04/11 09:22:05 kls Exp $ + * $Id: svdrp.c 4.41 2020/05/05 15:37:49 kls Exp $ */ #include "svdrp.h" @@ -840,8 +840,8 @@ const char *HelpPages[] = { " Used by peer-to-peer connections between VDRs to tell the other VDR\n" " to establish a connection to this VDR. The name is the SVDRP host name\n" " of this VDR, which may differ from its DNS name.", - "DELC <number>\n" - " Delete channel.", + "DELC <number> | <id>\n" + " Delete the channel with the given number or channel id.", "DELR <id>\n" " Delete the recording with the given id. Before a recording can be\n" " deleted, an LSTR command should have been executed in order to retrieve\n" @@ -1379,49 +1379,50 @@ void cSVDRPServer::CmdCONN(const char *Option) void cSVDRPServer::CmdDELC(const char *Option) { if (*Option) { - if (isnumber(Option)) { - LOCK_TIMERS_READ; - LOCK_CHANNELS_WRITE; - Channels->SetExplicitModify(); - if (cChannel *Channel = Channels->GetByNumber(strtol(Option, NULL, 10))) { - if (const cTimer *Timer = Timers->UsesChannel(Channel)) { - Reply(550, "Channel \"%s\" is in use by timer %s", Option, *Timer->ToDescr()); + LOCK_TIMERS_READ; + LOCK_CHANNELS_WRITE; + Channels->SetExplicitModify(); + cChannel *Channel = NULL; + if (isnumber(Option)) + Channel = Channels->GetByNumber(strtol(Option, NULL, 10)); + else + Channel = Channels->GetByChannelID(tChannelID::FromString(Option)); + if (Channel) { + if (const cTimer *Timer = Timers->UsesChannel(Channel)) { + Reply(550, "Channel \"%s\" is in use by timer %s", Option, *Timer->ToDescr()); + return; + } + int CurrentChannelNr = cDevice::CurrentChannel(); + cChannel *CurrentChannel = Channels->GetByNumber(CurrentChannelNr); + if (CurrentChannel && Channel == CurrentChannel) { + int n = Channels->GetNextNormal(CurrentChannel->Index()); + if (n < 0) + n = Channels->GetPrevNormal(CurrentChannel->Index()); + if (n < 0) { + Reply(501, "Can't delete channel \"%s\" - list would be empty", Option); return; } - int CurrentChannelNr = cDevice::CurrentChannel(); - cChannel *CurrentChannel = Channels->GetByNumber(CurrentChannelNr); - if (CurrentChannel && Channel == CurrentChannel) { - int n = Channels->GetNextNormal(CurrentChannel->Index()); - if (n < 0) - n = Channels->GetPrevNormal(CurrentChannel->Index()); - if (n < 0) { - Reply(501, "Can't delete channel \"%s\" - list would be empty", Option); - return; - } - CurrentChannel = Channels->Get(n); - CurrentChannelNr = 0; // triggers channel switch below - } - Channels->Del(Channel); - Channels->ReNumber(); - Channels->SetModifiedByUser(); - Channels->SetModified(); - isyslog("SVDRP %s < %s deleted channel %s", Setup.SVDRPHostName, *clientName, Option); - if (CurrentChannel && CurrentChannel->Number() != CurrentChannelNr) { - if (!cDevice::PrimaryDevice()->Replaying() || cDevice::PrimaryDevice()->Transferring()) - Channels->SwitchTo(CurrentChannel->Number()); - else - cDevice::SetCurrentChannel(CurrentChannel->Number()); - } - Reply(250, "Channel \"%s\" deleted", Option); + CurrentChannel = Channels->Get(n); + CurrentChannelNr = 0; // triggers channel switch below } - else - Reply(501, "Channel \"%s\" not defined", Option); + Channels->Del(Channel); + Channels->ReNumber(); + Channels->SetModifiedByUser(); + Channels->SetModified(); + isyslog("SVDRP %s < %s deleted channel %s", Setup.SVDRPHostName, *clientName, Option); + if (CurrentChannel && CurrentChannel->Number() != CurrentChannelNr) { + if (!cDevice::PrimaryDevice()->Replaying() || cDevice::PrimaryDevice()->Transferring()) + Channels->SwitchTo(CurrentChannel->Number()); + else + cDevice::SetCurrentChannel(CurrentChannel->Number()); + } + Reply(250, "Channel \"%s\" deleted", Option); } else - Reply(501, "Error in channel number \"%s\"", Option); + Reply(501, "Channel \"%s\" not defined", Option); } else - Reply(501, "Missing channel number"); + Reply(501, "Missing channel number or id"); } static cString RecordingInUseMessage(int Reason, const char *RecordingId, cRecording *Recording) |