]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
cid logic changes for calle[re]
authorAnthony Minessale <anthm@freeswitch.org>
Fri, 17 Dec 2010 20:35:53 +0000 (14:35 -0600)
committerAnthony Minessale <anthm@freeswitch.org>
Fri, 17 Dec 2010 20:35:53 +0000 (14:35 -0600)
src/include/switch_channel.h
src/mod/endpoints/mod_sofia/mod_sofia.c
src/switch_channel.c
src/switch_ivr.c
src/switch_ivr_bridge.c
src/switch_ivr_originate.c

index d6bce5e8bf17c0c40cec97c7c95c3afbbb1668c1..e726554d81a51d40f4fe6deca4af0139d9d618e8 100644 (file)
@@ -312,6 +312,8 @@ SWITCH_DECLARE(switch_status_t) switch_channel_caller_extension_masquerade(switc
 */
 SWITCH_DECLARE(void) switch_channel_set_caller_extension(switch_channel_t *channel, switch_caller_extension_t *caller_extension);
 
+SWITCH_DECLARE(void) switch_channel_sort_cid(switch_channel_t *channel, switch_bool_t in);
+
 /*!
   \brief Retrieve caller extension from a given channel
   \param channel channel to retrieve extension from
index 07e125ad6c105acdbeea4ebf3f2e5bc9f22fd3f7..884e5bf9f5db0ad8bb72d508ccc63bf679554e80 100644 (file)
@@ -4065,6 +4065,8 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
                switch_channel_set_variable(nchannel, "sip_invite_params", "intercom=true");
        }
 
+       DUMP_EVENT(var_event);
+
        if (((hval = switch_event_get_header(var_event, "effective_callee_id_name")) ||
                 (hval = switch_event_get_header(var_event, "sip_callee_id_name"))) && !zstr(hval)) {
                caller_profile->callee_id_name = switch_core_strdup(caller_profile->pool, hval);
index ef21e8c8f1620849c87584d70061a63e2f8d6ab3..aa7f6699b74d94e30759c4bfef8f775b2a543280 100644 (file)
@@ -2382,12 +2382,48 @@ SWITCH_DECLARE(switch_status_t) switch_channel_caller_extension_masquerade(switc
        return status;
 }
 
+SWITCH_DECLARE(void) switch_channel_sort_cid(switch_channel_t *channel, switch_bool_t in)
+{
+
+       if (in) {
+               if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND && !switch_channel_test_flag(channel, CF_DIALPLAN)) {
+                       switch_channel_set_flag(channel, CF_DIALPLAN);
+               
+                       switch_mutex_lock(channel->profile_mutex);
+                       if (channel->caller_profile->callee_id_name) {
+                               switch_channel_set_variable(channel, "pre_transfer_caller_id_name", channel->caller_profile->caller_id_name);
+                               channel->caller_profile->caller_id_name = switch_core_strdup(channel->caller_profile->pool, channel->caller_profile->callee_id_name);
+                       }
+                       channel->caller_profile->callee_id_name = SWITCH_BLANK_STRING;
+
+                       if (channel->caller_profile->callee_id_number) {
+                               switch_channel_set_variable(channel, "pre_transfer_caller_id_number", channel->caller_profile->caller_id_number);
+                               channel->caller_profile->caller_id_number = switch_core_strdup(channel->caller_profile->pool, channel->caller_profile->callee_id_number);
+                       }
+                       channel->caller_profile->callee_id_number = SWITCH_BLANK_STRING;
+                       switch_mutex_unlock(channel->profile_mutex);
+               }
+
+               return;
+       }
+
+       if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND && switch_channel_test_flag(channel, CF_DIALPLAN)) {
+               switch_channel_clear_flag(channel, CF_DIALPLAN);
+               switch_mutex_lock(channel->profile_mutex);
+               channel->caller_profile->callee_id_name = SWITCH_BLANK_STRING;
+               channel->caller_profile->callee_id_number = SWITCH_BLANK_STRING;
+               switch_mutex_unlock(channel->profile_mutex);
+       }
+       
+}
+
+
 SWITCH_DECLARE(void) switch_channel_set_caller_extension(switch_channel_t *channel, switch_caller_extension_t *caller_extension)
 {
        switch_assert(channel != NULL);
 
-       switch_channel_set_flag(channel, CF_DIALPLAN);
-
+       switch_channel_sort_cid(channel, SWITCH_TRUE);
+       
        switch_mutex_lock(channel->profile_mutex);
        caller_extension->next = channel->caller_profile->caller_extension;
        channel->caller_profile->caller_extension = caller_extension;
index 494871ec8a3d11d102949b2c7efb4079b6511b87..cd74c332b79cf045895279ff96e28cc5d7c1c842 100644 (file)
@@ -1544,21 +1544,6 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_session_transfer(switch_core_session_
                new_profile->destination_number = switch_core_strdup(new_profile->pool, extension);
                new_profile->rdnis = switch_core_strdup(new_profile->pool, profile->destination_number);
 
-               if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND) {
-                       if (profile->callee_id_name) {
-                               switch_channel_set_variable(channel, "pre_transfer_caller_id_name", new_profile->caller_id_name);
-                               new_profile->caller_id_name = switch_core_strdup(new_profile->pool, profile->callee_id_name);
-                               profile->callee_id_name = SWITCH_BLANK_STRING;
-                       }
-
-                       if (profile->callee_id_number) {
-                               switch_channel_set_variable(channel, "pre_transfer_caller_id_number", new_profile->caller_id_number);
-                               new_profile->caller_id_number = switch_core_strdup(new_profile->pool, profile->callee_id_number);
-                               profile->callee_id_number = SWITCH_BLANK_STRING;
-                       }
-               }
-               
-
                switch_channel_set_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE, NULL);
 
                /* If HANGUP_AFTER_BRIDGE is set to 'true', SWITCH_SIGNAL_BRIDGE_VARIABLE 
index aa5ddb9232ae824147c59c4544648e7c8295f74b..2f2dcdbc956a22ec38fb79cfd1319086518ab224 100644 (file)
@@ -1052,6 +1052,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_signal_bridge(switch_core_session_t *
        switch_channel_set_variable(caller_channel, "signal_bridge", "true");
        switch_channel_set_variable(peer_channel, "signal_bridge", "true");
 
+       switch_channel_sort_cid(peer_channel, SWITCH_FALSE);
+
        /* fire events that will change the data table from "show channels" */
        if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_EXECUTE) == SWITCH_STATUS_SUCCESS) {
                switch_channel_event_set_data(caller_channel, event);
@@ -1117,6 +1119,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_multi_threaded_bridge(switch_core_ses
        switch_channel_set_flag_recursive(caller_channel, CF_BRIDGE_ORIGINATOR);
        switch_channel_clear_flag(peer_channel, CF_BRIDGE_ORIGINATOR);
 
+       switch_channel_sort_cid(peer_channel, SWITCH_FALSE);
+
        b_leg->session = peer_session;
        switch_copy_string(b_leg->b_uuid, switch_core_session_get_uuid(session), sizeof(b_leg->b_uuid));
        b_leg->stream_id = stream_id;
index b6ae346a66a490ae3c83efc6bec0a8c7ab9aef0d..87a47e65aa16c79f4e7a6b8e86cad2cabfb8b73a 100644 (file)
@@ -2383,24 +2383,6 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
                                        new_profile->chan_name = SWITCH_BLANK_STRING;
                                        new_profile->destination_number = switch_core_strdup(new_profile->pool, chan_data);
 
-                                       if (switch_channel_direction(caller_channel) == SWITCH_CALL_DIRECTION_OUTBOUND) {
-                                               const char *callee_id_name = new_profile->callee_id_name;
-                                               const char *callee_id_number = new_profile->callee_id_number;
-
-                                               if (zstr(callee_id_number)) {
-                                                       callee_id_number = caller_caller_profile->destination_number;
-                                               }
-
-                                               if (zstr(callee_id_name)) {
-                                                       callee_id_name = callee_id_number;
-                                               }
-
-                                               new_profile->caller_id_name = callee_id_name;
-                                               new_profile->caller_id_number = callee_id_number;
-                                               new_profile->callee_id_name = SWITCH_BLANK_STRING;
-                                               new_profile->callee_id_number = SWITCH_BLANK_STRING;
-                                       }
-
                                        if (cid_name_override) {
                                                new_profile->caller_id_name = switch_core_strdup(new_profile->pool, cid_name_override);
                                        }