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
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
98 [ -z "${voice_format}" ] && voice_format="wav49|gsm|wav"
99 echo "${asteriskuci_gen}[general]" > $file
100 for i in ${voicegeneral_list} ; do
101 eval value=\${voice_$i}
102 if [ ! -z "$value" ] ; then
103 echo "$i=$value" >> $file
106 echo "${N}[zonemessages]" >> $file
107 echo "homeloc=${asterisk_zone}| Q IMp" >> $file
108 echo "${voicezone_list}" >> $file
109 for i in ${voice_contextlist} ; do
110 echo "${N}[$i]" >> $file
111 eval "local cursection=\"\${voicebox_section_${i}}\""
112 echo "$cursection" >> $file
113 eval unset voicebox_section_${i}
117 check_checksum "$voicemail_conf" "$file" || ast_voicemail_restart=$isempty
120 handle_voicegeneral() {
123 format|format_ITEM*) append voice_format "$2" "|" ;;
126 if valid_voicemail $1 $2 ; then
129 logerror "Invalid general voice option: $1"
137 voicebox_context="${1%[-_]*}"
138 if [ "${voicebox_context}" == "$1" ] ; then
139 voicebox_context=default
141 voicebox_number=${1#*[-_]}
144 zone) voicebox_tz="$2" ;;
146 if valid_voicebox $1 $2 ; then
147 eval "voicebox_$1=\"$2\""
149 logerror "Invalid voicebox option: $1"
155 # Locality options for voicemail
157 check_add_voicezone() {
158 if [ ! -z "${voicezone_name}" ] ; then
159 [ -z "${voicezone_zone}" ] && voicezone_zone=${asterisk_zone}
160 if [ -z "${voicezone_message}" ] ; then
161 voicezone_message="Q IMp"
163 voicezone_message=`echo "$voicezone_message"|tr \" \'`
165 append voicezone_list "${voicezone_name}=${voicezone_zone}|${voicezone_message}" "${N}"
169 unset voicezone_message
176 name) voicezone_name="$2" ;;
177 zone) voicezone_zone="$2" ;;
178 message) voicezone_message="$2" ;;
179 *) logerror "Invalid voicezone option: $1"
184 handle_dialplanvoice() {
185 check_add dialplanvoice
188 dialplan|extension|voicecontext|voicebox)
189 eval "dial_voice_$1=\"$2\"" ;;
190 *) logerror "Invalid option: $1 for dialplanvoice"
195 check_add_dialplanvoice() {
196 if [ ! -z "${dial_voice_dialplan}" -a ! -z "${dial_voice_extension}" ] ; then
197 local ext="exten => ${dial_voice_extension},"
198 [ -z "${dial_voice_voicebox}" ] && dial_voice_voicebox=default
199 if [ -z "${dial_voice_voicebox}" ] ; then
200 logerror "Expecting voicebox for ${dial_voice_dialplan}/${dial_voice_extension}"
202 check_add_context ${dial_voice_dialplan}
203 local voiceext="${dial_voice_voicebox}@${dial_voice_voicecontext}"
205 append dialplan_context_${dial_voice_dialplan} "${ext}1,VoiceMailMain(${voiceext})" "${N}"
208 for i in dialplan extension voicecontext voicebox ; do
209 eval "unset dial_voice_$i"
214 enable_module res_adsi
215 enable_module app_voicemail
220 add_dialplan_voice() {
222 logdebug 1 "Adding Dialplan voice $1 $2"
223 check_add_context "$context"
224 local ext="exten => $2,"
226 append dialplan_context_${context} "${ext}1,VoiceMailMain($3)" "${N}"
231 reload_voicemail() astcmd "module reload app_voicemail.so"
232 unload_voicemail() astcmd "module unload app_voicemail.so"
235 # vim: ts=2 sw=2 noet foldmethod=indent