Revision
15420
Author
anthm
Date
2009-11-10 20:10:41 -0600 (Tue, 10 Nov 2009)

Log Message

add cols to sip_dialogs

Modified Paths

Diff

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c (15419 => 15420)


--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c	2009-11-11 01:50:43 UTC (rev 15419)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c	2009-11-11 02:10:41 UTC (rev 15420)
@@ -1167,6 +1167,19 @@
 	case SWITCH_MESSAGE_INDICATE_ANSWER:
 	case SWITCH_MESSAGE_INDICATE_PROGRESS:
 		{
+			const char *presence_data = switch_channel_get_variable(channel, "presence_data");
+			const char *presence_id = switch_channel_get_variable(channel, "presence_id");
+			char *sql;
+			
+			if (presence_id || presence_data) {
+				sql = switch_mprintf("update sip_dialogs set presence_id='%q',presence_data='%q' "
+									 "where uuid='%s';\n", switch_str_nil(presence_id), switch_str_nil(presence_data), 
+									 switch_core_session_get_uuid(session));
+			}
+
+			switch_assert(sql);
+			sofia_glue_execute_sql(tech_pvt->profile, &sql, SWITCH_TRUE);
+
 			const char *var;
 			if ((var = switch_channel_get_variable(channel, SOFIA_SECURE_MEDIA_VARIABLE)) && switch_true(var)) {
 				sofia_set_flag_locked(tech_pvt, TFLAG_SECURE);

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (15419 => 15420)


--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c	2009-11-11 01:50:43 UTC (rev 15419)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c	2009-11-11 02:10:41 UTC (rev 15420)
@@ -3451,7 +3451,7 @@
 				const char *from_user = "", *from_host = "", *to_user = "", *to_host = "", *contact_user = "", *contact_host = "";
 				const char *user_agent = "", *call_id = "";
 				char *sql = NULL;
-
+				
 				if (sip->sip_user_agent) {
 					user_agent = switch_str_nil(sip->sip_user_agent->g_string);
 				}
@@ -3476,23 +3476,38 @@
 				}
 
 				if (profile->pres_type) {
+					const char *presence_data = switch_channel_get_variable(channel, "presence_data");
+					const char *presence_id = switch_channel_get_variable(channel, "presence_id");
+					char *full_contact = "";
+					
+					if (sip->sip_contact) {
+						full_contact = sip_header_as_string(nua_handle_home(tech_pvt->nh), (void *) sip->sip_contact);
+					}
+					
 					sql = switch_mprintf("insert into sip_dialogs "
 										 "(call_id,uuid,sip_to_user,sip_to_host,sip_from_user,sip_from_host,contact_user,"
-										 "contact_host,state,direction,user_agent,profile_name,hostname) "
-										 "values('%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q')",
+										 "contact_host,state,direction,user_agent,profile_name,hostname,contact,presence_id, presence_data) "
+										 "values('%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q')",
 										 call_id,
 										 switch_core_session_get_uuid(session),
 										 to_user, to_host, from_user, from_host, contact_user, 
 										 contact_host, astate, "outbound", user_agent,
-										 profile->name, mod_sofia_globals.hostname);
-
+										 profile->name, mod_sofia_globals.hostname, switch_str_nil(full_contact),
+										 switch_str_nil(presence_id), switch_str_nil(presence_data));
+					
 					switch_assert(sql);
 
 					sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE);
+
 				}
 			} else if (status == 200 && (profile->pres_type)) {
 				char *sql = NULL;
-				sql = switch_mprintf("update sip_dialogs set state='%s' where uuid='%s';\n", astate, switch_core_session_get_uuid(session));
+				const char *presence_data = switch_channel_get_variable(channel, "presence_data");
+				const char *presence_id = switch_channel_get_variable(channel, "presence_id");
+
+				sql = switch_mprintf("update sip_dialogs set state='%q',presence_id='%q',presence_data='%q' "
+									 "where uuid='%s';\n", astate, switch_str_nil(presence_id), switch_str_nil(presence_data), 
+									 switch_core_session_get_uuid(session));
 				switch_assert(sql);
 				sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE);
 			}
@@ -5819,16 +5834,27 @@
 		}
 
 		if (profile->pres_type) {
+			const char *presence_data = switch_channel_get_variable(channel, "presence_data");
+			const char *presence_id = switch_channel_get_variable(channel, "presence_id");
+			char *full_contact = "";
+
+			if (sip->sip_contact) {
+				full_contact = sip_header_as_string(nua_handle_home(tech_pvt->nh), (void *) sip->sip_contact);
+			}
+			
 			sql = switch_mprintf("insert into sip_dialogs "
 								 "(call_id,uuid,sip_to_user,sip_to_host,sip_from_user,sip_from_host,contact_user,"
-								 "contact_host,state,direction,user_agent,profile_name,hostname) "
-								 "values('%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q')",
+								 "contact_host,state,direction,user_agent,profile_name,hostname,contact,presence_id,presence_data) "
+								 "values('%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q')",
 								 call_id,
 								 tech_pvt->sofia_private->uuid,
 								 to_user, to_host, dialog_from_user, dialog_from_host, 
 								 contact_user, contact_host, "confirmed", "inbound", user_agent,
-								 profile->name, mod_sofia_globals.hostname);
+								 profile->name, mod_sofia_globals.hostname, switch_str_nil(full_contact), 
+								 switch_str_nil(presence_id), switch_str_nil(presence_data));
+
 			switch_assert(sql);
+			
 			sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE);
 		}
 

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c (15419 => 15420)


--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c	2009-11-11 01:50:43 UTC (rev 15419)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c	2009-11-11 02:10:41 UTC (rev 15420)
@@ -3657,7 +3657,10 @@
 		"   direction       VARCHAR(255),\n" 
 		"   user_agent      VARCHAR(255),\n" 
 		"   profile_name    VARCHAR(255),\n"
-        "   hostname        VARCHAR(255)\n"
+        "   hostname        VARCHAR(255),\n"
+        "   contact         VARCHAR(255),\n"
+        "   presence_id     VARCHAR(255),\n"
+        "   presence_data   VARCHAR(255)\n"
 		");\n";
 
 	char sub_sql[] =
@@ -3750,6 +3753,9 @@
 			"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_contact on sip_shared_appearance_dialogs (contact)",
+			"create index ssd_presence_id on sip_shared_appearance_dialogs (presence_id)",
+			"create index ssd_presence_data on sip_shared_appearance_dialogs (presence_data)",
 			"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)",
@@ -3787,7 +3793,7 @@
 		}
 
 		free(test_sql);
-		test_sql = switch_mprintf("delete from sip_dialogs where hostname='%q'", mod_sofia_globals.hostname);
+		test_sql = switch_mprintf("delete from sip_dialogs where hostname='%q' and contact like '%%'", 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_dialogs", NULL);
@@ -3852,7 +3858,7 @@
 		switch_core_db_test_reactive(profile->master_db, test_sql, "DROP TABLE sip_subscriptions", sub_sql);
 		free(test_sql);
 
-		test_sql = switch_mprintf("delete from sip_dialogs where hostname='%q'", mod_sofia_globals.hostname);
+		test_sql = switch_mprintf("delete from sip_dialogs where hostname='%q' and contact like '%%'", mod_sofia_globals.hostname);
 		switch_core_db_test_reactive(profile->master_db, test_sql, "DROP TABLE sip_dialogs", dialog_sql);
 		free(test_sql);
 
@@ -3926,6 +3932,9 @@
 
 		switch_core_db_exec(profile->master_db, "create index if not exists sd_uuid on sip_dialogs (uuid)", NULL, NULL, NULL);
 		switch_core_db_exec(profile->master_db, "create index if not exists sd_hostname on sip_dialogs (hostname)", NULL, NULL, NULL);
+		switch_core_db_exec(profile->master_db, "create index if not exists sd_hostname on sip_dialogs (contact)", NULL, NULL, NULL);
+		switch_core_db_exec(profile->master_db, "create index if not exists sd_hostname on sip_dialogs (presence_id)", NULL, NULL, NULL);
+		switch_core_db_exec(profile->master_db, "create index if not exists sd_hostname on sip_dialogs (presence_data)", NULL, NULL, NULL);
 
 		switch_core_db_exec(profile->master_db, "create index if not exists sp_hostname on sip_presence (hostname)", NULL, NULL, NULL);