]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
refactor and cleanup more cid stuff
authorAnthony Minessale <anthm@freeswitch.org>
Fri, 5 Apr 2013 20:29:14 +0000 (15:29 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Fri, 5 Apr 2013 20:29:14 +0000 (15:29 -0500)
src/include/switch_channel.h
src/mod/applications/mod_fifo/mod_fifo.c
src/switch_channel.c
src/switch_ivr_bridge.c

index 0fe6bdda9e0047cd9ba76367db3a40f36f106695..1ace3893b34aba85643b41954dd37a46928ec882 100644 (file)
@@ -334,6 +334,7 @@ SWITCH_DECLARE(switch_status_t) switch_channel_caller_extension_masquerade(switc
 */
 SWITCH_DECLARE(void) switch_channel_set_caller_extension(switch_channel_t *channel, switch_caller_extension_t *caller_extension);
 
+SWITCH_DECLARE(void) switch_channel_invert_cid(switch_channel_t *channel);
 SWITCH_DECLARE(void) switch_channel_flip_cid(switch_channel_t *channel);
 SWITCH_DECLARE(void) switch_channel_sort_cid(switch_channel_t *channel);
 
@@ -603,7 +604,9 @@ SWITCH_DECLARE(void) switch_channel_event_set_extended_data(_In_ switch_channel_
 SWITCH_DECLARE(char *) switch_channel_expand_variables_check(switch_channel_t *channel, const char *in, switch_event_t *var_list, switch_event_t *api_list, uint32_t recur);
 #define switch_channel_expand_variables(_channel, _in) switch_channel_expand_variables_check(_channel, _in, NULL, NULL, 0)
 
-#define switch_channel_inbound_display(_channel) (switch_channel_direction(_channel) == SWITCH_CALL_DIRECTION_INBOUND || switch_channel_test_flag(_channel, CF_DIALPLAN))
+#define switch_channel_inbound_display(_channel) ((switch_channel_direction(_channel) == SWITCH_CALL_DIRECTION_INBOUND && !switch_channel_test_flag(_channel, CF_BLEG)) || (switch_channel_direction(_channel) == SWITCH_CALL_DIRECTION_OUTBOUND && switch_channel_test_flag(_channel, CF_DIALPLAN)))
+
+#define switch_channel_outbound_display(_channel) ((switch_channel_direction(_channel) == SWITCH_CALL_DIRECTION_INBOUND && switch_channel_test_flag(_channel, CF_BLEG)) || (switch_channel_direction(_channel) == SWITCH_CALL_DIRECTION_OUTBOUND && !switch_channel_test_flag(_channel, CF_DIALPLAN)))
 
 SWITCH_DECLARE(char *) switch_channel_build_param_string(_In_ switch_channel_t *channel, _In_opt_ switch_caller_profile_t *caller_profile,
                                                                                                                 _In_opt_ const char *prefix);
index 084f16cfcbb85c426d8a115e92daff86579e85e7..934603cc0c0d027a80c4ea2fa0e163952f161c2f 100644 (file)
@@ -2985,18 +2985,7 @@ SWITCH_STANDARD_APP(fifo_function)
                                originatee_cp = switch_channel_get_caller_profile(other_channel);
 
                                if (switch_channel_inbound_display(other_channel)) {
-                                       const char *tname = originatee_cp->caller_id_name;
-                                       const char *tnum = originatee_cp->caller_id_number;
-                                       
-#ifdef DEEP_DEBUG_CID
-                                       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "SWAP [%s][%s] [%s][%s]\n", originatee_cp->caller_id_name, originatee_cp->caller_id_number, originatee_cp->callee_id_name, originatee_cp->callee_id_number);
-#endif
-                                               
-                                       originatee_cp->caller_id_name = originatee_cp->callee_id_name;
-                                       originatee_cp->caller_id_number = originatee_cp->callee_id_number;
-                                       
-                                       originatee_cp->callee_id_name = tname;
-                                       originatee_cp->callee_id_number = tnum;
+                                       switch_channel_invert_cid(other_channel);
 
                                        if (switch_channel_direction(other_channel) == SWITCH_CALL_DIRECTION_INBOUND) {
                                                switch_channel_set_flag(other_channel, CF_BLEG);
index 0a664994ea40daccc5659e27b8573c9a6a26777d..699ad796101b4f5ecf65b72c3b04e77ed24e7b92 100644 (file)
@@ -2850,6 +2850,36 @@ SWITCH_DECLARE(switch_status_t) switch_channel_caller_extension_masquerade(switc
        return status;
 }
 
+SWITCH_DECLARE(void) switch_channel_invert_cid(switch_channel_t *channel)
+{
+       const char *tname, *tnum;
+       switch_caller_profile_t *cp;
+
+       cp = switch_channel_get_caller_profile(channel);
+
+       tname = cp->caller_id_name;
+       tnum = cp->caller_id_number;
+
+#ifdef DEEP_DEBUG_CID
+       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "SWAP [%s][%s] [%s][%s]\n", originate_cp->caller_id_name, cp->caller_id_number, cp->callee_id_name, cp->callee_id_number);
+#endif
+
+       cp->caller_id_name = cp->callee_id_name;
+       cp->caller_id_number = cp->callee_id_number;
+       
+       cp->callee_id_name = tname;
+       cp->callee_id_number = tnum;
+
+       if (zstr(cp->caller_id_name)) {
+               cp->caller_id_name = "Unknown";
+       }
+
+       if (zstr(cp->caller_id_number)) {
+               cp->caller_id_number = "Unknown";
+       }
+}
+
+
 SWITCH_DECLARE(void) switch_channel_flip_cid(switch_channel_t *channel)
 {
        switch_event_t *event;
index 97364b14c05fd580b3cc7eb05311476f8174ec55..0df636cac5ab01b3dd759dd9a9cf4de40e36f0d8 100644 (file)
@@ -1652,20 +1652,19 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_uuid_bridge(const char *originator_uu
                        originator_cp = switch_channel_get_caller_profile(originator_channel);
                        originatee_cp = switch_channel_get_caller_profile(originatee_channel);
 
-                       if (switch_channel_inbound_display(originatee_channel)) {
-                               const char *tname = originatee_cp->caller_id_name;
-                               const char *tnum = originatee_cp->caller_id_number;
-
-#ifdef DEEP_DEBUG_CID
-                               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "SWAP [%s][%s] [%s][%s]\n", originatee_cp->caller_id_name, originatee_cp->caller_id_number, originatee_cp->callee_id_name, originatee_cp->callee_id_number);
-#endif
-
-                               originatee_cp->caller_id_name = originatee_cp->callee_id_name;
-                               originatee_cp->caller_id_number = originatee_cp->callee_id_number;
 
-                               originatee_cp->callee_id_name = tname;
-                               originatee_cp->callee_id_number = tnum;
+                       
+                       if (switch_channel_outbound_display(originator_channel)) {
+                               switch_channel_invert_cid(originator_channel);
+                               
+                               if (switch_channel_direction(originator_channel) == SWITCH_CALL_DIRECTION_INBOUND) {
+                                       switch_channel_clear_flag(originatee_channel, CF_BLEG);
+                               }
+                       }
 
+                       if (switch_channel_inbound_display(originatee_channel)) {
+                               switch_channel_invert_cid(originatee_channel);
+                               
                                if (switch_channel_direction(originatee_channel) == SWITCH_CALL_DIRECTION_INBOUND) {
                                        switch_channel_set_flag(originatee_channel, CF_BLEG);
                                }