Revision
15840
Author
anthm
Date
2009-12-07 19:47:54 -0600 (Mon, 07 Dec 2009)

Log Message

add uuid_recv_dtmf

Modified Paths

Diff

Modified: freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c (15839 => 15840)


--- freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c	2009-12-08 01:20:22 UTC (rev 15839)
+++ freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c	2009-12-08 01:47:54 UTC (rev 15840)
@@ -3498,6 +3498,54 @@
 	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_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>");