diff options
author | Kinsey Moore <kmoore@digium.com> | 2012-06-05 14:41:43 +0000 |
---|---|---|
committer | Kinsey Moore <kmoore@digium.com> | 2012-06-05 14:41:43 +0000 |
commit | 571445ab9c9f268abfa7cdea1f80d199686c5fac (patch) | |
tree | bcaac031cac910fbc4aa613cb62700bcca8f8a48 | |
parent | d210685a20c950e418b84e3c6f085e2f7f19f299 (diff) |
Convert AST_FLAG_ANSWERED_ELSEWHERE usage to AST_CAUSE_ANSWERED_ELSEWHERE
This was essentially duplicated functionality where normal channels used
AST_CAUSE_ANSWERED_ELSEWHERE while local channels and queues used
AST_FLAG_ANSWERED_ELSEWHERE. This removes the flag and converts that usage
into AST_CAUSE_ANSWERED_ELSEWHER usage.
Review: https://reviewboard.asterisk.org/r/1944
(closes issue ASTERISK-19865)
Patch-by: Birger Harzenetter
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@368519 65c4cc65-6c06-0410-ace0-fbb531ad65f3
-rw-r--r-- | apps/app_dial.c | 15 | ||||
-rw-r--r-- | apps/app_queue.c | 8 | ||||
-rw-r--r-- | channels/chan_local.c | 13 | ||||
-rw-r--r-- | channels/chan_sip.c | 5 | ||||
-rw-r--r-- | channels/chan_unistim.c | 2 | ||||
-rw-r--r-- | include/asterisk/channel.h | 5 | ||||
-rw-r--r-- | main/channel_internal_api.c | 1 | ||||
-rw-r--r-- | main/features.c | 4 |
8 files changed, 24 insertions, 29 deletions
diff --git a/apps/app_dial.c b/apps/app_dial.c index e6eebbec7..1ebad3412 100644 --- a/apps/app_dial.c +++ b/apps/app_dial.c @@ -133,8 +133,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") <para>Reset the call detail record (CDR) for this call.</para> </option> <option name="c"> - <para>If the Dial() application cancels this call, always set the flag to tell the channel - driver that the call is answered elsewhere.</para> + <para>If the Dial() application cancels this call, always set HANGUPCAUSE to 'answered elsewhere'</para> </option> <option name="d"> <para>Allow the calling user to dial a 1 digit extension while waiting for @@ -727,8 +726,6 @@ static void hanguptree(struct dial_head *out_chans, struct ast_channel *exceptio /* Hangup any existing lines we have open */ if (outgoing->chan && (outgoing->chan != exception)) { if (answered_elsewhere) { - /* The flag is used for local channel inheritance and stuff */ - ast_set_flag(ast_channel_flags(outgoing->chan), AST_FLAG_ANSWERED_ELSEWHERE); /* This is for the channel drivers */ ast_channel_hangupcause_set(outgoing->chan, AST_CAUSE_ANSWERED_ELSEWHERE); } @@ -2515,12 +2512,12 @@ static int dial_exec_full(struct ast_channel *chan, const char *data, struct ast 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(ast_channel_flags(chan), AST_FLAG_ANSWERED_ELSEWHERE)) - ast_set_flag(ast_channel_flags(tc), AST_FLAG_ANSWERED_ELSEWHERE); + if (ast_channel_hangupcause(chan) == AST_CAUSE_ANSWERED_ELSEWHERE) + ast_channel_hangupcause_set(tc, AST_CAUSE_ANSWERED_ELSEWHERE); /* Check if we're forced by configuration */ if (ast_test_flag64(&opts, OPT_CANCEL_ELSEWHERE)) - ast_set_flag(ast_channel_flags(tc), AST_FLAG_ANSWERED_ELSEWHERE); + ast_channel_hangupcause_set(tc, AST_CAUSE_ANSWERED_ELSEWHERE); /* Inherit context and extension */ @@ -3079,11 +3076,11 @@ out: } ast_channel_early_bridge(chan, NULL); - hanguptree(&out_chans, NULL, 0); /* In this case, there's no answer anywhere */ + hanguptree(&out_chans, NULL, ast_channel_hangupcause(chan)==AST_CAUSE_ANSWERED_ELSEWHERE ? 1 : 0 ); /* forward 'answered elsewhere' if we received it */ pbx_builtin_setvar_helper(chan, "DIALSTATUS", pa.status); senddialendevent(chan, pa.status); ast_debug(1, "Exiting with DIALSTATUS=%s.\n", pa.status); - + if ((ast_test_flag64(peerflags, OPT_GO_ON)) && !ast_check_hangup(chan) && (res != AST_PBX_INCOMPLETE)) { if (!ast_tvzero(calldurationlimit)) memset(ast_channel_whentohangup(chan), 0, sizeof(*ast_channel_whentohangup(chan))); diff --git a/apps/app_queue.c b/apps/app_queue.c index cb9674959..931733cfc 100644 --- a/apps/app_queue.c +++ b/apps/app_queue.c @@ -3103,7 +3103,7 @@ static void hangupcalls(struct callattempt *outgoing, struct ast_channel *except /* Hangup any existing lines we have open */ if (outgoing->chan && (outgoing->chan != exception)) { if (exception || cancel_answered_elsewhere) { - ast_set_flag(ast_channel_flags(outgoing->chan), AST_FLAG_ANSWERED_ELSEWHERE); + ast_channel_hangupcause_set(outgoing->chan, AST_CAUSE_ANSWERED_ELSEWHERE); } ast_hangup(outgoing->chan); } @@ -3357,7 +3357,7 @@ static int ring_entry(struct queue_ent *qe, struct callattempt *tmp, int *busies ast_channel_lock_both(tmp->chan, qe->chan); if (qe->cancel_answered_elsewhere) { - ast_set_flag(ast_channel_flags(tmp->chan), AST_FLAG_ANSWERED_ELSEWHERE); + ast_channel_hangupcause_set(tmp->chan, AST_CAUSE_ANSWERED_ELSEWHERE); } ast_channel_appl_set(tmp->chan, "AppQueue"); ast_channel_data_set(tmp->chan, "(Outgoing Line)"); @@ -4825,10 +4825,10 @@ static int try_calling(struct queue_ent *qe, const struct ast_flags opts, char * qe->cancel_answered_elsewhere = 1; } - /* if the calling channel has the ANSWERED_ELSEWHERE flag set, make sure this is inherited. + /* if the calling channel has AST_CAUSE_ANSWERED_ELSEWHERE set, make sure this is inherited. (this is mainly to support chan_local) */ - if (ast_test_flag(ast_channel_flags(qe->chan), AST_FLAG_ANSWERED_ELSEWHERE)) { + if (ast_channel_hangupcause(qe->chan) == AST_CAUSE_ANSWERED_ELSEWHERE) { qe->cancel_answered_elsewhere = 1; } diff --git a/channels/chan_local.c b/channels/chan_local.c index bed9eebdc..3c5fca5de 100644 --- a/channels/chan_local.c +++ b/channels/chan_local.c @@ -37,6 +37,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include <sys/signal.h> #include "asterisk/lock.h" +#include "asterisk/causes.h" #include "asterisk/channel.h" #include "asterisk/config.h" #include "asterisk/module.h" @@ -909,9 +910,9 @@ static int local_call(struct ast_channel *ast, const char *dest, int timeout) ast_channel_cc_params_init(chan, ast_channel_get_cc_config_params(owner)); - /* 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_channel_flags(ast), AST_FLAG_ANSWERED_ELSEWHERE)) { - ast_set_flag(ast_channel_flags(chan), AST_FLAG_ANSWERED_ELSEWHERE); + /* Make sure we inherit the AST_CAUSE_ANSWERED_ELSEWHERE if it's set on the queue/dial call request in the dialplan */ + if (ast_channel_hangupcause(ast) == AST_CAUSE_ANSWERED_ELSEWHERE) { + ast_channel_hangupcause_set(chan, AST_CAUSE_ANSWERED_ELSEWHERE); } /* copy the channel variables from the incoming channel to the outgoing channel */ @@ -1028,9 +1029,9 @@ static int local_hangup(struct ast_channel *ast) isoutbound = IS_OUTBOUND(ast, p); /* just comparing pointer of ast */ - if (p->chan && ast_test_flag(ast_channel_flags(ast), AST_FLAG_ANSWERED_ELSEWHERE)) { - ast_set_flag(ast_channel_flags(p->chan), AST_FLAG_ANSWERED_ELSEWHERE); - ast_debug(2, "This local call has the ANSWERED_ELSEWHERE flag set.\n"); + if (p->chan && ast_channel_hangupcause(ast) == AST_CAUSE_ANSWERED_ELSEWHERE) { + ast_channel_hangupcause_set(p->chan, AST_CAUSE_ANSWERED_ELSEWHERE); + ast_debug(2, "This local call has AST_CAUSE_ANSWERED_ELSEWHERE set.\n"); } if (isoutbound) { diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 5ee1e4b88..31064fe6a 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -6369,11 +6369,8 @@ static int sip_hangup(struct ast_channel *ast) ast_debug(1, "Asked to hangup channel that was not connected\n"); return 0; } - if (ast_test_flag(ast_channel_flags(ast), AST_FLAG_ANSWERED_ELSEWHERE) || ast_channel_hangupcause(ast) == AST_CAUSE_ANSWERED_ELSEWHERE) { + if (ast_channel_hangupcause(ast) == AST_CAUSE_ANSWERED_ELSEWHERE) { ast_debug(1, "This call was answered elsewhere\n"); - if (ast_channel_hangupcause(ast) == 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; } diff --git a/channels/chan_unistim.c b/channels/chan_unistim.c index 434aa0cb7..b143d16e7 100644 --- a/channels/chan_unistim.c +++ b/channels/chan_unistim.c @@ -4856,7 +4856,7 @@ static int unistim_hangup(struct ast_channel *ast) refresh_all_favorite(s); /* Update favicons in case of DND keys */ if (s->state == STATE_RINGING && sub->subtype == SUB_RING) { send_no_ring(s); - if (!ast_test_flag(ast_channel_flags(ast), AST_FLAG_ANSWERED_ELSEWHERE) && ast_channel_hangupcause(ast) != AST_CAUSE_ANSWERED_ELSEWHERE) { + if (ast_channel_hangupcause(ast) != AST_CAUSE_ANSWERED_ELSEWHERE) { d->missed_call++; write_history(s, 'i', 1); } diff --git a/include/asterisk/channel.h b/include/asterisk/channel.h index 59008a6fe..da3515754 100644 --- a/include/asterisk/channel.h +++ b/include/asterisk/channel.h @@ -835,9 +835,10 @@ enum { /*! This is set to tell the channel not to generate DTMF begin frames, and * to instead only generate END frames. */ AST_FLAG_END_DTMF_ONLY = (1 << 14), - /*! Flag to show channels that this call is hangup due to the fact that the call + /* OBSOLETED in favor of AST_CAUSE_ANSWERED_ELSEWHERE + Flag to show channels that this call is hangup due to the fact that the call was indeed answered, but in another channel */ - AST_FLAG_ANSWERED_ELSEWHERE = (1 << 15), + /* AST_FLAG_ANSWERED_ELSEWHERE = (1 << 15), */ /*! This flag indicates that on a masquerade, an active stream should not * be carried over */ AST_FLAG_MASQ_NOSTREAM = (1 << 16), diff --git a/main/channel_internal_api.c b/main/channel_internal_api.c index 3fc3277d0..e39ee5dfd 100644 --- a/main/channel_internal_api.c +++ b/main/channel_internal_api.c @@ -250,7 +250,6 @@ static void channel_data_add_flags(struct ast_data *tree, ast_data_add_bool(tree, "IN_DTMF", ast_test_flag(ast_channel_flags(chan), AST_FLAG_IN_DTMF)); ast_data_add_bool(tree, "EMULATE_DTMF", ast_test_flag(ast_channel_flags(chan), AST_FLAG_EMULATE_DTMF)); ast_data_add_bool(tree, "END_DTMF_ONLY", ast_test_flag(ast_channel_flags(chan), AST_FLAG_END_DTMF_ONLY)); - ast_data_add_bool(tree, "ANSWERED_ELSEWHERE", ast_test_flag(ast_channel_flags(chan), AST_FLAG_ANSWERED_ELSEWHERE)); ast_data_add_bool(tree, "MASQ_NOSTREAM", ast_test_flag(ast_channel_flags(chan), AST_FLAG_MASQ_NOSTREAM)); ast_data_add_bool(tree, "BRIDGE_HANGUP_RUN", ast_test_flag(ast_channel_flags(chan), AST_FLAG_BRIDGE_HANGUP_RUN)); ast_data_add_bool(tree, "BRIDGE_HANGUP_DONT", ast_test_flag(ast_channel_flags(chan), AST_FLAG_BRIDGE_HANGUP_DONT)); diff --git a/main/features.c b/main/features.c index 04bc5326a..21d6edca2 100644 --- a/main/features.c +++ b/main/features.c @@ -7690,8 +7690,8 @@ int ast_do_pickup(struct ast_channel *chan, struct ast_channel *target) ast_channel_queue_connected_line_update(chan, &connected_caller, NULL); - /* setting this flag to generate a reason header in the cancel message to the ringing channel */ - ast_set_flag(ast_channel_flags(chan), AST_FLAG_ANSWERED_ELSEWHERE); + /* setting the HANGUPCAUSE so the ringing channel knows this call was not a missed call */ + ast_channel_hangupcause_set(chan, AST_CAUSE_ANSWERED_ELSEWHERE); if (ast_channel_masquerade(target, chan)) { ast_log(LOG_WARNING, "Unable to masquerade '%s' into '%s'\n", chan_name, |