From 79be96aa8e353507e74aa405f19c8bff381709a2 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Wed, 3 Apr 2013 17:17:01 -0500 Subject: [PATCH] more cid refactor --- src/include/switch_caller.h | 4 ++++ src/switch_caller.c | 18 ++++++++++++++++++ src/switch_ivr_bridge.c | 21 ++++++++++++++++----- 3 files changed, 38 insertions(+), 5 deletions(-) diff --git a/src/include/switch_caller.h b/src/include/switch_caller.h index 4060c7df39..47159a9fee 100644 --- a/src/include/switch_caller.h +++ b/src/include/switch_caller.h @@ -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 */ diff --git a/src/switch_caller.c b/src/switch_caller.c index 5de2d33e81..abe2f2df08 100644 --- a/src/switch_caller.c +++ b/src/switch_caller.c @@ -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); diff --git a/src/switch_ivr_bridge.c b/src/switch_ivr_bridge.c index 31d4869f06..09a2140ec2 100644 --- a/src/switch_ivr_bridge.c +++ b/src/switch_ivr_bridge.c @@ -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";