mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-11-08 12:34:53 +00:00
MODENDP-77 Gateway event subscriptions.
Merged with minor modifications. Still needs to add support for reload/rescan. git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@10525 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
1 parent
ee35d990d5
commit
d16d7ffd7d
6 files changed
+295
-13
No files matched your search
@@ -1617,12 +1617,66 @@ void sofia_presence_handle_sip_i_subscribe(int status,
|
||||
}
|
||||
}
|
||||
|
||||
sofia_gateway_subscription_t *sofia_find_gateway_subscription(sofia_gateway_t *gateway_ptr, const char *event) {
|
||||
sofia_gateway_subscription_t *gw_sub_ptr;
|
||||
for (gw_sub_ptr = gateway_ptr->subscriptions; gw_sub_ptr; gw_sub_ptr = gw_sub_ptr->next) {
|
||||
if (!strcasecmp(gw_sub_ptr->event, event)) {
|
||||
/* this is the gateway subscription we are interested in */
|
||||
return gw_sub_ptr;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void sofia_presence_handle_sip_r_subscribe(int status,
|
||||
char const *phrase,
|
||||
nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip,
|
||||
tagi_t tags[])
|
||||
{
|
||||
sip_event_t const *o = NULL;
|
||||
sofia_gateway_subscription_t *gw_sub_ptr;
|
||||
|
||||
if (!sip) {
|
||||
return;
|
||||
}
|
||||
|
||||
tl_gets(tags, SIPTAG_EVENT_REF(o), TAG_END());
|
||||
/* o->o_type: message-summary (for example) */
|
||||
if (!o) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Event information not given\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!sofia_private || !sofia_private->gateway) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Gateway information missing\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Find the subscription if one exists */
|
||||
if (!(gw_sub_ptr = sofia_find_gateway_subscription(sofia_private->gateway, o->o_type))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Could not find gateway subscription. Gateway: %s. Subscription Event: %s\n",
|
||||
sofia_private->gateway->name, o->o_type);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Update the subscription status for the subscription */
|
||||
switch (status) {
|
||||
case 200:
|
||||
/* TODO: in the spec it is possible for the other side to change the original expiry time,
|
||||
* this needs to be researched (eg, what sip header this information will be in) and implemented.
|
||||
* Although, since it seems the sofia stack is pretty much handling the subscription expiration
|
||||
* anyway, then maybe its not even worth bothering.
|
||||
*/
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "got 200 OK response, updated state to SUB_STATE_SUBSCRIBE.\n");
|
||||
gw_sub_ptr->state = SUB_STATE_SUBSCRIBE;
|
||||
break;
|
||||
case 100:
|
||||
break;
|
||||
default:
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "status (%d) != 200, updated state to SUB_STATE_FAILED.\n", status);
|
||||
gw_sub_ptr->state = SUB_STATE_FAILED;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void sofia_presence_handle_sip_i_publish(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip,
|
||||
|
||||
Reference in new issue
Block a user