#-------------------------------------------------------------------
# Application Teleperformance-ani_v3.tcl
#-------------------------------------------------------------------
#
# Copyright (c) 1998, 1999, 2000 by Cisco Systems, Inc.
# All rights reserved.
#-------------------------------------------------------------------
#
# This tcl script replaces the SESSION application for a POTS call
# leg. If the CLID matches one of the particular patterns, it's
# translation into a new CLID is done. In some cases, presentation
# restriction is forced. Otherwise CLID gets the default value.
#
# If DID is configured, just place the call to the DNIS. Otherwise,
# output dial-tone and collect digits from the caller against the
# dial-plan. Then place the call. If successful, connect it up,
# otherwise the caller should hear a busy or congested signal.
proc act_Setup { } {
global clid
global dest
global beep
global clid_new
set beep 0
if { [infotag get leg_isdid] } {
set dest [infotag get leg_dnis]
set clid [infotag get leg_ani]
leg proceeding leg_incoming
set clid_len [string length $clid]
set clid5 [string range $clid 0 4]
set clid7 [string range $clid 0 6]
set clid8 [string range $clid 0 7]
set clid9 [string range $clid 0 8]
set clid6a [string range $clid 5 5]
set clid7a [string range $clid 6 6]
set clid8a [string range $clid 7 7]
set clid9a [string range $clid 8 8]
set clid10a [string range $clid 9 9]
set clid_rst [string range $clid 2 $clid_len]
# Geo A-numbers 211*
if { ($clid7 == "2117606") ||
($clid9 == "211300095") ||
($clid9 == "211300166") ||
($clid8 == "21118807" && $clid9a >= "5" && $clid9a <= "9") ||
($clid8 == "21118839" && $clid9a >= "0" && $clid9a <= "2") ||
($clid8 == "21188010" && $clid9a >= "0" && $clid9a <= "4") ||
($clid8 == "21118106" && $clid9a >= "0" && $clid9a <= "4") ||
($clid8 == "21118708" && $clid9a >= "0" && $clid9a <= "4") } {
set callInfo(originationNum) $clid
set callInfo(originationNumPI) presentation_allowed
set callInfo(originationNumSI) network_provided
# Geo A-numbers 210*
} elseif { ($clid7 == "2109490" && $clid8a >= "5" && $clid8a <= "9") ||
($clid7 == "2109468") ||
($clid7 == "2109468") } {
set callInfo(originationNum) $clid
set callInfo(originationNumPI) presentation_allowed
set callInfo(originationNumSI) network_provided
# Cellphone A-numbers
} elseif { ($clid7 == "6944489") ||
($clid7 == "6933790") ||
($clid7 == "6944483" && $clid8a == "0") ||
($clid7 == "6944483" && $clid8a >= "6" $clid8a <= "9") ||
($clid7 == "6944482" && $clid8a >= "0" $clid8a <= "1") ||
($clid7 == "6944482" && $clid8a >= "3" $clid8a <= "5") } {
set callInfo(originationNum) $clid
set callInfo(originationNumPI) presentation_allowed
set callInfo(originationNumSI) network_provided
# Fallback to KEFALIKO
} else {
set dest_new 2109468000
set callInfo(originationNum) $dest_new
set callInfo(originationNumPI) presentation_allowed
set callInfo(originationNumSI) network_provided
}
leg setup $dest callInfo leg_incoming
fsm setstate PLACECALL
} else {
leg setupack leg_incoming
playtone leg_incoming tn_dial
set param(dialPlan) true
leg collectdigits leg_incoming param
}
}
proc act_GotDest { } {
global dest
set status [infotag get evt_status]
if { $status == "cd_004" } {
set dest [infotag get evt_dcdigits]
leg proceeding leg_incoming
leg setup $dest callInfo leg_incoming
} else {
puts "\nCall [infotag get con_all] got event $status collecting destination"
# use invalid-number cause code
leg disconnect leg_incoming -c28
call close
}
}
proc act_CallSetupDone { } {
global beep
set status [infotag get evt_status]
if { $status == "ls_000"} {
set creditTimeLeft [infotag get leg_settlement_time leg_all]
if { ($creditTimeLeft == "unlimited") ||
($creditTimeLeft == "uninitialized") } {
puts "\n Unlimited Time"
} else {
# start the timer for ...
if { $creditTimeLeft < 10 } {
set beep 1
set delay $creditTimeLeft
} else {
set delay [expr $creditTimeLeft - 10]
}
timer start leg_timer $delay leg_incoming
}
} else {
puts "Call [infotag get con_all] got event $status collecting destination"
call close
}
}
proc act_Timer { } {
global beep
global incoming
global outgoing
set incoming [infotag get leg_incoming]
set outgoing [infotag get leg_outgoing]
if { $beep == 0 } {
#insert a beep ...to the caller
connection destroy con_all
set beep 1
} else {
connection destroy con_all
fsm setstate LASTWARN
}
}
proc act_LastWarn { } {
media play leg_incoming flash:out_of_time.au
}
proc act_Destroy { } {
media play leg_incoming flash:beep.au
}
proc act_Beeped { } {
global incoming
global outgoing
connection create $incoming $outgoing
}
proc act_ConnectedAgain { } {
timer start leg_timer 10 leg_incoming
}
proc act_Ignore { } {
# Dummy
puts "Event Capture"
}
proc act_Cleanup { } {
call close
}
#------------------
# State Machine
#----------------------------------
set fsm(any_state,ev_disconnected) "act_Cleanup same_state"
set fsm(CALL_INIT,ev_setup_indication) "act_Setup GETDEST"
set fsm(GETDEST,ev_collectdigits_done) "act_GotDest PLACECALL"
set fsm(PLACECALL,ev_setup_done) "act_CallSetupDone CALLACTIVE"
set fsm(CALLACTIVE,ev_leg_timer) "act_Timer INSERTBEEP"
set fsm(INSERTBEEP,ev_destroy_done) "act_Destroy same_state"
set fsm(INSERTBEEP,ev_media_done) "act_Beeped same_state"
set fsm(INSERTBEEP,ev_create_done) "act_ConnectedAgain CALLACTIVE"
set fsm(LASTWARN,ev_destroy_done) "act_LastWarn CALLDISCONNECT"
set fsm(CALLACTIVE,ev_disconnected) "act_Cleanup CALLDISCONNECT"
set fsm(CALLDISCONNECT,ev_disconnected) "act_Cleanup same_state"
set fsm(CALLDISCONNECT,ev_media_done) "act_Cleanup same_state"
set fsm(CALLDISCONNECT,ev_disconnect_done) "act_Cleanup same_state"
set fsm(CALLDISCONNECT,ev_leg_timer) "act_Cleanup same_state"