mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-08-14 01:49:05 +00:00
switch_ivr/xml: Change the structure of the phrases/language system. Previously it was fxml->phrases->macros->language->macro. Changed it so fxml->languages->language->phrases->macros->macro
You can have sub macros <macros name="voicemail"><macro ...> and allow you to call it login@voicemail. Change the sound-path to sound-prefix to make it constistant with the rest of freeswitch. Also allow to set a sound-prefix to a macros, so you can override it for a specific file set. You can set say-modules="en" or whatever in the <language section to define that say module to use.
This commit is contained in:
130
src/switch_ivr.c
130
src/switch_ivr.c
@@ -29,6 +29,7 @@
|
||||
* Matt Klein <mklein@nmedia.net>
|
||||
* Michael Jerris <mike@jerris.com>
|
||||
* Ken Rice <krice at suspicious dot org>
|
||||
* Marc Olivier Chouinard <mochouinard@moctel.com>
|
||||
*
|
||||
* switch_ivr.c -- IVR Library
|
||||
*
|
||||
@@ -2327,9 +2328,9 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_say(switch_core_session_t *session,
|
||||
switch_say_interface_t *si;
|
||||
switch_channel_t *channel;
|
||||
switch_status_t status = SWITCH_STATUS_FALSE;
|
||||
const char *save_path = NULL, *chan_lang = NULL, *lang = NULL, *lname = NULL, *sound_path = NULL;
|
||||
const char *save_path = NULL, *chan_lang = NULL, *lang = NULL, *sound_path = NULL;
|
||||
switch_event_t *hint_data;
|
||||
switch_xml_t cfg, xml = NULL, language, macros;
|
||||
switch_xml_t cfg, xml = NULL, language = NULL, macros = NULL, phrases = NULL;
|
||||
char *p;
|
||||
|
||||
switch_assert(session);
|
||||
@@ -2341,6 +2342,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_say(switch_core_session_t *session,
|
||||
}
|
||||
|
||||
if (module_name) {
|
||||
char *p;
|
||||
p = switch_core_session_strdup(session, module_name);
|
||||
module_name = p;
|
||||
|
||||
@@ -2371,58 +2373,35 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_say(switch_core_session_t *session,
|
||||
switch_event_add_header_string(hint_data, SWITCH_STACK_BOTTOM, "lang", chan_lang);
|
||||
switch_channel_event_set_data(channel, hint_data);
|
||||
|
||||
if (switch_xml_locate("phrases", NULL, NULL, NULL, &xml, &cfg, hint_data, SWITCH_TRUE) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Open of phrases failed.\n");
|
||||
if (switch_xml_locate_language(&xml, &cfg, hint_data, &language, &phrases, ¯os, chan_lang) != SWITCH_STATUS_SUCCESS) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (!(macros = switch_xml_child(cfg, "macros"))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Can't find macros tag.\n");
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (!(language = switch_xml_child(macros, "language"))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Can't find language tag.\n");
|
||||
goto done;
|
||||
}
|
||||
|
||||
while (language) {
|
||||
if ((lname = (char *) switch_xml_attr(language, "name")) && !strcasecmp(lname, chan_lang)) {
|
||||
const char *tmp;
|
||||
|
||||
if ((tmp = switch_xml_attr(language, "module"))) {
|
||||
module_name = tmp;
|
||||
}
|
||||
break;
|
||||
}
|
||||
language = language->next;
|
||||
}
|
||||
|
||||
if (!language) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Can't find language %s.\n", chan_lang);
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (!module_name) {
|
||||
if ((p = (char *) switch_xml_attr(language, "say-module"))) {
|
||||
module_name = switch_core_session_strdup(session, p);
|
||||
} else if ((p = (char *) switch_xml_attr(language, "module"))) {
|
||||
module_name = switch_core_session_strdup(session, p);
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Deprecated usage of module attribute\n");
|
||||
} else {
|
||||
module_name = chan_lang;
|
||||
}
|
||||
|
||||
if (!(sound_path = (char *) switch_xml_attr(language, "sound-path"))) {
|
||||
sound_path = (char *) switch_xml_attr(language, "sound_path");
|
||||
if (!(sound_path = (char *) switch_xml_attr(language, "sound-prefix"))) {
|
||||
if (!(sound_path = (char *) switch_xml_attr(language, "sound-path"))) {
|
||||
sound_path = (char *) switch_xml_attr(language, "sound_path");
|
||||
}
|
||||
}
|
||||
|
||||
save_path = switch_channel_get_variable(channel, "sound_prefix");
|
||||
|
||||
if (sound_path) {
|
||||
switch_channel_set_variable(channel, "sound_prefix", sound_path);
|
||||
p = switch_core_session_strdup(session, sound_path);
|
||||
sound_path = p;
|
||||
if (channel) {
|
||||
const char *p = switch_channel_get_variable(channel, "sound_prefix_enforced");
|
||||
if (!switch_true(p)) {
|
||||
save_path = switch_channel_get_variable(channel, "sound_prefix");
|
||||
if (sound_path) {
|
||||
switch_channel_set_variable(channel, "sound_prefix", sound_path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (xml) {
|
||||
switch_xml_free(xml);
|
||||
}
|
||||
|
||||
if ((si = switch_loadable_module_get_say_interface(module_name))) {
|
||||
/* should go back and proto all the say mods to const.... */
|
||||
switch_say_args_t say_args = {0};
|
||||
@@ -2446,7 +2425,11 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_say(switch_core_session_t *session,
|
||||
if (save_path) {
|
||||
switch_channel_set_variable(channel, "sound_prefix", save_path);
|
||||
}
|
||||
|
||||
|
||||
if (xml) {
|
||||
switch_xml_free(xml);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -2463,9 +2446,9 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_say_string(switch_core_session_t *ses
|
||||
switch_say_interface_t *si;
|
||||
switch_channel_t *channel = NULL;
|
||||
switch_status_t status = SWITCH_STATUS_FALSE;
|
||||
const char *save_path = NULL, *chan_lang = NULL, *lname = NULL, *sound_path = NULL;
|
||||
const char *save_path = NULL, *chan_lang = NULL, *sound_path = NULL;
|
||||
switch_event_t *hint_data;
|
||||
switch_xml_t cfg, xml = NULL, language, macros;
|
||||
switch_xml_t cfg, xml = NULL, language = NULL, macros = NULL, phrases = NULL;
|
||||
|
||||
if (session) {
|
||||
channel = switch_core_session_get_channel(session);
|
||||
@@ -2498,52 +2481,31 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_say_string(switch_core_session_t *ses
|
||||
switch_channel_event_set_data(channel, hint_data);
|
||||
}
|
||||
|
||||
if (switch_xml_locate("phrases", NULL, NULL, NULL, &xml, &cfg, hint_data, SWITCH_TRUE) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Open of phrases failed.\n");
|
||||
if (switch_xml_locate_language(&xml, &cfg, hint_data, &language, &phrases, ¯os, chan_lang) != SWITCH_STATUS_SUCCESS) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (!(macros = switch_xml_child(cfg, "macros"))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Can't find macros tag.\n");
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (!(language = switch_xml_child(macros, "language"))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Can't find language tag.\n");
|
||||
goto done;
|
||||
}
|
||||
|
||||
while (language) {
|
||||
if ((lname = (char *) switch_xml_attr(language, "name")) && !strcasecmp(lname, chan_lang)) {
|
||||
const char *tmp;
|
||||
|
||||
if ((tmp = switch_xml_attr(language, "module"))) {
|
||||
module_name = tmp;
|
||||
}
|
||||
break;
|
||||
}
|
||||
language = language->next;
|
||||
}
|
||||
|
||||
if (!language) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Can't find language %s.\n", chan_lang);
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (!module_name) {
|
||||
if ((module_name = switch_xml_attr(language, "say-module"))) {
|
||||
} else if ((module_name = switch_xml_attr(language, "module"))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Deprecated usage of module attribute\n");
|
||||
} else {
|
||||
module_name = chan_lang;
|
||||
}
|
||||
|
||||
if (!(sound_path = (char *) switch_xml_attr(language, "sound-path"))) {
|
||||
sound_path = (char *) switch_xml_attr(language, "sound_path");
|
||||
if (!(sound_path = (char *) switch_xml_attr(language, "sound-prefix"))) {
|
||||
if (!(sound_path = (char *) switch_xml_attr(language, "sound-path"))) {
|
||||
sound_path = (char *) switch_xml_attr(language, "sound_path");
|
||||
}
|
||||
}
|
||||
|
||||
if (channel) {
|
||||
save_path = switch_channel_get_variable(channel, "sound_prefix");
|
||||
}
|
||||
|
||||
if (sound_path && channel) {
|
||||
switch_channel_set_variable(channel, "sound_prefix", sound_path);
|
||||
const char *p = switch_channel_get_variable(channel, "sound_prefix_enforced");
|
||||
if (!switch_true(p)) {
|
||||
save_path = switch_channel_get_variable(channel, "sound_prefix");
|
||||
if (sound_path) {
|
||||
switch_channel_set_variable(channel, "sound_prefix", sound_path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((si = switch_loadable_module_get_say_interface(module_name))) {
|
||||
|
Reference in New Issue
Block a user