[asterisk-commits] tilghman: trunk r234820 - in /trunk: ./ apps/ configs/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Dec 14 17:16:03 CST 2009


Author: tilghman
Date: Mon Dec 14 17:16:00 2009
New Revision: 234820

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=234820
Log:
Allow greetings-only mailboxes for Voicemail.
(closes issue #15132)
 Reported by: floletarmo
 Patches: 
       voicemail_changes.patch uploaded by floletarmo (license 784)
       (with some additional changes by me)

Modified:
    trunk/CHANGES
    trunk/apps/app_voicemail.c
    trunk/configs/voicemail.conf.sample

Modified: trunk/CHANGES
URL: http://svnview.digium.com/svn/asterisk/trunk/CHANGES?view=diff&rev=234820&r1=234819&r2=234820
==============================================================================
--- trunk/CHANGES (original)
+++ trunk/CHANGES Mon Dec 14 17:16:00 2009
@@ -88,6 +88,8 @@
    exit the application.
  * The Voicemail application has been improved to automatically ignore messages
    that only contain silence.
+ * If you set maxmsg to 0 in voicemail.conf, Voicemail will consider the
+   associated mailbox(es) to be greetings-only.
  * The ChanSpy application now has the 'S' option, which makes the application
    automatically exit once it hits a point where no more channels are available
    to spy on.

Modified: trunk/apps/app_voicemail.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/app_voicemail.c?view=diff&rev=234820&r1=234819&r2=234820
==============================================================================
--- trunk/apps/app_voicemail.c (original)
+++ trunk/apps/app_voicemail.c Mon Dec 14 17:16:00 2009
@@ -997,7 +997,8 @@
 			ast_log(AST_LOG_WARNING, "Option 'maxmessage' has been deprecated in favor of 'maxsecs'.  Please make that change in your voicemail config.\n");
 	} else if (!strcasecmp(var, "maxmsg")) {
 		vmu->maxmsg = atoi(value);
-		if (vmu->maxmsg <= 0) {
+		/* Accept maxmsg=0 (Greetings only voicemail) */
+		if (vmu->maxmsg < 0) {
 			ast_log(AST_LOG_WARNING, "Invalid number of messages per folder maxmsg=%s. Using default value %d\n", value, MAXMSG);
 			vmu->maxmsg = MAXMSG;
 		} else if (vmu->maxmsg > MAXMSGLIMIT) {
@@ -5393,6 +5394,13 @@
 		ast_set_flag(options, OPT_SILENT);
 		res = 0;
 	}
+	/* If maxmsg is zero, act as a "greetings only" voicemail: Exit successfully without recording */
+	if (vmu->maxmsg == 0) {
+		if (option_debug > 2)
+			ast_log(LOG_DEBUG, "Greetings only VM (maxmsg=0), Skipping voicemail recording\n");
+		pbx_builtin_setvar_helper(chan, "VMSTATUS", "SUCCESS");
+		goto leave_vm_out;
+	}
 	if (!res && !ast_test_flag(options, OPT_SILENT)) {
 		res = ast_stream_and_wait(chan, INTRO, ecodes);
 		if (res == '#') {
@@ -7403,10 +7411,12 @@
 #endif
 
 done:
-	if (vms->deleted)
+	if (vms->deleted && vmu->maxmsg) {
 		memset(vms->deleted, 0, vmu->maxmsg * sizeof(int)); 
-	if (vms->heard)
+	}
+	if (vms->heard && vmu->maxmsg) {
 		memset(vms->heard, 0, vmu->maxmsg * sizeof(int)); 
+	}
 
 	return 0;
 }
@@ -9278,12 +9288,13 @@
 	vmstate_insert(&vms);
 	init_vm_state(&vms);
 #endif
-	if (!(vms.deleted = ast_calloc(vmu->maxmsg, sizeof(int)))) {
+	/* Avoid allocating a buffer of 0 bytes, because some platforms really don't like that. */
+	if (!(vms.deleted = ast_calloc(vmu->maxmsg ? vmu->maxmsg : 1, sizeof(int)))) {
 		ast_log(AST_LOG_ERROR, "Could not allocate memory for deleted message storage!\n");
 		cmd = ast_play_and_wait(chan, "an-error-has-occured");
 		return -1;
 	}
-	if (!(vms.heard = ast_calloc(vmu->maxmsg, sizeof(int)))) {
+	if (!(vms.heard = ast_calloc(vmu->maxmsg ? vmu->maxmsg : 1, sizeof(int)))) {
 		ast_log(AST_LOG_ERROR, "Could not allocate memory for heard message storage!\n");
 		cmd = ast_play_and_wait(chan, "an-error-has-occured");
 		return -1;
@@ -10759,7 +10770,7 @@
 			maxmsg = MAXMSG;
 		} else {
 			maxmsg = atoi(val);
-			if (maxmsg <= 0) {
+			if (maxmsg < 0) {
 				ast_log(AST_LOG_WARNING, "Invalid number of messages per folder '%s'. Using default value %i\n", val, MAXMSG);
 				maxmsg = MAXMSG;
 			} else if (maxmsg > MAXMSGLIMIT) {

Modified: trunk/configs/voicemail.conf.sample
URL: http://svnview.digium.com/svn/asterisk/trunk/configs/voicemail.conf.sample?view=diff&rev=234820&r1=234819&r2=234820
==============================================================================
--- trunk/configs/voicemail.conf.sample (original)
+++ trunk/configs/voicemail.conf.sample Mon Dec 14 17:16:00 2009
@@ -34,7 +34,8 @@
 ; Should the email contain the voicemail as an attachment
 attach=yes
 ; Maximum number of messages per folder.  If not specified, a default value
-; (100) is used.  Maximum value for this option is 9999.
+; (100) is used.  Maximum value for this option is 9999.  If set to 0, a
+; mailbox will be greetings-only.
 ;maxmsg=100
 ; Maximum length of a voicemail message in seconds
 ;maxsecs=180




More information about the asterisk-commits mailing list