diff options
author | file <file@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-11-08 01:28:56 +0000 |
---|---|---|
committer | file <file@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-11-08 01:28:56 +0000 |
commit | ef6203ef48e940ea4394880e79e9a836b21adf58 (patch) | |
tree | 7d135a9e8111c759f49ed58d0e0858d257a54720 | |
parent | 1dd833fd025c0776df6435b3b005cbdf17060b1d (diff) |
Improve the devicestate logic for multiple devices. If any are available then the extension is considered available.
(closes issue #10164)
Reported by: nic_bellamy
Patches:
sip-hinting-svn-branch-1.4.patch uploaded by nic (license 299)
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@89099 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r-- | channels/chan_sip.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 640a5ecdf..84cbdfc26 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -7087,13 +7087,22 @@ static int transmit_state_notify(struct sip_pvt *p, int state, int full, int tim /* Check which device/devices we are watching and if they are registered */ if (ast_get_hint(hint, sizeof(hint), NULL, 0, NULL, p->context, p->exten)) { char *hint2 = hint, *individual_hint = NULL; + int hint_count = 0, unavailable_count = 0; + while ((individual_hint = strsep(&hint2, "&"))) { - /* If they are not registered, we will override notification and show no availability */ - if (ast_device_state(individual_hint) == AST_DEVICE_UNAVAILABLE) { - local_state = NOTIFY_CLOSED; - pidfstate = "away"; - pidfnote = "Not online"; - } + hint_count++; + + if (ast_device_state(individual_hint) == AST_DEVICE_UNAVAILABLE) + unavailable_count++; + } + + /* If none of the hinted devices are registered, we will + * override notification and show no availability. + */ + if (hint_count > 0 && hint_count == unavailable_count) { + local_state = NOTIFY_CLOSED; + pidfstate = "away"; + pidfnote = "Not online"; } } |