<HTML>
<HEAD>
<TITLE>Re: [asterisk-users] Stopping chanspy followup</TITLE>
</HEAD>
<BODY>
<FONT FACE="Monaco, Courier New"><SPAN STYLE='font-size:12.0px'>Here is a patch file for my change to 1.4.23.1 code<BR>
<BR>
*** app_chanspy.c.orig Fri Dec 19 07:03:02 2008<BR>
--- app_chanspy.c Thu Feb 5 09:53:32 2009<BR>
***************<BR>
*** 76,81 ****<BR>
--- 76,82 ----<BR>
" 'Agent/1234'.\n"<BR>
" Options:\n"<BR>
" b - Only spy on channels involved in a bridged call.\n"<BR>
+ " e - Exit when no channels to spy on.\n"<BR>
" g(grp) - Match only channels where their ${SPYGROUP} variable is set to\n"<BR>
" contain 'grp' in an optional : delimited list.\n"<BR>
" q - Don't play a beep when beginning to spy on a channel, or speak the\n"<BR>
***************<BR>
*** 104,109 ****<BR>
--- 105,111 ----<BR>
" - Dialing * will stop spying and look for another channel to spy on.\n"<BR>
" Options:\n"<BR>
" b - Only spy on channels involved in a bridged call.\n"<BR>
+ " e - Exit when no channels to spy on.\n"<BR>
" g(grp) - Match only channels where their ${SPYGROUP} variable is set to\n"<BR>
" contain 'grp' in an optional : delimited list.\n"<BR>
" q - Don't play a beep when beginning to spy on a channel, or speak the\n"<BR>
***************<BR>
*** 128,133 ****<BR>
--- 130,136 ----<BR>
OPTION_RECORD = (1 << 4),<BR>
OPTION_WHISPER = (1 << 5),<BR>
OPTION_PRIVATE = (1 << 6), /* Private Whisper mode */<BR>
+ OPTION_EXIT = (1 << 7), /* Exit when nothing to do */<BR>
} chanspy_opt_flags;<BR>
<BR>
enum {<BR>
***************<BR>
*** 140,145 ****<BR>
--- 143,149 ----<BR>
AST_APP_OPTIONS(spy_opts, {<BR>
AST_APP_OPTION('q', OPTION_QUIET),<BR>
AST_APP_OPTION('b', OPTION_BRIDGED),<BR>
+ AST_APP_OPTION('e', OPTION_EXIT),<BR>
AST_APP_OPTION('w', OPTION_WHISPER),<BR>
AST_APP_OPTION('W', OPTION_PRIVATE),<BR>
AST_APP_OPTION_ARG('v', OPTION_VOLUME, OPT_ARG_VOLUME),<BR>
***************<BR>
*** 672,677 ****<BR>
--- 676,685 ----<BR>
}<BR>
if (res == -1 || ast_check_hangup(chan))<BR>
break;<BR>
+ if (ast_test_flag(flags, OPTION_EXIT)) {<BR>
+ if (! peer_chanspy_ds)<BR>
+ break;<BR>
+ }<BR>
}<BR>
<BR>
ast_clear_flag(chan, AST_FLAG_SPYING);<BR>
<BR>
-- <BR>
Jim Dickenson<BR>
<a href="mailto:dickenson@cfmc.com">mailto:dickenson@cfmc.com</a><BR>
<BR>
CfMC<BR>
<a href="http://www.cfmc.com/">http://www.cfmc.com/</a><BR>
</SPAN></FONT><SPAN STYLE='font-size:12.0px'><FONT FACE="Verdana, Helvetica, Arial"><BR>
<BR>
<BR>
<FONT COLOR="#0000FF">> From: Anthony Francis <anthonyf@rockynet.com><BR>
> Reply-To: Asterisk Users Mailing List - Non-Commercial Discussion <BR>
> <asterisk-users@lists.digium.com><BR>
> Date: Wed, 04 Feb 2009 16:55:25 -0700<BR>
> To: Asterisk Users Mailing List - Non-Commercial Discussion <BR>
> <asterisk-users@lists.digium.com><BR>
> Subject: Re: [asterisk-users] Stopping chanspy followup<BR>
> <BR>
> <BR>
> Jim Dickenson wrote:<BR>
</FONT><FONT COLOR="#008000">>> I am still trying to figure out a reasonable way to exit the chanspy<BR>
>> application in a dialplan.<BR>
>> <BR>
>> For the most part I understand how things are working and there is one<BR>
>> change I would like to propose.<BR>
>> <BR>
>> The way the 1.4.23.1 code seems to work is that if there are no channels<BR>
>> that match the chanprefix argument the chanspy code stays in a loop waiting<BR>
>> for a new channel to come into being that matches chanprefix and spying will<BR>
>> start.<BR>
>> <BR>
>> I would like it if there are no channels to spy on that the chanspy<BR>
>> application exit.<BR>
>> <BR>
>> This can be done by changing line 673 of chanspy.c in the following way<BR>
>> <BR>
>> Old:<BR>
>> if (res == -1 || ast_check_hangup(chan))<BR>
>> <BR>
>> <BR>
>> New:<BR>
>> if (res == -1 || ast_check_hangup(chan) || !peer_chanspy_ds)<BR>
>> <BR>
>> Otherwise, as best I can tell, unless there is some error chanspy never<BR>
>> exits unless the channel running the chanspy application hangs up, which I<BR>
>> do not particularly want to do.<BR>
>> <BR>
>> <BR>
</FONT><FONT COLOR="#0000FF">> In the interim I would recommend you make chat change and recompile.<BR>
> <BR>
> -- <BR>
> Thank you and have any kind of day you want,<BR>
> <BR>
> Anthony Francis<BR>
> <BR>
> <BR>
> <BR>
> _______________________________________________<BR>
> -- Bandwidth and Colocation Provided by <a href="http://www.api-digital.com">http://www.api-digital.com</a> --<BR>
> <BR>
> asterisk-users mailing list<BR>
> To UNSUBSCRIBE or update options visit:<BR>
> <a href="http://lists.digium.com/mailman/listinfo/asterisk-users">http://lists.digium.com/mailman/listinfo/asterisk-users</a><BR>
</FONT></FONT></SPAN>
</BODY>
</HTML>