Index: apps/app_voicemail.c =================================================================== --- apps/app_voicemail.c (revision 91829) +++ apps/app_voicemail.c (working copy) @@ -233,13 +233,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, { @@ -247,6 +249,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), }); @@ -2953,6 +2956,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) @@ -2984,11 +2988,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; @@ -3059,6 +3063,15 @@ 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 */ if (!ast_strlen_zero(prefile)) { #ifdef ODBC_STORAGE @@ -3103,7 +3116,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)) { @@ -3118,7 +3131,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'; @@ -3135,6 +3148,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 (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"); @@ -7390,7 +7413,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; @@ -7401,6 +7424,10 @@ leave_options.record_gain = (signed char) gain; } } + if (ast_test_flag(&flags, OPT_DTMFEXIT)) { + if (opts[OPT_ARG_DTMFEXIT]) + leave_options.exitcontext = opts[OPT_ARG_DTMFEXIT]; + } } } else { char tmp[256];