[asterisk-commits] trunk - r8021 in /trunk: channels/ configs/

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Thu Jan 12 13:07:19 CST 2006


Author: mogorman
Date: Thu Jan 12 13:07:18 2006
New Revision: 8021

URL: http://svn.digium.com/view/asterisk?rev=8021&view=rev
Log:
Added option for limiting a user from logging in
as multiple agents at same time. bug 6046 thanks
ppyy

Modified:
    trunk/channels/chan_agent.c
    trunk/channels/chan_sip.c
    trunk/configs/agents.conf.sample

Modified: trunk/channels/chan_agent.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_agent.c?rev=8021&r1=8020&r2=8021&view=diff
==============================================================================
--- trunk/channels/chan_agent.c (original)
+++ trunk/channels/chan_agent.c Thu Jan 12 13:07:18 2006
@@ -157,6 +157,7 @@
 static int autologoff;
 static int wrapuptime;
 static int ackcall;
+static int multiplelogin = 1;
 
 static int maxlogintries = 3;
 static char agentgoodbye[AST_MAX_FILENAME_LEN] = "vm-goodbye";
@@ -1044,6 +1045,8 @@
 	/* Read in [general] section for persistance */
 	if ((general_val = ast_variable_retrieve(cfg, "general", "persistentagents")))
 		persistent_agents = ast_true(general_val);
+	if (ast_false(ast_variable_retrieve(cfg, "general", "multiplelogin") ) ) 
+		multiplelogin=0;
 
 	/* Read in the [agents] section */
 	v = ast_variable_browse(cfg, "agents");
@@ -1254,6 +1257,29 @@
 	return res;
 }
 
+/* return 1 if multiple login is fine, 0 if it is not and we find a match, -1 if multiplelogin is not allowed and we dont find a match. */
+static int allow_multiple_login(char *chan,char *context)
+{
+	struct agent_pvt *p;
+	char loginchan[80];
+	if(multiplelogin)
+		return 1;
+	if(!chan) 
+		return 0;
+	if(!context)
+		context="default";
+
+	snprintf(loginchan, sizeof(loginchan), "%s@%s", chan, !ast_strlen_zero(context) ? context : "default");
+	
+	p = agents;
+	while(p) {
+		if(!strcasecmp(chan, p->loginchan))
+			return 0;
+		p = p->next;
+	}
+	return -1;
+}
+
 /*--- agent_request: Part of the Asterisk PBX interface ---*/
 static struct ast_channel *agent_request(const char *type, int format, void *data, int *cause)
 {
@@ -1822,9 +1848,15 @@
 								res = 0;
 							} else
 								res = ast_app_getdata(chan, "agent-newlocation", tmpchan+pos, sizeof(tmpchan) - 2, 0);
-							if (ast_strlen_zero(tmpchan) || ast_exists_extension(chan, !ast_strlen_zero(context) ? context : "default", tmpchan,
-													     1, NULL))
+							if (ast_strlen_zero(tmpchan) )
 								break;
+							if(ast_exists_extension(chan, !ast_strlen_zero(context) ? context : "default", tmpchan,1, NULL) ) {
+								if(!allow_multiple_login(tmpchan,context) ) {
+									args.extension = NULL;
+									pos = 0;
+								} else
+									break;
+							}
 							if (args.extension) {
 								ast_log(LOG_WARNING, "Extension '%s' is not valid for automatic login of agent '%s'\n", args.extension, p->agent);
 								args.extension = NULL;

Modified: trunk/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_sip.c?rev=8021&r1=8020&r2=8021&view=diff
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Thu Jan 12 13:07:18 2006
@@ -2680,8 +2680,9 @@
 	switch(condition) {
 	case AST_CONTROL_RINGING:
 		if (ast->_state == AST_STATE_RING) {
-			if (!ast_test_flag(p, SIP_PROGRESS_SENT) ||
-			    (ast_test_flag(p, SIP_PROG_INBAND) == SIP_PROG_INBAND_NEVER)) {
+			if ((!ast_test_flag(p, SIP_PROGRESS_SENT) ||
+			    (ast_test_flag(p, SIP_PROG_INBAND) == SIP_PROG_INBAND_NEVER)) &&
+			    ast_test_flag(p, SIP_PROG_INBAND) != SIP_PROG_INBAND_YES) {				
 				/* Send 180 ringing if out-of-band seems reasonable */
 				transmit_response(p, "180 Ringing", &p->initreq);
 				ast_set_flag(p, SIP_RINGING);

Modified: trunk/configs/agents.conf.sample
URL: http://svn.digium.com/view/asterisk/trunk/configs/agents.conf.sample?rev=8021&r1=8020&r2=8021&view=diff
==============================================================================
--- trunk/configs/agents.conf.sample (original)
+++ trunk/configs/agents.conf.sample Thu Jan 12 13:07:18 2006
@@ -9,6 +9,10 @@
 ; Asterisk restarts.
 ;
 persistentagents=yes
+
+;enable or disable a single extension from longing in as multiple
+;agents, defaults to enabled
+;multiplelogin=yes
 
 [agents]
 ;



More information about the asterisk-commits mailing list