[svn-commits] branch oej/managerstuff - r8110 in /team/oej/managerstuff: ./ apps/ channels/...

svn-commits at lists.digium.com svn-commits at lists.digium.com
Mon Jan 16 14:57:19 MST 2006


Author: oej
Date: Mon Jan 16 15:57:02 2006
New Revision: 8110

URL: http://svn.digium.com/view/asterisk?rev=8110&view=rev
Log:
Merged revisions 7939,7955,7957,7960,7963,7965,7970,7972,7976,7986,7999,8047,8074 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.2

........
r7939 | oej | 2006-01-10 09:48:14 +0100 (Tue, 10 Jan 2006) | 3 lines

- Adding reference to README.tds
- Reformatting table

........
r7955 | tilghman | 2006-01-11 02:30:10 +0100 (Wed, 11 Jan 2006) | 2 lines

Bug 6192 - behave correctly when mailbox is specified as argument

........
r7957 | russell | 2006-01-11 04:12:44 +0100 (Wed, 11 Jan 2006) | 2 lines

fix a little typo

........
r7960 | russell | 2006-01-11 05:19:21 +0100 (Wed, 11 Jan 2006) | 2 lines

fix locking error - lock instead of unlock

........
r7963 | mogorman | 2006-01-11 05:38:07 +0100 (Wed, 11 Jan 2006) | 2 lines

Minor typo refrenced in 6191

........
r7965 | russell | 2006-01-11 05:53:24 +0100 (Wed, 11 Jan 2006) | 2 lines

lock list of translators *before* recalculating the translation matrix

........
r7970 | russell | 2006-01-11 06:26:21 +0100 (Wed, 11 Jan 2006) | 3 lines

don't override an error condition that occurred when acting on the primary channel
when stopping the autoservice on the peer channel.  (from issue #6087)

........
r7972 | russell | 2006-01-11 06:46:39 +0100 (Wed, 11 Jan 2006) | 2 lines

fix mem leak on module unload (issue #6190)

........
r7976 | russell | 2006-01-11 08:18:16 +0100 (Wed, 11 Jan 2006) | 2 lines

fix temp greetings with ODBC storage (issue #6078)

........
r7986 | russell | 2006-01-11 20:08:53 +0100 (Wed, 11 Jan 2006) | 2 lines

move variable to correct scope (issue #6197)

........
r7999 | tilghman | 2006-01-12 07:14:22 +0100 (Thu, 12 Jan 2006) | 2 lines

Bug 6211 - Add option deletevoicemail as equivalent to option delete for Realtime

........
r8047 | russell | 2006-01-13 07:07:39 +0100 (Fri, 13 Jan 2006) | 2 lines

fix spelling errors (issue #6227)

........
r8074 | tilghman | 2006-01-14 20:06:44 +0100 (Sat, 14 Jan 2006) | 2 lines

Bug 6238 - Fix segfault when delimiter not specified

........

Modified:
    team/oej/managerstuff/   (props changed)
    team/oej/managerstuff/app.c
    team/oej/managerstuff/apps/app_dial.c
    team/oej/managerstuff/apps/app_voicemail.c
    team/oej/managerstuff/channel.c
    team/oej/managerstuff/channels/chan_agent.c
    team/oej/managerstuff/channels/chan_sip.c
    team/oej/managerstuff/configs/voicemail.conf.sample
    team/oej/managerstuff/doc/README.cdr
    team/oej/managerstuff/funcs/func_strings.c
    team/oej/managerstuff/pbx.c
    team/oej/managerstuff/translate.c

Propchange: team/oej/managerstuff/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Mon Jan 16 15:57:02 2006
@@ -1,1 +1,1 @@
-/branches/1.2:1-7496,7498-7935
+/branches/1.2:1-7496,7498-8109

Modified: team/oej/managerstuff/app.c
URL: http://svn.digium.com/view/asterisk/team/oej/managerstuff/app.c?rev=8110&r1=8109&r2=8110&view=diff
==============================================================================
--- team/oej/managerstuff/app.c (original)
+++ team/oej/managerstuff/app.c Mon Jan 16 15:57:02 2006
@@ -317,8 +317,12 @@
 				}
 			}
 		}
-		if (peer)
-			res = ast_autoservice_stop(peer);
+		if (peer) {
+			/* Stop autoservice on the peer channel, but don't overwrite any error condition 
+			   that has occurred previously while acting on the primary channel */	
+			if (ast_autoservice_stop(peer) && !res)
+				res = -1;
+		}
 	}
 	return res;
 }

Modified: team/oej/managerstuff/apps/app_dial.c
URL: http://svn.digium.com/view/asterisk/team/oej/managerstuff/apps/app_dial.c?rev=8110&r1=8109&r2=8110&view=diff
==============================================================================
--- team/oej/managerstuff/apps/app_dial.c (original)
+++ team/oej/managerstuff/apps/app_dial.c Mon Jan 16 15:57:02 2006
@@ -164,7 +164,7 @@
 "    S(x) - Hang up the call after 'x' seconds *after* the called party has\n"
 "           answered the call.\n"  	
 "    t    - Allow the called party to transfer the calling party by sending the\n"
-"           DTMF sequence defiend in features.conf.\n"
+"           DTMF sequence defined in features.conf.\n"
 "    T    - Allow the calling party to transfer the called party by sending the\n"
 "           DTMF sequence defined in features.conf.\n"
 "    w    - Allow the called party to enable recording of the call by sending\n"

Modified: team/oej/managerstuff/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/team/oej/managerstuff/apps/app_voicemail.c?rev=8110&r1=8109&r2=8110&view=diff
==============================================================================
--- team/oej/managerstuff/apps/app_voicemail.c (original)
+++ team/oej/managerstuff/apps/app_voicemail.c Mon Jan 16 15:57:02 2006
@@ -77,6 +77,8 @@
 #endif
 
 #define COMMAND_TIMEOUT 5000
+#define	VOICEMAIL_DIR_MODE	0770
+#define	VOICEMAIL_FILE_MODE	0660
 
 #define VOICEMAIL_CONFIG "voicemail.conf"
 #define ASTERISK_USERNAME "asterisk"
@@ -123,11 +125,14 @@
 	OPT_RECORDGAIN =       (1 << 3),
 	OPT_PREPEND_MAILBOX =  (1 << 4),
 	OPT_PRIORITY_JUMP =    (1 << 5),
+	OPT_AUTOPLAY =         (1 << 6),
 } vm_option_flags;
 
 enum {
 	OPT_ARG_RECORDGAIN = 0,
-	OPT_ARG_ARRAY_SIZE = 1,
+	OPT_ARG_PLAYFOLDER = 1,
+	/* This *must* be the last value in this enum! */
+	OPT_ARG_ARRAY_SIZE = 2,
 } vm_option_args;
 
 AST_APP_OPTIONS(vm_app_options, {
@@ -137,6 +142,7 @@
 	AST_APP_OPTION_ARG('g', OPT_RECORDGAIN, OPT_ARG_RECORDGAIN),
 	AST_APP_OPTION('p', OPT_PREPEND_MAILBOX),
 	AST_APP_OPTION('j', OPT_PRIORITY_JUMP),
+	AST_APP_OPTION_ARG('a', OPT_AUTOPLAY, OPT_ARG_PLAYFOLDER),
 });
 
 static int load_config(void);
@@ -335,7 +341,9 @@
 "           is entered by the caller.\n"
 "    g(#) - Use the specified amount of gain when recording a voicemail\n"
 "           message. The units are whole-number decibels (dB).\n"
-"    s    - Skip checking the passcode for the mailbox.\n";
+"    s    - Skip checking the passcode for the mailbox.\n"
+"    a(#) - Skip folder prompt and go directly to folder specified.\n"
+"           Defaults to INBOX\n";
 
 static char *synopsis_vm_box_exists =
 "Check to see if Voicemail mailbox exists";
@@ -447,7 +455,7 @@
 		ast_copy_string(vmu->language, value, sizeof(vmu->language));
 	} else if (!strcasecmp(var, "tz")) {
 		ast_copy_string(vmu->zonetag, value, sizeof(vmu->zonetag));
-	} else if (!strcasecmp(var, "delete")) {
+	} else if (!strcasecmp(var, "delete") || !strcasecmp(var, "deletevoicemail")) {
 		ast_set2_flag(vmu, ast_true(value), VM_DELETE);	
 	} else if (!strcasecmp(var, "saycid")){
 		ast_set2_flag(vmu, ast_true(value), VM_SAYCID);	
@@ -526,15 +534,11 @@
 	struct ast_variable *var, *tmp;
 	struct ast_vm_user *retval;
 
-	if (ivm)
-		retval=ivm;
-	else
-		retval=malloc(sizeof(struct ast_vm_user));
-
-	if (retval) {
-		memset(retval, 0, sizeof(struct ast_vm_user));
+	if ((retval = (ivm ? ivm : ast_calloc(1, sizeof(*retval))))) {
 		if (!ivm)
 			ast_set_flag(retval, VM_ALLOCED);	
+		else
+			memset(retval, 0, sizeof(*retval));
 		if (mailbox) 
 			ast_copy_string(retval->mailbox, mailbox, sizeof(retval->mailbox));
 		populate_defaults(retval);
@@ -589,13 +593,9 @@
 		cur=cur->next;
 	}
 	if (cur) {
-		if (ivm)
-			vmu = ivm;
-		else
-			/* Make a copy, so that on a reload, we have no race */
-			vmu = malloc(sizeof(struct ast_vm_user));
-		if (vmu) {
-			memcpy(vmu, cur, sizeof(struct ast_vm_user));
+		/* Make a copy, so that on a reload, we have no race */
+		if ((vmu = (ivm ? ivm : ast_malloc(sizeof(*vmu))))) {
+			memcpy(vmu, cur, sizeof(*vmu));
 			ast_set2_flag(vmu, !ivm, VM_ALLOCED);	
 			vmu->next = NULL;
 		}
@@ -778,6 +778,41 @@
 static int make_file(char *dest, int len, char *dir, int num)
 {
 	return snprintf(dest, len, "%s/msg%04d", dir, num);
+}
+
+/** basically mkdir -p $dest/$context/$ext/$mailbox
+ * @dest    String. base directory.
+ * @context String. Ignored if is null or empty string.
+ * @ext     String. Ignored if is null or empty string.
+ * @mailbox String. Ignored if is null or empty string. 
+ * @returns 0 on failure, 1 on success.
+ * */
+static int create_dirpath(char *dest, int len, char *context, char *ext, char *mailbox)
+{
+	mode_t	mode = VOICEMAIL_DIR_MODE;
+
+	if(context && context[0] != '\0') {
+		make_dir(dest, len, context, "", "");
+		if(mkdir(dest, mode) && errno != EEXIST) {
+			ast_log(LOG_WARNING, "mkdir '%s' failed: %s\n", dest, strerror(errno));
+			return 0;
+		}
+	}
+	if(ext && ext[0] != '\0') {
+		make_dir(dest, len, context, ext, "");
+		if(mkdir(dest, mode) && errno != EEXIST) {
+			ast_log(LOG_WARNING, "mkdir '%s' failed: %s\n", dest, strerror(errno));
+			return 0;
+		}
+	}
+	if(mailbox && mailbox[0] != '\0') {
+		make_dir(dest, len, context, ext, mailbox);
+		if(mkdir(dest, mode) && errno != EEXIST) {
+			ast_log(LOG_WARNING, "mkdir '%s' failed: %s\n", dest, strerror(errno));
+			return 0;
+		}
+	}
+	return 1;
 }
 
 /* only return failure if ast_lock_path returns 'timeout',
@@ -1385,7 +1420,7 @@
 			ast_log(LOG_WARNING, "Unable to open %s in read-only mode\n", infile);
 			return -1;
 		}
-		if ((ofd = open(outfile, O_WRONLY | O_TRUNC | O_CREAT, 0600)) < 0) {
+		if ((ofd = open(outfile, O_WRONLY | O_TRUNC | O_CREAT, VOICEMAIL_FILE_MODE)) < 0) {
 			ast_log(LOG_WARNING, "Unable to open %s in write-only mode\n", outfile);
 			close(ifd);
 			return -1;
@@ -1455,7 +1490,7 @@
 	int txtsize = 0;
 
 	txtsize = (strlen(file) + 5)*sizeof(char);
-	txt = (char *)alloca(txtsize);
+	txt = alloca(txtsize);
 	/* Sprintf here would safe because we alloca'd exactly the right length,
 	 * but trying to eliminate all sprintf's anyhow
 	 */
@@ -1682,8 +1717,8 @@
 		strftime(date, sizeof(date), emaildateformat, &tm);
 
 		if (*fromstring) {
-			struct ast_channel *ast = ast_channel_alloc(0);
-			if (ast) {
+			struct ast_channel *ast;
+			if ((ast = ast_channel_alloc(0))) {
 				char *passdata;
 				int vmlen = strlen(fromstring)*3 + 200;
 				if ((passdata = alloca(vmlen))) {
@@ -1699,8 +1734,8 @@
 		fprintf(p, "To: %s <%s>\n", vmu->fullname, vmu->email);
 
 		if (emailsubject) {
-			struct ast_channel *ast = ast_channel_alloc(0);
-			if (ast) {
+			struct ast_channel *ast;
+			if ((ast = ast_channel_alloc(0))) {
 				char *passdata;
 				int vmlen = strlen(emailsubject)*3 + 200;
 				if ((passdata = alloca(vmlen))) {
@@ -1731,8 +1766,8 @@
 		}
 		fprintf(p, "Content-Type: text/plain; charset=%s\nContent-Transfer-Encoding: 8bit\n\n", charset);
 		if (emailbody) {
-			struct ast_channel *ast = ast_channel_alloc(0);
-			if (ast) {
+			struct ast_channel *ast;
+			if ((ast = ast_channel_alloc(0))) {
 				char *passdata;
 				int vmlen = strlen(emailbody)*3 + 200;
 				if ((passdata = alloca(vmlen))) {
@@ -1800,8 +1835,8 @@
 		fprintf(p, "Date: %s\n", date);
 
 		if (*pagerfromstring) {
-			struct ast_channel *ast = ast_channel_alloc(0);
-			if (ast) {
+			struct ast_channel *ast;
+			if ((ast = ast_channel_alloc(0))) {
 				char *passdata;
 				int vmlen = strlen(fromstring)*3 + 200;
 				if ((passdata = alloca(vmlen))) {
@@ -1817,8 +1852,8 @@
 			fprintf(p, "From: Asterisk PBX <%s>\n", who);
 		fprintf(p, "To: %s\n", pager);
                if (pagersubject) {
-                       struct ast_channel *ast = ast_channel_alloc(0);
-                       if (ast) {
+                       struct ast_channel *ast;
+                       if ((ast = ast_channel_alloc(0))) {
                                char *passdata;
                                int vmlen = strlen(pagersubject)*3 + 200;
                                if ((passdata = alloca(vmlen))) {
@@ -1833,8 +1868,8 @@
                        fprintf(p, "Subject: New VM\n\n");
 		strftime(date, sizeof(date), "%A, %B %d, %Y at %r", &tm);
                if (pagerbody) {
-                       struct ast_channel *ast = ast_channel_alloc(0);
-                       if (ast) {
+                       struct ast_channel *ast;
+                       if ((ast = ast_channel_alloc(0))) {
                                char *passdata;
                                int vmlen = strlen(pagerbody)*3 + 200;
                                if ((passdata = alloca(vmlen))) {
@@ -2251,18 +2286,8 @@
 
 	ast_log(LOG_NOTICE, "Copying message from %s@%s to %s@%s\n", vmu->mailbox, vmu->context, recip->mailbox, recip->context);
 
-	make_dir(todir, sizeof(todir), recip->context, "", "");
-	/* It's easier just to try to make it than to check for its existence */
-	if (mkdir(todir, 0700) && (errno != EEXIST))
-		ast_log(LOG_WARNING, "mkdir '%s' failed: %s\n", todir, strerror(errno));
-	make_dir(todir, sizeof(todir), recip->context, recip->mailbox, "");
-	/* It's easier just to try to make it than to check for its existence */
-	if (mkdir(todir, 0700) && (errno != EEXIST))
-		ast_log(LOG_WARNING, "mkdir '%s' failed: %s\n", todir, strerror(errno));
-	make_dir(todir, sizeof(todir), recip->context, recip->mailbox, "INBOX");
-	if (mkdir(todir, 0700) && (errno != EEXIST))
-		ast_log(LOG_WARNING, "mkdir '%s' failed: %s\n", todir, strerror(errno));
-
+	create_dirpath(todir, sizeof(todir), recip->context, recip->mailbox, "INBOX");
+  
 	make_dir(fromdir, sizeof(fromdir), vmu->context, vmu->mailbox, frombox);
 	make_file(frompath, sizeof(frompath), fromdir, msgnum);
 
@@ -2378,17 +2403,8 @@
 	if (ast_fileexists(tempfile, NULL, NULL) > 0)
 		ast_copy_string(prefile, tempfile, sizeof(prefile));
 	DISPOSE(tempfile, -1);
-	make_dir(dir, sizeof(dir), vmu->context, "", "");
 	/* It's easier just to try to make it than to check for its existence */
-	if (mkdir(dir, 0700) && (errno != EEXIST))
-		ast_log(LOG_WARNING, "mkdir '%s' failed: %s\n", dir, strerror(errno));
-	make_dir(dir, sizeof(dir), vmu->context, ext, "");
-	/* It's easier just to try to make it than to check for its existence */
-	if (mkdir(dir, 0700) && (errno != EEXIST))
-		ast_log(LOG_WARNING, "mkdir '%s' failed: %s\n", dir, strerror(errno));
-	make_dir(dir, sizeof(dir), vmu->context, ext, "INBOX");
-	if (mkdir(dir, 0700) && (errno != EEXIST))
-		ast_log(LOG_WARNING, "mkdir '%s' failed: %s\n", dir, strerror(errno));
+	create_dirpath(dir, sizeof(dir), vmu->context, ext, "INBOX");
 
 	/* Check current or macro-calling context for special extensions */
 	if (!ast_strlen_zero(vmu->exit)) {
@@ -2589,8 +2605,8 @@
 				}
 			}
 			if (ast_fileexists(fn, NULL, NULL)) {
+				STORE(dir, vmu->mailbox, vmu->context, msgnum);
 				notify_new_message(chan, vmu, msgnum, duration, fmt, chan->cid.cid_num, chan->cid.cid_name);
-				STORE(dir, vmu->mailbox, vmu->context, msgnum);
 				DISPOSE(dir, msgnum);
 			}
 			pbx_builtin_setvar_helper(chan, "VMSTATUS", "SUCCESS");
@@ -2653,9 +2669,8 @@
 	char ddir[256];
 	char *dbox = mbox(box);
 	int x;
-	make_file(sfn, sizeof(sfn), dir, msg);
-	make_dir(ddir, sizeof(ddir), context, username, dbox);
-	mkdir(ddir, 0700);
+ 	make_file(sfn, sizeof(sfn), dir, msg);
+	create_dirpath(ddir, sizeof(ddir), context, username, dbox);
 
 	if (vm_lock_path(ddir))
 		return ERROR_LOCK_PATH;
@@ -3414,7 +3429,7 @@
 		/* start optimistic */
 		valid_extensions = 1;
 		while (s) {
-			/* find_user is going to malloc since we have a NULL as first argument */
+			/* find_user is going to ast_malloc since we have a NULL as first argument */
 			if ((receiver = find_user(NULL, context, s))) {
 				if (!extensions)
 					vmtmp = extensions = receiver;
@@ -4742,6 +4757,7 @@
 	while (cmd >= 0 && cmd != 't') {
 		if (cmd)
 			retries = 0;
+		RETRIEVE(prefile, -1);
 		if (ast_fileexists(prefile, NULL, NULL) <= 0) {
 			play_record_review(chan, "vm-rec-temp", prefile, maxgreet, fmtc, 0, vmu, &duration, NULL, record_gain);
 			cmd = 't';	
@@ -4751,7 +4767,7 @@
 				cmd = play_record_review(chan, "vm-rec-temp", prefile, maxgreet, fmtc, 0, vmu, &duration, NULL, record_gain);
 				break;
 			case '2':
-				ast_filedelete(prefile, NULL);
+				DELETE(prefile, -1, prefile);
 				ast_play_and_wait(chan, "vm-tempremoved");
 				cmd = 't';	
 				break;
@@ -4770,6 +4786,7 @@
 					cmd = 't';
 			}
 		}
+		DISPOSE(prefile, -1);
 	}
 	if (cmd == 't')
 		cmd = 0;
@@ -5019,6 +5036,8 @@
 	int silentexit = 0;
 	struct ast_flags flags = { 0 };
 	signed char record_gain = 0;
+	int play_auto = 0;
+	int play_folder = 0;
 
 	LOCAL_USER_ADD(u);
 
@@ -5031,53 +5050,78 @@
 		ast_answer(chan);
 
 	if (!ast_strlen_zero(data)) {
-		char *tmp;
-		int argc;
-		char *argv[2];
 		char *opts[OPT_ARG_ARRAY_SIZE];
-
-		tmp = ast_strdupa(data);
-		argc = ast_app_separate_args(tmp, '|', argv, sizeof(argv) / sizeof(argv[0]));
-		if (argc == 2) {
-			if (ast_app_parse_options(vm_app_options, &flags, opts, argv[1])) {
+		char *parse;    
+		AST_DECLARE_APP_ARGS(args,
+			AST_APP_ARG(argv0);
+			AST_APP_ARG(argv1);
+		);
+				        
+		parse = ast_strdupa(data);
+		if (!parse) {
+			ast_log(LOG_ERROR, "Out of memory!\n");
+			LOCAL_USER_REMOVE(u);
+			return -1;
+		}
+
+		AST_STANDARD_APP_ARGS(args, parse);
+
+		if (args.argc == 2) {
+			if (ast_app_parse_options(vm_app_options, &flags, opts, args.argv1)) {
 				LOCAL_USER_REMOVE(u);
 				return -1;
 			}
 			if (ast_test_flag(&flags, OPT_RECORDGAIN)) {
 				int gain;
-
-				if (sscanf(opts[OPT_ARG_RECORDGAIN], "%d", &gain) != 1) {
-					ast_log(LOG_WARNING, "Invalid value '%s' provided for record gain option\n", opts[OPT_ARG_RECORDGAIN]);
-					LOCAL_USER_REMOVE(u);
-					return -1;
+				if(opts[OPT_ARG_RECORDGAIN]) {
+					if (sscanf(opts[OPT_ARG_RECORDGAIN], "%d", &gain) != 1) {
+						ast_log(LOG_WARNING, "Invalid value '%s' provided for record gain option\n", opts[OPT_ARG_RECORDGAIN]);
+						LOCAL_USER_REMOVE(u);
+						return -1;
+					} else {
+						record_gain = (signed char) gain;
+					}
 				} else {
-					record_gain = (signed char) gain;
+					ast_log(LOG_WARNING, "Invalid Gain level set with option g\n");
+				}
+			}
+			if (ast_test_flag(&flags, OPT_AUTOPLAY) ) {
+				play_auto = 1;
+				if(opts[OPT_ARG_PLAYFOLDER]) {
+					if (sscanf(opts[OPT_ARG_PLAYFOLDER], "%d", &play_folder) != 1) {
+						ast_log(LOG_WARNING, "Invalid value '%s' provided for folder autoplay option\n", opts[OPT_ARG_PLAYFOLDER]);
+					}
+				} else {
+					ast_log(LOG_WARNING, "Invalid folder set with option a\n");
+				}	
+				if ( play_folder > 9 || play_folder < 0) {
+					ast_log(LOG_WARNING, "Invalid value '%d' provided for folder autoplay option\n", play_folder);
+					play_folder = 0;
 				}
 			}
 		} else {
 			/* old style options parsing */
-			while (*argv[0]) {
-				if (*argv[0] == 's') {
+			while (*(args.argv0)) {
+				if (*(args.argv0) == 's')
 					ast_set_flag(&flags, OPT_SILENT);
-					argv[0]++;
-				} else if (*argv[0] == 'p') {
+				else if (*(args.argv0) == 'p')
 					ast_set_flag(&flags, OPT_PREPEND_MAILBOX);
-					argv[0]++;
-				} else 
+				else 
 					break;
+				(args.argv0)++;
 			}
 
 		}
 
 		valid = ast_test_flag(&flags, OPT_SILENT);
 
-		if ((context = strchr(argv[0], '@')))
+		if ((context = strchr(args.argv0, '@')))
 			*context++ = '\0';
 
 		if (ast_test_flag(&flags, OPT_PREPEND_MAILBOX))
-			ast_copy_string(prefixstr, argv[0], sizeof(prefixstr));
+			ast_copy_string(prefixstr, args.argv0, sizeof(prefixstr));
 		else
-			ast_copy_string(vms.username, argv[0], sizeof(vms.username));
+			ast_copy_string(vms.username, args.argv0, sizeof(vms.username));
 
 		if (!ast_strlen_zero(vms.username) && (vmu = find_user(&vmus, context ,vms.username)))
 			skipuser++;
@@ -5102,16 +5146,17 @@
 	if (!valid)
 		goto out;
 
-	vms.deleted = calloc(vmu->maxmsg, sizeof(int));
-	vms.heard = calloc(vmu->maxmsg, sizeof(int));
+	if (!(vms.deleted = ast_calloc(vmu->maxmsg, sizeof(int)))) {
+		/* TODO: Handle memory allocation failure */
+	}
+	if (!(vms.heard = ast_calloc(vmu->maxmsg, sizeof(int)))) {
+		/* TODO: Handle memory allocation failure */
+	}
 	
 	/* Set language from config to override channel language */
 	if (!ast_strlen_zero(vmu->language))
 		ast_copy_string(chan->language, vmu->language, sizeof(chan->language));
-	snprintf(vms.curdir, sizeof(vms.curdir), "%s/%s", VM_SPOOL_DIR, vmu->context);
-	mkdir(vms.curdir, 0700);
-	snprintf(vms.curdir, sizeof(vms.curdir), "%s/%s/%s", VM_SPOOL_DIR, vmu->context, vms.username);
-	mkdir(vms.curdir, 0700);
+	create_dirpath(vms.curdir, sizeof(vms.curdir), vmu->context, vms.username, "");
 	/* Retrieve old and new message counts */
 	res = open_mailbox(&vms, vmu, 1);
 	if (res == ERROR_LOCK_PATH)
@@ -5124,11 +5169,24 @@
 	vms.newmessages = vms.lastmsg + 1;
 		
 	/* Select proper mailbox FIRST!! */
-	if (!vms.newmessages && vms.oldmessages) {
-		/* If we only have old messages start here */
-		res = open_mailbox(&vms, vmu, 1);
+	if (play_auto) {
+		res = open_mailbox(&vms, vmu, play_folder);
 		if (res == ERROR_LOCK_PATH)
 			goto out;
+
+		/* If there are no new messages, inform the user and hangup */
+		if (vms.lastmsg == -1) {
+			cmd = vm_browse_messages(chan, &vms, vmu);
+			res = 0;
+			goto out;
+		}
+	} else {
+		if (!vms.newmessages && vms.oldmessages) {
+			/* If we only have old messages start here */
+			res = open_mailbox(&vms, vmu, 1);
+			if (res == ERROR_LOCK_PATH)
+				goto out;
+		}
 	}
 
 	if (useadsi)
@@ -5152,7 +5210,11 @@
 		}
 	}
 
-	cmd = vm_intro(chan, &vms);
+	if (play_auto) {
+		cmd = '1';
+	} else {
+		cmd = vm_intro(chan, &vms);
+	}
 
 	vms.repeats = 0;
 	vms.starting = 1;
@@ -5450,11 +5512,13 @@
 	struct localuser *u;
 	char tmp[256];
 	struct leave_vm_options leave_options;
-	int argc;
-	char *argv[2];
 	struct ast_flags flags = { 0 };
 	char *opts[OPT_ARG_ARRAY_SIZE];
-	
+	AST_DECLARE_APP_ARGS(args,
+		AST_APP_ARG(argv0);
+		AST_APP_ARG(argv1);
+	);
+
 	LOCAL_USER_ADD(u);
 	
 	memset(&leave_options, 0, sizeof(leave_options));
@@ -5464,9 +5528,9 @@
 
 	if (!ast_strlen_zero(data)) {
 		ast_copy_string(tmp, data, sizeof(tmp));
-		argc = ast_app_separate_args(tmp, '|', argv, sizeof(argv) / sizeof(argv[0]));
-		if (argc == 2) {
-			if (ast_app_parse_options(vm_app_options, &flags, opts, argv[1])) {
+		AST_STANDARD_APP_ARGS(args, tmp);
+		if (args.argc == 2) {
+			if (ast_app_parse_options(vm_app_options, &flags, opts, args.argv1)) {
 				LOCAL_USER_REMOVE(u);
 				return -1;
 			}
@@ -5484,21 +5548,18 @@
 			}
 		} else {
 			/* old style options parsing */
-			while (*argv[0]) {
-				if (*argv[0] == 's') {
+			while (*(args.argv0)) {
+				if (*(args.argv0) == 's')
 					ast_set_flag(&leave_options, OPT_SILENT);
-					argv[0]++;
-				} else if (*argv[0] == 'b') {
+				else if (*(args.argv0) == 'b')
 					ast_set_flag(&leave_options, OPT_BUSY_GREETING);
-					argv[0]++;
-				} else if (*argv[0] == 'u') {
+				else if (*(args.argv0) == 'u')
 					ast_set_flag(&leave_options, OPT_UNAVAIL_GREETING);
-					argv[0]++;
-				} else if (*argv[0] == 'j') {
+				else if (*(args.argv0) == 'j')
 					ast_set_flag(&leave_options, OPT_PRIORITY_JUMP);
-					argv[0]++;
-				} else 
+				else 
 					break;
+				(args.argv0)++;
 			}
 		}
 	} else {
@@ -5511,10 +5572,10 @@
 			LOCAL_USER_REMOVE(u);
 			return 0;
 		}
-		argv[0] = ast_strdupa(tmp);
-	}
-
-	res = leave_voicemail(chan, argv[0], &leave_options);
+		args.argv0 = ast_strdupa(tmp);
+	}
+
+	res = leave_voicemail(chan, args.argv0, &leave_options);
 
 	if (res == ERROR_LOCK_PATH) {
 		ast_log(LOG_ERROR, "Could not leave voicemail. The path is already locked.\n");
@@ -5540,9 +5601,7 @@
 	struct ast_vm_user *vmu;
 
 	ast_copy_string(tmp, data, sizeof(tmp));
-	vmu = malloc(sizeof(struct ast_vm_user));
-	if (vmu) {
-		memset(vmu, 0, sizeof(struct ast_vm_user));
+	if ((vmu = ast_calloc(1, sizeof(*vmu)))) {
 		ast_copy_string(vmu->context, context, sizeof(vmu->context));
 		ast_copy_string(vmu->mailbox, mbox, sizeof(vmu->mailbox));
 
@@ -5621,10 +5680,10 @@
 static int vmauthenticate(struct ast_channel *chan, void *data)
 {
 	struct localuser *u;
-	char *s = data, *user=NULL, *context=NULL, mailbox[AST_MAX_EXTENSION];
+	char *s = data, *user=NULL, *context=NULL, mailbox[AST_MAX_EXTENSION] = "";
 	struct ast_vm_user vmus;
 	char *options = NULL;
-	int silent = 0;
+	int silent = 0, skipuser = 0;
 	int res = -1;
 
 	LOCAL_USER_ADD(u);
@@ -5641,6 +5700,9 @@
 			s = user;
 			user = strsep(&s, "@");
 			context = strsep(&s, "");
+			if (!ast_strlen_zero(user))
+				skipuser++;
+			ast_copy_string(mailbox, user, sizeof(mailbox));
 		}
 	}
 
@@ -5648,9 +5710,10 @@
 		silent = (strchr(options, 's')) != NULL;
 	}
 
-	if (!vm_authenticate(chan, mailbox, sizeof(mailbox), &vmus, context, NULL, 0, 3, silent)) {
+	if (!vm_authenticate(chan, mailbox, sizeof(mailbox), &vmus, context, NULL, skipuser, 3, silent)) {
 		pbx_builtin_setvar_helper(chan, "AUTH_MAILBOX", mailbox);
 		pbx_builtin_setvar_helper(chan, "AUTH_CONTEXT", vmus.context);
+		ast_play_and_wait(chan, "auth-thankyou");
 		res = 0;
 	}
 
@@ -6074,8 +6137,7 @@
 					/* Timezones in this context */
 					while (var) {
 						struct vm_zone *z;
-						z = malloc(sizeof(struct vm_zone));
-						if (z != NULL) {
+						if ((z = ast_malloc(sizeof(*z)))) {
 							char *msg_format, *timezone;
 							msg_format = ast_strdupa(var->value);
 							if (msg_format != NULL) {
@@ -6101,8 +6163,7 @@
 								free(z);
 								return -1;
 							}
-						} else {
-							ast_log(LOG_WARNING, "Out of memory while reading voicemail config\n");
+						} else {						
 							return -1;
 						}
 						var = var->next;

Modified: team/oej/managerstuff/channel.c
URL: http://svn.digium.com/view/asterisk/team/oej/managerstuff/channel.c?rev=8110&r1=8109&r2=8110&view=diff
==============================================================================
--- team/oej/managerstuff/channel.c (original)
+++ team/oej/managerstuff/channel.c Mon Jan 16 15:57:02 2006
@@ -567,7 +567,7 @@
 	tmp->fds[AST_MAX_FDS-1] = tmp->alertpipe[0];
 	/* And timing pipe */
 	tmp->fds[AST_MAX_FDS-2] = tmp->timingfd;
-	strcpy(tmp->name, "**Unkown**");
+	strcpy(tmp->name, "**Unknown**");
 	/* Initial state */
 	tmp->_state = AST_STATE_DOWN;
 	tmp->streamid = -1;

Modified: team/oej/managerstuff/channels/chan_agent.c
URL: http://svn.digium.com/view/asterisk/team/oej/managerstuff/channels/chan_agent.c?rev=8110&r1=8109&r2=8110&view=diff
==============================================================================
--- team/oej/managerstuff/channels/chan_agent.c (original)
+++ team/oej/managerstuff/channels/chan_agent.c Mon Jan 16 15:57:02 2006
@@ -105,7 +105,7 @@
 static const char descrip3[] =
 "  AgentMonitorOutgoing([options]):\n"
 "Tries to figure out the id of the agent who is placing outgoing call based on\n"
-"comparision of the callerid of the current interface and the global variable \n"
+"comparison of the callerid of the current interface and the global variable \n"
 "placed by the AgentCallbackLogin application. That's why it should be used only\n"
 "with the AgentCallbackLogin app. Uses the monitoring functions in chan_agent \n"
 "instead of Monitor application. That have to be configured in the agents.conf file.\n"
@@ -147,7 +147,7 @@
 
 /** Persistent Agents astdb family */
 static const char pa_family[] = "/Agents";
-/** The maximum lengh of each persistent member agent database entry */
+/** The maximum length of each persistent member agent database entry */
 #define PA_MAX_LEN 2048
 /** queues.conf [general] option */
 static int persistent_agents = 0;
@@ -1054,7 +1054,7 @@
 	urlprefix[0] = '\0';
 	savecallsin[0] = '\0';
 
-	/* Read in [general] section for persistance */
+	/* Read in [general] section for persistence */
 	if ((general_val = ast_variable_retrieve(cfg, "general", "persistentagents")))
 		persistent_agents = ast_true(general_val);
 
@@ -1698,6 +1698,7 @@
 	char agent_goodbye[AST_MAX_FILENAME_LEN];
 	int update_cdr = updatecdr;
 	char *filename = "agent-loginok";
+	char tmpchan[AST_MAX_BUF] = "";
 
 	LOCAL_USER_ADD(u);
 
@@ -1793,7 +1794,7 @@
 				gettimeofday(&p->lastdisc, NULL);
 				p->lastdisc.tv_sec++;
 
-				/* Set Channel Specific Agent Overides */
+				/* Set Channel Specific Agent Overrides */
 				if (pbx_builtin_getvar_helper(chan, "AGENTACKCALL") && strlen(pbx_builtin_getvar_helper(chan, "AGENTACKCALL"))) {
 					if (!strcasecmp(pbx_builtin_getvar_helper(chan, "AGENTACKCALL"), "always"))
 						p->ackcall = 2;
@@ -1821,14 +1822,13 @@
 					if (option_verbose > 2)
 						ast_verbose(VERBOSE_PREFIX_3 "Saw variable AGENTWRAPUPTIME=%s, setting wrapuptime to: %d for Agent '%s'.\n",tmpoptions,p->wrapuptime,p->agent);
 				}
-				/* End Channel Specific Agent Overides */
+				/* End Channel Specific Agent Overrides */
 				if (!p->chan) {
 					char last_loginchan[80] = "";
 					long logintime;
 					snprintf(agent, sizeof(agent), "Agent/%s", p->agent);
 
 					if (callbackmode) {
-						char tmpchan[AST_MAX_BUF] = "";
 						int pos = 0;
 						/* Retrieve login chan */
 						for (;;) {
@@ -2364,7 +2364,7 @@
 	}
 	ast_mutex_unlock(&agentlock);
 	if (db_tree) {
-		ast_log(LOG_NOTICE, "Agents sucessfully reloaded from database.\n");
+		ast_log(LOG_NOTICE, "Agents successfully reloaded from database.\n");
 		ast_db_freetree(db_tree);
 	}
 }
@@ -2505,7 +2505,7 @@
 
 /**
  * Initialize the Agents module.
- * This funcion is being called by Asterisk when loading the module. Among other thing it registers applications, cli commands and reads the cofiguration file.
+ * This function is being called by Asterisk when loading the module. Among other thing it registers applications, cli commands and reads the cofiguration file.
  *
  * @returns int Always 0.
  */

Modified: team/oej/managerstuff/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/oej/managerstuff/channels/chan_sip.c?rev=8110&r1=8109&r2=8110&view=diff
==============================================================================
--- team/oej/managerstuff/channels/chan_sip.c (original)
+++ team/oej/managerstuff/channels/chan_sip.c Mon Jan 16 15:57:02 2006
@@ -13260,7 +13260,6 @@
 				ast_softhangup(p->owner, AST_SOFTHANGUP_APPUNLOAD);
 			p = p->next;
 		}
-		iflist = NULL;
 		ast_mutex_unlock(&iflock);
 	} else {
 		ast_log(LOG_WARNING, "Unable to lock the interface list\n");

Modified: team/oej/managerstuff/configs/voicemail.conf.sample
URL: http://svn.digium.com/view/asterisk/team/oej/managerstuff/configs/voicemail.conf.sample?rev=8110&r1=8109&r2=8110&view=diff
==============================================================================
--- team/oej/managerstuff/configs/voicemail.conf.sample (original)
+++ team/oej/managerstuff/configs/voicemail.conf.sample Mon Jan 16 15:57:02 2006
@@ -172,6 +172,7 @@
 			;     This does NOT affect option 3,3 from the advanced options menu
 ; delete=yes		; After notification, the voicemail is deleted from the server. [per-mailbox only]
 			;     This is intended for use with users who wish to receive their voicemail ONLY by email.
+			;     Note:  deletevoicemail is provided as an equivalent option for Realtime configuration.
 ; nextaftercmd=yes	; Skips to the next message after hitting 7 or 9 to delete/save current message.
 			;     [global option only at this time] 
 ; forcename=yes		; Forces a new user to record their name.  A new user is

Modified: team/oej/managerstuff/doc/README.cdr
URL: http://svn.digium.com/view/asterisk/team/oej/managerstuff/doc/README.cdr?rev=8110&r1=8109&r2=8110&view=diff
==============================================================================
--- team/oej/managerstuff/doc/README.cdr (original)
+++ team/oej/managerstuff/doc/README.cdr Mon Jan 16 15:57:02 2006
@@ -11,6 +11,8 @@
      for an updated list of supported databases, from MySQL to MsSQL
      and text files.
    * cdr_tds supports FreeTDS databases (Among them MS SQL)
+	NOTE: Please read README.tds for information on possible
+	problems with the FreeTDS driver
    * cdr_sqlite supports SQlite
    * cdr_pgsql supports PostgreSQL
 
@@ -37,28 +39,28 @@
 Fields of the CDR in Asterisk
 -----------------------------
 
-   1. accountcode: What account number to use, (string, 20 characters)
-   2. src: Caller*ID number (string, 80 characters)
-   3. dst: Destination extension (string, 80 characters)
-   4. dcontext: Destination context (string, 80 characters)
-   5. clid: Caller*ID with text (80 characters)
-   6. channel: Channel used (80 characters)
-   7. dstchannel: Destination channel if appropriate (80 characters)
-   8. lastapp: Last application if appropriate (80 characters)
-   9. lastdata: Last application data (arguments) (80 characters)
-  10. start: Start of call (date/time)
-  11. answer: Answer of call (date/time)
-  12. end: End of call (date/time)
-  13. duration: Total time in system, in seconds (integer), from dial to hangup
-  14. billsec: Total time call is up, in seconds (integer), from answer to hangup
-  15. disposition: What happened to the call: ANSWERED, NO ANSWER, BUSY
-  16. amaflags: What flags to use: DOCUMENTATION, BILL, IGNORE etc, 
-      specified on a per channel basis like accountcode.
-  17. user field: A user-defined field, maximum 255 characters 
+   1. accountcode:	What account number to use, (string, 20 characters)
+   2. src:		Caller*ID number (string, 80 characters)
+   3. dst:		Destination extension (string, 80 characters)
+   4. dcontext:		Destination context (string, 80 characters)
+   5. clid:		Caller*ID with text (80 characters)
+   6. channel:		Channel used (80 characters)
+   7. dstchannel:	Destination channel if appropriate (80 characters)
+   8. lastapp:		Last application if appropriate (80 characters)
+   9. lastdata:		Last application data (arguments) (80 characters)
+  10. start:		Start of call (date/time)
+  11. answer:		Answer of call (date/time)
+  12. end:		End of call (date/time)
+  13. duration:		Total time in system, in seconds (integer), from dial to hangup
+  14. billsec:		Total time call is up, in seconds (integer), from answer to hangup
+  15. disposition:	What happened to the call: ANSWERED, NO ANSWER, BUSY
+  16. amaflags:		What flags to use: DOCUMENTATION, BILL, IGNORE etc, 
+      			specified on a per channel basis like accountcode.
+  17. user field:	A user-defined field, maximum 255 characters 
 
 In some cases, uniqueid is appended:
 
-    * uniqueid: Unique Channel Identifier (32 characters) 
+    * uniqueid:		Unique Channel Identifier (32 characters) 
       This needs to be enabled in the source code at compile time
 
 

Modified: team/oej/managerstuff/funcs/func_strings.c
URL: http://svn.digium.com/view/asterisk/team/oej/managerstuff/funcs/func_strings.c?rev=8110&r1=8109&r2=8110&view=diff
==============================================================================
--- team/oej/managerstuff/funcs/func_strings.c (original)
+++ team/oej/managerstuff/funcs/func_strings.c Mon Jan 16 15:57:02 2006
@@ -50,8 +50,12 @@
 	if (delim) {
 		varname = strsep(&delim, "|");
 		pbx_retrieve_variable(chan, varname, &varval, workspace, sizeof(workspace), NULL);
-		while (strsep(&varval, delim))
-			fieldcount++;
+		if (delim) {
+			while (strsep(&varval, delim))
+				fieldcount++;
+		} else if (!ast_strlen_zero(varval)) {
+			fieldcount = 1;
+		}
 		snprintf(buf, len, "%d", fieldcount);
 	} else {
 		ast_log(LOG_ERROR, "Out of memory\n");

Modified: team/oej/managerstuff/pbx.c
URL: http://svn.digium.com/view/asterisk/team/oej/managerstuff/pbx.c?rev=8110&r1=8109&r2=8110&view=diff
==============================================================================
--- team/oej/managerstuff/pbx.c (original)
+++ team/oej/managerstuff/pbx.c Mon Jan 16 15:57:02 2006
@@ -2008,7 +2008,7 @@
 	    		cbprev = cblist;
 		}
 
-		ast_mutex_lock(&hintlock);
+		ast_mutex_unlock(&hintlock);
 		return -1;
 	}
 

Modified: team/oej/managerstuff/translate.c
URL: http://svn.digium.com/view/asterisk/team/oej/managerstuff/translate.c?rev=8110&r1=8109&r2=8110&view=diff
==============================================================================
--- team/oej/managerstuff/translate.c (original)
+++ team/oej/managerstuff/translate.c Mon Jan 16 15:57:02 2006
@@ -332,6 +332,7 @@
 	if (argc > 4) 
 		return RESULT_SHOWUSAGE;
 
+	ast_mutex_lock(&list_lock);
 	if (argv[2] && !strcasecmp(argv[2],"recalc")) {
 		z = argv[3] ? atoi(argv[3]) : 1;
 
@@ -350,7 +351,6 @@
 
 	ast_cli(fd, "         Translation times between formats (in milliseconds)\n");
 	ast_cli(fd, "          Source Format (Rows) Destination Format(Columns)\n\n");
-	ast_mutex_lock(&list_lock);
 	for (x = -1; x < SHOW_TRANS; x++) {
 		/* next 2 lines run faster than using strcpy() */
 		line[0] = ' ';



More information about the svn-commits mailing list