[asterisk-commits] tilghman: trunk r219105 - in /trunk: CHANGES apps/app_chanspy.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Sep 16 19:58:17 CDT 2009
Author: tilghman
Date: Wed Sep 16 19:58:10 2009
New Revision: 219105
URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=219105
Log:
Add the 'E' option to exit ChanSpy, once the single channel it spied upon hangs up.
In addition, there's a bit of cleanup to the arguments and documentation, in which
I discovered that the last feature added to this application duplicated an option
(oops!) and changed that option so that it now works.
(closes issue #14909)
Reported by: junky
Patches:
__20090901-spy_hangup_trunk.diff uploaded by lmadsen (license 10)
Tested by: amilcar, junky, flujan, lmadsen
Modified:
trunk/CHANGES
trunk/apps/app_chanspy.c
Modified: trunk/CHANGES
URL: http://svn.asterisk.org/svn-view/asterisk/trunk/CHANGES?view=diff&rev=219105&r1=219104&r2=219105
==============================================================================
--- trunk/CHANGES (original)
+++ trunk/CHANGES Wed Sep 16 19:58:10 2009
@@ -63,9 +63,11 @@
exit the application.
* The Voicemail application has been improved to automatically ignore messages
that only contain silence.
- * The ChanSpy application now has the 's' option, which makes the application
+ * The ChanSpy application now has the 'S' option, which makes the application
automatically exit once it hits a point where no more channels are available
to spy on.
+ * The ChanSpy application also now has the 'E' option, which spies on a single
+ channel and exits when that channel hangs up.
Dialplan Functions
------------------
Modified: trunk/apps/app_chanspy.c
URL: http://svn.asterisk.org/svn-view/asterisk/trunk/apps/app_chanspy.c?view=diff&rev=219105&r1=219104&r2=219105
==============================================================================
--- trunk/apps/app_chanspy.c (original)
+++ trunk/apps/app_chanspy.c Wed Sep 16 19:58:10 2009
@@ -71,6 +71,11 @@
<para>Instead of whispering on a single channel barge in on both
channels involved in the call.</para>
</option>
+ <option name="c">
+ <argument name="digit" required="true">
+ <para>Specify a DTMF digit that can be used to spy on the next available channel.</para>
+ </argument>
+ </option>
<option name="d">
<para>Override the typical numeric DTMF functionality and instead
use DTMF to switch between spy modes.</para>
@@ -86,6 +91,15 @@
</enum>
</enumlist>
</option>
+ <option name="e">
+ <argument name="ext" required="true" />
+ <para>Enable <emphasis>enforced</emphasis> mode, so the spying channel can
+ only monitor extensions whose name is in the <replaceable>ext</replaceable> : delimited
+ list.</para>
+ </option>
+ <option name="E">
+ <para>Exit when the spied-on channel hangs up.</para>
+ </option>
<option name="g">
<argument name="grp" required="true">
<para>Only spy on channels in which one or more of the groups
@@ -106,6 +120,9 @@
<argument name="mailbox" />
<argument name="context" />
</option>
+ <option name="o">
+ <para>Only listen to audio coming from this channel.</para>
+ </option>
<option name="q">
<para>Don't play a beep when beginning to spy on a channel, or speak the
selected channel name.</para>
@@ -119,6 +136,9 @@
<para>Skip the playback of the channel type (i.e. SIP, IAX, etc) when
speaking the selected channel name.</para>
</option>
+ <option name="S">
+ <para>Stop when no more channels are left to spy on.</para>
+ </option>
<option name="v">
<argument name="value" />
<para>Adjust the initial volume in the range from <literal>-4</literal>
@@ -132,11 +152,10 @@
<para>Enable <literal>private whisper</literal> mode, so the spying channel can
talk to the spied-on channel but cannot listen to that channel.</para>
</option>
- <option name="o">
- <para>Only listen to audio coming from this channel.</para>
- </option>
- <option name="s">
- <para>Stop when no more channels are left to spy on.</para>
+ <option name="x">
+ <argument name="digit" required="true">
+ <para>Specify a DTMF digit that can be used to exit the application.</para>
+ </argument>
</option>
<option name="X">
<para>Allow the user to exit ChanSpy to a valid single digit
@@ -144,22 +163,6 @@
specified by the <variable>SPY_EXIT_CONTEXT</variable> channel variable. The
name of the last channel that was spied on will be stored
in the <variable>SPY_CHANNEL</variable> variable.</para>
- </option>
- <option name="x">
- <argument name="digit" required="true">
- <para>Specify a DTMF digit that can be used to exit the application.</para>
- </argument>
- </option>
- <option name="c">
- <argument name="digit" required="true">
- <para>Specify a DTMF digit that can be used to spy on the next available channel.</para>
- </argument>
- </option>
- <option name="e">
- <argument name="ext" required="true" />
- <para>Enable <emphasis>enforced</emphasis> mode, so the spying channel can
- only monitor extensions whose name is in the <replaceable>ext</replaceable> : delimited
- list.</para>
</option>
</optionlist>
</parameter>
@@ -205,6 +208,11 @@
<para>Instead of whispering on a single channel barge in on both
channels involved in the call.</para>
</option>
+ <option name="c">
+ <argument name="digit" required="true">
+ <para>Specify a DTMF digit that can be used to spy on the next available channel.</para>
+ </argument>
+ </option>
<option name="d">
<para>Override the typical numeric DTMF functionality and instead
use DTMF to switch between spy modes.</para>
@@ -220,6 +228,15 @@
</enum>
</enumlist>
</option>
+ <option name="e">
+ <argument name="ext" required="true" />
+ <para>Enable <emphasis>enforced</emphasis> mode, so the spying channel can
+ only monitor extensions whose name is in the <replaceable>ext</replaceable> : delimited
+ list.</para>
+ </option>
+ <option name="E">
+ <para>Exit when the spied-on channel hangs up.</para>
+ </option>
<option name="g">
<argument name="grp" required="true">
<para>Only spy on channels in which one or more of the groups
@@ -240,6 +257,9 @@
<argument name="mailbox" />
<argument name="context" />
</option>
+ <option name="o">
+ <para>Only listen to audio coming from this channel.</para>
+ </option>
<option name="q">
<para>Don't play a beep when beginning to spy on a channel, or speak the
selected channel name.</para>
@@ -253,6 +273,9 @@
<para>Skip the playback of the channel type (i.e. SIP, IAX, etc) when
speaking the selected channel name.</para>
</option>
+ <option name="S">
+ <para>Stop when there are no more extensions left to spy on.</para>
+ </option>
<option name="v">
<argument name="value" />
<para>Adjust the initial volume in the range from <literal>-4</literal>
@@ -266,11 +289,10 @@
<para>Enable <literal>private whisper</literal> mode, so the spying channel can
talk to the spied-on channel but cannot listen to that channel.</para>
</option>
- <option name="o">
- <para>Only listen to audio coming from this channel.</para>
- </option>
- <option name="s">
- <para>Stop when there are no more extensions left to spy on.</para>
+ <option name="x">
+ <argument name="digit" required="true">
+ <para>Specify a DTMF digit that can be used to exit the application.</para>
+ </argument>
</option>
<option name="X">
<para>Allow the user to exit ChanSpy to a valid single digit
@@ -278,22 +300,6 @@
specified by the <variable>SPY_EXIT_CONTEXT</variable> channel variable. The
name of the last channel that was spied on will be stored
in the <variable>SPY_CHANNEL</variable> variable.</para>
- </option>
- <option name="x">
- <argument name="digit" required="true">
- <para>Specify a DTMF digit that can be used to exit the application.</para>
- </argument>
- </option>
- <option name="c">
- <argument name="digit" required="true">
- <para>Specify a DTMF digit that can be used to spy on the next available channel.</para>
- </argument>
- </option>
- <option name="e">
- <argument name="ext" required="true" />
- <para>Enable <emphasis>enforced</emphasis> mode, so the spying channel can
- only monitor extensions whose name is in the <replaceable>ext</replaceable> : delimited
- list.</para>
</option>
</optionlist>
</parameter>
@@ -356,6 +362,7 @@
OPTION_DTMF_CYCLE = (1 << 15), /* Custom DTMF for cycling next avaliable channel, (default is '*') */
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. */
};
enum {
@@ -370,23 +377,24 @@
};
AST_APP_OPTIONS(spy_opts, {
- AST_APP_OPTION('q', OPTION_QUIET),
AST_APP_OPTION('b', OPTION_BRIDGED),
AST_APP_OPTION('B', OPTION_BARGE),
+ AST_APP_OPTION_ARG('c', OPTION_DTMF_CYCLE, OPT_ARG_CYCLE),
+ AST_APP_OPTION('d', OPTION_DTMF_SWITCH_MODES),
+ AST_APP_OPTION_ARG('e', OPTION_ENFORCED, OPT_ARG_ENFORCED),
+ AST_APP_OPTION('E', OPTION_EXITONHANGUP),
+ AST_APP_OPTION_ARG('g', OPTION_GROUP, OPT_ARG_GROUP),
+ AST_APP_OPTION_ARG('n', OPTION_NAME, OPT_ARG_NAME),
+ AST_APP_OPTION('o', OPTION_READONLY),
+ AST_APP_OPTION('q', OPTION_QUIET),
+ 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_ARG('v', OPTION_VOLUME, OPT_ARG_VOLUME),
AST_APP_OPTION('w', OPTION_WHISPER),
AST_APP_OPTION('W', OPTION_PRIVATE),
- AST_APP_OPTION_ARG('v', OPTION_VOLUME, OPT_ARG_VOLUME),
- AST_APP_OPTION_ARG('g', OPTION_GROUP, OPT_ARG_GROUP),
- AST_APP_OPTION_ARG('r', OPTION_RECORD, OPT_ARG_RECORD),
- AST_APP_OPTION_ARG('e', OPTION_ENFORCED, OPT_ARG_ENFORCED),
- AST_APP_OPTION('o', OPTION_READONLY),
- AST_APP_OPTION('s', OPTION_STOP),
+ AST_APP_OPTION_ARG('x', OPTION_DTMF_EXIT, OPT_ARG_EXIT),
AST_APP_OPTION('X', OPTION_EXIT),
- AST_APP_OPTION('s', OPTION_NOTECH),
- AST_APP_OPTION_ARG('n', OPTION_NAME, OPT_ARG_NAME),
- AST_APP_OPTION('d', OPTION_DTMF_SWITCH_MODES),
- AST_APP_OPTION_ARG('x', OPTION_DTMF_EXIT, OPT_ARG_EXIT),
- AST_APP_OPTION_ARG('c', OPTION_DTMF_CYCLE, OPT_ARG_CYCLE),
});
struct chanspy_translation_helper {
@@ -726,6 +734,7 @@
char *ptr;
int num;
int num_spyed_upon = 1;
+ int hangup = 0;
struct ast_channel_iterator *iter = NULL;
if (ast_test_flag(flags, OPTION_EXIT)) {
@@ -957,6 +966,8 @@
next_autochan = NULL;
}
}
+ } else if (res == 0 && ast_test_flag(flags, OPTION_EXITONHANGUP)) {
+ goto exit;
}
}
@@ -1089,6 +1100,10 @@
if (oldwf && ast_set_write_format(chan, oldwf) < 0)
ast_log(LOG_ERROR, "Could Not Set Write Format.\n");
+ if (ast_test_flag(&flags, OPTION_EXITONHANGUP)) {
+ ast_verb(3, "Stopped spying due to the spied-on channel hanging up.\n");
+ }
+
return res;
}
More information about the asterisk-commits
mailing list