aboutsummaryrefslogtreecommitdiffstats
path: root/apps/app_dial.c
diff options
context:
space:
mode:
authortwilson <twilson@f38db490-d61c-443f-a65b-d21fe96a405b>2008-10-31 22:11:11 +0000
committertwilson <twilson@f38db490-d61c-443f-a65b-d21fe96a405b>2008-10-31 22:11:11 +0000
commit3324f710d555b5ec030ad0e53c7f6f55bac1f953 (patch)
tree1940ed6dbe3c19ac3257802dabe9829b70273f3f /apps/app_dial.c
parentfcfbbae620c0b424abd16fda1af0c0f70bb0bf05 (diff)
Merged revisions 153181 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk ........ r153181 | twilson | 2008-10-31 13:55:33 -0500 (Fri, 31 Oct 2008) | 5 lines Recent CDR fixes moved execution of the 'h' exten into the bridging code, so variables that were set after ast_bridge_call was called would not show up in the 'h' exten. Added a callback function to handle setting variables, etc. from w/in the bridging code. Calls back into a nested function within the function calling ast_bridge_call (closes issue #13793) Reported by: greenfieldtech ........ git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.1@153266 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps/app_dial.c')
-rw-r--r--apps/app_dial.c37
1 files changed, 25 insertions, 12 deletions
diff --git a/apps/app_dial.c b/apps/app_dial.c
index b0b4c3abb..6b3fafd92 100644
--- a/apps/app_dial.c
+++ b/apps/app_dial.c
@@ -1277,7 +1277,6 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags
int sentringing = 0, moh = 0;
const char *outbound_group = NULL;
int result = 0;
- time_t start_time;
char *parse;
int opermode = 0;
AST_DECLARE_APP_ARGS(args,
@@ -1639,7 +1638,6 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags
}
}
- time(&start_time);
peer = wait_for_answer(chan, outgoing, &to, peerflags, &pa, &num, &result);
/* The ast_channel_datastore_remove() function could fail here if the
@@ -1668,10 +1666,9 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags
/* almost done, although the 'else' block is 400 lines */
} else {
const char *number;
- time_t end_time, answer_time = time(NULL);
- char toast[80]; /* buffer to set variables */
strcpy(pa.status, "ANSWER");
+ pbx_builtin_setvar_helper(chan, "DIALSTATUS", pa.status);
/* Ah ha! Someone answered within the desired timeframe. Of course after this
we will always return with -1 so that it is hung up properly after the
conversation. */
@@ -1902,11 +1899,31 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags
res = ast_dtmf_stream(chan, peer, dtmfcalling, 250, 0);
}
}
-
+
if (res) { /* some error */
res = -1;
- end_time = time(NULL);
} else {
+ auto void end_bridge_callback(void);
+ void end_bridge_callback (void)
+ {
+ char buf[80];
+ time_t end;
+
+ time(&end);
+
+ ast_channel_lock(chan);
+ if (chan->cdr->answer.tv_sec) {
+ snprintf(buf, sizeof(buf), "%ld", end - chan->cdr->answer.tv_sec);
+ pbx_builtin_setvar_helper(chan, "ANSWEREDTIME", buf);
+ }
+
+ if (chan->cdr->start.tv_sec) {
+ snprintf(buf, sizeof(buf), "%ld", end - chan->cdr->start.tv_sec);
+ pbx_builtin_setvar_helper(chan, "DIALEDTIME", buf);
+ }
+ ast_channel_unlock(chan);
+ }
+
if (ast_test_flag64(peerflags, OPT_CALLEE_TRANSFER))
ast_set_flag(&(config.features_callee), AST_FEATURE_REDIRECT);
if (ast_test_flag64(peerflags, OPT_CALLER_TRANSFER))
@@ -1930,6 +1947,8 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags
if (ast_test_flag64(peerflags, OPT_GO_ON))
ast_set_flag(&(config.features_caller), AST_FEATURE_NO_H_EXTEN);
+ config.end_bridge_callback = end_bridge_callback;
+
if (moh) {
moh = 0;
ast_moh_stop(chan);
@@ -1960,14 +1979,8 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags
ast_channel_setoption(chan, AST_OPTION_OPRMODE, &oprmode, sizeof(oprmode), 0);
}
res = ast_bridge_call(chan, peer, &config);
- end_time = time(NULL);
- snprintf(toast, sizeof(toast), "%ld", (long)(end_time - answer_time));
- pbx_builtin_setvar_helper(chan, "ANSWEREDTIME", toast);
}
- snprintf(toast, sizeof(toast), "%ld", (long)(end_time - start_time));
- pbx_builtin_setvar_helper(chan, "DIALEDTIME", toast);
-
if (res != AST_PBX_NO_HANGUP_PEER_PARKED && ast_test_flag64(&opts, OPT_PEER_H)) {
ast_log(LOG_NOTICE, "PEER context: %s; PEER exten: %s; PEER priority: %d\n",
peer->context, peer->exten, peer->priority);