]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
[FS-11609] [core] lookup values in caller profile soft variables
authorlazedo <luis.azedo@factorlusitano.com>
Mon, 18 Feb 2019 14:03:24 +0000 (14:03 +0000)
committerlazedo <luis.azedo@factorlusitano.com>
Mon, 18 Feb 2019 14:03:24 +0000 (14:03 +0000)
src/include/switch_types.h
src/switch_caller.c
src/switch_core.c

index afb3e4e7c6c1e3433141c508de9e7351d0f0eff8..aec3ae0bd168ba70d10cd197c4dd8bcc930b0c90 100644 (file)
@@ -378,7 +378,8 @@ typedef enum {
        SCF_API_EXPANSION = (1 << 22),
        SCF_SESSION_THREAD_POOL = (1 << 23),
        SCF_DIALPLAN_TIMESTAMPS = (1 << 24),
-       SCF_CPF_SOFT_PREFIX = (1 << 25)
+       SCF_CPF_SOFT_PREFIX = (1 << 25),
+       SCF_CPF_SOFT_LOOKUP = (1 << 26)
 } switch_core_flag_enum_t;
 typedef uint32_t switch_core_flag_t;
 
@@ -580,7 +581,8 @@ typedef enum {
        SWITCH_CPF_SCREEN = (1 << 0),
        SWITCH_CPF_HIDE_NAME = (1 << 1),
        SWITCH_CPF_HIDE_NUMBER = (1 << 2),
-       SWITCH_CPF_SOFT_PREFIX = (1 << 3)
+       SWITCH_CPF_SOFT_PREFIX = (1 << 3),
+       SWITCH_CPF_SOFT_LOOKUP = (1 << 4)
 } switch_caller_profile_flag_enum_t;
 typedef uint32_t switch_caller_profile_flag_t;
 
index 0667d65dd6bf8310cf6b63642a940d00874267fd..37a3683039c36c8030595961ef57447f73be2eed 100644 (file)
@@ -100,6 +100,9 @@ SWITCH_DECLARE(switch_caller_profile_t *) switch_caller_profile_new(switch_memor
        if (switch_core_test_flag(SCF_CPF_SOFT_PREFIX)) {
                switch_set_flag(profile, SWITCH_CPF_SOFT_PREFIX);
        }
+       if (switch_core_test_flag(SCF_CPF_SOFT_LOOKUP)) {
+               switch_set_flag(profile, SWITCH_CPF_SOFT_LOOKUP);
+       }
        profile->pool = pool;
        return profile;
 }
@@ -304,6 +307,14 @@ SWITCH_DECLARE(const char *) switch_caller_get_field_by_name(switch_caller_profi
                return switch_core_sprintf(caller_profile->pool, "%" SWITCH_TIME_T_FMT, caller_profile->times->transferred);
        }
 
+       if (caller_profile->soft && switch_test_flag(caller_profile, SWITCH_CPF_SOFT_LOOKUP)) {
+               profile_node_t *pn;
+               for (pn = caller_profile->soft; pn; pn = pn->next) {
+                       if (!strcasecmp(name, pn->var)) {
+                               return pn->val;
+                       }
+               }
+       }
 
        return NULL;
 }
index 443b8bc0b88ac4c871dc3cb4ac37b6539dc407c7..596ef2bbe4fef5cfab9280fb0c1c95119248c02b 100644 (file)
@@ -2347,6 +2347,13 @@ static void switch_load_core_config(const char *file)
                                        } else {
                                                switch_clear_flag((&runtime), SCF_CPF_SOFT_PREFIX);
                                        }
+                               } else if (!strcasecmp(var, "caller-profile-soft-lookup-values") && !zstr(val)) {
+                                       int v = switch_true(val);
+                                       if (v) {
+                                               switch_set_flag((&runtime), SCF_CPF_SOFT_LOOKUP);
+                                       } else {
+                                               switch_clear_flag((&runtime), SCF_CPF_SOFT_LOOKUP);
+                                       }
                                }
                        }
                }