]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
tweaks for caller id in certian uuid_bridge situations
authorAnthony Minessale <anthm@freeswitch.org>
Fri, 29 Mar 2013 03:17:28 +0000 (22:17 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Fri, 29 Mar 2013 03:17:28 +0000 (22:17 -0500)
src/include/switch_channel.h
src/mod/applications/mod_fifo/mod_fifo.c
src/switch_channel.c
src/switch_ivr_bridge.c

index 73eb7f102603c0d828a8857eaf68003a598bf2ec..6af8cfb72ce2ba94b059f0b3b06d3351561c7780 100644 (file)
@@ -187,6 +187,7 @@ SWITCH_DECLARE(void) switch_channel_uninit(switch_channel_t *channel);
   \param caller_profile the profile to assign
 */
 SWITCH_DECLARE(void) switch_channel_set_caller_profile(switch_channel_t *channel, switch_caller_profile_t *caller_profile);
+SWITCH_DECLARE(void) switch_channel_step_caller_profile(switch_channel_t *channel);
 
 /*!
   \brief Retrieve the given channel's caller profile
@@ -200,7 +201,8 @@ SWITCH_DECLARE(switch_caller_profile_t *) switch_channel_get_caller_profile(swit
   \param channel channel to assign the profile to
   \param caller_profile the profile to assign
 */
-SWITCH_DECLARE(void) switch_channel_set_originator_caller_profile(switch_channel_t *channel, switch_caller_profile_t *caller_profile);
+SWITCH_DECLARE(void) _switch_channel_set_originator_caller_profile(switch_channel_t *channel, switch_caller_profile_t *caller_profile);
+#define switch_channel_set_originator_caller_profile(_c, _cp) switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(_c), SWITCH_LOG_CRIT, "%s SET ORIGINATOR\n", switch_channel_get_name(_c)); _switch_channel_set_originator_caller_profile(_c, _cp)
 
 SWITCH_DECLARE(void) switch_channel_set_hunt_caller_profile(switch_channel_t *channel, switch_caller_profile_t *caller_profile);
 
@@ -216,7 +218,8 @@ SWITCH_DECLARE(switch_caller_profile_t *) switch_channel_get_originator_caller_p
   \param channel channel to assign the profile to
   \param caller_profile the profile to assign
 */
-SWITCH_DECLARE(void) switch_channel_set_originatee_caller_profile(switch_channel_t *channel, switch_caller_profile_t *caller_profile);
+SWITCH_DECLARE(void) _switch_channel_set_originatee_caller_profile(switch_channel_t *channel, switch_caller_profile_t *caller_profile);
+#define switch_channel_set_originatee_caller_profile(_c, _cp) switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(_c), SWITCH_LOG_CRIT, "%s SET ORIGINATEE\n", switch_channel_get_name(_c)); _switch_channel_set_originatee_caller_profile(_c, _cp)
 
 /*!
   \brief Retrieve the given channel's originatee caller profile
@@ -651,6 +654,7 @@ SWITCH_DECLARE(void) switch_channel_state_thread_lock(switch_channel_t *channel)
 SWITCH_DECLARE(void) switch_channel_state_thread_unlock(switch_channel_t *channel);
 SWITCH_DECLARE(switch_status_t) switch_channel_state_thread_trylock(switch_channel_t *channel);
 
+
 SWITCH_END_EXTERN_C
 #endif
 /* For Emacs:
index 7e75326147e7d34e04f063bf652ce537f1ef83c5..685517beefc00c0c19b7378dad3ad509b013450d 100644 (file)
@@ -2906,7 +2906,7 @@ SWITCH_STANDARD_APP(fifo_function)
 
                        if (node && other_session) {
                                switch_channel_t *other_channel = switch_core_session_get_channel(other_session);
-                               switch_caller_profile_t *cloned_profile;
+                               switch_caller_profile_t *cloned_profile, *a_cp, *b_cp;
                                const char *o_announce = NULL;
                                const char *record_template = switch_channel_get_variable(channel, "fifo_record_template");
                                char *expanded = NULL;
@@ -2931,7 +2931,6 @@ SWITCH_STANDARD_APP(fifo_function)
 
                                switch_channel_set_variable(other_channel, "fifo_serviced_by", my_id);
                                switch_channel_set_variable(other_channel, "fifo_serviced_uuid", switch_core_session_get_uuid(session));
-
                                switch_channel_set_flag(other_channel, CF_BREAK);
 
                                while (switch_channel_ready(channel) && switch_channel_ready(other_channel) &&
@@ -2981,15 +2980,29 @@ SWITCH_STANDARD_APP(fifo_function)
                                }
 
                                switch_channel_answer(channel);
-                               cloned_profile = switch_caller_profile_clone(other_session, switch_channel_get_caller_profile(channel));
+
+                               a_cp = switch_channel_get_caller_profile(channel);
+                               b_cp = switch_channel_get_caller_profile(other_channel);
+                               
+
+
+                               cloned_profile = switch_caller_profile_clone(other_session, a_cp);
                                switch_assert(cloned_profile);
                                switch_channel_set_originator_caller_profile(other_channel, cloned_profile);
 
-                               cloned_profile = switch_caller_profile_clone(session, switch_channel_get_caller_profile(other_channel));
+                               a_cp->callee_id_name = switch_core_strdup(a_cp->pool, b_cp->caller_id_name);
+                               a_cp->callee_id_number = switch_core_strdup(a_cp->pool, b_cp->caller_id_number);
+
+
+                               cloned_profile = switch_caller_profile_clone(session, b_cp);
                                switch_assert(cloned_profile);
                                switch_assert(cloned_profile->next == NULL);
                                switch_channel_set_originatee_caller_profile(channel, cloned_profile);
 
+                               b_cp->callee_id_name = switch_core_strdup(b_cp->pool, a_cp->caller_id_name);
+                               b_cp->callee_id_number = switch_core_strdup(b_cp->pool, a_cp->caller_id_number);
+
+
                                ts = switch_micro_time_now();
                                switch_time_exp_lt(&tm, ts);
                                epoch_start = (long)switch_epoch_time_now(NULL);
index f673c8659f26376ae785178ddc857137bea1ca30..95b7fe0756b481e257558de93fce005279ca6ec9 100644 (file)
@@ -2497,7 +2497,17 @@ SWITCH_DECLARE(void) switch_channel_event_set_data(switch_channel_t *channel, sw
        switch_mutex_unlock(channel->profile_mutex);
 }
 
+SWITCH_DECLARE(void) switch_channel_step_caller_profile(switch_channel_t *channel)
+{
+       switch_caller_profile_t *cp;
+
 
+       switch_mutex_lock(channel->profile_mutex);
+       cp = switch_caller_profile_clone(channel->session, channel->caller_profile);
+       switch_mutex_unlock(channel->profile_mutex);
+       
+       switch_channel_set_caller_profile(channel, cp);
+}
 
 SWITCH_DECLARE(void) switch_channel_set_caller_profile(switch_channel_t *channel, switch_caller_profile_t *caller_profile)
 {
@@ -2561,7 +2571,7 @@ SWITCH_DECLARE(switch_caller_profile_t *) switch_channel_get_caller_profile(swit
        return profile;
 }
 
-SWITCH_DECLARE(void) switch_channel_set_originator_caller_profile(switch_channel_t *channel, switch_caller_profile_t *caller_profile)
+SWITCH_DECLARE(void) _switch_channel_set_originator_caller_profile(switch_channel_t *channel, switch_caller_profile_t *caller_profile)
 {
        switch_assert(channel != NULL);
        switch_assert(channel->caller_profile != NULL);
@@ -2625,7 +2635,7 @@ SWITCH_DECLARE(switch_caller_profile_t *) switch_channel_get_origination_caller_
 }
 
 
-SWITCH_DECLARE(void) switch_channel_set_originatee_caller_profile(switch_channel_t *channel, switch_caller_profile_t *caller_profile)
+SWITCH_DECLARE(void) _switch_channel_set_originatee_caller_profile(switch_channel_t *channel, switch_caller_profile_t *caller_profile)
 {
        switch_assert(channel != NULL);
        switch_assert(channel->caller_profile != NULL);
index 96d664e5fdaa99a8ea252be5be96e6dbb9e74229..695105b8da6b5aca6ec4caab51cbd61ee9b7be83 100644 (file)
@@ -1648,9 +1648,21 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_uuid_bridge(const char *originator_uu
                        switch_channel_set_variable(originator_channel, "original_caller_id_name", originator_cp->caller_id_name);
                        switch_channel_set_variable(originator_channel, "original_caller_id_number", originator_cp->caller_id_number);
 
+                       switch_channel_step_caller_profile(originatee_channel);
+                       switch_channel_step_caller_profile(originator_channel);
+
+                       originator_cp = switch_channel_get_caller_profile(originator_channel);
+                       originatee_cp = switch_channel_get_caller_profile(originatee_channel);
 
                        switch_channel_set_originator_caller_profile(originatee_channel, switch_caller_profile_clone(originatee_session, originator_cp));
                        switch_channel_set_originatee_caller_profile(originator_channel, switch_caller_profile_clone(originator_session, originatee_cp));
+                       
+                       originator_cp->callee_id_name = switch_core_strdup(originator_cp->pool, originatee_cp->caller_id_name);
+                       originator_cp->callee_id_number = switch_core_strdup(originator_cp->pool, originatee_cp->caller_id_number);
+
+                       originatee_cp->callee_id_name = switch_core_strdup(originatee_cp->pool, originator_cp->caller_id_name);
+                       originatee_cp->callee_id_number = switch_core_strdup(originatee_cp->pool, originator_cp->caller_id_number);
+                       
 
                        switch_channel_stop_broadcast(originator_channel);
                        switch_channel_stop_broadcast(originatee_channel);