[Astpp-commit] SF.net SVN: astpp:[2242] trunk
Brought to you by:
darrenkw
From: <dar...@us...> - 2009-03-11 02:47:25
|
Revision: 2242 http://astpp.svn.sourceforge.net/astpp/?rev=2242&view=rev Author: darrenkw Date: 2009-03-11 02:46:52 +0000 (Wed, 11 Mar 2009) Log Message: ----------- Added Freeswitch DID support. Modified Paths: -------------- trunk/freeswitch/astpp-fs-xml.pl trunk/modules/ASTPP/lib/ASTPP.pm Modified: trunk/freeswitch/astpp-fs-xml.pl =================================================================== --- trunk/freeswitch/astpp-fs-xml.pl 2009-03-10 00:52:26 UTC (rev 2241) +++ trunk/freeswitch/astpp-fs-xml.pl 2009-03-11 02:46:52 UTC (rev 2242) @@ -53,19 +53,21 @@ debug => "Destination = $params->{'Caller-Destination-Number'}" ); if ( $params->{section} eq "dialplan" ) { - $xml = $ASTPP->fs_dialplan_xml_header( - xml => $xml, - destination_number => $params->{'Caller-Destination-Number'} - ); - -# Check to see if this is a DID. If it is we handle it differently. -# + # Check to see if this is a DID. If it is we handle it differently. + # $didinfo = &get_did($astpp_db, $params->{'Caller-Destination-Number'}); if ($didinfo->{number}) { $astppdid = "ASTPP-DID"; $ASTPP->debug( debug => "This is a call for a DID: "); $params->{variable_accountcode} = $didinfo->{account}; } + + $xml = $ASTPP->fs_dialplan_xml_header( + xml => $xml, + destination_number => $params->{'Caller-Destination-Number'}, + DID => $didinfo->{number} + ); + @@ -113,7 +115,9 @@ $xml .= "<action application=\"reject\" data=\"CANNOT RETRIEVE ACCOUNT\"/>\n"; $xml = $ASTPP->fs_dialplan_xml_footer( xml => $xml ); - print $xml; +# print $xml; + $ASTPP->debug( debug => "Returning nothing so dialplan can continue." ); + print ""; exit(0); } @@ -228,8 +232,12 @@ $carddata->{pricelist}, $carddata, $astppdid ); - if ($astppdid > 0 ) { + if ($didinfo->{number} ) { $ASTPP->debug( debug => "THIS IS A DID CALL: $xml"); + my ($returned_data) = $ASTPP->fs_dialplan_xml_did( + did => $params->{'Caller-Destination-Number'} + ); + $xml .= $returned_data; } else { # Get the list of routes for the phone number. my @outboundroutes = Modified: trunk/modules/ASTPP/lib/ASTPP.pm =================================================================== --- trunk/modules/ASTPP/lib/ASTPP.pm 2009-03-10 00:52:26 UTC (rev 2241) +++ trunk/modules/ASTPP/lib/ASTPP.pm 2009-03-11 02:46:52 UTC (rev 2242) @@ -109,7 +109,11 @@ $arg{xml} .= "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n"; $arg{xml} .= "<document type=\"freeswitch/xml\">\n"; $arg{xml} .= "<section name=\"dialplan\" description=\"ASTPP Dynamic Routing\">\n"; + if ($arg{DID} > 0) { + $arg{xml} .= "<context name=\"public\">\n"; + } else { $arg{xml} .= "<context name=\"default\">\n"; + }; $arg{xml} .= "<extension name=\"" . $arg{destination_number} . "\">\n"; $arg{xml} .= "<condition field=\"destination_number\" expression=\"" . $arg{destination_number} . "\">\n"; return $arg{xml}; @@ -123,6 +127,22 @@ return $arg{xml}; } +sub fs_dialplan_xml_did +# Return the dialplan code for an incoming call to a DID. +{ + my ($self, %arg) = @_; + my ( $sql, $trunkdata, $dialstring,$data ); + my $tmp = "SELECT * FROM dids WHERE number = " + . $self->{_astpp_db}->quote( $arg{did} ) . + " LIMIT 1"; + print STDERR $tmp; + $sql = $self->{_astpp_db}->prepare($tmp); + $sql->execute; + my $diddata = $sql->fetchrow_hashref; + $sql->finish; + return $diddata->{variables}; +} + sub fs_dialplan_xml_bridge #Return the bridge command along with details. This is only called if a call is approved. # Requires the following variables: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |