8 ast_add_reload voicemail
10 ast_enable_type voicegeneral
11 ast_enable_type voicemail
12 ast_enable_type voicezone
13 ast_enable_type dialplanvoice
15 voice_format
="wav49|gsm|wav"
20 voice_silencethreshold
=128
22 voice_emaildateformat
="%A, %B %d, %Y at %r"
23 voice_sendvoicemail
=no
31 voicegeneral_list
="format serveremail attach skipms maxsilence silencethreshold maxlogins emaildateformat sendvoicemail maxmsg maxmessage minmessage maxgreet"
32 voicegeneral_ext_list
=""
35 is_in_list
$1 ${voicegeneral_list} ${voicegeneral_ext_list}
39 voicebox_list
="context number password name email pager"
41 voicebox_listopt
="tz attach serveremail saycid dialout callback review operator envelope sayduration saydurationm"
44 is_in_list
$1 ${voicebox_list} ${voicebox_listopt}
48 check_add_voicebox
() {
49 if [ ! -z ${voicebox_number} ] ; then
50 [ -z "${voicebox_context}" ] && voicebox_context
=default
51 logdebug
1 "Adding Voicebox ${voicebox_number} in ${voicebox_context}"
52 # Construct the voicebox line
53 local line
="$voicebox_number => "
54 [ -z ${voicebox_tz} ] && voicebox_tz
=homeloc
55 [ -z ${voicebox_name} ] && voicebox_name
=OpenWRT
57 for i
in password name email pager
; do
58 eval "local value=\"\${voicebox_$i}\""
59 line
="${line}${value},"
62 # Then add named options.
63 for i
in ${voicebox_listopt} ; do
64 eval val
=\
${voicebox_$i}
65 [ -z ${val} ] || append line
"$i=$val" \|
68 # Check if the current voicebox context has anything
69 eval local cur
=\
${voicebox_section_$voicebox_context}
70 # if not add it to the list of contexts used
71 [ -z $cur ] && append voice_contextlist
"${voicebox_context}" " "
73 # Then add the voicebox line to the context
74 logdebug
4 "Add Voicebox $line to ${voicebox_context}"
75 append voicebox_section_
${voicebox_context} "$line" "$N"
78 # Then clear the settings for the next one.
79 for i
in ${voicebox_list} ${voicebox_listopt} ; do
80 eval unset voicebox_
$i
84 create_voicemailconf
() {
86 file=${DEST_DIR}/voicemail.conf
87 get_checksum voicemail_conf
$file
90 if [ -z ${voice_contextlist} ] ; then
94 echo "${asteriskuci_gen}[general]" > $file
95 for i
in ${voicegeneral_list} ; do
96 eval value
=\
${voice_$i}
97 if [ ! -z "$value" ] ; then
98 echo "$i=$value" >> $file
101 echo "${N}[zonemessages]" >> $file
102 echo "homeloc=${asterisk_zone}| Q IMp" >> $file
103 echo "${voicezone_list}" >> $file
104 for i
in ${voice_contextlist} ; do
105 echo "${N}[$i]" >> $file
106 eval "local cursection=\"\${voicebox_section_${i}}\""
107 echo "$cursection" >> $file
108 eval unset voicebox_section_
${i}
112 check_checksum
"$voicemail_conf" "$file" || ast_voicemail_restart
=$isempty
115 handle_voicegeneral
() {
117 if valid_voicemail
$1 $2 ; then
120 logerror
"Invalid general voice option: $1"
127 voicebox_context
=${1%[-_]*}
128 if [ ${voicebox_context} == $1 ] ; then
129 voicebox_context
=default
131 voicebox_number
=${1#*[-_]}
134 zone
) voicebox_tz
="$2" ;;
136 if valid_voicebox
$1 $2 ; then
137 eval voicebox_
$1="$2"
139 logerror
"Invalid voicebox option: $1"
145 # Locality options for voicemail
147 check_add_voicezone
() {
148 if [ ! -z "${voicezone_name}" ] ; then
149 [ -z "${voicezone_zone}" ] && voicezone_zone
=${asterisk_zone}
150 if [ -z "${voicezone_message}" ] ; then
151 voicezone_message
="Q IMp"
153 voicezone_message
=`echo "$voicezone_message"|tr \" \'`
155 append voicezone_list
"${voicezone_name}=${voicezone_zone}|${voicezone_message}" "${N}"
159 unset voicezone_message
166 zone
) voicezone_zone
="$2" ;;
167 message
) voicezone_message
="$2" ;;
168 *) logerror
"Invalid voicezone option: $1"
173 handle_dialplanvoice
() {
174 check_add dialplanvoice
177 dialplan|extension|voicecontext|voicebox
)
178 eval "dial_voice_$1=\"$2\"" ;;
179 *) logerror
"Invalid option: $1 for dialplanvoice"
184 check_add_dialplanvoice
() {
185 if [ ! -z "${dial_voice_dialplan}" -a ! -z "${dial_voice_extension}" ] ; then
186 local ext
="exten => ${dial_voice_extension},"
187 [ -z ${dial_voice_voicebox} ] && dial_voice_voicebox
=default
188 if [ -z ${dial_voice_voicebox} ] ; then
189 logerror
"Expecting voicebox for ${dial_voice_dialplan}/${dial_voice_extension}"
191 check_add_context
${dial_voice_dialplan}
192 local voiceext
="${dial_voice_voicebox}@${dial_voice_voicecontext}"
194 append dialplan_context_
${dial_voice_dialplan} "${ext}1,VoiceMailMain(${voiceext})" "${N}"
197 for i in dialplan extension voicecontext voicebox ; do
198 eval "unset dial_voice_
$i"
202 add_dialplan_voice() {
204 logdebug 1 "Adding Dialplan voice
$1 $2"
205 check_add_context "$context"
206 local ext="exten
=> $2,"
208 append dialplan_context_${context} "${ext}1,VoiceMailMain($3)" "${N}"
213 reload_voicemail
() astcmd
"module reload app_voicemail.so"
214 unload_voicemail
() astcmd
"module unload app_voicemail.so"
217 # vim: ts=2 sw=2 noet foldmethod=indent