[asterisk-commits] file: branch 11 r377462 - /branches/11/channels/chan_motif.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sat Dec 8 19:23:02 CST 2012


Author: file
Date: Sat Dec  8 19:22:56 2012
New Revision: 377462

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=377462
Log:
Add missing support for "who hung up" to chan_motif.

(closes issue ASTERISK-20671)
Reported by: Matt Jordan
Review: https://reviewboard.asterisk.org/r/2208/

Modified:
    branches/11/channels/chan_motif.c

Modified: branches/11/channels/chan_motif.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/channels/chan_motif.c?view=diff&rev=377462&r1=377461&r2=377462
==============================================================================
--- branches/11/channels/chan_motif.c (original)
+++ branches/11/channels/chan_motif.c Sat Dec  8 19:22:56 2012
@@ -2352,6 +2352,8 @@
 	struct ast_channel *chan;
 	iks *reason, *text;
 	int cause = AST_CAUSE_NORMAL;
+	struct ast_control_pvt_cause_code *cause_code;
+	int data_size = sizeof(*cause_code);
 
 	if (!session) {
 		jingle_send_error_response(endpoint->connection, pak, "cancel", "item-not-found xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'",
@@ -2368,6 +2370,10 @@
 	/* Pull the reason text from the session-terminate message and translate it into a cause code */
 	if ((reason = iks_find(pak->query, "reason")) && (text = iks_child(reason))) {
 		int i;
+
+		/* Size of the string making up the cause code is "Motif " + text */
+		data_size += 6 + strlen(iks_name(text));
+		cause_code = ast_malloc(data_size);
 
 		/* Get the appropriate cause code mapping for this reason */
 		for (i = 0; i < ARRAY_LEN(jingle_reason_mappings); i++) {
@@ -2376,7 +2382,20 @@
 				break;
 			}
 		}
-	}
+
+		/* Store the technology specific information */
+		snprintf(cause_code->code, data_size - sizeof(*cause_code) + 1, "Motif %s", iks_name(text));
+	} else {
+		/* No technology specific information is available */
+		cause_code = ast_malloc(data_size);
+	}
+
+	ast_copy_string(cause_code->chan_name, ast_channel_name(chan), AST_CHANNEL_NAME);
+	cause_code->ast_cause = cause;
+	ast_queue_control_data(chan, AST_CONTROL_PVT_CAUSE_CODE, cause_code, data_size);
+	ast_channel_hangupcause_hash_set(chan, cause_code, data_size);
+
+	ast_free(cause_code);
 
 	ast_debug(3, "Hanging up channel '%s' due to session terminate message with cause '%d'\n", ast_channel_name(chan), cause);
 	ast_queue_hangup_with_cause(chan, cause);




More information about the asterisk-commits mailing list