[asterisk-commits] mmichelson: branch mmichelson/imap_consistency_trunk r134255 - /team/mmichels...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jul 29 17:10:34 CDT 2008


Author: mmichelson
Date: Tue Jul 29 17:10:33 2008
New Revision: 134255

URL: http://svn.digium.com/view/asterisk?view=rev&rev=134255
Log:
More conflict resolution. Still a lot needs to be
done with regards to retrieval function since greetings
can be retrieved from IMAP.


Modified:
    team/mmichelson/imap_consistency_trunk/apps/app_voicemail.c

Modified: team/mmichelson/imap_consistency_trunk/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/team/mmichelson/imap_consistency_trunk/apps/app_voicemail.c?view=diff&rev=134255&r1=134254&r2=134255
==============================================================================
--- team/mmichelson/imap_consistency_trunk/apps/app_voicemail.c (original)
+++ team/mmichelson/imap_consistency_trunk/apps/app_voicemail.c Tue Jul 29 17:10:33 2008
@@ -150,12 +150,7 @@
 static void set_update(MAILSTREAM * stream);
 static void init_vm_state(struct vm_state *vms);
 static void copy_msgArray(struct vm_state *dst, struct vm_state *src);
-<<<<<<< .working
 static int save_body(BODY *body, struct vm_state *vms, char *section, char *format, char *altfile);
-static int make_gsm_file(char *dest, size_t len, char *imapuser, char *dir, int num, char *prefix);
-=======
-static int save_body(BODY *body, struct vm_state *vms, char *section, char *format);
->>>>>>> .merge-right.r134223
 static void get_mailbox_delimiter(MAILSTREAM *stream);
 static void mm_parsequota (MAILSTREAM *stream, unsigned char *msg, QUOTALIST *pquota);
 static void imap_mailbox_name(char *spec, size_t len, struct vm_state *vms, int box, int target);
@@ -459,13 +454,9 @@
 #define DELETE(a,b,c,d) (delete_file(a,b))
 #else
 #ifdef IMAP_STORAGE
-<<<<<<< .working
 #define DISPOSE(a,b) (imap_remove_file(a,b))
 #define STORE(a,b,c,d,e,f,g,h,i,j,k) (imap_store_file(a,b,c,d,e,f,g,h,i,j,k))
-=======
 #define RETRIEVE(a,b,c) imap_retrieve_file(a,b,c)
-#define DISPOSE(a,b) remove_file(a,b)
->>>>>>> .merge-right.r134223
 #define EXISTS(a,b,c,d) (ast_fileexists(c,NULL,d) > 0)
 #define RENAME(a,b,c,d,e,f,g,h) (rename_file(g,h));
 #define COPY(a,b,c,d,e,f,g,h) (copy_file(g,h));
@@ -4567,13 +4558,9 @@
 #else
 	char urgdir[PATH_MAX];
 #endif
-<<<<<<< .working
 	char txtfile[PATH_MAX];
 	char tmptxtfile[PATH_MAX];
-=======
 	struct vm_state *vms = NULL;
-	char txtfile[PATH_MAX], tmptxtfile[PATH_MAX];
->>>>>>> .merge-right.r134223
 	char callerid[256];
 	FILE *txt;
 	char date[256];
@@ -5937,16 +5924,7 @@
 static int forward_message(struct ast_channel *chan, char *context, struct vm_state *vms, struct ast_vm_user *sender, char *fmt, int is_new_message, signed char record_gain, int urgent)
 {
 #ifdef IMAP_STORAGE
-<<<<<<< .working
-	BODY *body;
-	char *header_content;
-	char *temp;
-	char todir[256], introtmp[256];
-	char tmpcmd[512];
-	int todircount = 0, two_part = -1;
-=======
 	int todircount=0;
->>>>>>> .merge-right.r134223
 	struct vm_state *dstvms;
 	char tmpdir[PATH_MAX];
 #endif
@@ -6135,55 +6113,6 @@
 			AST_LIST_TRAVERSE_SAFE_BEGIN(&extensions, vmtmp, list) {
 #ifdef IMAP_STORAGE
 				int attach_user_voicemail;
-<<<<<<< .working
-
-				/* Need to get message content */
-				ast_debug(3, "Before mail_fetchheaders, curmsg is: %d, imap messages is %lu\n", vms->curmsg, vms->msgArray[vms->curmsg]);
-				if (!vms->msgArray[vms->curmsg]) {
-					ast_log(AST_LOG_WARNING, "Trying to access unknown message\n");
-					return -1;
-				}
-
-				/* This will only work for new messages... */
-				header_content = mail_fetchheader (vms->mailstream, vms->msgArray[vms->curmsg]);
-
-				/* empty string means no valid header */
-				if (ast_strlen_zero(header_content)) {
-					ast_log(AST_LOG_ERROR, "Could not fetch header for message number %ld\n", vms->msgArray[vms->curmsg]);
-					return -1;
-				}
-				/* Get header info needed by sendmail */
-				if ((temp = get_header_by_tag(header_content, "X-Asterisk-VM-Duration:", buf, sizeof(buf))))
-					duration = atoi(temp);
-				else
-					duration = 0;
-				
-				/* Attach only the first format */
-				if ((fmt = ast_strdupa(fmt))) {
-					stringp = fmt;
-					strsep(&stringp, "|");
-				} else {
-					ast_log(AST_LOG_ERROR, "audio format not set. Default to WAV\n");
-					fmt = "WAV";
-				}
-				if (!strcasecmp(fmt, "wav49"))
-					fmt = "WAV";
-				ast_debug(3, "**** format set to %s, vmfmts set to %s\n", fmt, vmfmts);
-				snprintf(todir, sizeof(todir), "%s%s/%s/tmp", VM_SPOOL_DIR, vmtmp->context, vmtmp->mailbox);
-				make_gsm_file(vms->fn, sizeof(vms->fn), vms->imapuser, todir, vms->curmsg, "msg");
-
-				ast_debug(3, "Before mail_fetchstructure, message number is %ld, filename is:%s\n", vms->msgArray[vms->curmsg], vms->fn);
-				mail_fetchstructure(vms->mailstream, vms->msgArray[vms->curmsg], &body);
-				/* should not assume "fmt" here! */
-				save_body(body, vms, "2", fmt, vms->fn);
-  
-				/* second attachment would be body if intro, otherwise null
-				 * two_part will be set to 0 if there are two parts, otherwise -1 */
-				snprintf(introtmp, sizeof(introtmp), "%stmp",vms->intro);
-				two_part = save_body(body,vms,"3",fmt, introtmp);
-
-=======
->>>>>>> .merge-right.r134223
 				/* If there are two parts to the existing 
 				 * message, merge them together into one message before sending */
 				if (two_part == 0) {
@@ -6202,13 +6131,8 @@
 					if (!dstvms->mailstream) {
 						ast_log(AST_LOG_ERROR, "IMAP mailstream for %s is NULL\n", vmtmp->mailbox);
 					} else {
-<<<<<<< .working
-						STORE(todir, vmtmp->mailbox, vmtmp->context, dstvms->curmsg, chan, vmtmp, fmt, duration, dstvms, tmptxtfile, urgent_str);
+						STORE(vmstmp.curdir, vmtmp->mailbox, vmtmp->context, dstvms->curmsg, chan, vmtmp, fmt, duration, dstvms, tmptxtfile, urgent_str);
 						run_externnotify(vmtmp->context, vmtmp->mailbox, urgent_str); 
-=======
-						STORE(vmstmp.curdir, vmtmp->mailbox, vmtmp->context, dstvms->curmsg, chan, vmtmp, fmt, duration, dstvms);
-						run_externnotify(vmtmp->context, vmtmp->mailbox); 
->>>>>>> .merge-right.r134223
 					}
 				} else {
 					ast_log(AST_LOG_ERROR, "Could not find state information for mailbox %s\n", vmtmp->mailbox);
@@ -6468,181 +6392,7 @@
 
 static int play_message(struct ast_channel *chan, struct ast_vm_user *vmu, struct vm_state *vms)
 {
-<<<<<<< .working
-	BODY *body;
-	char *header_content;
-	char cid[256], cidN[256];
-	char context[256];
-	char origtime[32];
-	char duration[16];
-	char category[32];
-	char todir[PATH_MAX];
-=======
->>>>>>> .merge-right.r134223
-	int res = 0, two_part = -1;
-<<<<<<< .working
-	char *attachedfilefmt;
-	char *temp;
-	char buf[1024];
-	char flag[80];
-
-	vms->starting = 0; 
-	ast_debug(3,"Before mail_fetchheaders, curmsg is: %d, imap messages is %lu\n",vms->curmsg, vms->msgArray[vms->curmsg]);
-
-	if (!vms->msgArray[vms->curmsg]) {
-		ast_log(AST_LOG_WARNING, "Trying to access unknown message\n");
-		return -1;
-	}
-
-	/* This will only work for new messages... */
-	header_content = mail_fetchheader (vms->mailstream, vms->msgArray[vms->curmsg]);
-	/* empty string means no valid header */
-	if (ast_strlen_zero(header_content)) {
-		ast_log(AST_LOG_ERROR, "Could not fetch header for message number %ld\n", vms->msgArray[vms->curmsg]);
-		return -1;
-	}
-
-	/* Get Urgent flag from headers */
-	temp = get_header_by_tag(header_content, "X-Asterisk-VM-Flag:", buf, sizeof(buf));
-	ast_debug(3,"Voicemail FLAG set to %s\n",temp);
-
-	if (temp)
-		ast_copy_string(flag, temp, sizeof(flag));
-	else
-		flag[0] = '\0';
-
-	snprintf(todir, sizeof(todir), "%s%s/%s/tmp", VM_SPOOL_DIR, vmu->context, vmu->mailbox);
-	make_gsm_file(vms->fn, sizeof(vms->fn), vms->imapuser, todir, vms->curmsg, "msg");
-	make_gsm_file(vms->intro, sizeof(vms->intro), vms->imapuser, todir, vms->curmsg, "msgintro");
-
-	mail_fetchstructure (vms->mailstream,vms->msgArray[vms->curmsg],&body);
-	
-	/* We have the body, now we extract the file name of the first attachment. */
-	if (body->nested.part && body->nested.part->next && body->nested.part->next->body.parameter->value) {
-		attachedfilefmt = ast_strdupa(body->nested.part->next->body.parameter->value);
-	} else {
-		ast_log(AST_LOG_ERROR, "There is no file attached to this IMAP message.\n");
-		return -1;
-	}
-	
-	/* Find the format of the attached file */
-	strsep(&attachedfilefmt, ".");
-	if (!attachedfilefmt) {
-		ast_log(AST_LOG_ERROR, "File format could not be obtained from IMAP message attachment\n");
-		return -1;
-	}
-	save_body(body, vms, "2", attachedfilefmt, vms->fn); /* save first attachment */
-	two_part = save_body(body, vms, "3", attachedfilefmt, vms->intro); /* save forwarded intro if present */
-
-	adsi_message(chan, vms);
-	ast_debug(5,"**************  About to check urgent flag, set to:%s\n", flag);
-	if (!strcasecmp(chan->language, "he")) {	/* HEBREW FORMAT */
-		/*
-		 * The syntax in hebrew for counting the number of message is up side down
-		 * in comparison to english.
-		 */
-		if (!vms->curmsg) {
-			res = wait_file2(chan, vms, "vm-message");
-			res = wait_file2(chan, vms, "vm-first");    /* "First" */
-		} else if (vms->curmsg == vms->lastmsg) {
-			res = wait_file2(chan, vms, "vm-message");
-			res = wait_file2(chan, vms, "vm-last");     /* "last" */
-		} else {
-			res = wait_file2(chan, vms, "vm-message");  /* "message" */
-			if (vms->curmsg && (vms->curmsg != vms->lastmsg)) {
-				ast_log(LOG_DEBUG, "curmsg: %s\n", vms->curmsg);
-				ast_log(LOG_DEBUG, "lagmsg: %s\n", vms->lastmsg);
-				if (!res) {
-					res = ast_say_number(chan, vms->curmsg + 1, AST_DIGIT_ANY, chan->language, "f");
-				}
-			}
-		}
-	} else {
-		if (!vms->curmsg)
-			res = wait_file2(chan, vms, "vm-first");	/* "First" */
-		else if (vms->curmsg == vms->lastmsg)
-			res = wait_file2(chan, vms, "vm-last");		/* "last" */
-	}
-	/* Play the word urgent if we are listening to urgent messages */
-	if (!ast_strlen_zero(flag) && !strcmp(flag, "Urgent")) {
-		res = wait_file2(chan, vms, "vm-Urgent");	/* "urgent" */
-	}
-
-	if (!res) {
-		res = wait_file2(chan, vms, "vm-message");	/* "message" */
-		if (vms->curmsg && (vms->curmsg != vms->lastmsg)) {
-			if (!res)
-				res = ast_say_number(chan, vms->curmsg + 1, AST_DIGIT_ANY, chan->language, NULL);
-		}
-	}
-
-	/* Get info from headers!! */
-	if ((temp = get_header_by_tag(header_content, "X-Asterisk-VM-Caller-ID-Name:", buf, sizeof(buf))))
-		ast_copy_string(cidN, temp, sizeof(cidN));
-	else
-		cidN[0] = '\0';
-
-	if ((temp = get_header_by_tag(header_content, "X-Asterisk-VM-Caller-ID-Num:", buf, sizeof(buf))))
-		snprintf(cid, sizeof(cid), "\"%s\" <%s>", cidN, temp);
-	else
-		cid[0] = '\0';
-
-	if ((temp = get_header_by_tag(header_content, "X-Asterisk-VM-Context:", buf, sizeof(buf))))
-		ast_copy_string(context, temp, sizeof(context)); 
-	else
-		context[0] = '\0';
-
-	if ((temp = get_header_by_tag(header_content, "X-Asterisk-VM-Orig-time:", buf, sizeof(buf))))
-		ast_copy_string(origtime, temp, sizeof(origtime));
-	else
-		origtime[0] = '\0';
-
-	if ((temp = get_header_by_tag(header_content, "X-Asterisk-VM-Duration:", buf, sizeof(buf))))
-		ast_copy_string(duration,temp, sizeof(duration));
-	else
-		duration[0] = '\0';
-	
-	if ((temp = get_header_by_tag(header_content, "X-Asterisk-VM-Category:", buf, sizeof(buf))))
-		ast_copy_string(category,temp, sizeof(category));
-	else
-		category[0] = '\0';
-
-	if (res == '1')
-		res = 0;
-
-	if ((!res) && !ast_strlen_zero(category)) {
-		res = play_message_category(chan, category);
-	}
-
-	if ((!res) && (ast_test_flag(vmu, VM_ENVELOPE)) && origtime[0] != '\0')
-		res = play_message_datetime(chan, vmu, origtime, "IMAP_STORAGE");
-	if ((!res) && (ast_test_flag(vmu, VM_SAYCID)) && cid[0] !='\0' && context[0] !='\0')
-		res = play_message_callerid(chan, vms, cid, context, 0);
-
-	if ((!res) && (ast_test_flag(vmu, VM_SAYDURATION)) && duration[0] != '\0')
-		res = play_message_duration(chan, vms, duration, vmu->saydurationm);
-
-	res = 0;
-
-	if (!res) {
-		vms->heard[vms->curmsg] = 1;
-		if (two_part == 0) {   /* If there are two parts */
-			wait_file(chan, vms, vms->fn);
-			res = wait_file(chan, vms, vms->intro);
-		} else {
-			res = wait_file(chan, vms, vms->fn);
-		}
-	}
-	DISPOSE(vms->curdir, vms->curmsg);
-	DELETE(0, 0, vms->fn);
-	return res;
-}
-#else
-static int play_message(struct ast_channel *chan, struct ast_vm_user *vmu, struct vm_state *vms)
-{
 	int res = 0;
-=======
->>>>>>> .merge-right.r134223
 	char filename[256], *cid;
 	const char *origtime, *context, *category, *duration, *flag;
 	struct ast_config *msg_cfg;




More information about the asterisk-commits mailing list