summaryrefslogtreecommitdiff
path: root/main/bridge_basic.c
diff options
context:
space:
mode:
authorMark Michelson <mmichelson@digium.com>2014-11-17 16:51:16 +0000
committerMark Michelson <mmichelson@digium.com>2014-11-17 16:51:16 +0000
commita1f1cdbd872cb38dfe589a699ff31706841be031 (patch)
tree3852382e03f712f150d9acfca5d48af26091f4a9 /main/bridge_basic.c
parente8286df19c1a5982d80236a1e308ca336cdb7125 (diff)
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 git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/13@428145 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/bridge_basic.c')
-rw-r--r--main/bridge_basic.c64
1 files changed, 48 insertions, 16 deletions
diff --git a/main/bridge_basic.c b/main/bridge_basic.c
index 97892e395..449543512 100644
--- a/main/bridge_basic.c
+++ b/main/bridge_basic.c
@@ -47,6 +47,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#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 @@ static int grab_transfer(struct ast_channel *chan, char *exten, size_t exten_len
{
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 @@ static int grab_transfer(struct ast_channel *chan, char *exten, size_t exten_len
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 @@ static int grab_transfer(struct ast_channel *chan, char *exten, size_t exten_len
}
/* 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;
}