[asterisk-commits] mogorman: branch 1.2 r49354 - /branches/1.2/apps/app_voicemail.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Wed Jan 3 16:22:48 MST 2007


Author: mogorman
Date: Wed Jan  3 17:22:47 2007
New Revision: 49354

URL: http://svn.digium.com/view/asterisk?view=rev&rev=49354
Log:
When using ODBC_STORAGE VoicemailMain doesn't create the
subdirectories for a mailbox such as the INBOX directory.

this patch solves that problem, was written by anthony
be-125

Modified:
    branches/1.2/apps/app_voicemail.c

Modified: branches/1.2/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/apps/app_voicemail.c?view=diff&rev=49354&r1=49353&r2=49354
==============================================================================
--- branches/1.2/apps/app_voicemail.c (original)
+++ branches/1.2/apps/app_voicemail.c Wed Jan  3 17:22:47 2007
@@ -869,7 +869,12 @@
 		else
 			ast_copy_string(fn, dir, sizeof(fn));
 		snprintf(full_fn, sizeof(full_fn), "%s.txt", fn);
-		f = fopen(full_fn, "w+");
+		
+		if (!(f = fopen(full_fn, "w+"))) {
+		        ast_log(LOG_WARNING, "Failed to open/create '%s'\n", full_fn);
+		        goto yuck;
+		}
+		
 		snprintf(full_fn, sizeof(full_fn), "%s.%s", fn, fmt);
 		res = SQLAllocHandle(SQL_HANDLE_STMT, obj->con, &stmt);
 		if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
@@ -1938,7 +1943,15 @@
 {
 	int res;
 	char fn[256];
+	char dest[256];
+
 	snprintf(fn, sizeof(fn), "%s%s/%s/greet", VM_SPOOL_DIR, context, ext);
+
+	if (!(res = create_dirpath(dest,256,context,ext,"greet"))) {
+		ast_log(LOG_WARNING, "Failed to make directory(%s)\n", fn);
+		return -1;
+	}
+
 	RETRIEVE(fn, -1);
 	if (ast_fileexists(fn, NULL, NULL) > 0) {
 		res = ast_streamfile(chan, fn, chan->language);
@@ -2386,6 +2399,7 @@
 	int ouseexten = 0;
 	char date[256];
 	char dir[256], tmpdir[260];
+	char dest[256];
 	char fn[256];
 	char prefile[256]="";
 	char tempfile[256]="";
@@ -2423,17 +2437,23 @@
 		pbx_builtin_setvar_helper(chan, "VMSTATUS", "FAILED");
 		return res;
 	}
-
 	/* Setup pre-file if appropriate */
 	if (strcmp(vmu->context, "default"))
 		snprintf(ext_context, sizeof(ext_context), "%s@%s", ext, vmu->context);
 	else
 		ast_copy_string(ext_context, vmu->context, sizeof(ext_context));
-	if (ast_test_flag(options, OPT_BUSY_GREETING))
+	if (ast_test_flag(options, OPT_BUSY_GREETING)) {
+		res = create_dirpath(dest, 256, vmu->context, ext, "busy");
 		snprintf(prefile, sizeof(prefile), "%s%s/%s/busy", VM_SPOOL_DIR, vmu->context, ext);
-	else if (ast_test_flag(options, OPT_UNAVAIL_GREETING))
+	} else if (ast_test_flag(options, OPT_UNAVAIL_GREETING)) {
+		res = create_dirpath(dest, 256, vmu->context, ext, "unavail");
 		snprintf(prefile, sizeof(prefile), "%s%s/%s/unavail", VM_SPOOL_DIR, vmu->context, ext);
+	}
 	snprintf(tempfile, sizeof(tempfile), "%s%s/%s/temp", VM_SPOOL_DIR, vmu->context, ext);
+	if (!(res = create_dirpath(dest, 256, vmu->context, ext, "temp"))) {
+		ast_log(LOG_WARNING, "Failed to make directory (%s)\n", tempfile);
+		return -1;
+	}
 	RETRIEVE(tempfile, -1);
 	if (ast_fileexists(tempfile, NULL, NULL) > 0)
 		ast_copy_string(prefile, tempfile, sizeof(prefile));
@@ -3568,8 +3588,7 @@
 	} else {
 		/* Forward VoiceMail */
 		long duration = 0;
-
-		RETRIEVE(dir, curmsg);
+ 		RETRIEVE(dir, curmsg);
 		cmd = vm_forwardoptions(chan, sender, dir, curmsg, vmfmts, context, record_gain, &duration);
 		if (!cmd) {
 			while (!res && vmtmp) {
@@ -4784,11 +4803,13 @@
 
 static int vm_tempgreeting(struct ast_channel *chan, struct ast_vm_user *vmu, struct vm_state *vms, char *fmtc, signed char record_gain)
 {
+	int res;
 	int cmd = 0;
 	int retries = 0;
 	int duration = 0;
 	char prefile[256]="";
 	unsigned char buf[256];
+	char dest[256];
 	int bytes=0;
 
 	if (adsi_available(chan))
@@ -4801,6 +4822,10 @@
 		adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
 	}
 	snprintf(prefile,sizeof(prefile), "%s%s/%s/temp", VM_SPOOL_DIR, vmu->context, vms->username);
+	if (!(res = create_dirpath(dest, 256, vmu->context, vms->username, "temp"))) {
+		ast_log(LOG_WARNING, "Failed to create directory (%s).\n", prefile);
+		return -1;
+	}
 	while((cmd >= 0) && (cmd != 't')) {
 		if (cmd)
 			retries = 0;



More information about the asterisk-commits mailing list