]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
Add uuid_ring_ready API command
authorTravis Cross <tc@traviscross.com>
Mon, 31 Mar 2014 21:07:36 +0000 (21:07 +0000)
committerTravis Cross <tc@traviscross.com>
Sat, 19 Apr 2014 04:02:41 +0000 (04:02 +0000)
We already had uuid_answer and uuid_pre_answer, so we might as well
add uuid_ring_ready.

src/mod/applications/mod_commands/mod_commands.c

index a637cf98e9e390df00c95fe18307d00dc24578b4..581b8330e18c19da9f94ffe83691bf932b8af4a7 100644 (file)
@@ -3161,6 +3161,43 @@ SWITCH_STANDARD_API(uuid_early_ok_function)
        return SWITCH_STATUS_SUCCESS;
 }
 
+#define RING_READY_SYNTAX "<uuid> [queued]"
+SWITCH_STANDARD_API(uuid_ring_ready_function)
+{
+       char *uuid = NULL, *mycmd = NULL, *argv[2] = { 0 };
+       switch_core_session_t *xsession;
+       int argc = 0, queued = 0;
+
+       if (!zstr(cmd) && (mycmd = strdup(cmd))) {
+               argc = switch_separate_string(mycmd, ' ', argv,
+                                                                         (sizeof(argv) / sizeof(argv[0])));
+       }
+       if (zstr(cmd) || argc < 1) goto usage;
+       uuid = argv[0];
+       if (argc > 1) {
+               if (!strcasecmp(argv[1], "queued")) {
+                       queued = 1;
+               } else goto usage;
+       }
+       if (!uuid || !(xsession = switch_core_session_locate(uuid)))
+               goto error;
+       switch_channel_ring_ready_value(switch_core_session_get_channel(xsession),
+                                                                       queued ? SWITCH_RING_READY_QUEUED
+                                                                       : SWITCH_RING_READY_RINGING);
+       switch_core_session_rwunlock(xsession);
+       stream->write_function(stream, "+OK\n");
+       goto done;
+ usage:
+       stream->write_function(stream, "-USAGE: %s\n", RING_READY_SYNTAX);
+       goto done;
+ error:
+       stream->write_function(stream, "-ERROR\n");
+       goto done;
+ done:
+       switch_safe_free(mycmd);
+       return SWITCH_STATUS_SUCCESS;
+}
+
 SWITCH_STANDARD_API(uuid_pre_answer_function)
 {
        char *uuid = (char *) cmd;
@@ -6279,6 +6316,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load)
        SWITCH_ADD_API(commands_api_interface, "uuid_park", "Park channel", park_function, PARK_SYNTAX);
        SWITCH_ADD_API(commands_api_interface, "uuid_pause", "Pause media on a channel", pause_function, PAUSE_SYNTAX);
        SWITCH_ADD_API(commands_api_interface, "uuid_phone_event", "Send an event to the phone", uuid_phone_event_function, PHONE_EVENT_SYNTAX);
+       SWITCH_ADD_API(commands_api_interface, "uuid_ring_ready", "Sending ringing to a channel", uuid_ring_ready_function, RING_READY_SYNTAX);
        SWITCH_ADD_API(commands_api_interface, "uuid_pre_answer", "pre_answer", uuid_pre_answer_function, "<uuid>");
        SWITCH_ADD_API(commands_api_interface, "uuid_preprocess", "Pre-process Channel", preprocess_function, PREPROCESS_SYNTAX);
        SWITCH_ADD_API(commands_api_interface, "uuid_record", "Record session audio", session_record_function, SESS_REC_SYNTAX);
@@ -6408,6 +6446,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load)
        switch_console_set_complete("add uuid_display ::console::list_uuid");
        switch_console_set_complete("add uuid_dump ::console::list_uuid");
        switch_console_set_complete("add uuid_answer ::console::list_uuid");
+       switch_console_set_complete("add uuid_ring_ready ::console::list_uuid queued");
        switch_console_set_complete("add uuid_pre_answer ::console::list_uuid");
        switch_console_set_complete("add uuid_early_ok ::console::list_uuid");
        switch_console_set_complete("add uuid_exists ::console::list_uuid");