diff --git a/src/mod/endpoints/mod_sofia/sofia_presence.c b/src/mod/endpoints/mod_sofia/sofia_presence.c index de5e8d49d9..775451db54 100644 --- a/src/mod/endpoints/mod_sofia/sofia_presence.c +++ b/src/mod/endpoints/mod_sofia/sofia_presence.c @@ -522,7 +522,7 @@ static void actual_sofia_presence_event_handler(switch_event_t *event) alt_event_type = "presence"; } - if ((user = strdup(from))) { + if (from && (user = strdup(from))) { if ((host = strchr(user, '@'))) { char *p; *host++ = '\0'; @@ -1065,7 +1065,7 @@ static char *gen_pidf(char *user_agent, char *id, char *url, char *open, char *r *ct = "application/xpidf+xml"; /* If unknown/none prpid is provided, just show the user as online. */ - if (!prpid) { + if (!prpid || !strcasecmp(prpid, "unknown")) { prpid = "online"; } @@ -1099,10 +1099,13 @@ static char *gen_pidf(char *user_agent, char *id, char *url, char *open, char *r } if (!strncasecmp(status, "Registered", 10)) { - prpid = NULL; status = "Available"; } + if (!strcasecmp(status, "Available")) { + prpid = NULL; + } + if (!strcasecmp(status, "Unregistered")) { prpid = NULL; @@ -1116,6 +1119,7 @@ static char *gen_pidf(char *user_agent, char *id, char *url, char *open, char *r if (zstr(status) && !zstr(prpid)) { status = "Available"; + prpid = NULL; } if (prpid) { diff --git a/src/mod/endpoints/mod_sofia/sofia_reg.c b/src/mod/endpoints/mod_sofia/sofia_reg.c index 8ac765aa42..2ded7ee4c4 100644 --- a/src/mod/endpoints/mod_sofia/sofia_reg.c +++ b/src/mod/endpoints/mod_sofia/sofia_reg.c @@ -1336,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, "login", profile->name); 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", "online"); + 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); }