[asterisk-commits] mmichelson: branch mmichelson/imap_consistency_trunk r135587 - /team/mmichels...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Aug 4 15:53:18 CDT 2008


Author: mmichelson
Date: Mon Aug  4 15:53:18 2008
New Revision: 135587

URL: http://svn.digium.com/view/asterisk?view=rev&rev=135587
Log:
Progress commit. Forwarding with prepended messages was
ALL screwed up after my merge of IMAP consistency. I've taken
some measures to help with some mix-ups which were occurring, and
everything appears to be working correctly with one exception.

That is, retrieving a message with an extra prepend attachment
appears to only grab the prepended message. The e-mail file
which is attached correctly has both attachments, and according
to my debug output, both files that I attempt to attach exist.

Once I have that sorted out, I'll just remove these silly
debug messages and get this merged to trunk finally.


Modified:
    team/mmichelson/imap_consistency_trunk/apps/app_voicemail.c

Modified: team/mmichelson/imap_consistency_trunk/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/team/mmichelson/imap_consistency_trunk/apps/app_voicemail.c?view=diff&rev=135587&r1=135586&r2=135587
==============================================================================
--- team/mmichelson/imap_consistency_trunk/apps/app_voicemail.c (original)
+++ team/mmichelson/imap_consistency_trunk/apps/app_voicemail.c Mon Aug  4 15:53:18 2008
@@ -1458,7 +1458,8 @@
 	}
 	
 	make_file(vms->fn, sizeof(vms->fn), dir, msgnum);
-	snprintf(vms->introfn, sizeof(vms->introfn), "%sintro", vms->fn);
+
+	ast_log(LOG_NOTICE, "The filenames are %s and %s\n", vms->fn, vms->introfn);
 
 	/* Don't try to retrieve a message from IMAP if it already is on the file system */
 	if (ast_fileexists(vms->fn, NULL, NULL) > 0) {
@@ -1504,13 +1505,10 @@
 	}
 	
 	save_body(body, vms, "2", attachedfilefmt, 0);
-	/* A non-zero return here means that there is no prepended
-	 * message saved here. We need to null the vms->introfn so
-	 * that nothing attempts to play a nonexistent file later
-	 */
-	if (save_body(body, vms, "3", attachedfilefmt, 1)) {
-		*vms->introfn = '\0';
-	}
+	save_body(body, vms, "3", attachedfilefmt, 1);
+
+	ast_log(LOG_NOTICE, "Now the filenames are %s and %s\n", vms->fn, vms->introfn);
+	ast_log(LOG_NOTICE, "BREAKPOINT!!!\n");
 
 	/* Get info from headers!! */
 	snprintf(text_file, sizeof(text_file), "%s.%s", vms->fn, "txt");
@@ -1710,6 +1708,7 @@
 {
 	char *myserveremail = serveremail;
 	char fn[PATH_MAX];
+	char introfn[PATH_MAX];
 	char mailbox[256];
 	char *stringp;
 	FILE *p=NULL;
@@ -1739,6 +1738,11 @@
 		make_file(fn, sizeof(fn), dir, msgnum);
 	else
 		ast_copy_string (fn, dir, sizeof(fn));
+
+	snprintf(introfn, sizeof(introfn), "%sintro", fn);
+	if (ast_fileexists(introfn, NULL, NULL) <= 0) {
+		*introfn = '\0';
+	}
 	
 	if (ast_strlen_zero(vmu->email)) {
 		/* We need the vmu->email to be set when we call make_email_file, but
@@ -1771,7 +1775,9 @@
 		imap_delete_old_greeting(fn, vms);
 	}
 	
-	make_email_file(p, myserveremail, vmu, msgnum, vmu->context, vmu->mailbox, S_OR(chan->cid.cid_num, NULL), S_OR(chan->cid.cid_name, NULL), fn, vms->introfn, fmt, duration, 1, chan, NULL, 1, flag);
+	ast_log(LOG_NOTICE, "I'm to be storing the following files: %s and %s to mailbox %s\n", fn, introfn, vmu->mailbox);
+
+	make_email_file(p, myserveremail, vmu, msgnum, vmu->context, vmu->mailbox, S_OR(chan->cid.cid_num, NULL), S_OR(chan->cid.cid_name, NULL), fn, introfn, fmt, duration, 1, chan, NULL, 1, flag);
 	/* read mail file to memory */		
 	len = ftell(p);
 	rewind(p);
@@ -2081,6 +2087,8 @@
 		ast_log(AST_LOG_ERROR, "Could not initialize mailstream\n");
 		return -1;
 	}
+	
+	create_dirpath(vms->curdir, sizeof(vms->curdir), vmu->context, vms->username, vms->curbox);
 	
 	/* Check Quota */
 	if  (box == 0)  {
@@ -3394,6 +3402,7 @@
 }
 #endif
 
+#endif /* #ifndef IMAP_STORAGE */
 
 /*!
  * \brief Utility function to copy a file.
@@ -3506,7 +3515,6 @@
 	ast_variables_destroy(var);
 }
 
-#endif /* #ifndef IMAP_STORAGE */
 #endif /* #else of #ifdef ODBC_STORAGE */
 #if (!defined(ODBC_STORAGE) && !defined(IMAP_STORAGE))
 /*! 
@@ -5755,9 +5763,14 @@
 
 #ifdef IMAP_STORAGE
 			/* Record new intro file */
+			ast_log(LOG_NOTICE, "msgfile is %s and textfile is %s\n", msgfile, textfile);
+			make_file(vms->introfn, sizeof(vms->introfn), curdir, curmsg);
+			strncat(vms->introfn, "intro", sizeof(vms->introfn));
 			res = ast_play_and_wait(chan, INTRO);
 			res = ast_play_and_wait(chan, "beep");
 			res = play_record_review(chan, NULL, vms->introfn, vmu->maxsecs, vmfmts, 1, vmu, (int *)duration, NULL, record_gain, vms, flag);
+			ast_log(LOG_NOTICE, "I believe I just recorded an intro...%s\n", vms->introfn);
+			ast_log(LOG_NOTICE, "btw, the address of vms is %p\n", vms);
 			cmd = 't';
 #else
 
@@ -5811,6 +5824,7 @@
 		case '2': 
 			/* NULL out introfile so we know there is no intro! */
 			*vms->introfn = '\0';
+			ast_log(LOG_NOTICE, "I just nulled out the vms->introfn for some reason...\n");
 			cmd = 't';
 			break;
 		case '*':
@@ -6146,9 +6160,7 @@
 
  		RETRIEVE(dir, curmsg, sender->mailbox, sender->context);
 
-		make_file(origmsgfile, sizeof(origmsgfile), dir, curmsg);
-		create_dirpath(vmstmp.curdir, sizeof(vmstmp.curdir), sender->context, vmstmp.username, "tmp");
-		make_file(msgfile, sizeof(msgfile), vmstmp.curdir, curmsg);
+		copy_plain_file(origmsgfile, msgfile);
 
 		cmd = vm_forwardoptions(chan, sender, vmstmp.curdir, curmsg, vmfmts, S_OR(context, "default"), record_gain, &duration, &vmstmp, urgent_str);
 		if (!cmd) {
@@ -6177,7 +6189,8 @@
 					myserveremail = vmtmp->serveremail;
 				attach_user_voicemail = ast_test_flag(vmtmp, VM_ATTACH);
 				/* NULL category for IMAP storage */
-				sendmail(myserveremail, vmtmp, todircount, vmtmp->context, vmtmp->mailbox, S_OR(chan->cid.cid_num, NULL), S_OR(chan->cid.cid_name, NULL), vms->fn, vms->introfn, fmt, duration, attach_user_voicemail, chan, NULL, urgent_str);
+				ast_log(LOG_NOTICE, "Sanity check, the files are %s(%s) and %s(%s)\n", vmstmp.fn, ast_fileexists(vmstmp.fn, NULL, NULL) > 0 ? "Exists!" : "Nonexistent!", vmstmp.introfn, ast_fileexists(vmstmp.introfn, NULL, NULL) > 0 ? "Exists!" : "Nonexistent!");
+				sendmail(myserveremail, vmtmp, todircount, vmtmp->context, vmtmp->mailbox, S_OR(chan->cid.cid_num, NULL), S_OR(chan->cid.cid_name, NULL), vmstmp.fn, vmstmp.introfn, fmt, duration, attach_user_voicemail, chan, NULL, urgent_str);
 #else
 				copy_message(chan, sender, 0, curmsg, duration, vmtmp, fmt, dir, urgent_str);
 #endif
@@ -6548,10 +6561,12 @@
 		 * as a separate file from the rest of the message
 		 */
 		if (!ast_strlen_zero(vms->introfn)) {
+			ast_log(LOG_NOTICE, "Gonna play intro %s\n", vms->introfn);
 			wait_file(chan, vms, vms->introfn);
 		}
 #endif
 		if ((res = wait_file(chan, vms, vms->fn)) < 0) {
+			ast_log(LOG_NOTICE, "Glonna play %s\n", vms->fn);
 			ast_log(AST_LOG_WARNING, "Playback of message %s failed\n", vms->fn);
 			res = 0;
 		}
@@ -6574,6 +6589,7 @@
 		ast_copy_string(fn, dir, sizeof(fn));
 	
 	if ((msgnum < 0 && imapgreetings) || msgnum > -1) {
+		ast_log(LOG_NOTICE, "Disposing of file %s and %s.txt\n", fn, fn);
 		ast_filedelete(fn, NULL);	
 		snprintf(full_fn, sizeof(full_fn), "%s.txt", fn);
 		unlink(full_fn);




More information about the asterisk-commits mailing list