]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
chan_local+app_dial: Propagagate call answered elsewhere over local channels.
authorWalter Doekes <walter+asterisk@wjd.nu>
Thu, 15 May 2014 15:32:35 +0000 (15:32 +0000)
committerWalter Doekes <walter+asterisk@wjd.nu>
Thu, 15 May 2014 15:32:35 +0000 (15:32 +0000)
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
apps/app_dial.c
channels/chan_local.c

index e70d7dd637f04a2eb8b3696209c698e9e62a9fab..fd4af6b4ab8a03cf2be52c5e8a2418f351c30ae4 100644 (file)
@@ -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).
index 226aaf468133efd5b23d954eb96f80719b196df6..86b0e4c906ac5f839b373fec47dec22a0e98e57a 100644 (file)
@@ -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);
index f7295ee3edc573f7df8e498890bcaf2a7ba48ee7..c6afe8a8562fda66d95e4e657d9bf268b5008c5c 100644 (file)
@@ -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"
@@ -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;
        }