[asterisk-dev] Enhancement patch for app_voicemail
Russell Brown
russell at lls.lls.com
Thu Sep 15 11:39:40 CDT 2011
[Please excuse me if I'm breaking protocols; first post to the dev list
and I did look for this info on asterisk.org but didn't find it]
I've changed app_voicemail so that when announcing the Caller ID at the
start of a message it will look for a recording that matches the numeric
ID and play that instead of reading out the number.
It's a small patch and while I'm using it for my 1.4.42 system it'll
slot into 1.8 and 1.10 as the relevant bit of app_voicemail.c hasn't
changed.
What's the protocol for getting it accepted as an official mod?
FWIW, here's the patch against 1.4.42:
*** asterisk-1.4.42/apps/app_voicemail.c Wed May 4 17:08:50 2011
--- asterisk-1.4.42.rbmod/apps/app_voicemail.c Thu Sep 15 17:38:06 2011
***************
*** 5790,5797 ****
}
! static int play_message_callerid(struct ast_channel *chan, struct vm_state *vms, char *cid, const char *context, int callback)
{
int res = 0;
int i;
--- 5790,5799 ----
}
+ /* Added the saycidnumber arg to force Asterisk to say the number instead of the recording of the
+ * callers name when playing the message envelope or replying */
! static int play_message_callerid(struct ast_channel *chan, struct vm_state *vms, char *cid, const char *context, int callback, int saycidnumber)
{
int res = 0;
int i;
***************
*** 5821,5827 ****
if (!res) {
snprintf(prefile, sizeof(prefile), "%s%s/%s/greet", VM_SPOOL_DIR, context, callerid);
if (!ast_strlen_zero(prefile)) {
! /* See if we can find a recorded name for this person instead of their extension number */
if (ast_fileexists(prefile, NULL, NULL) > 0) {
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "Playing envelope info: CID number '%s' matches mailbox number, playing recorded name\n", callerid);
--- 5823,5830 ----
if (!res) {
snprintf(prefile, sizeof(prefile), "%s%s/%s/greet", VM_SPOOL_DIR, context, callerid);
if (!ast_strlen_zero(prefile)) {
! /* See if we can find a recorded name for this callerid
! * and if found, use that instead of saying number . */
if (ast_fileexists(prefile, NULL, NULL) > 0) {
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "Playing envelope info: CID number '%s' matches mailbox number, playing recorded name\n", callerid);
***************
*** 5843,5852 ****
else if (!res){
if (option_debug > 2)
ast_log(LOG_DEBUG, "VM-CID: Numeric caller id: (%s)\n",callerid);
! /* BB: Since this is all nicely figured out, why not say "from phone number" in this case" */
! if (!callback)
! res = wait_file2(chan, vms, "vm-from-phonenumber");
! res = ast_say_digit_str(chan, callerid, AST_DIGIT_ANY, chan->language);
}
} else {
/* Number unknown */
--- 5846,5868 ----
else if (!res){
if (option_debug > 2)
ast_log(LOG_DEBUG, "VM-CID: Numeric caller id: (%s)\n",callerid);
! /* RB: If there is a recording for this numeric callerid then play that */
! if (!callback) {
! /* See if we can find a recorded name for this person instead of their extension number */
! snprintf(prefile, sizeof(prefile), "%s/Callerids/%s", VM_SPOOL_DIR, callerid);
! if ( !saycidnumber && ast_fileexists(prefile, NULL, NULL) > 0 ) {
! if (option_verbose > 2)
! ast_verbose(VERBOSE_PREFIX_3 "Playing recorded name for CID number '%s' - '%s'\n", callerid,prefile);
! res = wait_file2(chan, vms, "vm-from");
! res = ast_stream_and_wait(chan, prefile, chan->language, "");
! }
! if( !res ) {
! /* BB: Since this is all nicely figured out, why not say "from phone number" in this case" */
! res = wait_file2(chan, vms, "vm-from-phonenumber");
! res = ast_say_digit_str(chan, callerid, AST_DIGIT_ANY, chan->language);
! }
! } else
! res = ast_say_digit_str(chan, callerid, AST_DIGIT_ANY, chan->language);
}
} else {
/* Number unknown */
***************
*** 6022,6028 ****
if ((!res) && (ast_test_flag(vmu, VM_ENVELOPE)))
res = play_message_datetime(chan, vmu, origtime, filename);
if ((!res) && (ast_test_flag(vmu, VM_SAYCID)))
! res = play_message_callerid(chan, vms, cid, context, 0);
if ((!res) && (ast_test_flag(vmu, VM_SAYDURATION)))
res = play_message_duration(chan, vms, duration, vmu->saydurationm);
/* Allow pressing '1' to skip envelope / callerid */
--- 6038,6044 ----
if ((!res) && (ast_test_flag(vmu, VM_ENVELOPE)))
res = play_message_datetime(chan, vmu, origtime, filename);
if ((!res) && (ast_test_flag(vmu, VM_SAYCID)))
! res = play_message_callerid(chan, vms, cid, context, 0, 0);
if ((!res) && (ast_test_flag(vmu, VM_SAYDURATION)))
res = play_message_duration(chan, vms, duration, vmu->saydurationm);
/* Allow pressing '1' to skip envelope / callerid */
***************
*** 9383,9389 ****
if (!res)
res = play_message_datetime(chan, vmu, origtime, filename);
if (!res)
! res = play_message_callerid(chan, vms, cid, context, 0);
res = 't';
break;
--- 9399,9405 ----
if (!res)
res = play_message_datetime(chan, vmu, origtime, filename);
if (!res)
! res = play_message_callerid(chan, vms, cid, context, 0, 1);
res = 't';
break;
***************
*** 9445,9451 ****
ast_verbose( VERBOSE_PREFIX_3 "Confirm CID number '%s' is number to use for callback\n", num);
res = ast_play_and_wait(chan, "vm-num-i-have");
if (!res)
! res = play_message_callerid(chan, vms, num, vmu->context, 1);
if (!res)
res = ast_play_and_wait(chan, "vm-tocallnum");
/* Only prompt for a caller-specified number if there is a dialout context specified */
--- 9461,9467 ----
ast_verbose( VERBOSE_PREFIX_3 "Confirm CID number '%s' is number to use for callback\n", num);
res = ast_play_and_wait(chan, "vm-num-i-have");
if (!res)
! res = play_message_callerid(chan, vms, num, vmu->context, 1, 1);
if (!res)
res = ast_play_and_wait(chan, "vm-tocallnum");
/* Only prompt for a caller-specified number if there is a dialout context specified */
--
Regards,
Russell
--------------------------------------------------------------------
| Russell Brown | MAIL: russell at lls.com PHONE: 01780 471800 |
| Lady Lodge Systems | WWW Work: http://www.lls.com |
| Peterborough, England | WWW Play: http://www.ruffle.me.uk |
--------------------------------------------------------------------
More information about the asterisk-dev
mailing list