[svn-commits] qwell: branch 13 r420577 - in /branches/13: ./ apps/ configs/samples/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Aug 8 14:15:39 CDT 2014


Author: qwell
Date: Fri Aug  8 14:15:27 2014
New Revision: 420577

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=420577
Log:
app_voicemail: Add the ability to specify multiple email addresses.

ASTERISK-24045
Reported by: Jacob Barber
Review: https://reviewboard.asterisk.org/r/3833/

Modified:
    branches/13/CHANGES
    branches/13/apps/app_voicemail.c
    branches/13/configs/samples/voicemail.conf.sample

Modified: branches/13/CHANGES
URL: http://svnview.digium.com/svn/asterisk/branches/13/CHANGES?view=diff&rev=420577&r1=420576&r2=420577
==============================================================================
--- branches/13/CHANGES (original)
+++ branches/13/CHANGES Fri Aug  8 14:15:27 2014
@@ -209,6 +209,9 @@
    - jb-ga: article ga
    - jb-wa: article wa
    - jb-wo: article wo
+
+ * Add the ability to specify multiple email addresses in configuration,
+   separated by a |.
 
 res_config_pgsql
 ------------------

Modified: branches/13/apps/app_voicemail.c
URL: http://svnview.digium.com/svn/asterisk/branches/13/apps/app_voicemail.c?view=diff&rev=420577&r1=420576&r2=420577
==============================================================================
--- branches/13/apps/app_voicemail.c (original)
+++ branches/13/apps/app_voicemail.c Fri Aug  8 14:15:27 2014
@@ -795,7 +795,7 @@
 	char mailbox[AST_MAX_EXTENSION]; /*!< Mailbox id, unique within vm context */
 	char password[80];               /*!< Secret pin code, numbers only */
 	char fullname[80];               /*!< Full name, for directory app */
-	char email[80];                  /*!< E-mail address */
+	char *email;                     /*!< E-mail address */
 	char *emailsubject;              /*!< E-mail subject */
 	char *emailbody;                 /*!< E-mail body */
 	char pager[80];                  /*!< E-mail address to pager (no attachment) */
@@ -1269,6 +1269,8 @@
 		vmu->maxdeletedmsg = maxdeletedmsg;
 	}
 	vmu->volgain = volgain;
+	ast_free(vmu->email);
+	vmu->email = NULL;
 	ast_free(vmu->emailsubject);
 	vmu->emailsubject = NULL;
 	ast_free(vmu->emailbody);
@@ -1580,7 +1582,8 @@
 		} else if (!strcasecmp(var->name, "pager")) {
 			ast_copy_string(retval->pager, var->value, sizeof(retval->pager));
 		} else if (!strcasecmp(var->name, "email")) {
-			ast_copy_string(retval->email, var->value, sizeof(retval->email));
+			ast_free(retval->email);
+			retval->email = ast_strdup(var->value);
 		} else if (!strcasecmp(var->name, "fullname")) {
 			ast_copy_string(retval->fullname, var->value, sizeof(retval->fullname));
 		} else if (!strcasecmp(var->name, "context")) {
@@ -1717,6 +1720,7 @@
 		if ((vmu = (ivm ? ivm : ast_malloc(sizeof(*vmu))))) {
 			*vmu = *cur;
 			if (!ivm) {
+				vmu->email = ast_strdup(cur->email);
 				vmu->emailbody = ast_strdup(cur->emailbody);
 				vmu->emailsubject = ast_strdup(cur->emailsubject);
 			}
@@ -1999,6 +2003,9 @@
 {
 	if (ast_test_flag(vmu, VM_ALLOCED)) {
 
+		ast_free(vmu->email);
+		vmu->email = NULL;
+
 		ast_free(vmu->emailbody);
 		vmu->emailbody = NULL;
 
@@ -2629,7 +2636,7 @@
 		 * of this function, we will revert back to an empty string if tempcopy
 		 * is 1.
 		 */
-		ast_copy_string(vmu->email, vmu->imapuser, sizeof(vmu->email));
+		vmu->email = ast_strdup(vmu->imapuser);
 		tempcopy = 1;
 	}
 
@@ -2641,8 +2648,10 @@
 	   command hangs. */
 	if (!(p = vm_mkftemp(tmp))) {
 		ast_log(AST_LOG_WARNING, "Unable to store '%s' (can't create temporary file)\n", fn);
-		if (tempcopy)
-			*(vmu->email) = '\0';
+		if (tempcopy) {
+			ast_free(vmu->email);
+			vmu->email = NULL;
+		}
 		return -1;
 	}
 
@@ -4964,6 +4973,9 @@
 	struct ast_str *str1 = ast_str_create(16), *str2 = ast_str_create(16);
 	char *greeting_attachment; 
 	char filename[256];
+	int first_line;
+	char *emailsbuf;
+	char *email;
 
 	if (!str1 || !str2) {
 		ast_free(str1);
@@ -5005,7 +5017,7 @@
 			ast_str_substitute_variables(&str1, 0, ast, fromstring);
 
 			if (check_mime(ast_str_buffer(str1))) {
-				int first_line = 1;
+				first_line = 1;
 				ast_str_encode_mime(&str2, 0, ast_str_buffer(str1), strlen("From: "), strlen(who) + 3);
 				while ((ptr = strchr(ast_str_buffer(str2), ' '))) {
 					*ptr = '\0';
@@ -5026,20 +5038,25 @@
 		fprintf(p, "From: Asterisk PBX <%s>" ENDL, who);
 	}
 
-	if (check_mime(vmu->fullname)) {
-		int first_line = 1;
-		char *ptr;
-		ast_str_encode_mime(&str2, 0, vmu->fullname, strlen("To: "), strlen(vmu->email) + 3);
-		while ((ptr = strchr(ast_str_buffer(str2), ' '))) {
-			*ptr = '\0';
-			fprintf(p, "%s %s" ENDL, first_line ? "To:" : "", ast_str_buffer(str2));
-			first_line = 0;
-			/* Substring is smaller, so this will never grow */
-			ast_str_set(&str2, 0, "%s", ptr + 1);
-		}
-		fprintf(p, "%s %s <%s>" ENDL, first_line ? "To:" : "", ast_str_buffer(str2), vmu->email);
-	} else {
-		fprintf(p, "To: %s <%s>" ENDL, ast_str_quote(&str2, 0, vmu->fullname), vmu->email);
+	emailsbuf = ast_strdupa(vmu->email);
+	fprintf(p, "To:");
+	first_line = 1;
+	while ((email = strsep(&emailsbuf, "|"))) {
+		char *next = strchr(S_OR(emailsbuf, ""), '|');
+		if (check_mime(vmu->fullname)) {
+			char *ptr;
+			ast_str_encode_mime(&str2, 0, vmu->fullname, first_line ? strlen("To: ") : 0, strlen(email) + 3 + (next ? strlen(",") : 0));
+			while ((ptr = strchr(ast_str_buffer(str2), ' '))) {
+				*ptr = '\0';
+				fprintf(p, " %s" ENDL, ast_str_buffer(str2));
+				/* Substring is smaller, so this will never grow */
+				ast_str_set(&str2, 0, "%s", ptr + 1);
+			}
+			fprintf(p, " %s <%s>%s" ENDL, ast_str_buffer(str2), email, next ? "," : "");
+		} else {
+			fprintf(p, " %s <%s>%s" ENDL, ast_str_quote(&str2, 0, vmu->fullname), email, next ? "," : "");
+		}
+		first_line = 0;
 	}
 
 	if (!ast_strlen_zero(emailsubject) || !ast_strlen_zero(vmu->emailsubject)) {
@@ -5049,7 +5066,7 @@
 			prep_email_sub_vars(ast, vmu, msgnum + 1, context, mailbox, fromfolder, cidnum, cidname, dur, date, category, flag);
 			ast_str_substitute_variables(&str1, 0, ast, e_subj);
 			if (check_mime(ast_str_buffer(str1))) {
-				int first_line = 1;
+				first_line = 1;
 				char *ptr;
 				ast_str_encode_mime(&str2, 0, ast_str_buffer(str1), strlen("Subject: "), 0);
 				while ((ptr = strchr(ast_str_buffer(str2), ' '))) {
@@ -12011,7 +12028,7 @@
 		ast_copy_string(vmu->fullname, s, sizeof(vmu->fullname));
 	}
 	if (stringp && (s = strsep(&stringp, ","))) {
-		ast_copy_string(vmu->email, s, sizeof(vmu->email));
+		vmu->email = ast_strdup(s);
 	}
 	if (stringp && (s = strsep(&stringp, ","))) {
 		ast_copy_string(vmu->pager, s, sizeof(vmu->pager));
@@ -14342,7 +14359,7 @@
 	}
 
 	populate_defaults(vmu);
-	ast_copy_string(vmu->email, "test2 at example.net", sizeof(vmu->email));
+	vmu->email = ast_strdup("test2 at example.net");
 #ifdef IMAP_STORAGE
 	/* TODO When we set up the IMAP server test, we'll need to have credentials for the VMU structure added here */
 #endif

Modified: branches/13/configs/samples/voicemail.conf.sample
URL: http://svnview.digium.com/svn/asterisk/branches/13/configs/samples/voicemail.conf.sample?view=diff&rev=420577&r1=420576&r2=420577
==============================================================================
--- branches/13/configs/samples/voicemail.conf.sample (original)
+++ branches/13/configs/samples/voicemail.conf.sample Fri Aug  8 14:15:27 2014
@@ -232,10 +232,10 @@
 ;
 
 ; Each mailbox is listed in the form <mailbox>=<password>,<name>,<email>,<pager_email>,<options>
-; if the e-mail is specified, a message will be sent when a message is
-; received, to the given mailbox. If pager is specified, a message will be
-; sent there as well. If the password is prefixed by '-', then it is
-; considered to be unchangeable.
+; If email is specified, a message will be sent when a voicemail is received, to
+; the given mailbox, for each address listed (separated by |, ex. alice at foo.com|bob at foo.com).
+; If pager is specified, a message will be sent there as well. If the password
+; is prefixed by '-', then it is considered to be unchangeable.
 ;
 ; Advanced options example is extension 4069
 ; NOTE: All options can be expressed globally in the general section, and




More information about the svn-commits mailing list