[Asterisk-Dev] ASTCC: Asterisk Calling Card Solution

The Traveller traveler at xs4all.nl
Sat Jul 17 07:40:22 MST 2004


Hey Mark,

On Wed, Jul 14, 2004 at 00:24:08 -0500, Mark Spencer wrote:

> I am hereby announcing the immediate availablity of ASTCC for *alpha*
> testing.  ASTCC is an AGI script and CGI script which greatly simplifies
> the task of creating a calling card application on Asterisk.  Just check
> it out of Asterisk CVS as module astcc:
> 
> export CVSROOT=:pserver:anoncvs at cvs.digium.com:/usr/cvsroot
> cvs login    (password is anoncvs)
> cvs co astcc
> 
> ASTCC is, of course, distributed under GNU GPL.  I hope you enjoy!

Great app!  I bumped into several minor problems:

- The admin-script, when asking it to create the database, it literally
tries to add the database itself, instead of just trying to populate
an existing database you give it.  If it finds that the database was
already created and just needs to be populated, it fails completely.
Took me some time to track that one down.  :-)

- The AGI-script does not support the Zap-technology out of the box,
neither does it enforce any time-limits (although the latter seems to
have been prepared, except that "$maxmins" is not passed to "trytrunk()".

- After enabling the time-limit, I noticed that there can be situations
in which the call goes through, but with "$maxmins" set to "0", if the
caller has exactly the amount of credit left to set up the call.  This
would allow the call to go on for an unlimited time.  :-)

- The handling of the time-limit could be done much more graceful
using the "L"-option to app_dial, so the caller can be warned in advance
before the call is hung up.


I've attached a diff to this mail, fixing the last 3 points mentioned
above.  Adding support for the "Local" channel, as already suggested
on the list, should also be trivial.


PS: If you want, I can post it to the bug-tracker later.  My account there
seems to have expired, so I need to create a new one first.  :-)



     Grtz,

       Oliver
-------------- next part --------------
--- astcc.agi	2004-07-14 05:22:27.000000000 +0200
+++ astcc.agi.new	2004-07-17 16:15:27.000000000 +0200
@@ -222,7 +222,14 @@
 	$sth->finish;
 	return "CHANUNAVAIL" unless $res;
 	if ($res->{tech} eq "IAX2") {
-		$dialstr = "IAX2/$res->{path}/$phone|30|HS(" . ($maxtime * 60) . ")";
+		$dialstr = "IAX2/$res->{path}/$phone|30|HL(" . ($maxtime * 60 * 1000) . ":60000:30000)";
+		$res = $AGI->exec("DIAL $dialstr");
+		$answeredtime = $AGI->get_variable("ANSWEREDTIME");
+		$dialstatus = $AGI->get_variable("DIALSTATUS");
+		return $dialstatus;
+	}
+	if ($res->{tech} eq "Zap") {
+		$dialstr = "Zap/$res->{path}/$phone|30|HL(" . ($maxtime * 60 * 1000) . ":60000:30000)";
 		$res = $AGI->exec("DIAL $dialstr");
 		$answeredtime = $AGI->get_variable("ANSWEREDTIME");
 		$dialstatus = $AGI->get_variable("DIALSTATUS");
@@ -333,14 +340,20 @@
 	exit(0);
 }
 
-$res = &mystreamfile("astcc-pleasewait");
-exit(0) if $res < 0;
 
 $maxmins = int(($credit - $adjconn) / $adjcost);
+if ($maxmins <= 0.1) {
+	$res = &mystreamfile("astcc-notenough");
+	$AGI->stream_file("vm-goodbye") if (!$res);
+	exit(0);
+}
+
+$res = &mystreamfile("astcc-pleasewait");
+exit(0) if $res < 0;
 
 my @trunks = split(/:/, $numdata->{trunks});
 foreach $trunk (@trunks) {
-	$res = &trytrunk($trunk, $phoneno);
+	$res = &trytrunk($trunk, $phoneno, $maxmins);
 	if (!($res eq "CHANUNAVAIL") && !($res eq "CONGESTION")) {
 		# Ooh, something actually happend! 
 		if ($res eq "BUSY") {


More information about the asterisk-dev mailing list