]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add origination_caller_profile to log all attempted calls for a paticular leg
authorAnthony Minessale <anthm@freeswitch.org>
Wed, 8 Sep 2010 18:19:56 +0000 (13:19 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Wed, 8 Sep 2010 18:19:56 +0000 (13:19 -0500)
src/include/switch_caller.h
src/include/switch_channel.h
src/switch_channel.c
src/switch_core_session.c
src/switch_ivr.c

index b3002081da25791400e9098b749cb284b0c61463..f77f1b016d070677f84de2b6ad675aa883edb840 100644 (file)
@@ -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;
index 247beae46007fb6fedaf156552e692778da039b3..3f92534e3e7e8b8931529f289c39fee281352c92 100644 (file)
@@ -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
index d1308a1e9f68649e6f6e4166933f4750a19b4ee7..e3d77d72392a0958894342a67f864bbf02a0e009 100644 (file)
@@ -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);
index 74131644f925ee69a6fd2deaab87c9ffd0378abe..9e942fea5e3b4e5d447813221df299a237fdaeed 100644 (file)
@@ -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) {
index 61deece636a9fe7b839385d75841163dd9dd7598..c1dc33651cd3e140588f571356fa49f3f11625a3 100644 (file)
@@ -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;