diff --git a/src/include/switch_types.h b/src/include/switch_types.h index 1afa599395..3c0d842094 100644 --- a/src/include/switch_types.h +++ b/src/include/switch_types.h @@ -181,7 +181,9 @@ typedef enum { typedef enum { SOF_NONE = 0, SOF_NOBLOCK = (1 << 0), - SOF_FORKED_DIAL = (1 << 1) + SOF_FORKED_DIAL = (1 << 1), + SOF_NO_EFFECTIVE_CID_NUM = (1 << 2), + SOF_NO_EFFECTIVE_CID_NAME = (1 << 3) } switch_originate_flag_enum_t; typedef uint32_t switch_originate_flag_t; diff --git a/src/switch_core_session.c b/src/switch_core_session.c index a014b11bff..155c089281 100644 --- a/src/switch_core_session.c +++ b/src/switch_core_session.c @@ -270,9 +270,14 @@ SWITCH_DECLARE(switch_call_cause_t) switch_core_session_outgoing_channel(switch_ if (caller_profile) { const char *ecaller_id_name = NULL, *ecaller_id_number = NULL; + + if (!(flags & SOF_NO_EFFECTIVE_CID_NAME)) { + ecaller_id_name = switch_channel_get_variable(channel, "effective_caller_id_name"); + } - ecaller_id_name = switch_channel_get_variable(channel, "effective_caller_id_name"); - ecaller_id_number = switch_channel_get_variable(channel, "effective_caller_id_number"); + if (!(flags & SOF_NO_EFFECTIVE_CID_NUM)) { + ecaller_id_number = switch_channel_get_variable(channel, "effective_caller_id_number"); + } if (ecaller_id_name || ecaller_id_number) { outgoing_profile = switch_caller_profile_clone(session, caller_profile); diff --git a/src/switch_ivr_originate.c b/src/switch_ivr_originate.c index ac31b54394..a78d46354a 100644 --- a/src/switch_ivr_originate.c +++ b/src/switch_ivr_originate.c @@ -506,7 +506,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess const char *cid_num_override, switch_caller_profile_t *caller_profile_override, switch_originate_flag_t flags) { - switch_originate_flag_t myflags = SOF_NONE; + switch_originate_flag_t dftflags = SOF_NONE, myflags = dftflags; char *pipe_names[MAX_PEERS] = { 0 }; char *data = NULL; switch_status_t status = SWITCH_STATUS_SUCCESS; @@ -538,6 +538,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess uint8_t ring_ready = 0; char *loop_data = NULL; uint32_t progress_timelimit_sec = 0; + const char *cid_tmp; *bleg = NULL; @@ -742,18 +743,34 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess } } + if ((cid_tmp = switch_event_get_header(var_event, "origination_caller_id_name"))) { + cid_name_override = cid_tmp; + } + if (cid_name_override) { switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, "origination_caller_id_name", cid_name_override); } else { cid_name_override = switch_event_get_header(var_event, "origination_caller_id_name"); } + if ((cid_tmp = switch_event_get_header(var_event, "origination_caller_id_number"))) { + cid_num_override = cid_tmp; + } + if (cid_num_override) { switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, "origination_caller_id_number", cid_num_override); } else { cid_num_override = switch_event_get_header(var_event, "origination_caller_id_number"); } + if (cid_num_override) { + dftflags |= SOF_NO_EFFECTIVE_CID_NUM; + } + + if (cid_name_override) { + dftflags |= SOF_NO_EFFECTIVE_CID_NAME; + } + if (!progress_timelimit_sec) { progress_timelimit_sec = timelimit_sec; } @@ -793,7 +810,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess to = 0; sent_ring = 0; progress = 0; - + myflags = dftflags; + if (try > 0) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Originate attempt %d/%d in %d ms\n", try + 1, retries, sleep_ms); switch_yield(sleep_ms * 1000); @@ -915,6 +933,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess strncpy(tmp, var_begin, strlen(var_begin)); } new_profile->caller_id_number = switch_core_strdup(new_profile->pool, tmp); + myflags |= SOF_NO_EFFECTIVE_CID_NUM; } if (vdata && (var_begin = switch_stristr("origination_caller_id_name=", vdata))) { @@ -927,8 +946,10 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess strncpy(tmp, var_begin, strlen(var_begin)); } new_profile->caller_id_name = switch_core_strdup(new_profile->pool, tmp); + myflags |= SOF_NO_EFFECTIVE_CID_NAME; } + if ((reason = switch_core_session_outgoing_channel(session, var_event, chan_type, new_profile, &new_session, &pool, myflags)) != SWITCH_CAUSE_SUCCESS) {