summaryrefslogtreecommitdiff
path: root/channels
diff options
context:
space:
mode:
authorOlle Johansson <oej@edvina.net>2007-07-09 08:27:37 +0000
committerOlle Johansson <oej@edvina.net>2007-07-09 08:27:37 +0000
commita1b9cbcd31d3fdc917ca60304913dec4232842b6 (patch)
tree023b2775a78d84d074ca62e3f349240deaf0c4d9 /channels
parentba857cc8a9984225a842137c0674df6089862bb0 (diff)
Implementation of a feature that will disable "missed calls" counters on SIP phones.
If the call is answered by another phone, other phones won't display the call as "missed". You can also add an option to the dial command so that you can have a "followme" scenario and not count the calls as "missed" when you cancel the call. Thanks to Ramon and Frank for feedback on this feature. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@74024 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels')
-rw-r--r--channels/chan_local.c2
-rw-r--r--channels/chan_sip.c11
2 files changed, 12 insertions, 1 deletions
diff --git a/channels/chan_local.c b/channels/chan_local.c
index beac4064e..b4072cecc 100644
--- a/channels/chan_local.c
+++ b/channels/chan_local.c
@@ -495,6 +495,8 @@ static int local_hangup(struct ast_channel *ast)
return -1;
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 (isoutbound) {
const char *status = pbx_builtin_getvar_helper(p->chan, "DIALSTATUS");
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 6c9ea335d..9cebd9dab 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -752,7 +752,7 @@ struct sip_auth {
#define SIP_REALTIME (1 << 11) /*!< P: Flag for realtime users */
#define SIP_USECLIENTCODE (1 << 12) /*!< DP: Trust X-ClientCode info message */
#define SIP_OUTGOING (1 << 13) /*!< D: Direction of the last transaction in this dialog */
-#define SIP_FREE_BIT (1 << 14) /*!< ---- */
+#define SIP_DIALOG_ANSWEREDELSEWHERE (1 << 14) /*!< D: This call is cancelled due to answer on another channel */
#define SIP_DEFER_BYE_ON_TRANSFER (1 << 15) /*!< D: Do not hangup at first ast_hangup */
#define SIP_DTMF (3 << 16) /*!< DP: DTMF Support: four settings, uses two bits */
#define SIP_DTMF_RFC2833 (0 << 16) /*!< DP: DTMF Support: RTP DTMF - "rfc2833" */
@@ -3674,6 +3674,12 @@ 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, AST_FLAG_ANSWERED_ELSEWHERE)) {
+ if (option_debug)
+ ast_log(LOG_DEBUG, "This call was answered elsewhere");
+ append_history(p, "Cancel", "Call answered elsewhere");
+ ast_set_flag(&p->flags[0], SIP_DIALOG_ANSWEREDELSEWHERE);
+ }
if (ast_test_flag(&p->flags[0], SIP_DEFER_BYE_ON_TRANSFER)) {
if (ast_test_flag(&p->flags[0], SIP_INC_COUNT)) {
@@ -8140,6 +8146,9 @@ static int transmit_request(struct sip_pvt *p, int sipmethod, int seqno, enum xm
p->invitestate = INV_CONFIRMED;
reqprep(&resp, p, sipmethod, seqno, newbranch);
+ if (sipmethod == SIP_CANCEL && ast_test_flag(&p->flags[0], SIP_DIALOG_ANSWEREDELSEWHERE))
+ add_header(&resp, "Reason:", "SIP;cause=200;text=\"Call completed elsewhere\"");
+
add_header_contentLength(&resp, 0);
return send_request(p, &resp, reliable, seqno ? seqno : p->ocseq);
}