[asterisk-commits] qwell: branch qwell/hold_events r389739 - in /team/qwell/hold_events: ./ apps...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri May 24 16:11:38 CDT 2013


Author: qwell
Date: Fri May 24 16:11:28 2013
New Revision: 389739

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=389739
Log:
Multiple revisions 389733,389738

........
  r389733 | mjordan | 2013-05-24 15:44:07 -0500 (Fri, 24 May 2013) | 20 lines
  
  Migrate a large number of AMI events over to Stasis-Core
  
  This patch moves a number of AMI events over to the Stasis-Core message bus.
  This includes:
   * ChanSpyStart/Stop
   * MonitorStart/Stop
   * MusicOnHoldStart/Stop
   * FullyBooted/Reload
   * All Voicemail/MWI related events
  
  In addition, it adds some Stasis-Core and AMI support for generic AMI messages,
  refactors the message router in AMI to use a single router with topic
  forwarding for the topics that AMI cares about, and refactors MWI message
  types and topics to be more name compliant.
  
  Review: https://reviewboard.asterisk.org/r/2532
  
  (closes issue ASTERISK-21462)
........
  r389738 | kmoore | 2013-05-24 16:01:30 -0500 (Fri, 24 May 2013) | 5 lines
  
  Remove a junk define
  
  BLOB_HANDLER_BUCKETS is a remnant of using "type" fields in
  JSON/snapshot blobs and is no longer used.
........

Merged revisions 389733,389738 from http://svn.asterisk.org/svn/asterisk/trunk

Added:
    team/qwell/hold_events/main/manager_mwi.c
      - copied unchanged from r389738, trunk/main/manager_mwi.c
Modified:
    team/qwell/hold_events/   (props changed)
    team/qwell/hold_events/CHANGES
    team/qwell/hold_events/apps/app_chanspy.c
    team/qwell/hold_events/apps/app_fax.c
    team/qwell/hold_events/apps/app_minivm.c
    team/qwell/hold_events/apps/app_voicemail.c
    team/qwell/hold_events/channels/chan_dahdi.c
    team/qwell/hold_events/channels/chan_iax2.c
    team/qwell/hold_events/channels/chan_mgcp.c
    team/qwell/hold_events/channels/chan_sip.c
    team/qwell/hold_events/channels/chan_skinny.c
    team/qwell/hold_events/channels/chan_unistim.c
    team/qwell/hold_events/channels/sig_pri.c
    team/qwell/hold_events/include/asterisk/_private.h
    team/qwell/hold_events/include/asterisk/app.h
    team/qwell/hold_events/include/asterisk/json.h
    team/qwell/hold_events/include/asterisk/manager.h
    team/qwell/hold_events/include/asterisk/stasis_channels.h
    team/qwell/hold_events/main/app.c
    team/qwell/hold_events/main/asterisk.c
    team/qwell/hold_events/main/cdr.c
    team/qwell/hold_events/main/cli.c
    team/qwell/hold_events/main/dnsmgr.c
    team/qwell/hold_events/main/enum.c
    team/qwell/hold_events/main/json.c
    team/qwell/hold_events/main/loader.c
    team/qwell/hold_events/main/manager.c
    team/qwell/hold_events/main/manager_channels.c
    team/qwell/hold_events/main/pbx.c
    team/qwell/hold_events/main/stasis_channels.c
    team/qwell/hold_events/res/parking/parking_manager.c
    team/qwell/hold_events/res/res_fax.c
    team/qwell/hold_events/res/res_jabber.c
    team/qwell/hold_events/res/res_monitor.c
    team/qwell/hold_events/res/res_musiconhold.c
    team/qwell/hold_events/res/res_sip_mwi.c
    team/qwell/hold_events/res/res_stasis.c
    team/qwell/hold_events/res/res_xmpp.c

Propchange: team/qwell/hold_events/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Fri May 24 16:11:28 2013
@@ -1,1 +1,1 @@
-/trunk:1-389712
+/trunk:1-389738

Modified: team/qwell/hold_events/CHANGES
URL: http://svnview.digium.com/svn/asterisk/team/qwell/hold_events/CHANGES?view=diff&rev=389739&r1=389738&r2=389739
==============================================================================
--- team/qwell/hold_events/CHANGES (original)
+++ team/qwell/hold_events/CHANGES Fri May 24 16:11:28 2013
@@ -71,6 +71,26 @@
    ChanVariable: bar=baz. When multiple channels are present in a single AMI
    event, the various ChanVariable fields will contain a suffix that specifies
    which channel they correspond to.
+
+ * All "Reload" events have been consolidated into a single event type. This
+   event will always contain a Module field specifying the name of the module
+   and a Status field denoting the result of the reload. All modules now issue
+   this event when being reloaded.
+
+ * The "ModuleLoadReport" event has been removed. Most AMI connections would
+   fail to receive this event due to being connected after modules have loaded.
+   AMI connections that want to know when Asterisk is ready should listen for
+   the "FullyBooted" event.
+
+ * app_fax now sends the same send fax/receive fax events as res_fax. The
+   "FaxSent" event is now the "SendFAX" event, and the "FaxReceived" event is
+   now the "ReceiveFAX" event.
+
+ * The MusicOnHold event is now two events: MusicOnHoldStart and
+   MusicOnHoldStop. The sub type field has been removed.
+
+ * The JabberEvent event has been removed. It is not AMI's purpose to be a
+   carrier for another protocol.
 
  * The AMI 'Status' response event to the AMI Status action replaces the
    BridgedChannel and BridgedUniqueid headers with the BridgeID header to

Modified: team/qwell/hold_events/apps/app_chanspy.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/hold_events/apps/app_chanspy.c?view=diff&rev=389739&r1=389738&r2=389739
==============================================================================
--- team/qwell/hold_events/apps/app_chanspy.c (original)
+++ team/qwell/hold_events/apps/app_chanspy.c Fri May 24 16:11:28 2013
@@ -55,6 +55,8 @@
 #include "asterisk/lock.h"
 #include "asterisk/options.h"
 #include "asterisk/autochan.h"
+#include "asterisk/stasis_channels.h"
+#include "asterisk/json.h"
 
 #define AST_NAME_STRLEN 256
 #define NUM_SPYGROUPS 128
@@ -188,6 +190,8 @@
 		</description>
 		<see-also>
 			<ref type="application">ExtenSpy</ref>
+			<ref type="managerEvent">ChanSpyStart</ref>
+			<ref type="managerEvent">ChanSpyStop</ref>
 		</see-also>
 	</application>
 	<application name="ExtenSpy" language="en_US">
@@ -322,9 +326,10 @@
 		</description>
 		<see-also>
 			<ref type="application">ChanSpy</ref>
+			<ref type="managerEvent">ChanSpyStart</ref>
+			<ref type="managerEvent">ChanSpyStop</ref>
 		</see-also>
 	</application>
-	
 	<application name="DAHDIScan" language="en_US">
 		<synopsis>
 			Scan DAHDI channels to monitor calls.
@@ -338,6 +343,10 @@
 			<para>Allows a call center manager to monitor DAHDI channels in a
 			convenient way.  Use <literal>#</literal> to select the next channel and use <literal>*</literal> to exit.</para>
 		</description>
+		<see-also>
+			<ref type="managerEvent">ChanSpyStart</ref>
+			<ref type="managerEvent">ChanSpyStop</ref>
+		</see-also>
 	</application>
  ***/
 
@@ -512,6 +521,68 @@
 	}
 }
 
+static int pack_channel_into_message(struct ast_channel *chan, const char *role,
+									 struct ast_multi_channel_blob *payload)
+{
+	RAII_VAR(struct ast_channel_snapshot *, snapshot,
+			ast_channel_snapshot_get_latest(ast_channel_uniqueid(chan)),
+			ao2_cleanup);
+
+	if (!snapshot) {
+		return -1;
+	}
+	ast_multi_channel_blob_add_channel(payload, role, snapshot);
+	return 0;
+}
+
+/*! \internal
+ * \brief Publish the chanspy message over Stasis-Core
+ * \param spyer The channel doing the spying
+ * \param spyee Who is being spied upon
+ * \start start If non-zero, the spying is starting. Otherwise, the spyer is
+ * finishing
+ */
+static void publish_chanspy_message(struct ast_channel *spyer,
+									struct ast_channel *spyee,
+									int start)
+{
+	RAII_VAR(struct ast_json *, blob, NULL, ast_json_unref);
+	RAII_VAR(struct ast_multi_channel_blob *, payload, NULL, ao2_cleanup);
+	RAII_VAR(struct stasis_message *, message, NULL, ao2_cleanup);
+
+	if (!spyer) {
+		ast_log(AST_LOG_WARNING, "Attempt to publish ChanSpy message for NULL spyer channel\n");
+		return;
+	}
+	blob = ast_json_null();
+	if (!blob) {
+		return;
+	}
+
+	payload = ast_multi_channel_blob_create(blob);
+	if (!payload) {
+		return;
+	}
+
+	if (pack_channel_into_message(spyer, "spyer_channel", payload)) {
+		return;
+	}
+
+	if (spyee) {
+		if (pack_channel_into_message(spyee, "spyee_channel", payload)) {
+			return;
+		}
+	}
+
+	message = stasis_message_create(
+			start ? ast_channel_chanspy_start_type(): ast_channel_chanspy_stop_type(),
+					payload);
+	if (!message) {
+		return;
+	}
+	stasis_publish(ast_channel_topic(spyer), message);
+}
+
 static int channel_spy(struct ast_channel *chan, struct ast_autochan *spyee_autochan,
 	int *volfactor, int fd, struct spy_dtmf_options *user_options, struct ast_flags *flags,
 	char *exitcontext)
@@ -524,38 +595,22 @@
 	struct ast_silence_generator *silgen = NULL;
 	struct ast_autochan *spyee_bridge_autochan = NULL;
 	const char *spyer_name;
-	struct ast_channel *chans[] = { chan, spyee_autochan->chan };
+
+	if (ast_check_hangup(chan) || ast_check_hangup(spyee_autochan->chan) ||
+			ast_test_flag(ast_channel_flags(spyee_autochan->chan), AST_FLAG_ZOMBIE)) {
+		return 0;
+	}
 
 	ast_channel_lock(chan);
 	spyer_name = ast_strdupa(ast_channel_name(chan));
 	ast_channel_unlock(chan);
 
-	/* We now hold the channel lock on spyee */
-
-	if (ast_check_hangup(chan) || ast_check_hangup(spyee_autochan->chan) ||
-			ast_test_flag(ast_channel_flags(spyee_autochan->chan), AST_FLAG_ZOMBIE)) {
-		return 0;
-	}
-
 	ast_channel_lock(spyee_autochan->chan);
 	name = ast_strdupa(ast_channel_name(spyee_autochan->chan));
 	ast_channel_unlock(spyee_autochan->chan);
 
 	ast_verb(2, "Spying on channel %s\n", name);
-	/*** DOCUMENTATION
-		<managerEventInstance>
-			<synopsis>Raised when a channel has started spying on another channel.</synopsis>
-			<see-also>
-				<ref type="application">ChanSpy</ref>
-				<ref type="application">ExtenSpy</ref>
-				<ref type="managerEvent">ChanSpyStop</ref>
-			</see-also>
-		</managerEventInstance>
-	***/
-	ast_manager_event_multichan(EVENT_FLAG_CALL, "ChanSpyStart", 2, chans,
-			"SpyerChannel: %s\r\n"
-			"SpyeeChannel: %s\r\n",
-			spyer_name, name);
+	publish_chanspy_message(chan, spyee_autochan->chan, 1);
 
 	memset(&csth, 0, sizeof(csth));
 	ast_copy_flags(&csth.flags, flags, AST_FLAGS_ALL);
@@ -740,15 +795,7 @@
 	}
 
 	ast_verb(2, "Done Spying on channel %s\n", name);
-	/*** DOCUMENTATION
-		<managerEventInstance>
-			<synopsis>Raised when a channel has stopped spying on another channel.</synopsis>
-			<see-also>
-				<ref type="managerEvent">ChanSpyStart</ref>
-			</see-also>
-		</managerEventInstance>
-	***/
-	ast_manager_event(chan, EVENT_FLAG_CALL, "ChanSpyStop", "SpyeeChannel: %s\r\n", name);
+	publish_chanspy_message(chan, NULL, 0);
 
 	return running;
 }

Modified: team/qwell/hold_events/apps/app_fax.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/hold_events/apps/app_fax.c?view=diff&rev=389739&r1=389738&r2=389739
==============================================================================
--- team/qwell/hold_events/apps/app_fax.c (original)
+++ team/qwell/hold_events/apps/app_fax.c Fri May 24 16:11:28 2013
@@ -43,7 +43,8 @@
 #include "asterisk/app.h"
 #include "asterisk/dsp.h"
 #include "asterisk/module.h"
-#include "asterisk/manager.h"
+#include "asterisk/stasis.h"
+#include "asterisk/stasis_channels.h"
 
 /*** DOCUMENTATION
 	<application name="SendFAX" language="en_US" module="app_fax">
@@ -202,6 +203,9 @@
 
 static void phase_e_handler(t30_state_t *f, void *user_data, int result)
 {
+	RAII_VAR(struct ast_json *, json_object, NULL, ast_json_unref);
+	RAII_VAR(struct ast_json *, json_filenames, NULL, ast_json_unref);
+	RAII_VAR(struct stasis_message *, message, NULL, ao2_cleanup);
 	const char *local_ident;
 	const char *far_ident;
 	char buf[20];
@@ -251,32 +255,24 @@
 	ast_debug(1, "  Image resolution:  %d x %d\n", stat.x_resolution, stat.y_resolution);
 	ast_debug(1, "  Transfer Rate:     %d\n", stat.bit_rate);
 
-	ast_manager_event(s->chan, EVENT_FLAG_CALL,
-		s->direction ? "FaxSent" : "FaxReceived",
-		"Channel: %s\r\n"
-		"Exten: %s\r\n"
-		"CallerID: %s\r\n"
-		"CallerIDName: %s\r\n"
-		"ConnectedLineNum: %s\r\n"
-		"ConnectedLineName: %s\r\n"
-		"RemoteStationID: %s\r\n"
-		"LocalStationID: %s\r\n"
-		"PagesTransferred: %d\r\n"
-		"Resolution: %d\r\n"
-		"TransferRate: %d\r\n"
-		"FileName: %s\r\n",
-		ast_channel_name(s->chan),
-		ast_channel_exten(s->chan),
-		S_COR(ast_channel_caller(s->chan)->id.number.valid, ast_channel_caller(s->chan)->id.number.str, ""),
-		S_COR(ast_channel_caller(s->chan)->id.name.valid, ast_channel_caller(s->chan)->id.name.str, ""),
-		S_COR(ast_channel_connected(s->chan)->id.number.valid, ast_channel_connected(s->chan)->id.number.str, ""),
-		S_COR(ast_channel_connected(s->chan)->id.name.valid, ast_channel_connected(s->chan)->id.name.str, ""),
-		far_ident,
-		local_ident,
-		pages_transferred,
-		stat.y_resolution,
-		stat.bit_rate,
-		s->file_name);
+	json_filenames = ast_json_pack("[s]", s->file_name);
+	if (!json_filenames) {
+		return;
+	}
+	ast_json_ref(json_filenames);
+	json_object = ast_json_pack("{s: s, s: s, s: s, s: i, s: i, s: i, s: o}",
+			"type", s->direction ? "send" : "receive",
+			"remote_station_id", far_ident,
+			"local_station_id", local_ident,
+			"fax_pages", pages_transferred,
+			"fax_resolution", stat.y_resolution,
+			"fax_bitrate", stat.bit_rate,
+			"filenames", json_filenames);
+	message = ast_channel_cached_blob_create(s->chan, ast_channel_fax_type(), json_object);
+	if (!message) {
+		return;
+	}
+	stasis_publish(ast_channel_topic(s->chan), message);
 }
 
 /* === Helper functions to configure fax === */

Modified: team/qwell/hold_events/apps/app_minivm.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/hold_events/apps/app_minivm.c?view=diff&rev=389739&r1=389738&r2=389739
==============================================================================
--- team/qwell/hold_events/apps/app_minivm.c (original)
+++ team/qwell/hold_events/apps/app_minivm.c Fri May 24 16:11:28 2013
@@ -166,14 +166,15 @@
 #include "asterisk/say.h"
 #include "asterisk/module.h"
 #include "asterisk/app.h"
-#include "asterisk/manager.h"
 #include "asterisk/dsp.h"
 #include "asterisk/localtime.h"
 #include "asterisk/cli.h"
 #include "asterisk/utils.h"
 #include "asterisk/linkedlists.h"
 #include "asterisk/callerid.h"
-#include "asterisk/event.h"
+#include "asterisk/stasis.h"
+#include "asterisk/stasis_channels.h"
+#include "asterisk/json.h"
 
 /*** DOCUMENTATION
 <application name="MinivmRecord" language="en_US">
@@ -495,7 +496,23 @@
 		<ref type="function">MINIVMCOUNTER</ref>
 	</see-also>
 </function>
-
+	<managerEvent language="en_US" name="MiniVoiceMail">
+		<managerEventInstance class="EVENT_FLAG_CALL">
+			<synopsis>Raised when a notification is sent out by a MiniVoiceMail application</synopsis>
+			<syntax>
+				<xi:include xpointer="xpointer(/docs/managerEvent[@name='Newchannel']/managerEventInstance/syntax/parameter)" />
+				<parameter name="Action">
+					<para>What action was taken. Currently, this will always be <literal>SentNotification</literal></para>
+				</parameter>
+				<parameter name="Mailbox">
+					<para>The mailbox that the notification was about, specified as <literal>mailbox</literal>@<literal>context</literal></para>
+				</parameter>
+				<parameter name="Counter">
+					<para>A message counter derived from the <literal>MVM_COUNTER</literal> channel variable.</para>
+				</parameter>
+			</syntax>
+		</managerEventInstance>
+	</managerEvent>
 ***/
 
 #ifndef TRUE
@@ -1761,6 +1778,9 @@
  * \brief Send message to voicemail account owner */
 static int notify_new_message(struct ast_channel *chan, const char *templatename, struct minivm_account *vmu, const char *filename, long duration, const char *format, char *cidnum, char *cidname)
 {
+	RAII_VAR(struct ast_json *, json_object, NULL, ast_json_unref);
+	RAII_VAR(struct stasis_message *, message, NULL, ao2_cleanup);
+	RAII_VAR(struct ast_mwi_state *, mwi_state, NULL, ao2_cleanup);
 	char *stringp;
 	struct minivm_template *etemplate;
 	char *messageformat;
@@ -1826,8 +1846,26 @@
 		res = sendmail(etemplate, vmu, cidnum, cidname, filename, messageformat, duration, etemplate->attachment, MVM_MESSAGE_PAGE, counter);
 	}
 
-	ast_manager_event(chan, EVENT_FLAG_CALL, "MiniVoiceMail", "Action: SentNotification\rn\nMailbox: %s@%s\r\nCounter: %s\r\n", vmu->username, vmu->domain, counter);
-
+	mwi_state = ast_mwi_create(vmu->username, vmu->domain);
+	if (!mwi_state) {
+		goto notify_cleanup;
+	}
+	mwi_state->snapshot = ast_channel_snapshot_get_latest(ast_channel_uniqueid(chan));
+
+	json_object = ast_json_pack("{s: s, s: s}",
+			"Event", "MiniVoiceMail"
+			"Action", "SentNotification",
+			"Counter", counter);
+	if (!json_object) {
+		goto notify_cleanup;
+	}
+	message = ast_mwi_blob_create(mwi_state, ast_mwi_vm_app_type(), json_object);
+	if (!message) {
+		goto notify_cleanup;
+	}
+	stasis_publish(ast_mwi_topic(mwi_state->uniqueid), message);
+
+notify_cleanup:
 	run_externnotify(chan, vmu);		/* Run external notification */
 
 	if (etemplate->locale) {
@@ -2011,7 +2049,7 @@
 
 /*!\internal
  * \brief Queue a message waiting event */
-static void queue_mwi_event(const char *mbx, const char *ctx, int urgent, int new, int old)
+static void queue_mwi_event(const char *channel_id, const char *mbx, const char *ctx, int urgent, int new, int old)
 {
 	char *mailbox, *context;
 
@@ -2021,7 +2059,7 @@
 		context = "default";
 	}
 
-	stasis_publish_mwi_state(mailbox, context, new + urgent, old);
+	ast_publish_mwi_state_channel(mailbox, context, new + urgent, old, channel_id);
 }
 
 /*!\internal
@@ -2056,7 +2094,7 @@
 		ast_log(LOG_ERROR, "Need mailbox at context as argument. Sorry. Argument 0 %s\n", argv[0]);
 		return -1;
 	}
-	queue_mwi_event(mailbox, domain, atoi(argv[1]), atoi(argv[2]), atoi(argv[3]));
+	queue_mwi_event(ast_channel_uniqueid(chan), mailbox, domain, atoi(argv[1]), atoi(argv[2]), atoi(argv[3]));
 
 	return res;
 }
@@ -2078,7 +2116,6 @@
 	const char *filename;
 	const char *format;
 	const char *duration_string;
-
 	if (ast_strlen_zero(data))  {
 		ast_log(LOG_ERROR, "Minivm needs at least an account argument \n");
 		return -1;

Modified: team/qwell/hold_events/apps/app_voicemail.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/hold_events/apps/app_voicemail.c?view=diff&rev=389739&r1=389738&r2=389739
==============================================================================
--- team/qwell/hold_events/apps/app_voicemail.c (original)
+++ team/qwell/hold_events/apps/app_voicemail.c Fri May 24 16:11:28 2013
@@ -7741,7 +7741,7 @@
 	return cmd;
 }
 
-static void queue_mwi_event(const char *box, int urgent, int new, int old)
+static void queue_mwi_event(const char *channel_id, const char *box, int urgent, int new, int old)
 {
 	char *mailbox, *context;
 
@@ -7752,7 +7752,7 @@
 		context = "default";
 	}
 
-	stasis_publish_mwi_state(mailbox, context, new + urgent, old);
+	ast_publish_mwi_state_channel(mailbox, context, new + urgent, old, channel_id);
 }
 
 /*!
@@ -7842,32 +7842,7 @@
 	if (ast_app_has_voicemail(ext_context, NULL)) 
 		ast_app_inboxcount2(ext_context, &urgentmsgs, &newmsgs, &oldmsgs);
 
-	queue_mwi_event(ext_context, urgentmsgs, newmsgs, oldmsgs);
-
-	/*** DOCUMENTATION
-		<managerEventInstance>
-			<synopsis>Raised when a new message has been left in a voicemail mailbox.</synopsis>
-			<syntax>
-				<parameter name="Mailbox">
-					<para>The mailbox with the new message, specified as <emphasis>mailbox</emphasis>@<emphasis>context</emphasis></para>
-				</parameter>
-				<parameter name="Waiting">
-					<para>Whether or not the mailbox has access to a voicemail application.</para>
-				</parameter>
-				<parameter name="New">
-					<para>The number of new messages.</para>
-				</parameter>
-				<parameter name="Old">
-					<para>The number of old messages.</para>
-				</parameter>
-			</syntax>
-		</managerEventInstance>
-	***/
-	ast_manager_event(chan, EVENT_FLAG_CALL, "MessageWaiting",
-			"Mailbox: %s@%s\r\n"
-			"Waiting: %d\r\n"
-			"New: %d\r\n"
-			"Old: %d\r\n", vmu->mailbox, vmu->context, ast_app_has_voicemail(ext_context, NULL), newmsgs, oldmsgs);
+	queue_mwi_event(ast_channel_uniqueid(chan), ext_context, urgentmsgs, newmsgs, oldmsgs);
 	run_externnotify(vmu->context, vmu->mailbox, flag);
 
 #ifdef IMAP_STORAGE
@@ -11538,16 +11513,10 @@
 	if (valid) {
 		int new = 0, old = 0, urgent = 0;
 		snprintf(ext_context, sizeof(ext_context), "%s@%s", vms.username, vmu->context);
-		/*** DOCUMENTATION
-			<managerEventInstance>
-				<synopsis>Raised when a user has finished listening to their messages.</synopsis>
-			</managerEventInstance>
-		***/
-		ast_manager_event(chan, EVENT_FLAG_CALL, "MessageWaiting", "Mailbox: %s\r\nWaiting: %d\r\n", ext_context, has_voicemail(ext_context, NULL));
 		/* Urgent flag not passwd to externnotify here */
 		run_externnotify(vmu->context, vmu->mailbox, NULL);
 		ast_app_inboxcount2(ext_context, &urgent, &new, &old);
-		queue_mwi_event(ext_context, urgent, new, old);
+		queue_mwi_event(ast_channel_uniqueid(chan), ext_context, urgent, new, old);
 	}
 #ifdef IMAP_STORAGE
 	/* expunge message - use UID Expunge if supported on IMAP server*/
@@ -11766,7 +11735,7 @@
 	strcat(mailbox_full, context);
 
 	inboxcount2(mailbox_full, &urgent, &new, &old);
-	queue_mwi_event(mailbox_full, urgent, new, old);
+	queue_mwi_event(NULL, mailbox_full, urgent, new, old);
 
 	return 0;
 }
@@ -12502,7 +12471,7 @@
 		mwi_sub->old_urgent = urgent;
 		mwi_sub->old_new = new;
 		mwi_sub->old_old = old;
-		queue_mwi_event(mwi_sub->mailbox, urgent, new, old);
+		queue_mwi_event(NULL, mwi_sub->mailbox, urgent, new, old);
 		run_externnotify(NULL, mwi_sub->mailbox, NULL);
 	}
 }
@@ -12647,7 +12616,7 @@
 	}
 
 	change = stasis_message_data(msg);
-	if (change->topic == stasis_mwi_topic_all()) {
+	if (change->topic == ast_mwi_topic_all()) {
 		return;
 	}
 
@@ -12668,10 +12637,10 @@
 static void start_poll_thread(void)
 {
 	int errcode;
-	mwi_sub_sub = stasis_subscribe(stasis_mwi_topic_all(), mwi_event_cb, NULL);
+	mwi_sub_sub = stasis_subscribe(ast_mwi_topic_all(), mwi_event_cb, NULL);
 
 	if (mwi_sub_sub) {
-		struct ao2_container *cached = stasis_cache_dump(stasis_mwi_topic_cached(), stasis_subscription_change_type());
+		struct ao2_container *cached = stasis_cache_dump(ast_mwi_topic_cached(), stasis_subscription_change_type());
 		if (cached) {
 			ao2_callback(cached, OBJ_MULTIPLE | OBJ_NODATA, dump_cache, NULL);
 		}
@@ -15263,7 +15232,7 @@
 	snprintf(ext_context, sizeof(ext_context), "%s@%s", vmu->mailbox, vmu->context);
 	run_externnotify(vmu->context, vmu->mailbox, NULL);
 	ast_app_inboxcount2(ext_context, &urgent, &new, &old);
-	queue_mwi_event(ext_context, urgent, new, old);
+	queue_mwi_event(NULL, ext_context, urgent, new, old);
 }
 
 static int vm_msg_forward(const char *from_mailbox,

Modified: team/qwell/hold_events/channels/chan_dahdi.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/hold_events/channels/chan_dahdi.c?view=diff&rev=389739&r1=389738&r2=389739
==============================================================================
--- team/qwell/hold_events/channels/chan_dahdi.c (original)
+++ team/qwell/hold_events/channels/chan_dahdi.c Fri May 24 16:11:28 2013
@@ -3762,7 +3762,7 @@
 	if (ast_strlen_zero(context))
 		context = "default";
 
-	stasis_publish_mwi_state(mailbox, context, thereornot, thereornot);
+	ast_publish_mwi_state(mailbox, context, thereornot, thereornot);
 
 	if (!ast_strlen_zero(mailbox) && !ast_strlen_zero(mwimonitornotify)) {
 		snprintf(s, sizeof(s), "%s %s %d", mwimonitornotify, mailbox, thereornot);
@@ -5427,10 +5427,10 @@
 	}
 
 	ast_str_set(&uniqueid, 0, "%s@%s", mailbox, context);
-	mwi_message = stasis_cache_get(stasis_mwi_topic_cached(), stasis_mwi_state_type(), ast_str_buffer(uniqueid));
+	mwi_message = stasis_cache_get(ast_mwi_topic_cached(), ast_mwi_state_type(), ast_str_buffer(uniqueid));
 
 	if (mwi_message) {
-		struct stasis_mwi_state *mwi_state = stasis_message_data(mwi_message);
+		struct ast_mwi_state *mwi_state = stasis_message_data(mwi_message);
 		new_msgs = mwi_state->new_msgs;
 	} else {
 		new_msgs = ast_app_has_voicemail(p->mailbox, NULL);
@@ -13228,7 +13228,7 @@
 
 			ast_str_set(&uniqueid, 0, "%s@%s", mailbox, context);
 
-			mailbox_specific_topic = stasis_mwi_topic(ast_str_buffer(uniqueid));
+			mailbox_specific_topic = ast_mwi_topic(ast_str_buffer(uniqueid));
 			if (mailbox_specific_topic) {
 				tmp->mwi_event_sub = stasis_subscribe(mailbox_specific_topic, mwi_event_cb, NULL);
 			}

Modified: team/qwell/hold_events/channels/chan_iax2.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/hold_events/channels/chan_iax2.c?view=diff&rev=389739&r1=389738&r2=389739
==============================================================================
--- team/qwell/hold_events/channels/chan_iax2.c (original)
+++ team/qwell/hold_events/channels/chan_iax2.c Fri May 24 16:11:28 2013
@@ -8794,10 +8794,10 @@
 			}
 
 			ast_str_set(&uniqueid, 0, "%s@%s", mailbox, context);
-			msg = stasis_cache_get(stasis_mwi_topic_cached(), stasis_mwi_state_type(), ast_str_buffer(uniqueid));
+			msg = stasis_cache_get(ast_mwi_topic_cached(), ast_mwi_state_type(), ast_str_buffer(uniqueid));
 
 			if (msg) {
-				struct stasis_mwi_state *mwi_state = stasis_message_data(msg);
+				struct ast_mwi_state *mwi_state = stasis_message_data(msg);
 				new = mwi_state->new_msgs;
 				old = mwi_state->old_msgs;
 			} else { /* Fall back on checking the mailbox directly */
@@ -12556,7 +12556,7 @@
 
 		ast_str_set(&uniqueid, 0, "%s@%s", mailbox, context);
 
-		mailbox_specific_topic = stasis_mwi_topic(ast_str_buffer(uniqueid));
+		mailbox_specific_topic = ast_mwi_topic(ast_str_buffer(uniqueid));
 		if (mailbox_specific_topic) {
 			peer->mwi_event_sub = stasis_subscribe(mailbox_specific_topic, mwi_event_cb, NULL);
 		}

Modified: team/qwell/hold_events/channels/chan_mgcp.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/hold_events/channels/chan_mgcp.c?view=diff&rev=389739&r1=389738&r2=389739
==============================================================================
--- team/qwell/hold_events/channels/chan_mgcp.c (original)
+++ team/qwell/hold_events/channels/chan_mgcp.c Fri May 24 16:11:28 2013
@@ -507,10 +507,10 @@
 
 	ast_str_set(&uniqueid, 0, "%s@%s", mbox, cntx);
 
-	msg = stasis_cache_get(stasis_mwi_topic_cached(), stasis_mwi_state_type(), ast_str_buffer(uniqueid));
+	msg = stasis_cache_get(ast_mwi_topic_cached(), ast_mwi_state_type(), ast_str_buffer(uniqueid));
 
 	if (msg) {
-		struct stasis_mwi_state *mwi_state = stasis_message_data(msg);
+		struct ast_mwi_state *mwi_state = stasis_message_data(msg);
 		new_msgs = mwi_state->new_msgs;
 	} else {
 		new_msgs = ast_app_has_voicemail(p->mailbox, NULL);
@@ -4170,7 +4170,7 @@
 					ast_str_reset(uniqueid);
 					ast_str_set(&uniqueid, 0, "%s@%s", mbox, cntx);
 
-					mailbox_specific_topic = stasis_mwi_topic(ast_str_buffer(uniqueid));
+					mailbox_specific_topic = ast_mwi_topic(ast_str_buffer(uniqueid));
 					if (mailbox_specific_topic) {
 						e->mwi_event_sub = stasis_subscribe(mailbox_specific_topic, mwi_event_cb, NULL);
 					}

Modified: team/qwell/hold_events/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/hold_events/channels/chan_sip.c?view=diff&rev=389739&r1=389738&r2=389739
==============================================================================
--- team/qwell/hold_events/channels/chan_sip.c (original)
+++ team/qwell/hold_events/channels/chan_sip.c Fri May 24 16:11:28 2013
@@ -16715,7 +16715,7 @@
 		ao2_cleanup(peer);
 		return;
 	}
-	if (stasis_mwi_state_type() == stasis_message_type(msg)) {
+	if (ast_mwi_state_type() == stasis_message_type(msg)) {
 		sip_send_mwi_to_peer(peer, 0);
 	}
 }
@@ -24758,7 +24758,7 @@
 			char *old = strsep(&c, " ");
 			char *new = strsep(&old, "/");
 
-			stasis_publish_mwi_state(mailbox, "SIP_Remote", atoi(new), atoi(old));
+			ast_publish_mwi_state(mailbox, "SIP_Remote", atoi(new), atoi(old));
 
 			transmit_response(p, "200 OK", req);
 		} else {
@@ -27411,7 +27411,7 @@
 		ast_str_reset(uniqueid);
 		ast_str_set(&uniqueid, 0, "%s@%s", mailbox->mailbox, S_OR(mailbox->context, "default"));
 
-		mailbox_specific_topic = stasis_mwi_topic(ast_str_buffer(uniqueid));
+		mailbox_specific_topic = ast_mwi_topic(ast_str_buffer(uniqueid));
 		if (mailbox_specific_topic) {
 			ao2_ref(peer, +1);
 			mailbox->event_sub = stasis_subscribe(mailbox_specific_topic, mwi_event_cb, peer);
@@ -28621,12 +28621,12 @@
 	in_cache = 0;
 	AST_LIST_TRAVERSE(&peer->mailboxes, mailbox, entry) {
 		RAII_VAR(struct stasis_message *, msg, NULL, ao2_cleanup);
-		struct stasis_mwi_state *mwi_state;
+		struct ast_mwi_state *mwi_state;
 
 		ast_str_reset(uniqueid);
 		ast_str_set(&uniqueid, 0, "%s@%s", mailbox->mailbox, S_OR(mailbox->context, "default"));
 
-		msg = stasis_cache_get(stasis_mwi_topic_cached(), stasis_mwi_state_type(), ast_str_buffer(uniqueid));
+		msg = stasis_cache_get(ast_mwi_topic_cached(), ast_mwi_state_type(), ast_str_buffer(uniqueid));
 		if (!msg) {
 			continue;
 		}

Modified: team/qwell/hold_events/channels/chan_skinny.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/hold_events/channels/chan_skinny.c?view=diff&rev=389739&r1=389738&r2=389739
==============================================================================
--- team/qwell/hold_events/channels/chan_skinny.c (original)
+++ team/qwell/hold_events/channels/chan_skinny.c Fri May 24 16:11:28 2013
@@ -3535,8 +3535,8 @@
 		return;
 	}
 
-	if (msg && stasis_mwi_state_type() == stasis_message_type(msg)) {
-		struct stasis_mwi_state *mwi_state = stasis_message_data(msg);
+	if (msg && ast_mwi_state_type() == stasis_message_type(msg)) {
+		struct ast_mwi_state *mwi_state = stasis_message_data(msg);
 		l->newmsgs = mwi_state->new_msgs;
 	}
 
@@ -8210,7 +8210,7 @@
 
 		ast_str_set(&uniqueid, 0, "%s@%s", cfg_mailbox, cfg_context);
 
-		mailbox_specific_topic = stasis_mwi_topic(ast_str_buffer(uniqueid));
+		mailbox_specific_topic = ast_mwi_topic(ast_str_buffer(uniqueid));
 		if (mailbox_specific_topic) {
 			l->mwi_event_sub = stasis_subscribe(mailbox_specific_topic, mwi_event_cb, l);
 		}

Modified: team/qwell/hold_events/channels/chan_unistim.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/hold_events/channels/chan_unistim.c?view=diff&rev=389739&r1=389738&r2=389739
==============================================================================
--- team/qwell/hold_events/channels/chan_unistim.c (original)
+++ team/qwell/hold_events/channels/chan_unistim.c Fri May 24 16:11:28 2013
@@ -5507,10 +5507,10 @@
 
 	ast_str_set(&uniqueid, 0, "%s@%s", mailbox, context);
 
-	msg = stasis_cache_get(stasis_mwi_topic_cached(), stasis_mwi_state_type(), ast_str_buffer(uniqueid));
+	msg = stasis_cache_get(ast_mwi_topic_cached(), ast_mwi_state_type(), ast_str_buffer(uniqueid));
 
 	if (msg) {
-		struct stasis_mwi_state *mwi_state = stasis_message_data(msg);
+		struct ast_mwi_state *mwi_state = stasis_message_data(msg);
 		new = mwi_state->new_msgs;
 	} else { /* Fall back on checking the mailbox directly */
 		new = ast_app_has_voicemail(peer->mailbox, "INBOX");

Modified: team/qwell/hold_events/channels/sig_pri.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/hold_events/channels/sig_pri.c?view=diff&rev=389739&r1=389738&r2=389739
==============================================================================
--- team/qwell/hold_events/channels/sig_pri.c (original)
+++ team/qwell/hold_events/channels/sig_pri.c Fri May 24 16:11:28 2013
@@ -8769,9 +8769,9 @@
 	const char *mbox_number;
 	int num_messages;
 	int idx;
-	struct stasis_mwi_state *mwi_state;
-
-	if (stasis_mwi_state_type() != stasis_message_type(msg)) {
+	struct ast_mwi_state *mwi_state;
+
+	if (ast_mwi_state_type() != stasis_message_type(msg)) {
 		return;
 	}
 
@@ -8817,7 +8817,7 @@
 {
 	int idx;
 	struct ast_str *uniqueid = ast_str_alloca(AST_MAX_MAILBOX_UNIQUEID);
-	struct stasis_mwi_state *mwi_state;
+	struct ast_mwi_state *mwi_state;
 
 	for (idx = 0; idx < ARRAY_LEN(pri->mbox); ++idx) {
 		RAII_VAR(struct stasis_message *, msg, NULL, ao2_cleanup);
@@ -8829,7 +8829,7 @@
 		ast_str_reset(uniqueid);
 		ast_str_set(&uniqueid, 0, "%s@%s", pri->mbox[idx].number, pri->mbox[idx].context);
 
-		msg = stasis_cache_get(stasis_mwi_topic_cached(), stasis_mwi_state_type(), ast_str_buffer(uniqueid));
+		msg = stasis_cache_get(ast_mwi_topic_cached(), ast_mwi_state_type(), ast_str_buffer(uniqueid));
 		if (!msg) {
 			/* No cached event for this mailbox. */
 			continue;
@@ -9003,7 +9003,7 @@
 		ast_str_set(&mwi_description, -1, "%s span %d[%d] MWI mailbox %s@%s",
 			sig_pri_cc_type_name, pri->span, i, mbox_number, mbox_context);
 
-		mailbox_specific_topic = stasis_mwi_topic(ast_str_buffer(uniqueid));
+		mailbox_specific_topic = ast_mwi_topic(ast_str_buffer(uniqueid));
 		if (mailbox_specific_topic) {
 			pri->mbox[i].sub = stasis_subscribe(mailbox_specific_topic, sig_pri_mwi_event_cb, pri);
 		}

Modified: team/qwell/hold_events/include/asterisk/_private.h
URL: http://svnview.digium.com/svn/asterisk/team/qwell/hold_events/include/asterisk/_private.h?view=diff&rev=389739&r1=389738&r2=389739
==============================================================================
--- team/qwell/hold_events/include/asterisk/_private.h (original)
+++ team/qwell/hold_events/include/asterisk/_private.h Fri May 24 16:11:28 2013
@@ -52,6 +52,20 @@
 int aco_init(void);             /*!< Provided by config_options.c */
 
 /*!
+ * \since 12
+ * \brief Possible return types for \ref ast_module_reload
+ */
+enum ast_module_reload_result {
+	AST_MODULE_RELOAD_SUCCESS = 0,      /*!< The module was reloaded succesfully */
+	AST_MODULE_RELOAD_QUEUED,           /*!< The module reload request was queued */
+	AST_MODULE_RELOAD_NOT_FOUND,        /*!< The requested module was not found */
+	AST_MODULE_RELOAD_ERROR,            /*!< An error occurred while reloading the module */
+	AST_MODULE_RELOAD_IN_PROGRESS,      /*!< A module reload request is already in progress */
+	AST_MODULE_RELOAD_UNINITIALIZED,    /*!< The module has not been initialized */
+	AST_MODULE_RELOAD_NOT_IMPLEMENTED,  /*!< This module doesn't support reloading */
+};
+
+/*!
  * \brief Initialize the bridging system.
  * \since 12.0.0
  *
@@ -78,13 +92,10 @@
  *
  * \note Modules are reloaded using their reload() functions, not unloading
  * them and loading them again.
- * 
- * \return 0 if the specified module was not found.
- * \retval 1 if the module was found but cannot be reloaded.
- * \retval -1 if a reload operation is already in progress.
- * \retval 2 if the specfied module was found and reloaded.
+ *
+ * \retval The \ref ast_module_reload_result status of the module load request
  */
-int ast_module_reload(const char *name);
+enum ast_module_reload_result ast_module_reload(const char *name);
 
 /*!
  * \brief Process reload requests received during startup.

Modified: team/qwell/hold_events/include/asterisk/app.h
URL: http://svnview.digium.com/svn/asterisk/team/qwell/hold_events/include/asterisk/app.h?view=diff&rev=389739&r1=389738&r2=389739
==============================================================================
--- team/qwell/hold_events/include/asterisk/app.h (original)
+++ team/qwell/hold_events/include/asterisk/app.h Fri May 24 16:11:28 2013
@@ -1104,8 +1104,8 @@
 int ast_app_parse_timelen(const char *timestr, int *result, enum ast_timelen defunit);
 
 /*!
+ * \since 12
  * \brief Publish a MWI state update via stasis
- * \param[in] uniqueid A unique identifier for this mailbox (usually mailbox at context)
  * \param[in] mailbox The number identifying this mailbox
  * \param[in] context The context this mailbox resides in
  * \param[in] new_msgs The number of new messages in this mailbox
@@ -1114,26 +1114,44 @@
  * \retval -1 Failure
  * \since 12
  */
-#define stasis_publish_mwi_state(mailbox, context, new_msgs, old_msgs) \
-	stasis_publish_mwi_state_full(mailbox, context, new_msgs, old_msgs, NULL)
-
-/*!
- * \brief Publish a MWI state update via stasis with EID
- * \param[in] uniqueid A unique identifier for this mailbox (usually mailbox at context)
+#define ast_publish_mwi_state(mailbox, context, new_msgs, old_msgs) \
+	ast_publish_mwi_state_full(mailbox, context, new_msgs, old_msgs, NULL, NULL)
+
+/*!
+ * \since 12
+ * \brief Publish a MWI state update associated with some channel
  * \param[in] mailbox The number identifying this mailbox
  * \param[in] context The context this mailbox resides in
  * \param[in] new_msgs The number of new messages in this mailbox
  * \param[in] old_msgs The number of old messages in this mailbox
+ * \param[in] channel_id A unique identifier for a channel associated with this
+ * change in mailbox state
+ * \retval 0 Success
+ * \retval -1 Failure
+ * \since 12
+ */
+#define ast_publish_mwi_state_channel(mailbox, context, new_msgs, old_msgs, channel_id) \
+	ast_publish_mwi_state_full(mailbox, context, new_msgs, old_msgs, channel_id, NULL)
+
+/*!
+ * \since 12
+ * \brief Publish a MWI state update via stasis with all parameters
+ * \param[in] mailbox The number identifying this mailbox
+ * \param[in] context The context this mailbox resides in
+ * \param[in] new_msgs The number of new messages in this mailbox
+ * \param[in] old_msgs The number of old messages in this mailbox
+ * \param[in] channel_id A unique identifier for a channel associated with this
  * \param[in] eid The EID of the server that originally published the message
  * \retval 0 Success
  * \retval -1 Failure
  * \since 12
  */
-int stasis_publish_mwi_state_full(
+int ast_publish_mwi_state_full(
 			const char *mailbox,
 			const char *context,
 			int new_msgs,
 			int old_msgs,
+			const char *channel_id,
 			struct ast_eid *eid);
 
 /*! \addtogroup StasisTopicsAndMessages
@@ -1144,49 +1162,103 @@
  * \brief The structure that contains MWI state
  * \since 12
  */
-struct stasis_mwi_state {
+struct ast_mwi_state {
 	AST_DECLARE_STRING_FIELDS(
-		AST_STRING_FIELD(uniqueid);	/*!< Unique identifier for this mailbox/context */
-		AST_STRING_FIELD(mailbox);	/*!< Mailbox for this event */
-		AST_STRING_FIELD(context);	/*!< Context that this mailbox belongs to */
+		AST_STRING_FIELD(uniqueid);  /*!< Unique identifier for this mailbox/context */
+		AST_STRING_FIELD(mailbox);   /*!< Mailbox for this event */
+		AST_STRING_FIELD(context);   /*!< Context that this mailbox belongs to */
 	);
-	int new_msgs;				/*!< The current number of new messages for this mailbox */
-	int old_msgs;				/*!< The current number of old messages for this mailbox */
-	struct ast_eid eid;			/*!< The EID of the server where this message originated */
-};
-
-/*!
- * \brief Get the Stasis topic for MWI messages
+	int new_msgs;                    /*!< The current number of new messages for this mailbox */
+	int old_msgs;                    /*!< The current number of old messages for this mailbox */
+	/*! If applicable, a snapshot of the channel that caused this MWI change */
+	struct ast_channel_snapshot *snapshot;
+	struct ast_eid eid;              /*!< The EID of the server where this message originated */
+};
+
+/*!
+ * \brief Object that represents an MWI update with some additional application
+ * defined data
+ */
+struct ast_mwi_blob {
+	struct ast_mwi_state *mwi_state;    /*!< MWI state */
+	struct ast_json *blob;              /*!< JSON blob of data */
+};
+
+/*!
+ * \since 12
+ * \brief Create a \ref ast_mwi_state object
+ *
+ * \retval \ref ast_mwi_state object on success
+ * \retval NULL on error
+ */
+struct ast_mwi_state *ast_mwi_create(const char *mailbox, const char *context);
+
+/*!
+ * \since 12
+ * \brief Creates a \ref ast_mwi_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 mwi_state MWI state associated with the update
+ * \param message_type The type of message to create
+ * \param blob JSON object representing the data.
+ * \return \ref ast_mwi_blob message.
+ * \return \c NULL on error
+ */

[... 3515 lines stripped ...]



More information about the asterisk-commits mailing list