diff --git a/src/include/switch_caller.h b/src/include/switch_caller.h index b3002081da..f77f1b016d 100644 --- a/src/include/switch_caller.h +++ b/src/include/switch_caller.h @@ -103,6 +103,7 @@ SWITCH_BEGIN_EXTERN_C switch_caller_profile_flag_t flags; struct switch_caller_profile *originator_caller_profile; struct switch_caller_profile *originatee_caller_profile; + struct switch_caller_profile *origination_caller_profile; struct switch_caller_profile *hunt_caller_profile; struct switch_channel_timetable *times; struct switch_caller_extension *caller_extension; diff --git a/src/include/switch_channel.h b/src/include/switch_channel.h index 247beae460..3f92534e3e 100644 --- a/src/include/switch_channel.h +++ b/src/include/switch_channel.h @@ -215,6 +215,20 @@ SWITCH_DECLARE(void) switch_channel_set_originatee_caller_profile(switch_channel */ SWITCH_DECLARE(switch_caller_profile_t *) switch_channel_get_originatee_caller_profile(switch_channel_t *channel); +/*! + \brief Set the given channel's origination caller profile + \param channel channel to assign the profile to + \param caller_profile the profile to assign +*/ +SWITCH_DECLARE(void) switch_channel_set_origination_caller_profile(switch_channel_t *channel, switch_caller_profile_t *caller_profile); + +/*! + \brief Retrive the given channel's origination caller profile + \param channel channel to retrive the profile from + \return the requested profile +*/ +SWITCH_DECLARE(switch_caller_profile_t *) switch_channel_get_origination_caller_profile(switch_channel_t *channel); + /*! \brief Retrive the given channel's unique id diff --git a/src/switch_channel.c b/src/switch_channel.c index d1308a1e9f..e3d77d7239 100644 --- a/src/switch_channel.c +++ b/src/switch_channel.c @@ -2035,6 +2035,36 @@ SWITCH_DECLARE(void) switch_channel_set_hunt_caller_profile(switch_channel_t *ch switch_mutex_unlock(channel->profile_mutex); } +SWITCH_DECLARE(void) switch_channel_set_origination_caller_profile(switch_channel_t *channel, switch_caller_profile_t *caller_profile) +{ + switch_assert(channel != NULL); + switch_assert(channel->caller_profile != NULL); + + switch_mutex_lock(channel->profile_mutex); + + if (channel->caller_profile) { + caller_profile->next = channel->caller_profile->origination_caller_profile; + channel->caller_profile->origination_caller_profile = caller_profile; + } + switch_assert(channel->caller_profile->origination_caller_profile->next != channel->caller_profile->origination_caller_profile); + switch_mutex_unlock(channel->profile_mutex); +} + +SWITCH_DECLARE(switch_caller_profile_t *) switch_channel_get_origination_caller_profile(switch_channel_t *channel) +{ + switch_caller_profile_t *profile = NULL; + switch_assert(channel != NULL); + + switch_mutex_lock(channel->profile_mutex); + if (channel->caller_profile) { + profile = channel->caller_profile->origination_caller_profile; + } + switch_mutex_unlock(channel->profile_mutex); + + return profile; +} + + SWITCH_DECLARE(void) switch_channel_set_originatee_caller_profile(switch_channel_t *channel, switch_caller_profile_t *caller_profile) { switch_assert(channel != NULL); diff --git a/src/switch_core_session.c b/src/switch_core_session.c index 74131644f9..9e942fea5e 100644 --- a/src/switch_core_session.c +++ b/src/switch_core_session.c @@ -524,6 +524,14 @@ SWITCH_DECLARE(switch_call_cause_t) switch_core_session_outgoing_channel(switch_ switch_channel_set_originator_caller_profile(peer_channel, cloned_profile); } } + + + if ((profile = switch_channel_get_caller_profile(peer_channel))) { + if ((cloned_profile = switch_caller_profile_clone(session, profile)) != 0) { + switch_channel_set_origination_caller_profile(channel, cloned_profile); + } + } + } if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_OUTGOING) == SWITCH_STATUS_SUCCESS) { diff --git a/src/switch_ivr.c b/src/switch_ivr.c index 61deece636..c1dc33651c 100644 --- a/src/switch_ivr.c +++ b/src/switch_ivr.c @@ -2012,6 +2012,21 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_generate_xml_cdr(switch_core_session_ cp_off += switch_ivr_set_xml_profile_data(x_main_cp, caller_profile, 0); + if (caller_profile->origination_caller_profile) { + switch_caller_profile_t *cp = NULL; + int off = 0; + if (!(x_o = switch_xml_add_child_d(x_main_cp, "origination", cp_off++))) { + goto error; + } + + for (cp = caller_profile->origination_caller_profile; cp; cp = cp->next) { + if (!(x_caller_profile = switch_xml_add_child_d(x_o, "origination_caller_profile", off++))) { + goto error; + } + switch_ivr_set_xml_profile_data(x_caller_profile, cp, 0); + } + } + if (caller_profile->originator_caller_profile) { switch_caller_profile_t *cp = NULL; int off = 0;