[asterisk-commits] file: branch 1.4 r51213 - /branches/1.4/apps/app_voicemail.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Wed Jan 17 17:48:56 MST 2007


Author: file
Date: Wed Jan 17 18:48:55 2007
New Revision: 51213

URL: http://svn.digium.com/view/asterisk?view=rev&rev=51213
Log:
Build the IMAP remote directory string better and properly. Fix an issue with encoding the GSM voicemail when attaching to the voicemail. (issue #8808 reported by akohlsmith)

Modified:
    branches/1.4/apps/app_voicemail.c

Modified: branches/1.4/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/apps/app_voicemail.c?view=diff&rev=51213&r1=51212&r2=51213
==============================================================================
--- branches/1.4/apps/app_voicemail.c (original)
+++ branches/1.4/apps/app_voicemail.c Wed Jan 17 18:48:55 2007
@@ -1971,7 +1971,7 @@
 		snprintf(fname, sizeof(fname), "%s.%s", attach, format);
 		base_encode(fname, p);
 		/* only attach if necessary */
-		if (imap && strcmp(format, "gsm")) {
+		if (imap && !strcmp(format, "gsm")) {
 			fprintf(p, "--%s\r\n", bound);
 			fprintf(p, "Content-Type: audio/x-gsm; name=\"msg%04d.%s\"\r\n", msgnum, format);
 			fprintf(p, "Content-Transfer-Encoding: base64\r\n");
@@ -4569,8 +4569,9 @@
 #ifdef IMAP_STORAGE
 static void imap_mailbox_name(char *spec, struct vm_state *vms, int box, int use_folder)
 {
-	char tmp[256];
-	
+	char tmp[256], *t = tmp;
+	size_t left = sizeof(tmp);
+
 	if (box == 1) {
 		ast_copy_string(vms->curbox, mbox(0), sizeof(vms->curbox));
 		sprintf(vms->vmbox, "vm-%s", mbox(1));
@@ -4579,11 +4580,20 @@
 		snprintf(vms->vmbox, sizeof(vms->vmbox), "vm-%s", vms->curbox);
 	}
 
-	if (strlen(authuser) > 0) {
-		snprintf(tmp, sizeof(tmp), "{%s:%s/imap/authuser=%s/%s/user=%s}",imapserver,imapport,authuser,imapflags,vms->imapuser);
-	} else {
-		snprintf(tmp, sizeof(tmp), "{%s:%s/imap/%s/user=%s}",imapserver,imapport,imapflags,vms->imapuser);
-	}
+	/* Build up server information */
+	ast_build_string(&t, &left, "{%s:%s/imap", imapserver, imapport);
+
+	/* Add authentication user if present */
+	if (!ast_strlen_zero(authuser))
+		ast_build_string(&t, &left, "/%s", authuser);
+
+	/* Add flags if present */
+	if (!ast_strlen_zero(imapflags))
+		ast_build_string(&t, &left, "/%s", imapflags);
+
+	/* End with username */
+	ast_build_string(&t, &left, "/user=%s}", vms->imapuser);
+
 	if(box == 0 || box == 1)
 		sprintf(spec, "%s%s", tmp, use_folder? imapfolder: "INBOX");
 	else



More information about the asterisk-commits mailing list