From 8bf18ed4d3539e97945055a44efc2c5488a30394 Mon Sep 17 00:00:00 2001 From: Walter Doekes Date: Thu, 15 May 2014 15:32:35 +0000 Subject: [PATCH] chan_local+app_dial: Propagagate call answered elsewhere over local channels. AST_FLAG_ANSWERED_ELSEWHERE was not propagated back from local channels. It is now. That means that when a call is picked up from a callgroup of local channels, the other channels will now properly see it as "picked up". This occurs when you use a construct like Dial(Local/a@context&Local/b@context) where a@context and b@context dial two chan_sip devices respectively. If one device picks up, the other will not see "1 missed call" anymore. In this respect, it now behaves the same as when doing Dial(SIP/a&SIP/b). Review: https://reviewboard.asterisk.org/r/3540/ git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@413949 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- UPGRADE.txt | 3 +++ apps/app_dial.c | 4 +++- channels/chan_local.c | 11 ++++++++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/UPGRADE.txt b/UPGRADE.txt index e70d7dd637..fd4af6b4ab 100644 --- a/UPGRADE.txt +++ b/UPGRADE.txt @@ -21,6 +21,9 @@ from 1.8.27.0 to 1.8.28.0: * The asterisk command line -I option and the asterisk.conf internal_timing option are removed and always enabled if any timing module is loaded. +* SIP (chan_sip) accounts dialed through a Local channel will now properly + hide the "1 missed call" if one of the other dialed accounts picks up the + call. from 1.8.26.0 to 1.8.27.0: * res_fax now returns the correct rates for V.27ter (4800 or 9600 bit/s). diff --git a/apps/app_dial.c b/apps/app_dial.c index 226aaf4681..86b0e4c906 100644 --- a/apps/app_dial.c +++ b/apps/app_dial.c @@ -3025,7 +3025,9 @@ out: } ast_channel_early_bridge(chan, NULL); - hanguptree(outgoing, NULL, 0); /* In this case, there's no answer anywhere */ + /* When dialing local channels, the hangupcause of the parent channel + * tells us whether the call was answered elsewhere. */ + hanguptree(outgoing, NULL, chan->hangupcause == AST_CAUSE_ANSWERED_ELSEWHERE ? 1 : 0); pbx_builtin_setvar_helper(chan, "DIALSTATUS", pa.status); senddialendevent(chan, pa.status); ast_debug(1, "Exiting with DIALSTATUS=%s.\n", pa.status); diff --git a/channels/chan_local.c b/channels/chan_local.c index f7295ee3ed..c6afe8a856 100644 --- a/channels/chan_local.c +++ b/channels/chan_local.c @@ -37,6 +37,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include #include "asterisk/lock.h" +#include "asterisk/causes.h" #include "asterisk/channel.h" #include "asterisk/config.h" #include "asterisk/module.h" @@ -1018,6 +1019,7 @@ static int local_hangup(struct ast_channel *ast) struct ast_frame f = { AST_FRAME_CONTROL, { AST_CONTROL_HANGUP }, .data.uint32 = ast->hangupcause }; struct ast_channel *owner = NULL; struct ast_channel *chan = NULL; + int answered_elsewhere = 0; if (!p) { return -1; @@ -1040,6 +1042,7 @@ 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, AST_FLAG_ANSWERED_ELSEWHERE)) { + answered_elsewhere = 1; ast_set_flag(p->chan, AST_FLAG_ANSWERED_ELSEWHERE); ast_debug(2, "This local call has the ANSWERED_ELSEWHERE flag set.\n"); } @@ -1056,7 +1059,13 @@ static int local_hangup(struct ast_channel *ast) p->chan = NULL; } else { if (p->chan) { - ast_queue_hangup(p->chan); + /* Use the hangupcause to propagate the fact that the + * call was answered somewhere. */ + if (answered_elsewhere) { + ast_queue_hangup_with_cause(p->chan, AST_CAUSE_ANSWERED_ELSEWHERE); + } else { + ast_queue_hangup(p->chan); + } } p->owner = NULL; } -- 2.47.3