add vmname tag to httapi to play a voicemail recorded name

This commit is contained in:
Anthony Minessale 2012-02-14 13:04:51 -06:00
parent f507f89eb0
commit eb4cac9b5e
2 changed files with 63 additions and 2 deletions

View File

@ -395,6 +395,7 @@ static switch_status_t parse_playback(const char *tag_name, client_t *client, sw
const char *say_gender = NULL;
const char *sp_engine = NULL;
const char *sp_grammar = NULL;
char *free_string = NULL;
if (!strcasecmp(tag_name, "say")) {
say_lang = switch_xml_attr(tag, "language");
@ -431,6 +432,48 @@ static switch_status_t parse_playback(const char *tag_name, client_t *client, sw
} else {
play = 1;
}
} else if (!strcasecmp(tag_name, "vmname")) {
const char *id = switch_xml_attr(tag, "id");
char *cmd, *resp;
switch_stream_handle_t stream = { 0 };
char *p;
SWITCH_STANDARD_STREAM(stream);
cmd = switch_mprintf("%s|name_path", id);
switch_api_execute("vm_prefs", cmd, NULL, &stream);
resp = (char *) stream.data;
if (!zstr(resp)) {
if (switch_stristr("://", resp) || switch_file_exists(resp, NULL) == SWITCH_STATUS_SUCCESS) {
play = 1;
file = free_string = resp;
resp = NULL;
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid file! [%s]\n", resp);
switch_safe_free(resp);
return SWITCH_STATUS_FALSE;
}
} else {
switch_safe_free(resp);
say_lang = switch_xml_attr(tag, "language");
say_gender = switch_xml_attr(tag, "gender");
say_type = "name_spelled";
say_method = "pronounced";
free_string = strdup(id);
if ((p = strchr(free_string, '@'))) {
*p = '\0';
}
say = 1;
body = free_string;
switch_ivr_play_file(client->session, NULL, "voicemail/vm-person.wav", &nullargs);
}
switch_safe_free(resp);
}
@ -618,11 +661,13 @@ static switch_status_t parse_playback(const char *tag_name, client_t *client, sw
}
}
}
if (dmachine) {
switch_ivr_dmachine_destroy(&dmachine);
}
printf("WTF %d\n", status);
switch_safe_free(free_string);
return status;
}
@ -2790,6 +2835,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_httapi_load)
bind_parser("record", parse_record);
bind_parser("recordCall", parse_record_call);
bind_parser("playback", parse_playback);
bind_parser("vmName", parse_playback);
bind_parser("speak", parse_playback);
bind_parser("say", parse_playback);
bind_parser("conference", parse_conference);

View File

@ -80,6 +80,21 @@ asr-engine : ASR engine to use
asr-grammar : ASR grammar to use
<vmname file name action digit-timeout input-timeout loops><bind action strip>*EXPR*</bind></playback>
: Plays a vm name and optionally collects input.
ATTRS:
file : The file
name : Param name to save result.
error-file : Error file to play on invalid input.
action : Change the new target url.
temp-action : Change url to submit to. just for the next loop.
digit-timeout : Timeout waiting for digits after file plays (when input bindings are present)
input-timeout : Timeout waiting for more digits in a multi-digit input.
loops : max times to play the file when input bindings are present.
<record file name error-file action digit-timeout input-timeout><bind action strip>*EXPR*</bind></record>