Tue Aug 24 20:35:03 2010

Asterisk developer's documentation


app_transfer.c File Reference

Transfer a caller. More...

#include "asterisk.h"
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "asterisk/app.h"
#include "asterisk/channel.h"
Include dependency graph for app_transfer.c:

Go to the source code of this file.

Functions

 AST_MODULE_INFO_STANDARD (ASTERISK_GPL_KEY,"Transfers a caller to another extension")
static int load_module (void)
static int transfer_exec (struct ast_channel *chan, void *data)
static int unload_module (void)

Variables

static const char * app = "Transfer"

Detailed Description

Transfer a caller.

Author:
Mark Spencer <markster@digium.com>

Requires transfer support from channel driver

Definition in file app_transfer.c.


Function Documentation

AST_MODULE_INFO_STANDARD ( ASTERISK_GPL_KEY  ,
"Transfers a caller to another extension"   
)
static int load_module ( void   )  [static]

Definition at line 137 of file app_transfer.c.

References ast_register_application_xml, and transfer_exec().

00138 {
00139    return ast_register_application_xml(app, transfer_exec);
00140 }

static int transfer_exec ( struct ast_channel *  chan,
void *  data 
) [static]

Definition at line 77 of file app_transfer.c.

References AST_APP_ARG, AST_DECLARE_APP_ARGS, ast_log(), AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero(), ast_transfer(), len(), LOG_WARNING, parse(), pbx_builtin_setvar_helper(), status, ast_channel::tech, ast_channel_tech::transfer, and ast_channel_tech::type.

Referenced by load_module().

00078 {
00079    int res;
00080    int len;
00081    char *slash;
00082    char *tech = NULL;
00083    char *dest = NULL;
00084    char *status;
00085    char *parse;
00086    AST_DECLARE_APP_ARGS(args,
00087       AST_APP_ARG(dest);
00088    );
00089 
00090    if (ast_strlen_zero((char *)data)) {
00091       ast_log(LOG_WARNING, "Transfer requires an argument ([Tech/]destination)\n");
00092       pbx_builtin_setvar_helper(chan, "TRANSFERSTATUS", "FAILURE");
00093       return 0;
00094    } else
00095       parse = ast_strdupa(data);
00096 
00097    AST_STANDARD_APP_ARGS(args, parse);
00098 
00099    dest = args.dest;
00100 
00101    if ((slash = strchr(dest, '/')) && (len = (slash - dest))) {
00102       tech = dest;
00103       dest = slash + 1;
00104       /* Allow execution only if the Tech/destination agrees with the type of the channel */
00105       if (strncasecmp(chan->tech->type, tech, len)) {
00106          pbx_builtin_setvar_helper(chan, "TRANSFERSTATUS", "FAILURE");
00107          return 0;
00108       }
00109    }
00110 
00111    /* Check if the channel supports transfer before we try it */
00112    if (!chan->tech->transfer) {
00113       pbx_builtin_setvar_helper(chan, "TRANSFERSTATUS", "UNSUPPORTED");
00114       return 0;
00115    }
00116 
00117    res = ast_transfer(chan, dest);
00118 
00119    if (res < 0) {
00120       status = "FAILURE";
00121       res = 0;
00122    } else {
00123       status = "SUCCESS";
00124       res = 0;
00125    }
00126 
00127    pbx_builtin_setvar_helper(chan, "TRANSFERSTATUS", status);
00128 
00129    return res;
00130 }

static int unload_module ( void   )  [static]

Definition at line 132 of file app_transfer.c.

References ast_unregister_application().

00133 {
00134    return ast_unregister_application(app);
00135 }


Variable Documentation

const char* app = "Transfer" [static]

Definition at line 75 of file app_transfer.c.


Generated on 24 Aug 2010 for Asterisk - the Open Source PBX by  doxygen 1.6.1