[asterisk-commits] dlee: branch dlee/ASTERISK-21096 r383333 - in /team/dlee/ASTERISK-21096: incl...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Mar 18 16:13:23 CDT 2013


Author: dlee
Date: Mon Mar 18 16:13:19 2013
New Revision: 383333

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=383333
Log:
Changed NewCallerid to Stasis

Modified:
    team/dlee/ASTERISK-21096/include/asterisk/channel.h
    team/dlee/ASTERISK-21096/main/channel.c
    team/dlee/ASTERISK-21096/main/manager.c
    team/dlee/ASTERISK-21096/main/manager_channels.c

Modified: team/dlee/ASTERISK-21096/include/asterisk/channel.h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ASTERISK-21096/include/asterisk/channel.h?view=diff&rev=383333&r1=383332&r2=383333
==============================================================================
--- team/dlee/ASTERISK-21096/include/asterisk/channel.h (original)
+++ team/dlee/ASTERISK-21096/include/asterisk/channel.h Mon Mar 18 16:13:19 2013
@@ -4136,6 +4136,8 @@
 	int priority;			/*!< Dialplan: Current extension priority */
 	int amaflags;			/*!< AMA flags for billing */
 	int hangupcause;		/*!< Why is the channel hanged up. See causes.h */
+	int caller_pres;		/*!< Caller ID presentation. */
+
 	struct ast_flags flags;		/*!< channel flags of AST_FLAG_ type */
 };
 

Modified: team/dlee/ASTERISK-21096/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ASTERISK-21096/main/channel.c?view=diff&rev=383333&r1=383332&r2=383333
==============================================================================
--- team/dlee/ASTERISK-21096/main/channel.c (original)
+++ team/dlee/ASTERISK-21096/main/channel.c Mon Mar 18 16:13:19 2013
@@ -6837,39 +6837,6 @@
 }
 
 /*!
- * \pre chan is locked
- */
-static void report_new_callerid(struct ast_channel *chan)
-{
-	int pres;
-
-	pres = ast_party_id_presentation(&ast_channel_caller(chan)->id);
-	/*** DOCUMENTATION
-		<managerEventInstance>
-			<synopsis>Raised when a channel receives new Caller ID information.</synopsis>
-			<syntax>
-				<parameter name="CID-CallingPres">
-					<para>A description of the Caller ID presentation.</para>
-				</parameter>
-			</syntax>
-		</managerEventInstance>
-	***/
-	ast_manager_event(chan, EVENT_FLAG_CALL, "NewCallerid",
-		"Channel: %s\r\n"
-		"CallerIDNum: %s\r\n"
-		"CallerIDName: %s\r\n"
-		"Uniqueid: %s\r\n"
-		"CID-CallingPres: %d (%s)\r\n",
-		ast_channel_name(chan),
-		S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, ""),
-		S_COR(ast_channel_caller(chan)->id.name.valid, ast_channel_caller(chan)->id.name.str, ""),
-		ast_channel_uniqueid(chan),
-		pres,
-		ast_describe_caller_presentation(pres)
-		);
-}
-
-/*!
  * \internal
  * \brief Transfer COLP between target and transferee channels.
  * \since 1.8
@@ -7273,7 +7240,7 @@
 	ast_channel_redirecting_set(original, ast_channel_redirecting(clonechan));
 	ast_channel_redirecting_set(clonechan, &exchange.redirecting);
 
-	report_new_callerid(original);
+	publish_channel_state(original);
 
 	/* Restore original timing file descriptor */
 	ast_channel_set_fd(original, AST_TIMING_FD, ast_channel_timingfd(original));
@@ -7439,7 +7406,7 @@
 		ast_cdr_setcid(ast_channel_cdr(chan), chan);
 	}
 
-	report_new_callerid(chan);
+	publish_channel_state(chan);
 
 	ast_channel_unlock(chan);
 }
@@ -7471,13 +7438,7 @@
 		S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL);
 	pre_set_name = S_COR(ast_channel_caller(chan)->id.name.valid, ast_channel_caller(chan)->id.name.str, NULL);
 	ast_party_caller_set(ast_channel_caller(chan), caller, update);
-	if (S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL)
-			!= pre_set_number
-		|| S_COR(ast_channel_caller(chan)->id.name.valid, ast_channel_caller(chan)->id.name.str, NULL)
-			!= pre_set_name) {
-		/* The caller id name or number changed. */
-		report_new_callerid(chan);
-	}
+	publish_channel_state(chan);
 	if (ast_channel_cdr(chan)) {
 		ast_cdr_setcid(ast_channel_cdr(chan), chan);
 	}
@@ -11342,6 +11303,7 @@
 	snapshot->amaflags = ast_channel_amaflags(chan);
 	snapshot->hangupcause = ast_channel_hangupcause(chan);
 	snapshot->flags = *ast_channel_flags(chan);
+	snapshot->caller_pres = ast_party_id_presentation(&ast_channel_caller(chan)->id);
 
 	ao2_ref(snapshot, +1);
 	return snapshot;

Modified: team/dlee/ASTERISK-21096/main/manager.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ASTERISK-21096/main/manager.c?view=diff&rev=383333&r1=383332&r2=383333
==============================================================================
--- team/dlee/ASTERISK-21096/main/manager.c (original)
+++ team/dlee/ASTERISK-21096/main/manager.c Mon Mar 18 16:13:19 2013
@@ -5700,7 +5700,7 @@
 		return -1;
 	}
 
-	cat_str = authority_to_str(category, &auth);
+	cat_str = authority_to_str (category, &auth);
 	ast_str_set(&buf, 0,
 			"Event: %s\r\nPrivilege: %s\r\n",
 			 event, cat_str);

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=383333&r1=383332&r2=383333
==============================================================================
--- team/dlee/ASTERISK-21096/main/manager_channels.c (original)
+++ team/dlee/ASTERISK-21096/main/manager_channels.c Mon Mar 18 16:13:19 2013
@@ -30,6 +30,7 @@
 
 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 
+#include "asterisk/callerid.h"
 #include "asterisk/channel.h"
 #include "asterisk/manager.h"
 #include "asterisk/stasis_message_router.h"
@@ -208,6 +209,40 @@
 		      snapshot->exten, snapshot->appl, snapshot->data);
 }
 
+static void channel_newcallerid(struct ast_channel_snapshot *snapshot)
+{
+	RAII_VAR(struct ast_str *, channel_event_string, NULL, ast_free);
+
+	/*** DOCUMENTATION
+		<managerEventInstance>
+			<synopsis>Raised when a channel receives new Caller ID information.</synopsis>
+			<syntax>
+				<xi:include xpointer="xpointer(/docs/managerEvent[@name='Newchannel']/managerEventInstance/syntax/parameter)" />
+				<parameter name="CID-CallingPres">
+					<para>A description of the Caller ID presentation.</para>
+				</parameter>
+			</syntax>
+		</managerEventInstance>
+	***/
+
+	channel_event_string = manager_build_channel_state_string(snapshot);
+
+	if (!channel_event_string) {
+		return;
+	}
+
+	/* XXX manager.c channelvars should be appeneded to this event
+	 * i.e. ChanVariable(SIP/blink-00000000): foo=bar
+	 */
+	manager_event(EVENT_FLAG_CALL, "NewCallerid",
+		      "%s"
+		      "CID-CallingPres: %d (%s)\r\n",
+		      ast_str_buffer(channel_event_string),
+		      snapshot->caller_pres,
+		      ast_describe_caller_presentation(snapshot->caller_pres));
+
+}
+
 static void channel_snapshot_update(void *data, struct stasis_subscription *sub,
 				    struct stasis_topic *topic,
 				    struct stasis_message *message)
@@ -269,6 +304,14 @@
 			    strcmp(old_snapshot->exten, new_snapshot->exten) != 0))) {
 		channel_newexten(new_snapshot);
 	}
+
+	/* Detect NewCallerid */
+	if (old_snapshot && (
+		    strcmp(old_snapshot->caller_number, new_snapshot->caller_number) != 0 ||
+		    strcmp(old_snapshot->caller_name, new_snapshot->caller_number) != 0)) {
+		channel_newcallerid(new_snapshot);
+	}
+
 }
 
 static void channel_varset(struct ast_channel_blob *obj)




More information about the asterisk-commits mailing list