]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
allow creation of arbitrary profile vars
authorAnthony Minessale <anthm@freeswitch.org>
Fri, 13 May 2011 20:29:40 +0000 (15:29 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Fri, 13 May 2011 20:29:40 +0000 (15:29 -0500)
src/include/switch_caller.h
src/switch_caller.c
src/switch_channel.c
src/switch_ivr.c

index bd53a04f685536e3ce11abcaebf1956f8703d3de..fde3372105401da35e07e61717715de30b6faf7f 100644 (file)
 #include <switch.h>
 
 SWITCH_BEGIN_EXTERN_C
+
+typedef struct profile_node_s {
+       char *var;
+       char *val;
+       struct profile_node_s *next;
+} profile_node_t;
+
+
+
 /*! \brief Call Specific Data
  */
        struct switch_caller_profile {
@@ -110,6 +119,7 @@ SWITCH_BEGIN_EXTERN_C
        switch_memory_pool_t *pool;
        struct switch_caller_profile *next;
        switch_call_direction_t direction;
+       profile_node_t *soft;
 };
 
 /*! \brief An Abstract Representation of a dialplan Application */
index d0d242fe9091446f1d36831143d1de96d1c602a7..5e3070548eb09f99f9818e1e615268ee940827d0 100644 (file)
@@ -324,6 +324,16 @@ SWITCH_DECLARE(void) switch_caller_profile_event_set_data(switch_caller_profile_
                switch_snprintf(header_name, sizeof(header_name), "%s-Profile-Index", prefix);
                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, caller_profile->profile_index);
        }
+
+       if (caller_profile->soft) {
+               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 (caller_profile->times) {
                switch_snprintf(header_name, sizeof(header_name), "%s-Profile-Created-Time", prefix);
                switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, "%" SWITCH_TIME_T_FMT, caller_profile->times->profile_created);
index d0c478a1703f9a0fcf59ab6d29fbb46b8f0b3d46..76538bdaa6d7951caa7f63624d39ced8353939f7 100644 (file)
@@ -877,7 +877,20 @@ SWITCH_DECLARE(switch_status_t) switch_channel_set_profile_var(switch_channel_t
        } else if (!strcasecmp(name, "chan_name")) {
                channel->caller_profile->chan_name = v;
        } else {
-               status = SWITCH_STATUS_FALSE;
+               profile_node_t *pn, *n = switch_core_alloc(channel->caller_profile->pool, sizeof(*n));
+               
+               n->var = switch_core_strdup(channel->caller_profile->pool, name);
+               n->val = v;
+
+               if (!channel->caller_profile->soft) {
+                       channel->caller_profile->soft = n;
+               } else {
+                       for(pn = channel->caller_profile->soft; pn && pn->next; pn = pn->next);
+                       
+                       if (pn) {
+                               pn->next = n;
+                       }
+               }
        }
        switch_mutex_unlock(channel->profile_mutex);
 
index ee7fe868b17ccbfae39e8d0e3e84be43c0bc4739..2f0066f4155b144ab6263731c139b4121b494de1 100644 (file)
@@ -1964,6 +1964,21 @@ SWITCH_DECLARE(int) switch_ivr_set_xml_profile_data(switch_xml_t xml, switch_cal
        }
        switch_xml_set_txt_d(param, caller_profile->chan_name);
 
+
+       if (caller_profile->soft) {
+               profile_node_t *pn;
+
+               for (pn = caller_profile->soft; pn; pn = pn->next) {
+
+                       if (!(param = switch_xml_add_child_d(xml, pn->var, off++))) {
+                               return -1;
+                       }
+                       switch_xml_set_txt_d(param, pn->val);
+               }
+
+       }
+
+
        return off;
 }