[asterisk-commits] mmichelson: branch 13 r428145 - in /branches/13: ./ configs/samples/ include/...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Nov 17 10:51:21 CST 2014


Author: mmichelson
Date: Mon Nov 17 10:51:16 2014
New Revision: 428145

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=428145
Log:
Allow for transferer to retry when dialing an invalid extension.

This allows for a configurable number of attempts for a transferer
to dial an extension to transfer the call to. For Asterisk 13, the
default values are such that upgrading between versions will not
cause a behaivour change. For trunk, though, the defaults will be
changed to be more user-friendly.

Review: https://reviewboard.asterisk.org/r/4167


Modified:
    branches/13/CHANGES
    branches/13/configs/samples/features.conf.sample
    branches/13/include/asterisk/features_config.h
    branches/13/main/bridge_basic.c
    branches/13/main/features_config.c

Modified: branches/13/CHANGES
URL: http://svnview.digium.com/svn/asterisk/branches/13/CHANGES?view=diff&rev=428145&r1=428144&r2=428145
==============================================================================
--- branches/13/CHANGES (original)
+++ branches/13/CHANGES Mon Nov 17 10:51:16 2014
@@ -7,6 +7,19 @@
 === and the other UPGRADE files for older releases.
 ===
 ==============================================================================
+------------------------------------------------------------------------------
+--- Functionality changes from Asterisk 13.0.0 to Asterisk 13.1.0 ------------
+------------------------------------------------------------------------------
+
+Transfers
+-----------------
+
+The features.conf general section has three new configurable options:
+    * transferdialattempts
+	* transferretrysound
+	* transferinvalidsound
+For more information on what these options do, see the Asterisk wiki:
+	https://wiki.asterisk.org/wiki/x/W4fAAQ
 
 ------------------------------------------------------------------------------
 --- Functionality changes from Asterisk 12 to Asterisk 13 --------------------

Modified: branches/13/configs/samples/features.conf.sample
URL: http://svnview.digium.com/svn/asterisk/branches/13/configs/samples/features.conf.sample?view=diff&rev=428145&r1=428144&r2=428145
==============================================================================
--- branches/13/configs/samples/features.conf.sample (original)
+++ branches/13/configs/samples/features.conf.sample Mon Nov 17 10:51:16 2014
@@ -24,6 +24,10 @@
 ;atxferloopdelay = 10           ; Number of seconds to sleep between retries (if atxferdropcall = no)
 ;atxfercallbackretries = 2      ; Number of times to attempt to send the call back to the transferer.
                                 ; By default, this is 2.
+;transferdialattempts = 3       ; Number of times that a transferer may attempt to dial an extension before
+                                ; being kicked back to the original call.
+;transferretrysound = "beep"    ; Sound to play when a transferer fails to dial a valid extension.
+;transferinvalidsound = "beeperr" ; Sound to play when a transferer fails to dial a valid extension and is out of retries.
 
 
 ; Note that the DTMF features listed below only work when two channels have answered and are bridged together.

Modified: branches/13/include/asterisk/features_config.h
URL: http://svnview.digium.com/svn/asterisk/branches/13/include/asterisk/features_config.h?view=diff&rev=428145&r1=428144&r2=428145
==============================================================================
--- branches/13/include/asterisk/features_config.h (original)
+++ branches/13/include/asterisk/features_config.h Mon Nov 17 10:51:16 2014
@@ -68,6 +68,10 @@
 		AST_STRING_FIELD(atxferthreeway);
 		/*! DTMF sequence used to swap which party the transferer is talking to */
 		AST_STRING_FIELD(atxferswap);
+		/*! Sound played when an invalid extension is dialed, and the transferer should retry. */
+		AST_STRING_FIELD(transferretrysound);
+		/*! Sound played when an invalid extension is dialed, and the transferer is being returned to the call. */
+		AST_STRING_FIELD(transferinvalidsound);
 	);
 	/*! Seconds allowed between digit presses when dialing transfer destination */
 	unsigned int transferdigittimeout;
@@ -79,6 +83,8 @@
 	unsigned int atxfercallbackretries;
 	/*! Determines if the call is dropped on attended transfer failure */
 	unsigned int atxferdropcall;
+	/*! Number of dial attempts allowed for blind/attended transfers */
+	unsigned int transferdialattempts;
 };
 
 /*!

Modified: branches/13/main/bridge_basic.c
URL: http://svnview.digium.com/svn/asterisk/branches/13/main/bridge_basic.c?view=diff&rev=428145&r1=428144&r2=428145
==============================================================================
--- branches/13/main/bridge_basic.c (original)
+++ branches/13/main/bridge_basic.c Mon Nov 17 10:51:16 2014
@@ -47,6 +47,7 @@
 #include "asterisk/stasis_bridges.h"
 #include "asterisk/features.h"
 #include "asterisk/format_cache.h"
+#include "asterisk/test.h"
 
 #define NORMAL_FLAGS	(AST_BRIDGE_FLAG_DISSOLVE_HANGUP | AST_BRIDGE_FLAG_DISSOLVE_EMPTY \
 			| AST_BRIDGE_FLAG_SMART)
@@ -2977,7 +2978,11 @@
 {
 	int res;
 	int digit_timeout;
+	int attempts = 0;
+	int max_attempts;
 	RAII_VAR(struct ast_features_xfer_config *, xfer_cfg, NULL, ao2_cleanup);
+	char *retry_sound;
+	char *invalid_sound;
 
 	ast_channel_lock(chan);
 	xfer_cfg = ast_get_chan_features_xfer_config(chan);
@@ -2987,6 +2992,9 @@
 		return -1;
 	}
 	digit_timeout = xfer_cfg->transferdigittimeout * 1000;
+	max_attempts = xfer_cfg->transferdialattempts;
+	retry_sound = ast_strdupa(xfer_cfg->transferretrysound);
+	invalid_sound = ast_strdupa(xfer_cfg->transferinvalidsound);
 	ast_channel_unlock(chan);
 
 	/* Play the simple "transfer" prompt out and wait */
@@ -3002,24 +3010,48 @@
 	}
 
 	/* Drop to dialtone so they can enter the extension they want to transfer to */
-	res = ast_app_dtget(chan, context, exten, exten_len, exten_len - 1, digit_timeout);
-	if (res < 0) {
-		/* Hangup or error */
-		res = -1;
-	} else if (!res) {
-		/* 0 for invalid extension dialed. */
-		if (ast_strlen_zero(exten)) {
-			ast_debug(1, "%s dialed no digits.\n", ast_channel_name(chan));
+	do {
+		++attempts;
+		memset(exten, 0, exten_len);
+		ast_test_suite_event_notify("TRANSFER_BEGIN_DIAL",
+				"Channel: %s\r\n"
+				"Attempt: %d",
+				ast_channel_name(chan), attempts);
+		res = ast_app_dtget(chan, context, exten, exten_len, exten_len - 1, digit_timeout);
+		if (res < 0) {
+			/* Hangup or error */
+			res = -1;
+		} else if (!res) {
+			/* 0 for invalid extension dialed. */
+			if (ast_strlen_zero(exten)) {
+				ast_debug(1, "%s dialed no digits.\n", ast_channel_name(chan));
+			} else {
+				ast_debug(1, "%s dialed '%s@%s' does not exist.\n",
+					ast_channel_name(chan), exten, context);
+			}
+			if (attempts < max_attempts) {
+				ast_stream_and_wait(chan, retry_sound, AST_DIGIT_NONE);
+			} else {
+				ast_stream_and_wait(chan, invalid_sound, AST_DIGIT_NONE);
+			}
+			res = -1;
 		} else {
-			ast_debug(1, "%s dialed '%s@%s' does not exist.\n",
-				ast_channel_name(chan), exten, context);
+			/* Dialed extension is valid. */
+			res = 0;
 		}
-		ast_stream_and_wait(chan, "pbx-invalid", AST_DIGIT_NONE);
-		res = -1;
-	} else {
-		/* Dialed extension is valid. */
-		res = 0;
-	}
+		ast_test_suite_event_notify("TRANSFER_DIALLED",
+				"Channel: %s\r\n"
+				"Attempt: %d\r\n"
+				"Dialled: %s\r\n"
+				"Result: %s",
+				ast_channel_name(chan), attempts, exten, res == 0 ? "Success" : "Failure");
+	} while (res < 0 && attempts < max_attempts);
+
+	ast_test_suite_event_notify("TRANSFER_DIAL_FINAL",
+			"Channel: %s\r\n"
+			"Result: %s",
+			ast_channel_name(chan), res == 0 ? "Success" : "Failure");
+
 	return res;
 }
 

Modified: branches/13/main/features_config.c
URL: http://svnview.digium.com/svn/asterisk/branches/13/main/features_config.c?view=diff&rev=428145&r1=428144&r2=428145
==============================================================================
--- branches/13/main/features_config.c (original)
+++ branches/13/main/features_config.c Mon Nov 17 10:51:16 2014
@@ -131,6 +131,15 @@
 				</configOption>
 				<configOption name="pickupfailsound">
 					<synopsis>Sound to play to picker when a call cannot be picked up</synopsis>
+				</configOption>
+				<configOption name="transferdialattempts" default="3">
+					<synopsis>Number of dial attempts allowed when attempting a transfer</synopsis>
+				</configOption>
+				<configOption name="transferretrysound" default="pbx-invalid">
+					<synopsis>Sound that is played when an incorrect extension is dialed and the transferer should try again.</synopsis>
+				</configOption>
+				<configOption name="transferinvalidsound" default="privacy-incorrect">
+					<synopsis>Sound that is played when an incorrect extension is dialed and the transferer has no attempts remaining.</synopsis>
 				</configOption>
 			</configObject>
 			<configObject name="featuremap">
@@ -306,6 +315,9 @@
 					<enum name="pickupfailsound"><para><xi:include xpointer="xpointer(/docs/configInfo[@name='features']/configFile[@name='features.conf']/configObject[@name='globals']/configOption[@name='pickupfailsound']/synopsis/text())" /></para></enum>
 					<enum name="courtesytone"><para><xi:include xpointer="xpointer(/docs/configInfo[@name='features']/configFile[@name='features.conf']/configObject[@name='globals']/configOption[@name='courtesytone']/synopsis/text())" /></para></enum>
 					<enum name="recordingfailsound"><para><xi:include xpointer="xpointer(/docs/configInfo[@name='features']/configFile[@name='features.conf']/configObject[@name='globals']/configOption[@name='recordingfailsound']/synopsis/text())" /></para></enum>
+					<enum name="transferdialattempts"><para><xi:include xpointer="xpointer(/docs/configInfo[@name='features']/configFile[@name='features.conf']/configObject[@name='globals']/configOption[@name='transferdialattempts']/synopsis/text())" /></para></enum>
+					<enum name="transferretrysound"><para><xi:include xpointer="xpointer(/docs/configInfo[@name='features']/configFile[@name='features.conf']/configObject[@name='globals']/configOption[@name='transferretrysound']/synopsis/text())" /></para></enum>
+					<enum name="transferinvalidsound"><para><xi:include xpointer="xpointer(/docs/configInfo[@name='features']/configFile[@name='features.conf']/configObject[@name='globals']/configOption[@name='transferinvalidsound']/synopsis/text())" /></para></enum>
 				</enumlist>
 			</parameter>
 		</syntax>
@@ -366,6 +378,9 @@
 #define DEFAULT_ATXFER_COMPLETE                     "*2"
 #define DEFAULT_ATXFER_THREEWAY                     "*3"
 #define DEFAULT_ATXFER_SWAP                         "*4"
+#define DEFAULT_TRANSFER_DIAL_ATTEMPTS              1
+#define DEFAULT_TRANSFER_RETRY_SOUND                "pbx-invalid"
+#define DEFAULT_TRANSFER_INVALID_SOUND              "pbx-invalid"
 
 /*! Default pickup options */
 #define DEFAULT_PICKUPEXTEN                         "*8"
@@ -773,6 +788,7 @@
 	dest->atxferloopdelay = src->atxferloopdelay;
 	dest->atxfercallbackretries = src->atxfercallbackretries;
 	dest->atxferdropcall = src->atxferdropcall;
+	dest->transferdialattempts = src->transferdialattempts;
 }
 
 static void pickup_copy(struct ast_features_pickup_config *dest, const struct ast_features_pickup_config *src)
@@ -882,6 +898,12 @@
 		ast_string_field_set(xfer, atxferthreeway, value);
 	} else if (!strcasecmp(name, "atxferswap")) {
 		ast_string_field_set(xfer, atxferswap, value);
+	} else if (!strcasecmp(name, "transferdialattempts")) {
+		res = ast_parse_arg(value, PARSE_INT32, &xfer->transferdialattempts);
+	} else if (!strcasecmp(name, "transferretrysound")) {
+		ast_string_field_set(xfer, transferretrysound, value);
+	} else if (!strcasecmp(name, "transferinvalidsound")) {
+		ast_string_field_set(xfer, transferinvalidsound, value);
 	} else {
 		/* Unrecognized option */
 		res = -1;
@@ -917,6 +939,12 @@
 		ast_copy_string(buf, xfer->atxferthreeway, len);
 	} else if (!strcasecmp(field, "atxferswap")) {
 		ast_copy_string(buf, xfer->atxferswap, len);
+	} else if (!strcasecmp(field, "transferdialattempts")) {
+		snprintf(buf, len, "%u", xfer->transferdialattempts);
+	} else if (!strcasecmp(field, "transferretrysound")) {
+		ast_copy_string(buf, xfer->transferretrysound, len);
+	} else if (!strcasecmp(field, "transferinvalidsound")) {
+		ast_copy_string(buf, xfer->transferinvalidsound, len);
 	} else {
 		/* Unrecognized option */
 		res = -1;
@@ -1731,6 +1759,12 @@
 			DEFAULT_ATXFER_THREEWAY, xfer_handler, 0);
 	aco_option_register_custom(&cfg_info, "atxferswap", ACO_EXACT, global_options,
 			DEFAULT_ATXFER_SWAP, xfer_handler, 0);
+	aco_option_register_custom(&cfg_info, "transferdialattempts", ACO_EXACT, global_options,
+			__stringify(DEFAULT_TRANSFER_DIAL_ATTEMPTS), xfer_handler, 0);
+	aco_option_register_custom(&cfg_info, "transferretrysound", ACO_EXACT, global_options,
+			DEFAULT_TRANSFER_RETRY_SOUND, xfer_handler, 0);
+	aco_option_register_custom(&cfg_info, "transferinvalidsound", ACO_EXACT, global_options,
+			DEFAULT_TRANSFER_INVALID_SOUND, xfer_handler, 0);
 
 	aco_option_register_custom(&cfg_info, "pickupexten", ACO_EXACT, global_options,
 			DEFAULT_PICKUPEXTEN, pickup_handler, 0);




More information about the asterisk-commits mailing list