[asterisk-commits] tilghman: branch 1.6.0 r219819 - in /branches/1.6.0: ./ apps/app_voicemail.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Sep 22 16:47:30 CDT 2009


Author: tilghman
Date: Tue Sep 22 16:47:26 2009
New Revision: 219819

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

................
  r219818 | tilghman | 2009-09-22 16:43:22 -0500 (Tue, 22 Sep 2009) | 17 lines
  
  Merged revisions 219816 via svnmerge from 
  https://origsvn.digium.com/svn/asterisk/branches/1.4
  
  ........
    r219816 | tilghman | 2009-09-22 16:37:03 -0500 (Tue, 22 Sep 2009) | 10 lines
    
    When IMAP variables were changed during a reload, Voicemail did not use the new values.
    This change introduces a configuration version variable, which ensures that
    connections with the old values are not reused but are allowed to expire
    normally.
    (closes issue #15934)
     Reported by: viniciusfontes
     Patches: 
           20090922__issue15934.diff.txt uploaded by tilghman (license 14)
     Tested by: viniciusfontes
  ........
................

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

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

Modified: branches/1.6.0/apps/app_voicemail.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.6.0/apps/app_voicemail.c?view=diff&rev=219819&r1=219818&r2=219819
==============================================================================
--- branches/1.6.0/apps/app_voicemail.c (original)
+++ branches/1.6.0/apps/app_voicemail.c Tue Sep 22 16:47:26 2009
@@ -132,6 +132,7 @@
 static char greetingfolder[64];
 static char authuser[32];
 static char authpassword[42];
+static int imapversion = 1;
 
 static int expungeonhangup = 1;
 static int imapgreetings = 0;
@@ -391,6 +392,7 @@
 	char imapuser[80];               /*!< IMAP server login */
 	char imappassword[80];           /*!< IMAP server password if authpassword not defined */
 	char imapvmshareid[80];          /*!< Shared mailbox ID to use rather than the dialed one */
+	int imapversion;                 /*!< If configuration changes, use the new values */
 #endif
 	double volgain;                  /*!< Volume gain for voicemails sent via email */
 	AST_LIST_ENTRY(ast_vm_user) list;
@@ -427,6 +429,7 @@
 	MAILSTREAM *mailstream;
 	int vmArrayIndex;
 	char imapuser[80];                   /*!< IMAP server login */
+	int imapversion;
 	int interactive;
 	unsigned int quota_limit;
 	unsigned int quota_usage;
@@ -729,10 +732,13 @@
 #ifdef IMAP_STORAGE
 	} else if (!strcasecmp(var, "imapuser")) {
 		ast_copy_string(vmu->imapuser, value, sizeof(vmu->imapuser));
+		vmu->imapversion = imapversion;
 	} else if (!strcasecmp(var, "imappassword") || !strcasecmp(var, "imapsecret")) {
 		ast_copy_string(vmu->imappassword, value, sizeof(vmu->imappassword));
+		vmu->imapversion = imapversion;
 	} else if (!strcasecmp(var, "imapvmshareid")) {
 		ast_copy_string(vmu->imapvmshareid, value, sizeof(vmu->imapvmshareid));
+		vmu->imapversion = imapversion;
 #endif
 	} else if (!strcasecmp(var, "delete") || !strcasecmp(var, "deletevoicemail")) {
 		ast_set2_flag(vmu, ast_true(value), VM_DELETE);	
@@ -861,10 +867,13 @@
 #ifdef IMAP_STORAGE
 		} else if (!strcasecmp(tmp->name, "imapuser")) {
 			ast_copy_string(retval->imapuser, tmp->value, sizeof(retval->imapuser));
+			retval->imapversion = imapversion;
 		} else if (!strcasecmp(tmp->name, "imappassword") || !strcasecmp(tmp->name, "imapsecret")) {
 			ast_copy_string(retval->imappassword, tmp->value, sizeof(retval->imappassword));
+			retval->imapversion = imapversion;
 		} else if (!strcasecmp(tmp->name, "imapvmshareid")) {
 			ast_copy_string(retval->imapvmshareid, tmp->value, sizeof(retval->imapvmshareid));
+			retval->imapversion = imapversion;
 #endif
 		} else
 			apply_option(retval, tmp->name, tmp->value);
@@ -926,6 +935,11 @@
 		context = "default";
 
 	AST_LIST_TRAVERSE(&users, cur, list) {
+#ifdef IMAP_STORAGE
+		if (cur->imapversion != imapversion) {
+			continue;
+		}
+#endif
 		if (ast_test_flag((&globalflags), VM_SEARCH) && !strcasecmp(mailbox, cur->mailbox))
 			break;
 		if (context && (!strcasecmp(context, cur->context)) && (!strcasecmp(mailbox, cur->mailbox)))
@@ -1830,6 +1844,7 @@
 
 	ast_copy_string(vms->imapuser,vmu->imapuser, sizeof(vms->imapuser));
 	ast_debug(3,"Before init_mailstream, user is %s\n",vmu->imapuser);
+	vms->imapversion = vmu->imapversion;
 
 	if ((ret = init_mailstream(vms, box)) || !vms->mailstream) {
 		ast_log(LOG_ERROR, "Could not initialize mailstream\n");
@@ -2184,6 +2199,7 @@
 	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 */
 	vms_p->mailstream = NIL; /* save for access from interactive entry point */
+	vms_p->imapversion = vmu->imapversion;
 	if (option_debug > 4)
 		ast_log(LOG_DEBUG,"Copied %s to %s\n",vmu->imapuser,vms_p->imapuser);
 	vms_p->updated = 1;
@@ -2211,6 +2227,9 @@
 			ast_debug(3, "error: vms is NULL for %s\n", user);
 			continue;
 		}
+		if (vlist->vms->imapversion != imapversion) {
+			continue;
+		}
 		if (!vlist->vms->imapuser) {
 			ast_debug(3, "error: imapuser is NULL for %s\n", user);
 			continue;
@@ -2244,6 +2263,9 @@
 	AST_LIST_TRAVERSE(&vmstates, vlist, list) {
 		if (!vlist->vms) {
 			ast_debug(3, "error: vms is NULL for %s\n", mailbox);
+			continue;
+		}
+		if (vlist->vms->imapversion != imapversion) {
 			continue;
 		}
 		if (!vlist->vms->username) {
@@ -9350,6 +9372,8 @@
 			mail_parameters(NIL, SET_CLOSETIMEOUT, (void *) 60L);
 		}
 
+		/* Increment configuration version */
+		imapversion++;
 #endif
 		/* External voicemail notify application */
 		if ((val = ast_variable_retrieve(cfg, "general", "externnotify"))) {




More information about the asterisk-commits mailing list