Enhanced the SVDRP command CLRE to allow clearing the EPG data of a particular channel

This commit is contained in:
Klaus Schmidinger 2008-01-13 15:06:25 +01:00
parent 5e3374539c
commit dc0665ebf3
3 changed files with 61 additions and 5 deletions

View File

@ -2259,3 +2259,7 @@ Istv
Jiri Dobry <jdobry@centrum.cz>
for reporting a bug in displaying weekday names in the Schedule menu if the system
uses UTF-8
Benjamin Hess <benjamin.h@gmx.ch>
for enhancing the SVDRP command CLRE to allow clearing the EPG data of a particular
channel

View File

@ -5561,3 +5561,5 @@ Video Disk Recorder Revision History
- The automatic shutdown is now suppressed if the remote control is currently
disabled (suggested by Helmut Auer, implemented by Udo Richter).
- Added a section about "Logging" to PLUGINS.html (suggested by Torsten Kunkel).
- Enhanced the SVDRP command CLRE to allow clearing the EPG data of a particular
channel (thanks to Benjamin Hess).

60
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 1.104 2007/10/13 10:17:48 kls Exp $
* $Id: svdrp.c 1.105 2008/01/13 15:06:25 kls Exp $
*/
#include "svdrp.h"
@ -185,8 +185,9 @@ const char *HelpPages[] = {
" Switch channel up, down or to the given channel number, name or id.\n"
" Without option (or after successfully switching to the channel)\n"
" it returns the current channel number and name.",
"CLRE\n"
" Clear the entire EPG list.",
"CLRE [ <number> | <name> | <id> ]\n"
" Clear the EPG list of the given channel number, name or id.\n"
" Without option it clears the entire EPG list.",
"DELC <number>\n"
" Delete channel.",
"DELR <number>\n"
@ -538,8 +539,57 @@ void cSVDRP::CmdCHAN(const char *Option)
void cSVDRP::CmdCLRE(const char *Option)
{
cSchedules::ClearAll();
Reply(250, "EPG data cleared");
if (*Option) {
tChannelID ChannelID = tChannelID::InvalidID;
if (isnumber(Option)) {
int o = strtol(Option, NULL, 10);
if (o >= 1 && o <= Channels.MaxNumber())
ChannelID = Channels.GetByNumber(o)->GetChannelID();
}
else {
ChannelID = tChannelID::FromString(Option);
if (ChannelID == tChannelID::InvalidID) {
for (cChannel *Channel = Channels.First(); Channel; Channel = Channels.Next(Channel)) {
if (!Channel->GroupSep()) {
if (strcasecmp(Channel->Name(), Option) == 0) {
ChannelID = Channel->GetChannelID();
break;
}
}
}
}
}
if (!(ChannelID == tChannelID::InvalidID)) {
cSchedulesLock SchedulesLock(true, 1000);
cSchedules *s = (cSchedules *)cSchedules::Schedules(SchedulesLock);
if (s) {
cSchedule *Schedule = NULL;
ChannelID.ClrRid();
for (cSchedule *p = s->First(); p; p = s->Next(p)) {
if (p->ChannelID() == ChannelID) {
Schedule = p;
break;
}
}
if (Schedule) {
Schedule->Cleanup(INT_MAX);
Reply(250, "EPG data of channel \"%s\" cleared", Option);
}
else {
Reply(550, "No EPG data found for channel \"%s\"", Option);
return;
}
}
else
Reply(451, "Can't get EPG data");
}
else
Reply(501, "Undefined channel \"%s\"", Option);
}
else {
cSchedules::ClearAll();
Reply(250, "EPG data cleared");
}
}
void cSVDRP::CmdDELC(const char *Option)