]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
expand notify thing to let you pick a certian call_id instead of user@host
authorAnthony Minessale <anthony.minessale@gmail.com>
Fri, 26 Sep 2008 17:00:30 +0000 (17:00 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Fri, 26 Sep 2008 17:00:30 +0000 (17:00 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@9659 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/endpoints/mod_sofia/mod_sofia.c

index 0c5182efd7db97dbd16acf7a349edc3d3ce7ac1b..6f45aa91d4418d08f33708d6831aa9cebd4e72b6 100644 (file)
@@ -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);
                        }
                        
                }