[asterisk-commits] qwell: branch qwell/ari_channel_variables r392463 - in /team/qwell/ari_channe...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Jun 21 13:53:17 CDT 2013
Author: qwell
Date: Fri Jun 21 13:53:15 2013
New Revision: 392463
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=392463
Log:
Don't enqueue variables - they can be set immediately. Implement setVar.
Modified:
team/qwell/ari_channel_variables/include/asterisk/stasis_app.h
team/qwell/ari_channel_variables/res/stasis/control.c
team/qwell/ari_channel_variables/res/stasis_http/resource_channels.c
team/qwell/ari_channel_variables/rest-api/api-docs/channels.json
Modified: team/qwell/ari_channel_variables/include/asterisk/stasis_app.h
URL: http://svnview.digium.com/svn/asterisk/team/qwell/ari_channel_variables/include/asterisk/stasis_app.h?view=diff&rev=392463&r1=392462&r2=392463
==============================================================================
--- team/qwell/ari_channel_variables/include/asterisk/stasis_app.h (original)
+++ team/qwell/ari_channel_variables/include/asterisk/stasis_app.h Fri Jun 21 13:53:15 2013
@@ -162,6 +162,17 @@
char *stasis_app_control_get_var(struct stasis_app_control *control, const char *variable);
/*!
+ * \brief Set a variable on the channel associated with this control to value.
+ * \param control Control for \c res_stasis.
+ * \param variable The name of the variable
+ * \param value The value to set the variable to
+ *
+ * \return 0 for success.
+ * \return -1 for error.
+ */
+int stasis_app_control_set_var(struct stasis_app_control *control, const char *variable, const char *value);
+
+/*!
* \brief Returns the most recent snapshot for the associated channel.
*
* The returned pointer is AO2 managed, so ao2_cleanup() when you're done.
Modified: team/qwell/ari_channel_variables/res/stasis/control.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/ari_channel_variables/res/stasis/control.c?view=diff&rev=392463&r1=392462&r2=392463
==============================================================================
--- team/qwell/ari_channel_variables/res/stasis/control.c (original)
+++ team/qwell/ari_channel_variables/res/stasis/control.c Fri Jun 21 13:53:15 2013
@@ -105,29 +105,28 @@
stasis_app_send_command_async(control, app_control_continue, NULL);
}
-static void *app_control_get_var(struct stasis_app_control *control,
- struct ast_channel *chan, void *data)
-{
- const char *variable = data;
+char *stasis_app_control_get_var(struct stasis_app_control *control, const char *variable)
+{
const char *value;
if (variable[strlen(variable) - 1] == ')') {
char workspace[1024];
- ast_func_read(chan, (char *)variable, workspace, sizeof(workspace));
+ ast_func_read(control->channel, (char *)variable, workspace, sizeof(workspace));
value = workspace;
} else {
- value = pbx_builtin_getvar_helper(chan, variable);
+ value = pbx_builtin_getvar_helper(control->channel, variable);
}
return ast_strdup(value);
}
-char *stasis_app_control_get_var(struct stasis_app_control *control, const char *variable)
-{
- return stasis_app_send_command(control, app_control_get_var, (void *)variable);
-}
+int stasis_app_control_set_var(struct stasis_app_control *control, const char *variable, const char *value)
+{
+ return pbx_builtin_setvar_helper(control->channel, variable, value);
+}
+
struct ast_channel_snapshot *stasis_app_control_get_snapshot(
const struct stasis_app_control *control)
{
Modified: team/qwell/ari_channel_variables/res/stasis_http/resource_channels.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/ari_channel_variables/res/stasis_http/resource_channels.c?view=diff&rev=392463&r1=392462&r2=392463
==============================================================================
--- team/qwell/ari_channel_variables/res/stasis_http/resource_channels.c (original)
+++ team/qwell/ari_channel_variables/res/stasis_http/resource_channels.c Fri Jun 21 13:53:15 2013
@@ -408,6 +408,22 @@
void stasis_http_set_var(struct ast_variable *headers, struct ast_set_var_args *args, struct stasis_http_response *response)
{
- ast_log(LOG_ERROR, "TODO: stasis_http_set_var\n");
-}
-
+ RAII_VAR(struct stasis_app_control *, control, NULL, ao2_cleanup);
+
+ ast_assert(response != NULL);
+
+ control = find_control(response, args->channel_id);
+ if (control == NULL) {
+ return;
+ }
+
+ if (stasis_app_control_set_var(control, args->variable, args->value)) {
+ stasis_http_response_error(
+ response, 500, "Internal server error",
+ "Failed to set variable");
+ return;
+ }
+
+ stasis_http_response_no_content(response);
+}
+
Modified: team/qwell/ari_channel_variables/rest-api/api-docs/channels.json
URL: http://svnview.digium.com/svn/asterisk/team/qwell/ari_channel_variables/rest-api/api-docs/channels.json?view=diff&rev=392463&r1=392462&r2=392463
==============================================================================
--- team/qwell/ari_channel_variables/rest-api/api-docs/channels.json (original)
+++ team/qwell/ari_channel_variables/rest-api/api-docs/channels.json Fri Jun 21 13:53:15 2013
@@ -616,6 +616,10 @@
{
"code": 404,
"reason": "Channel not found"
+ },
+ {
+ "code": 409,
+ "reason": "Channel not in a Stasis application"
}
]
},
@@ -654,6 +658,10 @@
{
"code": 404,
"reason": "Channel not found"
+ },
+ {
+ "code": 409,
+ "reason": "Channel not in a Stasis application"
}
]
}
More information about the asterisk-commits
mailing list