Asterisk - The Open Source Telephony Project  GIT-master-a24979a
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.

Functions

 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)
 

Variables

static const char *const app = "AttendedTransfer"
 

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

◆ AST_MODULE_INFO_STANDARD_EXTENDED()

AST_MODULE_INFO_STANDARD_EXTENDED ( ASTERISK_GPL_KEY  ,
"Attended transfer to the given extension  
)

◆ 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.

78 {
79  char *exten = NULL;
80  const char *context = NULL;
81  char *parse;
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 
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
static const char *const app
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:298
#define ast_log
Definition: astobj2.c:42
static char exten[AST_MAX_EXTENSION]
Definition: chan_alsa.c:122
static char context[AST_MAX_CONTEXT]
Definition: chan_alsa.c:120
static void parse(struct mgcp_request *req)
Definition: chan_mgcp.c:1844
#define ast_channel_lock(chan)
Definition: channel.h:2922
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:1133
#define ast_channel_unlock(chan)
Definition: channel.h:2923
#define AST_APP_ARG(name)
Define an application argument.
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
#define AST_FEATURE_MAX_LEN
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_FRAME_DTMF
#define LOG_WARNING
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.
const char * pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
Return a pointer to the value of the corresponding channel variable.
#define NULL
Definition: resample.c:96
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65
Data structure associated with a single frame of data.
struct ast_frame_subclass subclass
union ast_frame::@254 data
enum ast_frame_type frametype
const char * args

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, ast_frame::data, 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().

◆ load_module()

static int load_module ( void  )
static

Definition at line 138 of file app_attended_transfer.c.

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

References app, ast_register_application_xml, and attended_transfer_exec().

◆ unload_module()

static int unload_module ( void  )
static

Definition at line 133 of file app_attended_transfer.c.

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

References app, and ast_unregister_application().

Variable Documentation

◆ 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().