[asterisk-commits] qwell: branch qwell/fun_with_transports r383715 - in /team/qwell/fun_with_tra...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Mar 25 10:38:55 CDT 2013


Author: qwell
Date: Mon Mar 25 10:38:51 2013
New Revision: 383715

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=383715
Log:
Multiple revisions 383523,383543,383562,383581,383606,383616,383635,383656-383657,383672

........
  r383523 | root | 2013-03-21 13:17:44 -0500 (Thu, 21 Mar 2013) | 5 lines
  
  Fix astobj2 doxygen comment.
  ........
  
  Merged revisions 383519 from file:///srv/subversion/repos/asterisk/trunk
........
  r383543 | root | 2013-03-21 15:17:37 -0500 (Thu, 21 Mar 2013) | 7 lines
  
  Corrected doc error for Stasis. I guess the mutex isn't necessary.
  
  Thanks, rmudgett!
  ........
  
  Merged revisions 383541 from file:///srv/subversion/repos/asterisk/trunk
........
  r383562 | root | 2013-03-22 02:17:39 -0500 (Fri, 22 Mar 2013) | 13 lines
  
  Fix skinny voicemail indication issues.
  
  Unsubscribe from MWI stasis event on channel reload.
  
  (closes issue ASTERISK-21216)
  Reported by: wedhorn 
  Tested by: snuffy, myself
  Patches: 
      skinny-mwiind02.diff uploaded by snuffy (license 5024)
  ........
  
  Merged revisions 383560 from file:///srv/subversion/repos/asterisk/trunk
........
  r383581 | root | 2013-03-22 09:18:11 -0500 (Fri, 22 Mar 2013) | 35 lines
  
  Move more channel events to Stasis; move res_json.c to main/json.c.
  
  This patch started out simply as fixing the bouncing tests introduced
  in r382685, but required some other changes to give it a decent
  implementation.
  
  To fix the bouncing tests, the UserEvent and Newexten AMI events
  needed to be refactored to dispatch via Stasis. Dispatching directly
  to AMI resulted in those events sometimes getting ahead of the
  associated Newchannel events, which would understandably confuse anyone.
  
  I found that instead of creating a zillion different message types and
  structures associated with them, it would be preferable to define a
  message type that has a channel snapshot and a blob of structured data
  with a small bit of additional information. The JSON object model
  provides a very nice way of representing structured data, so I went
  with that.
  
   * Move JSON support from res_json.c to main/json.c
     * Made libjansson-dev a required dependency
   * Added an ast_channel_blob message type, which has a channel
     snapshot and JSON blob of data.
   * Changed UserEvent and Newexten events so that they are dispatched
     via ast_channel_blob messages on the channel's topic.
   * Got rid of the ast_channel_varset message; used ast_channel_blob
     instead.
   * Extracted the manager functions converting Stasis channel events to
     AMI events into manager_channel.c.
  
  (issue ASTERISK-21096)
  Review: https://reviewboard.asterisk.org/r/2381/
  ........
  
  Merged revisions 383579 from file:///srv/subversion/repos/asterisk/trunk
........
  r383606 | mmichelson | 2013-03-22 13:51:51 -0500 (Fri, 22 Mar 2013) | 11 lines
  
  The configure script in this branch was broken.
  
  A macro from the auto-configure script did not expand properly
  and caused the configure script to fail.
  
  I've regenerated the configure script here. This will almost
  certainly cause a conflict the next time automerge occurs. When
  that happens, we'll respond by just using the version of the
  configure script that was being merged in.
........
  r383616 | root | 2013-03-22 15:17:44 -0500 (Fri, 22 Mar 2013) | 9 lines
  
  Corrected some module issues introduced by r383579.
  
  When I moved res_json.c to json.c, I left the MODULE_INFO stuff in there,
  which was interesting if you ran module show. I also forgot to call what
  was in module_load() from asterisk main().
  ........
  
  Merged revisions 383611 from file:///srv/subversion/repos/asterisk/trunk
........
  r383635 | root | 2013-03-22 16:17:38 -0500 (Fri, 22 Mar 2013) | 36 lines
  
  Multiple revisions 383632-383633
  
  ........
    r383632 | elguero | 2013-03-22 15:43:24 -0500 (Fri, 22 Mar 2013) | 21 lines
    
    Fix StopMixMonitor Hanging Up When Unable To Stop MixMonitor On A Channel
    
    A regression was accidentally introduced when allowing an optional ID to be used
    when calling StopMixMonitor.  When we are unable to stop MixMonitor on a
    channel, -1 is being returned which triggers the hangup of the channel.
    
    This patch restores the prior behavior by returning 0 whether we were successful
    or not.  It also allows the call from the manager to use the return code when
    the action fails.
    
    (closes issue ASTERISK-2294)
    Reported by: daroz
    Tested by: daroz
    Patches:
      asterisk-21294-stop_mixmonitor_hangingup.diff Michael L. Young (license 5026)
    
    Review: https://reviewboard.asterisk.org/r/2404/
    ........
    
    Merged revisions 383631 from http://svn.asterisk.org/svn/asterisk/branches/11
  ........
    r383633 | dlee | 2013-03-22 15:51:33 -0500 (Fri, 22 Mar 2013) | 5 lines
    
    Fixed another issue from r383579.
    
    Core modules don't honor <depend> flags in MODULEINFO, which broke jansson
    if specified --with-jansson to configure.
  ........
  
  Merged revisions 383632-383633 from file:///srv/subversion/repos/asterisk/trunk
........
  r383656 | file | 2013-03-23 20:51:12 -0500 (Sat, 23 Mar 2013) | 2 lines
  
  Fix memory leak where the ast_strs were not being freed.
........
  r383657 | file | 2013-03-23 20:57:49 -0500 (Sat, 23 Mar 2013) | 2 lines
  
  Late night commits... yow'sa.
........
  r383672 | root | 2013-03-25 08:17:44 -0500 (Mon, 25 Mar 2013) | 11 lines
  
  Properly delimit post data in res_config_curl.
  ........
  
  Merged revisions 383667 from http://svn.asterisk.org/svn/asterisk/branches/1.8
  ........
  
  Merged revisions 383668 from http://svn.asterisk.org/svn/asterisk/branches/11
  ........
  
  Merged revisions 383669 from file:///srv/subversion/repos/asterisk/trunk
........

Merged revisions 383523,383543,383562,383581,383606,383616,383635,383656-383657,383672 from http://svn.asterisk.org/svn/asterisk/team/group/pimp_my_sip

Added:
    team/qwell/fun_with_transports/main/json.c
      - copied unchanged from r383672, team/group/pimp_my_sip/main/json.c
    team/qwell/fun_with_transports/main/manager_channels.c
      - copied unchanged from r383672, team/group/pimp_my_sip/main/manager_channels.c
Removed:
    team/qwell/fun_with_transports/res/res_json.c
    team/qwell/fun_with_transports/res/res_json.exports.in
Modified:
    team/qwell/fun_with_transports/   (props changed)
    team/qwell/fun_with_transports/CHANGES
    team/qwell/fun_with_transports/apps/app_mixmonitor.c
    team/qwell/fun_with_transports/apps/app_userevent.c
    team/qwell/fun_with_transports/channels/chan_skinny.c
    team/qwell/fun_with_transports/configure
    team/qwell/fun_with_transports/configure.ac
    team/qwell/fun_with_transports/include/asterisk/astobj2.h
    team/qwell/fun_with_transports/include/asterisk/channel.h
    team/qwell/fun_with_transports/include/asterisk/json.h
    team/qwell/fun_with_transports/include/asterisk/manager.h
    team/qwell/fun_with_transports/include/asterisk/stasis.h
    team/qwell/fun_with_transports/main/Makefile
    team/qwell/fun_with_transports/main/asterisk.c
    team/qwell/fun_with_transports/main/channel.c
    team/qwell/fun_with_transports/main/manager.c
    team/qwell/fun_with_transports/main/pbx.c
    team/qwell/fun_with_transports/pbx/pbx_realtime.c
    team/qwell/fun_with_transports/res/res_config_curl.c
    team/qwell/fun_with_transports/res/res_sip_authenticator_digest.c
    team/qwell/fun_with_transports/tests/test_json.c

Propchange: team/qwell/fun_with_transports/
------------------------------------------------------------------------------
Binary property 'branch-11-merged' - no diff available.

Propchange: team/qwell/fun_with_transports/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Mon Mar 25 10:38:51 2013
@@ -1,1 +1,1 @@
-/team/group/pimp_my_sip:1-383510 /trunk:1-383466
+/team/group/pimp_my_sip:1-383510,383523-383672 /trunk:1-383466

Modified: team/qwell/fun_with_transports/CHANGES
URL: http://svnview.digium.com/svn/asterisk/team/qwell/fun_with_transports/CHANGES?view=diff&rev=383715&r1=383714&r2=383715
==============================================================================
--- team/qwell/fun_with_transports/CHANGES (original)
+++ team/qwell/fun_with_transports/CHANGES Mon Mar 25 10:38:51 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/qwell/fun_with_transports/apps/app_mixmonitor.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/fun_with_transports/apps/app_mixmonitor.c?view=diff&rev=383715&r1=383714&r2=383715
==============================================================================
--- team/qwell/fun_with_transports/apps/app_mixmonitor.c (original)
+++ team/qwell/fun_with_transports/apps/app_mixmonitor.c Mon Mar 25 10:38:51 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/qwell/fun_with_transports/apps/app_userevent.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/fun_with_transports/apps/app_userevent.c?view=diff&rev=383715&r1=383714&r2=383715
==============================================================================
--- team/qwell/fun_with_transports/apps/app_userevent.c (original)
+++ team/qwell/fun_with_transports/apps/app_userevent.c Mon Mar 25 10:38:51 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/qwell/fun_with_transports/channels/chan_skinny.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/fun_with_transports/channels/chan_skinny.c?view=diff&rev=383715&r1=383714&r2=383715
==============================================================================
--- team/qwell/fun_with_transports/channels/chan_skinny.c (original)
+++ team/qwell/fun_with_transports/channels/chan_skinny.c Mon Mar 25 10:38:51 2013
@@ -8571,6 +8571,9 @@
 		   We do not want to free the line here, that
 		   will happen below. */
 		while ((l = AST_LIST_REMOVE_HEAD(&d->lines, list))) {
+			if (l->mwi_event_sub) {
+				l->mwi_event_sub = stasis_unsubscribe(l->mwi_event_sub);
+			}
 		}
 		/* Delete all speeddials for this device */
 		while ((sd = AST_LIST_REMOVE_HEAD(&d->speeddials, list))) {

Modified: team/qwell/fun_with_transports/configure.ac
URL: http://svnview.digium.com/svn/asterisk/team/qwell/fun_with_transports/configure.ac?view=diff&rev=383715&r1=383714&r2=383715
==============================================================================
--- team/qwell/fun_with_transports/configure.ac (original)
+++ team/qwell/fun_with_transports/configure.ac Mon Mar 25 10:38:51 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/qwell/fun_with_transports/include/asterisk/astobj2.h
URL: http://svnview.digium.com/svn/asterisk/team/qwell/fun_with_transports/include/asterisk/astobj2.h?view=diff&rev=383715&r1=383714&r2=383715
==============================================================================
--- team/qwell/fun_with_transports/include/asterisk/astobj2.h (original)
+++ team/qwell/fun_with_transports/include/asterisk/astobj2.h Mon Mar 25 10:38:51 2013
@@ -1433,8 +1433,8 @@
  * \param flags search_flags to control linking the object.  (OBJ_NOLOCK)
  * \param tag used for debugging.
  *
- * \retval NULL on errors.
- * \retval !NULL on success.
+ * \retval 0 on errors.
+ * \retval 1 on success.
  *
  * This function inserts an object in a container according its key.
  *

Modified: team/qwell/fun_with_transports/include/asterisk/channel.h
URL: http://svnview.digium.com/svn/asterisk/team/qwell/fun_with_transports/include/asterisk/channel.h?view=diff&rev=383715&r1=383714&r2=383715
==============================================================================
--- team/qwell/fun_with_transports/include/asterisk/channel.h (original)
+++ team/qwell/fun_with_transports/include/asterisk/channel.h Mon Mar 25 10:38:51 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
 
@@ -4187,24 +4188,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/qwell/fun_with_transports/include/asterisk/json.h
URL: http://svnview.digium.com/svn/asterisk/team/qwell/fun_with_transports/include/asterisk/json.h?view=diff&rev=383715&r1=383714&r2=383715
==============================================================================
--- team/qwell/fun_with_transports/include/asterisk/json.h (original)
+++ team/qwell/fun_with_transports/include/asterisk/json.h Mon Mar 25 10:38:51 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/qwell/fun_with_transports/include/asterisk/manager.h
URL: http://svnview.digium.com/svn/asterisk/team/qwell/fun_with_transports/include/asterisk/manager.h?view=diff&rev=383715&r1=383714&r2=383715
==============================================================================
--- team/qwell/fun_with_transports/include/asterisk/manager.h (original)
+++ team/qwell/fun_with_transports/include/asterisk/manager.h Mon Mar 25 10:38:51 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/qwell/fun_with_transports/include/asterisk/stasis.h
URL: http://svnview.digium.com/svn/asterisk/team/qwell/fun_with_transports/include/asterisk/stasis.h?view=diff&rev=383715&r1=383714&r2=383715
==============================================================================
--- team/qwell/fun_with_transports/include/asterisk/stasis.h (original)
+++ team/qwell/fun_with_transports/include/asterisk/stasis.h Mon Mar 25 10:38:51 2013
@@ -54,9 +54,7 @@
  * enforced in code). Messages themselves are reference-counted, AO2 objects,
  * along with their values. By being both reference counted and immutable,
  * messages can be shared throughout the system without any concerns for
- * threading. (Well, the objects must be allocated with \ref
- * AO2_ALLOC_OPT_LOCK_MUTEX so that the reference counting operations are thread
- * safe. But other than that, no worries).
+ * threading.
  *
  * The type of a message is defined by an instance of \ref stasis_message_type,
  * which can be created by calling stasis_message_type_create(). Message types

Modified: team/qwell/fun_with_transports/main/Makefile
URL: http://svnview.digium.com/svn/asterisk/team/qwell/fun_with_transports/main/Makefile?view=diff&rev=383715&r1=383714&r2=383715
==============================================================================
--- team/qwell/fun_with_transports/main/Makefile (original)
+++ team/qwell/fun_with_transports/main/Makefile Mon Mar 25 10:38:51 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/qwell/fun_with_transports/main/asterisk.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/fun_with_transports/main/asterisk.c?view=diff&rev=383715&r1=383714&r2=383715
==============================================================================
--- team/qwell/fun_with_transports/main/asterisk.c (original)
+++ team/qwell/fun_with_transports/main/asterisk.c Mon Mar 25 10:38:51 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/qwell/fun_with_transports/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/fun_with_transports/main/channel.c?view=diff&rev=383715&r1=383714&r2=383715
==============================================================================
--- team/qwell/fun_with_transports/main/channel.c (original)
+++ team/qwell/fun_with_transports/main/channel.c Mon Mar 25 10:38:51 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;
 	}
@@ -8633,8 +8675,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);
@@ -8666,7 +8708,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);
@@ -11305,9 +11347,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/qwell/fun_with_transports/main/manager.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/fun_with_transports/main/manager.c?view=diff&rev=383715&r1=383714&r2=383715
==============================================================================
--- team/qwell/fun_with_transports/main/manager.c (original)
+++ team/qwell/fun_with_transports/main/manager.c Mon Mar 25 10:38:51 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);
 
@@ -7446,127 +7377,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)
 {
@@ -7589,8 +7399,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");
@@ -7683,10 +7491,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/qwell/fun_with_transports/main/pbx.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/fun_with_transports/main/pbx.c?view=diff&rev=383715&r1=383714&r2=383715
==============================================================================
--- team/qwell/fun_with_transports/main/pbx.c (original)
+++ team/qwell/fun_with_transports/main/pbx.c Mon Mar 25 10:38:51 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/qwell/fun_with_transports/pbx/pbx_realtime.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/fun_with_transports/pbx/pbx_realtime.c?view=diff&rev=383715&r1=383714&r2=383715
==============================================================================
--- team/qwell/fun_with_transports/pbx/pbx_realtime.c (original)
+++ team/qwell/fun_with_transports/pbx/pbx_realtime.c Mon Mar 25 10:38:51 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/qwell/fun_with_transports/res/res_config_curl.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/fun_with_transports/res/res_config_curl.c?view=diff&rev=383715&r1=383714&r2=383715
==============================================================================
--- team/qwell/fun_with_transports/res/res_config_curl.c (original)
+++ team/qwell/fun_with_transports/res/res_config_curl.c Mon Mar 25 10:38:51 2013
@@ -463,7 +463,7 @@
 {
 	struct ast_str *query, *buffer;
 	char *elm, field[256];
-	int type, size;
+	int type, size, i = 0;
 
 	if (!ast_custom_function_find("CURL")) {
 		ast_log(LOG_ERROR, "func_curl.so must be loaded in order to use res_config_curl.so!!\n");
@@ -484,7 +484,9 @@
 		type = va_arg(ap, require_type);
 		size = va_arg(ap, int);
 		ast_uri_encode(elm, field, sizeof(field), ast_uri_http);
-		ast_str_append(&query, 0, "%s=%s%%3A%d", field,
+		ast_str_append(&query, 0, "%s%s=%s%%3A%d",
+			i > 0 ? "&" : "",
+			field,
 			type == RQ_CHAR ? "char" :
 			type == RQ_INTEGER1 ? "integer1" :
 			type == RQ_UINTEGER1 ? "uinteger1" :
@@ -500,6 +502,7 @@
 			type == RQ_DATETIME ? "datetime" :
 			type == RQ_FLOAT ? "float" :
 			"unknown", size);
+		i++;
 	}
 
 	ast_str_append(&query, 0, ")}");

Modified: team/qwell/fun_with_transports/res/res_sip_authenticator_digest.c

[... 59 lines stripped ...]



More information about the asterisk-commits mailing list