diff options
author | martinp <martinp@f38db490-d61c-443f-a65b-d21fe96a405b> | 2003-09-12 16:51:35 +0000 |
---|---|---|
committer | martinp <martinp@f38db490-d61c-443f-a65b-d21fe96a405b> | 2003-09-12 16:51:35 +0000 |
commit | da1033cad245fbad3570aab1b49ddba9eb010d6e (patch) | |
tree | 0cfa74e63cdce0bf09e2e845357eac5addf73e15 /channel.c | |
parent | 72f06d4e1646591ef482d0bbf8dddfbcaac51c63 (diff) |
Add distinguishing between BUSY and FAILURE for outgoing spool calls. Always save CDR record (even if the call fails). If the call fails try to see if there is
"failed" extension in the specified context (only if you use context,extension,priority syntax) and execute it.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@1499 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channel.c')
-rwxr-xr-x | channel.c | 37 |
1 files changed, 26 insertions, 11 deletions
@@ -34,6 +34,7 @@ #include <asterisk/linkedlists.h> #include <asterisk/indications.h> #include <asterisk/monitor.h> +#include <asterisk/causes.h> #ifdef ZAPTEL_OPTIMIZATIONS #include <sys/ioctl.h> #include <linux/zaptel.h> @@ -1493,8 +1494,7 @@ struct ast_channel *ast_request_and_dial(char *type, int format, void *data, int int state = 0; struct ast_channel *chan; struct ast_frame *f; - int res; - + int res = 0; chan = ast_request(type, format, data); if (chan) { if (callerid) @@ -1504,8 +1504,6 @@ struct ast_channel *ast_request_and_dial(char *type, int format, void *data, int res = ast_waitfor(chan, timeout); if (res < 0) { /* Something not cool, or timed out */ - ast_hangup(chan); - chan = NULL; break; } /* If done, break out */ @@ -1516,8 +1514,7 @@ struct ast_channel *ast_request_and_dial(char *type, int format, void *data, int f = ast_read(chan); if (!f) { state = AST_CONTROL_HANGUP; - ast_hangup(chan); - chan = NULL; + res = 0; break; } if (f->frametype == AST_FRAME_CONTROL) { @@ -1537,17 +1534,36 @@ struct ast_channel *ast_request_and_dial(char *type, int format, void *data, int } ast_frfree(f); } - } else { - ast_hangup(chan); - chan = NULL; + } else ast_log(LOG_NOTICE, "Unable to request channel %s/%s\n", type, (char *)data); - } } else ast_log(LOG_NOTICE, "Unable to request channel %s/%s\n", type, (char *)data); if (chan && (chan->_state == AST_STATE_UP)) state = AST_CONTROL_ANSWER; if (outstate) *outstate = state; + if (chan && res <= 0) { + if (!chan->cdr) { + chan->cdr = ast_cdr_alloc(); + if (chan->cdr) + ast_cdr_init(chan->cdr, chan); + } + if (chan->cdr) { + char tmp[256]; + sprintf(tmp, "%s/%s",type,(char *)data); + ast_cdr_setapp(chan->cdr,"Dial",tmp); + ast_cdr_update(chan); + ast_cdr_start(chan->cdr); + ast_cdr_end(chan->cdr); + /* If the cause wasn't handled properly */ + if (ast_cdr_disposition(chan->cdr,chan->hangupcause)) + ast_cdr_failed(chan->cdr); + ast_cdr_reset(chan->cdr,1); + } else + ast_log(LOG_WARNING, "Unable to create Call Detail Record\n"); + ast_hangup(chan); + chan = NULL; + } return chan; } @@ -2431,4 +2447,3 @@ int ast_tonepair(struct ast_channel *chan, int freq1, int freq2, int duration, i return 0; } - |