summaryrefslogtreecommitdiff
path: root/apps/app_voicemail.c
diff options
context:
space:
mode:
authorJonathan Rose <jrose@digium.com>2011-12-16 22:00:37 +0000
committerJonathan Rose <jrose@digium.com>2011-12-16 22:00:37 +0000
commit1b0741c7db397114602da1e422125ad51d598b5c (patch)
tree99d387ec8549906e7d82fa87eaed6e1a4ec9ec73 /apps/app_voicemail.c
parente71bad495894ec9dc8d041b9b4bbca75d35cf1a3 (diff)
Voicemail with the saycid option will now play a caller's name based on cid if available.
In order to check the availability of the caller's name, app_voicemail will check for an audio file in <astspooldir>/recordings/callerids/ This change sets a precedent for where to put recordings of names. Currently the idea is that recordings here could also be used for applications like confbridge and meetme to find recorded names in this folder from callerid (when another recording isn't available) (closes issue ASTERISK-18565) Reporter: Russell Brown Patches: r uploaded by Russel Brown (license 6182) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@348416 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'apps/app_voicemail.c')
-rw-r--r--apps/app_voicemail.c38
1 files changed, 27 insertions, 11 deletions
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index a62a39b87..f4414d68b 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -7605,7 +7605,7 @@ static int play_message_datetime(struct ast_channel *chan, struct ast_vm_user *v
-static int play_message_callerid(struct ast_channel *chan, struct vm_state *vms, char *cid, const char *context, int callback)
+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;
@@ -7637,7 +7637,8 @@ static int play_message_callerid(struct ast_channel *chan, struct vm_state *vms,
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 */
+ /* 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) {
ast_verb(3, "Playing envelope info: CID number '%s' matches mailbox number, playing recorded name\n", callerid);
if (!callback)
@@ -7654,10 +7655,23 @@ static int play_message_callerid(struct ast_channel *chan, struct vm_state *vms,
}
} else if (!res) {
ast_debug(1, "VM-CID: Numeric caller id: (%s)\n", callerid);
- /* 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);
+ /* 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/recordings/callerids/%s", ast_config_AST_SPOOL_DIR, callerid);
+ if (!saycidnumber && ast_fileexists(prefile, NULL, NULL) > 0) {
+ ast_verb(3, "Playing recorded name for CID number '%s' - '%s'\n", callerid,prefile);
+ wait_file2(chan, vms, "vm-from");
+ res = ast_stream_and_wait(chan, prefile, "");
+ ast_verb(3, "Played recorded name result '%d'\n", res);
+ } else {
+ /* Since this is all nicely figured out, why not say "from phone number" in this case" */
+ 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 */
@@ -7842,7 +7856,7 @@ static int play_message(struct ast_channel *chan, struct ast_vm_user *vmu, struc
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);
+ 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);
@@ -13452,10 +13466,12 @@ static int advanced_options(struct ast_channel *chan, struct ast_vm_user *vmu, s
context = ast_variable_retrieve(msg_cfg, "message", "macrocontext");
switch (option) {
case 3: /* Play message envelope */
- if (!res)
+ if (!res) {
res = play_message_datetime(chan, vmu, origtime, filename);
- if (!res)
- res = play_message_callerid(chan, vms, cid, context, 0);
+ }
+ if (!res) {
+ res = play_message_callerid(chan, vms, cid, context, 0, 1);
+ }
res = 't';
break;
@@ -13515,7 +13531,7 @@ static int advanced_options(struct ast_channel *chan, struct ast_vm_user *vmu, s
ast_verb(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);
+ 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 */