]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
fix for MODAPP-122
authorAnthony Minessale <anthony.minessale@gmail.com>
Mon, 11 Aug 2008 21:27:20 +0000 (21:27 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Mon, 11 Aug 2008 21:27:20 +0000 (21:27 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@9248 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/include/switch_types.h
src/switch_core_session.c
src/switch_ivr_originate.c

index 1afa59939591f12e8075a2453e040b89efdf247f..3c0d842094308c99b32c07f9e44019773ba8390a 100644 (file)
@@ -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;
 
index a014b11bff9c715b28af848f50be44cbffceacb4..155c08928154b9b8f376efd0f106813fab2d974d 100644 (file)
@@ -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);
index ac31b54394164b3ea2b0a87f86cee038a62c579e..a78d46354ac5fc953903dd700cc2a49fb5150801 100644 (file)
@@ -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) {