diff --git a/CONTRIBUTORS b/CONTRIBUTORS index f45d6219..7f5acb85 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -2259,3 +2259,7 @@ Istv Jiri Dobry for reporting a bug in displaying weekday names in the Schedule menu if the system uses UTF-8 + +Benjamin Hess + for enhancing the SVDRP command CLRE to allow clearing the EPG data of a particular + channel diff --git a/HISTORY b/HISTORY index 8d2f256a..3c953253 100644 --- a/HISTORY +++ b/HISTORY @@ -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). diff --git a/svdrp.c b/svdrp.c index c8cd5be8..2ac3a4bb 100644 --- a/svdrp.c +++ b/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.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 [ | | ]\n" + " Clear the EPG list of the given channel number, name or id.\n" + " Without option it clears the entire EPG list.", "DELC \n" " Delete channel.", "DELR \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)