]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
adding test_sql and network_ip to sub callback
authorBrian West <brian@freeswitch.org>
Thu, 4 Jun 2009 01:18:00 +0000 (01:18 +0000)
committerBrian West <brian@freeswitch.org>
Thu, 4 Jun 2009 01:18:00 +0000 (01:18 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@13602 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/endpoints/mod_sofia/sofia_glue.c
src/mod/endpoints/mod_sofia/sofia_presence.c

index e2d5e29976b2026eb65cd4df8a1ce7939a3825ba..a83336304ebc8560efc6fe3e15b345cf4023b0b8 100644 (file)
@@ -3570,7 +3570,8 @@ int sofia_glue_init_sql(sofia_profile_t *profile)
                "   user_agent      VARCHAR(255),\n" 
                "   accept          VARCHAR(255),\n"
                "   profile_name    VARCHAR(255),\n"
-               "   hostname        VARCHAR(255)\n"
+               "   hostname        VARCHAR(255),\n"
+               "   network_ip      VARCHAR(255)\n"
                ");\n";
 
        char auth_sql[] = 
@@ -3621,6 +3622,7 @@ int sofia_glue_init_sql(sofia_profile_t *profile)
                        "create index sr_sip_realm on sip_registrations (sip_realm)",
                        "create index ss_call_id on sip_subscriptions (call_id)",
                        "create index ss_hostname on sip_subscriptions (hostname)",
+                       "create index ss_hostname on sip_subscriptions (network_ip)",
                        "create index ss_sip_user on sip_subscriptions (sip_user)",
                        "create index ss_sip_host on sip_subscriptions (sip_host)",
                        "create index ss_presence_hosts on sip_subscriptions (presence_hosts)",
@@ -3634,16 +3636,15 @@ int sofia_glue_init_sql(sofia_profile_t *profile)
                        "create index sa_nonce on sip_authentication (nonce)",
                        "create index sa_hostname on sip_authentication (hostname)",
                        "create index ssa_hostname on sip_shared_appearance_subscriptions (hostname)",
+                       "create index ssa_hostname on sip_shared_appearance_subscriptions (network_ip)",
                        "create index ssa_subscriber on sip_shared_appearance_subscriptions (subscriber)",
                        "create index ssa_profile_name on sip_shared_appearance_subscriptions (profile_name)",
                        "create index ssa_aor on sip_shared_appearance_subscriptions (aor)",
-
                        "create index ssd_profile_name on sip_shared_appearance_dialogs (profile_name)",
                        "create index ssd_hostname on sip_shared_appearance_dialogs (hostname)",
                        "create index ssd_contact_str on sip_shared_appearance_dialogs (contact_str)",
                        "create index ssd_call_id on sip_shared_appearance_dialogs (call_id)",
                        "create index ssd_expires on sip_shared_appearance_dialogs (expires)",
-                       
                        NULL    
                };
 
@@ -3700,7 +3701,7 @@ int sofia_glue_init_sql(sofia_profile_t *profile)
                }
                free(test_sql);
 
-               test_sql = switch_mprintf("delete from sip_shared_appearance_subscriptions where contact_str='' or hostname='%q'", mod_sofia_globals.hostname);
+               test_sql = switch_mprintf("delete from sip_shared_appearance_subscriptions where contact_str='' or network_ip='%q'", mod_sofia_globals.hostname);
                if (switch_odbc_handle_exec(profile->master_odbc, test_sql, NULL) != SWITCH_ODBC_SUCCESS) {
                        switch_odbc_handle_exec(profile->master_odbc, "DROP TABLE sip_shared_appearance_subscriptions", NULL);
                        switch_odbc_handle_exec(profile->master_odbc, shared_appearance_sql, NULL);
@@ -3737,7 +3738,7 @@ int sofia_glue_init_sql(sofia_profile_t *profile)
                switch_core_db_test_reactive(profile->master_db, test_sql, "DROP TABLE sip_registrations", reg_sql);
                free(test_sql);
 
-               test_sql = switch_mprintf("delete from sip_subscriptions where hostname='%q'", mod_sofia_globals.hostname);
+               test_sql = switch_mprintf("delete from sip_subscriptions where network_ip='%q'", mod_sofia_globals.hostname);
                switch_core_db_test_reactive(profile->master_db, test_sql, "DROP TABLE sip_subscriptions", sub_sql);
                free(test_sql);
                
@@ -3754,7 +3755,7 @@ int sofia_glue_init_sql(sofia_profile_t *profile)
                free(test_sql);
 
                
-               test_sql = switch_mprintf("delete from sip_shared_appearance_subscriptions where contact_str = '' or hostname='%q'", mod_sofia_globals.hostname);
+               test_sql = switch_mprintf("delete from sip_shared_appearance_subscriptions where contact_str = '' or network_ip='%q'", mod_sofia_globals.hostname);
                switch_core_db_test_reactive(profile->master_db, test_sql, "DROP TABLE sip_shared_appearance_subscriptions", shared_appearance_sql);
                free(test_sql);
 
@@ -3775,6 +3776,8 @@ int sofia_glue_init_sql(sofia_profile_t *profile)
                                                        NULL, NULL, NULL);
                switch_core_db_exec(profile->master_db, "create index if not exists ssd_hostname on sip_shared_appearance_dialogs (hostname)", 
                                                        NULL, NULL, NULL);
+               switch_core_db_exec(profile->master_db, "create index if not exists ssd_hostname on sip_shared_appearance_dialogs (network_ip)", 
+                                                       NULL, NULL, NULL);
                switch_core_db_exec(profile->master_db, "create index if not exists ssd_contact_str on sip_shared_appearance_dialogs (contact_str)",  
                                                        NULL, NULL, NULL);
                switch_core_db_exec(profile->master_db, "create index if not exists ssd_call_id on sip_shared_appearance_dialogs (call_id)",  
@@ -3801,6 +3804,7 @@ int sofia_glue_init_sql(sofia_profile_t *profile)
 
                switch_core_db_exec(profile->master_db, "create index if not exists ss_call_id on sip_subscriptions (call_id)", NULL, NULL, NULL);
                switch_core_db_exec(profile->master_db, "create index if not exists ss_hostname on sip_subscriptions (hostname)", NULL, NULL, NULL);
+               switch_core_db_exec(profile->master_db, "create index if not exists ss_hostname on sip_subscriptions (network_ip)", NULL, NULL, NULL);
                switch_core_db_exec(profile->master_db, "create index if not exists ss_sip_user on sip_subscriptions (sip_user)", NULL, NULL, NULL);
                switch_core_db_exec(profile->master_db, "create index if not exists ss_sip_host on sip_subscriptions (sip_host)", NULL, NULL, NULL);
                switch_core_db_exec(profile->master_db, "create index if not exists ss_presence_hosts on sip_subscriptions (presence_hosts)", NULL, NULL, NULL);
index 013ec4ee6d78de55dde16d9f6ed637a27339976c..eca5206e98aaef49268a91160309db3e3c117fdc 100644 (file)
@@ -209,7 +209,7 @@ void sofia_presence_cancel(void)
        
        if ((sql = switch_mprintf(
                                                          "select proto,sip_user,sip_host,sub_to_user,sub_to_host,event,contact,call_id,full_from,"
-                                                         "full_via,expires,user_agent,accept,profile_name"
+                                                         "full_via,expires,user_agent,accept,profile_name,network_ip"
                                                          ",-1,'unavailable','unavailable' from sip_subscriptions where event='presence' and hostname='%q'", 
                                                          mod_sofia_globals.hostname))) {
                switch_mutex_lock(mod_sofia_globals.hash_mutex);
@@ -354,13 +354,13 @@ static void actual_sofia_presence_mwi_event_handler(switch_event_t *event)
 
        if (for_everyone) {
                sql = switch_mprintf("select proto,sip_user,sip_host,sub_to_user,sub_to_host,event,contact,call_id,full_from,"
-                                                        "full_via,expires,user_agent,accept,profile_name"
+                                                        "full_via,expires,user_agent,accept,profile_name,network_ip"
                                                         ",'%q','%q' from sip_subscriptions where event='message-summary' "
                                                         "and sub_to_user='%q' and (sub_to_host='%q' or presence_hosts like '%%%q%%')",
                                                         stream.data, host, user, host, host);
        } else if (sub_call_id) {
                sql = switch_mprintf("select proto,sip_user,sip_host,sub_to_user,sub_to_host,event,contact,call_id,full_from,"
-                                                        "full_via,expires,user_agent,accept,profile_name"
+                                                        "full_via,expires,user_agent,accept,profile_name,network_ip"
                                                         ",'%q','%q' from sip_subscriptions where event='message-summary' "
                                                         "and sub_to_user='%q' and (sub_to_host='%q' or presence_hosts like '%%%q%%' and call_id='%q')",
                                                         stream.data, host, user, host, host, sub_call_id);
@@ -446,7 +446,7 @@ static void actual_sofia_presence_event_handler(switch_event_t *event)
                                                                 "sip_subscriptions.sub_to_user,sip_subscriptions.sub_to_host,sip_subscriptions.event,"
                                                                 "sip_subscriptions.contact,sip_subscriptions.call_id,sip_subscriptions.full_from,"
                                                                 "sip_subscriptions.full_via,sip_subscriptions.expires,sip_subscriptions.user_agent,"
-                                                                "sip_subscriptions.accept,sip_subscriptions.profile_name"
+                                                                "sip_subscriptions.accept,sip_subscriptions.profile_name,sip_subscriptions.network_ip"
                                                                 ",1,'%q','%q',sip_presence.status,sip_presence.rpid "
                                                                 "from sip_subscriptions left join sip_presence on "
                                                                 "(sip_subscriptions.sub_to_user=sip_presence.sip_user and sip_subscriptions.sub_to_host=sip_presence.sip_host and "
@@ -459,7 +459,7 @@ static void actual_sofia_presence_event_handler(switch_event_t *event)
                                                                 "sip_subscriptions.sub_to_user,sip_subscriptions.sub_to_host,sip_subscriptions.event,"
                                                                 "sip_subscriptions.contact,sip_subscriptions.call_id,sip_subscriptions.full_from,"
                                                                 "sip_subscriptions.full_via,sip_subscriptions.expires,sip_subscriptions.user_agent,"
-                                                                "sip_subscriptions.accept,sip_subscriptions.profile_name"
+                                                                "sip_subscriptions.accept,sip_subscriptions.profile_name,sip_subscriptions.network_ip"
                                                                 ",1,'%q','%q',sip_presence.status,sip_presence.rpid "
                                                                 "from sip_subscriptions left join sip_presence on "
                                                                 "(sip_subscriptions.sub_to_user=sip_presence.sip_user and sip_subscriptions.sub_to_host=sip_presence.sip_host and "
@@ -1777,15 +1777,12 @@ void sofia_presence_handle_sip_i_subscribe(int status,
 
                        sql = switch_mprintf("insert into sip_subscriptions "
                                                                 "(proto,sip_user,sip_host,sub_to_user,sub_to_host,presence_hosts,event,contact,call_id,full_from,"
-                                                                "full_via,expires,user_agent,accept,profile_name,hostname) "
-                                                                "values ('%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q',%ld,'%q','%q','%q','%q')",
+                                                                "full_via,expires,user_agent,accept,profile_name,hostname,network_ip) "
+                                                                "values ('%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q',%ld,'%q','%q','%q','%q','%q')",
                                                                 proto, from_user, from_host, to_user, to_host, profile->presence_hosts ? profile->presence_hosts : to_host, 
                                                                 event, contact_str, call_id, full_from, full_via, 
-
                                                                 exp_delta * -1, 
-                                                                //exp_abs + SUB_OVERLAP, 
-
-                                                                full_agent, accept, profile->name,mod_sofia_globals.hostname);
+                                                                full_agent, accept, profile->name,mod_sofia_globals.hostname, network_ip);
                                                                 
                        
                        if (mod_sofia_globals.debug_presence > 0) {