[asterisk-commits] oej: trunk r172318 - in /trunk: apps/ channels/ include/asterisk/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Jan 29 11:08:23 CST 2009
Author: oej
Date: Thu Jan 29 11:08:22 2009
New Revision: 172318
URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=172318
Log:
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.
Modified:
trunk/apps/app_dial.c
trunk/apps/app_queue.c
trunk/channels/chan_local.c
trunk/channels/chan_sip.c
trunk/include/asterisk/causes.h
Modified: trunk/apps/app_dial.c
URL: http://svn.digium.com/svn-view/asterisk/trunk/apps/app_dial.c?view=diff&rev=172318&r1=172317&r2=172318
==============================================================================
--- trunk/apps/app_dial.c (original)
+++ trunk/apps/app_dial.c Thu Jan 29 11:08:22 2009
@@ -568,8 +568,12 @@
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 @@
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 @@
/* 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);
Modified: trunk/apps/app_queue.c
URL: http://svn.digium.com/svn-view/asterisk/trunk/apps/app_queue.c?view=diff&rev=172318&r1=172317&r2=172318
==============================================================================
--- trunk/apps/app_queue.c (original)
+++ trunk/apps/app_queue.c Thu Jan 29 11:08:22 2009
@@ -646,6 +646,7 @@
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 @@
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 @@
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 @@
ast_set_flag(&(bridge_config.features_caller), AST_FEATURE_AUTOMIXMON);
break;
case 'C':
- cancel_answered_elsewhere = 1;
+ qe->cancel_answered_elsewhere = 1;
break;
}
@@ -3569,6 +3572,13 @@
* are done with it. We remove this reference in end_bridge_callback.
*/
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 */
@@ -3751,7 +3761,7 @@
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 @@
ao2_ref(member, -1);
}
out:
- hangupcalls(outgoing, NULL, cancel_answered_elsewhere);
+ hangupcalls(outgoing, NULL, qe->cancel_answered_elsewhere);
return res;
}
Modified: trunk/channels/chan_local.c
URL: http://svn.digium.com/svn-view/asterisk/trunk/channels/chan_local.c?view=diff&rev=172318&r1=172317&r2=172318
==============================================================================
--- trunk/channels/chan_local.c (original)
+++ trunk/channels/chan_local.c Thu Jan 29 11:08:22 2009
@@ -532,6 +532,11 @@
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) {
@@ -567,9 +572,14 @@
ast_mutex_lock(&p->lock);
- if (p->chan && ast_test_flag(ast, 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);
- isoutbound = IS_OUTBOUND(ast, p);
+ 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)) {
@@ -600,6 +610,7 @@
DEADLOCK_AVOIDANCE(&p->lock);
}
if (p->chan) {
+ p->chan->hangupcause = ast->hangupcause;
ast_queue_hangup(p->chan);
ast_channel_unlock(p->chan);
}
Modified: trunk/channels/chan_sip.c
URL: http://svn.digium.com/svn-view/asterisk/trunk/channels/chan_sip.c?view=diff&rev=172318&r1=172317&r2=172318
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Thu Jan 29 11:08:22 2009
@@ -5509,8 +5509,11 @@
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;
}
Modified: trunk/include/asterisk/causes.h
URL: http://svn.digium.com/svn-view/asterisk/trunk/include/asterisk/causes.h?view=diff&rev=172318&r1=172317&r2=172318
==============================================================================
--- trunk/include/asterisk/causes.h (original)
+++ trunk/include/asterisk/causes.h Thu Jan 29 11:08:22 2009
@@ -81,6 +81,10 @@
- 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
*/
@@ -136,6 +140,9 @@
#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
More information about the asterisk-commits
mailing list