summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Parker <jparker@digium.com>2007-06-07 20:10:47 +0000
committerJason Parker <jparker@digium.com>2007-06-07 20:10:47 +0000
commit20e1e1ad3c2840c184f800b247afd84bd30cac30 (patch)
tree6050f708833c4cdd9900d1f651cae8790b45836f
parent94f611ac682d076168db0e2e8730f12ca02fa9fe (diff)
Merged revisions 68211 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4 ................ r68211 | qwell | 2007-06-07 15:06:00 -0500 (Thu, 07 Jun 2007) | 12 lines Merged revisions 68204 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.2 ........ r68204 | qwell | 2007-06-07 15:02:50 -0500 (Thu, 07 Jun 2007) | 4 lines Don't try to save voicemail greetings unless the user presses '1' to accept/save. Issue 9904, patch by me. ........ ................ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@68220 65c4cc65-6c06-0410-ace0-fbb531ad65f3
-rw-r--r--apps/app_voicemail.c27
1 files changed, 19 insertions, 8 deletions
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index 7943cf072..787fc7b73 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -8545,6 +8545,7 @@ static int play_record_review(struct ast_channel *chan, char *playfile, char *re
int recorded = 0;
int message_exists = 0;
signed char zero_gain = 0;
+ char tempfile[PATH_MAX];
char *acceptdtmf = "#";
char *canceldtmf = "";
@@ -8556,6 +8557,11 @@ static int play_record_review(struct ast_channel *chan, char *playfile, char *re
return -1;
}
+ if (!outsidecaller)
+ snprintf(tempfile, sizeof(tempfile), "%s.tmp", recordfile);
+ else
+ ast_copy_string(tempfile, recordfile, sizeof(tempfile));
+
cmd = '3'; /* Want to start by recording */
while ((cmd >= 0) && (cmd != 't')) {
@@ -8569,9 +8575,10 @@ static int play_record_review(struct ast_channel *chan, char *playfile, char *re
/* Otherwise 1 is to save the existing message */
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "Saving message as is\n");
- ast_stream_and_wait(chan, "vm-msgsaved", "");
if (!outsidecaller)
- {
+ ast_filerename(tempfile, recordfile, NULL);
+ ast_stream_and_wait(chan, "vm-msgsaved", "");
+ if (!outsidecaller) {
STORE(recordfile, vmu->mailbox, vmu->context, -1, chan, vmu, fmt, *duration, vms);
DISPOSE(recordfile, -1);
}
@@ -8582,7 +8589,7 @@ static int play_record_review(struct ast_channel *chan, char *playfile, char *re
/* Review */
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "Reviewing the message\n");
- cmd = ast_stream_and_wait(chan, recordfile, AST_DIGIT_ANY);
+ cmd = ast_stream_and_wait(chan, tempfile, AST_DIGIT_ANY);
break;
case '3':
message_exists = 0;
@@ -8604,11 +8611,15 @@ static int play_record_review(struct ast_channel *chan, char *playfile, char *re
ast_channel_setoption(chan, AST_OPTION_RXGAIN, &record_gain, sizeof(record_gain), 0);
if (ast_test_flag(vmu, VM_OPERATOR))
canceldtmf = "0";
- cmd = ast_play_and_record_full(chan, playfile, recordfile, maxtime, fmt, duration, silencethreshold, maxsilence, unlockdir, acceptdtmf, canceldtmf);
+ cmd = ast_play_and_record_full(chan, playfile, tempfile, maxtime, fmt, duration, silencethreshold, maxsilence, unlockdir, acceptdtmf, canceldtmf);
if (record_gain)
ast_channel_setoption(chan, AST_OPTION_RXGAIN, &zero_gain, sizeof(zero_gain), 0);
if (cmd == -1) {
- /* User has hung up, no options to give */
+ /* User has hung up, no options to give */
+ if (!outsidecaller) {
+ /* user was recording a greeting and they hung up, so let's delete the recording. */
+ vm_delete(tempfile);
+ }
return cmd;
}
if (cmd == '0') {
@@ -8622,14 +8633,14 @@ static int play_record_review(struct ast_channel *chan, char *playfile, char *re
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "Message too short\n");
cmd = ast_play_and_wait(chan, "vm-tooshort");
- cmd = vm_delete(recordfile);
+ cmd = vm_delete(tempfile);
break;
}
else if (vmu->review && (cmd == 2 && *duration < (maxsilence + 3))) {
/* Message is all silence */
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "Nothing recorded\n");
- cmd = vm_delete(recordfile);
+ cmd = vm_delete(tempfile);
cmd = ast_play_and_wait(chan, "vm-nothingrecorded");
if (!cmd)
cmd = ast_play_and_wait(chan, "vm-speakup");
@@ -8658,7 +8669,7 @@ static int play_record_review(struct ast_channel *chan, char *playfile, char *re
case '*':
/* Cancel recording, delete message, offer to take another message*/
cmd = ast_play_and_wait(chan, "vm-deleted");
- cmd = vm_delete(recordfile);
+ cmd = vm_delete(tempfile);
if (outsidecaller) {
res = vm_exec(chan, NULL);
return res;