From 609c42c854c8880548571241b893604c02d513d4 Mon Sep 17 00:00:00 2001 From: Jason Parker Date: Wed, 26 Jun 2013 19:29:57 +0000 Subject: ARI: Add support for continuing to a different location in dialplan. This allows going elsewhere in the dialplan, so that the location can be specified after exiting the Stasis application. (closes issue ASTERISK-21870) Review: https://reviewboard.asterisk.org/r/2644/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@392987 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- res/stasis/control.c | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) (limited to 'res/stasis') diff --git a/res/stasis/control.c b/res/stasis/control.c index 06f36728f..310b66cbc 100644 --- a/res/stasis/control.c +++ b/res/stasis/control.c @@ -33,6 +33,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include "control.h" #include "asterisk/bridging.h" #include "asterisk/bridging_features.h" +#include "asterisk/pbx.h" struct stasis_app_control { /*! Queue of commands to dispatch on the channel */ @@ -91,17 +92,43 @@ int control_is_done(struct stasis_app_control *control) return control->is_done; } +struct stasis_app_control_continue_data { + char context[AST_MAX_CONTEXT]; + char extension[AST_MAX_EXTENSION]; + int priority; +}; + static void *app_control_continue(struct stasis_app_control *control, struct ast_channel *chan, void *data) { + RAII_VAR(struct stasis_app_control_continue_data *, continue_data, data, ast_free); + /* Called from stasis_app_exec thread; no lock needed */ + ast_explicit_goto(control->channel, continue_data->context, continue_data->extension, continue_data->priority); + control->is_done = 1; + return NULL; } -void stasis_app_control_continue(struct stasis_app_control *control) +int stasis_app_control_continue(struct stasis_app_control *control, const char *context, const char *extension, int priority) { - stasis_app_send_command_async(control, app_control_continue, NULL); + struct stasis_app_control_continue_data *continue_data; + + if (!(continue_data = ast_calloc(1, sizeof(*continue_data)))) { + return -1; + } + ast_copy_string(continue_data->context, S_OR(context, ""), sizeof(continue_data->context)); + ast_copy_string(continue_data->extension, S_OR(extension, ""), sizeof(continue_data->extension)); + if (priority > 0) { + continue_data->priority = priority; + } else { + continue_data->priority = -1; + } + + stasis_app_send_command_async(control, app_control_continue, continue_data); + + return 0; } struct ast_channel_snapshot *stasis_app_control_get_snapshot( -- cgit v1.2.3