# Copyright (C) 2000-2001 Open Source Telecom Corporation.
#  
# This file is free software; as a special exception the author gives
# unlimited permission to copy and/or distribute it, with or without 
# modifications, as long as this notice is preserved.
# 
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# Play and record main menu

	answer
	clear %session.digits	# clear digit buffer
	play *::playrec	# "press 1 to play or 2 to record..."
	sleep 60	# wait up to 60 seconds
	return.exit	status="timeout"

^1	goto ::play	# if pressed 1, goto play
^2	goto ::record   # if pressed 2, goto record

^star			# if * hangup or subroutine return
	return.exit	status="ok"

^dtmf			# any other dtmf digit...
	play *::playrec0	# "you have selected an invalid entry..."
	goto playrec	# repeat menu

	.private

::play

# Play a selected prompt message

	clear %session.digits
	play *::playrec1	# "enter the three digit prompt you wish to play..."
	sleep 60	# wait up to 60 seconds for first keystroke
	goto playrec	# if none, go back to main menu

	# timeout or non-digit entry is invalid
^A
^B
^C
^D
^pound
^star
^timeout
	play *::playrec0	# "you have entered an invalid value..."
	goto playrec	# restart menu

^dtmf
	collect 3 5 "" "*#ABCD"		# collect all 3 digits, ignore non-digit	
	set %var1 prompts/ %session.digits .au	# build name of audio prompt file
	play %var1			# play the prompt file selected
	slog "annotation %audio.annotation"	# show annotation
	slog "played %audio.played samples"	# show play result
	goto playrec			# go back to main menu

::record

# Record a selected prompt message

	clear %session.digits
	play *::playrec2	# "enter the three digit prompt you wish to record..."
	sleep 60	# wait up to 60 seconds for first keystroke
	goto playrec	# if none, go back to main menu

	# timeout or non-digit entry is invalid
^A
^B
^C
^D
^pound
^star
^timeout
	play *::playrec0	# "you have entered an invalid value..."
	goto playrec	# restart menu

^dtmf	
	collect 3 5 "" "*#ABCD"		# collect all 3 digits, ignore non-digit	
	set %var1 prompts/ %session.digits .au	# build name of audio prompt file
	set %audio.annotation "playrec generated prompt"
	record %var1 120 "*#"		# record the prompt file selected
	slog "recorded %audio.recorded samples"	# bytes recorded
	goto playrec			# go back to main menu