[asterisk-commits] mmichelson: branch 1.6.1 r140425 - in /branches/1.6.1: ./ apps/app_voicemail.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Aug 29 11:11:51 CDT 2008


Author: mmichelson
Date: Fri Aug 29 11:11:50 2008
New Revision: 140425

URL: http://svn.digium.com/view/asterisk?view=rev&rev=140425
Log:
Merged revisions 140422 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

................
r140422 | mmichelson | 2008-08-29 11:06:09 -0500 (Fri, 29 Aug 2008) | 20 lines

Merged revisions 140421 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r140421 | mmichelson | 2008-08-29 11:01:07 -0500 (Fri, 29 Aug 2008) | 12 lines

Add context checking when retrieving a vm_state.
This was causing a problem for people who had identically
named mailboxes in separate voicemail contexts.
This commit affects IMAP storage only.

(closes issue #13194)
Reported by: moliveras
Patches:
      13194.patch uploaded by putnopvut (license 60)
Tested by: putnopvut, moliveras


........

................

Modified:
    branches/1.6.1/   (props changed)
    branches/1.6.1/apps/app_voicemail.c

Propchange: branches/1.6.1/
------------------------------------------------------------------------------
Binary property 'trunk-merged' - no diff available.

Modified: branches/1.6.1/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/branches/1.6.1/apps/app_voicemail.c?view=diff&rev=140425&r1=140424&r2=140425
==============================================================================
--- branches/1.6.1/apps/app_voicemail.c (original)
+++ branches/1.6.1/apps/app_voicemail.c Fri Aug 29 11:11:50 2008
@@ -144,7 +144,7 @@
 static void vm_imap_delete(int msgnum, struct ast_vm_user *vmu);
 static char *get_user_by_mailbox(char *mailbox, char *buf, size_t len);
 static struct vm_state *get_vm_state_by_imapuser(char *user, int interactive);
-static struct vm_state *get_vm_state_by_mailbox(const char *mailbox, int interactive);
+static struct vm_state *get_vm_state_by_mailbox(const char *mailbox, const char *context, int interactive);
 static struct vm_state *create_vm_state_from_user(struct ast_vm_user *vmu);
 static void vmstate_insert(struct vm_state *vms);
 static void vmstate_delete(struct vm_state *vms);
@@ -415,6 +415,7 @@
 struct vm_state {
 	char curbox[80];
 	char username[80];
+	char context[80];
 	char curdir[PATH_MAX];
 	char vmbox[PATH_MAX];
 	char fn[PATH_MAX];
@@ -1335,7 +1336,7 @@
 		return;
 	}
 
-	if (!(vms = get_vm_state_by_mailbox(vmu->mailbox, 1)) && !(vms = get_vm_state_by_mailbox(vmu->mailbox, 0))) {
+	if (!(vms = get_vm_state_by_mailbox(vmu->mailbox, vmu->context, 1)) && !(vms = get_vm_state_by_mailbox(vmu->mailbox, vmu->context, 0))) {
 		ast_log(LOG_WARNING, "Couldn't find a vm_state for mailbox %s. Unable to set \\DELETED flag for message %d\n", vmu->mailbox, msgnum);
 		return;
 	}
@@ -1378,7 +1379,7 @@
 	}
 
 	/* check if someone is accessing this box right now... */
-	if (!(vms_p = get_vm_state_by_mailbox(vmu->mailbox, 1)) ||!(vms_p = get_vm_state_by_mailbox(vmu->mailbox, 0))) {
+	if (!(vms_p = get_vm_state_by_mailbox(vmu->mailbox, vmu->context, 1)) ||!(vms_p = get_vm_state_by_mailbox(vmu->mailbox, vmu->context, 0))) {
 		ast_log(AST_LOG_ERROR, "Voicemail state not found!\n");
 		return -1;
 	}
@@ -1444,7 +1445,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, 1)) && !(vms = get_vm_state_by_mailbox(vmu->mailbox, 0))) {
+	if (!(vms = get_vm_state_by_mailbox(vmu->mailbox, vmu->context, 1)) && !(vms = get_vm_state_by_mailbox(vmu->mailbox, vmu->context, 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
@@ -1615,7 +1616,7 @@
 	/* check if someone is accessing this box right now... */
 	vms_p = get_vm_state_by_imapuser(vmu->imapuser,1);
 	if (!vms_p) {
-		vms_p = get_vm_state_by_mailbox(mailbox,1);
+		vms_p = get_vm_state_by_mailbox(mailbox, context, 1);
 	}
 	if (vms_p) {
 		ast_debug(3, "Returning before search - user is logged in\n");
@@ -1633,7 +1634,7 @@
 	/* add one if not there... */
 	vms_p = get_vm_state_by_imapuser(vmu->imapuser,0);
 	if (!vms_p) {
-		vms_p = get_vm_state_by_mailbox(mailbox,0);
+		vms_p = get_vm_state_by_mailbox(mailbox, context, 0);
 	}
 
 	/* If URGENT, then look at INBOX */
@@ -2428,6 +2429,7 @@
 		return NULL;
 	ast_copy_string(vms_p->imapuser, vmu->imapuser, sizeof(vms_p->imapuser));
 	ast_copy_string(vms_p->username, vmu->mailbox, sizeof(vms_p->username)); /* save for access from interactive entry point */
+	ast_copy_string(vms_p->context, vmu->context, sizeof(vms_p->context));
 	vms_p->mailstream = NIL; /* save for access from interactive entry point */
 	if (option_debug > 4)
 		ast_log(AST_LOG_DEBUG,"Copied %s to %s\n",vmu->imapuser,vms_p->imapuser);
@@ -2466,10 +2468,11 @@
 	return NULL;
 }
 
-static struct vm_state *get_vm_state_by_mailbox(const char *mailbox, int interactive)
+static struct vm_state *get_vm_state_by_mailbox(const char *mailbox, const char *context, int interactive)
 {
 
 	struct vmstate *vlist = NULL;
+	const char *local_context = S_OR(context, "default");
 
 	AST_LIST_LOCK(&vmstates);
 	AST_LIST_TRAVERSE(&vmstates, vlist, list) {
@@ -2477,14 +2480,14 @@
 			ast_debug(3, "error: vms is NULL for %s\n", mailbox);
 			continue;
 		}
-		if (!vlist->vms->username) {
+		if (!vlist->vms->username || !vlist->vms->context) {
 			ast_debug(3, "error: username is NULL for %s\n", mailbox);
 			continue;
 		}
 
-		ast_debug(3, "comparing mailbox %s (i=%d) to vmstate mailbox %s (i=%d)\n", mailbox, interactive, vlist->vms->username, vlist->vms->interactive);
+		ast_debug(3, "comparing mailbox %s@%s (i=%d) to vmstate mailbox %s@%s (i=%d)\n", mailbox, local_context, interactive, vlist->vms->username, vlist->vms->context, vlist->vms->interactive);
 		
-		if (!strcmp(vlist->vms->username,mailbox) && vlist->vms->interactive == interactive) {
+		if (!strcmp(vlist->vms->username,mailbox) && !strcmp(vlist->vms->context, local_context) && vlist->vms->interactive == interactive) {
 			ast_debug(3, "Found it!\n");
 			AST_LIST_UNLOCK(&vmstates);
 			return vlist->vms;
@@ -2506,7 +2509,7 @@
 	   use the one we already have since it is more up to date.
 	   We can compare the username to find the duplicate */
 	if (vms->interactive == 1) {
-		altvms = get_vm_state_by_mailbox(vms->username,0);
+		altvms = get_vm_state_by_mailbox(vms->username, vms->context, 0);
 		if (altvms) {	
 			ast_debug(3, "Duplicate mailbox %s, copying message info...\n",vms->username);
 			vms->newmessages = altvms->newmessages;
@@ -4852,7 +4855,7 @@
 			ast_log(AST_LOG_NOTICE, "Can not leave voicemail, unable to count messages\n");
 			return -1;
 		}
-		if (!(vms = get_vm_state_by_mailbox(ext,0))) {
+		if (!(vms = get_vm_state_by_mailbox(ext, context, 0))) {
 		/* It is possible under certain circumstances that inboxcount did not
 		 * create a vm_state when it was needed. This is a catchall which will
 		 * rarely be used.
@@ -6155,7 +6158,7 @@
 				char *myserveremail = serveremail;
 				
 				/* get destination mailbox */
-				dstvms = get_vm_state_by_mailbox(vmtmp->mailbox,0);
+				dstvms = get_vm_state_by_mailbox(vmtmp->mailbox, vmtmp->context, 0);
 				if (!dstvms) {
 					dstvms = create_vm_state_from_user(vmtmp);
 				}




More information about the asterisk-commits mailing list