mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-06 12:36:58 +00:00
features: Add transfer initiation options.
Adds additional control options over the transfer feature functionality to give users more control in how the transfer feature sounds and works. First, the "transfer" sound that plays when a transfer is initiated can now be customized by the user in features.conf, just as with the other transfer sounds. Secondly, the user can now specify the transfer extension in advance by using the TRANSFER_EXTEN variable. If a valid extension is contained in this variable, the call will automatically be transferred to this destination. Otherwise, it will fall back to collecting the extension from the user as is always done now. ASTERISK-29899 #close Change-Id: Ibff309caa459a2b958706f2ed0ca393b1ef502e3
This commit is contained in:
committed by
George Joseph
parent
1390a247a6
commit
a5d5c3a92c
@@ -1397,6 +1397,27 @@ static const char *get_transfer_context(struct ast_channel *transferer, const ch
|
||||
return "default";
|
||||
}
|
||||
|
||||
/*!
|
||||
* \internal
|
||||
* \brief Determine the transfer extension to use.
|
||||
*
|
||||
* \param transferer Channel initiating the transfer.
|
||||
* \param extension User supplied extension if available. May be NULL.
|
||||
*
|
||||
* \return The extension to use for the transfer.
|
||||
*/
|
||||
static const char *get_transfer_exten(struct ast_channel *transferer, const char *exten)
|
||||
{
|
||||
if (!ast_strlen_zero(exten)) {
|
||||
return exten;
|
||||
}
|
||||
exten = pbx_builtin_getvar_helper(transferer, "TRANSFER_EXTEN");
|
||||
if (!ast_strlen_zero(exten)) {
|
||||
return exten;
|
||||
}
|
||||
return ""; /* empty default, to get transfer extension from user now */
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Allocate and initialize attended transfer properties
|
||||
*
|
||||
@@ -3162,10 +3183,25 @@ static int grab_transfer(struct ast_channel *chan, char *exten, size_t exten_len
|
||||
int attempts = 0;
|
||||
int max_attempts;
|
||||
struct ast_features_xfer_config *xfer_cfg;
|
||||
char *retry_sound;
|
||||
char *invalid_sound;
|
||||
char *announce_sound, *retry_sound, *invalid_sound;
|
||||
const char *extenoverride;
|
||||
|
||||
ast_channel_lock(chan);
|
||||
extenoverride = get_transfer_exten(chan, NULL);
|
||||
|
||||
if (!ast_strlen_zero(extenoverride)) {
|
||||
int extenres = ast_exists_extension(chan, context, extenoverride, 1,
|
||||
S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL)) ? 1 : 0;
|
||||
if (extenres) {
|
||||
ast_copy_string(exten, extenoverride, exten_len);
|
||||
ast_channel_unlock(chan);
|
||||
ast_verb(3, "Transfering call to '%s@%s'", exten, context);
|
||||
return 0;
|
||||
}
|
||||
ast_log(LOG_WARNING, "Override extension '%s' does not exist in context '%s'\n", extenoverride, context);
|
||||
/* since we didn't get a valid extension from the channel, fall back and grab it from the user as usual now */
|
||||
}
|
||||
|
||||
xfer_cfg = ast_get_chan_features_xfer_config(chan);
|
||||
if (!xfer_cfg) {
|
||||
ast_log(LOG_ERROR, "Channel %s: Unable to get transfer configuration\n",
|
||||
@@ -3175,21 +3211,24 @@ static int grab_transfer(struct ast_channel *chan, char *exten, size_t exten_len
|
||||
}
|
||||
digit_timeout = xfer_cfg->transferdigittimeout * 1000;
|
||||
max_attempts = xfer_cfg->transferdialattempts;
|
||||
announce_sound = ast_strdupa(xfer_cfg->transferannouncesound);
|
||||
retry_sound = ast_strdupa(xfer_cfg->transferretrysound);
|
||||
invalid_sound = ast_strdupa(xfer_cfg->transferinvalidsound);
|
||||
ao2_ref(xfer_cfg, -1);
|
||||
ast_channel_unlock(chan);
|
||||
|
||||
/* Play the simple "transfer" prompt out and wait */
|
||||
res = ast_stream_and_wait(chan, "pbx-transfer", AST_DIGIT_ANY);
|
||||
ast_stopstream(chan);
|
||||
if (res < 0) {
|
||||
/* Hangup or error */
|
||||
return -1;
|
||||
}
|
||||
if (res) {
|
||||
/* Store the DTMF digit that interrupted playback of the file. */
|
||||
exten[0] = res;
|
||||
if (!ast_strlen_zero(announce_sound)) {
|
||||
res = ast_stream_and_wait(chan, announce_sound, AST_DIGIT_ANY);
|
||||
ast_stopstream(chan);
|
||||
if (res < 0) {
|
||||
/* Hangup or error */
|
||||
return -1;
|
||||
}
|
||||
if (res) {
|
||||
/* Store the DTMF digit that interrupted playback of the file. */
|
||||
exten[0] = res;
|
||||
}
|
||||
}
|
||||
|
||||
/* Drop to dialtone so they can enter the extension they want to transfer to */
|
||||
|
Reference in New Issue
Block a user