[asterisk-commits] mmichelson: trunk r71883 - in /trunk: ./ apps/app_voicemail.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jun 26 14:06:48 CDT 2007


Author: mmichelson
Date: Tue Jun 26 14:06:47 2007
New Revision: 71883

URL: http://svn.digium.com/view/asterisk?view=rev&rev=71883
Log:
Merged revisions 71877 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r71877 | mmichelson | 2007-06-26 14:00:05 -0500 (Tue, 26 Jun 2007) | 11 lines

A few changes, the ultimate goal of which is to keep better track of the number of messages
that a mailbox currently has. A description of the changes:

1. Changed the "updated" field of the vm_state struct to act more as a binary semaphore than a
   counting semaphore, since its current implementation made the inboxcount function not work properly.
   This change falls in line with a change made by UPenn with their IMAP setup and helps to sync our changes with theirs.
2. Eliminated some redundant calls to get_vm_state_by_mailbox inside leave_voicemail
3. Use the play_folder variable to keep track of the number of old and new messages in a mailbox as the messages are deleted
4. Added an increment to the number of new messages that was not there previously in the leave_voicemail function


........

Modified:
    trunk/   (props changed)
    trunk/apps/app_voicemail.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Modified: trunk/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_voicemail.c?view=diff&rev=71883&r1=71882&r2=71883
==============================================================================
--- trunk/apps/app_voicemail.c (original)
+++ trunk/apps/app_voicemail.c Tue Jun 26 14:06:47 2007
@@ -2657,7 +2657,7 @@
 		return -1;
 	}
 
-	if (!ret && vms_p->updated == 1) {
+	if (!ret && vms_p->updated > 0) {
 		if (newmsgs) {
 			pgm = mail_newsearchpgm();
 			hdr = mail_newsearchheader("X-Asterisk-VM-Extension", (char *)mailboxnc);
@@ -2688,10 +2688,8 @@
 		}
 	}
 
- 	if (vms_p->updated == 1) {  /* changes, so we did the searches above */
+ 	if (vms_p->updated > 1) {  /* changes, so we did the searches above */
  		vms_p->updated = 0;
- 	} else if (vms_p->updated > 1) {  /* decrement delay count */
- 		vms_p->updated--;
  	} else {  /* no changes, so don't search */
  		mail_ping(vms_p->mailstream);
  		/* Keep the old data */
@@ -3111,19 +3109,13 @@
 #ifdef IMAP_STORAGE
 		/* Is ext a mailbox? */
 		/* must open stream for this user to get info! */
-		vms = get_vm_state_by_mailbox(ext,0);
-		if (vms) {
-			ast_debug(3, "Using vm_state, interactive set to %d.\n",vms->interactive);
-			newmsgs = vms->newmessages++;
-			oldmsgs = vms->oldmessages;
-		} else {
-			res = inboxcount(ext_context, &newmsgs, &oldmsgs);
-			if(res < 0) {
-				ast_log(LOG_NOTICE,"Can not leave voicemail, unable to count messages\n");
-				return -1;
-			}
-			vms = get_vm_state_by_mailbox(ext,0);
-		}
+		res = inboxcount(ext_context, &newmsgs, &oldmsgs);
+		if(res < 0) {
+			ast_log(LOG_NOTICE,"Can not leave voicemail, unable to count messages\n");
+			return -1;
+		}
+		if((vms = get_vm_state_by_mailbox(ext,0))) 
+			vms->newmessages++; /*still need to increment new message count*/
 		/* here is a big difference! We add one to it later */
 		msgnum = newmsgs + oldmsgs;
 		ast_debug(3, "Messagecount set to %d\n",msgnum);
@@ -6623,7 +6615,7 @@
 
 #ifdef IMAP_STORAGE
 	vms.interactive = 1;
-	vms.updated = 2;
+	vms.updated = 1;
 	vmstate_insert(&vms);
 	init_vm_state(&vms);
 #endif
@@ -6673,6 +6665,7 @@
 		if (!vms.newmessages && vms.oldmessages) {
 			/* If we only have old messages start here */
 			res = open_mailbox(&vms, vmu, 1);
+			play_folder = 1;
 			if (res == ERROR_LOCK_PATH)
 				goto out;
 		}
@@ -6736,6 +6729,7 @@
 				res = open_mailbox(&vms, vmu, cmd);
 				if (res == ERROR_LOCK_PATH)
 					goto out;
+				play_folder = cmd;
 				cmd = 0;
 			}
 			if (useadsi)
@@ -6872,10 +6866,20 @@
 				vms.deleted[vms.curmsg] = !vms.deleted[vms.curmsg];
 				if (useadsi)
 					adsi_delete(chan, &vms);
-				if (vms.deleted[vms.curmsg]) 
+				if (vms.deleted[vms.curmsg]) {
+					if (play_folder == 0)
+						vms.newmessages--;
+					else if (play_folder == 1)
+						vms.oldmessages--;
 					cmd = ast_play_and_wait(chan, "vm-deleted");
-				else
+				}
+				else {
+					if (play_folder == 0)
+						vms.newmessages++;
+					else if (play_folder == 1)
+						vms.oldmessages++;
 					cmd = ast_play_and_wait(chan, "vm-undeleted");
+				}
 				if (ast_test_flag((&globalflags), VM_SKIPAFTERCMD)) {
 					if (vms.curmsg < vms.lastmsg) {
 						vms.curmsg++;
@@ -9346,7 +9350,7 @@
 		ast_debug(3, "Duplicate mailbox %s, copying message info...\n", vms->username);
 		altvms->newmessages = vms->newmessages;
 		altvms->oldmessages = vms->oldmessages;
-		altvms->updated = 2;
+		altvms->updated = 1;
 	}
 	
 	ast_debug(3, "Removing vm_state for user:%s, mailbox %s\n", vms->imapuser, vms->username);
@@ -9381,7 +9385,7 @@
 
 	ast_debug(3, "User %s mailbox set for update.\n", user);
        
-	vms->updated = 2; /* Set updated flag since mailbox changed */
+	vms->updated = 1; /* Set updated flag since mailbox changed */
 }
 
 static void init_vm_state(struct vm_state *vms) 




More information about the asterisk-commits mailing list