diff --git a/channel.c b/channel.c index e6f0e98ae9728ede6dc16001ecca495d59cd27fa..094a8a33030181b2484e90565bef65282e82060b 100755 --- a/channel.c +++ b/channel.c @@ -1509,12 +1509,14 @@ struct ast_channel *__ast_request_and_dial(char *type, int format, void *data, i while( (var = strtok_r(NULL, "|", &tmp)) ) { pbx_builtin_setvar( chan, var ); } /* /JDG */ - if (*oh->context) + if (oh->context && *oh->context) strncpy(chan->context, oh->context, sizeof(chan->context) - 1); - if (*oh->exten) + if (oh->exten && *oh->exten) strncpy(chan->exten, oh->exten, sizeof(chan->exten) - 1); - if (*oh->callerid) + if (oh->callerid && *oh->callerid) ast_set_callerid(chan, oh->callerid, 1); + if (oh->account && *oh->account) + ast_cdr_setaccount(chan, oh->account); chan->priority = oh->priority; } if (callerid && strlen(callerid)) diff --git a/include/asterisk/channel.h b/include/asterisk/channel.h index d90be73e6f62a4644f7ad6b9325ffb784bc86f12..13e97da7c81de98da4c8f1c4e72afad21bb0d011 100755 --- a/include/asterisk/channel.h +++ b/include/asterisk/channel.h @@ -238,6 +238,7 @@ struct chanmon; oh.priority = priority; \ oh.callerid = callerid; \ oh.variable = variable; \ + oh.account = account; \ } struct outgoing_helper { @@ -246,6 +247,7 @@ struct outgoing_helper { int priority; char *callerid; char *variable; + char *account; }; #define AST_CDR_TRANSFER (1 << 0) diff --git a/include/asterisk/pbx.h b/include/asterisk/pbx.h index 3238ab403a85a3f2a3108003b68e95f455dd0d0a..23366d2eba8b425bb7bdf93e86edf91d3de4945c 100755 --- a/include/asterisk/pbx.h +++ b/include/asterisk/pbx.h @@ -480,11 +480,11 @@ int ast_async_goto_by_name(char *chan, char *context, char *exten, int priority) /* Synchronously or asynchronously make an outbound call and send it to a particular extension */ -int ast_pbx_outgoing_exten(char *type, int format, void *data, int timeout, char *context, char *exten, int priority, int *reason, int sync, char *callerid, char *variable ); +int ast_pbx_outgoing_exten(char *type, int format, void *data, int timeout, char *context, char *exten, int priority, int *reason, int sync, char *callerid, char *variable, char *account ); /* Synchronously or asynchronously make an outbound call and send it to a particular application with given extension */ -int ast_pbx_outgoing_app(char *type, int format, void *data, int timeout, char *app, char *appdata, int *reason, int sync, char *callerid, char *variable); +int ast_pbx_outgoing_app(char *type, int format, void *data, int timeout, char *app, char *appdata, int *reason, int sync, char *callerid, char *variable, char *account); /* Functions for returning values from structures */ char *ast_get_context_name(struct ast_context *con); diff --git a/manager.c b/manager.c index ba33f132c5d7a58d2a69d507b480ad3730ea8385..94f4628b1afcd1cad1d619a0a398e700388ea9b0 100755 --- a/manager.c +++ b/manager.c @@ -448,9 +448,9 @@ static int action_originate(struct mansession *s, struct message *m) *data = '\0'; data++; if (strlen(app)) { - res = ast_pbx_outgoing_app(tech, AST_FORMAT_SLINEAR, data, to, app, appdata, &reason, 0, strlen(callerid) ? callerid : NULL, NULL ); + res = ast_pbx_outgoing_app(tech, AST_FORMAT_SLINEAR, data, to, app, appdata, &reason, 0, strlen(callerid) ? callerid : NULL, NULL, NULL); } else { - res = ast_pbx_outgoing_exten(tech, AST_FORMAT_SLINEAR, data, to, context, exten, pi, &reason, 0, strlen(callerid) ? callerid : NULL, NULL ); + res = ast_pbx_outgoing_exten(tech, AST_FORMAT_SLINEAR, data, to, context, exten, pi, &reason, 0, strlen(callerid) ? callerid : NULL, NULL, NULL); } if (!res) astman_send_ack(s, m, "Originate successfully queued"); diff --git a/pbx.c b/pbx.c index 49a3af341ca1165ca91a5519bcf65c371187bf53..528aa0fbf123b815f03458504fed34d1395ebac3 100755 --- a/pbx.c +++ b/pbx.c @@ -3783,7 +3783,7 @@ static void *async_wait(void *data) return NULL; } -int ast_pbx_outgoing_exten(char *type, int format, void *data, int timeout, char *context, char *exten, int priority, int *reason, int sync, char *callerid, char *variable) +int ast_pbx_outgoing_exten(char *type, int format, void *data, int timeout, char *context, char *exten, int priority, int *reason, int sync, char *callerid, char *variable, char *account) { struct ast_channel *chan; struct async_stat *as; @@ -3888,7 +3888,7 @@ static void *ast_pbx_run_app(void *data) return NULL; } -int ast_pbx_outgoing_app(char *type, int format, void *data, int timeout, char *app, char *appdata, int *reason, int sync, char *callerid, char *variable) +int ast_pbx_outgoing_app(char *type, int format, void *data, int timeout, char *app, char *appdata, int *reason, int sync, char *callerid, char *variable, char *account) { struct ast_channel *chan; struct async_stat *as; diff --git a/pbx/pbx_spool.c b/pbx/pbx_spool.c index d51c17e9c2639bb2b4897f0e2252e73402297869..638dea6406f28878e410b576d7846d83c4c33112 100755 --- a/pbx/pbx_spool.c +++ b/pbx/pbx_spool.c @@ -69,6 +69,8 @@ struct outgoing { /* Channel variables */ char variable[10*256]; + /* Account code */ + char account[256]; /* Maximum length of call */ int maxlen; @@ -159,6 +161,8 @@ static int apply_outgoing(struct outgoing *o, char *fn, FILE *f) strncat(o->variable, c, sizeof(o->variable) - strlen(o->variable) - 1); strncat(o->variable, "|", sizeof(o->variable) - strlen(o->variable) - 1); + } else if (!strcasecmp(buf, "account")) { + strncpy(o->account, c, sizeof(o->account) - 1); } else { ast_log(LOG_WARNING, "Unknown keyword '%s' at line %d of %s\n", buf, lineno, fn); } @@ -185,11 +189,11 @@ static void *attempt_thread(void *data) if (strlen(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->callerid, o->variable); + 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->callerid, o->variable, o->account); } 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->callerid, o->variable ); + 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->callerid, o->variable, o->account); } if (res) { ast_log(LOG_NOTICE, "Call failed to go through, reason %d\n", reason);