add presence-probe-on-register sofia param to send a probe on register instead of presence to deal with some broken phones and add some general improvements to allow multi homed presence
This commit is contained in:
parent
f987903e5e
commit
143949941c
|
@ -132,6 +132,8 @@
|
||||||
<param name="record-template" value="${caller_id_number}.${target_domain}.${strftime(%Y-%m-%d-%H-%M-%S)}.wav"/>
|
<param name="record-template" value="${caller_id_number}.${target_domain}.${strftime(%Y-%m-%d-%H-%M-%S)}.wav"/>
|
||||||
<!--enable to use presence -->
|
<!--enable to use presence -->
|
||||||
<param name="manage-presence" value="true"/>
|
<param name="manage-presence" value="true"/>
|
||||||
|
<!-- send a presence probe on each register to query devices to send presence instead of sending presence with less info -->
|
||||||
|
<!--<param name="presence-probe-on-register" value="true"/>-->
|
||||||
<!--<param name="manage-shared-appearance" value="true"/>-->
|
<!--<param name="manage-shared-appearance" value="true"/>-->
|
||||||
<!-- used to share presence info across sofia profiles -->
|
<!-- used to share presence info across sofia profiles -->
|
||||||
<!-- Name of the db to use for this profile -->
|
<!-- Name of the db to use for this profile -->
|
||||||
|
|
|
@ -3936,7 +3936,7 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
|
||||||
dest_num = p + 5;
|
dest_num = p + 5;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
if (profile->pres_type) {
|
if (profile->pres_type) {
|
||||||
char *sql;
|
char *sql;
|
||||||
|
@ -3957,6 +3957,7 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
|
||||||
sofia_glue_actually_execute_sql(profile, sql, profile->ireg_mutex);
|
sofia_glue_actually_execute_sql(profile, sql, profile->ireg_mutex);
|
||||||
switch_safe_free(sql);
|
switch_safe_free(sql);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
caller_profile = switch_caller_profile_clone(nsession, outbound_profile);
|
caller_profile = switch_caller_profile_clone(nsession, outbound_profile);
|
||||||
|
|
||||||
|
|
|
@ -224,6 +224,7 @@ typedef enum {
|
||||||
PFLAG_IN_DIALOG_CHAT,
|
PFLAG_IN_DIALOG_CHAT,
|
||||||
PFLAG_DEL_SUBS_ON_REG,
|
PFLAG_DEL_SUBS_ON_REG,
|
||||||
PFLAG_IGNORE_183NOSDP,
|
PFLAG_IGNORE_183NOSDP,
|
||||||
|
PFLAG_PRESENCE_PROBE_ON_REGISTER,
|
||||||
/* No new flags below this line */
|
/* No new flags below this line */
|
||||||
PFLAG_MAX
|
PFLAG_MAX
|
||||||
} PFLAGS;
|
} PFLAGS;
|
||||||
|
|
|
@ -2405,6 +2405,12 @@ switch_status_t reconfig_sofia(sofia_profile_t *profile)
|
||||||
} else {
|
} else {
|
||||||
sofia_clear_pflag(profile, PFLAG_IGNORE_183NOSDP);
|
sofia_clear_pflag(profile, PFLAG_IGNORE_183NOSDP);
|
||||||
}
|
}
|
||||||
|
} else if (!strcasecmp(var, "presence-probe-on-register")) {
|
||||||
|
if (switch_true(val)) {
|
||||||
|
sofia_set_pflag(profile, PFLAG_PRESENCE_PROBE_ON_REGISTER);
|
||||||
|
} else {
|
||||||
|
sofia_clear_pflag(profile, PFLAG_PRESENCE_PROBE_ON_REGISTER);
|
||||||
|
}
|
||||||
} else if (!strcasecmp(var, "cid-in-1xx")) {
|
} else if (!strcasecmp(var, "cid-in-1xx")) {
|
||||||
if (switch_true(val)) {
|
if (switch_true(val)) {
|
||||||
sofia_set_pflag(profile, PFLAG_CID_IN_1XX);
|
sofia_set_pflag(profile, PFLAG_CID_IN_1XX);
|
||||||
|
@ -3070,6 +3076,12 @@ switch_status_t config_sofia(int reload, char *profile_name)
|
||||||
} else {
|
} else {
|
||||||
sofia_clear_pflag(profile, PFLAG_IGNORE_183NOSDP);
|
sofia_clear_pflag(profile, PFLAG_IGNORE_183NOSDP);
|
||||||
}
|
}
|
||||||
|
} else if (!strcasecmp(var, "presence-probe-on-register")) {
|
||||||
|
if (switch_true(val)) {
|
||||||
|
sofia_set_pflag(profile, PFLAG_PRESENCE_PROBE_ON_REGISTER);
|
||||||
|
} else {
|
||||||
|
sofia_clear_pflag(profile, PFLAG_PRESENCE_PROBE_ON_REGISTER);
|
||||||
|
}
|
||||||
} else if (!strcasecmp(var, "cid-in-1xx")) {
|
} else if (!strcasecmp(var, "cid-in-1xx")) {
|
||||||
if (switch_true(val)) {
|
if (switch_true(val)) {
|
||||||
sofia_set_pflag(profile, PFLAG_CID_IN_1XX);
|
sofia_set_pflag(profile, PFLAG_CID_IN_1XX);
|
||||||
|
@ -4420,7 +4432,6 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status
|
||||||
contact_host, astate, "outbound", user_agent,
|
contact_host, astate, "outbound", user_agent,
|
||||||
profile->name, mod_sofia_globals.hostname, switch_str_nil(full_contact),
|
profile->name, mod_sofia_globals.hostname, switch_str_nil(full_contact),
|
||||||
switch_str_nil(presence_id), switch_str_nil(presence_data), switch_str_nil(p));
|
switch_str_nil(presence_id), switch_str_nil(presence_data), switch_str_nil(p));
|
||||||
|
|
||||||
switch_assert(sql);
|
switch_assert(sql);
|
||||||
|
|
||||||
sofia_glue_actually_execute_sql(profile, sql, profile->ireg_mutex);
|
sofia_glue_actually_execute_sql(profile, sql, profile->ireg_mutex);
|
||||||
|
@ -6872,8 +6883,9 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_
|
||||||
|
|
||||||
sql =
|
sql =
|
||||||
switch_mprintf
|
switch_mprintf
|
||||||
("select call_id from sip_dialogs where call_info='%q' and sip_from_user='%q' and sip_from_host='%q' and call_id is not null",
|
("select call_id from sip_dialogs where call_info='%q' and ((sip_from_user='%q' and sip_from_host='%q') or presence_id='%q@%q') "
|
||||||
switch_str_nil(p), user, host);
|
"and call_id is not null",
|
||||||
|
switch_str_nil(p), user, host, user, host);
|
||||||
|
|
||||||
if ((str = sofia_glue_execute_sql2str(profile, profile->ireg_mutex, sql, cid, sizeof(cid)))) {
|
if ((str = sofia_glue_execute_sql2str(profile, profile->ireg_mutex, sql, cid, sizeof(cid)))) {
|
||||||
bnh = nua_handle_by_call_id(nua, str);
|
bnh = nua_handle_by_call_id(nua, str);
|
||||||
|
|
|
@ -567,7 +567,8 @@ static void actual_sofia_presence_event_handler(switch_event_t *event)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (probe_euser && probe_host && (profile = sofia_glue_find_profile(probe_host))) {
|
if (probe_euser && probe_host && (profile = sofia_glue_find_profile(probe_host))) {
|
||||||
sql = switch_mprintf("select status,rpid from sip_dialogs where sip_from_user='%q' and sip_from_host='%q'", probe_euser, probe_host);
|
sql = switch_mprintf("select status,rpid from sip_dialogs where ((sip_from_user='%q' and sip_from_host='%q') or presence_id='%q@%q')",
|
||||||
|
probe_euser, probe_host, probe_euser, probe_host);
|
||||||
sofia_glue_execute_sql_callback(profile, profile->ireg_mutex, sql, sofia_presence_dialog_callback, &dh);
|
sofia_glue_execute_sql_callback(profile, profile->ireg_mutex, sql, sofia_presence_dialog_callback, &dh);
|
||||||
|
|
||||||
h.profile = profile;
|
h.profile = profile;
|
||||||
|
@ -591,9 +592,11 @@ static void actual_sofia_presence_event_handler(switch_event_t *event)
|
||||||
"'%q','%q' "
|
"'%q','%q' "
|
||||||
|
|
||||||
"from sip_registrations left join sip_dialogs on "
|
"from sip_registrations left join sip_dialogs on "
|
||||||
"(sip_dialogs.sip_from_user = sip_registrations.sip_user "
|
"sip_dialogs.presence_id = sip_registrations.sip_user || '@' || sip_registrations.sip_host "
|
||||||
"and (sip_dialogs.sip_from_host = sip_registrations.orig_server_host or "
|
|
||||||
"sip_dialogs.sip_from_host = sip_registrations.sip_host) ) "
|
|
||||||
|
"or (sip_dialogs.sip_from_user = sip_registrations.sip_user "
|
||||||
|
"and sip_dialogs.sip_from_host = sip_registrations.sip_host) "
|
||||||
|
|
||||||
"left join sip_presence on "
|
"left join sip_presence on "
|
||||||
"(sip_registrations.sip_user=sip_presence.sip_user and sip_registrations.orig_server_host=sip_presence.sip_host and "
|
"(sip_registrations.sip_user=sip_presence.sip_user and sip_registrations.orig_server_host=sip_presence.sip_host and "
|
||||||
|
@ -601,7 +604,8 @@ static void actual_sofia_presence_event_handler(switch_event_t *event)
|
||||||
"where sip_dialogs.presence_id='%q@%q' or (sip_registrations.sip_user='%q' and "
|
"where sip_dialogs.presence_id='%q@%q' or (sip_registrations.sip_user='%q' and "
|
||||||
"(sip_registrations.orig_server_host='%q' or sip_registrations.sip_host='%q' "
|
"(sip_registrations.orig_server_host='%q' or sip_registrations.sip_host='%q' "
|
||||||
"or sip_registrations.presence_hosts like '%%%q%%'))",
|
"or sip_registrations.presence_hosts like '%%%q%%'))",
|
||||||
dh.status, dh.rpid, probe_euser, probe_host, probe_euser, probe_host, probe_host, probe_host);
|
dh.status, dh.rpid,
|
||||||
|
probe_euser, probe_host, probe_euser, probe_host, probe_host, probe_host);
|
||||||
switch_assert(sql);
|
switch_assert(sql);
|
||||||
|
|
||||||
if (mod_sofia_globals.debug_presence > 0) {
|
if (mod_sofia_globals.debug_presence > 0) {
|
||||||
|
@ -711,9 +715,10 @@ static void actual_sofia_presence_event_handler(switch_event_t *event)
|
||||||
sql = switch_mprintf("update sip_dialogs set call_info='%q',call_info_state='%q' where hostname='%q' and uuid='%q'",
|
sql = switch_mprintf("update sip_dialogs set call_info='%q',call_info_state='%q' where hostname='%q' and uuid='%q'",
|
||||||
call_info, call_info_state, mod_sofia_globals.hostname, uuid);
|
call_info, call_info_state, mod_sofia_globals.hostname, uuid);
|
||||||
} else {
|
} else {
|
||||||
sql = switch_mprintf("update sip_dialogs set call_info='%q', call_info_state='%q' where hostname='%q' and sip_dialogs.sip_from_user='%q' "
|
sql = switch_mprintf("update sip_dialogs set call_info='%q', call_info_state='%q' where hostname='%q' and "
|
||||||
"and sip_dialogs.sip_from_host='%q' and call_info='%q'",
|
"((sip_dialogs.sip_from_user='%q' and sip_dialogs.sip_from_host='%q') or presence_id='%q@%q') and call_info='%q'",
|
||||||
call_info, call_info_state, mod_sofia_globals.hostname, euser, host, call_info);
|
|
||||||
|
call_info, call_info_state, mod_sofia_globals.hostname, euser, host, euser, host, call_info);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -737,7 +742,8 @@ static void actual_sofia_presence_event_handler(switch_event_t *event)
|
||||||
sofia_glue_execute_sql_now(profile, &sql, SWITCH_TRUE);
|
sofia_glue_execute_sql_now(profile, &sql, SWITCH_TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
sql = switch_mprintf("select status,rpid from sip_dialogs where sip_from_user='%q' and sip_from_host='%q'", euser, host);
|
sql = switch_mprintf("select status,rpid from sip_dialogs where ((sip_from_user='%q' and sip_from_host='%q') or presence_id='%q@%q')",
|
||||||
|
euser, host, euser, host);
|
||||||
sofia_glue_execute_sql_callback(profile, profile->ireg_mutex, sql, sofia_presence_dialog_callback, &dh);
|
sofia_glue_execute_sql_callback(profile, profile->ireg_mutex, sql, sofia_presence_dialog_callback, &dh);
|
||||||
switch_safe_free(sql);
|
switch_safe_free(sql);
|
||||||
|
|
||||||
|
@ -753,17 +759,20 @@ static void actual_sofia_presence_event_handler(switch_event_t *event)
|
||||||
"(sip_subscriptions.sub_to_user=sip_presence.sip_user and sip_subscriptions.sub_to_host=sip_presence.sip_host and "
|
"(sip_subscriptions.sub_to_user=sip_presence.sip_user and sip_subscriptions.sub_to_host=sip_presence.sip_host and "
|
||||||
"sip_subscriptions.profile_name=sip_presence.profile_name) "
|
"sip_subscriptions.profile_name=sip_presence.profile_name) "
|
||||||
"left join sip_dialogs on "
|
"left join sip_dialogs on "
|
||||||
|
|
||||||
|
"sip_dialogs.presence_id = sip_subscriptions.sub_to_user || '@' || sip_subscriptions.sub_to_host or "
|
||||||
|
|
||||||
|
|
||||||
"(sip_dialogs.sip_from_user = sip_subscriptions.sub_to_user "
|
"(sip_dialogs.sip_from_user = sip_subscriptions.sub_to_user "
|
||||||
"and sip_dialogs.sip_from_host = sip_subscriptions.sub_to_host) "
|
"and sip_dialogs.sip_from_host = sip_subscriptions.sub_to_host) "
|
||||||
|
|
||||||
"where sip_subscriptions.expires > -1 and "
|
"where sip_subscriptions.expires > -1 and "
|
||||||
"(event='%q' or event='%q') and (sub_to_user='%q' or sip_dialogs.presence_id like '%q@%%') "
|
"(event='%q' or event='%q') and sub_to_user='%q' "
|
||||||
"and (sub_to_host='%q' or presence_hosts like '%%%q%%') "
|
"and (sub_to_host='%q' or presence_hosts like '%%%q%%') "
|
||||||
"and (sip_subscriptions.profile_name = '%q' or sip_subscriptions.presence_hosts != sip_subscriptions.sub_to_host)",
|
"and (sip_subscriptions.profile_name = '%q' or sip_subscriptions.presence_hosts != sip_subscriptions.sub_to_host)",
|
||||||
switch_str_nil(status), switch_str_nil(rpid), host,
|
switch_str_nil(status), switch_str_nil(rpid), host,
|
||||||
dh.status,dh.rpid,
|
dh.status,dh.rpid,
|
||||||
event_type, alt_event_type, euser, euser, host, host, profile->name))) {
|
event_type, alt_event_type, euser, host, host, profile->name))) {
|
||||||
|
|
||||||
struct presence_helper helper = { 0 };
|
struct presence_helper helper = { 0 };
|
||||||
|
|
||||||
|
@ -1918,7 +1927,8 @@ static void sync_sla(sofia_profile_t *profile, const char *to_user, const char *
|
||||||
switch_core_hash_init(&sh->hash, sh->pool);
|
switch_core_hash_init(&sh->hash, sh->pool);
|
||||||
|
|
||||||
sql = switch_mprintf("select sip_from_user,sip_from_host,call_info,call_info_state,uuid from sip_dialogs "
|
sql = switch_mprintf("select sip_from_user,sip_from_host,call_info,call_info_state,uuid from sip_dialogs "
|
||||||
"where hostname='%q' " "and sip_from_user='%q' and sip_from_host='%q' ", mod_sofia_globals.hostname, to_user, to_host);
|
"where hostname='%q' " "and ((sip_from_user='%q' and sip_from_host='%q) or presence_id='%q@%q')' ",
|
||||||
|
mod_sofia_globals.hostname, to_user, to_host, to_user, to_host);
|
||||||
|
|
||||||
|
|
||||||
if (mod_sofia_globals.debug_sla > 1) {
|
if (mod_sofia_globals.debug_sla > 1) {
|
||||||
|
@ -1954,7 +1964,8 @@ static void sync_sla(sofia_profile_t *profile, const char *to_user, const char *
|
||||||
|
|
||||||
|
|
||||||
if (clear) {
|
if (clear) {
|
||||||
sql = switch_mprintf("delete from sip_dialogs where sip_from_user='%q' and sip_from_host='%q' and call_info_state='seized'", to_user, to_host);
|
sql = switch_mprintf("delete from sip_dialogs where ((sip_from_user='%q' and sip_from_host='%q') or presence_id='%q@%q') "
|
||||||
|
"and call_info_state='seized'", to_user, to_host, to_user, to_host);
|
||||||
|
|
||||||
|
|
||||||
if (mod_sofia_globals.debug_sla > 1) {
|
if (mod_sofia_globals.debug_sla > 1) {
|
||||||
|
@ -2326,8 +2337,9 @@ void sofia_presence_handle_sip_i_subscribe(int status,
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "CANCEL LINE SEIZE\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "CANCEL LINE SEIZE\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
sql = switch_mprintf("delete from sip_dialogs where sip_from_user='%q' and sip_from_host='%q' and call_info_state='seized'",
|
sql = switch_mprintf("delete from sip_dialogs where ((sip_from_user='%q' and sip_from_host='%q') or presence_id='%q@%q') "
|
||||||
to_user, to_host);
|
"and call_info_state='seized'",
|
||||||
|
to_user, to_host, to_user, to_host);
|
||||||
|
|
||||||
|
|
||||||
if (mod_sofia_globals.debug_sla > 1) {
|
if (mod_sofia_globals.debug_sla > 1) {
|
||||||
|
@ -2360,8 +2372,9 @@ void sofia_presence_handle_sip_i_subscribe(int status,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
sql = switch_mprintf("delete from sip_dialogs where sip_from_user='%q' and sip_from_host='%q' and call_info_state='seized'",
|
sql = switch_mprintf("delete from sip_dialogs where ((sip_from_user='%q' and sip_from_host='%q') or presence_id='%q@%q') "
|
||||||
to_user, to_host);
|
"and call_info_state='seized'",
|
||||||
|
to_user, to_host, to_user, to_host);
|
||||||
|
|
||||||
|
|
||||||
if (mod_sofia_globals.debug_sla > 1) {
|
if (mod_sofia_globals.debug_sla > 1) {
|
||||||
|
|
|
@ -1445,27 +1445,27 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (sofia_test_pflag(profile, PFLAG_PRESENCE_PROBE_ON_REGISTER)) {
|
||||||
#if 0
|
if (switch_event_create(&s_event, SWITCH_EVENT_PRESENCE_PROBE) == SWITCH_STATUS_SUCCESS) {
|
||||||
if (switch_event_create(&s_event, SWITCH_EVENT_PRESENCE_PROBE) == SWITCH_STATUS_SUCCESS) {
|
switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "proto", SOFIA_CHAT_PROTO);
|
||||||
switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "proto", SOFIA_CHAT_PROTO);
|
switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "login", profile->name);
|
||||||
switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "login", profile->name);
|
switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "from", "%s@%s", to_user, sub_host);
|
||||||
switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "from", "%s@%s", to_user, sub_host);
|
switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "to", "%s@%s", to_user, sub_host);
|
||||||
switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "to", "%s@%s", to_user, sub_host);
|
switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "event_type", "presence");
|
||||||
switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "event_type", "presence");
|
switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "alt_event_type", "dialog");
|
||||||
switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "alt_event_type", "dialog");
|
switch_event_fire(&s_event);
|
||||||
switch_event_fire(&s_event);
|
}
|
||||||
|
} else {
|
||||||
|
if (switch_event_create(&s_event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
|
||||||
|
switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "proto", SOFIA_CHAT_PROTO);
|
||||||
|
switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "login", profile->name);
|
||||||
|
switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "from", "%s@%s", to_user, sub_host);
|
||||||
|
switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "rpid", "unknown");
|
||||||
|
switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "status", "Registered");
|
||||||
|
switch_event_fire(&s_event);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
if (switch_event_create(&s_event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
|
|
||||||
switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "proto", SOFIA_CHAT_PROTO);
|
|
||||||
switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "login", profile->name);
|
|
||||||
switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "from", "%s@%s", to_user, sub_host);
|
|
||||||
switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "rpid", "unknown");
|
|
||||||
switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "status", "Registered");
|
|
||||||
switch_event_fire(&s_event);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
} else {
|
} else {
|
||||||
if (switch_event_create_subclass(&s_event, SWITCH_EVENT_CUSTOM, MY_EVENT_UNREGISTER) == SWITCH_STATUS_SUCCESS) {
|
if (switch_event_create_subclass(&s_event, SWITCH_EVENT_CUSTOM, MY_EVENT_UNREGISTER) == SWITCH_STATUS_SUCCESS) {
|
||||||
switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "profile-name", profile->name);
|
switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "profile-name", profile->name);
|
||||||
|
|
Loading…
Reference in New Issue