;
; extension definitions
;


;
; general definitions
;
[general]
static=yes
writeprotect=no


;
; global definitions
;
[globals]
; currently none


;
; include other extension files
;
#include extensions-system.conf
#include extensions-vmauth.conf
#include extensions-forward.conf

;
; set a forwarding number
;
[set-forward]
exten => s,1,Playback(sm-020)
exten => s,2,Macro(vmauth,internal)
exten => s,3,Goto(incoming,s,1)

exten => s,103,Goto(set-forward-exten,s,103)


;
; set a forwarding number for this extension
;
[set-forward-exten]
exten => s,1,Playback(sm-020)
exten => s,2,Macro(vmauth,internal,${CALLERIDNUM})
exten => s,3,Goto(incoming,s,1)

exten => s,103,Macro(forward-set,internal, ${VMAUTH_EXTEN})
exten => s,104,Hangup()

;
; Standard Extension Macro:
;   ${ARG1} - Device(s) to ring
;   ${ARG2} - Dial options
;   rings device(s) for 30 seconds then forwards to voicemail
;
[macro-exten-standard]
exten => s,1,AGI(forward-get.agi,internal,${MACRO_EXTEN})
exten => s,2,GotoIf( $[ "${agiResult}" = "1" ] ? 3 : 30)
exten => s,3,GotoIf( $[ "${forwardType}" = "1" ] ? 10 : 4 )
exten => s,4,GotoIf( $[ "${forwardType}" = "2" ] ? 20 : 30 )

exten => s,10,SetVar(ringDevice=local/${forwardNumber}@internal)
exten => s,11,Goto(40)

exten => s,20,SetVar(ringDevice=${ARG1}&local/${forwardNumber}@outbound)
exten => s,21,Goto(40)

exten => s,30,SetVar(ringDevice=${ARG1})
exten => s,31,Goto(40)

exten => s,40,Dial(${ringDevice},30,jr${ARG2}${dialOptions})	; do the call
exten => s,41,Answer()						; answer the call
exten => s,42,Voicemail(u${MACRO_EXTEN}@internal)		; vm transfer - busy, na
exten => s,43,Goto(incoming,s,1)				; no voicemail for user

exten => o,1,Goto(incoming,s,1)
exten => t,1,Goto(incoming,s,1)
