Add end_bridge_callback for app_follome and add AUTOLOOP flag to res_features

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@153270 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.4
Terry Wilson 17 years ago
parent 1c4d34a0f7
commit 705d6f3742

@ -152,7 +152,6 @@ AST_APP_OPTIONS(followme_opts, {
}); });
static int ynlongest = 0; static int ynlongest = 0;
static time_t start_time, answer_time, end_time;
static const char *featuredigittostr; static const char *featuredigittostr;
static int featuredigittimeout = 5000; /*!< Feature Digit Timeout */ static int featuredigittimeout = 5000; /*!< Feature Digit Timeout */
@ -805,7 +804,6 @@ static void findmeexec(struct fm_args *tpargs)
if (option_debug > 1) if (option_debug > 1)
ast_log(LOG_DEBUG, "Number %s timeout %ld\n", nm->number,nm->timeout); ast_log(LOG_DEBUG, "Number %s timeout %ld\n", nm->number,nm->timeout);
time(&start_time);
number = ast_strdupa(nm->number); number = ast_strdupa(nm->number);
if (option_debug > 2) if (option_debug > 2)
@ -930,7 +928,6 @@ static int app_exec(struct ast_channel *chan, void *data)
int duration = 0; int duration = 0;
struct ast_channel *caller; struct ast_channel *caller;
struct ast_channel *outbound; struct ast_channel *outbound;
static char toast[80];
AST_DECLARE_APP_ARGS(args, AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(followmeid); AST_APP_ARG(followmeid);
@ -1028,6 +1025,27 @@ static int app_exec(struct ast_channel *chan, void *data)
ast_stream_and_wait(chan, targs.sorryprompt, chan->language, ""); ast_stream_and_wait(chan, targs.sorryprompt, chan->language, "");
res = 0; res = 0;
} else { } 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; caller = chan;
outbound = targs.outbound; outbound = targs.outbound;
/* Bridge the two channels. */ /* Bridge the two channels. */
@ -1037,6 +1055,8 @@ static int app_exec(struct ast_channel *chan, void *data)
ast_set_flag(&(config.features_callee), AST_FEATURE_AUTOMON); ast_set_flag(&(config.features_callee), AST_FEATURE_AUTOMON);
ast_set_flag(&(config.features_caller), AST_FEATURE_AUTOMON); ast_set_flag(&(config.features_caller), AST_FEATURE_AUTOMON);
config.end_bridge_callback = end_bridge_callback;
ast_moh_stop(caller); ast_moh_stop(caller);
/* Be sure no generators are left on it */ /* Be sure no generators are left on it */
ast_deactivate_generator(caller); ast_deactivate_generator(caller);
@ -1047,13 +1067,7 @@ static int app_exec(struct ast_channel *chan, void *data)
ast_hangup(outbound); ast_hangup(outbound);
goto outrun; goto outrun;
} }
time(&answer_time);
res = ast_bridge_call(caller,outbound,&config); 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) if (outbound)
ast_hangup(outbound); ast_hangup(outbound);
} }

@ -1449,6 +1449,7 @@ int ast_bridge_call(struct ast_channel *chan,struct ast_channel *peer,struct ast
int diff; int diff;
int hasfeatures=0; int hasfeatures=0;
int hadfeatures=0; int hadfeatures=0;
int autoloopflag;
struct ast_option_header *aoh; struct ast_option_header *aoh;
struct ast_bridge_config backup_config; struct ast_bridge_config backup_config;
struct ast_cdr *bridge_cdr = NULL; struct ast_cdr *bridge_cdr = NULL;
@ -1716,6 +1717,8 @@ int ast_bridge_call(struct ast_channel *chan,struct ast_channel *peer,struct ast
config->end_bridge_callback(); config->end_bridge_callback();
} }
autoloopflag = ast_test_flag(chan, AST_FLAG_IN_AUTOLOOP);
ast_set_flag(chan, AST_FLAG_IN_AUTOLOOP);
if (res != AST_PBX_KEEPALIVE && !ast_test_flag(&(config->features_caller),AST_FEATURE_NO_H_EXTEN) && ast_exists_extension(chan, chan->context, "h", 1, chan->cid.cid_num)) { if (res != AST_PBX_KEEPALIVE && !ast_test_flag(&(config->features_caller),AST_FEATURE_NO_H_EXTEN) && ast_exists_extension(chan, chan->context, "h", 1, chan->cid.cid_num)) {
struct ast_cdr *swapper; struct ast_cdr *swapper;
char savelastapp[AST_MAX_EXTENSION]; char savelastapp[AST_MAX_EXTENSION];
@ -1760,6 +1763,7 @@ int ast_bridge_call(struct ast_channel *chan,struct ast_channel *peer,struct ast
ast_copy_string(bridge_cdr->lastapp, savelastapp, sizeof(bridge_cdr->lastapp)); ast_copy_string(bridge_cdr->lastapp, savelastapp, sizeof(bridge_cdr->lastapp));
ast_copy_string(bridge_cdr->lastdata, savelastdata, sizeof(bridge_cdr->lastdata)); ast_copy_string(bridge_cdr->lastdata, savelastdata, sizeof(bridge_cdr->lastdata));
} }
ast_set2_flag(chan, autoloopflag, AST_FLAG_IN_AUTOLOOP);
/* obey the NoCDR() wishes. -- move the DISABLED flag to the bridge CDR if it was set on the channel during the bridge... */ /* obey the NoCDR() wishes. -- move the DISABLED flag to the bridge CDR if it was set on the channel during the bridge... */
if (res != AST_PBX_KEEPALIVE) { if (res != AST_PBX_KEEPALIVE) {

Loading…
Cancel
Save