[asterisk-commits] tilghman: branch 1.6.2 r244320 - in /branches/1.6.2: ./ apps/app_voicemail.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Feb 1 17:34:15 CST 2010


Author: tilghman
Date: Mon Feb  1 17:34:13 2010
New Revision: 244320

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=244320
Log:
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)
  ........
................

Modified:
    branches/1.6.2/   (props changed)
    branches/1.6.2/apps/app_voicemail.c

Propchange: branches/1.6.2/
------------------------------------------------------------------------------
Binary property 'trunk-merged' - no diff available.

Modified: branches/1.6.2/apps/app_voicemail.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.6.2/apps/app_voicemail.c?view=diff&rev=244320&r1=244319&r2=244320
==============================================================================
--- branches/1.6.2/apps/app_voicemail.c (original)
+++ branches/1.6.2/apps/app_voicemail.c Mon Feb  1 17:34:13 2010
@@ -6292,7 +6292,7 @@
 #endif
 	int cmd = 0;
 	int retries = 0, prepend_duration = 0, already_recorded = 0;
-	char msgfile[PATH_MAX], backup[PATH_MAX];
+	char msgfile[PATH_MAX], backup[PATH_MAX], backup_textfile[PATH_MAX];
 	char textfile[PATH_MAX];
 	struct ast_config *msg_cfg;
 	struct ast_flags config_flags = { CONFIG_FLAG_NOCACHE };
@@ -6305,8 +6305,10 @@
 	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)) && msg_cfg != CONFIG_STATUS_FILEINVALID && (duration_str = ast_variable_retrieve(msg_cfg, "message", "duration"))) {
 		*duration = atoi(duration_str);
@@ -6343,11 +6345,15 @@
 				break;
 			}
 			
-			/* Back up the original file, so we can retry the prepend */
-			if (already_recorded)
+			/* Back up the original file, so we can retry the prepend and restore it after forward. */
+			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)
@@ -6403,10 +6409,14 @@
 
 	if (msg_cfg)
 		ast_config_destroy(msg_cfg);
-	if (already_recorded)
-		ast_filedelete(backup, NULL);
 	if (prepend_duration)
 		*duration = prepend_duration;
+
+	if (already_recorded && cmd == -1) {
+		/* restore original message if prepention cancelled */
+		ast_filerename(backup, msgfile, NULL);
+		rename(backup_textfile, textfile);
+	}
 
 	if (cmd == 't' || cmd == 'S')
 		cmd = 0;
@@ -6569,7 +6579,9 @@
 	int curmsg;
 	char urgent_str[7] = "";
 	char tmptxtfile[PATH_MAX];
-
+#ifndef IMAP_STORAGE
+	char msgfile[PATH_MAX], textfile[PATH_MAX], backup[PATH_MAX], backup_textfile[PATH_MAX];
+#endif
 	if (ast_test_flag((&globalflags), VM_FWDURGAUTO)) {
 		ast_copy_string(urgent_str, urgent ? "Urgent" : "", sizeof(urgent_str));
 	}
@@ -6778,6 +6790,20 @@
 #endif
 				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
 		}
 		DISPOSE(dir, curmsg);
 	}




More information about the asterisk-commits mailing list