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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue May 22 17:57:59 CDT 2012


Author: mmichelson
Date: Tue May 22 17:57:55 2012
New Revision: 367361

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=367361
Log:
Attempt at adding message ID support to IMAP.

I am making the commit and will test compile on a separate
machine where I have IMAP set up already.


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=367361&r1=367360&r2=367361
==============================================================================
--- team/mmichelson/trunk-digiumphones/apps/app_voicemail.c (original)
+++ team/mmichelson/trunk-digiumphones/apps/app_voicemail.c Tue May 22 17:57:55 2012
@@ -495,7 +495,7 @@
 static void get_mailbox_delimiter(struct vm_state *vms, MAILSTREAM *stream);
 static void mm_parsequota (MAILSTREAM *stream, unsigned char *msg, QUOTALIST *pquota);
 static void imap_mailbox_name(char *spec, size_t len, struct vm_state *vms, int box, int target);
-static int imap_store_file(const char *dir, const char *mailboxuser, const char *mailboxcontext, int msgnum, struct ast_channel *chan, struct ast_vm_user *vmu, char *fmt, int duration, struct vm_state *vms, const char *flag);
+static int imap_store_file(const char *dir, const char *mailboxuser, const char *mailboxcontext, int msgnum, struct ast_channel *chan, struct ast_vm_user *vmu, char *fmt, int duration, struct vm_state *vms, const char *flag, const char *msg_id);
 static void update_messages_by_imapuser(const char *user, unsigned long number);
 static int vm_delete(char *file);
 
@@ -837,7 +837,7 @@
 static char odbc_table[80];
 #define RETRIEVE(a,b,c,d) retrieve_file(a,b)
 #define DISPOSE(a,b) remove_file(a,b)
-#define STORE(a,b,c,d,e,f,g,h,i,j) store_file(a,b,c,d)
+#define STORE(a,b,c,d,e,f,g,h,i,j,k) store_file(a,b,c,d)
 #define EXISTS(a,b,c,d) (message_exists(a,b))
 #define RENAME(a,b,c,d,e,f,g,h) (rename_file(a,b,c,d,e,f))
 #define COPY(a,b,c,d,e,f,g,h) (copy_file(a,b,c,d,e,f))
@@ -845,7 +845,7 @@
 #else
 #ifdef IMAP_STORAGE
 #define DISPOSE(a,b) (imap_remove_file(a,b))
-#define STORE(a,b,c,d,e,f,g,h,i,j) (imap_store_file(a,b,c,d,e,f,g,h,i,j))
+#define STORE(a,b,c,d,e,f,g,h,i,j,k) (imap_store_file(a,b,c,d,e,f,g,h,i,j))
 #define RETRIEVE(a,b,c,d) imap_retrieve_file(a,b,c,d)
 #define EXISTS(a,b,c,d) (ast_fileexists(c,NULL,d) > 0)
 #define RENAME(a,b,c,d,e,f,g,h) (rename_file(g,h));
@@ -854,7 +854,7 @@
 #else
 #define RETRIEVE(a,b,c,d)
 #define DISPOSE(a,b)
-#define STORE(a,b,c,d,e,f,g,h,i,j)
+#define STORE(a,b,c,d,e,f,g,h,i,j,k)
 #define EXISTS(a,b,c,d) (ast_fileexists(c,NULL,d) > 0)
 #define RENAME(a,b,c,d,e,f,g,h) (rename_file(g,h));
 #define COPY(a,b,c,d,e,f,g,h) (copy_plain_file(g,h)); 
@@ -1026,11 +1026,11 @@
 static int dialout(struct ast_channel *chan, struct ast_vm_user *vmu, char *num, char *outgoing_context);
 static int play_record_review(struct ast_channel *chan, char *playfile, char *recordfile, int maxtime,
 			char *fmt, int outsidecaller, struct ast_vm_user *vmu, int *duration, int *sound_duration, const char *unlockdir,
-			signed char record_gain, struct vm_state *vms, char *flag);
+			signed char record_gain, struct vm_state *vms, char *flag, const char *msg_id);
 static int vm_tempgreeting(struct ast_channel *chan, struct ast_vm_user *vmu, struct vm_state *vms, char *fmtc, signed char record_gain);
 static int vm_play_folder_name(struct ast_channel *chan, char *mbox);
 static int notify_new_message(struct ast_channel *chan, struct ast_vm_user *vmu, struct vm_state *vms, int msgnum, long duration, char *fmt, char *cidnum, char *cidname, const char *flag);
-static void make_email_file(FILE *p, char *srcemail, struct ast_vm_user *vmu, int msgnum, char *context, char *mailbox, const char *fromfolder, char *cidnum, char *cidname, char *attach, char *attach2, char *format, int duration, int attach_user_voicemail, struct ast_channel *chan, const char *category, int imap, const char *flag);
+static void make_email_file(FILE *p, char *srcemail, struct ast_vm_user *vmu, int msgnum, char *context, char *mailbox, const char *fromfolder, char *cidnum, char *cidname, char *attach, char *attach2, char *format, int duration, int attach_user_voicemail, struct ast_channel *chan, const char *category, int imap, const char *flag, const char *msg_id);
 static void apply_options(struct ast_vm_user *vmu, const char *options);
 static int add_email_attachment(FILE *p, struct ast_vm_user *vmu, char *format, char *attach, char *greeting_attachment, char *mailbox, char *bound, char *filename, int last, int msgnum);
 static int is_valid_dtmf(const char *key);
@@ -2129,6 +2129,8 @@
 	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, ""));
 	fclose(text_file_ptr);
 
 exit:
@@ -2333,7 +2335,7 @@
 	}
 }
 
-static int imap_store_file(const char *dir, const char *mailboxuser, const char *mailboxcontext, int msgnum, struct ast_channel *chan, struct ast_vm_user *vmu, char *fmt, int duration, struct vm_state *vms, const char *flag)
+static int imap_store_file(const char *dir, const char *mailboxuser, const char *mailboxcontext, int msgnum, struct ast_channel *chan, struct ast_vm_user *vmu, char *fmt, int duration, struct vm_state *vms, const char *flag, const char *msg_id)
 {
 	char *myserveremail = serveremail;
 	char fn[PATH_MAX];
@@ -2422,7 +2424,7 @@
 	make_email_file(p, myserveremail, vmu, msgnum, vmu->context, vmu->mailbox, "INBOX",
 		chan ? S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL) : NULL,
 		chan ? S_COR(chan->caller.id.name.valid, chan->caller.id.name.str, NULL) : NULL,
-		fn, introfn, fmt, duration, 1, chan, NULL, 1, flag);
+		fn, introfn, fmt, duration, 1, chan, NULL, 1, flag, msg_id);
 	/* read mail file to memory */
 	len = ftell(p);
 	rewind(p);
@@ -4679,7 +4681,25 @@
  *
  * The email body, and base 64 encoded attachement (if any) are stored to the file identified by *p. This method does not actually send the email.  That is done by invoking the configure 'mailcmd' and piping this generated file into it, or with the sendemail() function.
  */
-static void make_email_file(FILE *p, char *srcemail, struct ast_vm_user *vmu, int msgnum, char *context, char *mailbox, const char *fromfolder, char *cidnum, char *cidname, char *attach, char *attach2, char *format, int duration, int attach_user_voicemail, struct ast_channel *chan, const char *category, int imap, const char *flag)
+static void make_email_file(FILE *p,
+		char *srcemail,
+		struct ast_vm_user *vmu,
+		int msgnum,
+		char *context,
+		char *mailbox,
+		const char *fromfolder,
+		char *cidnum,
+		char *cidname,
+		char *attach,
+		char *attach2,
+		char *format,
+		int duration,
+		int attach_user_voicemail,
+		struct ast_channel *chan,
+		const char *category,
+		int imap,
+		const char *flag,
+		const char *msg_id)
 {
 	char date[256];
 	char host[MAXHOSTNAMELEN] = "";
@@ -4836,6 +4856,7 @@
 		fprintf(p, "X-Asterisk-VM-Message-Type: %s" ENDL, msgnum > -1 ? "Message" : greeting_attachment);
 		fprintf(p, "X-Asterisk-VM-Orig-date: %s" ENDL, date);
 		fprintf(p, "X-Asterisk-VM-Orig-time: %ld" ENDL, (long) time(NULL));
+		fprintf(p, "X-Asterisk-VM-Message-ID: %s" ENDL, msg_id);
 	}
 	if (!ast_strlen_zero(cidnum)) {
 		fprintf(p, "X-Asterisk-CallerID: %s" ENDL, enc_cidnum);
@@ -5002,7 +5023,23 @@
 	return 0;
 }
 
-static int sendmail(char *srcemail, struct ast_vm_user *vmu, int msgnum, char *context, char *mailbox, const char *fromfolder, char *cidnum, char *cidname, char *attach, char *attach2, char *format, int duration, int attach_user_voicemail, struct ast_channel *chan, const char *category, const char *flag)
+static int sendmail(char *srcemail,
+		struct ast_vm_user *vmu,
+		int msgnum,
+		char *context,
+		char *mailbox,
+		const char *fromfolder,
+		char *cidnum,
+		char *cidname,
+		char *attach,
+		char *attach2,
+		char *format,
+		int duration,
+		int attach_user_voicemail,
+		struct ast_channel *chan,
+		const char *category,
+		const char *flag,
+		const char *msg_id)
 {
 	FILE *p = NULL;
 	char tmp[80] = "/tmp/astmail-XXXXXX";
@@ -5028,7 +5065,7 @@
 		ast_log(AST_LOG_WARNING, "Unable to launch '%s' (can't create temporary file)\n", mailcmd);
 		return -1;
 	} else {
-		make_email_file(p, srcemail, vmu, msgnum, context, mailbox, fromfolder, cidnum, cidname, attach, attach2, format, duration, attach_user_voicemail, chan, category, 0, flag);
+		make_email_file(p, srcemail, vmu, msgnum, context, mailbox, fromfolder, cidnum, cidname, attach, attach2, format, duration, attach_user_voicemail, chan, category, 0, flag, msg_id);
 		fclose(p);
 		snprintf(tmp2, sizeof(tmp2), "( %s < %s ; rm -f %s ) &", mailcmd, tmp, tmp);
 		ast_safe_system(tmp2);
@@ -5515,7 +5552,7 @@
 			 * exists in the database, but we want to force copying from the
 			 * filesystem (since only the FS contains the prepend). */
 			copy_plain_file(frompath, topath);
-			STORE(todir, recip->mailbox, recip->context, recipmsgnum, chan, recip, fmt, duration, NULL, NULL);
+			STORE(todir, recip->mailbox, recip->context, recipmsgnum, chan, recip, fmt, duration, NULL, NULL, NULL);
 			vm_delete(topath);
 #ifndef ODBC_STORAGE
 		}
@@ -5783,6 +5820,7 @@
 	/* We aren't currently doing anything with category, since it comes from a channel variable and
 	 * this function doesn't use channels, but this function could add that as an argument later. */
 	const char *category = NULL; /* pointless for now */
+	char msg_id[256];
 
 	/* Start by checking to see if the file actually exists... */
 	if (!(ast_fileexists(recdata->recording_file, recdata->recording_ext, NULL))) {
@@ -5834,7 +5872,6 @@
 	/* Store information */
 	txt = fdopen(txtdes, "w+");
 	if (txt) {
-		char msg_id[256];
 		char msg_id_hash[256];
 
 		/* Every voicemail msg gets its own unique msg id.  The msg id is the originate time
@@ -6021,7 +6058,7 @@
 				SENTINEL);
 		}
 
-		STORE(dir, recipient->mailbox, recipient->context, msgnum, NULL, recipient, fmt, 0, vms, "");
+		STORE(dir, recipient->mailbox, recipient->context, msgnum, NULL, recipient, fmt, 0, vms, "", msg_id);
 	}
 
 	free_user(recipient);
@@ -6311,6 +6348,7 @@
 	/* The meat of recording the message...  All the announcements and beeps have been played*/
 	ast_copy_string(fmt, vmfmts, sizeof(fmt));
 	if (!ast_strlen_zero(fmt)) {
+		char msg_id[256] = "";
 		msgnum = 0;
 
 #ifdef IMAP_STORAGE
@@ -6403,7 +6441,6 @@
 		/* Store information */
 		txt = fdopen(txtdes, "w+");
 		if (txt) {
-			char msg_id[256] = "";
 			char msg_id_hash[256] = "";
 
 			/* Every voicemail msg gets its own unique msg id.  The msg id is the originate time
@@ -6454,7 +6491,7 @@
 			res = ast_streamfile(chan, "vm-mailboxfull", ast_channel_language(chan));
 			goto leave_vm_out;
 		}
-		res = play_record_review(chan, NULL, tmptxtfile, vmu->maxsecs, fmt, 1, vmu, &duration, &sound_duration, NULL, options->record_gain, vms, flag);
+		res = play_record_review(chan, NULL, tmptxtfile, vmu->maxsecs, fmt, 1, vmu, &duration, &sound_duration, NULL, options->record_gain, vms, flag, msg_id);
 
 		if (txt) {
 			fprintf(txt, "flag=%s\n", flag);
@@ -6516,7 +6553,7 @@
 					 * ODBC storage does the entire copy with SQL.
 					 */
 					if (ast_fileexists(fn, NULL, NULL) > 0) {
-						STORE(dir, vmu->mailbox, vmu->context, msgnum, chan, vmu, fmt, duration, vms, flag);
+						STORE(dir, vmu->mailbox, vmu->context, msgnum, chan, vmu, fmt, duration, vms, flag, msg_id);
 					}
 
 					/* Are there to be more recipients of this message? */
@@ -7332,6 +7369,8 @@
 	struct ast_flags config_flags = { CONFIG_FLAG_NOCACHE };
 #ifndef IMAP_STORAGE
 	signed char zero_gain = 0;
+#else
+	const char *msg_id = NULL;
 #endif
 	const char *duration_str;
 
@@ -7358,11 +7397,14 @@
 
 #ifdef IMAP_STORAGE
 			/* Record new intro file */
+			if (msg_cfg && msg_cfg != CONFIG_STATUS_FILEINVALID) {
+				msg_id = ast_variable_retrieve(msg_cfg, "message", "msg_id");
+			}
 			make_file(vms->introfn, sizeof(vms->introfn), curdir, curmsg);
 			strncat(vms->introfn, "intro", sizeof(vms->introfn));
 			ast_play_and_wait(chan, INTRO);
 			ast_play_and_wait(chan, "beep");
-			cmd = play_record_review(chan, NULL, vms->introfn, vmu->maxsecs, vm_fmts, 1, vmu, (int *) duration, NULL, NULL, record_gain, vms, flag);
+			cmd = play_record_review(chan, NULL, vms->introfn, vmu->maxsecs, vm_fmts, 1, vmu, (int *) duration, NULL, NULL, record_gain, vms, flag, msg_id);
 			if (cmd == -1) {
 				break;
 			}
@@ -7552,12 +7594,25 @@
 
 	if (!ast_strlen_zero(vmu->email)) {
 		int attach_user_voicemail = ast_test_flag(vmu, VM_ATTACH);
+		char *msg_id = NULL;
+#ifdef IMAP_STORAGE
+		struct ast_config *msg_cfg;
+		struct ast_config_flags config_flags = { CONFIG_FLAG_NOCACHE };
+		char filename[PATH_MAX];
+
+		snprintf(filename, sizeof(filename), "%s.txt", fn);
+		msg_cfg = ast_config_load(filename, config_flags);
+		if (msg_cfg && msg_cfg != CONFIG_STATUS_FILEINVALID) {
+			msg_id = ast_strdupa(ast_variable_retrieve(msg_cfg, "message", "msg_id"));
+			ast_config_destroy(msg_cfg);
+		}
+#endif
 
 		if (attach_user_voicemail)
 			RETRIEVE(todir, msgnum, vmu->mailbox, vmu->context);
 
 		/* XXX possible imap issue, should category be NULL XXX */
-		sendmail(myserveremail, vmu, msgnum, vmu->context, vmu->mailbox, mbox(vmu, 0), cidnum, cidname, fn, NULL, fmt, duration, attach_user_voicemail, chan, category, flag);
+		sendmail(myserveremail, vmu, msgnum, vmu->context, vmu->mailbox, mbox(vmu, 0), cidnum, cidname, fn, NULL, fmt, duration, attach_user_voicemail, chan, category, flag, msg_id);
 
 		if (attach_user_voicemail)
 			DISPOSE(todir, msgnum);
@@ -7817,9 +7872,24 @@
 		long duration = 0;
 		struct vm_state vmstmp;
 		int copy_msg_result = 0;
+#ifdef IMAP_STORAGE
+		char filename[PATH_MAX];
+		struct ast_config_flags config_flags = { CONFIG_FLAG_NOCACHE };
+		const char *msg_id = NULL;
+		struct ast_config *msg_cfg;
+#endif
 		memcpy(&vmstmp, vms, sizeof(vmstmp));
 
  		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);
+		msg_cfg = ast_config_load(filename, config_flags);
+		if (msg_cfg && msg_cfg == CONFIG_STATUS_FILEINVALID) {
+			msg_id = ast_strdupa(ast_variable_retrieve(msg_cfg, "message", "msg_id"));
+			ast_config_destroy(msg_cfg);
+		}
+#endif
 
 		cmd = vm_forwardoptions(chan, sender, vmstmp.curdir, curmsg, vmfmts, S_OR(context, "default"), record_gain, &duration, &vmstmp, urgent_str);
 		if (!cmd) {
@@ -7838,7 +7908,7 @@
 					if (!dstvms->mailstream) {
 						ast_log(AST_LOG_ERROR, "IMAP mailstream for %s is NULL\n", vmtmp->mailbox);
 					} else {
-						copy_msg_result = STORE(vmstmp.curdir, vmtmp->mailbox, vmtmp->context, dstvms->curmsg, chan, vmtmp, fmt, duration, dstvms, urgent_str);
+						copy_msg_result = STORE(vmstmp.curdir, vmtmp->mailbox, vmtmp->context, dstvms->curmsg, chan, vmtmp, fmt, duration, dstvms, urgent_str, msg_id);
 						run_externnotify(vmtmp->context, vmtmp->mailbox, urgent_str); 
 					}
 				} else {
@@ -7853,7 +7923,7 @@
 					S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL),
 					S_COR(ast_channel_caller(chan)->id.name.valid, ast_channel_caller(chan)->id.name.str, NULL),
 					vmstmp.fn, vmstmp.introfn, fmt, duration, attach_user_voicemail, chan,
-					NULL, urgent_str);
+					NULL, urgent_str, msg_id);
 #else
 				copy_msg_result = copy_message(chan, sender, 0, curmsg, duration, vmtmp, fmt, dir, urgent_str, NULL);
 #endif
@@ -9702,7 +9772,7 @@
 	if (ast_test_flag(vmu, VM_FORCENAME)) {
 		snprintf(prefile, sizeof(prefile), "%s%s/%s/greet", VM_SPOOL_DIR, vmu->context, vms->username);
 		if (ast_fileexists(prefile, NULL, NULL) < 1) {
-			cmd = play_record_review(chan, "vm-rec-name", prefile, maxgreet, fmtc, 0, vmu, &duration, NULL, NULL, record_gain, vms, NULL);
+			cmd = play_record_review(chan, "vm-rec-name", prefile, maxgreet, fmtc, 0, vmu, &duration, NULL, NULL, record_gain, vms, NULL, NULL);
 			if (cmd < 0 || cmd == 't' || cmd == '#')
 				return cmd;
 		}
@@ -9712,14 +9782,14 @@
 	if (ast_test_flag(vmu, VM_FORCEGREET)) {
 		snprintf(prefile, sizeof(prefile), "%s%s/%s/unavail", VM_SPOOL_DIR, vmu->context, vms->username);
 		if (ast_fileexists(prefile, NULL, NULL) < 1) {
-			cmd = play_record_review(chan, "vm-rec-unv", prefile, maxgreet, fmtc, 0, vmu, &duration, NULL, NULL, record_gain, vms, NULL);
+			cmd = play_record_review(chan, "vm-rec-unv", prefile, maxgreet, fmtc, 0, vmu, &duration, NULL, NULL, record_gain, vms, NULL, NULL);
 			if (cmd < 0 || cmd == 't' || cmd == '#')
 				return cmd;
 		}
 
 		snprintf(prefile, sizeof(prefile), "%s%s/%s/busy", VM_SPOOL_DIR, vmu->context, vms->username);
 		if (ast_fileexists(prefile, NULL, NULL) < 1) {
-			cmd = play_record_review(chan, "vm-rec-busy", prefile, maxgreet, fmtc, 0, vmu, &duration, NULL, NULL, record_gain, vms, NULL);
+			cmd = play_record_review(chan, "vm-rec-busy", prefile, maxgreet, fmtc, 0, vmu, &duration, NULL, NULL, record_gain, vms, NULL, NULL);
 			if (cmd < 0 || cmd == 't' || cmd == '#')
 				return cmd;
 		}
@@ -9801,15 +9871,15 @@
 		switch (cmd) {
 		case '1': /* Record your unavailable message */
 			snprintf(prefile, sizeof(prefile), "%s%s/%s/unavail", VM_SPOOL_DIR, vmu->context, vms->username);
-			cmd = play_record_review(chan, "vm-rec-unv", prefile, maxgreet, fmtc, 0, vmu, &duration, NULL, NULL, record_gain, vms, NULL);
+			cmd = play_record_review(chan, "vm-rec-unv", prefile, maxgreet, fmtc, 0, vmu, &duration, NULL, NULL, record_gain, vms, NULL, NULL);
 			break;
 		case '2':  /* Record your busy message */
 			snprintf(prefile, sizeof(prefile), "%s%s/%s/busy", VM_SPOOL_DIR, vmu->context, vms->username);
-			cmd = play_record_review(chan, "vm-rec-busy", prefile, maxgreet, fmtc, 0, vmu, &duration, NULL, NULL, record_gain, vms, NULL);
+			cmd = play_record_review(chan, "vm-rec-busy", prefile, maxgreet, fmtc, 0, vmu, &duration, NULL, NULL, record_gain, vms, NULL, NULL);
 			break;
 		case '3': /* Record greeting */
 			snprintf(prefile, sizeof(prefile), "%s%s/%s/greet", VM_SPOOL_DIR, vmu->context, vms->username);
-			cmd = play_record_review(chan, "vm-rec-name", prefile, maxgreet, fmtc, 0, vmu, &duration, NULL, NULL, record_gain, vms, NULL);
+			cmd = play_record_review(chan, "vm-rec-name", prefile, maxgreet, fmtc, 0, vmu, &duration, NULL, NULL, record_gain, vms, NULL, NULL);
 			break;
 		case '4':  /* manage the temporary greeting */
 			cmd = vm_tempgreeting(chan, vmu, vms, fmtc, record_gain);
@@ -9943,7 +10013,7 @@
 			retries = 0;
 		RETRIEVE(prefile, -1, vmu->mailbox, vmu->context);
 		if (ast_fileexists(prefile, NULL, NULL) <= 0) {
-			cmd = play_record_review(chan, "vm-rec-temp", prefile, maxgreet, fmtc, 0, vmu, &duration, NULL, NULL, record_gain, vms, NULL);
+			cmd = play_record_review(chan, "vm-rec-temp", prefile, maxgreet, fmtc, 0, vmu, &duration, NULL, NULL, record_gain, vms, NULL, NULL);
 			if (cmd == -1) {
 				break;
 			}
@@ -9951,7 +10021,7 @@
 		} else {
 			switch (cmd) {
 			case '1':
-				cmd = play_record_review(chan, "vm-rec-temp", prefile, maxgreet, fmtc, 0, vmu, &duration, NULL, NULL, record_gain, vms, NULL);
+				cmd = play_record_review(chan, "vm-rec-temp", prefile, maxgreet, fmtc, 0, vmu, &duration, NULL, NULL, record_gain, vms, NULL, NULL);
 				break;
 			case '2':
 				DELETE(prefile, -1, prefile, vmu);
@@ -11323,13 +11393,21 @@
 	generate_random_string(id, id_size);
 
 	var = ast_variable_new("msg_id", id, "");
+	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);
+		ast_variables_destroy(var);
+		return -1;
+	}
 
 	ast_variable_append(cat, var);
 
 	if (ast_config_text_file_save(filename, msg_cfg, "app_voicemail")) {
 		ast_log(LOG_WARNING, "Unable to update %s to have a message ID\n", filename);
-		ast_config_destroy(msg_cfg);
 		return -1;
 	}
 
@@ -13545,7 +13623,7 @@
 			break;
 		}
 		open_mailbox(&vms, vmu, folder2mbox[i]);
-		STORE(tmp[i].dir, testmailbox, testcontext, 0, chan, vmu, "gsm", 600, &vms, strcmp(folders[i], "Urgent") ? "" : "Urgent");
+		STORE(tmp[i].dir, testmailbox, testcontext, 0, chan, vmu, "gsm", 600, &vms, strcmp(folders[i], "Urgent") ? "" : "Urgent", NULL);
 
 		/* hasvm-old, hasvm-urgent, hasvm-new, ic-old, ic-urgent, ic-new, ic2-old, ic2-urgent, ic2-new, mc-old, mc-urgent, mc-new */
 		for (j = 0; j < 3; j++) {
@@ -13707,7 +13785,7 @@
 			test_items[which].location = test_items[which].u.strval;
 		}
 
-		make_email_file(file, from, vmu, 0, testcontext, testmailbox, "INBOX", cidnum, cidname, attach, attach2, format, 999, 1, chan, NULL, 0, NULL);
+		make_email_file(file, from, vmu, 0, testcontext, testmailbox, "INBOX", cidnum, cidname, attach, attach2, format, 999, 1, chan, NULL, 0, NULL, NULL);
 		rewind(file);
 		while (fgets(buf, sizeof(buf), file)) {
 			if (
@@ -14247,7 +14325,7 @@
 
 static int play_record_review(struct ast_channel *chan, char *playfile, char *recordfile, int maxtime, char *fmt,
 			int outsidecaller, struct ast_vm_user *vmu, int *duration, int *sound_duration, const char *unlockdir,
-			signed char record_gain, struct vm_state *vms, char *flag)
+			signed char record_gain, struct vm_state *vms, char *flag, const char *msg_id)
 {
 	/* Record message & let caller review or re-record it, or set options if applicable */
 	int res = 0;
@@ -14292,7 +14370,7 @@
 				ast_stream_and_wait(chan, "vm-msgsaved", "");
 				if (!outsidecaller) {
 					/* Saves to IMAP server only if imapgreeting=yes */
-					STORE(recordfile, vmu->mailbox, vmu->context, -1, chan, vmu, fmt, *duration, vms, flag);
+					STORE(recordfile, vmu->mailbox, vmu->context, -1, chan, vmu, fmt, *duration, vms, flag, msg_id);
 					DISPOSE(recordfile, -1);
 				}
 				cmd = 't';




More information about the asterisk-commits mailing list