From 1326265b96233a65aa122bf8b6b109ec6383a4ab Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Tue, 8 Dec 2009 01:47:54 +0000 Subject: [PATCH] add uuid_recv_dtmf git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@15840 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- .../applications/mod_commands/mod_commands.c | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/src/mod/applications/mod_commands/mod_commands.c b/src/mod/applications/mod_commands/mod_commands.c index ee2f7a4f0e..e1fd149eb5 100644 --- a/src/mod/applications/mod_commands/mod_commands.c +++ b/src/mod/applications/mod_commands/mod_commands.c @@ -3498,6 +3498,54 @@ done: return SWITCH_STATUS_SUCCESS; } + + +#define UUID_RECV_DTMF_SYNTAX " " +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 " [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, ""); SWITCH_ADD_API(commands_api_interface, "domain_exists", "check if a domain exists", domain_exists_function, ""); 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: ]"); SWITCH_ADD_API(commands_api_interface, "expand", "expand vars and execute", expand_function, "[uuid: ] "); SWITCH_ADD_API(commands_api_interface, "echo", "echo", echo_function, "");