aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormartinp <martinp@f38db490-d61c-443f-a65b-d21fe96a405b>2003-09-22 15:27:09 +0000
committermartinp <martinp@f38db490-d61c-443f-a65b-d21fe96a405b>2003-09-22 15:27:09 +0000
commitafd7d66d7fce31a65e9ba0c33152ea51c0f51368 (patch)
tree3847bb85d068ba5039561c73c0bc5a9c2aeda993
parentcb741d4947db6afbe80d406456c9d3d740460874 (diff)
Create better 'failed' CDRs for outgoing spool calls with context,extension,priority
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@1538 f38db490-d61c-443f-a65b-d21fe96a405b
-rwxr-xr-xchannel.c26
-rwxr-xr-xinclude/asterisk/channel.h18
-rwxr-xr-xinclude/asterisk/pbx.h1
-rwxr-xr-xpbx.c29
4 files changed, 49 insertions, 25 deletions
diff --git a/channel.c b/channel.c
index 6b9038873..00c863b75 100755
--- a/channel.c
+++ b/channel.c
@@ -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;
diff --git a/include/asterisk/channel.h b/include/asterisk/channel.h
index f33bb62d3..16a148302 100755
--- a/include/asterisk/channel.h
+++ b/include/asterisk/channel.h
@@ -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
diff --git a/include/asterisk/pbx.h b/include/asterisk/pbx.h
index 32dfcc127..3238ab403 100755
--- a/include/asterisk/pbx.h
+++ b/include/asterisk/pbx.h
@@ -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);
diff --git a/pbx.c b/pbx.c
index 058208154..aa833c791 100755
--- a/pbx.c
+++ b/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;
+ 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;