[asterisk-commits] dlee: branch dlee/ASTERISK-21096 r383397 - /team/dlee/ASTERISK-21096/main/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Mar 19 16:30:54 CDT 2013


Author: dlee
Date: Tue Mar 19 16:30:51 2013
New Revision: 383397

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=383397
Log:
Only post Cause on Hangup events

Modified:
    team/dlee/ASTERISK-21096/main/manager_channels.c

Modified: team/dlee/ASTERISK-21096/main/manager_channels.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ASTERISK-21096/main/manager_channels.c?view=diff&rev=383397&r1=383396&r2=383397
==============================================================================
--- team/dlee/ASTERISK-21096/main/manager_channels.c (original)
+++ team/dlee/ASTERISK-21096/main/manager_channels.c Tue Mar 19 16:30:51 2013
@@ -81,12 +81,6 @@
 				</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>
@@ -103,6 +97,12 @@
 			<synopsis>Raised when a channel is hung up.</synopsis>
 			<syntax>
 				<xi:include xpointer="xpointer(/docs/managerEvent[@name='Newchannel']/managerEventInstance/syntax/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>
@@ -156,9 +156,7 @@
 		"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",
+		"Uniqueid: %s\r\n",
 		snapshot->name,
 		snapshot->state,
 		ast_state2str(snapshot->state),
@@ -170,9 +168,7 @@
 		snapshot->context,
 		snapshot->exten,
 		snapshot->priority,
-		snapshot->uniqueid,
-		snapshot->hangupcause,
-		ast_cause2str(snapshot->hangupcause));
+		snapshot->uniqueid);
 
 	if (!res) {
 		return NULL;
@@ -273,6 +269,7 @@
 				    struct stasis_topic *topic,
 				    struct stasis_message *message)
 {
+	RAII_VAR(struct ast_str *, extra_fields, NULL, ast_free);
 	struct stasis_cache_update *update = stasis_message_data(message);
 	struct ast_channel_snapshot *old_snapshot;
 	struct ast_channel_snapshot *new_snapshot;
@@ -283,6 +280,11 @@
 		return;
 	}
 
+	extra_fields = ast_str_create(20);
+	if (!extra_fields) {
+		return;
+	}
+
 	old_snapshot = stasis_message_data(update->old_snapshot);
 	new_snapshot = stasis_message_data(update->new_snapshot);
 
@@ -304,6 +306,11 @@
 
 	if (!was_hungup && is_hungup) {
 		manager_event = "Hangup";
+		ast_str_append(&extra_fields, 0,
+			       "Cause: %d\r\n"
+			       "Cause-txt: %s\r\n",
+			       new_snapshot->hangupcause,
+			       ast_cause2str(new_snapshot->hangupcause));
 	}
 
 	/* Channel state change events */
@@ -314,8 +321,9 @@
 			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));
+			manager_event(EVENT_FLAG_CALL, manager_event, "%s%s",
+				      ast_str_buffer(channel_event_string),
+				      ast_str_buffer(extra_fields));
 		}
 	}
 




More information about the asterisk-commits mailing list