[svn-commits] mmichelson: branch mmichelson/1.4-test r69553 - in /team/mmichelson/1.4-test:...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Jun 15 13:21:49 CDT 2007


Author: mmichelson
Date: Fri Jun 15 13:21:49 2007
New Revision: 69553

URL: http://svn.digium.com/view/asterisk?view=rev&rev=69553
Log:
Adding my changes to app_voicemail for IMAP greetings. 


Modified:
    team/mmichelson/1.4-test/   (props changed)
    team/mmichelson/1.4-test/apps/app_voicemail.c

Propchange: team/mmichelson/1.4-test/
------------------------------------------------------------------------------
    svnmerge-integrated = /branches/1.4:1-69392

Modified: team/mmichelson/1.4-test/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/team/mmichelson/1.4-test/apps/app_voicemail.c?view=diff&rev=69553&r1=69552&r2=69553
==============================================================================
--- team/mmichelson/1.4-test/apps/app_voicemail.c (original)
+++ team/mmichelson/1.4-test/apps/app_voicemail.c Fri Jun 15 13:21:49 2007
@@ -135,6 +135,9 @@
 static void imap_mailbox_name(char *spec, struct vm_state *vms, int box, int target);
 static int imap_store_file(char *dir, char *mailboxuser, char *mailboxcontext, int msgnum, struct ast_channel *chan, struct ast_vm_user *vmu, char *fmt, int duration, struct vm_state *vms);
 static int open_mailbox(struct vm_state *vms, struct ast_vm_user *vmu,int box);
+static int imap_remove_file (char *dir, int msgnum);
+static int imap_retrieve_file (char *dir, int msgnum, char *mailbox, char *context);
+static int imap_delete_old_greeting (char *dir, struct vm_state *vms);
 struct vmstate {
 	struct vm_state *vms;
 	struct vmstate *next;
@@ -379,7 +382,7 @@
 #ifdef ODBC_STORAGE
 static char odbc_database[80];
 static char odbc_table[80];
-#define RETRIEVE(a,b) retrieve_file(a,b)
+#define RETRIEVE(a,b,c,d) retrieve_file(a,b)
 #define DISPOSE(a,b) remove_file(a,b)
 #define STORE(a,b,c,d,e,f,g,h,i) store_file(a,b,c,d)
 #define EXISTS(a,b,c,d) (message_exists(a,b))
@@ -388,8 +391,8 @@
 #define DELETE(a,b,c) (delete_file(a,b))
 #else
 #ifdef IMAP_STORAGE
-#define RETRIEVE(a,b)
-#define DISPOSE(a,b)
+#define RETRIEVE(a,b,c,d) (imap_retrieve_file(a,b,c,d ))
+#define DISPOSE(a,b) (imap_remove_file(a,b))
 #define STORE(a,b,c,d,e,f,g,h,i) (imap_store_file(a,b,c,d,e,f,g,h,i))
 #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));
@@ -397,7 +400,7 @@
 #define IMAP_DELETE(a,b,c,d) (vm_imap_delete(b,d))
 #define DELETE(a,b,c) (vm_delete(c))
 #else
-#define RETRIEVE(a,b)
+#define RETRIEVE(a,b,c,d)
 #define DISPOSE(a,b)
 #define STORE(a,b,c,d,e,f,g,h,i)
 #define EXISTS(a,b,c,d) (ast_fileexists(c,NULL,d) > 0)
@@ -876,6 +879,7 @@
 	/* this may be an index into vms->msgArray based on the msgnum. */
 
 	messageNum = vms->msgArray[msgnum];
+	ast_log (LOG_DEBUG, "the messageNum that is going to be erased is ... ... ... %d\n", messageNum);
 	if (messageNum == 0) {
 		ast_log(LOG_WARNING, "msgnum %d, mailbox message %lu is zero.\n",msgnum,messageNum);
 		return;
@@ -1843,6 +1847,8 @@
 	struct tm tm;
 	char *passdata2;
 	size_t len_passdata;
+	char *greeting_attachment;
+
 #ifdef IMAP_STORAGE
 #define ENDL "\r\n"
 #else
@@ -1855,6 +1861,11 @@
 	else {
 		snprintf(who, sizeof(who), "%s@%s", srcemail, host);
 	}
+	
+	greeting_attachment = strrchr(ast_strdupa(attach), '/');
+	if (greeting_attachment)
+		*greeting_attachment++ = '\0';
+
 	snprintf(dur, sizeof(dur), "%d:%02d", duration / 60, duration % 60);
 	strftime(date, sizeof(date), "%a, %d %b %Y %H:%M:%S %z", vmu_tm(vmu, &tm));
 	fprintf(p, "Date: %s" ENDL, date);
@@ -1919,8 +1930,11 @@
 		fprintf(p, "X-Asterisk-VM-Caller-ID-Num: %s" ENDL, cidnum);
 		fprintf(p, "X-Asterisk-VM-Caller-ID-Name: %s" ENDL, cidname);
 		fprintf(p, "X-Asterisk-VM-Duration: %d" ENDL, duration);
-		if (!ast_strlen_zero(category))
+		if (!ast_strlen_zero(category)) {
+			ast_log (LOG_DEBUG, "Category is %s\n", category);
 			fprintf(p, "X-Asterisk-VM-Category: %s" ENDL, category);
+		}
+		fprintf(p, "X-Asterisk-VM-Message-Type: %s\n", msgnum > -1 ? "Message" : greeting_attachment);
 		fprintf(p, "X-Asterisk-VM-Orig-date: %s" ENDL, date);
 		fprintf(p, "X-Asterisk-VM-Orig-time: %ld" ENDL, (long)time(NULL));
 	}
@@ -1953,12 +1967,15 @@
 			ast_channel_free(ast);
 		} else
 			ast_log(LOG_WARNING, "Cannot allocate the channel for variables substitution\n");
-	} else {
+	} else if (msgnum > -1){
 		fprintf(p, "Dear %s:" ENDL ENDL "\tJust wanted to let you know you were just left a %s long message (number %d)" ENDL
 
 		"in mailbox %s from %s, on %s so you might" ENDL
 		"want to check it when you get a chance.  Thanks!" ENDL ENDL "\t\t\t\t--Asterisk" ENDL ENDL, vmu->fullname, 
 		dur, msgnum + 1, mailbox, (cidname ? cidname : (cidnum ? cidnum : "an unknown caller")), date);
+	} else {
+		fprintf(p, "This message is to let you know that your greeting was changed on %s." ENDL
+				"Please do not delete this message, lest your greeting vanish with it." ENDL ENDL, date);
 	}
 	if (attach_user_voicemail) {
 		/* Eww. We want formats to tell us their own MIME type */
@@ -1979,10 +1996,16 @@
 				ast_log(LOG_DEBUG, "VOLGAIN: Stored at: %s.%s - Level: %.4f - Mailbox: %s\n", attach, format, vmu->volgain, mailbox);
 		}
 		fprintf(p, "--%s" ENDL, bound);
-		fprintf(p, "Content-Type: %s%s; name=\"msg%04d.%s\"" ENDL, ctype, format, msgnum + 1, format);
+		if (msgnum > -1)
+			fprintf(p, "Content-Type: %s%s; name=\"msg%04d.%s\"" ENDL, ctype, format, msgnum + 1, format);
+		else
+			fprintf(p, "Content-Type: %s%s; name=\"%s.%s\"" ENDL, ctype, format, greeting_attachment, format);
 		fprintf(p, "Content-Transfer-Encoding: base64" ENDL);
 		fprintf(p, "Content-Description: Voicemail sound attachment." ENDL);
-		fprintf(p, "Content-Disposition: attachment; filename=\"msg%04d.%s\"" ENDL ENDL, msgnum + 1, format);
+		if (msgnum > -1)
+			fprintf(p, "Content-Disposition: attachment; filename=\"msg%04d.%s\"" ENDL ENDL, msgnum + 1, format);
+		else
+			fprintf(p, "Content-Disposition: attachment; filename=\"%s.%s\"" ENDL ENDL, greeting_attachment, format);
 		snprintf(fname, sizeof(fname), "%s.%s", attach, format);
 		base_encode(fname, p);
 		fprintf(p, ENDL "--%s--" ENDL "." ENDL, bound);
@@ -2111,7 +2134,7 @@
 	struct tm tm;
 	time_t t;
 	t = time(0);
-	ast_localtime(&t, &tm, NULL);
+	localtime_r(&t,&tm);
 	return strftime(s, len, "%a %b %e %r %Z %Y", &tm);
 }
 
@@ -2128,7 +2151,7 @@
 		return -1;
 	}
 
-	RETRIEVE(fn, -1);
+	RETRIEVE(fn, -1, ext, context);
 	if (ast_fileexists(fn, NULL, NULL) > 0) {
 		res = ast_stream_and_wait(chan, fn, chan->language, ecodes);
 		if (res) {
@@ -2387,8 +2410,11 @@
 	if (!ast_strlen_zero(vmu->serveremail))
 		myserveremail = vmu->serveremail;
 
-	make_file(fn, sizeof(fn), dir, msgnum);
-
+	if (msgnum > -1)
+		make_file(fn, sizeof(fn), dir, msgnum);
+	else
+		ast_copy_string (fn, dir, sizeof(fn));
+	
 	if (ast_strlen_zero(vmu->email))
 		ast_copy_string(vmu->email, vmu->imapuser, sizeof(vmu->email));
 
@@ -2402,6 +2428,11 @@
 		ast_log(LOG_WARNING, "Unable to store '%s' (can't create temporary file)\n", fn);
 		return -1;
 	} else {
+		/*If storing a greeting, delete the old one*/
+		if (msgnum < 0) {
+			ast_log (LOG_DEBUG, "Sanity check: fn is %s\n", fn);
+			imap_delete_old_greeting(fn, vms);
+		}
 		make_email_file(p, myserveremail, vmu, msgnum, vmu->context, vmu->mailbox, S_OR(chan->cid.cid_num, NULL), S_OR(chan->cid.cid_name, NULL), fn, fmt, duration, 1, chan, NULL, 1);
 		/* read mail file to memory */		
 		len = ftell(p);
@@ -2871,7 +2902,7 @@
 		ast_log(LOG_WARNING, "Failed to make directory (%s)\n", tempfile);
 		return -1;
 	}
-	RETRIEVE(tempfile, -1);
+	RETRIEVE(tempfile, -1, ext, context);
 	if (ast_fileexists(tempfile, NULL, NULL) > 0)
 		ast_copy_string(prefile, tempfile, sizeof(prefile));
 	DISPOSE(tempfile, -1);
@@ -2908,7 +2939,7 @@
 
 	/* Play the beginning intro if desired */
 	if (!ast_strlen_zero(prefile)) {
-		RETRIEVE(prefile, -1);
+		RETRIEVE(prefile, -1, ext, context);
 		if (ast_fileexists(prefile, NULL, NULL) > 0) {
 			if (ast_streamfile(chan, prefile, chan->language) > -1) 
 				res = ast_waitstream(chan, ecodes);
@@ -4076,7 +4107,7 @@
 
 		/* Forward VoiceMail */
 		long duration = 0;
- 		RETRIEVE(dir, curmsg);
+ 		RETRIEVE(dir, curmsg, sender->mailbox, context);
 		cmd = vm_forwardoptions(chan, sender, dir, curmsg, vmfmts, S_OR(context, "default"), record_gain, &duration, vms);
 		if (!cmd) {
 			AST_LIST_TRAVERSE_SAFE_BEGIN(&extensions, vmtmp, list) {
@@ -4223,10 +4254,10 @@
 /* No internal variable parsing for now, so we'll comment it out for the time being */
 #if 0
 	/* Set the DIFF_* variables */
-	ast_localtime(&t, &time_now, NULL);
+	localtime_r(&t, &time_now);
 	tv_now = ast_tvnow();
 	tnow = tv_now.tv_sec;
-	ast_localtime(&tnow, &time_then, NULL);
+	localtime_r(&tnow,&time_then);
 
 	/* Day difference */
 	if (time_now.tm_year == time_then.tm_year)
@@ -4425,6 +4456,7 @@
 		ast_log(LOG_ERROR, "There is no file attached to this IMAP message.\n");
 		return -1;
 	}
+	
 	
 	/* Find the format of the attached file */
 
@@ -4571,7 +4603,7 @@
 	/* Retrieve info from VM attribute file */
 	make_file(vms->fn2, sizeof(vms->fn2), vms->curdir, vms->curmsg);
 	snprintf(filename, sizeof(filename), "%s.txt", vms->fn2);
-	RETRIEVE(vms->curdir, vms->curmsg);
+	RETRIEVE(vms->curdir, vms->curmsg, vmu->mailbox, vmu->context);
 	msg_cfg = ast_config_load(filename);
 	if (!msg_cfg) {
 		ast_log(LOG_WARNING, "No message attribute file?!! (%s)\n", filename);
@@ -4746,6 +4778,182 @@
 
 	mail_free_searchpgm(&pgm);
 	return 0;
+}
+
+static int imap_remove_file(char *dir, int msgnum)
+{
+	char fn[PATH_MAX];
+	char full_fn[PATH_MAX];
+	char msgnums[80];
+	
+	if (msgnum > -1) {
+		snprintf(msgnums, sizeof(msgnums), "%d", msgnum);
+		make_file(fn, sizeof(fn), dir, msgnum);
+	} else
+		ast_copy_string(fn, dir, sizeof(fn));
+	ast_filedelete(fn, NULL);	
+	snprintf(full_fn, sizeof(full_fn), "%s.txt", fn);
+	unlink(full_fn);
+	return 0;
+}
+
+static int imap_retrieve_file (char *dir, int msgnum, char *mailbox, char *context)
+{
+	struct ast_vm_user *vmu;
+	struct vm_state *vms_p;
+	char *file, *filename;
+	char *attachment;
+	/*char *mb, *cur;*/
+	int ret = 0, i;
+	BODY *body;
+
+	if (msgnum > -1) {
+		return 0;
+	} else {
+		file = strrchr(ast_strdupa(dir), '/');
+		if (file)
+			*file++ = '\0';
+		else {
+			ast_log (LOG_DEBUG, "Failed to procure file name from directory passed. You should never see this.\n");
+			return -1;
+		}
+	}
+	/* We have to get the user before we can open the stream! */
+	/* ast_log (LOG_DEBUG,"Before find_user, context is %s and mailbox is %s\n",context,mailbox); */
+	vmu = find_user(NULL, context, mailbox);
+	if (!vmu) {
+		ast_log (LOG_ERROR,"Couldn't find mailbox %s in context %s\n",mailbox,context);
+		return -1;
+	} else {
+		/* No IMAP account available */
+		if (vmu->imapuser[0] == '\0') {
+			ast_log (LOG_WARNING,"IMAP user not set for mailbox %s\n",vmu->mailbox);
+			free_user(vmu);
+			return -1;
+		}
+	}
+
+	/* 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);
+	}
+	if (!vms_p){
+		/* 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);
+		}
+
+		if (!vms_p) {
+			if(option_debug > 2)
+				ast_log (LOG_DEBUG,"Adding new vmstate for %s\n",vmu->imapuser);
+			if (!(vms_p = ast_calloc(1, sizeof(*vms_p)))) {
+				free_user(vmu);
+				return -1;
+			}
+			ast_copy_string(vms_p->imapuser,vmu->imapuser, sizeof(vms_p->imapuser));
+			ast_copy_string(vms_p->username, mailbox, sizeof(vms_p->username)); /* save for access from interactive entry point */
+			vms_p->mailstream = NIL; /* save for access from interactive entry point */
+			if(option_debug > 2)
+				ast_log (LOG_DEBUG,"Copied %s to %s\n",vmu->imapuser,vms_p->imapuser);
+			vms_p->updated = 1;
+			/* set mailbox to INBOX! */
+			ast_copy_string(vms_p->curbox, mbox(0), sizeof(vms_p->curbox));
+			init_vm_state(vms_p);
+			vmstate_insert(vms_p);
+		}
+	}
+	
+	ret = init_mailstream(vms_p, 0);
+	if (!vms_p->mailstream) {
+		ast_log (LOG_ERROR,"IMAP mailstream is NULL\n");
+		free_user(vmu);
+		return -1;
+	}
+
+	for (i = 0; i < vms_p->mailstream->nmsgs; i++)
+	{
+		mail_fetchstructure(vms_p->mailstream, i + 1, &body);
+		/* We have the body, now we extract the file name of the first attachment. */
+		if (body->nested.part->next && body->nested.part->next->body.parameter->value) {
+			attachment = ast_strdupa(body->nested.part->next->body.parameter->value);
+		} else {
+			ast_log(LOG_ERROR, "There is no file attached to this IMAP message.\n");
+			return -1;
+		}
+		filename = strsep(&attachment, ".");
+		if (!strcmp(filename, file))
+		{
+			ast_log (LOG_DEBUG, "HOLY SHIT we found the message. It was number %d\n", i + 1);
+			ast_copy_string(vms_p->fn, dir, sizeof(vms_p->fn));
+			vms_p->msgArray[vms_p->curmsg] = i + 1;
+			save_body(body, vms_p, "2", attachment);
+			free_user(vmu);
+			return 0;
+		}
+	}
+	
+
+/*	pgm = mail_newsearchpgm ();
+	hdr = mail_newsearchheader ("X-Asterisk-VM-Message-Type", file);
+	pgm->header = hdr;
+	pgm->unseen = 1;
+	pgm->seen = 0;
+	pgm->undeleted = 1;
+	pgm->deleted = 0;
+
+	vms_p->vmArrayIndex = 0;
+	
+	mail_search_full (vms_p->mailstream, NULL, pgm, NIL);
+	vms_p->newmessages = vms_p->vmArrayIndex;
+	mail_free_searchpgm(&pgm);*/
+
+
+	free_user(vmu);
+	return 0;
+}
+
+static int imap_delete_old_greeting (char *dir, struct vm_state *vms)
+{
+	char *file, *filename;
+	char *attachment;
+	char arg[10];
+	int i;
+	BODY* body;
+
+	ast_log (LOG_DEBUG, "Test> I am being called correctly\n");
+	
+	file = strrchr(ast_strdupa(dir), '/');
+	if (file)
+		*file++ = '\0';
+	else {
+		ast_log (LOG_DEBUG, "Failed to procure file name from directory passed. You should never see this.\n");
+		return -1;
+	}
+	
+	for (i = 0; i < vms->mailstream->nmsgs; i++) {
+		mail_fetchstructure(vms->mailstream, i + 1, &body);
+		/* We have the body, now we extract the file name of the first attachment. */
+		if (body->nested.part->next && body->nested.part->next->body.parameter->value) {
+			attachment = ast_strdupa(body->nested.part->next->body.parameter->value);
+		} else {
+			ast_log(LOG_ERROR, "There is no file attached to this IMAP message.\n");
+			return -1;
+		}
+		filename = strsep(&attachment, ".");
+		if (!strcmp(filename, file))
+		{
+			ast_log (LOG_DEBUG, "Poised to delete message number %d\n", i+1);
+			sprintf (arg,"%lu", i+1);
+			mail_setflag (vms->mailstream,arg,"\\DELETED");
+			mail_expunged(vms->mailstream, i+1);
+			return 0;
+		}
+	}	
+	if (option_debug > 2)
+		ast_log (LOG_DEBUG, "Unable to find greeting\n");
+	return -1;
 }
 #else
 static int open_mailbox(struct vm_state *vms, struct ast_vm_user *vmu,int box)
@@ -4903,7 +5111,7 @@
 {
 	int cmd;
 
-	if (!strcasecmp(chan->language, "it") || !strcasecmp(chan->language, "es") || !strcasecmp(chan->language, "pt") || !strcasecmp(chan->language, "pt_BR")) { /* Italian, Spanish, French or Portuguese syntax */
+	if (!strcasecmp(chan->language, "it") || !strcasecmp(chan->language, "es") || !strcasecmp(chan->language, "fr") || !strcasecmp(chan->language, "pt") || !strcasecmp(chan->language, "pt_BR")) { /* Italian, Spanish, French or Portuguese syntax */
 		cmd = ast_play_and_wait(chan, "vm-messages"); /* "messages */
 		return cmd ? cmd : ast_play_and_wait(chan, mbox);
 	} else if (!strcasecmp(chan->language, "gr")){
@@ -5376,14 +5584,14 @@
 		}
 		if (!res && vms->oldmessages) {
 			res = say_and_wait(chan, vms->oldmessages, chan->language);
-			if (!res)
-				res = ast_play_and_wait(chan, "vm-Old");
 			if (!res) {
 				if (vms->oldmessages == 1)
 					res = ast_play_and_wait(chan, "vm-message");
 				else
 					res = ast_play_and_wait(chan, "vm-messages");
 			}
+			if (!res)
+				res = ast_play_and_wait(chan, "vm-Old");
 		}
 		if (!res) {
 			if (!vms->oldmessages && !vms->newmessages) {
@@ -5970,7 +6178,7 @@
 	while((cmd >= 0) && (cmd != 't')) {
 		if (cmd)
 			retries = 0;
-		RETRIEVE(prefile, -1);
+		RETRIEVE(prefile, -1, vmu->mailbox, vmu->context);
 		if (ast_fileexists(prefile, NULL, NULL) <= 0) {
 #ifndef IMAP_STORAGE
 			play_record_review(chan, "vm-rec-temp", prefile, maxgreet, fmtc, 0, vmu, &duration, NULL, record_gain, NULL);
@@ -7853,7 +8061,7 @@
 
 	make_file(vms->fn2, sizeof(vms->fn2), vms->curdir, vms->curmsg);
 	snprintf(filename,sizeof(filename), "%s.txt", vms->fn2);
-	RETRIEVE(vms->curdir, vms->curmsg);
+	RETRIEVE(vms->curdir, vms->curms, vmu->mailbox, vmu->context);
 	msg_cfg = ast_config_load(filename);
 	DISPOSE(vms->curdir, vms->curmsg);
 	if (!msg_cfg) {
@@ -8042,7 +8250,6 @@
 	int recorded = 0;
 	int message_exists = 0;
 	signed char zero_gain = 0;
-	char tempfile[PATH_MAX];
 	char *acceptdtmf = "#";
 	char *canceldtmf = "";
 
@@ -8053,11 +8260,6 @@
 		ast_log(LOG_WARNING, "Error play_record_review called without duration pointer\n");
 		return -1;
 	}
-
-	if (!outsidecaller)
-		snprintf(tempfile, sizeof(tempfile), "%s.tmp", recordfile);
-	else
-		ast_copy_string(tempfile, recordfile, sizeof(tempfile));
 
 	cmd = '3';  /* Want to start by recording */
 
@@ -8072,10 +8274,9 @@
 				/* Otherwise 1 is to save the existing message */
 				if (option_verbose > 2)
 					ast_verbose(VERBOSE_PREFIX_3 "Saving message as is\n");
+				ast_stream_and_wait(chan, "vm-msgsaved", chan->language, "");
 				if (!outsidecaller)
-					ast_filerename(tempfile, recordfile, NULL);
-				ast_stream_and_wait(chan, "vm-msgsaved", chan->language, "");
-				if (!outsidecaller) {
+				{
 					STORE(recordfile, vmu->mailbox, vmu->context, -1, chan, vmu, fmt, *duration, vms);
 					DISPOSE(recordfile, -1);
 				}
@@ -8086,7 +8287,7 @@
 			/* Review */
 			if (option_verbose > 2)
 				ast_verbose(VERBOSE_PREFIX_3 "Reviewing the message\n");
-			cmd = ast_stream_and_wait(chan, tempfile, chan->language, AST_DIGIT_ANY);
+			cmd = ast_stream_and_wait(chan, recordfile, chan->language, AST_DIGIT_ANY);
 			break;
 		case '3':
 			message_exists = 0;
@@ -8108,15 +8309,11 @@
 				ast_channel_setoption(chan, AST_OPTION_RXGAIN, &record_gain, sizeof(record_gain), 0);
 			if (ast_test_flag(vmu, VM_OPERATOR))
 				canceldtmf = "0";
-			cmd = ast_play_and_record_full(chan, playfile, tempfile, maxtime, fmt, duration, silencethreshold, maxsilence, unlockdir, acceptdtmf, canceldtmf);
+			cmd = ast_play_and_record_full(chan, playfile, recordfile, maxtime, fmt, duration, silencethreshold, maxsilence, unlockdir, acceptdtmf, canceldtmf);
 			if (record_gain)
 				ast_channel_setoption(chan, AST_OPTION_RXGAIN, &zero_gain, sizeof(zero_gain), 0);
 			if (cmd == -1) {
-				/* User has hung up, no options to give */
-				if (!outsidecaller) {
-					/* user was recording a greeting and they hung up, so let's delete the recording. */
-					vm_delete(tempfile);
-				}
+			/* User has hung up, no options to give */
 				return cmd;
 			}
 			if (cmd == '0') {
@@ -8130,14 +8327,14 @@
 				if (option_verbose > 2)
 					ast_verbose(VERBOSE_PREFIX_3 "Message too short\n");
 				cmd = ast_play_and_wait(chan, "vm-tooshort");
-				cmd = vm_delete(tempfile);
+				cmd = vm_delete(recordfile);
 				break;
 			}
 			else if (vmu->review && (cmd == 2 && *duration < (maxsilence + 3))) {
 				/* Message is all silence */
 				if (option_verbose > 2)
 					ast_verbose(VERBOSE_PREFIX_3 "Nothing recorded\n");
-				cmd = vm_delete(tempfile);
+				cmd = vm_delete(recordfile);
 				cmd = ast_play_and_wait(chan, "vm-nothingrecorded");
 				if (!cmd)
 					cmd = ast_play_and_wait(chan, "vm-speakup");
@@ -8166,7 +8363,7 @@
 		case '*':
 			/* Cancel recording, delete message, offer to take another message*/
 			cmd = ast_play_and_wait(chan, "vm-deleted");
-			cmd = vm_delete(tempfile);
+			cmd = vm_delete(recordfile);
 			if (outsidecaller) {
 				res = vm_exec(chan, NULL);
 				return res;
@@ -8255,8 +8452,7 @@
 	
 	vms = get_vm_state_by_imapuser(user,2);
 	if (vms) {
-		if(option_debug > 2)
-			ast_log (LOG_DEBUG, "saving mailbox message number %lu as message %d. Interactive set to %d\n",number,vms->vmArrayIndex,vms->interactive);
+		ast_log (LOG_DEBUG, "saving mailbox message number %lu as message %d. Interactive set to %d\n",number,vms->vmArrayIndex,vms->interactive);
 		vms->msgArray[vms->vmArrayIndex++] = number;
 	} else {
 		ast_log (LOG_ERROR, "No state found.\n");
@@ -8912,6 +9108,7 @@
 	if (!body || body == NIL)
 		return -1;
 	display_body (body, NIL, (long) 0);
+	ast_log (LOG_DEBUG, "testing, vms->curmsg is %d and vms-msgArray[vms-curmsg] is %d\n", vms->curmsg, vms->msgArray[vms->curmsg]);
 	body_content = mail_fetchbody (vms->mailstream, vms->msgArray[vms->curmsg], section, &len);
 	if (body_content != NIL) {
 		sprintf(filename,"%s.%s", vms->fn, format);




More information about the svn-commits mailing list