
[general]


[globals]
;Set(TIMEOUT(digit)=6)


;[local-incoming]
;include=services
;include=local-lines
;include=line-outgoing
;include=local-hangup
;include=>parkedcalls
;include=sip-outgoing

;[local-lines]
;include=sip-outgoing

[default]
include=services
;include=local-lines
include=sip-outgoing
include=line-incoming
include=parkedcalls

[sip-outgoing]
include=sip_outgoing
include=line-incoming
include=parkedcalls

;[sip_incoming]
;include=local-lines
;exten => _XXXXXXX,1,Dial(SIP/${EXTEN})

[line-incoming]
;exten => _6XXXXXX,1,macro(dialuser,SIP/${EXTEN},${EXTEN})
exten => _6XXXXXX,1,Dial(SIP/${EXTEN})

[sip_outgoing]
exten => _XXXXXXX,1,Dial(SIP/osaka/${EXTEN})
exten => _6XXXXXX,1,Dial(SIP/${EXTEN})
;exten => _6XXXXXX,1,Playback(hello-world)
;exten => _.,1,Dial(SIP/osaka/${EXTEN})
;exten => _.,n,WaitExten()
;exten => 6,1,Dial(SIP/osaka/${EXTEN})
;exten => 6,n,WaitExten(2)
;exten => 7,1,Dial(SIP/osaka/${EXTEN})
;exten => 7,n,WaitExten(2)
;exten => 3,1,Dial(SIP/osaka/${EXTEN})
;exten => 3,n,WaitExten(2)
;exten => 0,1,Dial(SIP/osaka/${EXTEN})
;exten => 0,n,WaitExten(2)
;exten => 3,1,Dial(SIP/osaka/${EXTEN})
;exten => 3,n,WaitExten(2)
;exten => 0,1,Dial(SIP/osaka/${EXTEN})

;[line-outgoing]
;exten => _.,1,DigitTimeout,6
;exten => _.,1,macro(dialuser,Zap/g1/${EXTEN},${EXTEN})
;exten => _6.,1,macro(dialuser,Zap/g1/${EXTEN},${EXTEN})
;exten => 9,1,Dial(Zap/g1)
;exten => 9,n,Hanhup()
;exten => 2345,1,MeetMe(2345,i,9938)

;[services]
;ECHO extension - start with answer
exten => 600,1,answer
;Wait for channel
exten => 600,2,wait(2)
;Play a beep
exten => 600,3,playback(beep)
;Repeat everything
exten => 600,4,echo()
exten => 2345,1,MeetMe(2345,i,9938)
exten => 800,1,VoiceMailMain()
exten => 9000,1,Record(/tmp/asterisk-recording:gsm)
exten => 9000,2,Hangup()
exten => 9001,1,Answer()
exten => 9001,2,wait(2)
exten => 9001,3,playback(/tmp/asterisk-recording)
exten => 9001,4,wait(2)
exten => 9001,5,Hangup()
exten => 9002,1,Answer()
exten => 9002,2,Wait(2)
exten => 9002,3,playback(/var/lib/asterisk/sounds/FR00001)
exten => 9002,4,Wait(2)
exten => 9002,5,Hangup()
exten => 800,1,Voicemailmain()
exten => 800,n,hangup


;[local-lines]
;exten => _[1-9]XXXXXX,1,macro(dialuser,SIP/${EXTEN:4},@{EXTEN:4})

exten => _XXXXXXX,1,macro(dialuser,SIP/${EXTEN},${EXTEN})

; Let it go directly into the trunk line-outgoing context

;exten => h,1,noop(PM: Hangup received in local-lines)
;exten => h,n,hangup

[local-hangup]
exten => _!,1,answer
exten => _!,n,wait(4)
exten => _!,n,playback(pbx-invalid)
exten => _!,n,hangup

;-----------------------------------------------------------------



[macro-dialuser]
;exten => s,1,SetVar(_ALERT_INFO=<http://127.0.0.1/Bellcore-dr2>)
;exten => s,1,Set(TIMEOUT(digit)=6)
exten => s,1,dial(${ARG1},38,r)
exten => s,n,noop(PM: Dial ended !!)
exten => s,n,noop(${DIALSTATUS})
exten => s,n,Goto(s-${DIALSTATUS},1)

exten => s-NOANSWER,1,answer
exten => s-NOANSWER,n,wait(2)
;exten => s-NOANSWER,n,SayDigits(${ARG2})
;exten => s-NOANSWER,n,playback(FR00001)
exten => s-NOANSWER,n,VoiceMail(${MACRO_EXTEN}@default,u)
exten => s-NOANSWER,n,hangup

exten => s-BUSY,1,answer
exten => s-BUSY,n,wait(4)
exten => s-BUSY,n,SayDigits(${ARG2})
exten => s-BUSY,n,playback(vm-isonphone)
exten => s-BUSY,n,noop(PM-Busy)
exten => s-BUSY,n,VoiceMail(b${MACRO_EXTEN})
exten => s-BUSY,n,congestion
exten => s-BUSY,n,hangup

exten => s-CHANUNAVAIL,1,answer
exten => s-CHANUNAVAIL,n,wait(4)
;exten => s-CHANUNAVAIL,n,playback(pbx-invalid)
exten => s-CHANUNAVAIL,n,hangup

exten => _s-.,1,answer
exten => _s-.,n,wait(4)
exten => _s-.,n,SayDigits(${ARG2})
exten => _s-.,n,playback(FR00001)
exten => _s-.,n,hangup

exten => h,1,noop(PM: Hangup in macro !!)

