[asterisk-commits] rmudgett: trunk r407033 - in /trunk: CHANGES apps/app_chanspy.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Jan 31 17:04:28 CST 2014


Author: rmudgett
Date: Fri Jan 31 17:04:25 2014
New Revision: 407033

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=407033
Log:
ChanSpy: Add ability to specify channel uniqueids as well as channel names.

* Made ChanSpy accept a channel uniqueid or a fully specified channel name
as the chanprefix parameter if the 'u' option is specified.

(closes issue AFS-42)

Review: https://reviewboard.asterisk.org/r/3160/

Modified:
    trunk/CHANGES
    trunk/apps/app_chanspy.c

Modified: trunk/CHANGES
URL: http://svnview.digium.com/svn/asterisk/trunk/CHANGES?view=diff&rev=407033&r1=407032&r2=407033
==============================================================================
--- trunk/CHANGES (original)
+++ trunk/CHANGES Fri Jan 31 17:04:25 2014
@@ -14,6 +14,11 @@
 
 Applications
 --------------------------
+
+ChanSpy
+--------------------------
+ * ChanSpy now accepts a channel uniqueid or a fully specified channel name
+   as the chanprefix parameter if the 'u' option is specified.
 
 ConfBridge
 --------------------------

Modified: trunk/apps/app_chanspy.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/app_chanspy.c?view=diff&rev=407033&r1=407032&r2=407033
==============================================================================
--- trunk/apps/app_chanspy.c (original)
+++ trunk/apps/app_chanspy.c Fri Jan 31 17:04:25 2014
@@ -145,6 +145,10 @@
 					<option name="S">
 						<para>Stop when no more channels are left to spy on.</para>
 					</option>
+					<option name="u">
+						<para>The <literal>chanprefix</literal> parameter is a channel uniqueid
+						or fully specified channel name.</para>
+					</option>
 					<option name="v">
 						<argument name="value" />
 						<para>Adjust the initial volume in the range from <literal>-4</literal> 
@@ -181,9 +185,9 @@
 			<para> - Dialing <literal>#</literal> cycles the volume level.</para>
 			<para> - Dialing <literal>*</literal> will stop spying and look for another channel to spy on.</para>
 			<para> - Dialing a series of digits followed by <literal>#</literal> builds a channel name to append
-			to 'chanprefix'. For example, executing ChanSpy(Agent) and then dialing the digits '1234#' 
-			while spying will begin spying on the channel 'Agent/1234'. Note that this feature will be overridden if the 'd' option
-			is used</para>
+			to <literal>chanprefix</literal>. For example, executing ChanSpy(Agent) and then dialing the digits '1234#'
+			while spying will begin spying on the channel 'Agent/1234'. Note that this feature will be overridden
+			if the 'd' or 'u' options are used.</para>
 			<note><para>The <replaceable>X</replaceable> option supersedes the three features above in that if a valid
 			single digit extension exists in the correct context ChanSpy will exit to it.
 			This also disables choosing a channel based on <literal>chanprefix</literal> and a digit sequence.</para></note>
@@ -376,6 +380,7 @@
 	OPTION_DAHDI_SCAN        = (1 << 16),	/* Scan groups in DAHDIScan mode */
 	OPTION_STOP              = (1 << 17),
 	OPTION_EXITONHANGUP      = (1 << 18),   /* Hang up when the spied-on channel hangs up. */
+	OPTION_UNIQUEID          = (1 << 19),	/* The chanprefix is a channel uniqueid or fully specified channel name. */
 };
 
 enum {
@@ -403,6 +408,7 @@
 	AST_APP_OPTION_ARG('r', OPTION_RECORD, OPT_ARG_RECORD),
 	AST_APP_OPTION('s', OPTION_NOTECH),
 	AST_APP_OPTION('S', OPTION_STOP),
+	AST_APP_OPTION('u', OPTION_UNIQUEID),
 	AST_APP_OPTION_ARG('v', OPTION_VOLUME, OPT_ARG_VOLUME),
 	AST_APP_OPTION('w', OPTION_WHISPER),
 	AST_APP_OPTION('W', OPTION_PRIVATE),
@@ -885,7 +891,19 @@
 
 		/* Set up the iterator we'll be using during this call */
 		if (!ast_strlen_zero(spec)) {
-			iter = ast_channel_iterator_by_name_new(spec, strlen(spec));
+			if (ast_test_flag(flags, OPTION_UNIQUEID)) {
+				struct ast_channel *unique_chan;
+
+				unique_chan = ast_channel_get_by_name(spec);
+				if (!unique_chan) {
+					res = -1;
+					goto exit;
+				}
+				iter = ast_channel_iterator_by_name_new(ast_channel_name(unique_chan), 0);
+				ast_channel_unref(unique_chan);
+			} else {
+				iter = ast_channel_iterator_by_name_new(spec, strlen(spec));
+			}
 		} else if (!ast_strlen_zero(exten)) {
 			iter = ast_channel_iterator_by_exten_new(exten, context);
 		} else {
@@ -1069,7 +1087,7 @@
 				ast_autochan_destroy(autochan);
 				iter = ast_channel_iterator_destroy(iter);
 				goto exit;
-			} else if (res > 1 && spec) {
+			} else if (res > 1 && spec && !ast_test_flag(flags, OPTION_UNIQUEID)) {
 				struct ast_channel *next;
 
 				snprintf(nameprefix, AST_NAME_STRLEN, "%s/%d", spec, res);




More information about the asterisk-commits mailing list