diff options
author | Olle Johansson <oej@edvina.net> | 2009-01-29 17:08:22 +0000 |
---|---|---|
committer | Olle Johansson <oej@edvina.net> | 2009-01-29 17:08:22 +0000 |
commit | 7ecda454826ec42c79a6e6537963568c7e9b28b9 (patch) | |
tree | de5917bbd7b2b261e6caa93c380ee86afd42f892 /apps | |
parent | b3ab95317c51f2dcc622c7e31af61dbc8fc4906d (diff) |
Fix "cancel answered elsewhere" through app_queue with members in chan_local.
Also, implement a private cause code (as suggested by Tilghman). This works with
chan_sip, but doesn't propagate through chan_local.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@172318 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'apps')
-rw-r--r-- | apps/app_dial.c | 15 | ||||
-rw-r--r-- | apps/app_queue.c | 18 |
2 files changed, 28 insertions, 5 deletions
diff --git a/apps/app_dial.c b/apps/app_dial.c index f4e8aabd6..41c85d521 100644 --- a/apps/app_dial.c +++ b/apps/app_dial.c @@ -568,8 +568,12 @@ static void hanguptree(struct chanlist *outgoing, struct ast_channel *exception, while (outgoing) { /* Hangup any existing lines we have open */ if (outgoing->chan && (outgoing->chan != exception)) { - if (answered_elsewhere) + if (answered_elsewhere) { + /* The flag is used for local channel inheritance and stuff */ ast_set_flag(outgoing->chan, AST_FLAG_ANSWERED_ELSEWHERE); + /* This is for the channel drivers */ + outgoing->chan->hangupcause = AST_CAUSE_ANSWERED_ELSEWHERE; + } ast_hangup(outgoing->chan); } oo = outgoing; @@ -1567,6 +1571,7 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags goto done; } + if (ast_test_flag64(&opts, OPT_OPERMODE)) { opermode = ast_strlen_zero(opt_args[OPT_ARG_OPERMODE]) ? 1 : atoi(opt_args[OPT_ARG_OPERMODE]); ast_verb(3, "Setting operator services mode to %d.\n", opermode); @@ -1780,6 +1785,14 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags /* If we have an outbound group, set this peer channel to it */ if (outbound_group) ast_app_group_set_channel(tc, outbound_group); + /* If the calling channel has the ANSWERED_ELSEWHERE flag set, inherit it. This is to support local channels */ + if (ast_test_flag(chan, AST_FLAG_ANSWERED_ELSEWHERE)) + ast_set_flag(tc, AST_FLAG_ANSWERED_ELSEWHERE); + + /* Check if we're forced by configuration */ + if (ast_test_flag64(&opts, OPT_CANCEL_ELSEWHERE)) + ast_set_flag(tc, AST_FLAG_ANSWERED_ELSEWHERE); + /* Inherit context and extension */ ast_string_field_set(tc, dialcontext, ast_strlen_zero(chan->macrocontext) ? chan->context : chan->macrocontext); diff --git a/apps/app_queue.c b/apps/app_queue.c index 5cf064a89..caa6613c1 100644 --- a/apps/app_queue.c +++ b/apps/app_queue.c @@ -646,6 +646,7 @@ struct queue_ent { int linwrapped; /*!< Is the linpos wrapped? */ time_t start; /*!< When we started holding */ time_t expire; /*!< When this entry should expire (time out of queue) */ + int cancel_answered_elsewhere; /*!< Whether we should force the CAE flag on this call (C) option*/ struct ast_channel *chan; /*!< Our channel */ AST_LIST_HEAD_NOLOCK(,penalty_rule) qe_rules; /*!< Local copy of the queue's penalty rules */ struct penalty_rule *pr; /*!< Pointer to the next penalty rule to implement */ @@ -2412,6 +2413,9 @@ static int ring_entry(struct queue_ent *qe, struct callattempt *tmp, int *busies return 0; } + if (qe->cancel_answered_elsewhere) { + ast_set_flag(tmp->chan, AST_FLAG_ANSWERED_ELSEWHERE); + } tmp->chan->appl = "AppQueue"; tmp->chan->data = "(Outgoing Line)"; memset(&tmp->chan->whentohangup, 0, sizeof(tmp->chan->whentohangup)); @@ -3484,7 +3488,6 @@ static int try_calling(struct queue_ent *qe, const char *options, char *announce struct ao2_iterator memi; struct ast_datastore *datastore, *transfer_ds; struct queue_end_bridge *queue_end_bridge = NULL; - int cancel_answered_elsewhere = 0; ast_channel_lock(qe->chan); datastore = ast_channel_datastore_find(qe->chan, &dialed_interface_info, NULL); @@ -3553,7 +3556,7 @@ static int try_calling(struct queue_ent *qe, const char *options, char *announce ast_set_flag(&(bridge_config.features_caller), AST_FEATURE_AUTOMIXMON); break; case 'C': - cancel_answered_elsewhere = 1; + qe->cancel_answered_elsewhere = 1; break; } @@ -3571,6 +3574,13 @@ static int try_calling(struct queue_ent *qe, const char *options, char *announce queue_ref(qe->parent); } + /* if the calling channel has the ANSWERED_ELSEWHERE flag set, make sure this is inherited. + (this is mainly to support chan_local) + */ + if (ast_test_flag(qe->chan, AST_FLAG_ANSWERED_ELSEWHERE)) { + qe->cancel_answered_elsewhere = 1; + } + /* Hold the lock while we setup the outgoing calls */ if (use_weight) ao2_lock(queues); @@ -3751,7 +3761,7 @@ static int try_calling(struct queue_ent *qe, const char *options, char *announce member = lpeer->member; /* Increment the refcount for this member, since we're going to be using it for awhile in here. */ ao2_ref(member, 1); - hangupcalls(outgoing, peer, cancel_answered_elsewhere); + hangupcalls(outgoing, peer, qe->cancel_answered_elsewhere); outgoing = NULL; if (announce || qe->parent->reportholdtime || qe->parent->memberdelay) { int res2; @@ -4154,7 +4164,7 @@ static int try_calling(struct queue_ent *qe, const char *options, char *announce ao2_ref(member, -1); } out: - hangupcalls(outgoing, NULL, cancel_answered_elsewhere); + hangupcalls(outgoing, NULL, qe->cancel_answered_elsewhere); return res; } |