[asterisk-commits] tilghman: trunk r97305 - /trunk/apps/app_voicemail.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Jan 8 17:51:51 CST 2008
Author: tilghman
Date: Tue Jan 8 17:51:51 2008
New Revision: 97305
URL: http://svn.digium.com/view/asterisk?view=rev&rev=97305
Log:
Add a new flag 'd' (with optional context) permitting any extension within
that context to be entered as a new extension during the playback of a
voicemail greeting.
Patch inspired by bluecrow76, by tilghman.
(Closes issue #7063)
Modified:
trunk/apps/app_voicemail.c
Modified: trunk/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_voicemail.c?view=diff&rev=97305&r1=97304&r2=97305
==============================================================================
--- trunk/apps/app_voicemail.c (original)
+++ trunk/apps/app_voicemail.c Tue Jan 8 17:51:51 2008
@@ -240,13 +240,15 @@
OPT_RECORDGAIN = (1 << 3),
OPT_PREPEND_MAILBOX = (1 << 4),
OPT_AUTOPLAY = (1 << 6),
+ OPT_DTMFEXIT = (1 << 7),
} vm_option_flags;
enum {
OPT_ARG_RECORDGAIN = 0,
OPT_ARG_PLAYFOLDER = 1,
+ OPT_ARG_DTMFEXIT = 2,
/* This *must* be the last value in this enum! */
- OPT_ARG_ARRAY_SIZE = 2,
+ OPT_ARG_ARRAY_SIZE = 3,
} vm_option_args;
AST_APP_OPTIONS(vm_app_options, {
@@ -254,6 +256,7 @@
AST_APP_OPTION('b', OPT_BUSY_GREETING),
AST_APP_OPTION('u', OPT_UNAVAIL_GREETING),
AST_APP_OPTION_ARG('g', OPT_RECORDGAIN, OPT_ARG_RECORDGAIN),
+ AST_APP_OPTION_ARG('d', OPT_DTMFEXIT, OPT_ARG_DTMFEXIT),
AST_APP_OPTION('p', OPT_PREPEND_MAILBOX),
AST_APP_OPTION_ARG('a', OPT_AUTOPLAY, OPT_ARG_PLAYFOLDER),
});
@@ -496,12 +499,14 @@
" application. The possible values are:\n"
" SUCCESS | USEREXIT | FAILED\n\n"
" Options:\n"
- " b - Play the 'busy' greeting to the calling party.\n"
- " g(#) - Use the specified amount of gain when recording the voicemail\n"
- " message. The units are whole-number decibels (dB).\n"
- " s - Skip the playback of instructions for leaving a message to the\n"
- " calling party.\n"
- " u - Play the 'unavailable' greeting.\n";
+ " b - Play the 'busy' greeting to the calling party.\n"
+ " d([c]) - Accept digits for a new extension in context c, if played during\n"
+ " the greeting. Context defaults to the current context.\n"
+ " g(#) - Use the specified amount of gain when recording the voicemail\n"
+ " message. The units are whole-number decibels (dB).\n"
+ " s - Skip the playback of instructions for leaving a message to the\n"
+ " calling party.\n"
+ " u - Play the 'unavailable' greeting.\n";
static char *synopsis_vmain = "Check Voicemail messages";
@@ -2952,6 +2957,7 @@
struct leave_vm_options {
unsigned int flags;
signed char record_gain;
+ char *exitcontext;
};
static int leave_voicemail(struct ast_channel *chan, char *ext, struct leave_vm_options *options)
@@ -2983,11 +2989,11 @@
char ext_context[256] = "";
char fmt[80];
char *context;
- char ecodes[16] = "#";
+ char ecodes[17] = "#";
char tmp[1024] = "", *tmpptr;
struct ast_vm_user *vmu;
struct ast_vm_user svm;
- const char *category = NULL;
+ const char *category = NULL, *code, *alldtmf = "0123456789ABCD*#";
ast_copy_string(tmp, ext, sizeof(tmp));
ext = tmp;
@@ -3056,6 +3062,15 @@
else if (!ast_strlen_zero(chan->macrocontext) && ast_exists_extension(chan, chan->macrocontext, "a", 1, chan->cid.cid_num)) {
strncat(ecodes, "*", sizeof(ecodes) - strlen(ecodes) - 1);
ausemacro = 1;
+ }
+
+ if (ast_test_flag(options, OPT_DTMFEXIT)) {
+ for (code = alldtmf; *code; code++) {
+ char e[2] = "";
+ e[0] = *code;
+ if (strchr(ecodes, e[0]) == NULL && ast_canmatch_extension(chan, chan->context, e, 1, chan->cid.cid_num))
+ strncat(ecodes, e, sizeof(ecodes) - strlen(ecodes) - 1);
+ }
}
/* Play the beginning intro if desired */
@@ -3102,7 +3117,7 @@
ast_stopstream(chan);
/* Check for a '*' here in case the caller wants to escape from voicemail to something
other than the operator -- an automated attendant or mailbox login for example */
- if (res == '*') {
+ if (!ast_strlen_zero(vmu->exit) && (res == '*')) {
chan->exten[0] = 'a';
chan->exten[1] = '\0';
if (!ast_strlen_zero(vmu->exit)) {
@@ -3117,7 +3132,7 @@
}
/* Check for a '0' here */
- if (res == '0') {
+ if (ast_test_flag(vmu, VM_OPERATOR) && res == '0') {
transfer:
if (ouseexten || ousemacro) {
chan->exten[0] = 'o';
@@ -3134,6 +3149,16 @@
}
return 0;
}
+
+ /* Allow all other digits to exit Voicemail and return to the dialplan */
+ if (ast_test_flag(options, OPT_DTMFEXIT) && res > 0) {
+ if (!ast_strlen_zero(options->exitcontext))
+ ast_copy_string(chan->context, options->exitcontext, sizeof(chan->context));
+ free_user(vmu);
+ pbx_builtin_setvar_helper(chan, "VMSTATUS", "USEREXIT");
+ return res;
+ }
+
if (res < 0) {
free_user(vmu);
pbx_builtin_setvar_helper(chan, "VMSTATUS", "FAILED");
@@ -7400,7 +7425,7 @@
if (args.argc == 2) {
if (ast_app_parse_options(vm_app_options, &flags, opts, args.argv1))
return -1;
- ast_copy_flags(&leave_options, &flags, OPT_SILENT | OPT_BUSY_GREETING | OPT_UNAVAIL_GREETING);
+ ast_copy_flags(&leave_options, &flags, OPT_SILENT | OPT_BUSY_GREETING | OPT_UNAVAIL_GREETING | OPT_DTMFEXIT);
if (ast_test_flag(&flags, OPT_RECORDGAIN)) {
int gain;
@@ -7410,6 +7435,10 @@
} else {
leave_options.record_gain = (signed char) gain;
}
+ }
+ if (ast_test_flag(&flags, OPT_DTMFEXIT)) {
+ if (!ast_strlen_zero(opts[OPT_ARG_DTMFEXIT]))
+ leave_options.exitcontext = opts[OPT_ARG_DTMFEXIT];
}
}
} else {
More information about the asterisk-commits
mailing list