aboutsummaryrefslogtreecommitdiffstats
path: root/apps/app_transfer.c
diff options
context:
space:
mode:
authorkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2005-11-07 22:48:29 +0000
committerkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2005-11-07 22:48:29 +0000
commit568c5c30f8f656ffbc413fec4920039d498dc21a (patch)
tree309c1fe4c0229cee3707ba5ae5e57fb7feda80cd /apps/app_transfer.c
parent048a9219ad1dc5566632bc25f872c59b4368e2c0 (diff)
issue #5646
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@6996 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps/app_transfer.c')
-rwxr-xr-xapps/app_transfer.c48
1 files changed, 35 insertions, 13 deletions
diff --git a/apps/app_transfer.c b/apps/app_transfer.c
index b6ba16faa..4443a7874 100755
--- a/apps/app_transfer.c
+++ b/apps/app_transfer.c
@@ -40,6 +40,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "asterisk/options.h"
+#include "asterisk/app.h"
STANDARD_LOCAL_USER;
@@ -52,21 +53,19 @@ static const char *app = "Transfer";
static const char *synopsis = "Transfer caller to remote extension";
static const char *descrip =
-" Transfer([Tech/]dest): Requests the remote caller be transfered\n"
-"to a given extension. If TECH (SIP, IAX2, LOCAL etc) is used, only\n"
+" Transfer([Tech/]dest[|options]): Requests the remote caller be transferred\n"
+"to a given destination. If TECH (SIP, IAX2, LOCAL etc) is used, only\n"
"an incoming call with the same channel technology will be transfered.\n"
"Note that for SIP, if you transfer before call is setup, a 302 redirect\n"
"SIP message will be returned to the caller.\n"
"\nThe result of the application will be reported in the TRANSFERSTATUS\n"
"channel variable:\n"
-" SUCCESS Transfer succeeded\n"
+" SUCCESS Transfer succeeded\n"
" FAILURE Transfer failed\n"
" UNSUPPORTED Transfer unsupported by channel driver\n"
-"Returns -1 on hangup, or 0 on completion regardless of whether the\n"
-"transfer was successful.\n\n"
-"Old depraciated behaviour: If the transfer was *not* supported or\n"
-"successful and there exists a priority n + 101,\n"
-"then that priority will be taken next.\n" ;
+"The option string many contain the following character:\n"
+"'j' -- jump to n+101 priority if the channel transfer attempt\n"
+" fails\n";
static int transfer_exec(struct ast_channel *chan, void *data)
{
@@ -75,16 +74,39 @@ static int transfer_exec(struct ast_channel *chan, void *data)
struct localuser *u;
char *slash;
char *tech = NULL;
- char *dest = data;
+ char *dest = NULL;
char *status;
+ char *parse;
+ int priority_jump = 0;
+ AST_DECLARE_APP_ARGS(args,
+ AST_APP_ARG(dest);
+ AST_APP_ARG(options);
+ );
- if (ast_strlen_zero(dest)) {
- ast_log(LOG_WARNING, "Transfer requires an argument ([Tech/]destination)\n");
+ LOCAL_USER_ADD(u);
+
+ if (ast_strlen_zero((char *)data)) {
+ ast_log(LOG_WARNING, "Transfer requires an argument ([Tech/]destination[|options])\n");
+ LOCAL_USER_REMOVE(u);
pbx_builtin_setvar_helper(chan, "TRANSFERSTATUS", "FAILURE");
return 0;
+ } else {
+ parse = ast_strdupa(data);
+ if (!parse) {
+ ast_log(LOG_ERROR, "Out of memory!\n");
+ LOCAL_USER_REMOVE(u);
+ return -1;
+ }
}
- LOCAL_USER_ADD(u);
+ AST_STANDARD_APP_ARGS(args, parse);
+
+ if (args.options) {
+ if (strchr(args.options, 'j'))
+ priority_jump = 1;
+ }
+
+ dest = args.dest;
if ((slash = strchr(dest, '/')) && (len = (slash - dest))) {
tech = dest;
@@ -108,7 +130,7 @@ static int transfer_exec(struct ast_channel *chan, void *data)
if (res < 0) {
status = "FAILURE";
- if (option_priority_jumping)
+ if (priority_jump || option_priority_jumping)
ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101);
res = 0;
} else {