From patchwork Sun Aug 28 08:34:35 2005 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Brachold X-Patchwork-Id: 11994 Received: from web1.dns-net.de ([212.91.231.162]) by www.linuxtv.org with esmtp (Exim 4.34) id 1E9Id2-0007O9-HP for vdr@linuxtv.org; Sun, 28 Aug 2005 10:35:00 +0200 Received: from wopr.deltab.de (n115-185.dsl.de.inter.net [213.73.115.185]) by web1.dns-net.de (8.11.6/8.11.6) with ESMTP id j7S8Yur13699 for ; Sun, 28 Aug 2005 10:34:56 +0200 From: Andreas Brachold To: vdr@linuxtv.org Date: Sun, 28 Aug 2005 10:34:35 +0200 Message-Id: <1125218075.6330.4.camel@wopr.deltab.de> Mime-Version: 1.0 X-Mailer: Evolution 2.0.4 Subject: [vdr] SVDRP MOVC X-BeenThere: vdr@linuxtv.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Klaus Schmidinger's VDR List-Id: Klaus Schmidinger's VDR List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 Aug 2005 08:35:00 -0000 Status: O X-Status: X-Keywords: X-UID: 4513 Hi, here a patch to implement MOVC on SVDRP... Andreas --- svdrp.c.orig 2005-08-07 16:20:41.000000000 +0200 +++ svdrp.c 2005-08-28 10:27:32.000000000 +0200 @@ -965,8 +965,61 @@ void cSVDRP::CmdMOVC(const char *Option) { - //TODO combine this with menu action (timers must be updated) - Reply(502, "MOVC not yet implemented"); + if (!*Option) { + Reply(501, "Error in channel settings"); + return; + } + + if (Channels.BeingEdited() || Timers.BeingEdited()) { + Reply(550, "Channels or Timers are being edited - try again later"); + return; + } + + char *tail; + int From = strtol(Option, &tail, 10); + if (!tail || tail == Option) { + Reply(501, "Error in channel settings"); + return; + } + + tail = skipspace(tail); + if (!tail || tail == Option) { + Reply(501, "Error in channel settings"); + return; + } + + int To = strtol(tail, NULL, 10); + int CurrentChannelNr = cDevice::CurrentChannel(); + cChannel *CurrentChannel = Channels.GetByNumber(CurrentChannelNr); + cChannel *FromChannel = Channels.GetByNumber(From); + if(!FromChannel) { + Reply(501, "Channel \"%d\" not defined", From); + return; + } + + cChannel *ToChannel = Channels.GetByNumber(To); + if(!ToChannel) { + Reply(501, "Channel \"%d\" not defined", To); + return; + } + + int FromNumber = FromChannel->Number(); + int ToNumber = ToChannel->Number(); + if(FromNumber == ToNumber) { + Reply(501, "Can't move Channel to same postion"); + return; + } + + Channels.Move(FromChannel, ToChannel); + Channels.ReNumber(); + Channels.SetModified(true); + + if (CurrentChannel && CurrentChannel->Number() != CurrentChannelNr) + Channels.SwitchTo(CurrentChannel->Number()); + + isyslog("channel %d moved to %d", FromNumber, ToNumber); + Reply(250, "Channel \"%d\" moved to \"%d\"", From, To); + } void cSVDRP::CmdMOVT(const char *Option)