[asterisk-commits] kpfleming: branch group/new_loader_completion r39680 - in /team/group/new_loa...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Sun Aug 13 20:10:37 MST 2006


Author: kpfleming
Date: Sun Aug 13 22:10:36 2006
New Revision: 39680

URL: http://svn.digium.com/view/asterisk?rev=39680&view=rev
Log:
update so i can work on the loader while flying tomorrow

Added:
    team/group/new_loader_completion/channels/misdn/asn1.c
      - copied unchanged from r39659, trunk/channels/misdn/asn1.c
    team/group/new_loader_completion/channels/misdn/asn1.h
      - copied unchanged from r39659, trunk/channels/misdn/asn1.h
    team/group/new_loader_completion/configs/sla.conf.sample
      - copied unchanged from r39659, trunk/configs/sla.conf.sample
    team/group/new_loader_completion/doc/imapstorage.txt
      - copied unchanged from r39659, trunk/doc/imapstorage.txt
    team/group/new_loader_completion/include/asterisk/threadstorage.h
      - copied unchanged from r39659, trunk/include/asterisk/threadstorage.h
    team/group/new_loader_completion/pbx/ael/ael-test/ael-ntest10/
      - copied from r39659, trunk/pbx/ael/ael-test/ael-ntest10/
    team/group/new_loader_completion/pbx/ael/ael-test/ael-ntest10/extensions.ael
      - copied unchanged from r39659, trunk/pbx/ael/ael-test/ael-ntest10/extensions.ael
    team/group/new_loader_completion/pbx/ael/ael-test/ael-ntest12/
      - copied from r39659, trunk/pbx/ael/ael-test/ael-ntest12/
    team/group/new_loader_completion/pbx/ael/ael-test/ael-ntest12/extensions.ael
      - copied unchanged from r39659, trunk/pbx/ael/ael-test/ael-ntest12/extensions.ael
    team/group/new_loader_completion/pbx/ael/ael-test/ael-test11/
      - copied from r39659, trunk/pbx/ael/ael-test/ael-test11/
    team/group/new_loader_completion/pbx/ael/ael-test/ael-test11/extensions.ael
      - copied unchanged from r39659, trunk/pbx/ael/ael-test/ael-test11/extensions.ael
    team/group/new_loader_completion/pbx/ael/ael-test/ael-vtest13/
      - copied from r39659, trunk/pbx/ael/ael-test/ael-vtest13/
    team/group/new_loader_completion/pbx/ael/ael-test/ael-vtest13/extensions.ael
      - copied unchanged from r39659, trunk/pbx/ael/ael-test/ael-vtest13/extensions.ael
    team/group/new_loader_completion/pbx/ael/ael-test/ael-vtest13/include1.ael2
      - copied unchanged from r39659, trunk/pbx/ael/ael-test/ael-vtest13/include1.ael2
    team/group/new_loader_completion/pbx/ael/ael-test/ael-vtest13/include2.ael2
      - copied unchanged from r39659, trunk/pbx/ael/ael-test/ael-vtest13/include2.ael2
    team/group/new_loader_completion/pbx/ael/ael-test/ael-vtest13/include3.ael2
      - copied unchanged from r39659, trunk/pbx/ael/ael-test/ael-vtest13/include3.ael2
    team/group/new_loader_completion/pbx/ael/ael-test/ael-vtest13/include4.ael2
      - copied unchanged from r39659, trunk/pbx/ael/ael-test/ael-vtest13/include4.ael2
    team/group/new_loader_completion/pbx/ael/ael-test/ael-vtest13/include5.ael2
      - copied unchanged from r39659, trunk/pbx/ael/ael-test/ael-vtest13/include5.ael2
    team/group/new_loader_completion/pbx/ael/ael-test/ael-vtest13/telemarket_torture.ael2
      - copied unchanged from r39659, trunk/pbx/ael/ael-test/ael-vtest13/telemarket_torture.ael2
    team/group/new_loader_completion/pbx/ael/ael-test/ref.ael-ntest10
      - copied unchanged from r39659, trunk/pbx/ael/ael-test/ref.ael-ntest10
    team/group/new_loader_completion/pbx/ael/ael-test/ref.ael-ntest12
      - copied unchanged from r39659, trunk/pbx/ael/ael-test/ref.ael-ntest12
    team/group/new_loader_completion/pbx/ael/ael-test/ref.ael-test11
      - copied unchanged from r39659, trunk/pbx/ael/ael-test/ref.ael-test11
    team/group/new_loader_completion/pbx/ael/ael-test/ref.ael-vtest13
      - copied unchanged from r39659, trunk/pbx/ael/ael-test/ref.ael-vtest13
Modified:
    team/group/new_loader_completion/   (props changed)
    team/group/new_loader_completion/.cleancount
    team/group/new_loader_completion/CREDITS
    team/group/new_loader_completion/Makefile
    team/group/new_loader_completion/UPGRADE.txt
    team/group/new_loader_completion/acinclude.m4
    team/group/new_loader_completion/apps/app_chanspy.c
    team/group/new_loader_completion/apps/app_dial.c
    team/group/new_loader_completion/apps/app_followme.c
    team/group/new_loader_completion/apps/app_meetme.c
    team/group/new_loader_completion/apps/app_queue.c
    team/group/new_loader_completion/apps/app_voicemail.c
    team/group/new_loader_completion/asterisk.c
    team/group/new_loader_completion/channel.c
    team/group/new_loader_completion/channels/Makefile
    team/group/new_loader_completion/channels/chan_h323.c
    team/group/new_loader_completion/channels/chan_iax2.c
    team/group/new_loader_completion/channels/chan_jingle.c
    team/group/new_loader_completion/channels/chan_mgcp.c
    team/group/new_loader_completion/channels/chan_misdn.c
    team/group/new_loader_completion/channels/chan_phone.c
    team/group/new_loader_completion/channels/chan_sip.c
    team/group/new_loader_completion/channels/chan_skinny.c
    team/group/new_loader_completion/channels/chan_zap.c
    team/group/new_loader_completion/channels/iax2-parser.c
    team/group/new_loader_completion/channels/misdn/Makefile
    team/group/new_loader_completion/channels/misdn/chan_misdn_config.h
    team/group/new_loader_completion/channels/misdn/fac.c
    team/group/new_loader_completion/channels/misdn/fac.h
    team/group/new_loader_completion/channels/misdn/ie.c
    team/group/new_loader_completion/channels/misdn/isdn_lib.c
    team/group/new_loader_completion/channels/misdn/isdn_lib.h
    team/group/new_loader_completion/channels/misdn/isdn_lib_intern.h
    team/group/new_loader_completion/channels/misdn/isdn_msg_parser.c
    team/group/new_loader_completion/channels/misdn_config.c
    team/group/new_loader_completion/cli.c
    team/group/new_loader_completion/config.c
    team/group/new_loader_completion/configs/features.conf.sample
    team/group/new_loader_completion/configs/followme.conf.sample
    team/group/new_loader_completion/configs/func_odbc.conf.sample
    team/group/new_loader_completion/configs/phone.conf.sample
    team/group/new_loader_completion/configs/voicemail.conf.sample
    team/group/new_loader_completion/configure
    team/group/new_loader_completion/configure.ac
    team/group/new_loader_completion/contrib/scripts/safe_asterisk
    team/group/new_loader_completion/devicestate.c
    team/group/new_loader_completion/doc/asterisk-conf.txt
    team/group/new_loader_completion/doc/channelvariables.txt
    team/group/new_loader_completion/doc/realtime.txt
    team/group/new_loader_completion/frame.c
    team/group/new_loader_completion/include/asterisk/ael_structs.h
    team/group/new_loader_completion/include/asterisk/app.h
    team/group/new_loader_completion/include/asterisk/channel.h
    team/group/new_loader_completion/include/asterisk/compiler.h
    team/group/new_loader_completion/include/asterisk/config.h
    team/group/new_loader_completion/include/asterisk/frame.h
    team/group/new_loader_completion/include/asterisk/logger.h
    team/group/new_loader_completion/include/asterisk/options.h
    team/group/new_loader_completion/include/asterisk/slinfactory.h
    team/group/new_loader_completion/include/asterisk/stringfields.h
    team/group/new_loader_completion/include/asterisk/utils.h
    team/group/new_loader_completion/logger.c
    team/group/new_loader_completion/manager.c
    team/group/new_loader_completion/pbx.c
    team/group/new_loader_completion/pbx/ael/ael-test/ael-test1/extensions.ael
    team/group/new_loader_completion/pbx/ael/ael-test/ref.ael-ntest9
    team/group/new_loader_completion/pbx/ael/ael-test/ref.ael-test1
    team/group/new_loader_completion/pbx/ael/ael-test/ref.ael-test2
    team/group/new_loader_completion/pbx/ael/ael-test/ref.ael-test3
    team/group/new_loader_completion/pbx/ael/ael-test/ref.ael-test4
    team/group/new_loader_completion/pbx/ael/ael-test/ref.ael-test5
    team/group/new_loader_completion/pbx/ael/ael-test/ref.ael-test6
    team/group/new_loader_completion/pbx/ael/ael-test/ref.ael-test7
    team/group/new_loader_completion/pbx/ael/ael-test/ref.ael-test8
    team/group/new_loader_completion/pbx/ael/ael-test/runtests
    team/group/new_loader_completion/pbx/ael/ael.tab.c
    team/group/new_loader_completion/pbx/ael/ael.y
    team/group/new_loader_completion/pbx/pbx_ael.c
    team/group/new_loader_completion/pbx/pbx_config.c
    team/group/new_loader_completion/pbx/pbx_gtkconsole.c
    team/group/new_loader_completion/res/res_agi.c
    team/group/new_loader_completion/res/res_features.c
    team/group/new_loader_completion/res/res_jabber.c
    team/group/new_loader_completion/res/res_musiconhold.c
    team/group/new_loader_completion/res/res_snmp.c
    team/group/new_loader_completion/rtp.c
    team/group/new_loader_completion/slinfactory.c
    team/group/new_loader_completion/utils.c
    team/group/new_loader_completion/utils/ael_main.c

Propchange: team/group/new_loader_completion/
------------------------------------------------------------------------------
    automerge = yes

Propchange: team/group/new_loader_completion/
------------------------------------------------------------------------------
Binary property 'branch-1.2-blocked' - no diff available.

Propchange: team/group/new_loader_completion/
------------------------------------------------------------------------------
Binary property 'branch-1.2-merged' - no diff available.

Propchange: team/group/new_loader_completion/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Sun Aug 13 22:10:36 2006
@@ -1,1 +1,1 @@
-/trunk:1-38353
+/trunk:1-39659

Modified: team/group/new_loader_completion/.cleancount
URL: http://svn.digium.com/view/asterisk/team/group/new_loader_completion/.cleancount?rev=39680&r1=39679&r2=39680&view=diff
==============================================================================
--- team/group/new_loader_completion/.cleancount (original)
+++ team/group/new_loader_completion/.cleancount Sun Aug 13 22:10:36 2006
@@ -1,1 +1,1 @@
-19
+20

Modified: team/group/new_loader_completion/CREDITS
URL: http://svn.digium.com/view/asterisk/team/group/new_loader_completion/CREDITS?rev=39680&r1=39679&r2=39680&view=diff
==============================================================================
--- team/group/new_loader_completion/CREDITS (original)
+++ team/group/new_loader_completion/CREDITS Sun Aug 13 22:10:36 2006
@@ -41,6 +41,39 @@
 	russelb at clemson.edu
 
 Anthony Minessale II - Countless big and small fixes, and relentless forward push
+also:
+app_chanspy
+app_forkcdr
+app_controlplayback
+app_while
+app_dumpchan
+app_dictate
+app_realtime
+app_macroif
+app_execif
+app_execiftime
+res_odbc
+res_config_odbc
+format_slin
+app_retrydial
+cdr_custom
+res_muxmon (now MixMonitor)
+res_sqlite
+format_mp3
+Several Features in app_dial including L(), G() and enhancements to M() and D()
+The concept design and initial implementation of dialplan functions with several examples.
+Several CDR enhancements including CDR variables.
+Attended Transfer
+One Touch Record
+Native Music On Hold
+Pluggable config backend (res_config)
+Realtime Caching options and SIP/IAX clusterability
+IAX codec preferences
+Modifications to the manager API to disable events.
+command line '-t' flag to allow recording/voicemail on nfs shares.
+#exec parser in config files.
+setvar from iax and sip peers.
+mulit-line comments in config files.
 	anthmct at yahoo.com              http://www.asterlink.com
 
 James Golovich - Innumerable contributions
@@ -131,6 +164,16 @@
 John Martin, Aupix - Improved video support in the SIP channel
 
 Steve Underwood - Provided T.38 pass through support.
+
+George Konstantoulakis - Support for Greek in voicemail added by InAccess Networks (work funded by HOL, www.hol.gr) gkon at inaccessnetworks.com
+
+Daniel Nylander - Support for Swedish and Norwegian languages in voicemail. http://www.danielnylander.se/
+
+Stojan Sljivic - An option for maximum number of messsages per mailbox in voicemail.  Also an issue with voicemail synchronization has been fixed.  GDS Partners www.gdspartners.com .  stojan.sljivic at gdspartners.com
+
+Bartosz Supczinski - Support for Polish added by DIR (www.dir.pl) Bartosz.Supczinski at dir.pl
+
+James Rothenberger - Support for IMAP storage integration added by OneBizTone LLC Work funded by University of Pennsylvania jar at onebiztone.com
 
 === OTHER CONTRIBUTIONS ===
 John Todd - Monkey sounds and associated teletorture prompt

Modified: team/group/new_loader_completion/Makefile
URL: http://svn.digium.com/view/asterisk/team/group/new_loader_completion/Makefile?rev=39680&r1=39679&r2=39680&view=diff
==============================================================================
--- team/group/new_loader_completion/Makefile (original)
+++ team/group/new_loader_completion/Makefile Sun Aug 13 22:10:36 2006
@@ -131,13 +131,17 @@
 GLOBAL_MAKEOPTS=$(wildcard /etc/asterisk.makeopts)
 USER_MAKEOPTS=$(wildcard ~/.asterisk.makeopts)
 
-ifneq ($(wildcard menuselect.makeopts),)
+ifeq ($(strip $(foreach var,clean distclean dist-clean update,$(findstring $(var),$(MAKECMDGOALS)))),)
+ ifneq ($(wildcard menuselect.makeopts),)
   include menuselect.makeopts
   include menuselect.makedeps
-endif
-
-ifneq ($(wildcard makeopts),)
+ endif
+endif
+
+ifeq ($(strip $(foreach var,clean distclean dist-clean update,$(findstring $(var),$(MAKECMDGOALS)))),)
+ ifneq ($(wildcard makeopts),)
   include makeopts
+ endif
 endif
 
 TOPDIR_CFLAGS=-Iinclude
@@ -429,12 +433,16 @@
 db1-ast/libdb1.a:
 	CFLAGS="$(ASTCFLAGS)" $(MAKE) -C db1-ast libdb1.a
 
-ifneq ($(wildcard .depend),)
+ifeq ($(strip $(foreach var,clean distclean dist-clean update,$(findstring $(var),$(MAKECMDGOALS)))),)
+ ifneq ($(wildcard .depend),)
   include .depend
-endif
-
-ifneq ($(wildcard .tags-depend),)
+ endif
+endif
+
+ifeq ($(strip $(foreach var,clean distclean dist-clean update,$(findstring $(var),$(MAKECMDGOALS)))),)
+ ifneq ($(wildcard .tags-depend),)
   include .tags-depend
+ endif
 endif
 
 ast_expr2.c ast_expr2.h:

Modified: team/group/new_loader_completion/UPGRADE.txt
URL: http://svn.digium.com/view/asterisk/team/group/new_loader_completion/UPGRADE.txt?rev=39680&r1=39679&r2=39680&view=diff
==============================================================================
--- team/group/new_loader_completion/UPGRADE.txt (original)
+++ team/group/new_loader_completion/UPGRADE.txt Sun Aug 13 22:10:36 2006
@@ -240,6 +240,10 @@
 * Builtin transfer functionality sets the variable ${TRANSFERERNAME} in the new
   created channel. This variables holds the channel name of the transferer.
 
+* The dial plan variable PRI_CAUSE will be removed from future versions 
+  of Asterisk.
+  It is replaced by adding a cause value to the hangup() application.
+
 Functions:
 
 * The function ${CHECK_MD5()} has been deprecated in favor of using an

Modified: team/group/new_loader_completion/acinclude.m4
URL: http://svn.digium.com/view/asterisk/team/group/new_loader_completion/acinclude.m4?rev=39680&r1=39679&r2=39680&view=diff
==============================================================================
--- team/group/new_loader_completion/acinclude.m4 (original)
+++ team/group/new_loader_completion/acinclude.m4 Sun Aug 13 22:10:36 2006
@@ -56,10 +56,10 @@
       if test "x${$1_HEADER_FOUND}" = "x0" ; then
          if test ! -z "${$1_MANDATORY}" ;
          then
-            echo " ***"
-            echo " *** It appears that you do not have the $2 development package installed."
-            echo " *** Please install it to include ${$1_DESCRIP} support, or re-run configure"
-            echo " *** without explicitly specifying --with-${$1_OPTION}"
+            AC_MSG_NOTICE( ***)
+            AC_MSG_NOTICE( *** It appears that you do not have the $2 development package installed.)
+            AC_MSG_NOTICE( *** Please install it to include ${$1_DESCRIP} support, or re-run configure)
+            AC_MSG_NOTICE( *** without explicitly specifying --with-${$1_OPTION})
             exit 1
          fi
          $1_LIB=""
@@ -71,10 +71,10 @@
       fi
    elif test ! -z "${$1_MANDATORY}";
    then
-      echo "***"
-      echo "*** The ${$1_DESCRIP} installation on this system appears to be broken."
-      echo "*** Either correct the installation, or run configure"
-      echo "*** without explicitly specifying --with-${$1_OPTION}"
+      AC_MSG_NOTICE(***)
+      AC_MSG_NOTICE(*** The ${$1_DESCRIP} installation on this system appears to be broken.)
+      AC_MSG_NOTICE(*** Either correct the installation, or run configure)
+      AC_MSG_NOTICE(*** without explicitly specifying --with-${$1_OPTION})
       exit 1
    fi
 fi
@@ -93,7 +93,7 @@
    done ;
 ) ;
 if test  "x$GNU_MAKE" = "xNot Found"  ; then
-   echo " *** Please install GNU make.  It is required to build Asterisk!"
+   AC_MSG_ERROR( *** Please install GNU make.  It is required to build Asterisk!)
    exit 1
 fi
 AC_SUBST([GNU_MAKE])

Modified: team/group/new_loader_completion/apps/app_chanspy.c
URL: http://svn.digium.com/view/asterisk/team/group/new_loader_completion/apps/app_chanspy.c?rev=39680&r1=39679&r2=39680&view=diff
==============================================================================
--- team/group/new_loader_completion/apps/app_chanspy.c (original)
+++ team/group/new_loader_completion/apps/app_chanspy.c Sun Aug 13 22:10:36 2006
@@ -51,45 +51,76 @@
 #include "asterisk/module.h"
 #include "asterisk/lock.h"
 
-AST_MUTEX_DEFINE_STATIC(modlock);
-
 #define AST_NAME_STRLEN 256
-#define ALL_DONE(u, ret) ast_module_user_remove(u); return ret;
-#define get_volfactor(x) x ? ((x > 0) ? (1 << x) : ((1 << abs(x)) * -1)) : 0
-
-static const char *app = "ChanSpy";
-static const char *desc = 
+
+static const char *tdesc = "Listen to a channel, and optionally whisper into it";
+static const char *app_chan = "ChanSpy";
+static const char *desc_chan = 
 "  ChanSpy([chanprefix][|options]): This application is used to listen to the\n"
-"audio from an active Asterisk channel. This includes the audio coming in and\n"
+"audio from an Asterisk channel. This includes the audio coming in and\n"
 "out of the channel being spied on. If the 'chanprefix' parameter is specified,\n"
 "only channels beginning with this string will be spied upon.\n"
-"  While Spying, the following actions may be performed:\n"
+"  While spying, the following actions may be performed:\n"
 "    - Dialing # cycles the volume level.\n"
 "    - Dialing * will stop spying and look for another channel to spy on.\n"
 "    - Dialing a series of digits followed by # builds a channel name to append\n"
 "      to 'chanprefix'. For example, executing ChanSpy(Agent) and then dialing\n"
-"      the digits '1234#' while spying will begin spying on the channel,\n"
+"      the digits '1234#' while spying will begin spying on the channel\n"
 "      'Agent/1234'.\n"
 "  Options:\n"
-"    b - Only spy on channels involved in a bridged call.\n"
-"    g(grp) - Match only channels where their ${SPYGROUP} variable is set to\n"
-"             contain 'grp' in an optional : delimited list.\n"
-"    q - Don't play a beep when beginning to spy on a channel.\n"
+"    b             - Only spy on channels involved in a bridged call.\n"
+"    g(grp)        - Match only channels where their ${SPYGROUP} variable is set to\n"
+"                    contain 'grp' in an optional : delimited list.\n"
+"    q             - Don't play a beep when beginning to spy on a channel, or speak the\n"
+"                    selected channel name.\n"
 "    r[(basename)] - Record the session to the monitor spool directory. An\n"
 "                    optional base for the filename may be specified. The\n"
 "                    default is 'chanspy'.\n"
-"    v([value]) - Adjust the initial volume in the range from -4 to 4. A\n"
-"                 negative value refers to a quieter setting.\n"
+"    v([value])    - Adjust the initial volume in the range from -4 to 4. A\n"
+"                    negative value refers to a quieter setting.\n"
+"    w             - Enable 'whisper' mode, so the spying channel can talk to\n"
+"                    the spied-on channel.\n"
+"    W             - Enable 'private whisper' mode, so the spying channel can\n"
+"                    talk to the spied-on channel but cannot listen to that\n"
+"                    channel.\n"
 ;
 
-static const char *chanspy_spy_type = "ChanSpy";
+static const char *app_ext = "ExtenSpy";
+static const char *desc_ext = 
+"  ExtenSpy(exten[@context][|options]): This application is used to listen to the\n"
+"audio from an Asterisk channel. This includes the audio coming in and\n"
+"out of the channel being spied on. Only channels created by outgoing calls for the\n"
+"specified extension will be selected for spying. If the optional context is not\n"
+"supplied, the current channel's context will be used.\n"
+"  While spying, the following actions may be performed:\n"
+"    - Dialing # cycles the volume level.\n"
+"    - Dialing * will stop spying and look for another channel to spy on.\n"
+"  Options:\n"
+"    b             - Only spy on channels involved in a bridged call.\n"
+"    g(grp)        - Match only channels where their ${SPYGROUP} variable is set to\n"
+"                    contain 'grp' in an optional : delimited list.\n"
+"    q             - Don't play a beep when beginning to spy on a channel, or speak the\n"
+"                    selected channel name.\n"
+"    r[(basename)] - Record the session to the monitor spool directory. An\n"
+"                    optional base for the filename may be specified. The\n"
+"                    default is 'chanspy'.\n"
+"    v([value])    - Adjust the initial volume in the range from -4 to 4. A\n"
+"                    negative value refers to a quieter setting.\n"
+"    w             - Enable 'whisper' mode, so the spying channel can talk to\n"
+"                    the spied-on channel.\n"
+"    W             - Enable 'private whisper' mode, so the spying channel can\n"
+"                    talk to the spied-on channel but cannot listen to that\n"
+"                    channel.\n"
+;
 
 enum {
 	OPTION_QUIET	 = (1 << 0),	/* Quiet, no announcement */
 	OPTION_BRIDGED   = (1 << 1),	/* Only look at bridged calls */
 	OPTION_VOLUME    = (1 << 2),	/* Specify initial volume */
 	OPTION_GROUP     = (1 << 3),	/* Only look at channels in group */
-	OPTION_RECORD    = (1 << 4),	/* Record */
+	OPTION_RECORD    = (1 << 4),
+	OPTION_WHISPER	 = (1 << 5),
+	OPTION_PRIVATE   = (1 << 6),	/* Private Whisper mode */
 } chanspy_opt_flags;
 
 enum {
@@ -99,9 +130,11 @@
 	OPT_ARG_ARRAY_SIZE,
 } chanspy_opt_args;
 
-AST_APP_OPTIONS(chanspy_opts, {
+AST_APP_OPTIONS(spy_opts, {
 	AST_APP_OPTION('q', OPTION_QUIET),
 	AST_APP_OPTION('b', OPTION_BRIDGED),
+	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),
@@ -114,34 +147,6 @@
 	int fd;
 	int volfactor;
 };
-
-static struct ast_channel *local_channel_walk(struct ast_channel *chan) 
-{
-	struct ast_channel *ret;
-	ast_mutex_lock(&modlock);	
-	if ((ret = ast_channel_walk_locked(chan))) {
-		ast_mutex_unlock(&ret->lock);
-	}
-	ast_mutex_unlock(&modlock);			
-	return ret;
-}
-
-static struct ast_channel *local_get_channel_begin_name(char *name) 
-{
-	struct ast_channel *chan, *ret = NULL;
-	ast_mutex_lock(&modlock);
-	chan = local_channel_walk(NULL);
-	while (chan) {
-		if (!strncmp(chan->name, name, strlen(name))) {
-			ret = chan;
-			break;
-		}
-		chan = local_channel_walk(chan);
-	}
-	ast_mutex_unlock(&modlock);
-	
-	return ret;
-}
 
 static void *spy_alloc(struct ast_channel *chan, void *data)
 {
@@ -183,7 +188,6 @@
 	return 0;
 }
 
-
 static struct ast_generator spygen = {
 	.alloc = spy_alloc,
 	.release = spy_release,
@@ -201,26 +205,25 @@
 	res = ast_channel_spy_add(chan, spy);
 	ast_channel_unlock(chan);
 
-	if (!res && ast_test_flag(chan, AST_FLAG_NBRIDGE) && (peer = ast_bridged_channel(chan))) {
+	if (!res && ast_test_flag(chan, AST_FLAG_NBRIDGE) && (peer = ast_bridged_channel(chan)))
 		ast_softhangup(peer, AST_SOFTHANGUP_UNBRIDGE);	
-	}
 
 	return res;
 }
 
-static void stop_spying(struct ast_channel *chan, struct ast_channel_spy *spy) 
+static void stop_spying(struct ast_channel_spy *spy) 
 {
 	/* If our status has changed to DONE, then the channel we're spying on is gone....
 	   DON'T TOUCH IT!!!  RUN AWAY!!! */
 	if (spy->status == CHANSPY_DONE)
 		return;
 
-	if (!chan)
+	if (!spy->chan)
 		return;
 
-	ast_channel_lock(chan);
-	ast_channel_spy_remove(chan, spy);
-	ast_channel_unlock(chan);
+	ast_channel_lock(spy->chan);
+	ast_channel_spy_remove(spy->chan, spy);
+	ast_channel_unlock(spy->chan);
 };
 
 /* Map 'volume' levels from -4 through +4 into
@@ -248,332 +251,463 @@
 
 	if (!ast_channel_setoption(chan, AST_OPTION_TXGAIN, &volume_adjust, sizeof(volume_adjust), 0))
 		csth->volfactor = 0;
-}
-
-static int channel_spy(struct ast_channel *chan, struct ast_channel *spyee, int *volfactor, int fd) 
+	csth->spy.read_vol_adjustment = csth->volfactor;
+	csth->spy.write_vol_adjustment = csth->volfactor;
+}
+
+static int channel_spy(struct ast_channel *chan, struct ast_channel *spyee, int *volfactor, int fd,
+		       const struct ast_flags *flags) 
 {
 	struct chanspy_translation_helper csth;
-	int running, res = 0, x = 0;
-	char inp[24];
-	char *name=NULL;
+	int running = 0, res, x = 0;
+	char inp[24] = {0};
+	char *name;
 	struct ast_frame *f;
-
-	running = (chan && !ast_check_hangup(chan) && spyee && !ast_check_hangup(spyee));
-
-	if (running) {
-		memset(inp, 0, sizeof(inp));
-		name = ast_strdupa(spyee->name);
-		if (option_verbose >= 2)
-			ast_verbose(VERBOSE_PREFIX_2 "Spying on channel %s\n", name);
-
-		memset(&csth, 0, sizeof(csth));
-		ast_set_flag(&csth.spy, CHANSPY_FORMAT_AUDIO);
-		ast_set_flag(&csth.spy, CHANSPY_TRIGGER_NONE);
-		ast_set_flag(&csth.spy, CHANSPY_MIXAUDIO);
-		csth.spy.type = chanspy_spy_type;
-		csth.spy.status = CHANSPY_RUNNING;
-		csth.spy.read_queue.format = AST_FORMAT_SLINEAR;
-		csth.spy.write_queue.format = AST_FORMAT_SLINEAR;
-		ast_mutex_init(&csth.spy.lock);
-		csth.volfactor = *volfactor;
-		set_volume(chan, &csth);
-		csth.spy.read_vol_adjustment = csth.volfactor;
-		csth.spy.write_vol_adjustment = csth.volfactor;
-		csth.fd = fd;
-
-		if (start_spying(spyee, chan, &csth.spy))
+	struct ast_silence_generator *silgen = NULL;
+
+	if (ast_check_hangup(chan) || ast_check_hangup(spyee))
+		return 0;
+
+	name = ast_strdupa(spyee->name);
+	if (option_verbose >= 2)
+		ast_verbose(VERBOSE_PREFIX_2 "Spying on channel %s\n", name);
+
+	memset(&csth, 0, sizeof(csth));
+	ast_set_flag(&csth.spy, CHANSPY_FORMAT_AUDIO);
+	ast_set_flag(&csth.spy, CHANSPY_TRIGGER_NONE);
+	ast_set_flag(&csth.spy, CHANSPY_MIXAUDIO);
+	csth.spy.type = "ChanSpy";
+	csth.spy.status = CHANSPY_RUNNING;
+	csth.spy.read_queue.format = AST_FORMAT_SLINEAR;
+	csth.spy.write_queue.format = AST_FORMAT_SLINEAR;
+	ast_mutex_init(&csth.spy.lock);
+	csth.volfactor = *volfactor;
+	set_volume(chan, &csth);
+	csth.fd = fd;
+	
+	if (start_spying(spyee, chan, &csth.spy)) {
+		ast_mutex_destroy(&csth.spy.lock);
+		return 0;
+	}
+
+	if (ast_test_flag(flags, OPTION_WHISPER)) {
+		struct ast_filestream *beepstream;
+
+		ast_channel_whisper_start(csth.spy.chan);
+		if ((beepstream = ast_openstream_full(chan, "beep", chan->language, 1))) {
+			struct ast_frame *f;
+
+			while ((f = ast_readframe(beepstream))) {
+				ast_channel_whisper_feed(csth.spy.chan, f);
+				ast_frfree(f);
+			}
+
+			ast_closestream(beepstream);
+		}
+	}
+
+	if (ast_test_flag(flags, OPTION_PRIVATE))
+		silgen = ast_channel_start_silence_generator(chan);
+	else
+		ast_activate_generator(chan, &spygen, &csth);
+
+	/* We can no longer rely on 'spyee' being an actual channel;
+	   it can be hung up and freed out from under us. However, the
+	   channel destructor will put NULL into our csth.spy.chan
+	   field when that happens, so that is our signal that the spyee
+	   channel has gone away.
+	*/
+
+	/* Note: it is very important that the ast_waitfor() be the first
+	   condition in this expression, so that if we wait for some period
+	   of time before receiving a frame from our spying channel, we check
+	   for hangup on the spied-on channel _after_ knowing that a frame
+	   has arrived, since the spied-on channel could have gone away while
+	   we were waiting
+	*/
+	while ((res = ast_waitfor(chan, -1) > -1) &&
+	       csth.spy.status == CHANSPY_RUNNING &&
+	       !ast_check_hangup(chan) &&
+	       csth.spy.chan) {
+		if (!(f = ast_read(chan)))
+			break;
+
+		if (ast_test_flag(flags, OPTION_WHISPER) &&
+		    (f->frametype == AST_FRAME_VOICE)) {
+			ast_channel_whisper_feed(csth.spy.chan, f);
+			ast_frfree(f);
+			continue;
+		}
+
+		res = (f->frametype == AST_FRAME_DTMF) ? f->subclass : 0;
+		ast_frfree(f);
+		if (!res)
+			continue;
+
+		if (x == sizeof(inp))
+			x = 0;
+
+		if (res < 0) {
+			running = -1;
+			break;
+		}
+
+		if (res == '*') {
 			running = 0;
-	}
-
-	if (running) {
-		running = 1;
-		ast_activate_generator(chan, &spygen, &csth);
-
-		while (csth.spy.status == CHANSPY_RUNNING &&
-		       chan && !ast_check_hangup(chan) &&
-		       spyee &&
-		       !ast_check_hangup(spyee) &&
-		       running == 1 &&
-		       (res = ast_waitfor(chan, -1) > -1)) {
-			if ((f = ast_read(chan))) {
-				res = 0;
-				if (f->frametype == AST_FRAME_DTMF) {
-					res = f->subclass;
-				}
-				ast_frfree(f);
-				if (!res) {
-					continue;
-				}
-			} else {
+			break;
+		} else if (res == '#') {
+			if (!ast_strlen_zero(inp)) {
+				running = atoi(inp);
 				break;
 			}
-			if (x == sizeof(inp)) {
-				x = 0;
+
+			(*volfactor)++;
+			if (*volfactor > 4)
+				*volfactor = -4;
+			if (option_verbose > 2)
+				ast_verbose(VERBOSE_PREFIX_3 "Setting spy volume on %s to %d\n", chan->name, *volfactor);
+			csth.volfactor = *volfactor;
+			set_volume(chan, &csth);
+		} else if (res >= '0' && res <= '9') {
+			inp[x++] = res;
+		}
+	}
+
+	if (ast_test_flag(flags, OPTION_WHISPER) && csth.spy.chan)
+		ast_channel_whisper_stop(csth.spy.chan);
+
+	if (ast_test_flag(flags, OPTION_PRIVATE))
+		ast_channel_stop_silence_generator(chan, silgen);
+	else
+		ast_deactivate_generator(chan);
+
+	stop_spying(&csth.spy);
+	
+	if (option_verbose >= 2)
+		ast_verbose(VERBOSE_PREFIX_2 "Done Spying on channel %s\n", name);
+	
+	ast_mutex_destroy(&csth.spy.lock);
+
+	return running;
+}
+
+static struct ast_channel *next_channel(const struct ast_channel *last, const char *spec,
+					const char *exten, const char *context)
+{
+	struct ast_channel *this;
+
+	if (spec)
+		this = ast_walk_channel_by_name_prefix_locked(last, spec, strlen(spec));
+	else if (exten)
+		this = ast_walk_channel_by_exten_locked(last, exten, context);
+	else
+		this = ast_channel_walk_locked(last);
+
+	if (this)
+		ast_channel_unlock(this);
+
+	return this;
+}
+
+static int common_exec(struct ast_channel *chan, const struct ast_flags *flags,
+		       int volfactor, const int fd, const char *mygroup, const char *spec,
+		       const char *exten, const char *context)
+{
+	struct ast_channel *peer, *prev, *next;
+	char nameprefix[AST_NAME_STRLEN];
+	char peer_name[AST_NAME_STRLEN + 5];
+	signed char zero_volume = 0;
+	int waitms;
+	int res;
+	char *ptr;
+	int num;
+
+	if (chan->_state != AST_STATE_UP)
+		ast_answer(chan);
+
+	ast_set_flag(chan, AST_FLAG_SPYING); /* so nobody can spy on us while we are spying */
+
+	waitms = 100;
+
+	for (;;) {
+		if (!ast_test_flag(flags, OPTION_QUIET)) {
+			res = ast_streamfile(chan, "beep", chan->language);
+			if (!res)
+				res = ast_waitstream(chan, "");
+			else if (res < 0) {
+				ast_clear_flag(chan, AST_FLAG_SPYING);
+				break;
 			}
-			if (res < 0) {
-				running = -1;
+		}
+
+		res = ast_waitfordigit(chan, waitms);
+		if (res < 0) {
+			ast_clear_flag(chan, AST_FLAG_SPYING);
+			break;
+		}
+				
+		/* reset for the next loop around, unless overridden later */
+		waitms = 100;
+		peer = prev = next = NULL;
+
+		for (peer = next_channel(peer, spec, exten, context);
+		     peer;
+		     prev = peer, peer = next ? next : next_channel(peer, spec, exten, context), next = NULL) {
+			const char *group;
+			int igrp = !mygroup;
+			char *groups[25];
+			int num_groups = 0;
+			char *dup_group;
+			int x;
+			char *s;
+				
+			if (peer == prev)
+				break;
+
+			if (peer == chan)
+				continue;
+
+			if (ast_test_flag(flags, OPTION_BRIDGED) && !ast_bridged_channel(peer))
+				continue;
+
+			if (ast_check_hangup(peer) || ast_test_flag(peer, AST_FLAG_SPYING))
+				continue;
+
+			if (mygroup) {
+				if ((group = pbx_builtin_getvar_helper(peer, "SPYGROUP"))) {
+					dup_group = ast_strdupa(group);
+					num_groups = ast_app_separate_args(dup_group, ':', groups,
+									   sizeof(groups) / sizeof(groups[0]));
+				}
+				
+				for (x = 0; x < num_groups; x++) {
+					if (!strcmp(mygroup, groups[x])) {
+						igrp = 1;
+						break;
+					}
+				}
 			}
-			if (res == 0) {
+			
+			if (!igrp)
 				continue;
-			} else if (res == '*') {
-				running = 0; 
-			} else if (res == '#') {
-				if (!ast_strlen_zero(inp)) {
-					running = x ? atoi(inp) : -1;
-					break;
+
+			strcpy(peer_name, "spy-");
+			strncat(peer_name, peer->name, AST_NAME_STRLEN);
+			ptr = strchr(peer_name, '/');
+			*ptr++ = '\0';
+			
+			for (s = peer_name; s < ptr; s++)
+				*s = tolower(*s);
+			
+			if (!ast_test_flag(flags, OPTION_QUIET)) {
+				if (ast_fileexists(peer_name, NULL, NULL) != -1) {
+					res = ast_streamfile(chan, peer_name, chan->language);
+					if (!res)
+						res = ast_waitstream(chan, "");
+					if (res)
+						break;
+				} else
+					res = ast_say_character_str(chan, peer_name, "", chan->language);
+				if ((num = atoi(ptr))) 
+					ast_say_digits(chan, atoi(ptr), "", chan->language);
+			}
+			
+			waitms = 5000;
+			res = channel_spy(chan, peer, &volfactor, fd, flags);
+			
+			if (res == -1) {
+				break;
+			} else if (res > 1 && spec) {
+				snprintf(nameprefix, AST_NAME_STRLEN, "%s/%d", spec, res);
+				if ((next = ast_get_channel_by_name_prefix_locked(nameprefix, strlen(nameprefix)))) {
+					ast_channel_unlock(next);
 				} else {
-					(*volfactor)++;
-					if (*volfactor > 4) {
-						*volfactor = -4;
-					}
-					if (option_verbose > 2) {
-						ast_verbose(VERBOSE_PREFIX_3 "Setting spy volume on %s to %d\n", chan->name, *volfactor);
-					}
-					csth.volfactor = *volfactor;
-					set_volume(chan, &csth);
-					csth.spy.read_vol_adjustment = csth.volfactor;
-					csth.spy.write_vol_adjustment = csth.volfactor;
+					/* stay on this channel */
+					next = peer;
 				}
-			} else if (res >= 48 && res <= 57) {
-				inp[x++] = res;
+				peer = NULL;
 			}
 		}
-		ast_deactivate_generator(chan);
-		stop_spying(spyee, &csth.spy);
-
-		if (option_verbose >= 2) {
-			ast_verbose(VERBOSE_PREFIX_2 "Done Spying on channel %s\n", name);
-		}
-	} else {
-		running = 0;
-	}
-
-	ast_mutex_destroy(&csth.spy.lock);
-
-	return running;
+	}
+	
+	ast_clear_flag(chan, AST_FLAG_SPYING);
+
+	ast_channel_setoption(chan, AST_OPTION_TXGAIN, &zero_volume, sizeof(zero_volume), 0);
+
+	return res;
 }
 
 static int chanspy_exec(struct ast_channel *chan, void *data)
 {
 	struct ast_module_user *u;
-	struct ast_channel *peer=NULL, *prev=NULL;
-	char name[AST_NAME_STRLEN],
-		peer_name[AST_NAME_STRLEN + 5],
-		*args,
-		*ptr = NULL,
-		*options = NULL,
-		*spec = NULL,
-		*argv[5],
-		*mygroup = NULL,
-		*recbase = NULL;
-	int res = -1,
-		volfactor = 0,
-		silent = 0,
-		argc = 0,
-		bronly = 0,
-		chosen = 0,
-		count=0,
-		waitms = 100,
-		num = 0,
-		oldrf = 0,
-		oldwf = 0,
-		fd = 0;
+	char *options = NULL;
+	char *spec = NULL;
+	char *argv[2];
+	char *mygroup = NULL;
+	char *recbase = NULL;
+	int fd = 0;
 	struct ast_flags flags;
-	signed char zero_volume = 0;
-
-	if (!(args = ast_strdupa(data)))
-		return -1;
+	int oldwf = 0;
+	int argc = 0;
+	int volfactor = 0;
+	int res;
+
+	data = ast_strdupa(data);
 
 	u = ast_module_user_add(chan);
 
-	oldrf = chan->readformat;
+	if ((argc = ast_app_separate_args(data, '|', argv, sizeof(argv) / sizeof(argv[0])))) {
+		spec = argv[0];
+		if (argc > 1)
+			options = argv[1];
+
+		if (ast_strlen_zero(spec) || !strcmp(spec, "all"))
+			spec = NULL;
+	}
+
+	if (options) {
+		char *opts[OPT_ARG_ARRAY_SIZE];
+		
+		ast_app_parse_options(spy_opts, &flags, opts, options);
+		if (ast_test_flag(&flags, OPTION_GROUP))
+			mygroup = opts[OPT_ARG_GROUP];
+
+		if (ast_test_flag(&flags, OPTION_RECORD) &&
+		    !(recbase = opts[OPT_ARG_RECORD]))
+			recbase = "chanspy";
+
+		if (ast_test_flag(&flags, OPTION_VOLUME) && opts[OPT_ARG_VOLUME]) {
+			int vol;
+
+			if ((sscanf(opts[OPT_ARG_VOLUME], "%d", &vol) != 1) || (vol > 4) || (vol < -4))
+				ast_log(LOG_NOTICE, "Volume factor must be a number between -4 and 4\n");
+			else
+				volfactor = vol;
+		}
+
+		if (ast_test_flag(&flags, OPTION_PRIVATE))
+			ast_set_flag(&flags, OPTION_WHISPER);
+	}
+
 	oldwf = chan->writeformat;
-	if (ast_set_read_format(chan, AST_FORMAT_SLINEAR) < 0) {
-		ast_log(LOG_ERROR, "Could Not Set Read Format.\n");
-		ast_module_user_remove(u);
-		return -1;
-	}
-	
 	if (ast_set_write_format(chan, AST_FORMAT_SLINEAR) < 0) {
 		ast_log(LOG_ERROR, "Could Not Set Write Format.\n");
 		ast_module_user_remove(u);
 		return -1;
 	}
 
-	ast_answer(chan);
-
-	ast_set_flag(chan, AST_FLAG_SPYING); /* so nobody can spy on us while we are spying */
-
-	if ((argc = ast_app_separate_args(args, '|', argv, sizeof(argv) / sizeof(argv[0])))) {
-		spec = argv[0];
-		if ( argc > 1) {
+	if (recbase) {
+		char filename[512];
+
+		snprintf(filename, sizeof(filename), "%s/%s.%d.raw", ast_config_AST_MONITOR_DIR, recbase, (int) time(NULL));
+		if ((fd = open(filename, O_CREAT | O_WRONLY | O_TRUNC, 0644)) <= 0) {
+			ast_log(LOG_WARNING, "Cannot open '%s' for recording\n", filename);
+			fd = 0;
+		}
+	}
+
+	res = common_exec(chan, &flags, volfactor, fd, mygroup, spec, NULL, NULL);
+
+	if (fd)
+		close(fd);
+
+	if (oldwf && ast_set_write_format(chan, oldwf) < 0)
+		ast_log(LOG_ERROR, "Could Not Set Write Format.\n");
+
+	ast_module_user_remove(u);
+
+	return res;
+}
+
+static int extenspy_exec(struct ast_channel *chan, void *data)
+{
+	struct ast_module_user *u;
+	char *options = NULL;
+	char *exten = NULL;
+	char *context = NULL;
+	char *argv[2];
+	char *mygroup = NULL;
+	char *recbase = NULL;
+	int fd = 0;
+	struct ast_flags flags;
+	int oldwf = 0;
+	int argc = 0;
+	int volfactor = 0;
+	int res;
+
+	data = ast_strdupa(data);
+
+	u = ast_module_user_add(chan);
+
+	if ((argc = ast_app_separate_args(data, '|', argv, sizeof(argv) / sizeof(argv[0])))) {
+		context = argv[0];
+		exten = strsep(&context, "@");
+		if (ast_strlen_zero(context))
+			context = ast_strdupa(chan->context);
+		if (argc > 1)
 			options = argv[1];
-		}
-		if (ast_strlen_zero(spec) || !strcmp(spec, "all")) {
-			spec = NULL;
-		}
 	}
 
 	if (options) {
 		char *opts[OPT_ARG_ARRAY_SIZE];
-		ast_app_parse_options(chanspy_opts, &flags, opts, options);
-		if (ast_test_flag(&flags, OPTION_GROUP)) {
-			mygroup = opts[1];
-		}
-		if (ast_test_flag(&flags, OPTION_RECORD)) {
-			if (!(recbase = opts[2])) {
-				recbase = "chanspy";
-			}
-		}
-		silent = ast_test_flag(&flags, OPTION_QUIET);
-		bronly = ast_test_flag(&flags, OPTION_BRIDGED);
-		if (ast_test_flag(&flags, OPTION_VOLUME) && opts[1]) {
+		
+		ast_app_parse_options(spy_opts, &flags, opts, options);
+		if (ast_test_flag(&flags, OPTION_GROUP))
+			mygroup = opts[OPT_ARG_GROUP];
+
+		if (ast_test_flag(&flags, OPTION_RECORD) &&
+		    !(recbase = opts[OPT_ARG_RECORD]))
+			recbase = "chanspy";
+
+		if (ast_test_flag(&flags, OPTION_VOLUME) && opts[OPT_ARG_VOLUME]) {
 			int vol;
 
-			if ((sscanf(opts[0], "%d", &vol) != 1) || (vol > 4) || (vol < -4))
+			if ((sscanf(opts[OPT_ARG_VOLUME], "%d", &vol) != 1) || (vol > 4) || (vol < -4))

[... 19029 lines stripped ...]


More information about the asterisk-commits mailing list