Asterisk - The Open Source Telephony Project  18.5.0
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"
Include dependency graph for app_attended_transfer.c:

Go to the source code of this file.


 AST_MODULE_INFO_STANDARD_EXTENDED (ASTERISK_GPL_KEY, "Attended transfer to the given extension")
static int attended_transfer_exec (struct ast_channel *chan, const char *data)
static int load_module (void)
static int unload_module (void)


static const char *const app = "AttendedTransfer"

Detailed Description

Attended transfer by caller channel.

Alexei Gradinari alex2[email protected]grad[email protected]@gmai[email protected][email protected]m

Definition in file app_attended_transfer.c.

Function Documentation


"Attended transfer to the given extension  

Referenced by load_module().

◆ attended_transfer_exec()

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

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 };
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  }
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  }
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);
110  parse = ast_strdupa(data);
111  AST_STANDARD_APP_ARGS(args, parse);
113  exten = args.exten;
115  for (digit = feature_code; *digit; ++digit) {
116  f.subclass.integer = *digit;
117  ast_queue_frame(chan, &f);
118  }
120  for (digit = exten; *digit; ++digit) {
121  f.subclass.integer = *digit;
122  ast_queue_frame(chan, &f);
123  }
125  f.subclass.integer = '#';
126  ast_queue_frame(chan, &f);
128  pbx_builtin_setvar_helper(chan, "ATTENDEDTRANSFERSTATUS", "SUCCESS");
130  return 0;
131 }
char digit
#define ast_channel_lock(chan)
Definition: channel.h:2945
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.
Definition: logger.h:274
const char * args
#define NULL
Definition: resample.c:96
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
#define ast_strlen_zero(foo)
Definition: strings.h:52
#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:1139
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_channel_unlock(chan)
Definition: channel.h:2946
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...
Data structure associated with a single frame of data.
static const char *const app
union ast_frame::@263 data
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  )

Definition at line 138 of file app_attended_transfer.c.

References app, AST_MODULE_INFO_STANDARD_EXTENDED(), ast_register_application_xml, ASTERISK_GPL_KEY, 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  )

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

◆ app

const char* const app = "AttendedTransfer"

Definition at line 75 of file app_attended_transfer.c.

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