[svn-commits] russell: branch russell/events r59235 -
/team/russell/events/channels/chan_sip.c
svn-commits at lists.digium.com
svn-commits at lists.digium.com
Mon Mar 26 15:21:31 MST 2007
Author: russell
Date: Mon Mar 26 17:21:30 2007
New Revision: 59235
URL: http://svn.digium.com/view/asterisk?view=rev&rev=59235
Log:
If chan_sip is configured to send MWI for a peer even if they have not
subscribed to it, then create the MWI event subscription when the peer is
created. Otherwise, wait until they subscribe to it.
Modified:
team/russell/events/channels/chan_sip.c
Modified: team/russell/events/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/russell/events/channels/chan_sip.c?view=diff&rev=59235&r1=59234&r2=59235
==============================================================================
--- team/russell/events/channels/chan_sip.c (original)
+++ team/russell/events/channels/chan_sip.c Mon Mar 26 17:21:30 2007
@@ -1032,7 +1032,6 @@
before strolling to the Grokyzpå
(A bit unsure of this, please correct if
you know more) */
- struct ast_event_sub *mwi_event_sub; /*!< The MWI event subscription */
};
static struct sip_pvt *dialoglist = NULL;
@@ -1161,6 +1160,7 @@
struct ast_variable *chanvars; /*!< Variables to set for channel created by user */
struct sip_pvt *mwipvt; /*!< Subscription for MWI */
int autoframing;
+ struct ast_event_sub *mwi_event_sub; /*!< The MWI event subscription */
};
@@ -2597,6 +2597,11 @@
if (peer->mwipvt) /* We have an active subscription, delete it */
sip_destroy(peer->mwipvt);
+ if (peer->mwi_event_sub) {
+ ast_event_unsubscribe(peer->mwi_event_sub);
+ peer->mwi_event_sub = NULL;
+ }
+
if (peer->chanvars) {
ast_variables_destroy(peer->chanvars);
peer->chanvars = NULL;
@@ -3194,9 +3199,6 @@
/* Remove link from peer to subscription of MWI */
if (p->relatedpeer && p->relatedpeer->mwipvt)
p->relatedpeer->mwipvt = NULL;
-
- if (p->mwi_event_sub)
- ast_event_unsubscribe(p->mwi_event_sub);
if (dumphistory)
sip_dump_history(p);
@@ -15153,9 +15155,11 @@
}
p->subscribed = MWI_NOTIFICATION;
- p->mwi_event_sub = ast_event_subscribe(AST_EVENT_MWI, mwi_event_cb,
- AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, authpeer->mailbox,
- AST_EVENT_IE_END);
+ if (ast_test_flag(&authpeer->flags[1], SIP_PAGE2_SUBSCRIBEMWIONLY)) {
+ authpeer->mwi_event_sub = ast_event_subscribe(AST_EVENT_MWI, mwi_event_cb,
+ AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, authpeer->mailbox,
+ AST_EVENT_IE_END);
+ }
if (authpeer->mwipvt && authpeer->mwipvt != p) /* Destroy old PVT if this is a new one */
/* We only allow one subscription per peer */
sip_destroy(authpeer->mwipvt);
@@ -16613,7 +16617,6 @@
struct ast_flags peerflags[2] = {{(0)}};
struct ast_flags mask[2] = {{(0)}};
char callback[256] = "";
-
if (!realtime)
/* Note we do NOT use find_peer here, to avoid realtime recursion */
@@ -16853,7 +16856,18 @@
global_allowsubscribe = TRUE; /* No global ban any more */
if (!found && ast_test_flag(&peer->flags[1], SIP_PAGE2_DYNAMIC) && !ast_test_flag(&peer->flags[0], SIP_REALTIME))
reg_source_db(peer);
+
+ /* If they didn't request that MWI is sent *only* on subscribe, go ahead and
+ * subscribe to it now. */
+ if (!ast_test_flag(&peer->flags[1], SIP_PAGE2_SUBSCRIBEMWIONLY) &&
+ !ast_strlen_zero(peer->mailbox)) {
+ peer->mwi_event_sub = ast_event_subscribe(AST_EVENT_MWI, mwi_event_cb,
+ AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, peer->mailbox,
+ AST_EVENT_IE_END);
+ }
+
ASTOBJ_UNMARK(peer);
+
ast_free_ha(oldha);
if (!ast_strlen_zero(callback)) { /* build string from peer info */
char *reg_string;
More information about the svn-commits
mailing list