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

static void __reg_module (void)
static void __unreg_module (void)
static int load_module (void)
static int transfer_exec (struct ast_channel *chan, const char *data)
static int unload_module (void)

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Transfers a caller to another extension" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, .support_level = AST_MODULE_SUPPORT_CORE, }
static const char *const app = "Transfer"
static struct ast_module_infoast_module_info = &__mod_info


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

static void __reg_module ( void   )  [static]

Definition at line 146 of file app_transfer.c.

static void __unreg_module ( void   )  [static]

Definition at line 146 of file app_transfer.c.

static int load_module ( void   )  [static]

Definition at line 141 of file app_transfer.c.

References ast_register_application_xml, and transfer_exec().

00142 {
00143    return ast_register_application_xml(app, transfer_exec);
00144 }

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

Definition at line 81 of file app_transfer.c.

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

Referenced by load_module().

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

static int unload_module ( void   )  [static]

Definition at line 136 of file app_transfer.c.

References ast_unregister_application().

00137 {
00138    return ast_unregister_application(app);
00139 }


Variable Documentation

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Transfers a caller to another extension" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, .support_level = AST_MODULE_SUPPORT_CORE, } [static]

Definition at line 146 of file app_transfer.c.

const char* const app = "Transfer" [static]

Definition at line 79 of file app_transfer.c.

Definition at line 146 of file app_transfer.c.


Generated on Thu Apr 16 06:28:46 2015 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6