--- ../original/asterisk-1.2.7.1/apps/app_voicemail.c 2006-04-11 17:24:46.000000000 -0500 +++ apps/app_voicemail.c 2006-04-27 12:48:29.000000000 -0500 @@ -2389,6 +2389,9 @@ struct ast_vm_user svm; char *category = NULL; + int vmx = 0; + char strvmx[2], strvmext[4]; + ast_copy_string(tmp, ext, sizeof(tmp)); ext = tmp; context = strchr(tmp, '@'); @@ -2453,6 +2456,20 @@ ausemacro = 1; } + for (vmx = 1; vmx <= 9; vmx++) { + snprintf(strvmx, sizeof(strvmx), "%d", vmx); + snprintf(strvmext, sizeof(strvmext), "vm%d", vmx); + + if (!ast_strlen_zero(vmu->exit)) { + if (ast_exists_extension(chan, vmu->exit, strvmext, 1, chan->cid.cid_num)) + strncat(ecodes, strvmx, sizeof(ecodes) - strlen(ecodes) - 1); + } else if (ast_exists_extension(chan, chan->context, strvmext, 1, chan->cid.cid_num)) + strncat(ecodes, strvmx, sizeof(ecodes) - strlen(ecodes) - 1); + else if (!ast_strlen_zero(chan->macrocontext) && ast_exists_extension(chan, chan->macrocontext, strvmext, 1, chan->cid.cid_num)) { + strncat(ecodes, strvmx, sizeof(ecodes) - strlen(ecodes) - 1); + } + } + /* Play the beginning intro if desired */ if (!ast_strlen_zero(prefile)) { RETRIEVE(prefile, -1); @@ -2499,9 +2516,37 @@ } chan->priority = 0; free_user(vmu); + pbx_builtin_setvar_helper(chan, "VMMAILBOX", vmu->mailbox); pbx_builtin_setvar_helper(chan, "VMSTATUS", "USEREXIT"); return 0; } + /* Check for res = 1-9, goto vm${res} */ + switch (res) { + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + chan->exten[0] = 'v'; + chan->exten[1] = 'm'; + chan->exten[2] = res; + chan->exten[3] = '\0'; + if (!ast_strlen_zero(vmu->exit)) { + ast_copy_string(chan->context, vmu->exit, sizeof(chan->context)); + } else if (!ast_strlen_zero(chan->macrocontext)) { + ast_copy_string(chan->context, chan->macrocontext, sizeof(chan->context)); + } + chan->priority = 0; + free_user(vmu); + pbx_builtin_setvar_helper(chan, "VMMAILBOX", vmu->mailbox); + pbx_builtin_setvar_helper(chan, "VMSTATUS", "USEREXIT"); + return 0; + } + /* Check for a '0' here */ if (res == '0') { transfer: @@ -2516,10 +2561,12 @@ ast_play_and_wait(chan, "transfer"); chan->priority = 0; free_user(vmu); + pbx_builtin_setvar_helper(chan, "VMMAILBOX", vmu->mailbox); pbx_builtin_setvar_helper(chan, "VMSTATUS", "USEREXIT"); return 0; } else { ast_play_and_wait(chan, "vm-sorry"); + pbx_builtin_setvar_helper(chan, "VMMAILBOX", vmu->mailbox); pbx_builtin_setvar_helper(chan, "VMSTATUS", "USEREXIT"); return 0; }