]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
more cid refactor
authorAnthony Minessale <anthm@freeswitch.org>
Wed, 3 Apr 2013 22:17:01 +0000 (17:17 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Wed, 3 Apr 2013 22:17:01 +0000 (17:17 -0500)
src/include/switch_caller.h
src/switch_caller.c
src/switch_ivr_bridge.c

index 4060c7df39a7f69fd8ea8a6c1face208e01c9980..47159a9fee71e859dfaa7c7eccabf4b3fa50b5ea 100644 (file)
@@ -76,6 +76,10 @@ typedef struct profile_node_s {
        const char *caller_id_name;
        /*! Caller ID Number */
        const char *caller_id_number;
+       /*! Original Caller ID Name */
+       const char *orig_caller_id_name;
+       /*! Original Caller ID Number */
+       const char *orig_caller_id_number;
        /*! Callee ID Name */
        const char *callee_id_name;
        /*! Callee ID Number */
index 5de2d33e81e83462ff26cb1dcb6aa04b11782674..abe2f2df081eed4c5f233bc990d0549d79fd5499 100644 (file)
@@ -73,6 +73,8 @@ SWITCH_DECLARE(switch_caller_profile_t *) switch_caller_profile_new(switch_memor
        profile_dup_clean(dialplan, profile->dialplan, pool);
        profile_dup_clean(caller_id_name, profile->caller_id_name, pool);
        profile_dup_clean(caller_id_number, profile->caller_id_number, pool);
+       profile_dup_clean(caller_id_name, profile->orig_caller_id_name, pool);
+       profile_dup_clean(caller_id_number, profile->orig_caller_id_number, pool);
        profile->caller_ton = SWITCH_TON_UNDEF;
        profile->caller_numplan = SWITCH_NUMPLAN_UNDEF;
        profile_dup_clean(network_addr, profile->network_addr, pool);
@@ -115,6 +117,8 @@ SWITCH_DECLARE(switch_caller_profile_t *) switch_caller_profile_dup(switch_memor
        profile_dup(tocopy->caller_id_number, profile->caller_id_number, pool);
        profile_dup(tocopy->callee_id_name, profile->callee_id_name, pool);
        profile_dup(tocopy->callee_id_number, profile->callee_id_number, pool);
+       profile_dup(tocopy->orig_caller_id_name, profile->orig_caller_id_name, pool);
+       profile_dup(tocopy->orig_caller_id_number, profile->orig_caller_id_number, pool);
        profile_dup(tocopy->network_addr, profile->network_addr, pool);
        profile_dup(tocopy->ani, profile->ani, pool);
        profile_dup(tocopy->aniii, profile->aniii, pool);
@@ -190,6 +194,12 @@ SWITCH_DECLARE(const char *) switch_caller_get_field_by_name(switch_caller_profi
        if (!strcasecmp(name, "caller_id_number")) {
                return caller_profile->caller_id_number;
        }
+       if (!strcasecmp(name, "orig_caller_id_name")) {
+               return caller_profile->orig_caller_id_name;
+       }
+       if (!strcasecmp(name, "orig_caller_id_number")) {
+               return caller_profile->orig_caller_id_number;
+       }
        if (!strcasecmp(name, "callee_id_name")) {
                return caller_profile->callee_id_name;
        }
@@ -316,6 +326,14 @@ SWITCH_DECLARE(void) switch_caller_profile_event_set_data(switch_caller_profile_
                switch_snprintf(header_name, sizeof(header_name), "%s-Caller-ID-Number", prefix);
                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->caller_id_number);
        }
+       if (!zstr(caller_profile->caller_id_name)) {
+               switch_snprintf(header_name, sizeof(header_name), "%s-Orig-Caller-ID-Name", prefix);
+               switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->orig_caller_id_name);
+       }
+       if (!zstr(caller_profile->caller_id_number)) {
+               switch_snprintf(header_name, sizeof(header_name), "%s-Orig-Caller-ID-Number", prefix);
+               switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->orig_caller_id_number);
+       }
        if (!zstr(caller_profile->callee_id_name)) {
                switch_snprintf(header_name, sizeof(header_name), "%s-Callee-ID-Name", prefix);
                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->callee_id_name);
index 31d4869f06e0737eae6778928ee530da170c2b46..09a2140ec2a4b39acfea2fd1a11d1099d5d8131c 100644 (file)
@@ -93,17 +93,28 @@ static void send_display(switch_core_session_t *session, switch_core_session_t *
 {
 
        switch_core_session_message_t *msg;
-       switch_caller_profile_t *caller_profile;
-       switch_channel_t *caller_channel;
+       switch_caller_profile_t *caller_profile, *peer_caller_profile;
+       switch_channel_t *caller_channel, *peer_channel;
        const char *name, *number, *p;
 
        caller_channel = switch_core_session_get_channel(session);
+       peer_channel = switch_core_session_get_channel(peer_session);
+
        caller_profile = switch_channel_get_caller_profile(caller_channel);
-       
+       peer_caller_profile = switch_channel_get_caller_profile(peer_channel);
 
        if (switch_channel_test_flag(caller_channel, CF_BRIDGE_ORIGINATOR)) {
-               name = caller_profile->caller_id_name;
-               number = caller_profile->caller_id_number;              
+               if (!zstr(peer_caller_profile->caller_id_name)) {
+                       name = peer_caller_profile->caller_id_name;
+               } else {
+                       name = caller_profile->caller_id_name;
+               }
+
+               if (!zstr(peer_caller_profile->caller_id_number)) {
+                       number = peer_caller_profile->caller_id_number;
+               } else {
+                       number = caller_profile->caller_id_number;              
+               }
 
                if (zstr(number)) {
                        number = "UNKNOWN";