From: Anthony Minessale Date: Fri, 3 May 2013 18:13:38 +0000 (-0500) Subject: FS-5365 --resolve X-Git-Tag: v1.2.9~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=749afaa7a32899518b6740af672951ed80d0d3b7;p=thirdparty%2Ffreeswitch.git FS-5365 --resolve --- diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index ccca1aaed9..29742b0a87 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -2016,6 +2016,32 @@ void event_handler(switch_event_t *event) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "\nCannot inject MWI event\n"); return; } + } else if ((subclass = switch_event_get_header_nil(event, "orig-event-subclass")) && !strcasecmp(subclass, MY_EVENT_UNREGISTER)) { + char *profile_name = switch_event_get_header_nil(event, "orig-profile-name"); + char *from_user = switch_event_get_header_nil(event, "orig-from-user"); + char *from_host = switch_event_get_header_nil(event, "orig-from-host"); + char *call_id = switch_event_get_header_nil(event, "orig-call-id"); + char *contact_str = switch_event_get_header_nil(event, "orig-contact"); + + sofia_profile_t *profile = NULL; + + if (!profile_name || !(profile = sofia_glue_find_profile(profile_name))) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Profile\n"); + return; + } + + if (sofia_test_pflag(profile, PFLAG_MULTIREG)) { + sql = switch_mprintf("delete from sip_registrations where call_id='%q'", call_id); + } else { + sql = switch_mprintf("delete from sip_registrations where sip_user='%q' and sip_host='%q'", from_user, from_host); + } + + sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Expired propagated registration for %s@%s->%s\n", from_user, from_host, contact_str); + + if (profile) { + sofia_glue_release_profile(profile); + } } else if ((subclass = switch_event_get_header_nil(event, "orig-event-subclass")) && !strcasecmp(subclass, MY_EVENT_REGISTER)) { char *from_user = switch_event_get_header_nil(event, "orig-from-user"); char *from_host = switch_event_get_header_nil(event, "orig-from-host");