]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
more presence stuff
authorAnthony Minessale <anthm@freeswitch.org>
Mon, 23 Aug 2010 23:18:56 +0000 (18:18 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Mon, 23 Aug 2010 23:18:56 +0000 (18:18 -0500)
src/mod/endpoints/mod_sofia/sofia_presence.c
src/mod/endpoints/mod_sofia/sofia_reg.c

index de5560d875a8ea426f8fb9bca3be1a8dcdd86f00..de5e8d49d9a2266a95faa0aac0ebc731ab88156b 100644 (file)
@@ -1069,11 +1069,6 @@ static char *gen_pidf(char *user_agent, char *id, char *url, char *open, char *r
                        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. */
                if (!strcmp(prpid, "on-the-phone")) {
                        prpid = "onthephone";
@@ -1430,9 +1425,11 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char *
                                if (direction && !strcasecmp(direction, "outbound")) {
                                        op = switch_event_get_header(helper->event, "Other-Leg-Caller-ID-Number");
                                } else {
-                                       if (!(op = switch_event_get_header(helper->event, "Caller-Callee-ID-Number"))) {
-                                               op = switch_event_get_header(helper->event, "Caller-Destination-Number");
-                                       }
+                                       op = switch_event_get_header(helper->event, "Caller-Callee-ID-Number");
+                               }
+
+                               if (!op) {
+                                       op = switch_event_get_header(helper->event, "Caller-Destination-Number");
                                }
 
                                if (direction) {
@@ -1451,7 +1448,7 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char *
 
                                } else if (!strcmp(astate, "confirmed")) {
                                        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 {
                                                switch_snprintf(status_line, sizeof(status_line), "Talk %s", op);
                                        }
index 33f26e98dcc73f45819344753717bcaac18d4e2f..8ac765aa4269b555033832f7b0033c62be72d055 100644 (file)
@@ -1146,6 +1146,13 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
                }
 
                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) {
                                sql =
                                        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);
                        }
                } 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);
                }
                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, "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", "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_fire(&s_event);
                        }