aboutsummaryrefslogtreecommitdiffstats
path: root/apps/app_followme.c
diff options
context:
space:
mode:
authortwilson <twilson@f38db490-d61c-443f-a65b-d21fe96a405b>2008-10-31 18:55:33 +0000
committertwilson <twilson@f38db490-d61c-443f-a65b-d21fe96a405b>2008-10-31 18:55:33 +0000
commitb417a0a687cc0c5ed9bac14430cfa70281274657 (patch)
tree88c419c36f1dbffe6e003489a19683b9008f3f12 /apps/app_followme.c
parent3fef0135393c79b4f787773736f750fb1652aea8 (diff)
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/trunk@153181 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps/app_followme.c')
-rw-r--r--apps/app_followme.c31
1 files changed, 22 insertions, 9 deletions
diff --git a/apps/app_followme.c b/apps/app_followme.c
index 7a4b1fdc3..3f8d114ac 100644
--- a/apps/app_followme.c
+++ b/apps/app_followme.c
@@ -148,7 +148,6 @@ AST_APP_OPTIONS(followme_opts, {
});
static int ynlongest = 0;
-static time_t start_time, answer_time, end_time;
static const char *featuredigittostr;
static int featuredigittimeout = 5000; /*!< Feature Digit Timeout */
@@ -788,7 +787,6 @@ static void findmeexec(struct fm_args *tpargs)
while (nm) {
ast_debug(2, "Number %s timeout %ld\n", nm->number,nm->timeout);
- time(&start_time);
number = ast_strdupa(nm->number);
ast_debug(3, "examining %s\n", number);
@@ -964,7 +962,6 @@ static int app_exec(struct ast_channel *chan, void *data)
int duration = 0;
struct ast_channel *caller;
struct ast_channel *outbound;
- static char toast[80];
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(followmeid);
AST_APP_ARG(options);
@@ -1067,6 +1064,27 @@ static int app_exec(struct ast_channel *chan, void *data)
ast_stream_and_wait(chan, targs.sorryprompt, "");
res = 0;
} 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);
+ }
+
caller = chan;
outbound = targs.outbound;
/* Bridge the two channels. */
@@ -1075,6 +1093,7 @@ static int app_exec(struct ast_channel *chan, void *data)
ast_set_flag(&(config.features_callee), AST_FEATURE_REDIRECT);
ast_set_flag(&(config.features_callee), AST_FEATURE_AUTOMON);
ast_set_flag(&(config.features_caller), AST_FEATURE_AUTOMON);
+ config.end_bridge_callback = end_bridge_callback;
ast_moh_stop(caller);
/* Be sure no generators are left on it */
@@ -1086,13 +1105,7 @@ static int app_exec(struct ast_channel *chan, void *data)
ast_hangup(outbound);
goto outrun;
}
- time(&answer_time);
res = ast_bridge_call(caller, outbound, &config);
- time(&end_time);
- snprintf(toast, sizeof(toast), "%ld", (long)(end_time - start_time));
- pbx_builtin_setvar_helper(caller, "DIALEDTIME", toast);
- snprintf(toast, sizeof(toast), "%ld", (long)(end_time - answer_time));
- pbx_builtin_setvar_helper(caller, "ANSWEREDTIME", toast);
if (outbound)
ast_hangup(outbound);
}