diff options
author | tilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2010-02-01 23:30:19 +0000 |
---|---|---|
committer | tilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2010-02-01 23:30:19 +0000 |
commit | cd498d3f4de3c35898fd35e7e6ec8ccc1d98a6f6 (patch) | |
tree | f7a04d4e3582832b114952abc747ef34d3c75b70 | |
parent | 4125763ff405ec19ac25c7b4108dc02d73bb29c7 (diff) |
Merged revisions 244243 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
................
r244243 | tilghman | 2010-02-01 17:16:12 -0600 (Mon, 01 Feb 2010) | 18 lines
Merged revisions 244242 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r244242 | tilghman | 2010-02-01 17:13:44 -0600 (Mon, 01 Feb 2010) | 11 lines
Backup and restore original textfile, for prosthesis (gerund of prepend).
Also, fix menuselect such that changing voicemail build options correctly
causes rebuild.
(closes issue #16415)
Reported by: tomo1657
Patches:
prepention.patch uploaded by tomo1657 (license 484)
(with modifications by me to backport to 1.4)
........
................
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.0@244303 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r-- | apps/app_voicemail.c | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c index ad1b4a10b..881f33f35 100644 --- a/apps/app_voicemail.c +++ b/apps/app_voicemail.c @@ -5508,15 +5508,17 @@ leave_vm_out: struct ast_flags config_flags = { CONFIG_FLAG_NOCACHE }; struct ast_config *msg_cfg; const char *duration_str; - char msgfile[PATH_MAX], backup[PATH_MAX]; + char msgfile[PATH_MAX], backup[PATH_MAX], backup_textfile[PATH_MAX]; char textfile[PATH_MAX]; /* Must always populate duration correctly */ make_file(msgfile, sizeof(msgfile), curdir, curmsg); strcpy(textfile, msgfile); strcpy(backup, msgfile); + strcpy(backup_textfile, msgfile); strncat(textfile, ".txt", sizeof(textfile) - strlen(textfile) - 1); strncat(backup, "-bak", sizeof(backup) - strlen(backup) - 1); + strncat(backup_textfile, "-bak.txt", sizeof(backup_textfile) - strlen(backup_textfile) - 1); if ((msg_cfg = ast_config_load(textfile, config_flags)) && (duration_str = ast_variable_retrieve(msg_cfg, "message", "duration"))) { *duration = atoi(duration_str); @@ -5539,10 +5541,13 @@ leave_vm_out: } /* Back up the original file, so we can retry the prepend */ - if (already_recorded) + if (already_recorded) { ast_filecopy(backup, msgfile, NULL); - else + copy(backup_textfile, textfile); + } else { ast_filecopy(msgfile, backup, NULL); + copy(textfile,backup_textfile); + } already_recorded = 1; if (record_gain) @@ -5590,10 +5595,12 @@ leave_vm_out: if (msg_cfg) ast_config_destroy(msg_cfg); - if (already_recorded) - ast_filedelete(backup, NULL); if (prepend_duration) *duration = prepend_duration; + if (already_recorded) { + ast_filerename(backup, msgfile, NULL); + rename(backup_textfile, textfile); + } if (cmd == 't' || cmd == 'S') cmd = 0; @@ -5691,6 +5698,8 @@ leave_vm_out: #ifdef IMAP_STORAGE int todircount = 0; struct vm_state *dstvms; +#else + char textfile[PATH_MAX], backup[PATH_MAX], backup_textfile[PATH_MAX]; #endif char username[70] = ""; char fn[PATH_MAX]; /* for playback of name greeting */ @@ -5911,7 +5920,21 @@ leave_vm_out: if (!res) res = ast_play_and_wait(chan, "vm-saved"); */ res = ast_play_and_wait(chan, "vm-msgsaved"); - } + } +#ifndef IMAP_STORAGE + /* Restore original message without prepended message if backup exists */ + make_file(msgfile, sizeof(msgfile), dir, curmsg); + strcpy(textfile, msgfile); + strcpy(backup, msgfile); + strcpy(backup_textfile, msgfile); + strncat(textfile, ".txt", sizeof(textfile) - strlen(textfile) - 1); + strncat(backup, "-bak", sizeof(backup) - strlen(backup) - 1); + strncat(backup_textfile, "-bak.txt", sizeof(backup_textfile) - strlen(backup_textfile) - 1); + if (ast_fileexists(backup, NULL, NULL) > 0) { + ast_filerename(backup, msgfile, NULL); + rename(backup_textfile, textfile); + } +#endif } /* Remove surrogate file */ DISPOSE(dir, curmsg); |