From d3403a17ea03efc1df307fd0f4a90414b311b5dc Mon Sep 17 00:00:00 2001 From: markster Date: Sat, 23 Oct 2004 12:19:47 +0000 Subject: First pass at making transfer work within agent (not tested, shouldn't break anything that currently worked) git-svn-id: http://svn.digium.com/svn/asterisk/trunk@4061 f38db490-d61c-443f-a65b-d21fe96a405b --- channels/chan_agent.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'channels/chan_agent.c') diff --git a/channels/chan_agent.c b/channels/chan_agent.c index 2246bf900..706f6754d 100755 --- a/channels/chan_agent.c +++ b/channels/chan_agent.c @@ -324,6 +324,7 @@ static struct ast_frame *agent_read(struct ast_channel *ast) /* Note that we don't hangup if it's not a callback because Asterisk will do it for us when the PBX instance that called login finishes */ if (!ast_strlen_zero(p->loginchan)) { + p->chan->_bridge = NULL; ast_hangup(p->chan); if (p->wrapuptime) { gettimeofday(&p->lastdisc, NULL); @@ -351,6 +352,9 @@ static struct ast_frame *agent_read(struct ast_channel *ast) else { p->acknowledged = 1; f = &answer_frame; + if (p->chan) + p->chan->_bridge = ast; + } } if (f && (f->frametype == AST_FRAME_DTMF) && (f->subclass == '#')) { @@ -360,6 +364,8 @@ static struct ast_frame *agent_read(struct ast_channel *ast) p->acknowledged = 1; ast_frfree(f); f = &answer_frame; + if (p->chan) + p->chan->_bridge = ast; } } if (f && (f->frametype == AST_FRAME_DTMF) && (f->subclass == '*')) { @@ -704,6 +710,19 @@ static int agent_ack_sleep( void *data ) return res; } +static struct ast_channel *agent_bridgedchannel(struct ast_channel *chan, struct ast_channel *bridge) +{ + struct agent_pvt *p; + struct ast_channel *ret=NULL; + + p = bridge->pvt->pvt; + if (chan == p->chan) + ret = bridge->_bridge; + else if (chan == bridge->_bridge) + ret = p->chan; + return NULL; +} + static struct ast_channel *agent_new(struct agent_pvt *p, int state) { struct ast_channel *tmp; @@ -748,6 +767,7 @@ static struct ast_channel *agent_new(struct agent_pvt *p, int state) tmp->pvt->exception = agent_read; tmp->pvt->indicate = agent_indicate; tmp->pvt->fixup = agent_fixup; + tmp->pvt->bridged_channel = agent_bridgedchannel; p->owner = tmp; ast_mutex_lock(&usecnt_lock); usecnt++; @@ -1144,8 +1164,8 @@ static int agents_show(int fd, int argc, char **argv) username[0] = '\0'; if (p->chan) { snprintf(location, sizeof(location), "logged in on %s", p->chan->name); - if (p->owner && p->owner->bridge) { - snprintf(talkingto, sizeof(talkingto), " talking to %s", p->owner->bridge->name); + if (p->owner && ast_bridged_channel(p->owner)) { + snprintf(talkingto, sizeof(talkingto), " talking to %s", ast_bridged_channel(p->owner)->name); } else { strncpy(talkingto, " is idle", sizeof(talkingto) - 1); } -- cgit v1.2.3