From 1050299bf2fc70d22605b846cfbbb23ffa292c22 Mon Sep 17 00:00:00 2001 From: paulc Date: Mon, 2 Mar 2009 18:49:45 +0000 Subject: [PATCH] Do not autoanswer if an analog or BRI goes off-hook. Put the proper dial tones (and silences). git-svn-id: http://yate.null.ro/svn/yate/trunk@2504 acf43c95-373e-0410-b603-e72c3f656dc1 --- share/scripts/overlapped.php | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/share/scripts/overlapped.php b/share/scripts/overlapped.php index 0accf899..8558e5ad 100755 --- a/share/scripts/overlapped.php +++ b/share/scripts/overlapped.php @@ -45,7 +45,7 @@ function setState($newstate) $state = $newstate; $m = new Yate("chan.attach"); $m->params["id"] = $ourcallid; - $m->params["source"] = "tone/specdial"; + $m->params["source"] = "tone/dial"; $m->params["consumer"] = "wave/record/-"; $m->params["maxlen"] = 320000; $m->params["notify"] = $ourcallid; @@ -69,7 +69,7 @@ function setState($newstate) case "routing": $m = new Yate("chan.attach"); $m->params["id"] = $ourcallid; - $m->params["source"] = "wave/play/-"; + $m->params["source"] = "tone/noise"; $m->params["consumer"] = "wave/record/-"; $m->params["maxlen"] = 320000; $m->params["notify"] = $ourcallid; @@ -137,7 +137,7 @@ function gotDTMF($dtmf) routeTo($collect); } -function endRoute($callto,$ok,$err) +function endRoute($callto,$ok,$err,$params) { global $partycallid; global $num; @@ -145,6 +145,7 @@ function endRoute($callto,$ok,$err) if ($ok) { Yate::Output("Overlapped got route: '$callto' for '$collect'"); $m = new Yate("chan.masquerade"); + $m->params = $params; $m->params["message"] = "call.execute"; $m->params["id"] = $partycallid; $m->params["callto"] = $callto; @@ -175,16 +176,18 @@ while ($state != "") { $partycallid = $ev->GetValue("id"); $ev->params["targetid"] = $ourcallid; $num = $ev->GetValue("caller"); + $autoanswer = ($ev->GetValue("called") != "off-hook"); $ev->handled = true; // we must ACK this message before dispatching a call.answered $ev->Acknowledge(); // we already ACKed this message $ev = false; - - $m = new Yate("call.answered"); - $m->params["id"] = $ourcallid; - $m->params["targetid"] = $partycallid; - $m->Dispatch(); + if ($autoanswer) { + $m = new Yate("call.answered"); + $m->params["id"] = $ourcallid; + $m->params["targetid"] = $partycallid; + $m->Dispatch(); + } setState("prompt"); break; @@ -212,7 +215,7 @@ while ($state != "") { break; case "answer": if ($ev->name == "call.route") - endRoute($ev->retval,$ev->handled,$ev->GetValue("error")); + endRoute($ev->retval,$ev->handled,$ev->GetValue("error"),$ev->params); break; } }