]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
ARI: Add support for continuing to a different location in dialplan.
authorJason Parker <jparker@digium.com>
Wed, 26 Jun 2013 19:29:57 +0000 (19:29 +0000)
committerJason Parker <jparker@digium.com>
Wed, 26 Jun 2013 19:29:57 +0000 (19:29 +0000)
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

include/asterisk/stasis_app.h
res/res_stasis_http_channels.c
res/stasis/control.c
res/stasis_http/resource_channels.c
res/stasis_http/resource_channels.h
rest-api/api-docs/channels.json

index 3eed47e35c03f740cb2fe33ea87ec739c5cdb292..881ef72a49b72cb38fb10aff4969fd9493865a12 100644 (file)
@@ -142,8 +142,14 @@ const char *stasis_app_control_get_channel_id(
  * If the channel is no longer in \c res_stasis, this function does nothing.
  *
  * \param control Control for \c res_stasis
+ * \param context An optional context to continue to
+ * \param extension An optional extension to continue to
+ * \param priority An optional priority to continue to
+ *
+ * \return 0 for success
+ * \return -1 for error.
  */
-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);
 
 /*!
  * \brief Answer the channel associated with this control.
index 87f663d946ff01513f162bfd6bee3959ba390c1d..2776b167ed8f8250d3f9ae2a0c4c02fa1d7c9ae4 100644 (file)
@@ -191,6 +191,18 @@ static void stasis_http_continue_in_dialplan_cb(
        struct ast_continue_in_dialplan_args args = {};
        struct ast_variable *i;
 
+       for (i = get_params; i; i = i->next) {
+               if (strcmp(i->name, "context") == 0) {
+                       args.context = (i->value);
+               } else
+               if (strcmp(i->name, "extension") == 0) {
+                       args.extension = (i->value);
+               } else
+               if (strcmp(i->name, "priority") == 0) {
+                       args.priority = atoi(i->value);
+               } else
+               {}
+       }
        for (i = path_vars; i; i = i->next) {
                if (strcmp(i->name, "channelId") == 0) {
                        args.channel_id = (i->value);
index 06f36728fc3b0b41c1a78b287b677d4dade153a5..310b66cbc7e61ce47b333c07366efbb8b3376d69 100644 (file)
@@ -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(
index c51696a28730fa79b52546f02c7ef4b5976559bb..4d2ebdfbd8f786c20e564ccc94b54ba3d5b6de4c 100644 (file)
@@ -97,7 +97,11 @@ void stasis_http_continue_in_dialplan(
                return;
        }
 
-       stasis_app_control_continue(control);
+       if (stasis_app_control_continue(control, args->context, args->extension, args->priority)) {
+               stasis_http_response_alloc_failed(response);
+               return;
+       }
+
        stasis_http_response_no_content(response);
 }
 
index 4616611e6322db122079a49a8973b6424e2d9ff3..1cb408b4ac04f4abfaec1b2ecabfbdf1de9e886d 100644 (file)
@@ -124,6 +124,12 @@ void stasis_http_dial(struct ast_variable *headers, struct ast_dial_args *args,
 struct ast_continue_in_dialplan_args {
        /*! \brief Channel's id */
        const char *channel_id;
+       /*! \brief The context to continue to. */
+       const char *context;
+       /*! \brief The extension to continue to. */
+       const char *extension;
+       /*! \brief The priority to continue to. */
+       int priority;
 };
 /*!
  * \brief Exit application; continue execution in the dialplan.
index 4b35f155ed6db8492bd9d0377a8e3a01c3d6bd2f..d097267e7d5c6e42a32ac54270a63a65afabe47c 100644 (file)
                                                        "required": true,
                                                        "allowMultiple": false,
                                                        "dataType": "string"
+                                               },
+                                               {
+                                                       "name": "context",
+                                                       "description": "The context to continue to.",
+                                                       "paramType": "query",
+                                                       "required": false,
+                                                       "allowMultiple": false,
+                                                       "dataType": "string"
+                                               },
+                                               {
+                                                       "name": "extension",
+                                                       "description": "The extension to continue to.",
+                                                       "paramType": "query",
+                                                       "required": false,
+                                                       "allowMultiple": false,
+                                                       "dataType": "string"
+                                               },
+                                               {
+                                                       "name": "priority",
+                                                       "description": "The priority to continue to.",
+                                                       "paramType": "query",
+                                                       "required": false,
+                                                       "allowMultiple": false,
+                                                       "dataType": "int"
                                                }
                                        ],
                                        "errorResponses": [