Commit Message
Hi,
here a patch to implement MOVC on SVDRP...
Andreas
@@ -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)