aboutsummaryrefslogtreecommitdiffstats
path: root/channels/chan_agent.c
diff options
context:
space:
mode:
authorkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2005-09-14 00:39:05 +0000
committerkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2005-09-14 00:39:05 +0000
commitc0cb6a4581b84f9739b0b6c5aaa23934fcbf21d8 (patch)
treeccfd948a1b644e5d5a54854b31d0db978ed2f53e /channels/chan_agent.c
parent2753fbf6863f0a4a2beeb350ac68b444a071f05e (diff)
ensure that the AGENTBYCALLERID_* variable is cleared when an agent logs in to a different device (issue #5213)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@6575 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels/chan_agent.c')
-rwxr-xr-xchannels/chan_agent.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/channels/chan_agent.c b/channels/chan_agent.c
index 3818686e7..808776fad 100755
--- a/channels/chan_agent.c
+++ b/channels/chan_agent.c
@@ -690,16 +690,16 @@ static int agent_call(struct ast_channel *ast, char *dest, int timeout)
}
/* store/clear the global variable that stores agentid based on the callerid */
-static void set_agentbycallerid(const struct agent_pvt *agent)
+static void set_agentbycallerid(const char *callerid, const char *agent)
{
char buf[AST_MAX_BUF];
/* if there is no Caller ID, nothing to do */
- if (!agent->logincallerid[0])
+ if (!callerid || ast_strlen_zero(callerid))
return;
- snprintf(buf, sizeof(buf), "%s_%s",GETAGENTBYCALLERID, agent->logincallerid);
- pbx_builtin_setvar_helper(NULL, buf, ast_strlen_zero(agent->loginchan) ? NULL : agent->agent);
+ snprintf(buf, sizeof(buf), "%s_%s",GETAGENTBYCALLERID, callerid);
+ pbx_builtin_setvar_helper(NULL, buf, agent);
}
static int agent_hangup(struct ast_channel *ast)
@@ -760,8 +760,8 @@ static int agent_hangup(struct ast_channel *ast)
p->agent, p->loginchan, logintime, ast->uniqueid);
snprintf(agent, sizeof(agent), "Agent/%s", p->agent);
ast_queue_log("NONE", ast->uniqueid, agent, "AGENTCALLBACKLOGOFF", "%s|%ld|%s", p->loginchan, logintime, "Autologoff");
+ set_agentbycallerid(p->logincallerid, NULL);
p->loginchan[0] = '\0';
- set_agentbycallerid(p);
p->logincallerid[0] = '\0';
}
} else if (p->dead) {
@@ -1445,8 +1445,8 @@ static int agent_logoff(char *agent, int soft)
"Logintime: %ld\r\n",
p->agent, p->loginchan, logintime);
ast_queue_log("NONE", "NONE", agent, "AGENTCALLBACKLOGOFF", "%s|%ld|%s", p->loginchan, logintime, "CommandLogoff");
+ set_agentbycallerid(p->logincallerid, NULL);
p->loginchan[0] = '\0';
- set_agentbycallerid(p);
p->logincallerid[0] = '\0';
ast_device_state_changed("Agent/%s", p->agent);
if (persistent_agents)
@@ -1817,6 +1817,7 @@ static int __login_exec(struct ast_channel *chan, void *data, int callbackmode)
}
exten = tmpchan;
if (!res) {
+ set_agentbycallerid(p->logincallerid, NULL);
if (context && !ast_strlen_zero(context) && !ast_strlen_zero(tmpchan))
snprintf(p->loginchan, sizeof(p->loginchan), "%s@%s", tmpchan, context);
else {
@@ -1827,11 +1828,10 @@ static int __login_exec(struct ast_channel *chan, void *data, int callbackmode)
if (ast_strlen_zero(p->loginchan)) {
login_state = 2;
filename = "agent-loggedoff";
- set_agentbycallerid(p);
} else {
if (chan->cid.cid_num) {
ast_copy_string(p->logincallerid, chan->cid.cid_num, sizeof(p->logincallerid));
- set_agentbycallerid(p);
+ set_agentbycallerid(p->logincallerid, p->agent);
} else
p->logincallerid[0] = '\0';
}
@@ -2272,7 +2272,7 @@ static void reload_agents(void)
ast_copy_string(cur_agent->loginchan, agent_chan, sizeof(cur_agent->loginchan));
if (agent_callerid) {
ast_copy_string(cur_agent->logincallerid, agent_callerid, sizeof(cur_agent->logincallerid));
- set_agentbycallerid(cur_agent);
+ set_agentbycallerid(cur_agent->logincallerid, cur_agent->agent);
} else
cur_agent->logincallerid[0] = '\0';
if (cur_agent->loginstart == 0)