diff --git a/CHANGES b/CHANGES
index 37eaca35cf..eedb2074c1 100644
--- a/CHANGES
+++ b/CHANGES
@@ -15,6 +15,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
--------------------------
* CONFBRIDGE dialplan function is now capable of creating/modifying dynamic
diff --git a/apps/app_chanspy.c b/apps/app_chanspy.c
index bfe97a0d76..0347906dc6 100644
--- a/apps/app_chanspy.c
+++ b/apps/app_chanspy.c
@@ -145,6 +145,10 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
Stop when no more channels are left to spy on.
+
+ The chanprefix parameter is a channel uniqueid
+ or fully specified channel name.
+
Adjust the initial volume in the range from -4
@@ -181,9 +185,9 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
- Dialing # cycles the volume level.
- Dialing * will stop spying and look for another channel to spy on.
- Dialing a series of digits followed by # 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
+ 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' or 'u' options are used.
The X 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 chanprefix and a digit sequence.
@@ -376,6 +380,7 @@ enum {
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_OPTIONS(spy_opts, {
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 @@ static int common_exec(struct ast_channel *chan, struct ast_flags *flags,
/* 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 @@ static int common_exec(struct ast_channel *chan, struct ast_flags *flags,
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);