mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-10-29 22:54:18 +00:00
change xml_lookups to take an event as params instead of url string this will break your xml_curl scripts please update
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@7333 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
1 parent
14ba0b9999
commit
1424b6c73b
16 files changed
+286
-103
No files matched your search
@@ -50,7 +50,7 @@ SWITCH_STANDARD_API(user_data_function)
|
||||
char delim = ' ';
|
||||
const char *err = NULL;
|
||||
const char *container = "params", *elem = "param";
|
||||
char *params = NULL;
|
||||
switch_event_t *params = NULL;
|
||||
|
||||
if (!cmd) {
|
||||
err = "bad args";
|
||||
@@ -77,7 +77,13 @@ SWITCH_STANDARD_API(user_data_function)
|
||||
domain = "cluecon.com";
|
||||
}
|
||||
|
||||
params = switch_mprintf("user=%s&domain=%s&type=%s&key=%s", user, domain, type, key);
|
||||
switch_event_create(¶ms, SWITCH_EVENT_MESSAGE);
|
||||
switch_assert(params);
|
||||
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "user", user);
|
||||
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "domain", domain);
|
||||
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "type", type);
|
||||
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "key", key);
|
||||
|
||||
|
||||
if (switch_xml_locate_user("id", user, domain, NULL, &xml, &x_domain, &x_user, params) != SWITCH_STATUS_SUCCESS) {
|
||||
err = "can't find user";
|
||||
@@ -87,6 +93,9 @@ SWITCH_STANDARD_API(user_data_function)
|
||||
|
||||
end:
|
||||
|
||||
switch_event_destroy(¶ms);
|
||||
|
||||
|
||||
if (xml) {
|
||||
if (err) {
|
||||
//stream->write_function(stream, "-Error %s\n", err);
|
||||
@@ -217,7 +226,8 @@ SWITCH_STANDARD_API(xml_locate_function)
|
||||
switch_xml_t xml = NULL, obj = NULL;
|
||||
int argc;
|
||||
char *mydata = NULL, *argv[4];
|
||||
char *section, *tag, *tag_attr_name, *tag_attr_val, *params = NULL;
|
||||
char *section, *tag, *tag_attr_name, *tag_attr_val;
|
||||
switch_event_t *params = NULL;
|
||||
char *xmlstr;
|
||||
char *path_info, delim = ' ';
|
||||
char *host = NULL;
|
||||
@@ -259,8 +269,13 @@ SWITCH_STANDARD_API(xml_locate_function)
|
||||
tag_attr_name = argv[2];
|
||||
tag_attr_val = argv[3];
|
||||
|
||||
params = switch_mprintf("section=%s&tag=%s&tag_attr_name=%s&tag_attr_val=%s", section, tag, tag_attr_name, tag_attr_val);
|
||||
switch_event_create(¶ms, SWITCH_EVENT_MESSAGE);
|
||||
switch_assert(params);
|
||||
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "section", section);
|
||||
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "tag", tag);
|
||||
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "tag_attr_name", tag_attr_name);
|
||||
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "tag_attr_val", tag_attr_val);
|
||||
|
||||
if (switch_xml_locate(section, tag, tag_attr_name, tag_attr_val, &xml, &obj, params) != SWITCH_STATUS_SUCCESS) {
|
||||
stream->write_function(stream, "can't find anything\n");
|
||||
goto end;
|
||||
@@ -269,6 +284,8 @@ SWITCH_STANDARD_API(xml_locate_function)
|
||||
|
||||
end:
|
||||
|
||||
switch_event_destroy(¶ms);
|
||||
|
||||
if (err) {
|
||||
if (host) {
|
||||
stream->write_function(stream, "<error>%s</error>\n", err);
|
||||
|
||||
@@ -3187,7 +3187,7 @@ static switch_status_t conf_api_sub_bgdial(conference_obj_t * conference, switch
|
||||
static switch_status_t conf_api_sub_transfer(conference_obj_t * conference, switch_stream_handle_t *stream, int argc, char **argv)
|
||||
{
|
||||
switch_status_t ret_status = SWITCH_STATUS_SUCCESS;
|
||||
char *params = NULL, *chanvars = NULL;
|
||||
switch_event_t *params = NULL;
|
||||
switch_assert(conference != NULL);
|
||||
switch_assert(stream != NULL);
|
||||
|
||||
@@ -3229,10 +3229,15 @@ static switch_status_t conf_api_sub_transfer(conference_obj_t * conference, swit
|
||||
} else {
|
||||
profile_name = "default";
|
||||
}
|
||||
params = switch_mprintf("conf_name=%s&profile_name=%s", conf_name, profile_name);
|
||||
chanvars = switch_channel_build_param_string(channel, NULL, params);
|
||||
|
||||
switch_event_create(¶ms, SWITCH_EVENT_MESSAGE);
|
||||
switch_assert(params);
|
||||
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "conf_name", conf_name);
|
||||
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "profile_name", profile_name);
|
||||
switch_channel_event_set_data(channel, params);
|
||||
|
||||
/* Open the config from the xml registry */
|
||||
if (!(cxml = switch_xml_open_cfg(global_cf_name, &cfg, chanvars))) {
|
||||
if (!(cxml = switch_xml_open_cfg(global_cf_name, &cfg, params))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", global_cf_name);
|
||||
goto done;
|
||||
}
|
||||
@@ -3303,9 +3308,9 @@ static switch_status_t conf_api_sub_transfer(conference_obj_t * conference, swit
|
||||
}
|
||||
|
||||
done:
|
||||
switch_safe_free(params);
|
||||
switch_safe_free(chanvars);
|
||||
|
||||
if (params) {
|
||||
switch_event_destroy(¶ms);
|
||||
}
|
||||
return ret_status;
|
||||
}
|
||||
|
||||
@@ -3980,7 +3985,7 @@ SWITCH_STANDARD_APP(conference_function)
|
||||
uint8_t rl = 0, isbr = 0;
|
||||
char *dpin = NULL;
|
||||
conf_xml_cfg_t xml_cfg = { 0 };
|
||||
char *params = NULL;
|
||||
switch_event_t *params = NULL;
|
||||
|
||||
switch_assert(channel != NULL);
|
||||
|
||||
@@ -4032,7 +4037,11 @@ SWITCH_STANDARD_APP(conference_function)
|
||||
profile_name = "default";
|
||||
}
|
||||
|
||||
params = switch_mprintf("conf_name=%s&profile_name=%s", conf_name, profile_name);
|
||||
|
||||
switch_event_create(¶ms, SWITCH_EVENT_MESSAGE);
|
||||
switch_assert(params);
|
||||
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "conf_name", conf_name);
|
||||
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "profile_name", profile_name);
|
||||
|
||||
/* Open the config from the xml registry */
|
||||
if (!(cxml = switch_xml_open_cfg(global_cf_name, &cfg, params))) {
|
||||
@@ -4337,7 +4346,7 @@ SWITCH_STANDARD_APP(conference_function)
|
||||
codec_done2:
|
||||
switch_core_codec_destroy(&member.write_codec);
|
||||
done:
|
||||
switch_safe_free(params);
|
||||
switch_event_destroy(¶ms);
|
||||
switch_buffer_destroy(&member.resample_buffer);
|
||||
switch_buffer_destroy(&member.audio_buffer);
|
||||
switch_buffer_destroy(&member.mux_buffer);
|
||||
@@ -4957,9 +4966,15 @@ static void pres_event_handler(switch_event_t *event)
|
||||
static void send_presence(switch_event_types_t id)
|
||||
{
|
||||
switch_xml_t cxml, cfg, advertise, room;
|
||||
switch_event_t *params = NULL;
|
||||
|
||||
switch_event_create(¶ms, SWITCH_EVENT_MESSAGE);
|
||||
switch_assert(params);
|
||||
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "presence", "true");
|
||||
|
||||
|
||||
/* Open the config from the xml registry */
|
||||
if (!(cxml = switch_xml_open_cfg(global_cf_name, &cfg, "presence"))) {
|
||||
if (!(cxml = switch_xml_open_cfg(global_cf_name, &cfg, params))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", global_cf_name);
|
||||
goto done;
|
||||
}
|
||||
@@ -4983,6 +4998,8 @@ static void send_presence(switch_event_types_t id)
|
||||
}
|
||||
|
||||
done:
|
||||
switch_event_destroy(¶ms);
|
||||
|
||||
/* Release the config registry handle */
|
||||
if (cxml) {
|
||||
switch_xml_free(cxml);
|
||||
|
||||
@@ -864,16 +864,19 @@ static switch_ivr_action_t menu_handler(switch_ivr_menu_t * menu, char *param, c
|
||||
SWITCH_STANDARD_APP(ivr_application_function)
|
||||
{
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
char *params,*chanvars;
|
||||
|
||||
if (channel && !switch_strlen_zero(data) && (params = switch_core_session_strdup(session, data))) {
|
||||
switch_event_t *params;
|
||||
|
||||
if (channel) {
|
||||
switch_xml_t cxml = NULL, cfg = NULL, xml_menus = NULL, xml_menu = NULL;
|
||||
|
||||
// Open the config from the xml registry
|
||||
chanvars = switch_channel_build_param_string(channel, NULL, NULL);
|
||||
if ((cxml = switch_xml_open_cfg(ivr_cf_name, &cfg, chanvars)) != NULL) {
|
||||
switch_event_create(¶ms, SWITCH_EVENT_MESSAGE);
|
||||
switch_assert(params);
|
||||
switch_channel_event_set_data(channel, params);
|
||||
|
||||
if ((cxml = switch_xml_open_cfg(ivr_cf_name, &cfg, params)) != NULL) {
|
||||
if ((xml_menus = switch_xml_child(cfg, "menus"))) {
|
||||
xml_menu = switch_xml_find_child(xml_menus, "menu", "name", params);
|
||||
xml_menu = switch_xml_find_child(xml_menus, "menu", "name", (char *)data);
|
||||
|
||||
// if the menu was found
|
||||
if (xml_menu != NULL) {
|
||||
@@ -889,20 +892,20 @@ SWITCH_STANDARD_APP(ivr_application_function)
|
||||
switch_xml_free(cxml);
|
||||
cxml = NULL;
|
||||
switch_channel_pre_answer(channel);
|
||||
switch_ivr_menu_execute(session, menu_stack, params, NULL);
|
||||
switch_ivr_menu_execute(session, menu_stack, (char *)data, NULL);
|
||||
switch_ivr_menu_stack_free(menu_stack);
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to create menu '%s'\n", params);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to create menu\n");
|
||||
}
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to find menu '%s'\n", params);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to find menu\n");
|
||||
}
|
||||
}
|
||||
switch_xml_free(cxml);
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", ivr_cf_name);
|
||||
}
|
||||
switch_safe_free(chanvars);
|
||||
switch_event_destroy(¶ms);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1414,7 +1417,7 @@ static switch_call_cause_t user_outgoing_channel(switch_core_session_t *session,
|
||||
static switch_call_cause_t cause = SWITCH_CAUSE_UNALLOCATED;
|
||||
unsigned int timelimit = 60;
|
||||
switch_channel_t *new_channel = NULL;
|
||||
|
||||
switch_event_t *params;
|
||||
if (switch_strlen_zero(outbound_profile->destination_number)) {
|
||||
goto done;
|
||||
}
|
||||
@@ -1427,7 +1430,12 @@ static switch_call_cause_t user_outgoing_channel(switch_core_session_t *session,
|
||||
|
||||
*domain++ = '\0';
|
||||
|
||||
if (switch_xml_locate_user("id", user, domain, NULL, &xml, &x_domain, &x_user, "as_channel=true") != SWITCH_STATUS_SUCCESS) {
|
||||
switch_event_create(¶ms, SWITCH_EVENT_MESSAGE);
|
||||
switch_assert(params);
|
||||
switch_event_add_header(params, SWITCH_STACK_BOTTOM, "as_channel", "true");
|
||||
|
||||
|
||||
if (switch_xml_locate_user("id", user, domain, NULL, &xml, &x_domain, &x_user, params) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "can't find user [%s@%s]\n", user, domain);
|
||||
goto done;
|
||||
}
|
||||
@@ -1458,6 +1466,8 @@ static switch_call_cause_t user_outgoing_channel(switch_core_session_t *session,
|
||||
|
||||
done:
|
||||
|
||||
switch_event_destroy(¶ms);
|
||||
|
||||
if (dest) {
|
||||
const char *var;
|
||||
char *d_dest = NULL;
|
||||
|
||||
@@ -1562,20 +1562,24 @@ case VM_CHECK_AUTH:
|
||||
}
|
||||
|
||||
if (!x_user) {
|
||||
char *xtra;
|
||||
switch_event_t *params;
|
||||
int ok = 1;
|
||||
caller_profile = switch_channel_get_caller_profile(channel);
|
||||
xtra = switch_mprintf("mailbox=%s&destination_number=%s&caller_id_number=%s",
|
||||
myid,caller_profile->destination_number,caller_profile->caller_id_number);
|
||||
switch_assert(xtra);
|
||||
|
||||
switch_event_create(¶ms, SWITCH_EVENT_MESSAGE);
|
||||
switch_assert(params);
|
||||
switch_event_add_header(params, SWITCH_STACK_BOTTOM, "mailbox", myid);
|
||||
switch_event_add_header(params, SWITCH_STACK_BOTTOM, "destination_number", caller_profile->destination_number);
|
||||
switch_event_add_header(params, SWITCH_STACK_BOTTOM, "caller_id_number", caller_profile->caller_id_number);
|
||||
|
||||
|
||||
if (switch_xml_locate_user("id", myid, domain_name, switch_channel_get_variable(channel, "network_addr"),
|
||||
&x_domain_root, &x_domain, &x_user, xtra) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "can't find user [%s@%s]\n", myid, domain_name);
|
||||
ok = 0;
|
||||
&x_domain_root, &x_domain, &x_user, params) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "can't find user [%s@%s]\n", myid, domain_name);
|
||||
ok = 0;
|
||||
}
|
||||
|
||||
switch_safe_free(xtra);
|
||||
|
||||
switch_event_destroy(¶ms);
|
||||
|
||||
if (!ok) {
|
||||
goto end;
|
||||
@@ -1742,16 +1746,19 @@ static switch_status_t voicemail_leave_main(switch_core_session_t *session, cons
|
||||
|
||||
if (id) {
|
||||
int ok = 1;
|
||||
char *xtra = switch_mprintf("mailbox=%s", id);
|
||||
switch_event_t *params = NULL;
|
||||
switch_xml_t x_domain, x_domain_root, x_user, x_params, x_param;
|
||||
const char *email_addr = NULL;
|
||||
|
||||
switch_assert(xtra);
|
||||
|
||||
switch_event_create(¶ms, SWITCH_EVENT_MESSAGE);
|
||||
switch_assert(params);
|
||||
switch_event_add_header(params, SWITCH_STACK_BOTTOM, "mailbox", id);
|
||||
|
||||
x_user = x_domain = x_domain_root = NULL;
|
||||
if (switch_xml_locate_user("id", id, domain_name, switch_channel_get_variable(channel, "network_addr"),
|
||||
&x_domain_root, &x_domain, &x_user, xtra) == SWITCH_STATUS_SUCCESS) {
|
||||
if ((x_params = switch_xml_child(x_user, "params"))) {
|
||||
for (x_param = switch_xml_child(x_params, "param"); x_param; x_param = x_param->next) {
|
||||
&x_domain_root, &x_domain, &x_user, params) == SWITCH_STATUS_SUCCESS) {
|
||||
if ((x_params = switch_xml_child(x_user, "params"))) {
|
||||
for (x_param = switch_xml_child(x_params, "param"); x_param; x_param = x_param->next) {
|
||||
const char *var = switch_xml_attr_soft(x_param, "name");
|
||||
const char *val = switch_xml_attr_soft(x_param, "value");
|
||||
|
||||
@@ -1778,7 +1785,7 @@ static switch_status_t voicemail_leave_main(switch_core_session_t *session, cons
|
||||
ok = 0;
|
||||
}
|
||||
|
||||
switch_safe_free(xtra);
|
||||
switch_event_destroy(¶ms);
|
||||
switch_xml_free(x_domain_root);
|
||||
if (!ok) {
|
||||
goto end;
|
||||
|
||||
Reference in new issue
Block a user