Fix a bug with app_voicemail when trying to use app_directory to leave messages

to another user (options 3, 5, 2).

If the context/extension didn't exist in the dialplan (and why should it have to?),
it would fail, saying that it's an "invalid extension".

(issue BE-71)


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@40426 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.4
Jason Parker 19 years ago
parent 5dc72404ab
commit 7c05e6478d

@ -259,7 +259,8 @@ static char *convert(char *lastname)
* '*' for skipped entry from directory * '*' for skipped entry from directory
*/ */
static int play_mailbox_owner(struct ast_channel *chan, char *context, static int play_mailbox_owner(struct ast_channel *chan, char *context,
char *dialcontext, char *ext, char *name, int readext) char *dialcontext, char *ext, char *name, int readext,
int fromappvm)
{ {
int res = 0; int res = 0;
int loop; int loop;
@ -311,12 +312,17 @@ static int play_mailbox_owner(struct ast_channel *chan, char *context,
if (res < 0) /* User hungup, so jump out now */ if (res < 0) /* User hungup, so jump out now */
break; break;
if (res == '1') { /* Name selected */ if (res == '1') { /* Name selected */
if (ast_goto_if_exists(chan, dialcontext, ext, 1)) { if (fromappvm) {
ast_log(LOG_WARNING, /* We still want to set the exten though */
"Can't find extension '%s' in context '%s'. " ast_copy_string(chan->exten, ext, sizeof(chan->exten));
"Did you pass the wrong context to Directory?\n", } else {
ext, dialcontext); if (ast_goto_if_exists(chan, dialcontext, ext, 1)) {
res = -1; ast_log(LOG_WARNING,
"Can't find extension '%s' in context '%s'. "
"Did you pass the wrong context to Directory?\n",
ext, dialcontext);
res = -1;
}
} }
break; break;
} }
@ -388,7 +394,7 @@ static struct ast_config *realtime_directory(char *context)
return cfg; return cfg;
} }
static int do_directory(struct ast_channel *chan, struct ast_config *cfg, char *context, char *dialcontext, char digit, int last, int readext) static int do_directory(struct ast_channel *chan, struct ast_config *cfg, char *context, char *dialcontext, char digit, int last, int readext, int fromappvm)
{ {
/* Read in the first three digits.. "digit" is the first digit, already read */ /* Read in the first three digits.. "digit" is the first digit, already read */
char ext[NUMDIGITS + 1]; char ext[NUMDIGITS + 1];
@ -467,7 +473,7 @@ static int do_directory(struct ast_channel *chan, struct ast_config *cfg, char *
if (v) { if (v) {
/* We have a match -- play a greeting if they have it */ /* We have a match -- play a greeting if they have it */
res = play_mailbox_owner(chan, context, dialcontext, v->name, name, readext); res = play_mailbox_owner(chan, context, dialcontext, v->name, name, readext, fromappvm);
switch (res) { switch (res) {
case -1: case -1:
/* user pressed '1' but extension does not exist, or /* user pressed '1' but extension does not exist, or
@ -512,6 +518,7 @@ static int directory_exec(struct ast_channel *chan, void *data)
struct ast_config *cfg; struct ast_config *cfg;
int last = 1; int last = 1;
int readext = 0; int readext = 0;
int fromappvm = 0;
char *dirintro, *parse; char *dirintro, *parse;
AST_DECLARE_APP_ARGS(args, AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(vmcontext); AST_APP_ARG(vmcontext);
@ -535,6 +542,8 @@ static int directory_exec(struct ast_channel *chan, void *data)
last = 0; last = 0;
if (strchr(args.options, 'e')) if (strchr(args.options, 'e'))
readext = 1; readext = 1;
if (strchr(args.options, 'v'))
fromappvm = 1;
} }
if (ast_strlen_zero(args.dialcontext)) if (ast_strlen_zero(args.dialcontext))
@ -563,7 +572,7 @@ static int directory_exec(struct ast_channel *chan, void *data)
if (!res) if (!res)
res = ast_waitfordigit(chan, 5000); res = ast_waitfordigit(chan, 5000);
if (res > 0) { if (res > 0) {
res = do_directory(chan, cfg, args.vmcontext, args.dialcontext, res, last, readext); res = do_directory(chan, cfg, args.vmcontext, args.dialcontext, res, last, readext, fromappvm);
if (res > 0) { if (res > 0) {
res = ast_waitstream(chan, AST_DIGIT_ANY); res = ast_waitstream(chan, AST_DIGIT_ANY);
ast_stopstream(chan); ast_stopstream(chan);

@ -3864,13 +3864,15 @@ static int forward_message(struct ast_channel *chan, char *context, struct vm_st
app = pbx_findapp("Directory"); app = pbx_findapp("Directory");
if (app) { if (app) {
/* make mackup copies */ char vmcontext[256];
/* make backup copies */
memcpy(old_context, chan->context, sizeof(chan->context)); memcpy(old_context, chan->context, sizeof(chan->context));
memcpy(old_exten, chan->exten, sizeof(chan->exten)); memcpy(old_exten, chan->exten, sizeof(chan->exten));
old_priority = chan->priority; old_priority = chan->priority;
/* call the the Directory, changes the channel */ /* call the the Directory, changes the channel */
res = pbx_exec(chan, app, context ? context : "default"); sprintf(vmcontext, "%s||v", context ? context : "default");
res = pbx_exec(chan, app, vmcontext);
ast_copy_string(username, chan->exten, sizeof(username)); ast_copy_string(username, chan->exten, sizeof(username));

Loading…
Cancel
Save