]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
sla cid tweaks
authorAnthony Minessale <anthm@freeswitch.org>
Fri, 5 Apr 2013 05:29:20 +0000 (00:29 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Fri, 5 Apr 2013 05:29:20 +0000 (00:29 -0500)
src/mod/endpoints/mod_sofia/mod_sofia.c
src/mod/endpoints/mod_sofia/sofia.c
src/mod/endpoints/mod_sofia/sofia_glue.c
src/mod/endpoints/mod_sofia/sofia_presence.c
src/switch_ivr_async.c

index 099c04295bf0a4e9d30b1033ac0c185cf47ee5f2..37f67deb4192c85a373c692bf1a43bddf211ec9c 100644 (file)
@@ -526,6 +526,7 @@ switch_status_t sofia_on_hangup(switch_core_session_t *session)
                char *bye_headers = sofia_glue_get_extra_headers(channel, SOFIA_SIP_BYE_HEADER_PREFIX);
                const char *val = NULL;
                const char *max_forwards = switch_channel_get_variable(channel, SWITCH_MAX_FORWARDS_VARIABLE);
+               const char *call_info = switch_channel_get_variable(channel, "presence_call_info_full");
 
                val = switch_channel_get_variable(tech_pvt->channel, "disable_q850_reason");
 
@@ -544,8 +545,6 @@ switch_status_t sofia_on_hangup(switch_core_session_t *session)
                }
 
                if (switch_channel_test_flag(channel, CF_ANSWERED) || sofia_test_flag(tech_pvt, TFLAG_ANS)) {
-                       const char *call_info = switch_channel_get_variable(channel, "presence_call_info_full");
-
                        if (!tech_pvt->got_bye) {
                                switch_channel_set_variable(channel, "sip_hangup_disposition", "send_bye");
                        }
@@ -565,6 +564,7 @@ switch_status_t sofia_on_hangup(switch_core_session_t *session)
                                }
                                if (!sofia_test_flag(tech_pvt, TFLAG_BYE)) {
                                        nua_cancel(tech_pvt->nh,
+                                                          TAG_IF(call_info, SIPTAG_CALL_INFO_STR(call_info)),
                                                           TAG_IF(!zstr(reason), SIPTAG_REASON_STR(reason)), TAG_IF(!zstr(bye_headers), SIPTAG_HEADER_STR(bye_headers)), TAG_END());
                                }
                        } else {
@@ -2311,6 +2311,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
        case SWITCH_MESSAGE_INDICATE_DISPLAY:
                {
                        const char *name = msg->string_array_arg[0], *number = msg->string_array_arg[1];
+                       const char *call_info = switch_channel_get_variable(channel, "presence_call_info_full");
                        
                        if (!zstr(name)) {
                                char message[256] = "";
@@ -2387,6 +2388,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
                                                        nua_update(tech_pvt->nh,
                                                                           NUTAG_SESSION_TIMER(tech_pvt->session_timeout),
                                                                           NUTAG_SESSION_REFRESHER(tech_pvt->session_refresher),
+                                                                          TAG_IF(call_info, SIPTAG_CALL_INFO_STR(call_info)),
                                                                           TAG_IF(!zstr(tech_pvt->route_uri), NUTAG_PROXY(tech_pvt->route_uri)),
                                                                           TAG_IF(!zstr_buf(message), SIPTAG_HEADER_STR(message)),
                                                                           TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)), TAG_END());
@@ -2397,6 +2399,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
                                                        nua_update(tech_pvt->nh,
                                                                           NUTAG_SESSION_TIMER(tech_pvt->session_timeout),
                                                                           NUTAG_SESSION_REFRESHER(tech_pvt->session_refresher),
+                                                                          TAG_IF(call_info, SIPTAG_CALL_INFO_STR(call_info)),
                                                                           TAG_IF(!zstr(tech_pvt->route_uri), NUTAG_PROXY(tech_pvt->route_uri)),
                                                                           TAG_IF(!zstr_buf(message), SIPTAG_HEADER_STR(message)),
                                                                           TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)), TAG_END());
@@ -2407,6 +2410,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
                                                        nua_update(tech_pvt->nh,
                                                                           NUTAG_SESSION_TIMER(tech_pvt->session_timeout),
                                                                           NUTAG_SESSION_REFRESHER(tech_pvt->session_refresher),
+                                                                          TAG_IF(call_info, SIPTAG_CALL_INFO_STR(call_info)),
                                                                           TAG_IF(!zstr(tech_pvt->route_uri), NUTAG_PROXY(tech_pvt->route_uri)),
                                                                           TAG_IF(!zstr_buf(message), SIPTAG_HEADER_STR(message)),
                                                                           TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)), TAG_END());
@@ -2417,6 +2421,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
                                                        nua_update(tech_pvt->nh,
                                                                           NUTAG_SESSION_TIMER(tech_pvt->session_timeout),
                                                                           NUTAG_SESSION_REFRESHER(tech_pvt->session_refresher),
+                                               TAG_IF(call_info, SIPTAG_CALL_INFO_STR(call_info)),
                                                                           TAG_IF(!zstr(tech_pvt->route_uri), NUTAG_PROXY(tech_pvt->route_uri)),
                                                                           TAG_IF(!zstr_buf(message), SIPTAG_HEADER_STR(message)),
                                                                           TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)), TAG_END());
index b1a6f00ae2540aea29fb9fe17b2c6c5328b0e9cc..0018c44c9972a61fe57c0969efca4385f2e34bce 100644 (file)
@@ -8453,9 +8453,15 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia
                                switch_channel_t *b_channel = switch_core_session_get_channel(b_session);
                                const char *bridge_uuid;
                                switch_caller_profile_t *orig_cp;
-                               const char *sent_name, *sent_number;
+                               //const char *sent_name, *sent_number;
                                orig_cp = switch_channel_get_caller_profile(b_channel);
-                               
+                               tech_pvt->caller_profile->callee_id_name = switch_core_strdup(tech_pvt->caller_profile->pool, orig_cp->callee_id_name);
+                               tech_pvt->caller_profile->callee_id_number = switch_core_strdup(tech_pvt->caller_profile->pool, orig_cp->callee_id_number);
+                               tech_pvt->caller_profile->caller_id_name = switch_core_strdup(tech_pvt->caller_profile->pool, orig_cp->caller_id_name);
+                               tech_pvt->caller_profile->caller_id_number = switch_core_strdup(tech_pvt->caller_profile->pool, orig_cp->caller_id_number);
+
+
+#if 0                          
                                sent_name = switch_channel_get_variable(b_channel, "last_sent_callee_id_name");
                                sent_number = switch_channel_get_variable(b_channel, "last_sent_callee_id_number");
 
@@ -8471,6 +8477,7 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia
                                                tech_pvt->caller_profile->callee_id_number = switch_core_strdup(tech_pvt->caller_profile->pool, orig_cp->caller_id_number);
                                        }
                                }
+#endif
 
                                if (is_nat) {
                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "Setting NAT mode based on %s\n", is_nat);
@@ -8499,13 +8506,25 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia
                                                codec_str = switch_core_session_sprintf(session, "set:absolute_codec_string=%s@%di,", read_impl.iananame, 
                                                                                                                           read_impl.microseconds_per_packet / 1000);
                                        }
-                                       
-
 
                                        if (!zstr(bridge_uuid) && switch_channel_test_flag(b_channel, CF_LEG_HOLDING)) {
                                                tech_pvt->caller_profile->destination_number = switch_core_sprintf(tech_pvt->caller_profile->pool, 
                                                                                                                                                                                   "%sanswer,intercept:%s", codec_str, bridge_uuid);
                                        } else {
+                                               const char *name = NULL, *num = NULL;
+                                               switch_caller_profile_t *bcp = switch_channel_get_caller_profile(b_channel);
+                                               
+                                               if (switch_channel_test_flag(b_channel, CF_BRIDGE_ORIGINATOR) || !switch_channel_test_flag(b_channel, CF_BRIDGED)) {
+                                                       name = bcp->callee_id_name;
+                                                       num = bcp->callee_id_number;
+                                               } else {
+                                                       name = bcp->caller_id_name;
+                                                       num = bcp->caller_id_number;
+                                               }                                       
+                                               
+                                               tech_pvt->caller_profile->callee_id_name = switch_core_strdup(tech_pvt->caller_profile->pool, name);
+                                               tech_pvt->caller_profile->callee_id_number = switch_core_strdup(tech_pvt->caller_profile->pool, num);
+
                                                tech_pvt->caller_profile->destination_number = switch_core_sprintf(tech_pvt->caller_profile->pool, 
                                                                                                                                                                                   "%sanswer,sofia_sla:%s", codec_str, b_private->uuid);
                                        }
index 416c0c033b0c9eb8c9d107b223f3303561f4c6a2..f77f2bf1655a41dacb80f8e5a2615a7e3e93f574 100644 (file)
@@ -2136,7 +2136,6 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
        const char *recover_via = NULL;
        int require_timer = 1;
 
-
        if (switch_channel_test_flag(tech_pvt->channel, CF_RECOVERING)) {
                const char *recover_contact = switch_channel_get_variable(tech_pvt->channel, "sip_recover_contact");
                recover_via = switch_channel_get_variable(tech_pvt->channel, "sip_recover_via");
index 7caa716a545b7dac325e77730148c0f4b37ecf58..634c9e4a783d5acbd43beaf32fb9427fbd00d46a 100644 (file)
@@ -3276,26 +3276,22 @@ static int broadsoft_sla_gather_state_callback(void *pArg, int argc, char **argv
 
        data = switch_core_hash_find(sh->hash, key);
 
-       if (uuid && (session = switch_core_session_locate(uuid))) {
+       if (strcasecmp(state, "idle") && uuid && (session = switch_core_session_locate(uuid))) {
                switch_channel_t *channel = switch_core_session_get_channel(session);
 
-               if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_INBOUND) {
+               if (switch_channel_test_flag(channel, CF_BRIDGE_ORIGINATOR)) {
+                       callee_name = switch_channel_get_variable(channel, "callee_id_name");
+                       callee_number = switch_channel_get_variable(channel, "callee_id_number");
 
-                       if (zstr((callee_name = switch_channel_get_variable(channel, "effective_callee_id_name"))) &&
-                               zstr((callee_name = switch_channel_get_variable(channel, "sip_callee_id_name")))) {
-                               callee_name = switch_channel_get_variable(channel, "callee_id_name");
-                       }
-                       
-                       if (zstr((callee_number = switch_channel_get_variable(channel, "effective_callee_id_number"))) &&
-                               zstr((callee_number = switch_channel_get_variable(channel, "sip_callee_id_number"))) &&
-                               zstr((callee_number = switch_channel_get_variable(channel, "callee_id_number")))) {
+                       if (zstr(callee_number)) {
                                callee_number = switch_channel_get_variable(channel, "destination_number");
                        }
+                               
                } else {
                        callee_name = switch_channel_get_variable(channel, "caller_id_name");
                        callee_number = switch_channel_get_variable(channel, "caller_id_number");
                }
-               
+
                if (zstr(callee_name) && !zstr(callee_number)) {
                        callee_name = callee_number;
                }
@@ -3307,9 +3303,20 @@ static int broadsoft_sla_gather_state_callback(void *pArg, int argc, char **argv
                if (!zstr(callee_name)) {
                        callee_name = switch_sanitize_number(switch_core_session_strdup(session, callee_name));
                }
+
+
+               //if (switch_channel_get_state(channel) != CS_EXECUTE) {
+                       //callee_number = NULL;
+               //}
+
                switch_core_session_rwunlock(session);
        }
 
+       if (data && strstr(data, info)) {
+               return 0;
+       }
+
+
        if (!zstr(callee_number)) {
                if (zstr(callee_name)) {
                        callee_name = "unknown";
index b545748cb2b59082ada9971adbd2325b2868a9eb..ddb6d8c801ecba36ebb59472856b8d761ee356c2 100644 (file)
@@ -1473,7 +1473,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_eavesdrop_session(switch_core_session
                switch_codec_implementation_t tread_impl = { 0 }, read_impl = { 0 };
                switch_core_session_message_t msg = { 0 };
                char cid_buf[1024] = "";
-               switch_caller_profile_t *cp = NULL;
+               switch_caller_profile_t *cp = NULL, *my_cp = NULL;
                uint32_t sanity = 600;
 
                if (!switch_channel_media_up(channel)) {
@@ -1595,26 +1595,29 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_eavesdrop_session(switch_core_session
                msg.message_id = SWITCH_MESSAGE_INDICATE_BRIDGE;
                switch_core_session_receive_message(session, &msg);
                cp = switch_channel_get_caller_profile(tchannel);
+               my_cp = switch_channel_get_caller_profile(channel);
                name = cp->caller_id_name;
                num = cp->caller_id_number;
 
                if (flags & ED_COPY_DISPLAY) {
-                       const char *tmp_name = NULL, *tmp_num = NULL;
-                       name = cp->callee_id_name;
-                       num = cp->callee_id_number;
-                       
-                       if (!((tmp_name = switch_channel_get_variable(tchannel, "last_sent_callee_id_name")) 
-                                 && (tmp_num = switch_channel_get_variable(tchannel, "last_sent_callee_id_number")))) {
-                               
-                               tmp_name = switch_channel_get_variable(tchannel, "callee_id_name");
-                               tmp_num = switch_channel_get_variable(tchannel, "callee_id_number");
+                       if (switch_channel_test_flag(tchannel, CF_BRIDGE_ORIGINATOR) || !switch_channel_test_flag(tchannel, CF_BRIDGED)) {
+                               name = cp->callee_id_name;
+                               num = cp->callee_id_number;
+                       } else {
+                               name = cp->caller_id_name;
+                               num = cp->caller_id_number;
                        }
-                       
-                       if (tmp_name) name = tmp_name;
-                       if (tmp_num) num = tmp_num;
-                       
+
+                       my_cp->callee_id_name = switch_core_strdup(my_cp->pool, name);
+                       my_cp->callee_id_number = switch_core_strdup(my_cp->pool, num);
                }
 
+               sanity = 300;
+               while(switch_channel_up(channel) && !switch_channel_media_ack(channel) && --sanity) {
+                       switch_yield(10000);
+               }
+
+
                switch_snprintf(cid_buf, sizeof(cid_buf), "%s|%s", name, num);
                msg.string_arg = cid_buf;
                msg.message_id = SWITCH_MESSAGE_INDICATE_DISPLAY;