2
0
mirror of https://github.com/ACSPRI/queXS synced 2024-04-02 12:12:16 +00:00

Fixes lp:1362418 - Cannot originate calls on Asterisk 11

Adds ORIGINATE_CONTEXT as a configuration default and sets it to 'from-internal'
This commit is contained in:
Adam Zammit
2014-09-17 15:25:22 +10:00
parent 529133c8c6
commit fb0f9240f5
2 changed files with 21 additions and 15 deletions

View File

@@ -94,6 +94,12 @@ if (!defined('VOIP_ADMIN_PASS')) define('VOIP_ADMIN_PASS','amp111');
*/ */
if (!defined('VOIP_PORT')) define('VOIP_PORT','5038'); if (!defined('VOIP_PORT')) define('VOIP_PORT','5038');
/**
* The Asterisk context to originate calls from (in FreePBX this should be
* 'from-internal' otherwise try 'default'
*/
if (!defined('ORIGINATE_CONTEXT')) define('ORIGINATE_CONTEXT','from-internal');
/** /**
* The freepbx root path (if installed) otherwise false to disable freepbx integration * The freepbx root path (if installed) otherwise false to disable freepbx integration
*/ */

View File

@@ -75,7 +75,7 @@ class voip {
$chans = array(); $chans = array();
foreach ($c as $s) foreach ($c as $s)
{ {
if(preg_match("{Event: PeerEntry.*ObjectName: ([0-9a-zA-Z-]+).*Status: ([/0-9a-zA-Z-]+)}i",$s,$regs)) if(preg_match("{Event: PeerEntry.*ObjectName: ([0-9a-zA-Z-]+).*Status: ([/0-9a-zA-Z-]+)}is",$s,$regs))
{ {
//print T_("Channel: SIP/") . $regs[1] . " BridgedChannel " . $regs[2] . "\n"; //print T_("Channel: SIP/") . $regs[1] . " BridgedChannel " . $regs[2] . "\n";
$chan = substr($regs[1],0,4); $chan = substr($regs[1],0,4);
@@ -102,14 +102,14 @@ class voip {
$chans = array(); $chans = array();
foreach ($c as $s) foreach ($c as $s)
{ {
if(preg_match("{Event: Status.*Channel: ((SIP/|IAX2/)[0-9a-zA-Z-]+).*BridgedChannel: ((SIP/|IAX2/)[/0-9a-zA-Z-]+)}i",$s,$regs)) if(preg_match("{Event: Status.*Channel: ((SIP/|IAX2/)[0-9a-zA-Z-]+).*BridgedChannel: ((SIP/|IAX2/)[/0-9a-zA-Z-]+)}is",$s,$regs))
{ {
//print T_("Channel: SIP/") . $regs[1] . " BridgedChannel " . $regs[2] . "\n"; //print T_("Channel: SIP/") . $regs[1] . " BridgedChannel " . $regs[2] . "\n";
$ccs = explode('-',$regs[1]); $ccs = explode('-',$regs[1]);
$chan = $ccs[0]; $chan = $ccs[0];
$chans[$chan] = array($regs[1],$regs[3]); $chans[$chan] = array($regs[1],$regs[3]);
} }
else if(preg_match("{Event: Status.*Channel: ((SIP/|IAX2/)[0-9a-zA-Z-]+)}i",$s,$regs)) else if(preg_match("{Event: Status.*Channel: ((SIP/|IAX2/)[0-9a-zA-Z-]+)}is",$s,$regs))
{ {
//print T_("Channel: ") . $regs[1] . "\n"; //print T_("Channel: ") . $regs[1] . "\n";
$ccs = explode('-', $regs[1]); $ccs = explode('-', $regs[1]);
@@ -187,7 +187,7 @@ class voip {
*/ */
function dial($ext,$number) function dial($ext,$number)
{ {
$r = $this->query("Action: Originate\r\nChannel: $ext\r\nExten: $number\r\nPriority: 1\r\nCallerid: $ext\r\n\r\n","Response"); $r = $this->query("Action: Originate\r\nChannel: $ext\r\nExten: $number\r\nContext: " . ORIGINATE_CONTEXT . "\r\nPriority: 1\r\nCallerid: $ext\r\n\r\n","Response");
} }
@@ -266,7 +266,7 @@ class voip {
if ($type == "SIP") if ($type == "SIP")
{ {
$ret = $this->query("Action: ExtensionState\r\nContext: from-internal\r\nExten: $ext\r\nActionID: \r\n\r\n","Status:"); $ret = $this->query("Action: ExtensionState\r\nContext: from-internal\r\nExten: $ext\r\nActionID: \r\n\r\n","Status:");
if(preg_match("{Status: ([0-9]+)}i",$ret,$regs)) if(preg_match("{Status: ([0-9]+)}is",$ret,$regs))
{ {
if (isset($regs[1])) if (isset($regs[1]))
{ {
@@ -540,14 +540,14 @@ class voipWatch extends voip {
* *
*/ */
if ($in == "\r\n") if ($in == "\r\n")
{ {
//print "PROCESS: "; //print "PROCESS: ";
/** /**
* The call is ringing * The call is ringing
*/ */
if (preg_match("{Event: Dial.*SubEvent: Begin.*Channel: ((SIP/|IAX2/)[0-9]+)}i",$line,$regs)) if (preg_match("{Event: Dial.*SubEvent: Begin.*Channel: ((SIP/|IAX2/)[0-9]+)}is",$line,$regs))
{ {
list($call_id,$case_id) = $this->getCallId($regs[1]); list($call_id,$case_id) = $this->getCallId($regs[1]);
if ($call_id != 0) if ($call_id != 0)
{ {
print T_("Ringing") . T_(" Extension ") . $regs[1] . " " . T_("Case id") . ": <a href=\"supervisor.php?case_id=$case_id\">$case_id</a>\n"; print T_("Ringing") . T_(" Extension ") . $regs[1] . " " . T_("Case id") . ": <a href=\"supervisor.php?case_id=$case_id\">$case_id</a>\n";
@@ -557,8 +557,8 @@ class voipWatch extends voip {
/** /**
* The call has been answered * The call has been answered
*/ */
else if (preg_match("{Event: Bridge.*Channel1: ((SIP/|IAX2/)[0-9]+)}i",$line,$regs)) else if (preg_match("{Event: Bridge.*Channel1: ((SIP/|IAX2/)[0-9]+)}is",$line,$regs))
{ {
list($call_id,$case_id) = $this->getCallId($regs[1]); list($call_id,$case_id) = $this->getCallId($regs[1]);
if ($call_id != 0) if ($call_id != 0)
{ {
@@ -569,8 +569,8 @@ class voipWatch extends voip {
/** /**
* The call has been hung up * The call has been hung up
*/ */
else if (preg_match("{Event: Hangup.*Channel: ((SIP/|IAX2/)[0-9]+)}i",$line,$regs)) else if (preg_match("{Event: Hangup.*Channel: ((SIP/|IAX2/)[0-9]+)}is",$line,$regs))
{ {
list($call_id,$case_id) = $this->getCallId($regs[1]); list($call_id,$case_id) = $this->getCallId($regs[1]);
if ($call_id != 0) if ($call_id != 0)
{ {
@@ -582,7 +582,7 @@ class voipWatch extends voip {
/** /**
* The status of an extension has changed to unregistered * The status of an extension has changed to unregistered
*/ */
else if (preg_match("{Event: PeerStatus.*Peer: ((SIP/|IAX2/)[0-9]+).*PeerStatus: Unregistered}i",$line,$regs)) else if (preg_match("{Event: PeerStatus.*Peer: ((SIP/|IAX2/)[0-9]+).*PeerStatus: Unregistered}is",$line,$regs))
{ {
print T_("Unregistered") . T_(" Extension ") . $regs[1] . "\n"; print T_("Unregistered") . T_(" Extension ") . $regs[1] . "\n";
$this->setExtensionStatus($regs[1],false); $this->setExtensionStatus($regs[1],false);
@@ -591,7 +591,7 @@ class voipWatch extends voip {
/** /**
* The status of an extension has changed to registered * The status of an extension has changed to registered
*/ */
else if (preg_match("{Event: PeerStatus.*Peer: ((SIP/|IAX2/)[0-9]+).*PeerStatus: Registered}i",$line,$regs)) else if (preg_match("{Event: PeerStatus.*Peer: ((SIP/|IAX2/)[0-9]+).*PeerStatus: Registered}is",$line,$regs))
{ {
print T_("Registered") . T_(" Extension ") . $regs[1] . "\n"; print T_("Registered") . T_(" Extension ") . $regs[1] . "\n";
$this->setExtensionStatus($regs[1],true); $this->setExtensionStatus($regs[1],true);