[asterisk-commits] mogorman: branch mogorman/asterisk-jabber r42801 - in /team/mogorman/asterisk...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Mon Sep 11 16:02:03 MST 2006


Author: mogorman
Date: Mon Sep 11 18:02:02 2006
New Revision: 42801

URL: http://svn.digium.com/view/asterisk?rev=42801&view=rev
Log:
brought to trunk, should merge tonight.

Modified:
    team/mogorman/asterisk-jabber/   (props changed)
    team/mogorman/asterisk-jabber/LICENSE
    team/mogorman/asterisk-jabber/Makefile
    team/mogorman/asterisk-jabber/Makefile.moddir_rules
    team/mogorman/asterisk-jabber/Makefile.rules
    team/mogorman/asterisk-jabber/README
    team/mogorman/asterisk-jabber/UPGRADE.txt
    team/mogorman/asterisk-jabber/agi/Makefile
    team/mogorman/asterisk-jabber/apps/app_amd.c
    team/mogorman/asterisk-jabber/apps/app_authenticate.c
    team/mogorman/asterisk-jabber/apps/app_chanspy.c
    team/mogorman/asterisk-jabber/apps/app_dial.c
    team/mogorman/asterisk-jabber/apps/app_followme.c
    team/mogorman/asterisk-jabber/apps/app_meetme.c
    team/mogorman/asterisk-jabber/apps/app_mixmonitor.c
    team/mogorman/asterisk-jabber/apps/app_page.c
    team/mogorman/asterisk-jabber/apps/app_queue.c
    team/mogorman/asterisk-jabber/apps/app_read.c
    team/mogorman/asterisk-jabber/apps/app_record.c
    team/mogorman/asterisk-jabber/apps/app_voicemail.c
    team/mogorman/asterisk-jabber/apps/app_waitforsilence.c
    team/mogorman/asterisk-jabber/build_tools/cflags.xml
    team/mogorman/asterisk-jabber/channels/chan_alsa.c
    team/mogorman/asterisk-jabber/channels/chan_iax2.c
    team/mogorman/asterisk-jabber/channels/chan_local.c
    team/mogorman/asterisk-jabber/channels/chan_misdn.c
    team/mogorman/asterisk-jabber/channels/chan_oss.c
    team/mogorman/asterisk-jabber/channels/chan_sip.c
    team/mogorman/asterisk-jabber/channels/chan_skinny.c
    team/mogorman/asterisk-jabber/channels/chan_zap.c
    team/mogorman/asterisk-jabber/codecs/codec_gsm.c
    team/mogorman/asterisk-jabber/codecs/codec_ilbc.c
    team/mogorman/asterisk-jabber/codecs/codec_lpc10.c
    team/mogorman/asterisk-jabber/codecs/codec_speex.c
    team/mogorman/asterisk-jabber/configs/alsa.conf.sample
    team/mogorman/asterisk-jabber/configs/cdr.conf.sample
    team/mogorman/asterisk-jabber/configs/dundi.conf.sample
    team/mogorman/asterisk-jabber/configs/enum.conf.sample
    team/mogorman/asterisk-jabber/configs/extensions.ael.sample
    team/mogorman/asterisk-jabber/configs/extensions.conf.sample
    team/mogorman/asterisk-jabber/configs/features.conf.sample
    team/mogorman/asterisk-jabber/configs/iax.conf.sample
    team/mogorman/asterisk-jabber/configs/mgcp.conf.sample
    team/mogorman/asterisk-jabber/configs/misdn.conf.sample
    team/mogorman/asterisk-jabber/configs/osp.conf.sample
    team/mogorman/asterisk-jabber/configs/oss.conf.sample
    team/mogorman/asterisk-jabber/configs/phone.conf.sample
    team/mogorman/asterisk-jabber/configs/queues.conf.sample
    team/mogorman/asterisk-jabber/configs/sip.conf.sample
    team/mogorman/asterisk-jabber/configs/skinny.conf.sample
    team/mogorman/asterisk-jabber/configs/smdi.conf.sample
    team/mogorman/asterisk-jabber/configs/voicemail.conf.sample
    team/mogorman/asterisk-jabber/configs/vpb.conf.sample
    team/mogorman/asterisk-jabber/configs/zapata.conf.sample
    team/mogorman/asterisk-jabber/doc/CODING-GUIDELINES
    team/mogorman/asterisk-jabber/doc/ael.txt
    team/mogorman/asterisk-jabber/doc/app-sms.txt
    team/mogorman/asterisk-jabber/doc/asterisk-conf.txt
    team/mogorman/asterisk-jabber/doc/backtrace.txt
    team/mogorman/asterisk-jabber/doc/billing.txt
    team/mogorman/asterisk-jabber/doc/callfiles.txt
    team/mogorman/asterisk-jabber/doc/chaniax.txt
    team/mogorman/asterisk-jabber/doc/configuration.txt
    team/mogorman/asterisk-jabber/doc/cygwin.txt
    team/mogorman/asterisk-jabber/doc/dundi.txt
    team/mogorman/asterisk-jabber/doc/enum.txt
    team/mogorman/asterisk-jabber/doc/extensions.txt
    team/mogorman/asterisk-jabber/doc/imapstorage.txt
    team/mogorman/asterisk-jabber/doc/ip-tos.txt
    team/mogorman/asterisk-jabber/doc/jabber.txt
    team/mogorman/asterisk-jabber/doc/manager.txt
    team/mogorman/asterisk-jabber/doc/misdn.txt
    team/mogorman/asterisk-jabber/doc/osp.txt
    team/mogorman/asterisk-jabber/doc/queues-with-callback-members.txt
    team/mogorman/asterisk-jabber/doc/sms.txt
    team/mogorman/asterisk-jabber/doc/speechrec.txt
    team/mogorman/asterisk-jabber/funcs/func_curl.c
    team/mogorman/asterisk-jabber/funcs/func_odbc.c
    team/mogorman/asterisk-jabber/funcs/func_strings.c
    team/mogorman/asterisk-jabber/include/asterisk/chanspy.h
    team/mogorman/asterisk-jabber/include/asterisk/frame.h
    team/mogorman/asterisk-jabber/main/cdr.c
    team/mogorman/asterisk-jabber/main/channel.c
    team/mogorman/asterisk-jabber/main/file.c
    team/mogorman/asterisk-jabber/main/frame.c
    team/mogorman/asterisk-jabber/main/logger.c
    team/mogorman/asterisk-jabber/main/pbx.c
    team/mogorman/asterisk-jabber/main/rtp.c
    team/mogorman/asterisk-jabber/main/utils.c
    team/mogorman/asterisk-jabber/res/res_adsi.c
    team/mogorman/asterisk-jabber/res/res_agi.c
    team/mogorman/asterisk-jabber/res/res_jabber.c
    team/mogorman/asterisk-jabber/utils/Makefile

Propchange: team/mogorman/asterisk-jabber/
------------------------------------------------------------------------------
Binary property 'branch-1.2-blocked' - no diff available.

Propchange: team/mogorman/asterisk-jabber/
------------------------------------------------------------------------------
Binary property 'branch-1.2-merged' - no diff available.

Propchange: team/mogorman/asterisk-jabber/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Mon Sep 11 18:02:02 2006
@@ -1,1 +1,1 @@
-/trunk:1-41651
+/trunk:1-42788

Modified: team/mogorman/asterisk-jabber/LICENSE
URL: http://svn.digium.com/view/asterisk/team/mogorman/asterisk-jabber/LICENSE?rev=42801&r1=42800&r2=42801&view=diff
==============================================================================
--- team/mogorman/asterisk-jabber/LICENSE (original)
+++ team/mogorman/asterisk-jabber/LICENSE Mon Sep 11 18:02:02 2006
@@ -38,7 +38,8 @@
 wish to use these trademarks for purposes other than simple
 redistribution of Asterisk source code obtained from Digium, you
 should contact our licensing department to determine the necessary
-steps you must take.
+steps you must take. For more information on this policy, please read
+http://www.digium.com/en/company/profile/trademarkpolicy.php
 
 If you have any questions regarding our licensing policy, please
 contact us:

Modified: team/mogorman/asterisk-jabber/Makefile
URL: http://svn.digium.com/view/asterisk/team/mogorman/asterisk-jabber/Makefile?rev=42801&r1=42800&r2=42801&view=diff
==============================================================================
--- team/mogorman/asterisk-jabber/Makefile (original)
+++ team/mogorman/asterisk-jabber/Makefile Mon Sep 11 18:02:02 2006
@@ -22,7 +22,12 @@
 
 .EXPORT_ALL_VARIABLES:
 
-include makeopts
+# even though we could use '-include makeopts' here, use a wildcard
+# lookup anyway, so that make won't try to build makeopts if it doesn't
+# exist (other rules will force it to be built if needed)
+ifneq ($(wildcard makeopts),)
+  include makeopts
+endif
 
 #Uncomment this to see all build commands instead of 'quiet' output
 #NOISY_BUILD=yes
@@ -235,9 +240,8 @@
 
 all: cleantest $(SUBDIRS)
 	@echo " +--------- Asterisk Build Complete ---------+"  
-	@echo " + Asterisk has successfully been built, but +"  
-	@echo " + cannot be run before being installed by   +"  
-	@echo " + running:                                  +"  
+	@echo " + Asterisk has successfully been built, and +"  
+	@echo " + can be installed by running:              +"
 	@echo " +                                           +"
 	@echo " +               make install                +"  
 	@echo " +-------------------------------------------+"  
@@ -316,6 +320,7 @@
 	rm -f include/asterisk/version.h
 	rm -f .depend
 	@$(MAKE) -C menuselect clean
+	cp -f .cleancount .lastclean
 
 dist-clean: distclean
 
@@ -604,8 +609,7 @@
 
 cleantest:
 	@if ! cmp -s .cleancount .lastclean ; then \
-		$(MAKE) clean; cp -f .cleancount .lastclean;\
-		$(MAKE) defaults.h;\
+		$(MAKE) clean;\
 	fi
 
 $(SUBDIRS_UNINSTALL):

Modified: team/mogorman/asterisk-jabber/Makefile.moddir_rules
URL: http://svn.digium.com/view/asterisk/team/mogorman/asterisk-jabber/Makefile.moddir_rules?rev=42801&r1=42800&r2=42801&view=diff
==============================================================================
--- team/mogorman/asterisk-jabber/Makefile.moddir_rules (original)
+++ team/mogorman/asterisk-jabber/Makefile.moddir_rules Mon Sep 11 18:02:02 2006
@@ -95,7 +95,9 @@
 
 uninstall::
 
--include .depend
+ifneq ($(wildcard .depend),)
+  include .depend
+endif
 
 depend: .depend
 

Modified: team/mogorman/asterisk-jabber/Makefile.rules
URL: http://svn.digium.com/view/asterisk/team/mogorman/asterisk-jabber/Makefile.rules?rev=42801&r1=42800&r2=42801&view=diff
==============================================================================
--- team/mogorman/asterisk-jabber/Makefile.rules (original)
+++ team/mogorman/asterisk-jabber/Makefile.rules Mon Sep 11 18:02:02 2006
@@ -15,7 +15,7 @@
 # Prefixing one or the other with @\# or @ or nothing makes the desired
 # behaviour. ECHO_PREFIX prefixes the comment, CMD_PREFIX prefixes the command.
 
-include $(ASTTOPDIR)/makeopts
+-include $(ASTTOPDIR)/makeopts
 
 ifeq ($(NOISY_BUILD),)
    ECHO_PREFIX=@

Modified: team/mogorman/asterisk-jabber/README
URL: http://svn.digium.com/view/asterisk/team/mogorman/asterisk-jabber/README?rev=42801&r1=42800&r2=42801&view=diff
==============================================================================
--- team/mogorman/asterisk-jabber/README (original)
+++ team/mogorman/asterisk-jabber/README Mon Sep 11 18:02:02 2006
@@ -1,4 +1,4 @@
-The Asterisk Open Source PBX
+The Asterisk(R) Open Source PBX
 by Mark Spencer <markster at digium.com>
 and the Asterisk.org developer community
 
@@ -247,3 +247,6 @@
   Welcome to the growing worldwide community of Asterisk users!
 
 Mark Spencer
+
+----
+Asterisk is a trademark belonging to Digium, inc

Modified: team/mogorman/asterisk-jabber/UPGRADE.txt
URL: http://svn.digium.com/view/asterisk/team/mogorman/asterisk-jabber/UPGRADE.txt?rev=42801&r1=42800&r2=42801&view=diff
==============================================================================
--- team/mogorman/asterisk-jabber/UPGRADE.txt (original)
+++ team/mogorman/asterisk-jabber/UPGRADE.txt Mon Sep 11 18:02:02 2006
@@ -216,6 +216,12 @@
   previously used only by EXTENDED_ODBC_STORAGE. This means that you will need to update
   your table format using the schema provided in doc/odbcstorage.txt
 
+* app_waitforsilence: Fixes have been made to this application which changes the 
+  default behavior with how quickly it returns. You can maintain "old-style" behavior
+  with the addition/use of a third "timeout" parameter.
+  Please consult the application documentation and make changes to your dialplan 
+  if appropriate.
+
 Manager:
 
 * After executing the 'status' manager action, the "Status" manager events

Modified: team/mogorman/asterisk-jabber/agi/Makefile
URL: http://svn.digium.com/view/asterisk/team/mogorman/asterisk-jabber/agi/Makefile?rev=42801&r1=42800&r2=42801&view=diff
==============================================================================
--- team/mogorman/asterisk-jabber/agi/Makefile (original)
+++ team/mogorman/asterisk-jabber/agi/Makefile Mon Sep 11 18:02:02 2006
@@ -40,7 +40,9 @@
 clean: clean-depend
 	rm -f *.so *.o look eagi-test eagi-sphinx-test
 
--include .depend
+ifneq ($(wildcard .depend),)
+  include .depend
+endif
 
 depend: .depend
 

Modified: team/mogorman/asterisk-jabber/apps/app_amd.c
URL: http://svn.digium.com/view/asterisk/team/mogorman/asterisk-jabber/apps/app_amd.c?rev=42801&r1=42800&r2=42801&view=diff
==============================================================================
--- team/mogorman/asterisk-jabber/apps/app_amd.c (original)
+++ team/mogorman/asterisk-jabber/apps/app_amd.c Mon Sep 11 18:02:02 2006
@@ -88,26 +88,21 @@
 
 static void isAnsweringMachine(struct ast_channel *chan, void *data)
 {
-	int res = 0, ret = 0;
-
+	int res = 0;
 	struct ast_frame *f = NULL;
-
-	struct ast_dsp *silenceDetector;         /* silence detector dsp */
-	int dspsilence = 0;
-	int readFormat;
-	int framelength;
-
-	int inInitialSilence         = 1;
-	int inGreeting               = 0;
-	int voiceDuration            = 0;
-	int silenceDuration          = 0;
-	int iTotalTime               = 0;
-	int iWordsCount              = 0;
-	int currentState             = STATE_IN_SILENCE;
-	int previousState            = STATE_IN_SILENCE;
+	struct ast_dsp *silenceDetector = NULL;
+	int dspsilence = 0, readFormat, framelength;
+	int inInitialSilence = 1;
+	int inGreeting = 0;
+	int voiceDuration = 0;
+	int silenceDuration = 0;
+	int iTotalTime = 0;
+	int iWordsCount = 0;
+	int currentState = STATE_IN_SILENCE;
+	int previousState = STATE_IN_SILENCE;
 	int consecutiveVoiceDuration = 0;
-	char amdCause[256]           = "";
-	char amdStatus[256]          = "";
+	char amdCause[256] = "", amdStatus[256] = "";
+	char *parse = ast_strdupa(data);
 
 	/* Lets set the initial values of the variables that will control the algorithm.
 	   The initial values are the default ones. If they are passed as arguments
@@ -122,7 +117,6 @@
 	int maximumNumberOfWords = dfltMaximumNumberOfWords;
 	int silenceThreshold     = dfltSilenceThreshold;
 
-	char *parse;
 	AST_DECLARE_APP_ARGS(args,
 			     AST_APP_ARG(argInitialSilence);
 			     AST_APP_ARG(argGreeting);
@@ -133,98 +127,92 @@
 			     AST_APP_ARG(argMaximumNumberOfWords);
 			     AST_APP_ARG(argSilenceThreshold);
 	);
+
 	if (option_verbose > 2)
 		ast_verbose(VERBOSE_PREFIX_3 "AMD: %s %s %s (Fmt: %d)\n", chan->name ,chan->cid.cid_ani, chan->cid.cid_rdnis, chan->readformat);
 
 	/* Lets parse the arguments. */
-	if (ast_strlen_zero(data)) {
+	if (!ast_strlen_zero(parse)) {
+		/* Some arguments have been passed. Lets parse them and overwrite the defaults. */
+		AST_STANDARD_APP_ARGS(args, parse);
+		if (!ast_strlen_zero(args.argInitialSilence))
+			initialSilence = atoi(args.argInitialSilence);
+		if (!ast_strlen_zero(args.argGreeting))
+			greeting = atoi(args.argGreeting);
+		if (!ast_strlen_zero(args.argAfterGreetingSilence))
+			afterGreetingSilence = atoi(args.argAfterGreetingSilence);
+		if (!ast_strlen_zero(args.argTotalAnalysisTime))
+			totalAnalysisTime = atoi(args.argTotalAnalysisTime);
+		if (!ast_strlen_zero(args.argMinimumWordLength))
+			minimumWordLength = atoi(args.argMinimumWordLength);
+		if (!ast_strlen_zero(args.argBetweenWordsSilence))
+			betweenWordsSilence = atoi(args.argBetweenWordsSilence);
+		if (!ast_strlen_zero(args.argMaximumNumberOfWords))
+			maximumNumberOfWords = atoi(args.argMaximumNumberOfWords);
+		if (!ast_strlen_zero(args.argSilenceThreshold))
+			silenceThreshold = atoi(args.argSilenceThreshold);
+	} else
 		ast_log(LOG_NOTICE, "AMD using the default parameters.\n");
-	} else {
-		/* Some arguments have been passed. Lets parse them and overwrite the defaults. */
-		parse = ast_strdupa(data);
-
-		AST_STANDARD_APP_ARGS(args, parse);
-
-		if (!ast_strlen_zero(args.argInitialSilence)) {
-			initialSilence = atoi(args.argInitialSilence);
-		}
-		if (!ast_strlen_zero(args.argGreeting)) {
-			greeting = atoi(args.argGreeting);
-		}
-		if (!ast_strlen_zero(args.argAfterGreetingSilence)) {
-			afterGreetingSilence = atoi(args.argAfterGreetingSilence);
-		}
-		if (!ast_strlen_zero(args.argTotalAnalysisTime)) {
-			totalAnalysisTime = atoi(args.argTotalAnalysisTime);
-		}
-		if (!ast_strlen_zero(args.argMinimumWordLength)) {
-			minimumWordLength = atoi(args.argMinimumWordLength);
-		}
-		if (!ast_strlen_zero(args.argBetweenWordsSilence)) {
-			betweenWordsSilence = atoi(args.argBetweenWordsSilence);
-		}
-		if (!ast_strlen_zero(args.argMaximumNumberOfWords)) {
-			maximumNumberOfWords = atoi(args.argMaximumNumberOfWords);
-		}
-		if (!ast_strlen_zero(args.argSilenceThreshold)) {
-			silenceThreshold = atoi(args.argSilenceThreshold);
-		}
-	}
 
 	/* Now we're ready to roll! */
-	
 	if (option_verbose > 2)
 		ast_verbose(VERBOSE_PREFIX_3 "AMD: initialSilence [%d] greeting [%d] afterGreetingSilence [%d] "
 		"totalAnalysisTime [%d] minimumWordLength [%d] betweenWordsSilence [%d] maximumNumberOfWords [%d] silenceThreshold [%d] \n",
 				initialSilence, greeting, afterGreetingSilence, totalAnalysisTime,
 				minimumWordLength, betweenWordsSilence, maximumNumberOfWords, silenceThreshold );
 
+	/* Set read format to signed linear so we get signed linear frames in */
 	readFormat = chan->readformat;
-	res = ast_set_read_format(chan, AST_FORMAT_SLINEAR);
-	if (res < 0 ) {
+	if (ast_set_read_format(chan, AST_FORMAT_SLINEAR) < 0 ) {
 		ast_log(LOG_WARNING, "AMD: Channel [%s]. Unable to set to linear mode, giving up\n", chan->name );
-		pbx_builtin_setvar_helper(chan , "AMDSTATUS" , "" );
-		pbx_builtin_setvar_helper(chan , "AMDCAUSE" , "" );
+		pbx_builtin_setvar_helper(chan , "AMDSTATUS", "");
+		pbx_builtin_setvar_helper(chan , "AMDCAUSE", "");
 		return;
 	}
 
-	silenceDetector = ast_dsp_new();
-	if (!silenceDetector ) {
+	/* Create a new DSP that will detect the silence */
+	if (!(silenceDetector = ast_dsp_new())) {
 		ast_log(LOG_WARNING, "AMD: Channel [%s]. Unable to create silence detector :(\n", chan->name );
-		pbx_builtin_setvar_helper(chan , "AMDSTATUS" , "" );
-		pbx_builtin_setvar_helper(chan , "AMDCAUSE" , "" );
+		pbx_builtin_setvar_helper(chan , "AMDSTATUS", "");
+		pbx_builtin_setvar_helper(chan , "AMDCAUSE", "");
 		return;
 	}
-	ast_dsp_set_threshold(silenceDetector, silenceThreshold );
-
-	while ((ret = ast_waitfor(chan, totalAnalysisTime)))
-	{
-		if (ret < 0 || !(f = ast_read(chan))) {
-			/* No Frame OR Error on ast_waitfor : Called Party Must Have Dropped */
+
+	/* Set silence threshold to specified value */
+	ast_dsp_set_threshold(silenceDetector, silenceThreshold);
+
+	/* Now we go into a loop waiting for frames from the channel */
+	while ((res = ast_waitfor(chan, totalAnalysisTime)) > -1) {
+		/* If we fail to read in a frame, that means they hung up */
+		if (!(f = ast_read(chan))) {
 			if (option_verbose > 2)
 				ast_verbose(VERBOSE_PREFIX_3 "AMD: HANGUP\n");
 			if (option_debug)
 				ast_log(LOG_DEBUG, "Got hangup\n");
-			strcpy(amdStatus , "HANGUP" );
-			strcpy(amdCause , "" );
+			strcpy(amdStatus, "HANGUP");
 			break;
 		}
-		if (f->frametype == AST_FRAME_VOICE ) {
+
+		if (f->frametype == AST_FRAME_VOICE) {
+			/* If the total time exceeds the analysis time then give up as we are not too sure */
 			framelength = (ast_codec_get_samples(f) / DEFAULT_SAMPLES_PER_MS);
 			iTotalTime += framelength;
-			if (iTotalTime >= totalAnalysisTime ) {
+			if (iTotalTime >= totalAnalysisTime) {
 				if (option_verbose > 2)	
 					ast_verbose(VERBOSE_PREFIX_3 "AMD: Channel [%s]. Too long...\n", chan->name );
 				ast_frfree(f);
-				strcpy(amdStatus , "NOTSURE" );
-				sprintf(amdCause , "TOOLONG-%d", iTotalTime );
+				strcpy(amdStatus , "NOTSURE");
+				sprintf(amdCause , "TOOLONG-%d", iTotalTime);
 				break;
 			}
+
+			/* Feed the frame of audio into the silence detector and see if we get a result */
 			dspsilence = 0;
 			ast_dsp_silence(silenceDetector, f, &dspsilence);
-			if (dspsilence ) {
+			if (dspsilence) {
 				silenceDuration = dspsilence;
-				if (silenceDuration >= betweenWordsSilence ) {
+				
+				if (silenceDuration >= betweenWordsSilence) {
 					if (currentState != STATE_IN_SILENCE ) {
 						previousState = currentState;
 						if (option_verbose > 2)
@@ -233,87 +221,88 @@
 					currentState  = STATE_IN_SILENCE;
 					consecutiveVoiceDuration = 0;
 				}
-				if (inInitialSilence == 1  && silenceDuration >= initialSilence ) {
+				
+				if (inInitialSilence == 1  && silenceDuration >= initialSilence) {
 					if (option_verbose > 2)
 						ast_verbose(VERBOSE_PREFIX_3 "AMD: ANSWERING MACHINE: silenceDuration:%d initialSilence:%d\n",
-							silenceDuration, initialSilence );
+							    silenceDuration, initialSilence);
 					ast_frfree(f);
-					strcpy(amdStatus , "MACHINE" );
-					sprintf(amdCause , "INITIALSILENCE-%d-%d", silenceDuration, initialSilence );
+					strcpy(amdStatus , "MACHINE");
+					sprintf(amdCause , "INITIALSILENCE-%d-%d", silenceDuration, initialSilence);
 					break;
 				}
-
-				if (silenceDuration >= afterGreetingSilence  &&  inGreeting == 1 ) {
+				
+				if (silenceDuration >= afterGreetingSilence  &&  inGreeting == 1) {
 					if (option_verbose > 2)
 						ast_verbose(VERBOSE_PREFIX_3 "AMD: HUMAN: silenceDuration:%d afterGreetingSilence:%d\n",
-							silenceDuration, afterGreetingSilence );
+							    silenceDuration, afterGreetingSilence);
 					ast_frfree(f);
-					strcpy(amdStatus , "HUMAN" );
-					sprintf(amdCause , "HUMAN-%d-%d", silenceDuration, afterGreetingSilence );
+					strcpy(amdStatus , "HUMAN");
+					sprintf(amdCause , "HUMAN-%d-%d", silenceDuration, afterGreetingSilence);
 					break;
 				}
+				
 			} else {
 				consecutiveVoiceDuration += framelength;
 				voiceDuration += framelength;
-
+				
 				/* If I have enough consecutive voice to say that I am in a Word, I can only increment the
-					number of words if my previous state was Silence, which means that I moved into a word. */
-				if (consecutiveVoiceDuration >= minimumWordLength ) {
-					if (currentState == STATE_IN_SILENCE ) {
-						iWordsCount++;
-						if (option_verbose > 2)
-							ast_verbose(VERBOSE_PREFIX_3 "AMD: Word detected. iWordsCount:%d\n", iWordsCount );
-						previousState = currentState;
-						currentState = STATE_IN_WORD;
-					}
-				}
-
-				if (iWordsCount >= maximumNumberOfWords ) {
-					if (option_verbose > 2)
-						ast_verbose(VERBOSE_PREFIX_3 "AMD: ANSWERING MACHINE: iWordsCount:%d\n", iWordsCount );
+				   number of words if my previous state was Silence, which means that I moved into a word. */
+				if (consecutiveVoiceDuration >= minimumWordLength && currentState == STATE_IN_SILENCE) {
+					iWordsCount++;
+					if (option_verbose > 2)
+						ast_verbose(VERBOSE_PREFIX_3 "AMD: Word detected. iWordsCount:%d\n", iWordsCount);
+					previousState = currentState;
+					currentState = STATE_IN_WORD;
+				}
+				
+				if (iWordsCount >= maximumNumberOfWords) {
+					if (option_verbose > 2)
+						ast_verbose(VERBOSE_PREFIX_3 "AMD: ANSWERING MACHINE: iWordsCount:%d\n", iWordsCount);
 					ast_frfree(f);
-					strcpy(amdStatus , "MACHINE" );
-					sprintf(amdCause , "MAXWORDS-%d-%d", iWordsCount, maximumNumberOfWords );
+					strcpy(amdStatus , "MACHINE");
+					sprintf(amdCause , "MAXWORDS-%d-%d", iWordsCount, maximumNumberOfWords);
 					break;
 				}
-
-				if (inGreeting == 1  &&  voiceDuration >= greeting ) {
-					if (option_verbose > 2)
-					ast_verbose(VERBOSE_PREFIX_3 "AMD: ANSWERING MACHINE: voiceDuration:%d greeting:%d\n", voiceDuration, greeting);
-					 ast_frfree(f);
-					strcpy(amdStatus , "MACHINE" );
-					sprintf(amdCause , "LONGGREETING-%d-%d", voiceDuration, greeting );
+				
+				if (inGreeting == 1 && voiceDuration >= greeting) {
+					if (option_verbose > 2)
+						ast_verbose(VERBOSE_PREFIX_3 "AMD: ANSWERING MACHINE: voiceDuration:%d greeting:%d\n", voiceDuration, greeting);
+					ast_frfree(f);
+					strcpy(amdStatus , "MACHINE");
+					sprintf(amdCause , "LONGGREETING-%d-%d", voiceDuration, greeting);
 					break;
 				}
+				
 				if (voiceDuration >= minimumWordLength ) {
 					silenceDuration = 0;
 					inInitialSilence = 0;
 					inGreeting = 1;
 				}
+				
 			}
 		}
 		ast_frfree(f);
 	}
-	if (!ret) {
+	
+	if (!res) {
 		/* It took too long to get a frame back. Giving up. */
 		if (option_verbose > 2)
-			ast_verbose(VERBOSE_PREFIX_3 "AMD: Channel [%s]. Too long...\n", chan->name );
-		strcpy(amdStatus , "NOTSURE" );
-		sprintf(amdCause , "TOOLONG-%d", iTotalTime );
-	}
-
-	pbx_builtin_setvar_helper(chan , "AMDSTATUS" , amdStatus );
-	pbx_builtin_setvar_helper(chan , "AMDCAUSE" , amdCause );
-
-	/* If We Started With A Valid Read Format, Return To It... */
-	if (readFormat && chan->_state == AST_STATE_UP) {
-		res = ast_set_read_format(chan, readFormat );
-		if (res)
-			ast_log(LOG_WARNING, "AMD: Unable to restore read format on '%s'\n", chan->name);
-	}
-
-	/* Free The Silence Detector DSP */
-	ast_dsp_free(silenceDetector );
+			ast_verbose(VERBOSE_PREFIX_3 "AMD: Channel [%s]. Too long...\n", chan->name);
+		strcpy(amdStatus , "NOTSURE");
+		sprintf(amdCause , "TOOLONG-%d", iTotalTime);
+	}
+
+	/* Set the status and cause on the channel */
+	pbx_builtin_setvar_helper(chan , "AMDSTATUS" , amdStatus);
+	pbx_builtin_setvar_helper(chan , "AMDCAUSE" , amdCause);
+
+	/* Restore channel read format */
+	if (readFormat && ast_set_read_format(chan, readFormat))
+		ast_log(LOG_WARNING, "AMD: Unable to restore read format on '%s'\n", chan->name);
+
+	/* Free the DSP used to detect silence */
+	ast_dsp_free(silenceDetector);
 
 	return;
 }
@@ -321,7 +310,7 @@
 
 static int amd_exec(struct ast_channel *chan, void *data)
 {
-	struct ast_module_user *u;
+	struct ast_module_user *u = NULL;
 
 	u = ast_module_user_add(chan);
 	isAnsweringMachine(chan, data);
@@ -332,13 +321,11 @@
 
 static void load_config(void)
 {
-	struct ast_config *cfg;
-	char *cat;
-	struct ast_variable *var;
-
-	cfg = ast_config_load("amd.conf");
-
-	if (!cfg) {
+	struct ast_config *cfg = NULL;
+	char *cat = NULL;
+	struct ast_variable *var = NULL;
+
+	if (!(cfg = ast_config_load("amd.conf"))) {
 		ast_log(LOG_ERROR, "Configuration file amd.conf missing.\n");
 		return;
 	}
@@ -374,6 +361,7 @@
 		}
 		cat = ast_category_browse(cfg, cat);
 	}
+
 	ast_config_destroy(cfg);
 
 	if (option_verbose > 2)

Modified: team/mogorman/asterisk-jabber/apps/app_authenticate.c
URL: http://svn.digium.com/view/asterisk/team/mogorman/asterisk-jabber/apps/app_authenticate.c?rev=42801&r1=42800&r2=42801&view=diff
==============================================================================
--- team/mogorman/asterisk-jabber/apps/app_authenticate.c (original)
+++ team/mogorman/asterisk-jabber/apps/app_authenticate.c Mon Sep 11 18:02:02 2006
@@ -218,7 +218,7 @@
 		if (!res)
 			res = ast_waitstream(chan, "");
 	} else {
-		if (ast_test_flag(&flags,OPT_JUMP) && ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101)) {
+		if (ast_test_flag(&flags,OPT_JUMP) && ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101) == 0) {
 			res = 0;
 		} else {
 			if (!ast_streamfile(chan, "vm-goodbye", chan->language))

Modified: team/mogorman/asterisk-jabber/apps/app_chanspy.c
URL: http://svn.digium.com/view/asterisk/team/mogorman/asterisk-jabber/apps/app_chanspy.c?rev=42801&r1=42800&r2=42801&view=diff
==============================================================================
--- team/mogorman/asterisk-jabber/apps/app_chanspy.c (original)
+++ team/mogorman/asterisk-jabber/apps/app_chanspy.c Mon Sep 11 18:02:02 2006
@@ -211,21 +211,6 @@
 	return res;
 }
 
-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 (!spy->chan)
-		return;
-
-	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
    decibel (dB) settings for channel drivers
 */
@@ -327,10 +312,11 @@
 	*/
 	while ((res = ast_waitfor(chan, -1) > -1) &&
 	       csth.spy.status == CHANSPY_RUNNING &&
-	       !ast_check_hangup(chan) &&
 	       csth.spy.chan) {
-		if (!(f = ast_read(chan)))
+		if (!(f = ast_read(chan)) || ast_check_hangup(chan)) {
+			running = -1;
 			break;
+		}
 
 		if (ast_test_flag(flags, OPTION_WHISPER) &&
 		    (f->frametype == AST_FRAME_VOICE)) {
@@ -381,13 +367,18 @@
 	else
 		ast_deactivate_generator(chan);
 
-	stop_spying(&csth.spy);
+	/* If a channel still exists on our spy structure then we need to remove ourselves */
+	if (csth.spy.chan) {
+		csth.spy.status = CHANSPY_DONE;
+		ast_channel_lock(csth.spy.chan);
+		ast_channel_spy_remove(csth.spy.chan, &csth.spy);
+		ast_channel_unlock(csth.spy.chan);
+	}
+	ast_channel_spy_free(&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;
 }
 
@@ -396,6 +387,7 @@
 {
 	struct ast_channel *this;
 
+	redo:
 	if (spec)
 		this = ast_walk_channel_by_name_prefix_locked(last, spec, strlen(spec));
 	else if (exten)
@@ -403,8 +395,11 @@
 	else
 		this = ast_channel_walk_locked(last);
 
-	if (this)
+	if (this) {
 		ast_channel_unlock(this);
+		if (!strncmp(this->name, "Zap/pseudo", 10))
+			goto redo;
+	}
 
 	return this;
 }
@@ -528,6 +523,8 @@
 				peer = NULL;
 			}
 		}
+		if (res == -1)
+			break;
 	}
 	
 	ast_clear_flag(chan, AST_FLAG_SPYING);

Modified: team/mogorman/asterisk-jabber/apps/app_dial.c
URL: http://svn.digium.com/view/asterisk/team/mogorman/asterisk-jabber/apps/app_dial.c?rev=42801&r1=42800&r2=42801&view=diff
==============================================================================
--- team/mogorman/asterisk-jabber/apps/app_dial.c (original)
+++ team/mogorman/asterisk-jabber/apps/app_dial.c Mon Sep 11 18:02:02 2006
@@ -151,7 +151,8 @@
 "                          specified priority. Optionally, an extension, or\n"
 "                          extension and priority can be specified.\n"
 "           You cannot use any additional action post answer options in conjunction\n"
-"           with this option.\n"
+"           with this option. Also, pbx services are not run on the peer (called) channel,\n"
+"           so you will not be able to set timeouts via the TIMEOUT() function in this macro.\n"
 "    n    - This option is a modifier for the screen/privacy mode. It specifies\n"
 "           that no introductions are to be saved in the priv-callerintros\n"
 "           directory.\n"

Modified: team/mogorman/asterisk-jabber/apps/app_followme.c
URL: http://svn.digium.com/view/asterisk/team/mogorman/asterisk-jabber/apps/app_followme.c?rev=42801&r1=42800&r2=42801&view=diff
==============================================================================
--- team/mogorman/asterisk-jabber/apps/app_followme.c (original)
+++ team/mogorman/asterisk-jabber/apps/app_followme.c Mon Sep 11 18:02:02 2006
@@ -30,7 +30,7 @@
 
 #include "asterisk.h"
 
-ASTERISK_FILE_VERSION(__FILE__, "$revision$")
+ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -59,8 +59,7 @@
 #include "asterisk/app.h"
 
 static char *app = "FollowMe";
-static char *synopsis = 
-"Find-Me/Follow-Me.";
+static char *synopsis = "Find-Me/Follow-Me application";
 static char *descrip = 
 "  FollowMe(followmeid|options):\n"
 "This application performs Find-Me/Follow-Me functionality for the caller\n"
@@ -72,8 +71,10 @@
 "    s    - Playback the incoming status message prior to starting the follow-me step(s)\n"
 "    a    - Record the caller's name so it can be announced to the callee on each step\n" 
 "    n    - Playback the unreachable status message if we've run out of steps to reach the\n"
-"           or the callee has elected not to be reachable.\n";
-
+"           or the callee has elected not to be reachable.\n"
+"Returns -1 on hangup\n";
+
+/*! \brief Number structure */
 struct number {
 	char number[512];	/*!< Phone Number(s) and/or Extension(s) */
 	long timeout;		/*!< Dial Timeout, if used. */
@@ -81,7 +82,8 @@
 	AST_LIST_ENTRY(number) entry; /*!< Next Number record */
 };
 
-struct ast_call_followme {
+/*! \brief Data structure for followme scripts */
+struct call_followme {
 	ast_mutex_t lock;
 	char name[AST_MAX_EXTENSION];	/*!< Name - FollowMeID */
 	char moh[AST_MAX_CONTEXT];	/*!< Music On Hold Class to be used */
@@ -89,17 +91,17 @@
 	unsigned int active;		/*!< Profile is active (1), or disabled (0). */
 	char takecall[20];		/*!< Digit mapping to take a call */
 	char nextindp[20];		/*!< Digit mapping to decline a call */
-	char callfromprompt[PATH_MAX];
-	char norecordingprompt[PATH_MAX];
-	char optionsprompt[PATH_MAX];
-	char plsholdprompt[PATH_MAX];
-	char statusprompt[PATH_MAX];
-	char sorryprompt[PATH_MAX];
+	char callfromprompt[PATH_MAX];	/*!< Sound prompt name and path */
+	char norecordingprompt[PATH_MAX];	/*!< Sound prompt name and path */
+	char optionsprompt[PATH_MAX];	/*!< Sound prompt name and path */
+	char plsholdprompt[PATH_MAX];	/*!< Sound prompt name and path */
+	char statusprompt[PATH_MAX];	/*!< Sound prompt name and path */
+	char sorryprompt[PATH_MAX];	/*!< Sound prompt name and path */
 
 	AST_LIST_HEAD_NOLOCK(numbers, number) numbers;	   /*!< Head of the list of follow-me numbers */
 	AST_LIST_HEAD_NOLOCK(blnumbers, number) blnumbers; /*!< Head of the list of black-listed numbers */
 	AST_LIST_HEAD_NOLOCK(wlnumbers, number) wlnumbers; /*!< Head of the list of white-listed numbers */
-	AST_LIST_ENTRY(ast_call_followme) entry;           /*!< Next Follow-Me record */
+	AST_LIST_ENTRY(call_followme) entry;           /*!< Next Follow-Me record */
 };
 
 struct fm_args {
@@ -112,12 +114,12 @@
 	struct ast_channel *outbound;
 	char takecall[20];		/*!< Digit mapping to take a call */
 	char nextindp[20];		/*!< Digit mapping to decline a call */
-	char callfromprompt[PATH_MAX];
-	char norecordingprompt[PATH_MAX];
-	char optionsprompt[PATH_MAX];
-	char plsholdprompt[PATH_MAX];
-	char statusprompt[PATH_MAX];
-	char sorryprompt[PATH_MAX];
+	char callfromprompt[PATH_MAX];	/*!< Sound prompt name and path */
+	char norecordingprompt[PATH_MAX];	/*!< Sound prompt name and path */
+	char optionsprompt[PATH_MAX];	/*!< Sound prompt name and path */
+	char plsholdprompt[PATH_MAX];	/*!< Sound prompt name and path */
+	char statusprompt[PATH_MAX];	/*!< Sound prompt name and path */
+	char sorryprompt[PATH_MAX];	/*!< Sound prompt name and path */
 	struct ast_flags followmeflags;
 };
 
@@ -145,7 +147,6 @@
 });
 
 static int ynlongest = 0;
-static char toast[80];
 static time_t start_time, answer_time, end_time;
 
 static char *featuredigittostr;
@@ -161,10 +162,10 @@
 static char sorryprompt[PATH_MAX] = "followme/sorry";
 
 
-static AST_LIST_HEAD_STATIC(followmes, ast_call_followme);
+static AST_LIST_HEAD_STATIC(followmes, call_followme);
 AST_LIST_HEAD_NOLOCK(findme_user_listptr, findme_user);
 
-static void free_numbers(struct ast_call_followme *f)
+static void free_numbers(struct call_followme *f)
 {
 	/* Free numbers attached to the profile */
 	struct number *prev;
@@ -187,32 +188,33 @@
 }
 
 
-static struct ast_call_followme *alloc_profile(const char *fmname)
-{
-	struct ast_call_followme *f;
-
-	f = ast_calloc(1, sizeof(*f));
-	if (f) {
-		ast_mutex_init(&f->lock);
-		ast_copy_string(f->name, fmname, sizeof(f->name));
-		ast_copy_string(f->moh, "", sizeof(f->moh));
-		ast_copy_string(f->context, "", sizeof(f->context));
-		ast_copy_string(f->takecall, takecall, sizeof(f->takecall));
-		ast_copy_string(f->nextindp, nextindp, sizeof(f->nextindp));
-		ast_copy_string(f->callfromprompt, callfromprompt, sizeof(f->callfromprompt));
-		ast_copy_string(f->norecordingprompt, norecordingprompt, sizeof(f->norecordingprompt));
-		ast_copy_string(f->optionsprompt, optionsprompt, sizeof(f->optionsprompt));
-		ast_copy_string(f->plsholdprompt, plsholdprompt, sizeof(f->plsholdprompt));
-		ast_copy_string(f->statusprompt, statusprompt, sizeof(f->statusprompt));
-		ast_copy_string(f->sorryprompt, sorryprompt, sizeof(f->sorryprompt));
-		AST_LIST_HEAD_INIT_NOLOCK(&f->numbers);
-		AST_LIST_HEAD_INIT_NOLOCK(&f->blnumbers);
-		AST_LIST_HEAD_INIT_NOLOCK(&f->wlnumbers);
-	}
+/*! \brief Allocate and initialize followme profile */
+static struct call_followme *alloc_profile(const char *fmname)
+{
+	struct call_followme *f;
+
+	if (!(f = ast_calloc(1, sizeof(*f))))
+		return NULL;
+
+	ast_mutex_init(&f->lock);
+	ast_copy_string(f->name, fmname, sizeof(f->name));
+	f->moh[0] = '\0';
+	f->context[0] = '\0';
+	ast_copy_string(f->takecall, takecall, sizeof(f->takecall));
+	ast_copy_string(f->nextindp, nextindp, sizeof(f->nextindp));
+	ast_copy_string(f->callfromprompt, callfromprompt, sizeof(f->callfromprompt));
+	ast_copy_string(f->norecordingprompt, norecordingprompt, sizeof(f->norecordingprompt));
+	ast_copy_string(f->optionsprompt, optionsprompt, sizeof(f->optionsprompt));
+	ast_copy_string(f->plsholdprompt, plsholdprompt, sizeof(f->plsholdprompt));
+	ast_copy_string(f->statusprompt, statusprompt, sizeof(f->statusprompt));
+	ast_copy_string(f->sorryprompt, sorryprompt, sizeof(f->sorryprompt));
+	AST_LIST_HEAD_INIT_NOLOCK(&f->numbers);
+	AST_LIST_HEAD_INIT_NOLOCK(&f->blnumbers);
+	AST_LIST_HEAD_INIT_NOLOCK(&f->wlnumbers);
 	return f;
 }
 
-static void init_profile(struct ast_call_followme *f)
+static void init_profile(struct call_followme *f)
 {
 	f->active = 1;
 	ast_copy_string(f->moh, defaultmoh, sizeof(f->moh));
@@ -220,30 +222,31 @@
 
    
    
-static void profile_set_param(struct ast_call_followme *f, const char *param, const char *val, int linenum, int failunknown)
+/*! \brief Set parameter in profile from configuration file */
+static void profile_set_param(struct call_followme *f, const char *param, const char *val, int linenum, int failunknown)
 {
 
 	if (!strcasecmp(param, "musicclass") || !strcasecmp(param, "musiconhold") || !strcasecmp(param, "music")) 
 		ast_copy_string(f->moh, val, sizeof(f->moh));
-	else if (!strcasecmp(param, "context")) {
+	else if (!strcasecmp(param, "context")) 
 		ast_copy_string(f->context, val, sizeof(f->context));
-	} else if (!strcasecmp(param, "takecall")) {
+	else if (!strcasecmp(param, "takecall"))
 		ast_copy_string(f->takecall, val, sizeof(f->takecall));
-	} else if (!strcasecmp(param, "declinecall")) {
+	else if (!strcasecmp(param, "declinecall"))
 		ast_copy_string(f->nextindp, val, sizeof(f->nextindp));
-	} else if (!strcasecmp(param, "call-from-prompt")) {
+	else if (!strcasecmp(param, "call-from-prompt"))
 		ast_copy_string(f->callfromprompt, val, sizeof(f->callfromprompt));
-	} else if (!strcasecmp(param, "followme-norecording-prompt")) {
+	else if (!strcasecmp(param, "followme-norecording-prompt")) 
 		ast_copy_string(f->norecordingprompt, val, sizeof(f->norecordingprompt));
-	} else if (!strcasecmp(param, "followme-options-prompt")) {
+	else if (!strcasecmp(param, "followme-options-prompt")) 
 		ast_copy_string(f->optionsprompt, val, sizeof(f->optionsprompt));
-	} else if (!strcasecmp(param, "followme-pls-hold-prompt")) {
+	else if (!strcasecmp(param, "followme-pls-hold-prompt"))
 		ast_copy_string(f->plsholdprompt, val, sizeof(f->plsholdprompt));
-	} else if (!strcasecmp(param, "followme-status-prompt")) {
+	else if (!strcasecmp(param, "followme-status-prompt")) 
 		ast_copy_string(f->statusprompt, val, sizeof(f->statusprompt));
-	} else if (!strcasecmp(param, "followme-sorry-prompt")) {
+	else if (!strcasecmp(param, "followme-sorry-prompt")) 
 		ast_copy_string(f->sorryprompt, val, sizeof(f->sorryprompt));
-	} else if (failunknown) {
+	else if (failunknown) {
 		if (linenum >= 0)
 			ast_log(LOG_WARNING, "Unknown keyword in profile '%s': %s at line %d of followme.conf\n", f->name, param, linenum);
 		else
@@ -251,32 +254,31 @@
 	}
 }
 
+/*! \brief Add a new number */
 static struct number *create_followme_number(char *number, int timeout, int numorder)
 {
 	struct number *cur;
 	char *tmp;
 	
-	/* Add a new number */
-
-	cur = ast_calloc(1, sizeof(*cur));
-
-	if (cur) {
-		cur->timeout = timeout;
-		if ((tmp = strchr(number, ','))) { 
-			*tmp = '\0';
-		}
-		ast_copy_string(cur->number, number, sizeof(cur->number));
-		cur->order = numorder;
-		if (option_debug)
-			ast_log(LOG_DEBUG, "Created a number, %s, order of , %d, with a timeout of %ld.\n", cur->number, cur->order, cur->timeout);
-	}
+

[... 9197 lines stripped ...]


More information about the asterisk-commits mailing list