Create better 'failed' CDRs for outgoing spool calls with context,extension,priority

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@1538 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.0
Martin Pycko 22 years ago
parent a83662beda
commit c545cd3cf7

@ -1489,7 +1489,7 @@ int ast_set_read_format(struct ast_channel *chan, int fmts)
return 0;
}
struct ast_channel *ast_request_and_dial(char *type, int format, void *data, int timeout, int *outstate, char *callerid)
struct ast_channel *__ast_request_and_dial(char *type, int format, void *data, int timeout, int *outstate, char *callerid, struct outgoing_helper *oh)
{
int state = 0;
struct ast_channel *chan;
@ -1497,8 +1497,23 @@ struct ast_channel *ast_request_and_dial(char *type, int format, void *data, int
int res = 0;
chan = ast_request(type, format, data);
if (chan) {
if (callerid)
ast_set_callerid(chan, callerid, 1);
if (oh) {
char *tmp, *var;
/* JDG chanvar */
tmp = oh->variable;
/* FIXME replace this call with strsep NOT*/
while( (var = strtok_r(NULL, "|", &tmp)) ) {
pbx_builtin_setvar( chan, var );
} /* /JDG */
if (*oh->context)
strncpy(chan->context, oh->context, sizeof(chan->context) - 1);
if (*oh->exten)
strncpy(chan->exten, oh->exten, sizeof(chan->exten) - 1);
if (*oh->callerid)
ast_set_callerid(chan, oh->callerid, 1);
chan->priority = oh->priority;
}
if (!ast_call(chan, data, 0)) {
while(timeout && (chan->_state != AST_STATE_UP)) {
res = ast_waitfor(chan, timeout);
@ -1566,6 +1581,11 @@ struct ast_channel *ast_request_and_dial(char *type, int format, void *data, int
return chan;
}
struct ast_channel *ast_request_and_dial(char *type, int format, void *data, int timeout, int *outstate, char *callerid)
{
return __ast_request_and_dial(type, format, data, timeout, outstate, callerid, NULL);
}
struct ast_channel *ast_request(char *type, int format, void *data)
{
struct chanlist *chan;

@ -230,6 +230,22 @@ struct ast_channel {
struct chanmon;
#define LOAD_OH(oh) { \
oh.context = context; \
oh.exten = exten; \
oh.priority = priority; \
oh.callerid = callerid; \
oh.variable = variable; \
}
struct outgoing_helper {
char *context;
char *exten;
int priority;
char *callerid;
char *variable;
};
#define AST_CDR_TRANSFER (1 << 0)
#define AST_CDR_FORWARD (1 << 1)
#define AST_CDR_CALLWAIT (1 << 2)
@ -327,6 +343,8 @@ int ast_device_state(char *device);
*/
struct ast_channel *ast_request_and_dial(char *type, int format, void *data, int timeout, int *reason, char *callerid);
struct ast_channel *__ast_request_and_dial(char *type, int format, void *data, int timeout, int *reason, char *callerid, struct outgoing_helper *oh);
//! Registers a channel
/*!
* \param type type of channel you are registering

@ -521,6 +521,7 @@ struct ast_sw *ast_walk_context_switches(struct ast_context *con, struct ast_sw
extern char *pbx_builtin_getvar_helper(struct ast_channel *chan, char *name);
extern void pbx_builtin_setvar_helper(struct ast_channel *chan, char *name, char *value);
extern void pbx_builtin_clear_globals(void);
extern int pbx_builtin_setvar(struct ast_channel *chan, void *data);
extern void pbx_substitute_variables_helper(struct ast_channel *c,const char *cp1,char *cp2,int count);
int ast_extension_patmatch(const char *pattern, const char *data);

27
pbx.c

@ -162,13 +162,13 @@ static int pbx_builtin_setaccount(struct ast_channel *, void *);
static int pbx_builtin_ringing(struct ast_channel *, void *);
static int pbx_builtin_congestion(struct ast_channel *, void *);
static int pbx_builtin_busy(struct ast_channel *, void *);
static int pbx_builtin_setvar(struct ast_channel *, void *);
static int pbx_builtin_setglobalvar(struct ast_channel *, void *);
static int pbx_builtin_noop(struct ast_channel *, void *);
static int pbx_builtin_gotoif(struct ast_channel *, void *);
static int pbx_builtin_gotoiftime(struct ast_channel *, void *);
static int pbx_builtin_saynumber(struct ast_channel *, void *);
static int pbx_builtin_saydigits(struct ast_channel *, void *);
int pbx_builtin_setvar(struct ast_channel *, void *);
void pbx_builtin_setvar_helper(struct ast_channel *chan, char *name, char *value);
char *pbx_builtin_getvar_helper(struct ast_channel *chan, char *name);
@ -3786,31 +3786,16 @@ int ast_pbx_outgoing_exten(char *type, int format, void *data, int timeout, char
struct async_stat *as;
int res = -1;
char *var, *tmp;
struct outgoing_helper oh;
if (sync) {
chan = ast_request_and_dial(type, format, data, timeout, reason, callerid);
LOAD_OH(oh);
chan = __ast_request_and_dial(type, format, data, timeout, reason, callerid, &oh);
if (chan) {
/* JDG chanvar */
tmp = variable;
/* FIXME replace this call with strsep NOT*/
while( (var = strtok_r(NULL, "|", &tmp)) ) {
pbx_builtin_setvar( chan, var );
} /* /JDG */
if (chan->_state == AST_STATE_UP) {
res = 0;
if (option_verbose > 3)
ast_verbose(VERBOSE_PREFIX_4 "Channel %s was answered.\n", chan->name);
if (context && *context)
strncpy(chan->context, context, sizeof(chan->context) - 1);
if (exten && *exten)
strncpy(chan->exten, exten, sizeof(chan->exten) - 1);
if (callerid && *callerid) {
/* XXX call ast_set_callerid? */
if (chan->callerid)
free(chan->callerid);
chan->callerid = strdup(callerid);
}
if (priority > 0)
chan->priority = priority;
if (sync > 1) {
if (ast_pbx_run(chan)) {
ast_log(LOG_WARNING, "Unable to run PBX on %s\n", chan->name);
@ -4345,7 +4330,7 @@ void pbx_builtin_setvar_helper(struct ast_channel *chan, char *name, char *value
}
}
static int pbx_builtin_setvar(struct ast_channel *chan, void *data)
int pbx_builtin_setvar(struct ast_channel *chan, void *data)
{
char *name;
char *value;

Loading…
Cancel
Save