提交 d544c065 authored 作者: Marc Olivier Chouinard's avatar Marc Olivier Chouinard

mod_voicemail_ivr: Fixed issue in settings system. Added initials settings.

上级 f2cba2aa
<configuration name="voicemail_ivr.conf" description="Voicemail IVR">
<profiles>
<profile name="default">
<!-- Not yet implemented - Open for comments
<settings>
<param name="record-format" value="wav"/>
<param name="record-rate" value="8000"/>
<param name="IVR-Maximum-Attempts" value="3" />
<param name="IVR-Entry-Timeout" value="3" />
<param name="Record-Format" value="wav" />
<!--<param name="Record-Sample-Rate" value="8000" />-->
<param name="Record-Silence-Hits" value="4" />
<param name="Record-Silence-Threshold" value="200" />
<param name="Record-Maximum-Length" value="30" />
<param name="Exit-Purge" value="true" />
<param name="Password-Mask" value="XXX." />
<param name="User-Mask" value="X." />
</settings>
-->
<apis>
<api name="auth_login" value="vm_fsdb_auth_login" />
<api name="msg_list" value="vm_fsdb_msg_list" />
......@@ -64,12 +71,9 @@
</menu>
<menu name="std_navigator">
<!-- Not yet implemented - Open for comments
This will inherit the settings from the top profile settings. So if it global, put it inside the profile <settings>
<settings>
<param name="playback-order" value="newest-first" />
<!--<param name="Nav-Action-On-Delete" value="next_msg" />-->
</settings>
-->
<phrases>
<phrase name="msg_count" value="message_count@voicemail_ivr" />
<phrase name="say_date" value="say_date_event@voicemail_ivr" />
......
......@@ -52,12 +52,14 @@ void menu_init(vmivr_profile_t *profile, vmivr_menu_t *menu) {
goto end;
}
if (profile->event_settings && menu->event_settings) {
if (profile->event_settings) {
/* TODO Replace this with a switch_event_merge_not_set(...) */
switch_event_t *menu_default;
switch_event_create(&menu_default, SWITCH_EVENT_REQUEST_PARAMS);
switch_event_merge(menu_default, menu->event_settings);
switch_event_destroy(&menu->event_settings);
if (menu->event_settings) {
switch_event_merge(menu_default, menu->event_settings);
switch_event_destroy(&menu->event_settings);
}
switch_event_create(&menu->event_settings, SWITCH_EVENT_REQUEST_PARAMS);
switch_event_merge(menu->event_settings, profile->event_settings);
......@@ -65,6 +67,12 @@ void menu_init(vmivr_profile_t *profile, vmivr_menu_t *menu) {
switch_event_destroy(&menu_default);
}
{
const char *s_max_attempts = switch_event_get_header(menu->event_settings, "IVR-Maximum-Attempts");
const char *s_entry_timeout = switch_event_get_header(menu->event_settings, "IVR-Entry-Timeout");
menu->ivr_maximum_attempts = atoi(s_max_attempts);
menu->ivr_entry_timeout = atoi(s_entry_timeout);
}
if ((x_profile = switch_xml_find_child(x_profiles, "profile", "name", profile->name))) {
if ((x_menus = switch_xml_child(x_profile, "menus"))) {
......@@ -127,38 +135,36 @@ void menu_free(vmivr_menu_t *menu) {
static void append_event_profile(vmivr_menu_t *menu) {
if (!menu->phrase_params) {
switch_event_create(&menu->phrase_params, SWITCH_EVENT_REQUEST_PARAMS);
}
if (!menu->phrase_params) {
switch_event_create(&menu->phrase_params, SWITCH_EVENT_REQUEST_PARAMS);
}
/* Used for some appending function */
if (menu->profile && menu->profile->name && menu->profile->id && menu->profile->domain) {
switch_event_add_header(menu->phrase_params, SWITCH_STACK_BOTTOM, "VM-Profile", "%s", menu->profile->name);
switch_event_add_header(menu->phrase_params, SWITCH_STACK_BOTTOM, "VM-Account-ID", "%s", menu->profile->id);
switch_event_add_header(menu->phrase_params, SWITCH_STACK_BOTTOM, "VM-Account-Domain", "%s", menu->profile->domain);
}
/* Used for some appending function */
if (menu->profile && menu->profile->name && menu->profile->id && menu->profile->domain) {
switch_event_add_header(menu->phrase_params, SWITCH_STACK_BOTTOM, "VM-Profile", "%s", menu->profile->name);
switch_event_add_header(menu->phrase_params, SWITCH_STACK_BOTTOM, "VM-Account-ID", "%s", menu->profile->id);
switch_event_add_header(menu->phrase_params, SWITCH_STACK_BOTTOM, "VM-Account-Domain", "%s", menu->profile->domain);
}
}
static void populate_dtmfa_from_event(vmivr_menu_t *menu) {
int i = 0;
if (menu->event_keys_dtmf) {
switch_event_header_t *hp;
for (hp = menu->event_keys_dtmf->headers; hp; hp = hp->next) {
if (strlen(hp->name) < 3 && hp->value) { /* TODO This is a hack to discard default FS Events ! */
const char *varphrasename = switch_event_get_header(menu->event_keys_varname, hp->value);
menu->dtmfa[i++] = hp->name;
if (varphrasename && !zstr(varphrasename)) {
switch_event_add_header(menu->phrase_params, SWITCH_STACK_BOTTOM, varphrasename, "%s", hp->name);
}
}
}
}
menu->dtmfa[i++] = '\0';
int i = 0;
if (menu->event_keys_dtmf) {
switch_event_header_t *hp;
}
for (hp = menu->event_keys_dtmf->headers; hp; hp = hp->next) {
if (strlen(hp->name) < 3 && hp->value) { /* TODO This is a hack to discard default FS Events ! */
const char *varphrasename = switch_event_get_header(menu->event_keys_varname, hp->value);
menu->dtmfa[i++] = hp->name;
if (varphrasename && !zstr(varphrasename)) {
switch_event_add_header(menu->phrase_params, SWITCH_STACK_BOTTOM, varphrasename, "%s", hp->name);
}
}
}
}
menu->dtmfa[i++] = '\0';
}
vmivr_profile_t *get_profile(switch_core_session_t *session, const char *profile_name)
{
......@@ -193,7 +199,17 @@ vmivr_profile_t *get_profile(switch_core_session_t *session, const char *profile
profile->menu_check_main = "std_main_menu";
profile->menu_check_terminate = "std_purge";
/* TODO Create event_settings and add default settings here */
/* Populate default general settings */
switch_event_create(&profile->event_settings, SWITCH_EVENT_REQUEST_PARAMS);
switch_event_add_header(profile->event_settings, SWITCH_STACK_BOTTOM, "IVR-Maximum-Attempts", "%d", 3);
switch_event_add_header(profile->event_settings, SWITCH_STACK_BOTTOM, "IVR-Entry-Timeout", "%d", 3000);
switch_event_add_header(profile->event_settings, SWITCH_STACK_BOTTOM, "Exit-Purge", "%s", "true");
switch_event_add_header(profile->event_settings, SWITCH_STACK_BOTTOM, "Password-Mask", "%s", "XXX.");
switch_event_add_header(profile->event_settings, SWITCH_STACK_BOTTOM, "User-Mask", "%s", "X.");
switch_event_add_header(profile->event_settings, SWITCH_STACK_BOTTOM, "Record-Format", "%s", "wav");
switch_event_add_header(profile->event_settings, SWITCH_STACK_BOTTOM, "Record-Silence-Hits", "%d", 4);
switch_event_add_header(profile->event_settings, SWITCH_STACK_BOTTOM, "Record-Silence-Threshold", "%d", 200);
switch_event_add_header(profile->event_settings, SWITCH_STACK_BOTTOM, "Record-Maximum-Length", "%d", 30);
if ((x_settings = switch_xml_child(x_profile, "settings"))) {
switch_event_import_xml(switch_xml_child(x_settings, "param"), "name", "value", &profile->event_settings);
......
......@@ -91,6 +91,8 @@ struct vmivr_menu {
switch_event_t *phrase_params;
ivre_data_t ivre_d;
int ivr_maximum_attempts;
int ivr_entry_timeout;
};
typedef struct vmivr_menu vmivr_menu_t;
......
......@@ -33,11 +33,10 @@
#include "utils.h"
switch_status_t vmivr_merge_media_files(const char** inputs, const char *output) {
switch_status_t vmivr_merge_media_files(const char** inputs, const char *output, int rate) {
switch_status_t status = SWITCH_STATUS_SUCCESS;
switch_file_handle_t fh_output = { 0 };
int channels = 1;
int rate = 8000; /* TODO Make this configurable */
int j = 0;
if (switch_core_file_open(&fh_output, output, channels, rate, SWITCH_FILE_FLAG_WRITE | SWITCH_FILE_DATA_SHORT, NULL) != SWITCH_STATUS_SUCCESS) {
......@@ -99,7 +98,7 @@ switch_event_t *jsonapi2event(switch_core_session_t *session, switch_event_t *ap
return phrases_event;
}
char *generate_random_file_name(switch_core_session_t *session, const char *mod_name, char *file_extension) {
char *generate_random_file_name(switch_core_session_t *session, const char *mod_name, const char *file_extension) {
char rand_uuid[SWITCH_UUID_FORMATTED_LENGTH + 1] = "";
switch_uuid_t srand_uuid;
......
......@@ -34,12 +34,10 @@
#include "config.h"
switch_status_t vmivr_merge_files(const char** inputs, const char *output);
void append_event_message(switch_core_session_t *session, vmivr_profile_t *profile, switch_event_t *phrase_params, switch_event_t *msg_list_event, size_t current_msg);
char *generate_random_file_name(switch_core_session_t *session, const char *mod_name, char *file_extension);
char *generate_random_file_name(switch_core_session_t *session, const char *mod_name, const char *file_extension);
switch_event_t *jsonapi2event(switch_core_session_t *session, switch_event_t *apply_event, const char *api, const char *data);
switch_status_t vmivr_merge_media_files(const char** inputs, const char *output);
switch_status_t vmivr_merge_media_files(const char** inputs, const char *output, int rate);
switch_status_t vmivr_api_execute(switch_core_session_t *session, const char *apiname, const char *arguments);
#endif /* _UTIL_H_ */
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论