[asterisk-commits] sgriepentrog: branch sgriepentrog/12-userevent r413087 - in /team/sgriepentro...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Apr 28 22:37:17 CDT 2014
Author: sgriepentrog
Date: Mon Apr 28 22:37:09 2014
New Revision: 413087
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=413087
Log:
userevents: cleanup
Added:
team/sgriepentrog/12-userevent/include/asterisk/stasis_user.h (with props)
Modified:
team/sgriepentrog/12-userevent/main/stasis_user.c
team/sgriepentrog/12-userevent/res/res_stasis.c
Added: team/sgriepentrog/12-userevent/include/asterisk/stasis_user.h
URL: http://svnview.digium.com/svn/asterisk/team/sgriepentrog/12-userevent/include/asterisk/stasis_user.h?view=auto&rev=413087
==============================================================================
--- team/sgriepentrog/12-userevent/include/asterisk/stasis_user.h (added)
+++ team/sgriepentrog/12-userevent/include/asterisk/stasis_user.h Mon Apr 28 22:37:09 2014
@@ -1,0 +1,67 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2014, Digium, Inc.
+ *
+ * Scott Griepentrog <sgriepentrog at digium.com>
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+
+#ifndef STASIS_USER_H_
+#define STASIS_USER_H_
+
+#include "asterisk/stringfields.h"
+#include "asterisk/stasis.h"
+#include "asterisk/json.h"
+#include "asterisk/channel.h"
+#include "asterisk/stasis_channels.h"
+#include "asterisk/stasis_bridges.h"
+#include "asterisk/stasis_endpoints.h"
+
+
+/*!
+ * \since 12
+ * \brief Message type for when a custom user event is sent with optional multiple objects
+ *
+ * \retval A stasis message type
+ */
+struct stasis_message_type *ast_multi_user_event_type(void);
+
+/*! \brief Create a stasis user event multi object blob */
+struct ast_multi_object_blob *ast_multi_object_blob_create(struct ast_json *blob);
+
+/*! \brief Add a channel snapshot to a stasis user event multi object blob */
+void ast_multi_object_blob_add_channel(struct ast_multi_object_blob *obj,
+ char *name, struct ast_channel_snapshot *channel_snapshot);
+
+/*! \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 *obj,
+ char *name, struct ast_bridge_snapshot *bridge_snapshot);
+
+/*! \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 *obj,
+ char *name, struct ast_endpoint_snapshot *endpoint_snapshot);
+
+/*! \brief Publish single channel user event (for app_userevent compatibility) */
+void ast_multi_object_blob_single_channel_publish(struct ast_channel *chan,
+ struct stasis_message_type *type, struct ast_json *blob);
+
+
+/*!
+ * \brief Initialize the stasis user message types
+ * \return 0 on success
+ * \return Non-zero on error
+ */
+int ast_user_stasis_init(void);
+
+#endif /* STASIS_USER_H_ */
Propchange: team/sgriepentrog/12-userevent/include/asterisk/stasis_user.h
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: team/sgriepentrog/12-userevent/include/asterisk/stasis_user.h
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: team/sgriepentrog/12-userevent/include/asterisk/stasis_user.h
------------------------------------------------------------------------------
svn:mime-type = text/plain
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=413087&r1=413086&r2=413087
==============================================================================
--- team/sgriepentrog/12-userevent/main/stasis_user.c (original)
+++ team/sgriepentrog/12-userevent/main/stasis_user.c Mon Apr 28 22:37:09 2014
@@ -43,12 +43,12 @@
#include "asterisk/stasis_user.h"
/*
- * notes on mapping of URI to snapshot structures
+ * mapping of URI to snapshot in multi object blob
*
* channel: = ast_channel_snapshot
* bridge: = ast_bridge_snapshot
* endpoint: = ast_endpoint_snapshot
- * deviceState: = ???
+ * deviceState: = not implemented
*
*/
@@ -107,7 +107,7 @@
return strcasecmp(lkey->name, rkey->name) ? 0 : (CMP_MATCH);
}
-/*! \brief A multi object blob data structure for multi_object_blob stasis messages */
+/*! \brief A multi object blob data structure to carry user event stasis messages */
struct ast_multi_object_blob {
struct ao2_container *object_snapshots; /*!< A container holding the snapshots */
struct ast_json *blob; /*< A blob of JSON data */
@@ -164,6 +164,7 @@
return obj;
}
+/*! \internal \brief Add an object (snapshot) to the blob */
static void ast_multi_object_blob_add_object(struct ast_multi_object_blob *multi,
char *typename, char *supplied_name, void *object,
enum stasis_user_multi_object_snapshot_type type)
@@ -193,7 +194,6 @@
ast_copy_string(mos->key.name, name, name_len);
mos->key.type = type;
mos->snapshot = object;
- //ao2_ref(mos->snapshot, +1);
ao2_link(multi->object_snapshots, mos);
}
@@ -220,7 +220,7 @@
/*! \brief Publish single channel user event (for app_userevent compatibility) */
void ast_multi_object_blob_single_channel_publish(struct ast_channel *chan,
- struct stasis_message_type *type, struct ast_json *blob)
+ struct stasis_message_type *type, struct ast_json *blob)
{
RAII_VAR(struct stasis_message *, message, NULL, ao2_cleanup);
RAII_VAR(struct ast_channel_snapshot *, channel_snapshot, NULL, ao2_cleanup);
@@ -268,6 +268,7 @@
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);
@@ -351,7 +352,7 @@
return ami_str;
}
-/*! \internal \brief Callback to pass user defined parameters from blob */
+/*! \internal \brief Callback to pass only user defined parameters from blob */
static int userevent_exclusion_cb(const char *key)
{
if (!strcmp("eventname", key)) {
Modified: team/sgriepentrog/12-userevent/res/res_stasis.c
URL: http://svnview.digium.com/svn/asterisk/team/sgriepentrog/12-userevent/res/res_stasis.c?view=diff&rev=413087&r1=413086&r2=413087
==============================================================================
--- team/sgriepentrog/12-userevent/res/res_stasis.c (original)
+++ team/sgriepentrog/12-userevent/res/res_stasis.c Mon Apr 28 22:37:09 2014
@@ -1392,11 +1392,9 @@
return res;
}
- //ao2_ref(message, +1);
stasis_publish(ast_app_get_topic(app), message);
if (have_channel) {
- //ao2_ref(message, +1);
stasis_publish(ast_manager_get_topic(), message);
}
More information about the asterisk-commits
mailing list