From aeb005c54e058608ed6234ff8ab21199d4190f25 Mon Sep 17 00:00:00 2001 From: paulc Date: Fri, 6 Sep 2013 11:07:39 +0000 Subject: [PATCH] Handle the "control" command in engine like rmanager does. This allows other modules to easily perform control operations. git-svn-id: http://yate.null.ro/svn/yate/trunk@5641 acf43c95-373e-0410-b603-e72c3f656dc1 --- engine/Engine.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/engine/Engine.cpp b/engine/Engine.cpp index 6b63da13..fb46a08e 100644 --- a/engine/Engine.cpp +++ b/engine/Engine.cpp @@ -646,6 +646,32 @@ bool EngineCommand::received(Message &msg) doCompletion(msg,msg.getValue("partline"),msg.getValue("partword")); return false; } + if (line.startSkip("control")) { + int pos = line.find(' '); + String id = line.substr(0,pos).trimBlanks(); + String ctrl = line.substr(pos+1).trimBlanks(); + if ((pos <= 0) || id.null() || ctrl.null()) + return false; + Message m("chan.control"); + m.addParam("targetid",id); + m.addParam("component",id); + m.copyParam(msg,"module"); + m.copyParam(msg,"cmd",'_'); + static const Regexp r("^\\(.* \\)\\?\\([^= ]\\+\\)=\\([^=]*\\)$"); + while (ctrl) { + if (!ctrl.matches(r)) { + m.setParam("operation",ctrl); + break; + } + m.setParam(ctrl.matchString(2),ctrl.matchString(3).trimBlanks()); + ctrl = ctrl.matchString(1).trimBlanks(); + } + if (!Engine::dispatch(m)) + return false; + msg.retValue() = m.retValue(); + NamedString* opStatus = m.getParam(YSTRING("operation-status")); + return !opStatus || opStatus->toBoolean(); + } if (!line.startSkip("module")) { if (line.startSkip("events") || (line == "logview" && (line.clear(),true))) { bool clear = line.startSkip("clear");