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/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@407033 65c4cc65-6c06-0410-ace0-fbb531ad65f3
changes/97/197/1
Richard Mudgett 11 years ago
parent 97324d6b7b
commit aeb4466656

@ -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

@ -145,6 +145,10 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
<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 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
<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 @@ 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);

Loading…
Cancel
Save