Merged revisions 9581 via svnmerge from

https://origsvn.digium.com/svn/asterisk/branches/1.2

........
r9581 | russell | 2006-02-11 13:15:00 -0500 (Sat, 11 Feb 2006) | 2 lines

now that CDR is a loadable module, don't depend on it elsewhere (issue #6460)

........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@9582 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.4
Russell Bryant 20 years ago
parent 1f06418500
commit 95151cead2

@ -2434,6 +2434,8 @@ struct ast_channel *__ast_request_and_dial(const char *type, int format, void *d
ast_set_callerid(chan, oh->cid_num, oh->cid_name, oh->cid_num);
if (oh->parent_channel)
ast_channel_inherit_variables(oh->parent_channel, chan);
if (oh->account)
ast_cdr_setaccount(chan, oh->account);
}
ast_set_callerid(chan, cid_num, cid_name, cid_num);

@ -481,6 +481,7 @@ struct chanmon;
oh.priority = priority; \
oh.cid_num = cid_num; \
oh.cid_name = cid_name; \
oh.account = account; \
oh.vars = vars; \
oh.parent_channel = NULL; \
}
@ -491,6 +492,7 @@ struct outgoing_helper {
int priority;
const char *cid_num;
const char *cid_name;
const char *account;
struct ast_variable *vars;
struct ast_channel *parent_channel;
};

@ -56,8 +56,8 @@
#define EVENT_FLAG_USER (1 << 6) /* Ability to read/set user info */
/* Export manager structures */
#define MAX_HEADERS 80
#define MAX_LEN 256
#define AST_MAX_MANHEADERS 80
#define AST_MAX_MANHEADER_LEN 256
struct eventqent {
struct eventqent *next;
@ -88,7 +88,7 @@ struct mansession {
/*! Authorization for writing */
int writeperm;
/*! Buffer */
char inbuf[MAX_LEN];
char inbuf[AST_MAX_MANHEADER_LEN];
int inlen;
int send_events;
/* Queued events that we've not had the ability to send yet */
@ -101,7 +101,7 @@ struct mansession {
struct message {
int hdrcount;
char headers[MAX_HEADERS][MAX_LEN];
char headers[AST_MAX_MANHEADERS][AST_MAX_MANHEADER_LEN];
};
struct manager_action {

@ -563,11 +563,11 @@ int ast_async_goto_by_name(const char *chan, const char *context, const char *ex
/* Synchronously or asynchronously make an outbound call and send it to a
particular extension */
int ast_pbx_outgoing_exten(const char *type, int format, void *data, int timeout, const char *context, const char *exten, int priority, int *reason, int sync, const char *cid_num, const char *cid_name, struct ast_variable *vars, struct ast_channel **locked_channel);
int ast_pbx_outgoing_exten(const char *type, int format, void *data, int timeout, const char *context, const char *exten, int priority, int *reason, int sync, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel);
/* Synchronously or asynchronously make an outbound call and send it to a
particular application with given extension */
int ast_pbx_outgoing_app(const char *type, int format, void *data, int timeout, const char *app, const char *appdata, int *reason, int sync, const char *cid_num, const char *cid_name, struct ast_variable *vars, struct ast_channel **locked_channel);
int ast_pbx_outgoing_app(const char *type, int format, void *data, int timeout, const char *app, const char *appdata, int *reason, int sync, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel);
/* Functions for returning values from structures */
const char *ast_get_context_name(struct ast_context *con);

@ -66,16 +66,17 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/utils.h"
struct fast_originate_helper {
char tech[256];
char data[256];
char tech[AST_MAX_MANHEADER_LEN];
char data[AST_MAX_MANHEADER_LEN];
int timeout;
char app[256];
char appdata[256];
char cid_name[256];
char cid_num[256];
char context[256];
char exten[256];
char idtext[256];
char app[AST_MAX_APP];
char appdata[AST_MAX_MANHEADER_LEN];
char cid_name[AST_MAX_MANHEADER_LEN];
char cid_num[AST_MAX_MANHEADER_LEN];
char context[AST_MAX_CONTEXT];
char exten[AST_MAX_EXTENSION];
char idtext[AST_MAX_MANHEADER_LEN];
char account[AST_MAX_ACCOUNT_CODE];
int priority;
struct ast_variable *vars;
};
@ -949,12 +950,12 @@ static void *fast_originate(void *data)
res = ast_pbx_outgoing_app(in->tech, AST_FORMAT_SLINEAR, in->data, in->timeout, in->app, in->appdata, &reason, 1,
!ast_strlen_zero(in->cid_num) ? in->cid_num : NULL,
!ast_strlen_zero(in->cid_name) ? in->cid_name : NULL,
in->vars, &chan);
in->vars, in->account, &chan);
} else {
res = ast_pbx_outgoing_exten(in->tech, AST_FORMAT_SLINEAR, in->data, in->timeout, in->context, in->exten, in->priority, &reason, 1,
!ast_strlen_zero(in->cid_num) ? in->cid_num : NULL,
!ast_strlen_zero(in->cid_name) ? in->cid_name : NULL,
in->vars, &chan);
in->vars, in->account, &chan);
}
/* Tell the manager what happened with the channel */
@ -1056,12 +1057,6 @@ static int action_originate(struct mansession *s, struct message *m)
if (ast_strlen_zero(l))
l = NULL;
}
if (account) {
struct ast_variable *newvar;
newvar = ast_variable_new("CDR(accountcode|r)", account);
newvar->next = vars;
vars = newvar;
}
if (ast_true(async)) {
struct fast_originate_helper *fast = malloc(sizeof(struct fast_originate_helper));
if (!fast) {
@ -1081,6 +1076,7 @@ static int action_originate(struct mansession *s, struct message *m)
fast->vars = vars;
ast_copy_string(fast->context, context, sizeof(fast->context));
ast_copy_string(fast->exten, exten, sizeof(fast->exten));
ast_copy_string(fast->account, account, sizeof(fast->account));
fast->timeout = to;
fast->priority = pi;
pthread_attr_init(&attr);
@ -1092,10 +1088,10 @@ static int action_originate(struct mansession *s, struct message *m)
}
}
} else if (!ast_strlen_zero(app)) {
res = ast_pbx_outgoing_app(tech, AST_FORMAT_SLINEAR, data, to, app, appdata, &reason, 1, l, n, vars, NULL);
res = ast_pbx_outgoing_app(tech, AST_FORMAT_SLINEAR, data, to, app, appdata, &reason, 1, l, n, vars, account, NULL);
} else {
if (exten && context && pi)
res = ast_pbx_outgoing_exten(tech, AST_FORMAT_SLINEAR, data, to, context, exten, pi, &reason, 1, l, n, vars, NULL);
res = ast_pbx_outgoing_exten(tech, AST_FORMAT_SLINEAR, data, to, context, exten, pi, &reason, 1, l, n, vars, account, NULL);
else {
astman_send_error(s, m, "Originate with 'Exten' requires 'Context' and 'Priority'");
return 0;
@ -1414,7 +1410,7 @@ static void *session_do(void *data)
if (process_message(s, &m))
break;
memset(&m, 0, sizeof(m));
} else if (m.hdrcount < MAX_HEADERS - 1)
} else if (m.hdrcount < AST_MAX_MANHEADERS - 1)
m.hdrcount++;
} else if (res < 0)
break;

19
pbx.c

@ -4649,7 +4649,7 @@ int ast_pbx_outgoing_cdr_failed(void)
return 0; /* success */
}
int ast_pbx_outgoing_exten(const char *type, int format, void *data, int timeout, const char *context, const char *exten, int priority, int *reason, int sync, const char *cid_num, const char *cid_name, struct ast_variable *vars, struct ast_channel **channel)
int ast_pbx_outgoing_exten(const char *type, int format, void *data, int timeout, const char *context, const char *exten, int priority, int *reason, int sync, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **channel)
{
struct ast_channel *chan;
struct async_stat *as;
@ -4666,7 +4666,7 @@ int ast_pbx_outgoing_exten(const char *type, int format, void *data, int timeout
ast_mutex_lock(&chan->lock);
}
if (chan) {
if(chan->cdr) { /* check if the channel already has a cdr record, if not give it one */
if (chan->cdr) { /* check if the channel already has a cdr record, if not give it one */
ast_log(LOG_WARNING, "%s already has a call record??\n", chan->name);
} else {
chan->cdr = ast_cdr_alloc(); /* allocate a cdr for the channel */
@ -4743,6 +4743,8 @@ int ast_pbx_outgoing_exten(const char *type, int format, void *data, int timeout
ast_copy_string(chan->exten, "failed", sizeof(chan->exten));
chan->priority = 1;
ast_set_variables(chan, vars);
if (account)
ast_cdr_setaccount(chan, account);
ast_pbx_run(chan);
} else
ast_log(LOG_WARNING, "Can't allocate the channel structure, skipping execution of extension 'failed'\n");
@ -4772,6 +4774,8 @@ int ast_pbx_outgoing_exten(const char *type, int format, void *data, int timeout
as->priority = priority;
as->timeout = timeout;
ast_set_variables(chan, vars);
if (account)
ast_cdr_setaccount(chan, account);
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
if (ast_pthread_create(&as->p, &attr, async_wait, as)) {
@ -4813,7 +4817,7 @@ static void *ast_pbx_run_app(void *data)
return NULL;
}
int ast_pbx_outgoing_app(const char *type, int format, void *data, int timeout, const char *app, const char *appdata, int *reason, int sync, const char *cid_num, const char *cid_name, struct ast_variable *vars, struct ast_channel **locked_channel)
int ast_pbx_outgoing_app(const char *type, int format, void *data, int timeout, const char *app, const char *appdata, int *reason, int sync, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel)
{
struct ast_channel *chan;
struct async_stat *as;
@ -4821,9 +4825,10 @@ int ast_pbx_outgoing_app(const char *type, int format, void *data, int timeout,
int res = -1, cdr_res = -1;
struct outgoing_helper oh;
pthread_attr_t attr;
memset(&oh, 0, sizeof(oh));
oh.vars = vars;
oh.vars = vars;
oh.account = account;
if (locked_channel)
*locked_channel = NULL;
@ -4850,6 +4855,8 @@ int ast_pbx_outgoing_app(const char *type, int format, void *data, int timeout,
ast_cdr_start(chan->cdr);
}
ast_set_variables(chan, vars);
if (account)
ast_cdr_setaccount(chan, account);
if (chan->_state == AST_STATE_UP) {
res = 0;
if (option_verbose > 3)
@ -4929,6 +4936,8 @@ int ast_pbx_outgoing_app(const char *type, int format, void *data, int timeout,
ast_copy_string(as->appdata, appdata, sizeof(as->appdata));
as->timeout = timeout;
ast_set_variables(chan, vars);
if (account)
ast_cdr_setaccount(chan, account);
/* Start a new thread, and get something handling this channel. */
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);

@ -86,6 +86,9 @@ struct outgoing {
char cid_num[256];
char cid_name[256];
/* account code */
char account[AST_MAX_ACCOUNT_CODE];
/* Variables and Functions */
struct ast_variable *vars;
@ -211,11 +214,7 @@ static int apply_outgoing(struct outgoing *o, char *fn, FILE *f)
} else
ast_log(LOG_WARNING, "Malformed \"%s\" argument. Should be \"%s: variable=value\"\n", buf, buf);
} else if (!strcasecmp(buf, "account")) {
var = ast_variable_new("CDR(accountcode|r)", c);
if (var) {
var->next = o->vars;
o->vars = var;
}
ast_copy_string(o->account, c, sizeof(o->account));
} else {
ast_log(LOG_WARNING, "Unknown keyword '%s' at line %d of %s\n", buf, lineno, fn);
}
@ -259,11 +258,11 @@ static void *attempt_thread(void *data)
if (!ast_strlen_zero(o->app)) {
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "Attempting call on %s/%s for application %s(%s) (Retry %d)\n", o->tech, o->dest, o->app, o->data, o->retries);
res = ast_pbx_outgoing_app(o->tech, AST_FORMAT_SLINEAR, o->dest, o->waittime * 1000, o->app, o->data, &reason, 2 /* wait to finish */, o->cid_num, o->cid_name, o->vars, NULL);
res = ast_pbx_outgoing_app(o->tech, AST_FORMAT_SLINEAR, o->dest, o->waittime * 1000, o->app, o->data, &reason, 2 /* wait to finish */, o->cid_num, o->cid_name, o->vars, o->account, NULL);
} else {
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "Attempting call on %s/%s for %s@%s:%d (Retry %d)\n", o->tech, o->dest, o->exten, o->context,o->priority, o->retries);
res = ast_pbx_outgoing_exten(o->tech, AST_FORMAT_SLINEAR, o->dest, o->waittime * 1000, o->context, o->exten, o->priority, &reason, 2 /* wait to finish */, o->cid_num, o->cid_name, o->vars, NULL);
res = ast_pbx_outgoing_exten(o->tech, AST_FORMAT_SLINEAR, o->dest, o->waittime * 1000, o->context, o->exten, o->priority, &reason, 2 /* wait to finish */, o->cid_num, o->cid_name, o->vars, o->account, NULL);
}
if (res) {
ast_log(LOG_NOTICE, "Call failed to go through, reason %d\n", reason);

@ -88,7 +88,7 @@ static int orig_app(const char *chan, const char *app, const char *appdata)
return RESULT_SHOWUSAGE;
}
ast_pbx_outgoing_app(chantech, AST_FORMAT_SLINEAR, chandata, TIMEOUT * 1000, app, appdata, &reason, 1, NULL, NULL, NULL, NULL);
ast_pbx_outgoing_app(chantech, AST_FORMAT_SLINEAR, chandata, TIMEOUT * 1000, app, appdata, &reason, 1, NULL, NULL, NULL, NULL, NULL);
return RESULT_SUCCESS;
}
@ -122,7 +122,7 @@ static int orig_exten(const char *chan, const char *data)
if (ast_strlen_zero(context))
context = "default";
ast_pbx_outgoing_exten(chantech, AST_FORMAT_SLINEAR, chandata, TIMEOUT * 1000, context, exten, 1, &reason, 1, NULL, NULL, NULL, NULL);
ast_pbx_outgoing_exten(chantech, AST_FORMAT_SLINEAR, chandata, TIMEOUT * 1000, context, exten, 1, &reason, 1, NULL, NULL, NULL, NULL, NULL);
return RESULT_SUCCESS;
}

Loading…
Cancel
Save