*/
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
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);
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;
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
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);
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;
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);
}