[asterisk-commits] jrose: branch jrose/bridge_projects r383650 - in /team/jrose/bridge_projects:...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Mar 22 16:51:00 CDT 2013


Author: jrose
Date: Fri Mar 22 16:50:56 2013
New Revision: 383650

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=383650
Log:
resolved conflict against manager, enable automerge

Added:
    team/jrose/bridge_projects/main/json.c
      - copied unchanged from r383649, team/group/bridge_construction/main/json.c
    team/jrose/bridge_projects/main/manager_channels.c
      - copied unchanged from r383649, team/group/bridge_construction/main/manager_channels.c
Removed:
    team/jrose/bridge_projects/res/res_json.c
    team/jrose/bridge_projects/res/res_json.exports.in
Modified:
    team/jrose/bridge_projects/   (props changed)
    team/jrose/bridge_projects/CHANGES
    team/jrose/bridge_projects/apps/app_mixmonitor.c
    team/jrose/bridge_projects/apps/app_userevent.c
    team/jrose/bridge_projects/configure
    team/jrose/bridge_projects/configure.ac
    team/jrose/bridge_projects/include/asterisk/autoconfig.h.in
    team/jrose/bridge_projects/include/asterisk/channel.h
    team/jrose/bridge_projects/include/asterisk/json.h
    team/jrose/bridge_projects/include/asterisk/manager.h
    team/jrose/bridge_projects/main/Makefile
    team/jrose/bridge_projects/main/asterisk.c
    team/jrose/bridge_projects/main/channel.c
    team/jrose/bridge_projects/main/manager.c
    team/jrose/bridge_projects/main/pbx.c
    team/jrose/bridge_projects/pbx/pbx_realtime.c
    team/jrose/bridge_projects/tests/test_json.c

Propchange: team/jrose/bridge_projects/
------------------------------------------------------------------------------
    automerge = *

Propchange: team/jrose/bridge_projects/
------------------------------------------------------------------------------
--- bridge_construction-integrated (original)
+++ bridge_construction-integrated Fri Mar 22 16:50:56 2013
@@ -1,1 +1,1 @@
-/trunk:1-383560
+/trunk:1-383649

Modified: team/jrose/bridge_projects/CHANGES
URL: http://svnview.digium.com/svn/asterisk/team/jrose/bridge_projects/CHANGES?view=diff&rev=383650&r1=383649&r2=383650
==============================================================================
--- team/jrose/bridge_projects/CHANGES (original)
+++ team/jrose/bridge_projects/CHANGES Fri Mar 22 16:50:56 2013
@@ -40,6 +40,15 @@
    stopped, restarted, reversed, or skipped forward. When initiated by other
    mechanisms (such as the Playback application), the audio can be stopped,
    reversed, or skipped forward.
+
+ * Channel related events now contain a snapshot of channel state, adding new
+   fields to many of these events.
+
+ * The AMI event 'Newexten' field 'Extension' is deprecated, and may be removed
+   in a future release. Please use the common 'Exten' field instead.
+
+ * The AMI event 'UserEvent' from app_userevent now contains the channel state
+   fields. The channel state fields will come before the body fields.
 
 Channel Drivers
 ------------------

Modified: team/jrose/bridge_projects/apps/app_mixmonitor.c
URL: http://svnview.digium.com/svn/asterisk/team/jrose/bridge_projects/apps/app_mixmonitor.c?view=diff&rev=383650&r1=383649&r2=383650
==============================================================================
--- team/jrose/bridge_projects/apps/app_mixmonitor.c (original)
+++ team/jrose/bridge_projects/apps/app_mixmonitor.c Fri Mar 22 16:50:56 2013
@@ -1042,7 +1042,7 @@
 	return 0;
 }
 
-static int stop_mixmonitor_exec(struct ast_channel *chan, const char *data)
+static int stop_mixmonitor_full(struct ast_channel *chan, const char *data)
 {
 	struct ast_datastore *datastore = NULL;
 	char *parse = "";
@@ -1093,6 +1093,12 @@
 	}
 	ast_channel_unlock(chan);
 
+	return 0;
+}
+
+static int stop_mixmonitor_exec(struct ast_channel *chan, const char *data)
+{
+	stop_mixmonitor_full(chan, data);
 	return 0;
 }
 
@@ -1315,7 +1321,7 @@
 		return AMI_SUCCESS;
 	}
 
-	res = stop_mixmonitor_exec(c, mixmonitor_id);
+	res = stop_mixmonitor_full(c, mixmonitor_id);
 
 	if (res) {
 		astman_send_error(s, m, "Could not stop monitoring channel");

Modified: team/jrose/bridge_projects/apps/app_userevent.c
URL: http://svnview.digium.com/svn/asterisk/team/jrose/bridge_projects/apps/app_userevent.c?view=diff&rev=383650&r1=383649&r2=383650
==============================================================================
--- team/jrose/bridge_projects/apps/app_userevent.c (original)
+++ team/jrose/bridge_projects/apps/app_userevent.c Fri Mar 22 16:50:56 2013
@@ -33,6 +33,7 @@
 #include "asterisk/module.h"
 #include "asterisk/manager.h"
 #include "asterisk/app.h"
+#include "asterisk/json.h"
 
 /*** DOCUMENTATION
 	<application name="UserEvent" language="en_US">
@@ -68,11 +69,12 @@
 		AST_APP_ARG(eventname);
 		AST_APP_ARG(extra)[100];
 	);
-	struct ast_str *body = ast_str_create(16);
+	RAII_VAR(struct ast_str *, body, ast_str_create(16), ast_free);
+	RAII_VAR(struct ast_json *, blob, NULL, ast_json_unref);
+	RAII_VAR(struct stasis_message *, msg, NULL, ao2_cleanup);
 
 	if (ast_strlen_zero(data)) {
 		ast_log(LOG_WARNING, "UserEvent requires an argument (eventname,optional event body)\n");
-		ast_free(body);
 		return -1;
 	}
 
@@ -89,24 +91,21 @@
 		ast_str_append(&body, 0, "%s\r\n", args.extra[x]);
 	}
 
-	/*** DOCUMENTATION
-	<managerEventInstance>
-		<synopsis>A user defined event raised from the dialplan.</synopsis>
-		<parameter name="UserEvent">
-			<para>The event name, as specified in the dialplan.</para>
-		</parameter>
-		<see-also>
-			<ref type="application">UserEvent</ref>
-		</see-also>
-	</managerEventInstance>
-	***/
-	manager_event(EVENT_FLAG_USER, "UserEvent",
-			"UserEvent: %s\r\n"
-			"Uniqueid: %s\r\n"
-			"%s",
-			args.eventname, ast_channel_uniqueid(chan), ast_str_buffer(body));
+	blob = ast_json_pack("{s: s, s: s, s: s}",
+			     "type", "userevent",
+			     "eventname", args.eventname,
+			     "body", ast_str_buffer(body));
+	if (!blob) {
+		ast_log(LOG_WARNING, "Unable to create message buffer\n");
+		return -1;
+	}
 
-	ast_free(body);
+	msg = ast_channel_blob_create(chan, blob);
+	if (!msg) {
+		return -1;
+	}
+
+	stasis_publish(ast_channel_topic(chan), msg);
 
 	return 0;
 }

Modified: team/jrose/bridge_projects/configure.ac
URL: http://svnview.digium.com/svn/asterisk/team/jrose/bridge_projects/configure.ac?view=diff&rev=383650&r1=383649&r2=383650
==============================================================================
--- team/jrose/bridge_projects/configure.ac (original)
+++ team/jrose/bridge_projects/configure.ac Fri Mar 22 16:50:56 2013
@@ -491,12 +491,13 @@
 AC_HEADER_SYS_WAIT
 AC_CHECK_HEADERS([arpa/inet.h fcntl.h inttypes.h libintl.h limits.h locale.h malloc.h netdb.h netinet/in.h stddef.h stdint.h stdlib.h string.h strings.h sys/event.h sys/file.h sys/ioctl.h sys/param.h sys/socket.h sys/time.h syslog.h termios.h unistd.h utime.h arpa/nameser.h sys/io.h])
 
-# Any one of these 5 packages support a mandatory requirement, so we want to check on them as early as possible.
+# Any one of these packages support a mandatory requirement, so we want to check on them as early as possible.
 AST_EXT_LIB_CHECK([TERMCAP], [termcap], [tgetent], [])
 AST_EXT_LIB_CHECK([TINFO], [tinfo], [tgetent], [])
 AST_EXT_LIB_CHECK([CURSES], [curses], [initscr], [curses.h])
 AST_EXT_LIB_CHECK([NCURSES], [ncurses], [initscr], [curses.h])
 AST_EXT_LIB_CHECK([UUID], [uuid], [uuid_generate_random], [uuid/uuid.h], [-luuid])
+AST_EXT_LIB_CHECK([JANSSON], [jansson], [json_dumps], [jansson.h])
 
 EDITLINE_LIB=""
 if test "x$TERMCAP_LIB" != "x" ; then
@@ -514,6 +515,10 @@
 
 if test "x$UUID_LIB" == "x"; then
   AC_MSG_ERROR([*** uuid support not found (this typically means the uuid development package is missing)])
+fi
+
+if test "x$JANSSON_LIB" == "x"; then
+  AC_MSG_ERROR([*** JSON support not found (this typically means the libjansson development package is missing)])
 fi
 
 # Another mandatory item (unless it's explicitly disabled)
@@ -1869,8 +1874,6 @@
 
 AST_EXT_LIB_CHECK([JACK], [jack], [jack_activate], [jack/jack.h])
 
-AST_EXT_LIB_CHECK([JANSSON], [jansson], [json_dumps], [jansson.h])
-
 # BSD (and OS X) equivalent of inotify
 AST_EXT_LIB_CHECK([KQUEUE], [c], [kqueue], [sys/event.h])
 

Modified: team/jrose/bridge_projects/include/asterisk/autoconfig.h.in
URL: http://svnview.digium.com/svn/asterisk/team/jrose/bridge_projects/include/asterisk/autoconfig.h.in?view=diff&rev=383650&r1=383649&r2=383650
==============================================================================
--- team/jrose/bridge_projects/include/asterisk/autoconfig.h.in (original)
+++ team/jrose/bridge_projects/include/asterisk/autoconfig.h.in Fri Mar 22 16:50:56 2013
@@ -1229,6 +1229,11 @@
 /* Define to 1 if running on Darwin. */
 #undef _DARWIN_UNLIMITED_SELECT
 
+/* Enable large inode numbers on Mac OS X 10.5.  */
+#ifndef _DARWIN_USE_64_BIT_INODE
+# define _DARWIN_USE_64_BIT_INODE 1
+#endif
+
 /* Number of bits in a file offset, on hosts where this is settable. */
 #undef _FILE_OFFSET_BITS
 

Modified: team/jrose/bridge_projects/include/asterisk/channel.h
URL: http://svnview.digium.com/svn/asterisk/team/jrose/bridge_projects/include/asterisk/channel.h?view=diff&rev=383650&r1=383649&r2=383650
==============================================================================
--- team/jrose/bridge_projects/include/asterisk/channel.h (original)
+++ team/jrose/bridge_projects/include/asterisk/channel.h Fri Mar 22 16:50:56 2013
@@ -151,6 +151,7 @@
 #include "asterisk/ccss.h"
 #include "asterisk/framehook.h"
 #include "asterisk/stasis.h"
+#include "asterisk/json.h"
 
 #define DATASTORE_INHERIT_FOREVER	INT_MAX
 
@@ -4185,24 +4186,51 @@
 
 /*!
  * \since 12
- * \brief Variable set event.
- */
-struct ast_channel_varset {
-	/*! Channel variable was set on (or NULL for global variable) */
+ * \brief Blob of data associated with a channel.
+ *
+ * The \c blob is actually a JSON object of structured data. It has a "type" field
+ * which contains the type string describing this blob.
+ */
+struct ast_channel_blob {
+	/*! Channel blob is associated with (or NULL for global/all channels) */
 	struct ast_channel_snapshot *snapshot;
-	/*! Variable name */
-	char *variable;
-	/*! New value */
-	char *value;
+	/*! JSON blob of data */
+	struct ast_json *blob;
 };
 
 /*!
  * \since 12
- * \brief Message type for \ref ast_channel_varset messages.
- *
- * \retval Message type for \ref ast_channel_varset messages.
- */
-struct stasis_message_type *ast_channel_varset(void);
+ * \brief Message type for \ref ast_channel_blob messages.
+ *
+ * \retval Message type for \ref ast_channel_blob messages.
+ */
+struct stasis_message_type *ast_channel_blob(void);
+
+/*!
+ * \since 12
+ * \brief Extracts the type field from a \ref ast_channel_blob.
+ * Returned \c char* is still owned by \a obj
+ * \param obj Channel blob object.
+ * \return Type field value from the blob.
+ * \return \c NULL on error.
+ */
+const char *ast_channel_blob_type(struct ast_channel_blob *obj);
+
+/*!
+ * \since 12
+ * \brief Creates a \ref ast_channel_blob message.
+ *
+ * The \a blob JSON object requires a \c "type" field describing the blob. It
+ * should also be treated as immutable and not modified after it is put into the
+ * message.
+ *
+ * \param chan Channel blob is associated with, or NULL for global/all channels.
+ * \param blob JSON object representing the data.
+ * \return \ref ast_channel_blob message.
+ * \return \c NULL on error
+ */
+struct stasis_message *ast_channel_blob_create(struct ast_channel *chan,
+					       struct ast_json *blob);
 
 /*!
  * \since 12

Modified: team/jrose/bridge_projects/include/asterisk/json.h
URL: http://svnview.digium.com/svn/asterisk/team/jrose/bridge_projects/include/asterisk/json.h?view=diff&rev=383650&r1=383649&r2=383650
==============================================================================
--- team/jrose/bridge_projects/include/asterisk/json.h (original)
+++ team/jrose/bridge_projects/include/asterisk/json.h Fri Mar 22 16:50:56 2013
@@ -31,6 +31,11 @@
  */
 
 /*!@{*/
+
+/*!
+ * \brief Initialize the JSON library.
+ */
+void ast_json_init(void);
 
 /*!
  * \brief Set custom allocators instead of the standard ast_malloc() and ast_free().

Modified: team/jrose/bridge_projects/include/asterisk/manager.h
URL: http://svnview.digium.com/svn/asterisk/team/jrose/bridge_projects/include/asterisk/manager.h?view=diff&rev=383650&r1=383649&r2=383650
==============================================================================
--- team/jrose/bridge_projects/include/asterisk/manager.h (original)
+++ team/jrose/bridge_projects/include/asterisk/manager.h Fri Mar 22 16:50:56 2013
@@ -316,4 +316,12 @@
  */
 struct ast_datastore *astman_datastore_find(struct mansession *s, const struct ast_datastore_info *info, const char *uid);
 
+/*!
+ * \brief Initialize support for AMI channel events.
+ * \return 0 on success.
+ * \return non-zero on error.
+ * \since 12
+ */
+int manager_channels_init(void);
+
 #endif /* _ASTERISK_MANAGER_H */

Modified: team/jrose/bridge_projects/main/Makefile
URL: http://svnview.digium.com/svn/asterisk/team/jrose/bridge_projects/main/Makefile?view=diff&rev=383650&r1=383649&r2=383650
==============================================================================
--- team/jrose/bridge_projects/main/Makefile (original)
+++ team/jrose/bridge_projects/main/Makefile Fri Mar 22 16:50:56 2013
@@ -151,6 +151,7 @@
 db.o: _ASTCFLAGS+=$(SQLITE3_INCLUDE)
 asterisk.o: _ASTCFLAGS+=$(LIBEDIT_INCLUDE)
 cli.o: _ASTCFLAGS+=$(LIBEDIT_INCLUDE)
+json.o: _ASTCFLAGS+=$(JANSSON_INCLUDE)
 
 ifneq ($(findstring ENABLE_UPLOADS,$(MENUSELECT_CFLAGS)),)
 http.o: _ASTCFLAGS+=$(GMIME_INCLUDE)

Modified: team/jrose/bridge_projects/main/asterisk.c
URL: http://svnview.digium.com/svn/asterisk/team/jrose/bridge_projects/main/asterisk.c?view=diff&rev=383650&r1=383649&r2=383650
==============================================================================
--- team/jrose/bridge_projects/main/asterisk.c (original)
+++ team/jrose/bridge_projects/main/asterisk.c Fri Mar 22 16:50:56 2013
@@ -241,6 +241,7 @@
 #include "asterisk/uuid.h"
 #include "asterisk/sorcery.h"
 #include "asterisk/stasis.h"
+#include "asterisk/json.h"
 
 #include "../defaults.h"
 
@@ -4070,6 +4071,7 @@
 			ast_el_read_history(filename);
 	}
 
+	ast_json_init();
 	ast_ulaw_init();
 	ast_alaw_init();
 	tdd_init();

Modified: team/jrose/bridge_projects/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/team/jrose/bridge_projects/main/channel.c?view=diff&rev=383650&r1=383649&r2=383650
==============================================================================
--- team/jrose/bridge_projects/main/channel.c (original)
+++ team/jrose/bridge_projects/main/channel.c Fri Mar 22 16:50:56 2013
@@ -155,7 +155,7 @@
 /*! \brief Message type for channel snapshot events */
 static struct stasis_message_type *__channel_snapshot;
 
-static struct stasis_message_type *__channel_varset;
+static struct stasis_message_type *__channel_blob;
 
 struct stasis_topic *__channel_topic_all;
 
@@ -243,37 +243,79 @@
 	stasis_publish(ast_channel_topic(chan), message);
 }
 
-static void channel_varset_dtor(void *obj)
-{
-	struct ast_channel_varset *event = obj;
+static void channel_blob_dtor(void *obj)
+{
+	struct ast_channel_blob *event = obj;
 	ao2_cleanup(event->snapshot);
-	ast_free(event->variable);
-	ast_free(event->value);
+	ast_json_unref(event->blob);
+}
+
+struct stasis_message *ast_channel_blob_create(struct ast_channel *chan,
+					       struct ast_json *blob)
+{
+	RAII_VAR(struct ast_channel_blob *, obj, NULL, ao2_cleanup);
+	RAII_VAR(struct stasis_message *, msg, NULL, ao2_cleanup);
+	struct ast_json *type;
+
+	ast_assert(blob != NULL);
+
+	type = ast_json_object_get(blob, "type");
+	if (type == NULL) {
+		ast_log(LOG_ERROR, "Invalid ast_channel_blob; missing type field");
+		return NULL;
+	}
+
+	obj = ao2_alloc(sizeof(*obj), channel_blob_dtor);
+	if (!obj) {
+		return NULL;
+	}
+
+	if (chan) {
+		obj->snapshot = ast_channel_snapshot_create(chan);
+		if (obj->snapshot == NULL) {
+			return NULL;
+		}
+	}
+
+	obj->blob = ast_json_ref(blob);
+
+	msg = stasis_message_create(ast_channel_blob(), obj);
+	if (!msg) {
+		return NULL;
+	}
+
+	ao2_ref(msg, +1);
+	return msg;
+}
+
+const char *ast_channel_blob_type(struct ast_channel_blob *obj)
+{
+	if (obj == NULL) {
+		return NULL;
+	}
+
+	return ast_json_string_get(ast_json_object_get(obj->blob, "type"));
 }
 
 void ast_channel_publish_varset(struct ast_channel *chan, const char *name, const char *value)
 {
-	RAII_VAR(struct ast_channel_varset *, event, NULL, ao2_cleanup);
 	RAII_VAR(struct stasis_message *, msg, NULL, ao2_cleanup);
-
-	event = ao2_alloc(sizeof(*event), channel_varset_dtor);
-	if (!event) {
+	RAII_VAR(struct ast_json *, blob, NULL, ast_json_unref);
+
+	ast_assert(name != NULL);
+	ast_assert(value != NULL);
+
+	blob = ast_json_pack("{s: s, s: s, s: s}",
+			     "type", "varset",
+			     "variable", name,
+			     "value", value);
+	if (!blob) {
+		ast_log(LOG_ERROR, "Error creating message\n");
 		return;
 	}
 
-	if (chan) {
-		event->snapshot = ast_channel_snapshot_create(chan);
-		if (event->snapshot == NULL) {
-			return;
-		}
-	}
-	event->variable = ast_strdup(name);
-	event->value = ast_strdup(value);
-	if (event->variable == NULL || event->value == NULL) {
-		return;
-	}
-
-	msg = stasis_message_create(ast_channel_varset(), event);
+	msg = ast_channel_blob_create(chan, ast_json_ref(blob));
+
 	if (!msg) {
 		return;
 	}
@@ -8636,8 +8678,8 @@
 {
 	ao2_cleanup(__channel_snapshot);
 	__channel_snapshot = NULL;
-	ao2_cleanup(__channel_varset);
-	__channel_varset = NULL;
+	ao2_cleanup(__channel_blob);
+	__channel_blob = NULL;
 	ao2_cleanup(__channel_topic_all);
 	__channel_topic_all = NULL;
 	__channel_topic_all_cached = stasis_caching_unsubscribe(__channel_topic_all_cached);
@@ -8669,7 +8711,7 @@
 	}
 
 	__channel_snapshot = stasis_message_type_create("ast_channel_snapshot");
-	__channel_varset = stasis_message_type_create("ast_channel_varset");
+	__channel_blob = stasis_message_type_create("ast_channel_blob");
 
 	__channel_topic_all = stasis_topic_create("ast_channel_topic_all");
 	__channel_topic_all_cached = stasis_caching_topic_create(__channel_topic_all, channel_snapshot_get_id);
@@ -11308,9 +11350,9 @@
 	return snapshot;
 }
 
-struct stasis_message_type *ast_channel_varset(void)
-{
-	return __channel_varset;
+struct stasis_message_type *ast_channel_blob(void)
+{
+	return __channel_blob;
 }
 
 struct stasis_message_type *ast_channel_snapshot(void)

Modified: team/jrose/bridge_projects/main/manager.c
URL: http://svnview.digium.com/svn/asterisk/team/jrose/bridge_projects/main/manager.c?view=diff&rev=383650&r1=383649&r2=383650
==============================================================================
--- team/jrose/bridge_projects/main/manager.c (original)
+++ team/jrose/bridge_projects/main/manager.c Fri Mar 22 16:50:56 2013
@@ -964,73 +964,6 @@
                         manager.conf will be present upon starting a new session.</para>
 		</description>
 	</manager>
-	<managerEvent language="en_US" name="Newchannel">
-		<managerEventInstance class="EVENT_FLAG_CALL">
-			<synopsis>Raised when a new channel is created.</synopsis>
-			<syntax>
-				<parameter name="Channel">
-				</parameter>
-				<parameter name="ChannelState">
-					<para>A numeric code for the channel's current state, related to ChannelStateDesc</para>
-				</parameter>
-				<parameter name="ChannelStateDesc">
-					<enumlist>
-						<enum name="Down"/>
-						<enum name="Rsrvd"/>
-						<enum name="OffHook"/>
-						<enum name="Dialing"/>
-						<enum name="Ring"/>
-						<enum name="Ringing"/>
-						<enum name="Up"/>
-						<enum name="Busy"/>
-						<enum name="Dialing Offhook"/>
-						<enum name="Pre-ring"/>
-						<enum name="Unknown"/>
-					</enumlist>
-				</parameter>
-				<parameter name="CallerIDNum">
-				</parameter>
-				<parameter name="CallerIDName">
-				</parameter>
-				<parameter name="ConnectedLineNum">
-				</parameter>
-				<parameter name="ConnectedLineName">
-				</parameter>
-				<parameter name="AccountCode">
-				</parameter>
-				<parameter name="Context">
-				</parameter>
-				<parameter name="Exten">
-				</parameter>
-				<parameter name="Priority">
-				</parameter>
-				<parameter name="Uniqueid">
-				</parameter>
-				<parameter name="Cause">
-					<para>A numeric cause code for why the channel was hung up.</para>
-				</parameter>
-				<parameter name="Cause-txt">
-					<para>A description of why the channel was hung up.</para>
-				</parameter>
-			</syntax>
-		</managerEventInstance>
-	</managerEvent>
-	<managerEvent language="en_US" name="Newstate">
-		<managerEventInstance class="EVENT_FLAG_CALL">
-			<synopsis>Raised when a channel's state changes.</synopsis>
-			<syntax>
-				<xi:include xpointer="xpointer(/docs/managerEvent[@name='Newchannel']/managerEventInstance/syntax/parameter)" />
-			</syntax>
-		</managerEventInstance>
-	</managerEvent>
-	<managerEvent language="en_US" name="Hangup">
-		<managerEventInstance class="EVENT_FLAG_CALL">
-			<synopsis>Raised when a channel is hung up.</synopsis>
-			<syntax>
-				<xi:include xpointer="xpointer(/docs/managerEvent[@name='Newchannel']/managerEventInstance/syntax/parameter)" />
-			</syntax>
-		</managerEventInstance>
-	</managerEvent>
  ***/
 
 /*! \addtogroup Group_AMI AMI functions
@@ -1127,8 +1060,6 @@
 	{{ "module", "unload", NULL }},
 	{{ "restart", "gracefully", NULL }},
 };
-
-static struct stasis_subscription *channel_state_sub;
 
 static void acl_change_event_cb(const struct ast_event *event, void *userdata);
 
@@ -7436,127 +7367,6 @@
 	AST_RWLIST_UNLOCK(&channelvars);
 }
 
-/*!
- * \brief Generate the AMI message body from a channel snapshot
- * \internal
- *
- * \param snapshot the channel snapshot for which to generate an AMI message body
- *
- * \retval NULL on error
- * \retval ast_str* on success (must be ast_freed by caller)
- */
-static struct ast_str *manager_build_channel_state_string(const struct ast_channel_snapshot *snapshot)
-{
-	struct ast_str *out = ast_str_create(1024);
-	int res = 0;
-	if (!out) {
-		return NULL;
-	}
-	res = ast_str_set(&out, 0,
-		"Channel: %s\r\n"
-		"ChannelState: %d\r\n"
-		"ChannelStateDesc: %s\r\n"
-		"CallerIDNum: %s\r\n"
-		"CallerIDName: %s\r\n"
-		"ConnectedLineNum: %s\r\n"
-		"ConnectedLineName: %s\r\n"
-		"AccountCode: %s\r\n"
-		"Context: %s\r\n"
-		"Exten: %s\r\n"
-		"Priority: %d\r\n"
-		"Uniqueid: %s\r\n"
-		"Cause: %d\r\n"
-		"Cause-txt: %s\r\n",
-		snapshot->name,
-		snapshot->state,
-		ast_state2str(snapshot->state),
-		snapshot->caller_number,
-		snapshot->caller_name,
-		snapshot->connected_number,
-		snapshot->connected_name,
-		snapshot->accountcode,
-		snapshot->context,
-		snapshot->exten,
-		snapshot->priority,
-		snapshot->uniqueid,
-		snapshot->hangupcause,
-		ast_cause2str(snapshot->hangupcause));
-
-	if (!res) {
-		return NULL;
-	}
-
-	return out;
-}
-
-static void channel_snapshot_update(struct ast_channel_snapshot *old_snapshot, struct ast_channel_snapshot *new_snapshot)
-{
-	int is_hungup;
-	char *manager_event = NULL;
-
-	if (!new_snapshot) {
-		/* Ignore cache clearing events; we'll see the hangup first */
-		return;
-	}
-
-	is_hungup = ast_test_flag(&new_snapshot->flags, AST_FLAG_ZOMBIE) ? 1 : 0;
-
-	if (!old_snapshot) {
-		manager_event = "Newchannel";
-	}
-
-	if (old_snapshot && old_snapshot->state != new_snapshot->state) {
-		manager_event = "Newstate";
-	}
-
-	if (old_snapshot && is_hungup) {
-		manager_event = "Hangup";
-	}
-
-	if (manager_event) {
-		RAII_VAR(struct ast_str *, channel_event_string, NULL, ast_free);
-
-		channel_event_string = manager_build_channel_state_string(new_snapshot);
-		if (channel_event_string) {
-			manager_event(EVENT_FLAG_CALL, manager_event, "%s", ast_str_buffer(channel_event_string));
-		}
-	}
-}
-
-static void channel_varset(const char *channel_name, const char *uniqueid, const char *name, const char *value)
-{
-	/*** DOCUMENTATION
-		<managerEventInstance>
-			<synopsis>Raised when a variable is set to a particular value.</synopsis>
-		</managerEventInstance>
-	***/
-	manager_event(EVENT_FLAG_DIALPLAN, "VarSet",
-		      "Channel: %s\r\n"
-		      "Variable: %s\r\n"
-		      "Value: %s\r\n"
-		      "Uniqueid: %s\r\n",
-		      channel_name, name, value, uniqueid);
-}
-
-static void channel_event_cb(void *data, struct stasis_subscription *sub, struct stasis_topic *topic, struct stasis_message *message)
-{
-	if (stasis_message_type(message) == stasis_cache_update()) {
-		struct stasis_cache_update *update = stasis_message_data(message);
-		if (ast_channel_snapshot() == update->type) {
-			struct ast_channel_snapshot *old_snapshot =
-				stasis_message_data(update->old_snapshot);
-			struct ast_channel_snapshot *new_snapshot =
-				stasis_message_data(update->new_snapshot);
-			channel_snapshot_update(old_snapshot, new_snapshot);
-		}
-	} else if (stasis_message_type(message) == ast_channel_varset()) {
-		struct ast_channel_varset *varset = stasis_message_data(message);
-		const char *name = varset->snapshot ? varset->snapshot->name : "none";
-		const char *uniqueid = varset->snapshot ? varset->snapshot->uniqueid : "none";
-		channel_varset(name, uniqueid, varset->variable, varset->value);
-	}
-}
-
 /*! \internal \brief Free a user record.  Should already be removed from the list */
 static void manager_free_user(struct ast_manager_user *user)
 {
@@ -7579,8 +7389,6 @@
 static void manager_shutdown(void)
 {
 	struct ast_manager_user *user;
-
-	channel_state_sub = stasis_unsubscribe(channel_state_sub);
 
 	if (registered) {
 		ast_manager_unregister("Ping");
@@ -7673,10 +7481,8 @@
 
 	manager_enabled = 0;
 
-	if (!channel_state_sub) {
-		channel_state_sub = stasis_subscribe(
-			stasis_caching_get_topic(ast_channel_topic_all_cached()),
-			channel_event_cb, NULL);
+	if (manager_channels_init()) {
+		return -1;
 	}
 
 	if (!registered) {

Modified: team/jrose/bridge_projects/main/pbx.c
URL: http://svnview.digium.com/svn/asterisk/team/jrose/bridge_projects/main/pbx.c?view=diff&rev=383650&r1=383649&r2=383650
==============================================================================
--- team/jrose/bridge_projects/main/pbx.c (original)
+++ team/jrose/bridge_projects/main/pbx.c Fri Mar 22 16:50:56 2013
@@ -4655,8 +4655,9 @@
 	int res;
 	struct pbx_find_info q = { .stacklen = 0 }; /* the rest is reset in pbx_find_extension */
 	char passdata[EXT_DATA_SIZE];
-
 	int matching_action = (action == E_MATCH || action == E_CANMATCH || action == E_MATCHMORE);
+	RAII_VAR(struct ast_channel_snapshot *, snapshot, NULL, ao2_cleanup);
+	RAII_VAR(struct stasis_message *, msg, NULL, ao2_cleanup);
 
 	ast_rdlock_contexts();
 	if (found)
@@ -4700,28 +4701,18 @@
 					COLORIZE(COLOR_BRMAGENTA, 0, passdata),
 					"in new stack");
 			}
-			/*** DOCUMENTATION
-				<managerEventInstance>
-					<synopsis>Raised when a channel enters a new context, extension, priority.</synopsis>
-					<syntax>
-						<parameter name="Application">
-							<para>The application about to be executed.</para>
-						</parameter>
-						<parameter name="AppData">
-							<para>The data to be passed to the application.</para>
-						</parameter>
-					</syntax>
-				</managerEventInstance>
-			***/
-			manager_event(EVENT_FLAG_DIALPLAN, "Newexten",
-					"Channel: %s\r\n"
-					"Context: %s\r\n"
-					"Extension: %s\r\n"
-					"Priority: %d\r\n"
-					"Application: %s\r\n"
-					"AppData: %s\r\n"
-					"Uniqueid: %s\r\n",
-					ast_channel_name(c), ast_channel_context(c), ast_channel_exten(c), ast_channel_priority(c), app->name, passdata, ast_channel_uniqueid(c));
+			snapshot = ast_channel_snapshot_create(c);
+			if (snapshot) {
+				/* pbx_exec sets application name and data, but we don't want to log
+				 * every exec. Just update the snapshot here instead.
+				 */
+				ast_string_field_set(snapshot, appl, app->name);
+				ast_string_field_set(snapshot, data, passdata);
+				msg = stasis_message_create(ast_channel_snapshot(), snapshot);
+				if (msg) {
+					stasis_publish(ast_channel_topic(c), msg);
+				}
+			}
 			return pbx_exec(c, app, passdata);	/* 0 on success, -1 on failure */
 		}
 	} else if (q.swo) {	/* not found here, but in another switch */

Modified: team/jrose/bridge_projects/pbx/pbx_realtime.c
URL: http://svnview.digium.com/svn/asterisk/team/jrose/bridge_projects/pbx/pbx_realtime.c?view=diff&rev=383650&r1=383649&r2=383650
==============================================================================
--- team/jrose/bridge_projects/pbx/pbx_realtime.c (original)
+++ team/jrose/bridge_projects/pbx/pbx_realtime.c Fri Mar 22 16:50:56 2013
@@ -345,6 +345,8 @@
 				char tmp1[80];
 				char tmp2[80];
 				char tmp3[EXT_DATA_SIZE];
+				RAII_VAR(struct ast_channel_snapshot *, snapshot, NULL, ao2_cleanup);
+				RAII_VAR(struct stasis_message *, msg, NULL, ao2_cleanup);
 
 				appdata[0] = 0; /* just in case the substitute var func isn't called */
 				if(!ast_strlen_zero(tmp))
@@ -354,16 +356,18 @@
 						 term_color(tmp1, app, COLOR_BRCYAN, 0, sizeof(tmp1)),
 						 term_color(tmp2, ast_channel_name(chan), COLOR_BRMAGENTA, 0, sizeof(tmp2)),
 						 term_color(tmp3, S_OR(appdata, ""), COLOR_BRMAGENTA, 0, sizeof(tmp3)));
-				manager_event(EVENT_FLAG_DIALPLAN, "Newexten",
-							  "Channel: %s\r\n"
-							  "Context: %s\r\n"
-							  "Extension: %s\r\n"
-							  "Priority: %d\r\n"
-							  "Application: %s\r\n"
-							  "AppData: %s\r\n"
-							  "Uniqueid: %s\r\n",
-							  ast_channel_name(chan), ast_channel_context(chan), ast_channel_exten(chan), ast_channel_priority(chan), app, !ast_strlen_zero(appdata) ? appdata : "(NULL)", ast_channel_uniqueid(chan));
-				
+				snapshot = ast_channel_snapshot_create(chan);
+				if (snapshot) {
+					/* pbx_exec sets application name and data, but we don't want to log
+					 * every exec. Just update the snapshot here instead.
+					 */
+					ast_string_field_set(snapshot, appl, app);
+					ast_string_field_set(snapshot, data, !ast_strlen_zero(appdata) ? appdata : "(NULL)");
+					msg = stasis_message_create(ast_channel_snapshot(), snapshot);
+					if (msg) {
+						stasis_publish(ast_channel_topic(chan), msg);
+					}
+				}
 				res = pbx_exec(chan, a, appdata);
 			} else
 				ast_log(LOG_NOTICE, "No such application '%s' for extension '%s' in context '%s'\n", app, exten, context);

Modified: team/jrose/bridge_projects/tests/test_json.c
URL: http://svnview.digium.com/svn/asterisk/team/jrose/bridge_projects/tests/test_json.c?view=diff&rev=383650&r1=383649&r2=383650
==============================================================================
--- team/jrose/bridge_projects/tests/test_json.c (original)
+++ team/jrose/bridge_projects/tests/test_json.c Fri Mar 22 16:50:56 2013
@@ -31,7 +31,6 @@
 
 /*** MODULEINFO
 	<depend>TEST_FRAMEWORK</depend>
-	<depend>res_json</depend>
 	<support_level>core</support_level>
  ***/
 
@@ -1720,5 +1719,4 @@
 
 AST_MODULE_INFO(ASTERISK_GPL_KEY, 0, "JSON testing",
 		.load = load_module,
-		.unload = unload_module,
-		.nonoptreq = "res_json");
+		.unload = unload_module);




More information about the asterisk-commits mailing list