From 701334c20ab7acabd026b8f243aa7ca1cfe38cb8 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Fri, 26 Sep 2008 17:00:30 +0000 Subject: [PATCH] expand notify thing to let you pick a certian call_id instead of user@host git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@9659 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/mod/endpoints/mod_sofia/mod_sofia.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index 0c5182efd7..6f45aa91d4 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -2166,20 +2166,31 @@ static void general_event_handler(switch_event_t *event) const char *es = switch_event_get_header(event, "event-string"); const char *user = switch_event_get_header(event, "user"); const char *host = switch_event_get_header(event, "host"); + const char *call_id = switch_event_get_header(event, "call-id"); const char *body = switch_event_get_body(event); sofia_profile_t *profile; if (profile_name && ct && es && user && host && (profile = sofia_glue_find_profile(profile_name))) { - char *sql = switch_mprintf("select sip_user,sip_host,contact,profile_name,'%q','%q','%q' " - "from sip_registrations where sip_user='%s' and sip_host='%q'", - ct, es, body, user, host - ); + char *sql; + + if (call_id) { + sql = switch_mprintf("select sip_user,sip_host,contact,profile_name,'%q','%q','%q' " + "from sip_registrations where call_id='%q'", ct, es, body, call_id + ); + } else { + sql = switch_mprintf("select sip_user,sip_host,contact,profile_name,'%q','%q','%q' " + "from sip_registrations where sip_user='%s' and sip_host='%q'", + ct, es, body, user, host + ); + } switch_mutex_lock(profile->ireg_mutex); sofia_glue_execute_sql_callback(profile, SWITCH_TRUE, NULL, sql, notify_callback, profile); switch_mutex_unlock(profile->ireg_mutex); sofia_glue_release_profile(profile); + + free(sql); } }