diff options
-rw-r--r-- | apps/app_macro.c | 36 | ||||
-rw-r--r-- | apps/app_queue.c | 11 |
2 files changed, 39 insertions, 8 deletions
diff --git a/apps/app_macro.c b/apps/app_macro.c index 26e4262b1..61f3ab722 100644 --- a/apps/app_macro.c +++ b/apps/app_macro.c @@ -245,7 +245,7 @@ static int _macro_exec(struct ast_channel *chan, const char *data, int exclusive int setmacrocontext=0; int autoloopflag, inhangup = 0; struct ast_str *tmp_subst = NULL; - + const char *my_macro_exten = NULL; char *save_macro_exten; char *save_macro_context; char *save_macro_priority; @@ -306,12 +306,32 @@ static int _macro_exec(struct ast_channel *chan, const char *data, int exclusive } snprintf(fullmacro, sizeof(fullmacro), "macro-%s", macro); - if (!ast_exists_extension(chan, fullmacro, "s", 1, - S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL))) { - if (!ast_context_find(fullmacro)) - ast_log(LOG_WARNING, "No such context '%s' for macro '%s'. Was called by %s@%s\n", fullmacro, macro, ast_channel_exten(chan), ast_channel_context(chan)); - else - ast_log(LOG_WARNING, "Context '%s' for macro '%s' lacks 's' extension, priority 1\n", fullmacro, macro); + + /* first search for the macro */ + if (!ast_context_find(fullmacro)) { + ast_log(LOG_WARNING, "No such context '%s' for macro '%s'. Was called by %s@%s\n", + fullmacro, macro, ast_channel_exten(chan), ast_channel_context(chan)); + return 0; + } + + /* now search for the right extension */ + if (ast_exists_extension(chan, fullmacro, "s", 1, + S_COR(ast_channel_caller(chan)->id.number.valid, + ast_channel_caller(chan)->id.number.str, NULL))) { + /* We have a normal macro */ + my_macro_exten = "s"; + } else if (ast_exists_extension(chan, fullmacro, "~~s~~", 1, + S_COR(ast_channel_caller(chan)->id.number.valid, + ast_channel_caller(chan)->id.number.str, NULL))) { + /* We have an AEL generated macro */ + my_macro_exten = "~~s~~"; + } + + /* do we have a valid exten? */ + if (!my_macro_exten) { + ast_log(LOG_WARNING, + "Context '%s' for macro '%s' lacks 's' extension, priority 1\n", + fullmacro, macro); return 0; } @@ -363,7 +383,7 @@ static int _macro_exec(struct ast_channel *chan, const char *data, int exclusive ast_set_flag(ast_channel_flags(chan), AST_FLAG_SUBROUTINE_EXEC); /* Setup environment for new run */ - ast_channel_exten_set(chan, "s"); + ast_channel_exten_set(chan, my_macro_exten); ast_channel_context_set(chan, fullmacro); ast_channel_priority_set(chan, 1); diff --git a/apps/app_queue.c b/apps/app_queue.c index a5cb12640..f9dd86b67 100644 --- a/apps/app_queue.c +++ b/apps/app_queue.c @@ -4102,6 +4102,17 @@ static void hangupcalls(struct queue_ent *qe, struct callattempt *outgoing, stru ast_channel_hangupcause_set(outgoing->chan, AST_CAUSE_ANSWERED_ELSEWHERE); } ast_channel_publish_dial(qe->chan, outgoing->chan, outgoing->interface, "CANCEL"); + + /* When dialing channels it is possible that they may not ever + * leave the not in use state (Local channels in particular) by + * the time we cancel them. If this occurs but we know they were + * dialed we explicitly remove them from the pending members + * container so that subsequent call attempts occur. + */ + if (outgoing->member->status == AST_DEVICE_NOT_INUSE) { + pending_members_remove(outgoing->member); + } + ast_hangup(outgoing->chan); } oo = outgoing; |