Added support for issuing generic control operations.

git-svn-id: http://voip.null.ro/svn/yate@2770 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
paulc 2009-07-27 21:36:02 +00:00
parent 14ace8e2ca
commit 67665e11e0
1 changed files with 29 additions and 0 deletions

View File

@ -104,6 +104,7 @@ static const CommandInfo s_cmdInfo[] =
#endif
{ "drop", "{chan|*|all} [reason]", s_dall, "Drops one or all active calls" },
{ "call", "chan target", 0, "Execute an outgoing call" },
{ "control", "chan operation", 0, "Apply arbitrary control operations to a channel or entity" },
{ "reload", 0, 0, "Reloads module configuration files" },
{ "restart", "[now]", s_rnow, "Restarts the engine if executing supervised" },
{ "stop", "[exitcode]", 0, "Stops the engine with optionally provided exit code" },
@ -947,6 +948,34 @@ bool Connection::processLine(const char *line)
}
writeStr(str);
}
else if (str.startSkip("control"))
{
int pos = str.find(' ');
if (pos <= 0) {
writeStr(m_machine ? "%%=control:fail=noarg\r\n" : "You must specify channel and operation!\r\n");
return false;
}
String id = str.substr(0,pos);
String ctrl = str.substr(pos+1);
Message m("chan.control");
m.addParam("targetid",id);
m.addParam("component",id);
pos = ctrl.find('=');
if (pos <= 0)
m.addParam("operation",ctrl);
else
m.addParam(ctrl.substr(0,pos),ctrl.substr(pos+1));
if (Engine::dispatch(m)) {
if (m_machine)
str = "%%=control:success:" + id + ":" + m.retValue() + "\r\n";
else
str = "Control '" + id + "' " + m.retValue().safe("OK") + "\r\n";
}
else
str = (m_machine ? "%%=control:fail:" : "Could not control ") + str + "\r\n";
writeStr(str);
}
#ifdef HAVE_COREDUMPER
else if (str.startSkip("coredump"))
{