[asterisk-commits] qwell: branch qwell/http-channels-post r390668 - in /team/qwell/http-channels...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Jun 6 11:22:20 CDT 2013


Author: qwell
Date: Thu Jun  6 11:22:18 2013
New Revision: 390668

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=390668
Log:
Address feedback.

Modified:
    team/qwell/http-channels-post/res/res_stasis_http_channels.c
    team/qwell/http-channels-post/res/stasis_http/resource_channels.c
    team/qwell/http-channels-post/res/stasis_http/resource_channels.h
    team/qwell/http-channels-post/rest-api/api-docs/channels.json

Modified: team/qwell/http-channels-post/res/res_stasis_http_channels.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/http-channels-post/res/res_stasis_http_channels.c?view=diff&rev=390668&r1=390667&r2=390668
==============================================================================
--- team/qwell/http-channels-post/res/res_stasis_http_channels.c (original)
+++ team/qwell/http-channels-post/res/res_stasis_http_channels.c Thu Jun  6 11:22:18 2013
@@ -83,6 +83,12 @@
 		if (strcmp(i->name, "context") == 0) {
 			args.context = (i->value);
 		} else
+		if (strcmp(i->name, "callerId") == 0) {
+			args.caller_id = (i->value);
+		} else
+		if (strcmp(i->name, "timeout") == 0) {
+			args.timeout = atoi(i->value);
+		} else
 		if (strcmp(i->name, "app") == 0) {
 			args.app = (i->value);
 		} else

Modified: team/qwell/http-channels-post/res/stasis_http/resource_channels.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/http-channels-post/res/stasis_http/resource_channels.c?view=diff&rev=390668&r1=390667&r2=390668
==============================================================================
--- team/qwell/http-channels-post/res/stasis_http/resource_channels.c (original)
+++ team/qwell/http-channels-post/res/stasis_http/resource_channels.c Thu Jun  6 11:22:18 2013
@@ -34,6 +34,7 @@
 
 #include "asterisk/file.h"
 #include "asterisk/pbx.h"
+#include "asterisk/callerid.h"
 #include "asterisk/stasis_app.h"
 #include "asterisk/stasis_app_playback.h"
 #include "asterisk/stasis_channels.h"
@@ -315,8 +316,11 @@
 			   struct ast_originate_args *args,
 			   struct stasis_http_response *response)
 {
-	char *dialtech = "Local";
+	const char *dialtech = NULL;
 	char dialdevice[AST_CHANNEL_NAME];
+	char *caller_id = NULL;
+	char *cid_num = NULL;
+	char *cid_name = NULL;
 
 	int timeout = 30000;
 
@@ -331,6 +335,10 @@
 	ast_str_set(&appdata, 0, "%s", args->app);
 	if (!ast_strlen_zero(args->app_args)) {
 		ast_str_append(&appdata, 0, ",%s", args->app_args);
+	}
+
+	if (args->timeout > 0) {
+		timeout = args->timeout * 1000;
 	}
 
 	if (!ast_strlen_zero(args->endpoint)) {
@@ -343,18 +351,40 @@
 			ast_copy_string(dialdevice, stuff, sizeof(dialdevice));
 	        }
 	} else if (!ast_strlen_zero(args->extension) && !ast_strlen_zero(args->context)) {
+		dialtech = "Local";
 		snprintf(dialdevice, sizeof(dialdevice), "%s@%s", args->extension, args->context);
-	} else {
+	}
+
+	if (ast_strlen_zero(dialtech) || ast_strlen_zero(dialdevice)) {
 		stasis_http_response_error(
 			response, 500, "Internal server error",
-			"Endpoint or extension and context required");
-		return;
+			"Invalid endpoint or extension and context specified");
+		return;
+	}
+
+	if (!ast_strlen_zero(args->caller_id)) {
+		caller_id = ast_strdupa(args->caller_id);
+		ast_callerid_parse(caller_id, &cid_name, &cid_num);
+
+		if (cid_num) {
+			ast_shrink_phone_number(cid_num);
+
+			if (ast_strlen_zero(cid_num)) {
+				cid_num = NULL;
+			}
+		}
+		if (ast_strlen_zero(cid_name)) {
+			cid_name = NULL;
+		}
 	}
 
 	ast_log(LOG_DEBUG, "Dialing %s/%s\n", dialtech, dialdevice);
 
 	/* originate a channel, putting it into an application */
-	ast_pbx_outgoing_app(dialtech, NULL, dialdevice, timeout, app, ast_str_buffer(appdata), NULL, 0, NULL, NULL, NULL, NULL, NULL);
+	if (ast_pbx_outgoing_app(dialtech, NULL, dialdevice, timeout, app, ast_str_buffer(appdata), NULL, 0, cid_num, cid_name, NULL, NULL, NULL)) {
+		stasis_http_response_alloc_failed(response);
+		return;
+	}
 
 	stasis_http_response_no_content(response);
 }

Modified: team/qwell/http-channels-post/res/stasis_http/resource_channels.h
URL: http://svnview.digium.com/svn/asterisk/team/qwell/http-channels-post/res/stasis_http/resource_channels.h?view=diff&rev=390668&r1=390667&r2=390668
==============================================================================
--- team/qwell/http-channels-post/res/stasis_http/resource_channels.h (original)
+++ team/qwell/http-channels-post/res/stasis_http/resource_channels.h Thu Jun  6 11:22:18 2013
@@ -56,8 +56,12 @@
 	const char *endpoint;
 	/*! \brief When routing via dialplan, the extension to dial */
 	const char *extension;
-	/*! \brief When routing via dialplan, the context use. If omitted, uses 'default' */
+	/*! \brief When routing via dialplan, the context to use. If omitted, uses 'default' */
 	const char *context;
+	/*! \brief CallerID to use when dialing the endpoint or extension. */
+	const char *caller_id;
+	/*! \brief Timeout (in seconds), before giving up dialing. */
+	int timeout;
 	/*! \brief Application name to pass to the Stasis application. */
 	const char *app;
 	/*! \brief Application arguments to pass to the Stasis application. */

Modified: team/qwell/http-channels-post/rest-api/api-docs/channels.json
URL: http://svnview.digium.com/svn/asterisk/team/qwell/http-channels-post/rest-api/api-docs/channels.json?view=diff&rev=390668&r1=390667&r2=390668
==============================================================================
--- team/qwell/http-channels-post/rest-api/api-docs/channels.json (original)
+++ team/qwell/http-channels-post/rest-api/api-docs/channels.json Thu Jun  6 11:22:18 2013
@@ -41,11 +41,27 @@
 						},
 						{
 							"name": "context",
-							"description": "When routing via dialplan, the context use. If omitted, uses 'default'",
-							"paramType": "query",
-							"required": false,
-							"allowMultiple": false,
-							"dataType": "string"
+							"description": "When routing via dialplan, the context to use. If omitted, uses 'default'",
+							"paramType": "query",
+							"required": false,
+							"allowMultiple": false,
+							"dataType": "string"
+						},
+						{
+							"name": "callerId",
+							"description": "CallerID to use when dialing the endpoint or extension.",
+							"paramType": "query",
+							"required": false,
+							"allowMultiple": false,
+							"dataType": "string"
+						},
+						{
+							"name": "timeout",
+							"description": "Timeout (in seconds), before giving up dialing.",
+							"paramType": "query",
+							"required": false,
+							"allowMultiple": false,
+							"dataType": "int"
 						},
 						{
 							"name": "app",




More information about the asterisk-commits mailing list