[svn-commits] bweschke: branch bweschke/polycom_acd_on_1.4 r97246 - in /team/bweschke/polyc...
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Tue Jan 8 15:51:21 CST 2008
Author: bweschke
Date: Tue Jan 8 15:51:21 2008
New Revision: 97246
URL: http://svn.digium.com/view/asterisk?view=rev&rev=97246
Log:
Commit progress
Modified:
team/bweschke/polycom_acd_on_1.4/channels/chan_agent.c
team/bweschke/polycom_acd_on_1.4/channels/chan_sip.c
team/bweschke/polycom_acd_on_1.4/include/asterisk/channel.h
team/bweschke/polycom_acd_on_1.4/main/channel.c
Modified: team/bweschke/polycom_acd_on_1.4/channels/chan_agent.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/polycom_acd_on_1.4/channels/chan_agent.c?view=diff&rev=97246&r1=97245&r2=97246
==============================================================================
--- team/bweschke/polycom_acd_on_1.4/channels/chan_agent.c (original)
+++ team/bweschke/polycom_acd_on_1.4/channels/chan_agent.c Tue Jan 8 15:51:21 2008
@@ -235,6 +235,8 @@
} while(0)
/*--- Forward declarations */
+static void callback_deprecated(void);
+int agent_cb_login(const char *agentid, const char *extenid, const char *context);
const char *agent_getsecret(const char *agentid);
static struct ast_channel *agent_request(const char *type, int format, void *data, int *cause);
static int agent_devicestate(void *data);
@@ -1846,15 +1848,63 @@
int agent_cb_login(const char *agentid, const char *extenid, const char *context)
{
struct agent_pvt *p;
+ int login_state = 0;
+
+ callback_deprecated();
+
+ if (ast_strlen_zero(agentid)) {
+ ast_log(LOG_ERROR, "No agent specified");
+ return 0;
+ }
+
+ if (ast_strlen_zero(extenid)) {
+ ast_log(LOG_ERROR, "No extension specified");
+ return 0;
+ }
AST_LIST_LOCK(&agents);
AST_LIST_TRAVERSE(&agents, p, list) {
- if (!strcmp(p->agent, agentid) && !p->pending) {
-
- }
+ if (strcmp(p->agent, agentid) || p->pending)
+ continue;
+ if (p->chan) {
+ login_state = 2; /* already logged in (and on the phone) */
+ break;
+ }
+ ast_mutex_lock(&p->lock);
+ login_state = 1; /* Successful login */
+
+ if (ast_strlen_zero(context))
+ ast_copy_string(p->loginchan, extenid, sizeof(p->loginchan));
+ else
+ snprintf(p->loginchan, sizeof(p->loginchan), "%s@%s", extenid, context);
+
+ if (p->loginstart == 0)
+ time(&p->loginstart);
+ ast_copy_string(p->logincallerid, extenid, sizeof(p->logincallerid));
+ set_agentbycallerid(extenid, p->agent);
+ manager_event(EVENT_FLAG_AGENT, "Agentcallbacklogin",
+ "Agent: %s\r\n"
+ "Loginchan: %s\r\n",
+ p->agent, p->loginchan);
+ ast_queue_log("NONE", "NONE", agentid, "AGENTCALLBACKLOGIN", "%s", p->loginchan);
+
+ if (option_verbose > 1)
+ ast_verbose(VERBOSE_PREFIX_2 "Callback Agent '%s' logged in on %s\n", p->agent, p->loginchan);
+ ast_device_state_changed("Agent/%s", p->agent);
+ ast_mutex_unlock(&p->lock);
+ if (persistent_agents)
+ dump_agents();
}
AST_LIST_UNLOCK(&agents);
- return 0;
+
+ if (option_debug > 2 && login_state == 1)
+ ast_log(LOG_DEBUG, "Agent '%s' logged in via API call\n", agentid);
+ else if (option_debug > 2 && login_state == 0)
+ ast_log(LOG_DEBUG, "No such agent, '%s', to login\n", agentid);
+ if (option_debug > 2 && login_state == 2)
+ ast_log(LOG_DEBUG, "Agent '%s' already logged in, and on the phone\n", agentid);
+
+ return 0;
}
/*!
@@ -2721,7 +2771,7 @@
/* Dialplan Functions */
ast_custom_function_register(&agent_function);
- ast_install_ast_agent_functions(agent_getsecret);
+ ast_install_ast_agent_functions(agent_getsecret, agent_cb_login);
return 0;
}
Modified: team/bweschke/polycom_acd_on_1.4/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/polycom_acd_on_1.4/channels/chan_sip.c?view=diff&rev=97246&r1=97245&r2=97246
==============================================================================
--- team/bweschke/polycom_acd_on_1.4/channels/chan_sip.c (original)
+++ team/bweschke/polycom_acd_on_1.4/channels/chan_sip.c Tue Jan 8 15:51:21 2008
@@ -9537,9 +9537,10 @@
else
goto agentauthwrong;
checkauthret = check_auth(p, req, p->digestname, agentsecret, NULL, sipmethod, uri2, reliable, ast_test_flag(req, SIP_PKT_IGNORE));
- if (!checkauthret)
+ if (!checkauthret) {
ast_log(LOG_DEBUG, "auth'd correctly with %s on peer %s\n", p->digestname, peer->name);
- else {
+ ast_agent_cb_login(p->digestname, peer->name, peer->agentcbcontext);
+ } else {
agentauthwrong:
ast_log(LOG_DEBUG, "not auth'd correctly with %s on peer %s\n", p->digestname, peer->name);
}
Modified: team/bweschke/polycom_acd_on_1.4/include/asterisk/channel.h
URL: http://svn.digium.com/view/asterisk/team/bweschke/polycom_acd_on_1.4/include/asterisk/channel.h?view=diff&rev=97246&r1=97245&r2=97246
==============================================================================
--- team/bweschke/polycom_acd_on_1.4/include/asterisk/channel.h (original)
+++ team/bweschke/polycom_acd_on_1.4/include/asterisk/channel.h Tue Jan 8 15:51:21 2008
@@ -1395,9 +1395,10 @@
*/
char *ast_channel_reason2str(int reason);
-void ast_install_ast_agent_functions(const char *(*agent_getsecret_ptr)(const char *));
+void ast_install_ast_agent_functions(const char *(*agent_getsecret_ptr)(const char *), int (*agent_cb_login_ptr)(const char *, const char *, const char *));
void ast_uninstall_agent_functions(void);
const char *ast_agent_getsecret(const char *agentid);
+int ast_agent_cb_login(const char *agentid, const char *extenid, const char *context);
#if defined(__cplusplus) || defined(c_plusplus)
}
Modified: team/bweschke/polycom_acd_on_1.4/main/channel.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/polycom_acd_on_1.4/main/channel.c?view=diff&rev=97246&r1=97245&r2=97246
==============================================================================
--- team/bweschke/polycom_acd_on_1.4/main/channel.c (original)
+++ team/bweschke/polycom_acd_on_1.4/main/channel.c Tue Jan 8 15:51:21 2008
@@ -4622,15 +4622,18 @@
}
static const char *(*ast_agent_getsecret_ptr)(const char *) = NULL;
-
-void ast_install_ast_agent_functions(const char *(*agent_getsecret_ptr)(const char *))
+static int (*ast_agent_cb_login_ptr)(const char *, const char *, const char *) = NULL;
+
+void ast_install_ast_agent_functions(const char *(*agent_getsecret_ptr)(const char *), int (*agent_cb_login_ptr)(const char *, const char*, const char*))
{
ast_agent_getsecret_ptr = agent_getsecret_ptr;
+ ast_agent_cb_login_ptr = agent_cb_login_ptr;
}
void ast_uninstall_agent_functions(void)
{
ast_agent_getsecret_ptr = NULL;
+ ast_agent_cb_login_ptr = NULL;
}
const char *ast_agent_getsecret(const char *agentid)
@@ -4640,6 +4643,18 @@
if (option_verbose > 2)
ast_log(LOG_WARNING, "Agent lookup requested on agent ID %s but no chan_agent is loaded\n", agentid);
+ return 0;
+
+}
+
+int ast_agent_cb_login(const char *agentid, const char *extenid, const char *context)
+{
+
+ if (ast_agent_cb_login_ptr)
+ return ast_agent_cb_login_ptr(agentid, extenid, context);
+
+ if (option_verbose > 2)
+ ast_log(LOG_WARNING, "Agent API login requested on agent ID %s but no chan_agent is loaded\n", agentid);
return 0;
}
More information about the svn-commits
mailing list