This commit is contained in:
Raymond Chandler 2013-01-09 18:18:07 -05:00
parent 5ae5803e63
commit c7c4bda847
3 changed files with 49 additions and 39 deletions

View File

@ -5191,8 +5191,7 @@ static void general_event_handler(switch_event_t *event)
return;
}
if (to_uri && from_uri && ct && es && profile_name && (profile = sofia_glue_find_profile(profile_name))) {
if (to_uri && from_uri && ct && es) {
sofia_destination_t *dst = NULL;
nua_handle_t *nh;
char *route_uri = NULL;

View File

@ -29,7 +29,7 @@
* Bret McDanel <trixter AT 0xdecafbad.com>
* Marcel Barbulescu <marcelbarbulescu@gmail.com>
* Norman Brandinger
* Raymond Chandler <intralanman@gmail.com>
* Raymond Chandler <intralanman@freeswitch.org>
* Nathan Patrick <npatrick at corp.sonic.net>
* Joseph Sullivan <jossulli@amazon.com>
*
@ -4047,8 +4047,6 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name)
}
} else if (!strcasecmp(var, "pnp-provision-url")) {
profile->pnp_prov_url = switch_core_strdup(profile->pool, val);
} else if (!strcasecmp(var, "pnp-notify-profile")) {
profile->pnp_notify_profile = switch_core_strdup(profile->pool, val);
} else if (!strcasecmp(var, "manage-presence")) {
if (!strcasecmp(val, "passive")) {
profile->pres_type = PRES_TYPE_PASSIVE;

View File

@ -27,7 +27,7 @@
* Ken Rice <krice@freeswitch.org>
* Paul D. Tinsley <pdt at jackhammer.org>
* Bret McDanel <trixter AT 0xdecafbad.com>
* Raymond Chandler <intralanman@gmail.com>
* Raymond Chandler <intralanman@freeswitch.org>
*
*
* sofia_presence.c -- SOFIA SIP Endpoint (presence code)
@ -3725,6 +3725,43 @@ void sofia_presence_handle_sip_i_subscribe(int status,
}
if ( sip->sip_event && sip->sip_event->o_type && !strcasecmp(sip->sip_event->o_type, "ua-profile") && contact_host ) {
char *uri = NULL;
char *ct = "application/url";
char *extra_headers = NULL;
if ( contact_port ) {
uri = switch_mprintf("sip:%s:%s", contact_host, contact_port);
} else {
uri = switch_mprintf("sip:%s", contact_host);
}
if ( uri ) {
switch_event_t *params = NULL;
/* Grandstream REALLY uses a header called Message Body */
extra_headers = switch_mprintf("MessageBody: %s\r\n", profile->pnp_prov_url);
nua_respond(nh, SIP_202_ACCEPTED, NUTAG_WITH_THIS_MSG(de->data->e_msg), TAG_END());
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "sending pnp NOTIFY for %s to provision to %s\n", uri, profile->pnp_prov_url);
switch_event_create(&params, SWITCH_EVENT_NOTIFY);
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "profile", profile->name);
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "event-string", sip->sip_event->o_type);
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "to-uri", uri);
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "from-uri", uri);
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "extra-headers", extra_headers);
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "content-type", ct);
switch_event_add_body(params, "%s", profile->pnp_prov_url);
switch_event_fire(&params);
switch_safe_free(uri);
switch_safe_free(extra_headers);
goto end;
}
}
if (status < 200) {
char *sticky = NULL;
char *contactstr = profile->url, *cs = NULL;
@ -3781,6 +3818,9 @@ void sofia_presence_handle_sip_i_subscribe(int status,
sip_to_tag(nh->nh_home, sip->sip_to, to_tag);
if (mod_sofia_globals.debug_presence > 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Responding to SUBSCRIBE with 202 Accepted\n");
}
nua_respond(nh, SIP_202_ACCEPTED,
SIPTAG_TO(sip->sip_to),
TAG_IF(new_contactstr, SIPTAG_CONTACT_STR(new_contactstr)),
@ -3791,6 +3831,9 @@ void sofia_presence_handle_sip_i_subscribe(int status,
switch_safe_free(sticky);
if (sub_state == nua_substate_terminated) {
if (mod_sofia_globals.debug_presence > 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Sending NOTIFY with Expires [0] and State [%s]\n", sstr);
}
nua_notify(nh,
SIPTAG_EXPIRES_STR("0"),
SIPTAG_SUBSCRIPTION_STATE_STR(sstr),
@ -3920,36 +3963,6 @@ void sofia_presence_handle_sip_i_subscribe(int status,
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Call-Id", call_id);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Sofia-Profile", profile->name);
switch_event_fire(&event);
} else if ( sip->sip_event && sip->sip_event->o_type && !strcasecmp(sip->sip_event->o_type, "ua-profile") && contact_host ) {
switch_event_t *params;
char *uri = NULL;
char *extra_headers = NULL;
if ( contact_port ) {
uri = switch_mprintf("sip:%s:%s", contact_host, contact_port);
} else {
uri = switch_mprintf("sip:%s", contact_host);
}
if ( uri ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "sending pnp NOTIFY to %s\n", uri);
/* Grandstream REALLY uses a header called Message Body */
extra_headers = switch_mprintf("MessageBody: %s\r\n", profile->pnp_prov_url);
switch_event_create(&params, SWITCH_EVENT_NOTIFY);
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "profile", profile->pnp_notify_profile);
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "event-string", sip->sip_event->o_type);
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "to-uri", uri);
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "from-uri", uri);
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "extra-headers", extra_headers);
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "content-type", "application/url");
switch_event_add_body(params, "%s", profile->pnp_prov_url);
switch_event_fire(&params);
switch_safe_free(uri);
switch_safe_free(extra_headers);
}
}
end: