]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
[FS-11608] [core] set prefix for caller profile soft variables
authorlazedo <luis.azedo@factorlusitano.com>
Tue, 18 Dec 2018 10:55:55 +0000 (10:55 +0000)
committerlazedo <luis.azedo@factorlusitano.com>
Wed, 30 Jan 2019 23:54:16 +0000 (23:54 +0000)
src/include/switch_types.h
src/switch_caller.c
src/switch_core.c

index 926c8a6bea0c6009d78d073e7fa7b10f2d68cd75..afb3e4e7c6c1e3433141c508de9e7351d0f0eff8 100644 (file)
@@ -377,7 +377,8 @@ typedef enum {
        SCF_DEBUG_SQL = (1 << 21),
        SCF_API_EXPANSION = (1 << 22),
        SCF_SESSION_THREAD_POOL = (1 << 23),
-       SCF_DIALPLAN_TIMESTAMPS = (1 << 24)
+       SCF_DIALPLAN_TIMESTAMPS = (1 << 24),
+       SCF_CPF_SOFT_PREFIX = (1 << 25)
 } switch_core_flag_enum_t;
 typedef uint32_t switch_core_flag_t;
 
@@ -578,7 +579,8 @@ typedef enum {
        SWITCH_CPF_NONE = 0,
        SWITCH_CPF_SCREEN = (1 << 0),
        SWITCH_CPF_HIDE_NAME = (1 << 1),
-       SWITCH_CPF_HIDE_NUMBER = (1 << 2)
+       SWITCH_CPF_HIDE_NUMBER = (1 << 2),
+       SWITCH_CPF_SOFT_PREFIX = (1 << 3)
 } switch_caller_profile_flag_enum_t;
 typedef uint32_t switch_caller_profile_flag_t;
 
index d3b835ec80f008ffe45e0c920a363364537fb287..0667d65dd6bf8310cf6b63642a940d00874267fd 100644 (file)
@@ -97,6 +97,9 @@ SWITCH_DECLARE(switch_caller_profile_t *) switch_caller_profile_new(switch_memor
        profile->callee_id_name = SWITCH_BLANK_STRING;
        profile->callee_id_number = SWITCH_BLANK_STRING;
        switch_set_flag(profile, SWITCH_CPF_SCREEN);
+       if (switch_core_test_flag(SCF_CPF_SOFT_PREFIX)) {
+               switch_set_flag(profile, SWITCH_CPF_SOFT_PREFIX);
+       }
        profile->pool = pool;
        return profile;
 }
@@ -399,7 +402,12 @@ SWITCH_DECLARE(void) switch_caller_profile_event_set_data(switch_caller_profile_
                profile_node_t *pn;
 
                for (pn = caller_profile->soft; pn; pn = pn->next) {
-                       switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, pn->var, pn->val);
+                       if (switch_test_flag(caller_profile, SWITCH_CPF_SOFT_PREFIX)) {
+                               switch_snprintf(header_name, sizeof(header_name), "%s-%s", prefix, pn->var);
+                               switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, pn->val);
+                       } else {
+                               switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, pn->var, pn->val);
+                       }
                }
 
        }
index ca87b5f8cd2ee6a381d10a4b2b732502f433b530..443b8bc0b88ac4c871dc3cb4ac37b6539dc407c7 100644 (file)
@@ -2340,6 +2340,13 @@ static void switch_load_core_config(const char *file)
                                                                                  "rtp-retain-crypto-keys enabled. Could be used to decrypt secure media.\n");
                                        }
                                        switch_core_set_variable("rtp_retain_crypto_keys", val);
+                               } else if (!strcasecmp(var, "caller-profile-soft-variables-uses-prefix") && !zstr(val)) {
+                                       int v = switch_true(val);
+                                       if (v) {
+                                               switch_set_flag((&runtime), SCF_CPF_SOFT_PREFIX);
+                                       } else {
+                                               switch_clear_flag((&runtime), SCF_CPF_SOFT_PREFIX);
+                                       }
                                }
                        }
                }