[asterisk-commits] mmichelson: branch mmichelson/trunk-digiumphones r368090 - /team/mmichelson/t...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu May 31 14:58:51 CDT 2012


Author: mmichelson
Date: Thu May 31 14:58:47 2012
New Revision: 368090

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=368090
Log:
Incorporate review feedback from Matt and Kinsey.

* Only print e-mail headers to a metadata file if the header was retrieved successfully
* When updating message IDs for IMAP messages, only delete the old message if the new one is stored successfully
* Only call save_to_folder() if the folder in question is not already the INBOX
* Get rid of whitespace violations.


Modified:
    team/mmichelson/trunk-digiumphones/apps/app_voicemail.c

Modified: team/mmichelson/trunk-digiumphones/apps/app_voicemail.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/trunk-digiumphones/apps/app_voicemail.c?view=diff&rev=368090&r1=368089&r2=368090
==============================================================================
--- team/mmichelson/trunk-digiumphones/apps/app_voicemail.c (original)
+++ team/mmichelson/trunk-digiumphones/apps/app_voicemail.c Thu May 31 14:58:47 2012
@@ -2007,7 +2007,7 @@
 	}
 
 	duration_str = ast_variable_retrieve(msg_cfg, "message", "duration");
-	
+
 	if (!ast_strlen_zero(duration_str)) {
 		sscanf(duration_str, "%30d", &duration);
 	}
@@ -2020,11 +2020,13 @@
 	 * store it in an arbitrary folder. So we have to save it to the INBOX and then
 	 * move to the appropriate folder.
 	 */
-	vm_imap_delete(dir, msgnum, vmu);
-	imap_store_file(dir, vmu->mailbox, vmu->context, msgnum, chan, vmu, vmfmts,
-			duration, vms, ast_variable_retrieve(msg_cfg, "message", "flag"), msg_id);
-	save_to_folder(vmu, vms, msgnum, folder, NULL, 1);
-
+	if (!imap_store_file(dir, vmu->mailbox, vmu->context, msgnum, chan, vmu, vmfmts,
+			duration, vms, ast_variable_retrieve(msg_cfg, "message", "flag"), msg_id)) {
+		if (folder != NEW_FOLDER) {
+			save_to_folder(vmu, vms, msgnum, folder, NULL, 1);
+		}
+		vm_imap_delete(dir, msgnum, vmu);
+	}
 	close_mailbox(vms, vmu);
 	ast_channel_unref(chan);
 }
@@ -2206,22 +2208,30 @@
 
 	fprintf(text_file_ptr, "%s\n", "[message]");
 
-	get_header_by_tag(header_content, "X-Asterisk-VM-Caller-ID-Name:", buf, sizeof(buf));
-	fprintf(text_file_ptr, "callerid=\"%s\" ", S_OR(buf, ""));
-	get_header_by_tag(header_content, "X-Asterisk-VM-Caller-ID-Num:", buf, sizeof(buf));
-	fprintf(text_file_ptr, "<%s>\n", S_OR(buf, ""));
-	get_header_by_tag(header_content, "X-Asterisk-VM-Context:", buf, sizeof(buf));
-	fprintf(text_file_ptr, "context=%s\n", S_OR(buf, ""));
-	get_header_by_tag(header_content, "X-Asterisk-VM-Orig-time:", buf, sizeof(buf));
-	fprintf(text_file_ptr, "origtime=%s\n", S_OR(buf, ""));
-	get_header_by_tag(header_content, "X-Asterisk-VM-Duration:", buf, sizeof(buf));
-	fprintf(text_file_ptr, "duration=%s\n", S_OR(buf, ""));
-	get_header_by_tag(header_content, "X-Asterisk-VM-Category:", buf, sizeof(buf));
-	fprintf(text_file_ptr, "category=%s\n", S_OR(buf, ""));
-	get_header_by_tag(header_content, "X-Asterisk-VM-Flag:", buf, sizeof(buf));
-	fprintf(text_file_ptr, "flag=%s\n", S_OR(buf, ""));
-	get_header_by_tag(header_content, "X-Asterisk-VM-Message-ID:", buf, sizeof(buf));
-	fprintf(text_file_ptr, "msg_id=%s\n", S_OR(buf, ""));
+	if (get_header_by_tag(header_content, "X-Asterisk-VM-Caller-ID-Name:", buf, sizeof(buf))) {
+		fprintf(text_file_ptr, "callerid=\"%s\" ", S_OR(buf, ""));
+	}
+	if (get_header_by_tag(header_content, "X-Asterisk-VM-Caller-ID-Num:", buf, sizeof(buf))) {
+		fprintf(text_file_ptr, "<%s>\n", S_OR(buf, ""));
+	}
+	if (get_header_by_tag(header_content, "X-Asterisk-VM-Context:", buf, sizeof(buf))) {
+		fprintf(text_file_ptr, "context=%s\n", S_OR(buf, ""));
+	}
+	if (get_header_by_tag(header_content, "X-Asterisk-VM-Orig-time:", buf, sizeof(buf))) {
+		fprintf(text_file_ptr, "origtime=%s\n", S_OR(buf, ""));
+	}
+	if (get_header_by_tag(header_content, "X-Asterisk-VM-Duration:", buf, sizeof(buf))) {
+		fprintf(text_file_ptr, "duration=%s\n", S_OR(buf, ""));
+	}
+	if (get_header_by_tag(header_content, "X-Asterisk-VM-Category:", buf, sizeof(buf))) {
+		fprintf(text_file_ptr, "category=%s\n", S_OR(buf, ""));
+	}
+	if (get_header_by_tag(header_content, "X-Asterisk-VM-Flag:", buf, sizeof(buf))) {
+		fprintf(text_file_ptr, "flag=%s\n", S_OR(buf, ""));
+	}
+	if (get_header_by_tag(header_content, "X-Asterisk-VM-Message-ID:", buf, sizeof(buf))) {
+		fprintf(text_file_ptr, "msg_id=%s\n", S_OR(buf, ""));
+	}
 	fclose(text_file_ptr);
 
 exit:
@@ -7975,7 +7985,7 @@
 #endif
 		memcpy(&vmstmp, vms, sizeof(vmstmp));
 
- 		RETRIEVE(dir, curmsg, sender->mailbox, sender->context);
+		RETRIEVE(dir, curmsg, sender->mailbox, sender->context);
 #ifdef IMAP_STORAGE
 		make_file(filename, sizeof(filename), dir, curmsg);
 		strncat(filename, ".txt", sizeof(filename) - strlen(filename) - 1);
@@ -11491,7 +11501,7 @@
 	if (!var) {
 		return -1;
 	}
-	
+
 	cat = ast_category_get(msg_cfg, "message");
 	if (!cat) {
 		ast_log(LOG_ERROR, "Voicemail data file %s/%d.txt has no [message] category?\n", dir, msg);




More information about the asterisk-commits mailing list