[asterisk-commits] sgriepentrog: branch sgriepentrog/12-userevent r413072 - in /team/sgriepentro...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Apr 28 13:55:52 CDT 2014
Author: sgriepentrog
Date: Mon Apr 28 13:55:42 2014
New Revision: 413072
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=413072
Log:
userevent: bridge and endpoint working
Modified:
team/sgriepentrog/12-userevent/main/stasis_user.c
team/sgriepentrog/12-userevent/res/ari/ari_model_validators.c
team/sgriepentrog/12-userevent/res/ari/ari_model_validators.h
team/sgriepentrog/12-userevent/rest-api/api-docs/events.json
Modified: team/sgriepentrog/12-userevent/main/stasis_user.c
URL: http://svnview.digium.com/svn/asterisk/team/sgriepentrog/12-userevent/main/stasis_user.c?view=diff&rev=413072&r1=413071&r2=413072
==============================================================================
--- team/sgriepentrog/12-userevent/main/stasis_user.c (original)
+++ team/sgriepentrog/12-userevent/main/stasis_user.c Mon Apr 28 13:55:42 2014
@@ -165,7 +165,8 @@
}
static void ast_multi_object_blob_add_object(struct ast_multi_object_blob *multi,
- char *typename, char *supplied_name, void *object)
+ char *typename, char *supplied_name, void *object,
+ enum stasis_user_multi_object_snapshot_type type)
{
RAII_VAR(struct ast_multi_object_snapshot *, mos, NULL, ao2_cleanup);
char *name = supplied_name;
@@ -174,11 +175,9 @@
if (!multi || !object) {
return;
}
- ast_log(LOG_ERROR,"have name = %s\n", name);
if (ast_strlen_zero(name)) {
int count = ao2_container_count(multi->object_snapshots);
- ast_log(LOG_ERROR,"have count = %d\n", count);
if (count) {
ast_asprintf(&name, "%s%d", typename, ++count);
} else {
@@ -192,7 +191,7 @@
return;
}
ast_copy_string(mos->key.name, name, name_len);
- mos->key.type = STASIS_UMOS_CHANNEL;
+ mos->key.type = type;
mos->snapshot = object;
//ao2_ref(mos->snapshot, +1);
ao2_link(multi->object_snapshots, mos);
@@ -202,21 +201,21 @@
void ast_multi_object_blob_add_channel(struct ast_multi_object_blob *multi,
char *name, struct ast_channel_snapshot *channel_snapshot)
{
- ast_multi_object_blob_add_object(multi, "channel", name, channel_snapshot);
+ ast_multi_object_blob_add_object(multi, "channel", name, channel_snapshot, STASIS_UMOS_CHANNEL);
}
/*! \brief Add a bridge snapshot to a stasis user event multi object blob */
void ast_multi_object_blob_add_bridge(struct ast_multi_object_blob *multi,
char *name, struct ast_bridge_snapshot *bridge_snapshot)
{
- ast_multi_object_blob_add_object(multi, "bridge", name, bridge_snapshot);
+ ast_multi_object_blob_add_object(multi, "bridge", name, bridge_snapshot, STASIS_UMOS_BRIDGE);
}
/*! \brief Add a endpoint snapshot to a stasis user event multi object blob */
void ast_multi_object_blob_add_endpoint(struct ast_multi_object_blob *multi,
char *name, struct ast_endpoint_snapshot *endpoint_snapshot)
{
- ast_multi_object_blob_add_object(multi, "endpoint", name, endpoint_snapshot);
+ ast_multi_object_blob_add_object(multi, "endpoint", name, endpoint_snapshot, STASIS_UMOS_ENDPOINT);
}
/*! \brief Publish single channel user event (for app_userevent compatibility) */
@@ -268,24 +267,28 @@
it_snapshots = ao2_iterator_init(multi->object_snapshots, 0);
while ((mos = ao2_iterator_next(&it_snapshots))) {
struct ast_json *json_object = NULL;
+ const char *name = NULL;
switch (mos->key.type) {
case STASIS_UMOS_CHANNEL:
json_object = ast_channel_snapshot_to_json(mos->snapshot, sanitize);
+ name = "channel";
break;
case STASIS_UMOS_BRIDGE:
json_object = ast_bridge_snapshot_to_json(mos->snapshot, sanitize);
+ name = "bridge";
break;
case STASIS_UMOS_ENDPOINT:
json_object = ast_endpoint_snapshot_to_json(mos->snapshot, sanitize);
+ name = "endpoint";
break;
}
if (json_object) {
- ast_json_object_set(out, mos->key.name, json_object);
+ ast_json_object_set(out, name, json_object);
}
ao2_cleanup(mos);
}
ao2_iterator_destroy(&it_snapshots);
- //ast_log(LOG_ERROR,"*** '%s'\n",ast_json_dump_string(out));
+ ast_log(LOG_ERROR,"*** '%s'\n",ast_json_dump_string(out));
return ast_json_ref(out);
}
Modified: team/sgriepentrog/12-userevent/res/ari/ari_model_validators.c
URL: http://svnview.digium.com/svn/asterisk/team/sgriepentrog/12-userevent/res/ari/ari_model_validators.c?view=diff&rev=413072&r1=413071&r2=413072
==============================================================================
--- team/sgriepentrog/12-userevent/res/ari/ari_model_validators.c (original)
+++ team/sgriepentrog/12-userevent/res/ari/ari_model_validators.c Mon Apr 28 13:55:42 2014
@@ -3109,12 +3109,30 @@
res = 0;
}
} else
+ if (strcmp("bridge", ast_json_object_iter_key(iter)) == 0) {
+ int prop_is_valid;
+ prop_is_valid = ast_ari_validate_bridge(
+ ast_json_object_iter_value(iter));
+ if (!prop_is_valid) {
+ ast_log(LOG_ERROR, "ARI ChannelUserevent field bridge failed validation\n");
+ res = 0;
+ }
+ } else
if (strcmp("channel", ast_json_object_iter_key(iter)) == 0) {
int prop_is_valid;
prop_is_valid = ast_ari_validate_channel(
ast_json_object_iter_value(iter));
if (!prop_is_valid) {
ast_log(LOG_ERROR, "ARI ChannelUserevent field channel failed validation\n");
+ res = 0;
+ }
+ } else
+ if (strcmp("endpoint", ast_json_object_iter_key(iter)) == 0) {
+ int prop_is_valid;
+ prop_is_valid = ast_ari_validate_endpoint(
+ ast_json_object_iter_value(iter));
+ if (!prop_is_valid) {
+ ast_log(LOG_ERROR, "ARI ChannelUserevent field endpoint failed validation\n");
res = 0;
}
} else
Modified: team/sgriepentrog/12-userevent/res/ari/ari_model_validators.h
URL: http://svnview.digium.com/svn/asterisk/team/sgriepentrog/12-userevent/res/ari/ari_model_validators.h?view=diff&rev=413072&r1=413071&r2=413072
==============================================================================
--- team/sgriepentrog/12-userevent/res/ari/ari_model_validators.h (original)
+++ team/sgriepentrog/12-userevent/res/ari/ari_model_validators.h Mon Apr 28 13:55:42 2014
@@ -1278,7 +1278,9 @@
* - type: string (required)
* - application: string (required)
* - timestamp: Date
+ * - bridge: Bridge
* - channel: Channel
+ * - endpoint: Endpoint
* - eventname: string (required)
* - userevent: object (required)
* ChannelVarset
Modified: team/sgriepentrog/12-userevent/rest-api/api-docs/events.json
URL: http://svnview.digium.com/svn/asterisk/team/sgriepentrog/12-userevent/rest-api/api-docs/events.json?view=diff&rev=413072&r1=413071&r2=413072
==============================================================================
--- team/sgriepentrog/12-userevent/rest-api/api-docs/events.json (original)
+++ team/sgriepentrog/12-userevent/rest-api/api-docs/events.json Mon Apr 28 13:55:42 2014
@@ -453,7 +453,17 @@
"channel": {
"required": false,
"type": "Channel",
- "description": "The channel that signaled the user event."
+ "description": "A channel that is signaled with the user event."
+ },
+ "bridge": {
+ "required": false,
+ "type": "Bridge",
+ "description": "A bridge that is signaled with the user event."
+ },
+ "endpoint": {
+ "required": false,
+ "type": "Endpoint",
+ "description": "A endpoint that is signaled with the user event."
},
"userevent": {
"required": true,
More information about the asterisk-commits
mailing list