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 logdebug 1 "Adding in order options"
58 for i in password name email pager ; do
59 eval "local value=\"\${voicebox_$i}\""
60 line="${line}${value},"
63 # Then add named options.
64 logdebug 2 "Adding in named options"
65 for i in ${voicebox_listopt} ; do
66 eval val=\${voicebox_$i}
67 [ -z "${val}" ] || append line "$i=$val" \|
70 logdebug 2 "Check for empty"
71 # Check if the current voicebox context has anything
72 eval local cur="\${voicebox_section_$voicebox_context}"
73 # if not add it to the list of contexts used
74 [ -z "$cur" ] && append voice_contextlist "${voicebox_context}" " "
76 # Then add the voicebox line to the context
77 logdebug 4 "Add Voicebox $line to ${voicebox_context}"
78 append voicebox_section_${voicebox_context} "$line" "$N"
81 # Then clear the settings for the next one.
82 for i in ${voicebox_list} ${voicebox_listopt} ; do
83 eval unset voicebox_$i
87 create_voicemailconf() {
89 file=${DEST_DIR}/voicemail.conf
90 get_checksum voicemail_conf $file
93 if [ -z ${voice_contextlist} ] ; then
97 echo "${asteriskuci_gen}[general]" > $file
98 for i in ${voicegeneral_list} ; do
99 eval value=\${voice_$i}
100 if [ ! -z "$value" ] ; then
101 echo "$i=$value" >> $file
104 echo "${N}[zonemessages]" >> $file
105 echo "homeloc=${asterisk_zone}| Q IMp" >> $file
106 echo "${voicezone_list}" >> $file
107 for i in ${voice_contextlist} ; do
108 echo "${N}[$i]" >> $file
109 eval "local cursection=\"\${voicebox_section_${i}}\""
110 echo "$cursection" >> $file
111 eval unset voicebox_section_${i}
115 check_checksum "$voicemail_conf" "$file" || ast_voicemail_restart=$isempty
118 handle_voicegeneral() {
120 if valid_voicemail $1 $2 ; then
123 logerror "Invalid general voice option: $1"
130 voicebox_context="${1%[-_]*}"
131 if [ "${voicebox_context}" == "$1" ] ; then
132 voicebox_context=default
134 voicebox_number=${1#*[-_]}
137 zone) voicebox_tz="$2" ;;
139 if valid_voicebox $1 $2 ; then
140 eval "voicebox_$1=\"$2\""
142 logerror "Invalid voicebox option: $1"
148 # Locality options for voicemail
150 check_add_voicezone() {
151 if [ ! -z "${voicezone_name}" ] ; then
152 [ -z "${voicezone_zone}" ] && voicezone_zone=${asterisk_zone}
153 if [ -z "${voicezone_message}" ] ; then
154 voicezone_message="Q IMp"
156 voicezone_message=`echo "$voicezone_message"|tr \" \'`
158 append voicezone_list "${voicezone_name}=${voicezone_zone}|${voicezone_message}" "${N}"
162 unset voicezone_message
169 name) voicezone_name="$2" ;;
170 zone) voicezone_zone="$2" ;;
171 message) voicezone_message="$2" ;;
172 *) logerror "Invalid voicezone option: $1"
177 handle_dialplanvoice() {
178 check_add dialplanvoice
181 dialplan|extension|voicecontext|voicebox)
182 eval "dial_voice_$1=\"$2\"" ;;
183 *) logerror "Invalid option: $1 for dialplanvoice"
188 check_add_dialplanvoice() {
189 if [ ! -z "${dial_voice_dialplan}" -a ! -z "${dial_voice_extension}" ] ; then
190 local ext="exten => ${dial_voice_extension},"
191 [ -z ${dial_voice_voicebox} ] && dial_voice_voicebox=default
192 if [ -z ${dial_voice_voicebox} ] ; then
193 logerror "Expecting voicebox for ${dial_voice_dialplan}/${dial_voice_extension}"
195 check_add_context ${dial_voice_dialplan}
196 local voiceext="${dial_voice_voicebox}@${dial_voice_voicecontext}"
198 append dialplan_context_${dial_voice_dialplan} "${ext}1,VoiceMailMain(${voiceext})" "${N}"
201 for i in dialplan extension voicecontext voicebox ; do
202 eval "unset dial_voice_$i"
206 add_dialplan_voice() {
208 logdebug 1 "Adding Dialplan voice $1 $2"
209 check_add_context "$context"
210 local ext="exten => $2,"
212 append dialplan_context_${context} "${ext}1,VoiceMailMain($3)" "${N}"
217 reload_voicemail() astcmd "module reload app_voicemail.so"
218 unload_voicemail() astcmd "module unload app_voicemail.so"
221 # vim: ts=2 sw=2 noet foldmethod=indent