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);
}
}
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);
}
}
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);
}
" 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[] =
"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)",
}
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);
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);
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);