diff --git a/CHANGES b/CHANGES index 3a2067737c..bba0d4108e 100644 --- a/CHANGES +++ b/CHANGES @@ -63,9 +63,11 @@ Applications 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 ------------------ diff --git a/apps/app_chanspy.c b/apps/app_chanspy.c index 6664207e5f..f053b388e2 100644 --- a/apps/app_chanspy.c +++ b/apps/app_chanspy.c @@ -71,6 +71,11 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") Instead of whispering on a single channel barge in on both channels involved in the call. + + + + + - - - - - @@ -205,6 +208,11 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") Instead of whispering on a single channel barge in on both channels involved in the call. + + + + + - - - - - @@ -356,6 +362,7 @@ enum { 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 @@ enum { }; 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('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), + AST_APP_OPTION('X', OPTION_EXIT), }); struct chanspy_translation_helper { @@ -726,6 +734,7 @@ static int common_exec(struct ast_channel *chan, struct ast_flags *flags, 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 @@ static int common_exec(struct ast_channel *chan, struct ast_flags *flags, next_autochan = NULL; } } + } else if (res == 0 && ast_test_flag(flags, OPTION_EXITONHANGUP)) { + goto exit; } } @@ -1089,6 +1100,10 @@ static int chanspy_exec(struct ast_channel *chan, const char *data) 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; }