more presence stuff

This commit is contained in:
Anthony Minessale 2010-08-23 18:18:56 -05:00
parent 362eade2dc
commit a873b3841a
2 changed files with 16 additions and 10 deletions

View File

@ -1069,11 +1069,6 @@ static char *gen_pidf(char *user_agent, char *id, char *url, char *open, char *r
prpid = "online"; prpid = "online";
} }
/* FS currently send prpid closed on register, this force it to online */
if (!strncasecmp(status, "Registered", 10) && !strcasecmp(prpid, "closed")) {
prpid = "online";
}
/* of course!, lets make a big deal over dashes. Now the stupidity is complete. */ /* of course!, lets make a big deal over dashes. Now the stupidity is complete. */
if (!strcmp(prpid, "on-the-phone")) { if (!strcmp(prpid, "on-the-phone")) {
prpid = "onthephone"; prpid = "onthephone";
@ -1430,9 +1425,11 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char *
if (direction && !strcasecmp(direction, "outbound")) { if (direction && !strcasecmp(direction, "outbound")) {
op = switch_event_get_header(helper->event, "Other-Leg-Caller-ID-Number"); op = switch_event_get_header(helper->event, "Other-Leg-Caller-ID-Number");
} else { } else {
if (!(op = switch_event_get_header(helper->event, "Caller-Callee-ID-Number"))) { op = switch_event_get_header(helper->event, "Caller-Callee-ID-Number");
op = switch_event_get_header(helper->event, "Caller-Destination-Number");
} }
if (!op) {
op = switch_event_get_header(helper->event, "Caller-Destination-Number");
} }
if (direction) { if (direction) {
@ -1451,7 +1448,7 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char *
} else if (!strcmp(astate, "confirmed")) { } else if (!strcmp(astate, "confirmed")) {
if (zstr(op)) { if (zstr(op)) {
switch_snprintf(status_line, sizeof(status_line), "On The Phone %s", status); switch_snprintf(status_line, sizeof(status_line), "On The Phone");
} else { } else {
switch_snprintf(status_line, sizeof(status_line), "Talk %s", op); switch_snprintf(status_line, sizeof(status_line), "Talk %s", op);
} }

View File

@ -1146,6 +1146,13 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
} }
if (multi_reg) { if (multi_reg) {
if (reg_count == 1) {
sql = switch_mprintf("delete from sip_subscriptions where sip_user='%q' and sip_host='%q' and contact='%q'",
to_user, reg_host, contact_str);
sofia_glue_execute_sql_now(profile, &sql, SWITCH_TRUE);
}
if (multi_reg_contact) { if (multi_reg_contact) {
sql = sql =
switch_mprintf("delete from sip_registrations where sip_user='%q' and sip_host='%q' and contact='%q'", to_user, reg_host, contact_str); switch_mprintf("delete from sip_registrations where sip_user='%q' and sip_host='%q' and contact='%q'", to_user, reg_host, contact_str);
@ -1153,6 +1160,8 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
sql = switch_mprintf("delete from sip_registrations where call_id='%q'", call_id); sql = switch_mprintf("delete from sip_registrations where call_id='%q'", call_id);
} }
} else { } else {
sql = switch_mprintf("delete from sip_subscriptions where sip_user='%q' and sip_host='%q'");
sofia_glue_execute_sql_now(profile, &sql, SWITCH_TRUE);
sql = switch_mprintf("delete from sip_registrations where sip_user='%q' and sip_host='%q'", to_user, reg_host); sql = switch_mprintf("delete from sip_registrations where sip_user='%q' and sip_host='%q'", to_user, reg_host);
} }
switch_mutex_lock(profile->ireg_mutex); switch_mutex_lock(profile->ireg_mutex);
@ -1327,7 +1336,7 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
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, reg_host); switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "from", "%s@%s", to_user, reg_host);
switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "rpid", "closed"); switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "rpid", "online");
switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "status", "Registered"); switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "status", "Registered");
switch_event_fire(&s_event); switch_event_fire(&s_event);
} }