#include "asterisk.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include "asterisk/lock.h"
#include "asterisk/file.h"
#include "asterisk/logger.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "asterisk/options.h"
#include "asterisk/app.h"
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, void *data) |
static int | unload_module (void) |
Variables | |
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT | AST_MODFLAG_BUILDSUM, .description = "Transfer" , .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 = "361d7bb937402d51e4658efb5b4d76e4" , .load = load_module, .unload = unload_module, } |
static const char * | app = "Transfer" |
static const struct ast_module_info * | ast_module_info = &__mod_info |
static const char * | descrip |
static const char * | synopsis = "Transfer caller to remote extension" |
Definition in file app_transfer.c.
static void __reg_module | ( | void | ) | [static] |
Definition at line 156 of file app_transfer.c.
static void __unreg_module | ( | void | ) | [static] |
Definition at line 156 of file app_transfer.c.
static int load_module | ( | void | ) | [static] |
Definition at line 151 of file app_transfer.c.
References ast_register_application(), and transfer_exec().
00152 { 00153 return ast_register_application(app, transfer_exec, synopsis, descrip); 00154 }
static int transfer_exec | ( | struct ast_channel * | chan, | |
void * | data | |||
) | [static] |
Definition at line 68 of file app_transfer.c.
References AST_APP_ARG, AST_DECLARE_APP_ARGS, ast_goto_if_exists(), ast_log(), ast_module_user_add, ast_module_user_remove, ast_opt_priority_jumping, AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero(), ast_transfer(), ast_module_user::chan, ast_channel::context, len(), LOG_WARNING, parse(), pbx_builtin_setvar_helper(), ast_channel::tech, ast_channel_tech::transfer, and ast_channel_tech::type.
Referenced by load_module().
00069 { 00070 int res; 00071 int len; 00072 struct ast_module_user *u; 00073 char *slash; 00074 char *tech = NULL; 00075 char *dest = NULL; 00076 char *status; 00077 char *parse; 00078 int priority_jump = 0; 00079 AST_DECLARE_APP_ARGS(args, 00080 AST_APP_ARG(dest); 00081 AST_APP_ARG(options); 00082 ); 00083 00084 u = ast_module_user_add(chan); 00085 00086 if (ast_strlen_zero((char *)data)) { 00087 ast_log(LOG_WARNING, "Transfer requires an argument ([Tech/]destination[|options])\n"); 00088 ast_module_user_remove(u); 00089 pbx_builtin_setvar_helper(chan, "TRANSFERSTATUS", "FAILURE"); 00090 return 0; 00091 } else 00092 parse = ast_strdupa(data); 00093 00094 AST_STANDARD_APP_ARGS(args, parse); 00095 00096 if (args.options) { 00097 if (strchr(args.options, 'j')) 00098 priority_jump = 1; 00099 } 00100 00101 dest = args.dest; 00102 00103 if ((slash = strchr(dest, '/')) && (len = (slash - dest))) { 00104 tech = dest; 00105 dest = slash + 1; 00106 /* Allow execution only if the Tech/destination agrees with the type of the channel */ 00107 if (strncasecmp(chan->tech->type, tech, len)) { 00108 pbx_builtin_setvar_helper(chan, "TRANSFERSTATUS", "FAILURE"); 00109 ast_module_user_remove(u); 00110 return 0; 00111 } 00112 } 00113 00114 /* Check if the channel supports transfer before we try it */ 00115 if (!chan->tech->transfer) { 00116 pbx_builtin_setvar_helper(chan, "TRANSFERSTATUS", "UNSUPPORTED"); 00117 ast_module_user_remove(u); 00118 return 0; 00119 } 00120 00121 res = ast_transfer(chan, dest); 00122 00123 if (res < 0) { 00124 status = "FAILURE"; 00125 if (priority_jump || ast_opt_priority_jumping) 00126 ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101); 00127 res = 0; 00128 } else { 00129 status = "SUCCESS"; 00130 res = 0; 00131 } 00132 00133 pbx_builtin_setvar_helper(chan, "TRANSFERSTATUS", status); 00134 00135 ast_module_user_remove(u); 00136 00137 return res; 00138 }
static int unload_module | ( | void | ) | [static] |
Definition at line 140 of file app_transfer.c.
References ast_module_user_hangup_all, and ast_unregister_application().
00141 { 00142 int res; 00143 00144 res = ast_unregister_application(app); 00145 00146 ast_module_user_hangup_all(); 00147 00148 return res; 00149 }
struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT | AST_MODFLAG_BUILDSUM, .description = "Transfer" , .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 = "361d7bb937402d51e4658efb5b4d76e4" , .load = load_module, .unload = unload_module, } [static] |
Definition at line 156 of file app_transfer.c.
const char* app = "Transfer" [static] |
Definition at line 49 of file app_transfer.c.
const struct ast_module_info* ast_module_info = &__mod_info [static] |
Definition at line 156 of file app_transfer.c.
const char* descrip [static] |
Definition at line 53 of file app_transfer.c.
const char* synopsis = "Transfer caller to remote extension" [static] |
Definition at line 51 of file app_transfer.c.