allow creation of arbitrary profile vars
This commit is contained in:
parent
acf3090adf
commit
8764a046c6
|
@ -56,6 +56,15 @@
|
||||||
#include <switch.h>
|
#include <switch.h>
|
||||||
|
|
||||||
SWITCH_BEGIN_EXTERN_C
|
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
|
/*! \brief Call Specific Data
|
||||||
*/
|
*/
|
||||||
struct switch_caller_profile {
|
struct switch_caller_profile {
|
||||||
|
@ -110,6 +119,7 @@ SWITCH_BEGIN_EXTERN_C
|
||||||
switch_memory_pool_t *pool;
|
switch_memory_pool_t *pool;
|
||||||
struct switch_caller_profile *next;
|
struct switch_caller_profile *next;
|
||||||
switch_call_direction_t direction;
|
switch_call_direction_t direction;
|
||||||
|
profile_node_t *soft;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*! \brief An Abstract Representation of a dialplan Application */
|
/*! \brief An Abstract Representation of a dialplan Application */
|
||||||
|
|
|
@ -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_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);
|
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) {
|
if (caller_profile->times) {
|
||||||
switch_snprintf(header_name, sizeof(header_name), "%s-Profile-Created-Time", prefix);
|
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);
|
switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, "%" SWITCH_TIME_T_FMT, caller_profile->times->profile_created);
|
||||||
|
|
|
@ -877,7 +877,20 @@ SWITCH_DECLARE(switch_status_t) switch_channel_set_profile_var(switch_channel_t
|
||||||
} else if (!strcasecmp(name, "chan_name")) {
|
} else if (!strcasecmp(name, "chan_name")) {
|
||||||
channel->caller_profile->chan_name = v;
|
channel->caller_profile->chan_name = v;
|
||||||
} else {
|
} 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);
|
switch_mutex_unlock(channel->profile_mutex);
|
||||||
|
|
||||||
|
|
|
@ -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);
|
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;
|
return off;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue