[svn-commits] file: trunk r400255 - in /trunk: ./ include/asterisk/ res/ari/ res/stasis/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Oct 2 10:24:18 CDT 2013


Author: file
Date: Wed Oct  2 10:24:16 2013
New Revision: 400255

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=400255
Log:
Allow specifying a channel to dial an extension and context in an ARI dial operation.

(issue ASTERISK-22625)
Reported by: Scott Griepentrog
........

Merged revisions 400254 from http://svn.asterisk.org/svn/asterisk/branches/12

Modified:
    trunk/   (props changed)
    trunk/include/asterisk/stasis_app.h
    trunk/res/ari/resource_channels.c
    trunk/res/stasis/control.c

Propchange: trunk/
------------------------------------------------------------------------------
--- branch-12-merged (original)
+++ branch-12-merged Wed Oct  2 10:24:16 2013
@@ -1,1 +1,1 @@
-/branches/12:1-398558,398560-398577,398579-399305,399307-400181,400194,400196,400205,400217,400227,400236,400245
+/branches/12:1-398558,398560-398577,398579-399305,399307-400181,400194,400196,400205,400217,400227,400236,400245,400254

Modified: trunk/include/asterisk/stasis_app.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/stasis_app.h?view=diff&rev=400255&r1=400254&r2=400255
==============================================================================
--- trunk/include/asterisk/stasis_app.h (original)
+++ trunk/include/asterisk/stasis_app.h Wed Oct  2 10:24:16 2013
@@ -166,12 +166,15 @@
  *
  * \param control Control for \c res_stasis
  * \param endpoint The endpoint to dial.
+ * \param exten Extension to dial if no endpoint specified.
+ * \param context Context to use with extension.
  * \param timeout The amount of time to wait for answer, before giving up.
  *
  * \return 0 for success
  * \return -1 for error.
  */
-int stasis_app_control_dial(struct stasis_app_control *control, const char *endpoint, int timeout);
+int stasis_app_control_dial(struct stasis_app_control *control, const char *endpoint, const char *exten,
+                            const char *context, int timeout);
 
 /*!
  * \brief Apply a bridge role to a channel controlled by a stasis app control

Modified: trunk/res/ari/resource_channels.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/ari/resource_channels.c?view=diff&rev=400255&r1=400254&r2=400255
==============================================================================
--- trunk/res/ari/resource_channels.c (original)
+++ trunk/res/ari/resource_channels.c Wed Oct  2 10:24:16 2013
@@ -90,7 +90,7 @@
 		return;
 	}
 
-	if (stasis_app_control_dial(control, args->endpoint, args->timeout)) {
+	if (stasis_app_control_dial(control, args->endpoint, args->extension, args->context, args->timeout)) {
 		ast_ari_response_alloc_failed(response);
 		return;
 	}

Modified: trunk/res/stasis/control.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/stasis/control.c?view=diff&rev=400255&r1=400254&r2=400255
==============================================================================
--- trunk/res/stasis/control.c (original)
+++ trunk/res/stasis/control.c Wed Oct  2 10:24:16 2013
@@ -135,6 +135,10 @@
 	int timeout;
 };
 
+static void *app_control_add_channel_to_bridge(
+        struct stasis_app_control *control,
+        struct ast_channel *chan, void *data);
+
 static void *app_control_dial(struct stasis_app_control *control,
 	struct ast_channel *chan, void *data)
 {
@@ -142,9 +146,8 @@
 	RAII_VAR(struct stasis_app_control_dial_data *, dial_data, data, ast_free);
 	enum ast_dial_result res;
 	char *tech, *resource;
-
 	struct ast_channel *new_chan;
-	struct ast_bridge *bridge;
+	RAII_VAR(struct ast_bridge *, bridge, NULL, ao2_cleanup);
 
 	tech = dial_data->endpoint;
 	if (!(resource = strchr(tech, '/'))) {
@@ -178,13 +181,14 @@
 		AST_BRIDGE_IMPART_CHAN_INDEPENDENT)) {
 		ast_hangup(new_chan);
 	} else {
-		stasis_app_control_add_channel_to_bridge(control, bridge);
-	}
-
-	return NULL;
-}
-
-int stasis_app_control_dial(struct stasis_app_control *control, const char *endpoint, int timeout)
+		app_control_add_channel_to_bridge(control, chan, bridge);
+	}
+
+	return NULL;
+}
+
+int stasis_app_control_dial(struct stasis_app_control *control, const char *endpoint, const char *exten, const char *context,
+			    int timeout)
 {
 	struct stasis_app_control_dial_data *dial_data;
 
@@ -192,7 +196,13 @@
 		return -1;
 	}
 
-	ast_copy_string(dial_data->endpoint, endpoint, sizeof(dial_data->endpoint));
+	if (!ast_strlen_zero(endpoint)) {
+		ast_copy_string(dial_data->endpoint, endpoint, sizeof(dial_data->endpoint));
+	} else if (!ast_strlen_zero(exten) && !ast_strlen_zero(context)) {
+		snprintf(dial_data->endpoint, sizeof(dial_data->endpoint), "Local/%s@%s", exten, context);
+	} else {
+		return -1;
+	}
 
 	if (timeout > 0) {
 		dial_data->timeout = timeout * 1000;




More information about the svn-commits mailing list