]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add uuid_recv_dtmf
authorAnthony Minessale <anthony.minessale@gmail.com>
Tue, 8 Dec 2009 01:47:54 +0000 (01:47 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Tue, 8 Dec 2009 01:47:54 +0000 (01:47 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@15840 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/applications/mod_commands/mod_commands.c

index ee2f7a4f0e348a44649cde83c2c82d227da56d85..e1fd149eb5ab5fe368c2e5da8598b289998347b6 100644 (file)
@@ -3498,6 +3498,54 @@ done:
        return SWITCH_STATUS_SUCCESS;
 }
 
+
+
+#define UUID_RECV_DTMF_SYNTAX "<uuid> <dtmf_data>"
+SWITCH_STANDARD_API(uuid_recv_dtmf_function)
+{
+       switch_core_session_t *psession = NULL;
+       char *mycmd = NULL, *argv[2] = { 0 };
+       char *uuid = NULL, *dtmf_data = NULL;
+       int argc = 0;
+
+       if (zstr(cmd)) {
+               goto usage;
+       }
+
+       if (!(mycmd = strdup(cmd))) {
+               goto usage;
+       }
+
+       if ((argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) < 2) {
+               goto usage;
+       }
+
+       uuid = argv[0];
+       dtmf_data = argv[1];
+       if (zstr(uuid) || zstr(dtmf_data)) {
+               goto usage;
+       }
+
+       if (!(psession = switch_core_session_locate(uuid))) {
+               stream->write_function(stream, "-ERR Cannot locate session!\n");
+               return SWITCH_STATUS_SUCCESS;
+       }
+
+       switch_channel_queue_dtmf_string(switch_core_session_get_channel(psession), dtmf_data);
+       goto done;
+
+usage:
+       stream->write_function(stream, "-USAGE: %s\n", UUID_RECV_DTMF_SYNTAX);
+
+done:
+       if (psession) {
+               switch_core_session_rwunlock(psession);
+       }
+
+       switch_safe_free(mycmd);
+       return SWITCH_STATUS_SUCCESS;
+}
+
 #define DUMP_SYNTAX "<uuid> [format]"
 SWITCH_STANDARD_API(uuid_dump_function)
 {
@@ -3855,6 +3903,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load)
        SWITCH_ADD_API(commands_api_interface, "module_exists", "check if module exists", module_exists_function, "<module>");
        SWITCH_ADD_API(commands_api_interface, "domain_exists", "check if a domain exists", domain_exists_function, "<domain>");
        SWITCH_ADD_API(commands_api_interface, "uuid_send_dtmf", "send dtmf digits", uuid_send_dtmf_function, UUID_SEND_DTMF_SYNTAX);
+       SWITCH_ADD_API(commands_api_interface, "uuid_recv_dtmf", "receive dtmf digits", uuid_recv_dtmf_function, UUID_RECV_DTMF_SYNTAX);
        SWITCH_ADD_API(commands_api_interface, "eval", "eval (noop)", eval_function, "[uuid:<uuid> ]<expression>");
        SWITCH_ADD_API(commands_api_interface, "expand", "expand vars and execute", expand_function, "[uuid:<uuid> ]<cmd> <args>");
        SWITCH_ADD_API(commands_api_interface, "echo", "echo", echo_function, "<data>");