[Astpp-commit] SF.net SVN: astpp:[2301] trunk
Brought to you by:
darrenkw
From: <dar...@us...> - 2010-02-12 04:14:33
|
Revision: 2301 http://astpp.svn.sourceforge.net/astpp/?rev=2301&view=rev Author: darrenkw Date: 2010-02-12 04:14:25 +0000 (Fri, 12 Feb 2010) Log Message: ----------- Add a couple of missing perl modules. Adjust the xml that is returned when a record is not found. Modified Paths: -------------- trunk/Makefile trunk/freeswitch/astpp-fs-xml.pl trunk/modules/ASTPP/lib/ASTPP.pm Modified: trunk/Makefile =================================================================== --- trunk/Makefile 2010-02-10 05:33:45 UTC (rev 2300) +++ trunk/Makefile 2010-02-12 04:14:25 UTC (rev 2301) @@ -138,6 +138,7 @@ perl -MCPAN -e "install DateTime::TimeZone"; perl -MCPAN -e "install DateTime"; perl -MCPAN -e "install Locale::gettext_pp"; + perl -MCPAN -e "install XML::Simple"; cd modules/ASTPP && perl Makefile.PL && make && make install && cd ../../ Modified: trunk/freeswitch/astpp-fs-xml.pl =================================================================== --- trunk/freeswitch/astpp-fs-xml.pl 2010-02-10 05:33:45 UTC (rev 2300) +++ trunk/freeswitch/astpp-fs-xml.pl 2010-02-12 04:14:25 UTC (rev 2301) @@ -23,7 +23,7 @@ use strict; use vars - qw($cdr_db $params $ASTPP @output $config $freeswitch_db $astpp_db $verbosity ); + qw($void_xml $cdr_db $params $ASTPP @output $config $freeswitch_db $astpp_db $verbosity ); use Locale::gettext_pp qw(:locale_h); require "/usr/local/astpp/astpp-common.pl"; $ENV{LANGUAGE} = "en"; # de, es, br - whatever @@ -35,6 +35,13 @@ $ASTPP = ASTPP->new; $ASTPP->set_verbosity(4); #Tell ASTPP debugging how verbose we want to be. +$void_xml = "<?xml version=\"1.0\"?>\n"; +$void_xml .= "<document type=\"freeswitch/xml\">\n"; +$void_xml .= "<section name=\"result\">\n"; +$void_xml .= "<result status=\"not found\" />"; +$void_xml .= "</section>\n"; +$void_xml .= "</document>\n"; + sub initialize() { $config = &load_config(); $astpp_db = &connect_db( $config, @output ); @@ -120,9 +127,8 @@ $xml .= "<action application=\"reject\" data=\"CANNOT RETRIEVE ACCOUNT\"/>\n"; $xml = $ASTPP->fs_dialplan_xml_footer( xml => $xml ); -# print $xml; $ASTPP->debug( debug => "Returning nothing so dialplan can continue." ); - print ""; + print $void_xml; exit(0); } @@ -248,8 +254,8 @@ $xml .= "</extension>\n"; $xml .= "</context>\n"; $xml .= "<context name=\"default\">\n"; - $xml .= "<extension name=\"" . $arg{destination_number} . "\">\n"; - $xml .= "<condition field=\"destination_number\" expression=\"" . $arg{destination_number} . "\">\n"; + $xml .= "<extension name=\"" . $params->{'Caller-Destination-Number'} . "\">\n"; + $xml .= "<condition field=\"destination_number\" expression=\"" . $params->{'Caller-Destination-Number'} . "\">\n"; $xml .= $returned_data; } else { @@ -304,9 +310,10 @@ #domain 192.168.2.119 #ip 192.168.2.119 + my $user_count = 0; if ($params->{'user'}) { $xml = $ASTPP->fs_directory_xml_header( xml => $xml ); - $xml = $ASTPP->fs_directory_xml( + ($xml,$user_count) = $ASTPP->fs_directory_xml( xml => $xml, ip => $params->{'ip'}, user => $params->{'user'}, @@ -314,8 +321,14 @@ ); $xml = $ASTPP->fs_directory_xml_footer( xml => $xml ); } + $ASTPP->debug( debug => $xml ); - print $xml; + $ASTPP->debug( debug => $user_count ); + if ($user_count > 0) { + print $xml; + } else { + print $void_xml; + } } elsif ( $params->{cdr} ) { print header( -type => 'text/plain' ); Modified: trunk/modules/ASTPP/lib/ASTPP.pm =================================================================== --- trunk/modules/ASTPP/lib/ASTPP.pm 2010-02-10 05:33:45 UTC (rev 2300) +++ trunk/modules/ASTPP/lib/ASTPP.pm 2010-02-12 04:14:25 UTC (rev 2301) @@ -773,9 +773,11 @@ { my ($self, %arg) = @_; my ($sql,$sql1,$tmp,$tmp1); + my $user_count = 0; $arg{xml} .= "<domain name=\"" . $arg{domain} . "\">"; my @sip_users = &fs_list_sip_usernames($self,%arg); foreach my $record (@sip_users) { + $user_count++; $arg{xml} .= "<user id=\"" . $record->{username} . "\" mailbox=\"" . $record->{mailbox} . "\">\n"; $arg{xml} .= "<params>\n"; my @params = &fs_list_sip_params($self,$record->{id}); @@ -793,6 +795,7 @@ }; my @ip_users = &ip_address_authenticate($self,%arg); foreach my $record (@ip_users) { + $user_count++; # This is only temporary and should be removed # $record->{id} = 0; @@ -815,7 +818,7 @@ $arg{xml} .= "</user>\n"; } $arg{xml} .= "</domain>\n"; - return $arg{xml}; + return ($arg{xml},$user_count); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |