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;
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);
/* 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);
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 */
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));
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);
ast_set_flag(&(bridge_config.features_caller), AST_FEATURE_AUTOMIXMON);
break;
case 'C':
- cancel_answered_elsewhere = 1;
+ qe->cancel_answered_elsewhere = 1;
break;
}
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);
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;
ao2_ref(member, -1);
}
out:
- hangupcalls(outgoing, NULL, cancel_answered_elsewhere);
+ hangupcalls(outgoing, NULL, qe->cancel_answered_elsewhere);
return res;
}
return -1;
}
+ /* Make sure we inherit the ANSWERED_ELSEWHERE flag if it's set on the queue/dial call request in the dialplan */
+ if (ast_test_flag(ast, AST_FLAG_ANSWERED_ELSEWHERE)) {
+ ast_set_flag(p->chan, AST_FLAG_ANSWERED_ELSEWHERE);
+ }
+
/* copy the channel variables from the incoming channel to the outgoing channel */
/* Note that due to certain assumptions, they MUST be in the same order */
AST_LIST_TRAVERSE(&p->owner->varshead, varptr, entries) {
ast_mutex_lock(&p->lock);
- if (p->chan && ast_test_flag(ast, AST_FLAG_ANSWERED_ELSEWHERE))
- ast_set_flag(p->chan, AST_FLAG_ANSWERED_ELSEWHERE);
isoutbound = IS_OUTBOUND(ast, p);
+
+ if (p->chan && ast_test_flag(ast, AST_FLAG_ANSWERED_ELSEWHERE)) {
+ ast_set_flag(p->chan, AST_FLAG_ANSWERED_ELSEWHERE);
+ ast_debug(2, "This local call has the ANSWERED_ELSEWHERE flag set.\n");
+ }
+ /* Make sure the hangupcause follows down the chain of channels */
+
if (isoutbound) {
const char *status = pbx_builtin_getvar_helper(p->chan, "DIALSTATUS");
if ((status) && (p->owner)) {
DEADLOCK_AVOIDANCE(&p->lock);
}
if (p->chan) {
+ p->chan->hangupcause = ast->hangupcause;
ast_queue_hangup(p->chan);
ast_channel_unlock(p->chan);
}
ast_debug(1, "Asked to hangup channel that was not connected\n");
return 0;
}
- if (ast_test_flag(ast, AST_FLAG_ANSWERED_ELSEWHERE)) {
+ if (ast_test_flag(ast, AST_FLAG_ANSWERED_ELSEWHERE) || ast->hangupcause == AST_CAUSE_ANSWERED_ELSEWHERE) {
ast_debug(1, "This call was answered elsewhere");
+ if (ast->hangupcause == AST_CAUSE_ANSWERED_ELSEWHERE) {
+ ast_debug(1, "####### It's the cause code, buddy. The cause code!!!\n");
+ }
append_history(p, "Cancel", "Call answered elsewhere");
p->answered_elsewhere = TRUE;
}
- AST_CAUSE_PROTOCOL_ERROR 111
- AST_CAUSE_INTERWORKING 127
+The range 128-255 is private cause codes. Our private causes are:
+
+ - AST_CAUSE_ANSWERED_ELSEWHERE 200
+
For more information:
- \ref app_dial.c
*/
#define AST_CAUSE_PROTOCOL_ERROR 111
#define AST_CAUSE_INTERWORKING 127
+/* Private Cause codes for Asterisk */
+#define AST_CAUSE_ANSWERED_ELSEWHERE 200
+
/* Special Asterisk aliases */
#define AST_CAUSE_BUSY AST_CAUSE_USER_BUSY
#define AST_CAUSE_FAILURE AST_CAUSE_NETWORK_OUT_OF_ORDER