[asterisk-commits] qwell: branch qwell/ari_channel_variables r392388 - in /team/qwell/ari_channe...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Jun 20 17:01:43 CDT 2013
Author: qwell
Date: Thu Jun 20 17:01:42 2013
New Revision: 392388
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=392388
Log:
commit progress
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/res/stasis_json/resource_channels.h
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=392388&r1=392387&r2=392388
==============================================================================
--- team/qwell/ari_channel_variables/include/asterisk/stasis_app.h (original)
+++ team/qwell/ari_channel_variables/include/asterisk/stasis_app.h Thu Jun 20 17:01:42 2013
@@ -154,6 +154,14 @@
int stasis_app_control_answer(struct stasis_app_control *control);
/*!
+ * \brief Get the value of a variable on the channel associated with this control.
+ * \param control Control for \c res_stasis.
+ * \param variable The name of the variable
+ * \return The value of the variable.
+ */
+char *stasis_app_control_get_var(struct stasis_app_control *control, const char *variable);
+
+/*!
* \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=392388&r1=392387&r2=392388
==============================================================================
--- team/qwell/ari_channel_variables/res/stasis/control.c (original)
+++ team/qwell/ari_channel_variables/res/stasis/control.c Thu Jun 20 17:01:42 2013
@@ -33,6 +33,7 @@
#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 */
@@ -104,6 +105,29 @@
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;
+ const char *value;
+
+ if (variable[strlen(variable) - 1] == ')') {
+ char workspace[1024];
+
+ ast_func_read(chan, (char *)variable, workspace, sizeof(workspace));
+
+ value = workspace;
+ } else {
+ value = pbx_builtin_getvar_helper(chan, 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);
+}
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=392388&r1=392387&r2=392388
==============================================================================
--- team/qwell/ari_channel_variables/res/stasis_http/resource_channels.c (original)
+++ team/qwell/ari_channel_variables/res/stasis_http/resource_channels.c Thu Jun 20 17:01:42 2013
@@ -385,7 +385,25 @@
void stasis_http_get_var(struct ast_variable *headers, struct ast_get_var_args *args, struct stasis_http_response *response)
{
- ast_log(LOG_ERROR, "TODO: stasis_http_get_var\n");
+ RAII_VAR(struct ast_json *, json, NULL, ast_json_unref);
+ RAII_VAR(struct stasis_app_control *, control, NULL, ao2_cleanup);
+ RAII_VAR(char *, value, NULL, ast_free);
+
+ ast_assert(response != NULL);
+
+ control = find_control(response, args->channel_id);
+ if (control == NULL) {
+ return;
+ }
+
+ value = stasis_app_control_get_var(control, args->variable);
+
+ if (!(json = ast_json_pack("{s: s}", "value", S_OR(value, "")))) {
+ stasis_http_response_alloc_failed(response);
+ return;
+ }
+
+ stasis_http_response_ok(response, ast_json_ref(json));
}
void stasis_http_set_var(struct ast_variable *headers, struct ast_set_var_args *args, struct stasis_http_response *response)
Modified: team/qwell/ari_channel_variables/res/stasis_json/resource_channels.h
URL: http://svnview.digium.com/svn/asterisk/team/qwell/ari_channel_variables/res/stasis_json/resource_channels.h?view=diff&rev=392388&r1=392387&r2=392388
==============================================================================
--- team/qwell/ari_channel_variables/res/stasis_json/resource_channels.h (original)
+++ team/qwell/ari_channel_variables/res/stasis_json/resource_channels.h Thu Jun 20 17:01:42 2013
@@ -40,16 +40,22 @@
/*
* JSON models
*
- * DialplanCEP
- * - priority: long (required)
- * - exten: string (required)
- * - context: string (required)
+ * CallerID
+ * - name: string (required)
+ * - number: string (required)
+ * Dialed
* Playback
* - language: string
* - media_uri: string (required)
* - id: string (required)
* - target_uri: string (required)
* - state: string (required)
+ * Variable
+ * - variable: string (required)
+ * DialplanCEP
+ * - priority: long (required)
+ * - exten: string (required)
+ * - context: string (required)
* Channel
* - accountcode: string (required)
* - linkedid: string (required)
@@ -66,10 +72,6 @@
* - hangupsource: string (required)
* - dialplan: DialplanCEP (required)
* - data: string (required)
- * CallerID
- * - name: string (required)
- * - number: string (required)
- * Dialed
*/
#endif /* _ASTERISK_RESOURCE_CHANNELS_H */
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=392388&r1=392387&r2=392388
==============================================================================
--- team/qwell/ari_channel_variables/rest-api/api-docs/channels.json (original)
+++ team/qwell/ari_channel_variables/rest-api/api-docs/channels.json Thu Jun 20 17:01:42 2013
@@ -806,6 +806,16 @@
}
}
}
+ },
+ "Variable": {
+ "id": "Variable",
+ "properties": {
+ "variable": {
+ "required": true,
+ "type": "string",
+ "description": "The value of the variable requested"
+ }
+ }
}
}
}
More information about the asterisk-commits
mailing list