[asterisk-commits] mmichelson: branch mmichelson/imap_consistency r132570 - /team/mmichelson/ima...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Jul 21 17:15:46 CDT 2008


Author: mmichelson
Date: Mon Jul 21 17:15:45 2008
New Revision: 132570

URL: http://svn.digium.com/view/asterisk?view=rev&rev=132570
Log:
1. Eliminate the todir variable from forward_message since it is
   not necessary.

2. Fix an incredibly subtle bug by swapping the interactive
   preference in imap_retrieve_file. The problem was that the
   incorrect vm_state structure was being retrieved. The result
   was that if, for instance, you had three messages in your
   INBOX, then you would listen to three copies of the first
   message instead of hearing the three individual messages.

3. Added a call to messagecount in imap_store_file. The sole
   purpose of this is to update the vms->msgArray so that the
   newly stored message will be accounted for in case RETRIEVE
   is called for the newly left message. This is a terribly
   expensive way to accomplish this, but unfortunately there's
   no convenient way that I know of to get the IMAP message
   number of a message that was just appended. I will look
   through the UW docs more to see if there's a simpler way.

At this point, basic operation is successful. I can leave messages,
retrieve messages, and most importantly, forward messages. I will
also attempt some other operations, such as saving to a different
folder, sending a voicemail from VoiceMailMain, and other more
advanced operations.`


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

Modified: team/mmichelson/imap_consistency/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/team/mmichelson/imap_consistency/apps/app_voicemail.c?view=diff&rev=132570&r1=132569&r2=132570
==============================================================================
--- team/mmichelson/imap_consistency/apps/app_voicemail.c (original)
+++ team/mmichelson/imap_consistency/apps/app_voicemail.c Mon Jul 21 17:15:45 2008
@@ -1673,7 +1673,7 @@
 	/* Before anything can happen, we need a vm_state so that we can
 	 * actually access the imap server through the vms->mailstream
 	 */
-	if(!(vms = get_vm_state_by_mailbox(vmu->mailbox, 0)) && !(vms = get_vm_state_by_mailbox(vmu->mailbox, 1))) {
+	if(!(vms = get_vm_state_by_mailbox(vmu->mailbox, 1)) && !(vms = get_vm_state_by_mailbox(vmu->mailbox, 0))) {
 		/* This should not happen. If it does, then I guess we'd
 		 * need to create the vm_state, extract which mailbox to
 		 * open, and then set up the msgArray so that the correct
@@ -2512,6 +2512,7 @@
 
 #elif defined(IMAP_STORAGE)
 
+static int messagecount(const char *context, const char *mailbox, const char *folder);
 static int imap_store_file(char *dir, char *mailboxuser, char *mailboxcontext, int msgnum, struct ast_channel *chan, struct ast_vm_user *vmu, char *fmt, int duration, struct vm_state *vms)
 {
 	char *myserveremail = serveremail;
@@ -2528,7 +2529,7 @@
 	/*Greetings are not retrieved from IMAP, so there is no reason to attempt storing them there either*/
 	if (msgnum < 0)
 		return 0;
-	
+
 	/* Attach only the first format */
 	fmt = ast_strdupa(fmt);
 	stringp = fmt;
@@ -2561,7 +2562,7 @@
 		return -1;
 	} else {
 		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, fmt, duration, 1, chan, NULL, 1);
-		/* read mail file to memory */		
+		/* read mail file to memory */
 		len = ftell(p);
 		rewind(p);
 		if ((buf = ast_malloc(len+1)) == NIL) {
@@ -2581,6 +2582,10 @@
 		ast_free(buf);
 		if (option_debug > 2)
 			ast_log(LOG_DEBUG, "%s stored\n", fn);
+		/*XXX Temporary fix for msgArray problem. This may actually be
+		 * good enough for permanent usage, though.
+		 */
+		messagecount(vmu->context, vmu->mailbox, "INBOX");
 	}
 	if (tempcopy)
 		*(vmu->email) = '\0';
@@ -4164,7 +4169,6 @@
 static int forward_message(struct ast_channel *chan, char *context, struct vm_state *vms, struct ast_vm_user *sender, char *fmt, int flag, signed char record_gain)
 {
 #ifdef IMAP_STORAGE
-	char todir[256];
 	int todircount=0;
 	struct vm_state *dstvms;
 #endif
@@ -4338,7 +4342,7 @@
 					if (!dstvms->mailstream) {
 						ast_log (LOG_ERROR,"IMAP mailstream for %s is NULL\n",vmtmp->mailbox);
 					} else {
-						STORE(todir, vmtmp->mailbox, vmtmp->context, dstvms->curmsg, chan, vmtmp, fmt, duration, dstvms);
+						STORE(vmstmp.curdir, vmtmp->mailbox, vmtmp->context, dstvms->curmsg, chan, vmtmp, fmt, duration, dstvms);
 						run_externnotify(vmtmp->context, vmtmp->mailbox); 
 					}
 				} else {
@@ -4840,7 +4844,6 @@
 	if (option_debug > 2)
 		ast_log(LOG_DEBUG,"Before mail_search_full, user is %s\n",vmu->imapuser);
 	mail_search_full (vms->mailstream, NULL, pgm, NIL);
-
 
 	vms->lastmsg = vms->vmArrayIndex - 1;
 




More information about the asterisk-commits mailing list