--- 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") {