]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add vmname tag to httapi to play a voicemail recorded name
authorAnthony Minessale <anthm@freeswitch.org>
Tue, 14 Feb 2012 19:04:51 +0000 (13:04 -0600)
committerAnthony Minessale <anthm@freeswitch.org>
Tue, 14 Feb 2012 19:04:51 +0000 (13:04 -0600)
src/mod/applications/mod_httapi/mod_httapi.c
src/mod/applications/mod_httapi/mod_httapi_doc.txt

index 4a42aec8236a81a52510f9fee8904a6b9a81ed0a..fba77363631e8921df73f1d568eb4289e88ab4f5 100644 (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);
index e8bf9bf9bcc8a56c0b7011c86bbe28b49a7b5739..8690a62fc89af7320b0bd37ed24db3cb9f5e82b9 100644 (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>