The SVDRP command DELC now also accepts a channel id

This commit is contained in:
Klaus Schmidinger 2020-05-05 15:37:49 +02:00
parent abe61dc903
commit c813de133b
3 changed files with 43 additions and 40 deletions

View File

@ -2918,6 +2918,7 @@ Manuel Reimer <Manuel.Reimer@gmx.de>
when switching to a less privileged user id
for reporting a bug in moving channels between number groups in SVDRP's MOVC command
for fixing compatibility with current versions of glibc
for suggesting to make the SVDRP command DELC accept a channel id
Rene van den Braken <rene@vandenbraken.name>
for reporting a bug in writing the PCR pid into the PMT in

View File

@ -9420,7 +9420,7 @@ Video Disk Recorder Revision History
- Fixed handling the S2SatelliteDeliverySystemDescriptor for transponders broadcasting
in "backwards compatibility mode" according to ETSI EN 300 468 (thanks to Onur Sentürk).
2020-05-04:
2020-05-05:
- Fixed moving channels between number groups in SVDRP's MOVC command and the Channels
menu, in case a channel is moved to a higher number and into a numbered group
@ -9429,3 +9429,4 @@ Video Disk Recorder Revision History
for NID and TID (thanks to Uwe Scheffler for reporting a problem with failed tuning
in SCR systems, and Helmut Binder for helping with the implementation).
- Fixed compatibility with current versions of glibc (thanks to Manuel Reimer).
- The SVDRP command DELC now also accepts a channel id (suggested by Manuel Reimer).

79
svdrp.c
View File

@ -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)