Index: apps/app_transfer.c =================================================================== RCS file: /usr/cvsroot/asterisk/apps/app_transfer.c,v retrieving revision 1.11 diff -u -r1.11 app_transfer.c --- apps/app_transfer.c 6 Jun 2005 22:39:32 -0000 1.11 +++ apps/app_transfer.c 26 Jul 2005 21:10:43 -0000 @@ -25,6 +25,7 @@ #include "asterisk/channel.h" #include "asterisk/pbx.h" #include "asterisk/module.h" +#include "asterisk/options.h" static char *tdesc = "Transfer"; @@ -38,8 +39,14 @@ "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" +" 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. If the transfer was *not* supported or\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" ; @@ -54,28 +61,42 @@ struct localuser *u; char *slash; char *dest = data; + char *status = "FAILURE"; + if (!data || !strlen(data)) { ast_log(LOG_WARNING, "Transfer requires an argument ([Tech/]destination)\n"); + pbx_builtin_setvar_helper(chan, "TRANSFERSTATUS", status); res = 1; } if ((slash = strchr((char *)data, '/')) && (len = (slash - (char *)data))) { dest = slash + 1; /* Allow execution only if the Tech/destination agrees with the type of the channel */ - if (strncasecmp(chan->type, (char *)data, len)) + if (strncasecmp(chan->type, (char *)data, len)) { + pbx_builtin_setvar_helper(chan, "TRANSFERSTATUS", status); return 0; + } } LOCAL_USER_ADD(u); + /* Check if the channel supports transfer before we try it */ + if (!chan->tech->transfer) { + status = "UNSUPPORTED"; + pbx_builtin_setvar_helper(chan, "TRANSFERSTATUS", status); + return 0; + } if (!res) { res = ast_transfer(chan, dest); - } if (!res) { + status = "FAILURE"; /* Look for a "busy" place */ - if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->cid.cid_num)) + if (option_priority_jumping && ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->cid.cid_num)) chan->priority += 100; } - if (res > 0) + if (res > 0) { + status = "SUCCESS"; res = 0; + } + pbx_builtin_setvar_helper(chan, "TRANSFERSTATUS", status); LOCAL_USER_REMOVE(u); return res; }