From 9df33c4ed8f77c92bdba9f45edfe2cb3ccc888fd Mon Sep 17 00:00:00 2001 From: markster Date: Thu, 21 Aug 2003 16:42:13 +0000 Subject: First pass at making '#' work on non-callback agents git-svn-id: http://svn.digium.com/svn/asterisk/trunk@1395 f38db490-d61c-443f-a65b-d21fe96a405b --- channels/chan_agent.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/channels/chan_agent.c b/channels/chan_agent.c index bcd5c8bd3..404862ee2 100755 --- a/channels/chan_agent.c +++ b/channels/chan_agent.c @@ -359,6 +359,7 @@ static int agent_call(struct ast_channel *ast, char *dest, int timeout) struct agent_pvt *p = ast->pvt->pvt; int res = -1; ast_mutex_lock(&p->lock); + p->acknowledged = 0; if (!p->chan) { if (p->pending) { ast_log(LOG_DEBUG, "Pretending to dial on pending agent\n"); @@ -412,8 +413,14 @@ static int agent_call(struct ast_channel *ast, char *dest, int timeout) } if( !res ) { - /* Call is immediately up */ - ast_setstate(ast, AST_STATE_UP); + /* Call is immediately up, or might need ack */ + if (p->ackcall > 1) + ast_setstate(ast, AST_STATE_RINGING); + else { + ast_setstate(ast, AST_STATE_UP); + p->acknowledged = 1; + } + res = 0; } CLEANUP(ast,p); ast_mutex_unlock(&p->lock); @@ -428,13 +435,13 @@ static int agent_hangup(struct ast_channel *ast) p->owner = NULL; ast->pvt->pvt = NULL; p->app_sleep_cond = 1; + p->acknowledged = 0; if (p->start && (ast->_state != AST_STATE_UP)) howlong = time(NULL) - p->start; time(&p->start); if (p->chan) { /* If they're dead, go ahead and hang up on the agent now */ if (strlen(p->loginchan)) { - p->acknowledged = 0; if (p->chan) { /* Recognize the hangup and pass it along immediately */ ast_hangup(p->chan); @@ -645,7 +652,12 @@ static int read_agent_config(void) if (autologoff < 0) autologoff = 0; } else if (!strcasecmp(v->name, "ackcall")) { - ackcall = ast_true(v->value); + if (!strcasecmp(v->value, "always")) + ackcall = 2; + else if (ast_true(v->value)) + ackcall = 1; + else + ackcall = 0; } else if (!strcasecmp(v->name, "wrapuptime")) { wrapuptime = atoi(v->value); if (wrapuptime < 0) @@ -1079,7 +1091,6 @@ static int __login_exec(struct ast_channel *chan, void *data, int callbackmode) /* Login this channel and wait for it to go away */ p->chan = chan; - p->acknowledged = 1; check_availability(p, 0); ast_mutex_unlock(&p->lock); ast_mutex_unlock(&agentlock); -- cgit v1.2.3