Asterisk - The Open Source Telephony Project  GIT-master-1f78ee9
Functions | Variables
app_attended_transfer.c File Reference

Attended transfer by caller channel. More...

#include "asterisk.h"
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "asterisk/app.h"
#include "asterisk/channel.h"
#include "asterisk/bridge.h"
#include "asterisk/features_config.h"

Go to the source code of this file.

Functions

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

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Attended transfer to the given 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 = "AttendedTransfer"
 
static const struct ast_module_infoast_module_info = &__mod_info
 

Detailed Description

Attended transfer by caller channel.

Author
Alexei Gradinari alex2.nosp@m.grad.nosp@m.@gmai.nosp@m.l.co.nosp@m.m

Definition in file app_attended_transfer.c.

Function Documentation

◆ __reg_module()

static void __reg_module ( void  )
static

Definition at line 143 of file app_attended_transfer.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 143 of file app_attended_transfer.c.

◆ AST_MODULE_SELF_SYM()

struct ast_module* AST_MODULE_SELF_SYM ( void  )

Definition at line 143 of file app_attended_transfer.c.

◆ attended_transfer_exec()

static int attended_transfer_exec ( struct ast_channel chan,
const char *  data 
)
static

Definition at line 77 of file app_attended_transfer.c.

References app, args, AST_APP_ARG, ast_channel_lock, ast_channel_unlock, AST_DECLARE_APP_ARGS, AST_FEATURE_MAX_LEN, AST_FRAME_DTMF, ast_get_builtin_feature(), ast_log, ast_queue_frame(), AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero, context, digit, exten, ast_frame::frametype, ast_frame_subclass::integer, LOG_WARNING, NULL, parse(), pbx_builtin_getvar_helper(), pbx_builtin_setvar_helper(), and ast_frame::subclass.

Referenced by load_module().

78 {
79  char *exten = NULL;
80  const char *context = NULL;
81  char *parse;
83  AST_APP_ARG(exten);
84  );
85  char feature_code[AST_FEATURE_MAX_LEN];
86  const char *digit;
87  struct ast_frame f = { .frametype = AST_FRAME_DTMF };
88 
89  if (ast_strlen_zero((char *)data)) {
90  ast_log(LOG_WARNING, "%s requires an argument (exten)\n", app);
91  pbx_builtin_setvar_helper(chan, "ATTENDEDTRANSFERSTATUS", "FAILURE");
92  return 0;
93  }
94 
95  context = pbx_builtin_getvar_helper(chan, "TRANSFER_CONTEXT");
96  if (ast_strlen_zero(context)) {
97  pbx_builtin_setvar_helper(chan, "ATTENDEDTRANSFERSTATUS", "NOTPERMITTED");
98  return 0;
99  }
100 
101  ast_channel_lock(chan);
102  if (ast_get_builtin_feature(chan, "atxfer", feature_code, sizeof(feature_code)) ||
103  ast_strlen_zero(feature_code)) {
104  pbx_builtin_setvar_helper(chan, "ATTENDEDTRANSFERSTATUS", "NOTPERMITTED");
105  ast_channel_unlock(chan);
106  return 0;
107  }
108  ast_channel_unlock(chan);
109 
110  parse = ast_strdupa(data);
111  AST_STANDARD_APP_ARGS(args, parse);
112 
113  exten = args.exten;
114 
115  for (digit = feature_code; *digit; ++digit) {
116  f.subclass.integer = *digit;
117  ast_queue_frame(chan, &f);
118  }
119 
120  for (digit = exten; *digit; ++digit) {
121  f.subclass.integer = *digit;
122  ast_queue_frame(chan, &f);
123  }
124 
125  f.subclass.integer = '#';
126  ast_queue_frame(chan, &f);
127 
128  pbx_builtin_setvar_helper(chan, "ATTENDEDTRANSFERSTATUS", "SUCCESS");
129 
130  return 0;
131 }
char digit
#define ast_channel_lock(chan)
Definition: channel.h:2837
static char exten[AST_MAX_EXTENSION]
Definition: chan_alsa.c:118
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
#define LOG_WARNING
Definition: logger.h:274
const char * args
#define NULL
Definition: resample.c:96
#define AST_FRAME_DTMF
const char * pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
Return a pointer to the value of the corresponding channel variable.
struct ast_frame_subclass subclass
union ast_frame::@255 data
#define ast_log
Definition: astobj2.c:42
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:300
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to a channel's frame queue.
Definition: channel.c:1135
int ast_get_builtin_feature(struct ast_channel *chan, const char *feature, char *buf, size_t len)
Get the DTMF code for a builtin feature.
#define ast_strlen_zero(a)
Definition: muted.c:73
#define ast_channel_unlock(chan)
Definition: channel.h:2838
static void parse(struct mgcp_request *req)
Definition: chan_mgcp.c:1872
int pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value)
Add a variable to the channel variable stack, removing the most recently set value for the same name...
#define AST_FEATURE_MAX_LEN
Data structure associated with a single frame of data.
static const char *const app
enum ast_frame_type frametype
static char context[AST_MAX_CONTEXT]
Definition: chan_alsa.c:116
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
#define AST_APP_ARG(name)
Define an application argument.

◆ load_module()

static int load_module ( void  )
static

Definition at line 138 of file app_attended_transfer.c.

References app, ast_register_application_xml, and attended_transfer_exec().

139 {
141 }
static int attended_transfer_exec(struct ast_channel *chan, const char *data)
static const char *const app
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
Definition: module.h:626

◆ unload_module()

static int unload_module ( void  )
static

Definition at line 133 of file app_attended_transfer.c.

References app, and ast_unregister_application().

134 {
136 }
int ast_unregister_application(const char *app)
Unregister an application.
Definition: pbx_app.c:392
static const char *const app

Variable Documentation

◆ __mod_info

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Attended transfer to the given 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 143 of file app_attended_transfer.c.

◆ app

const char* const app = "AttendedTransfer"
static

Definition at line 75 of file app_attended_transfer.c.

Referenced by attended_transfer_exec(), load_module(), and unload_module().

◆ ast_module_info

const struct ast_module_info* ast_module_info = &__mod_info
static

Definition at line 143 of file app_attended_transfer.c.