[asterisk-commits] trunk r25056 - in /trunk: apps/app_queue.c configs/queues.conf.sample

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Mon May 8 04:11:05 MST 2006


Author: bweschke
Date: Fri May  5 16:22:45 2006
New Revision: 25056

URL: http://svn.digium.com/view/asterisk?rev=25056&view=rev
Log:
 Allow for the execution of an AGI to the caller's channel right before they get bridged with the queue member that is going to take their call. Add the option to set a MEMBERINTERFACE variable on the caller's channel that will contain the interface of the queue member that is going to/did take the call. #6843 


Modified:
    trunk/apps/app_queue.c
    trunk/configs/queues.conf.sample

Modified: trunk/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_queue.c?rev=25056&r1=25055&r2=25056&view=diff
==============================================================================
--- trunk/apps/app_queue.c (original)
+++ trunk/apps/app_queue.c Fri May  5 16:22:45 2006
@@ -129,7 +129,7 @@
 static char *synopsis = "Queue a call for a call queue";
 
 static char *descrip =
-"  Queue(queuename[|options[|URL][|announceoverride][|timeout]]):\n"
+"  Queue(queuename[|options[|URL][|announceoverride][|timeout][|AGI]):\n"
 "Queues an incoming call in a particular call queue as defined in queues.conf.\n"
 "This application will return to the dialplan if the queue does not exist, or\n"
 "any of the join options cause the caller to not enter the queue.\n"
@@ -148,6 +148,8 @@
 "up by another user.\n"
 "  The optional URL will be sent to the called party if the channel supports\n"
 "it.\n"
+"  The optional AGI parameter will setup an AGI script to be executed on the \n"
+"calling party's channel once they are connected to a queue member.\n"
 "  The timeout will cause the queue to fail out after a specified number of\n"
 "seconds, checked between each queues.conf 'timeout' and 'retry' cycle.\n"
 "  This application sets the following channel variable upon completion:\n"
@@ -329,6 +331,7 @@
 	unsigned int eventwhencalled:1;
 	unsigned int leavewhenempty:2;
 	unsigned int ringinuse:1;
+	unsigned int setinterfacevar:1;
 	unsigned int reportholdtime:1;
 	unsigned int wrapped:1;
 	unsigned int timeoutrestart:1;
@@ -579,6 +582,7 @@
 	q->roundingseconds = 0; /* Default - don't announce seconds */
 	q->servicelevel = 0;
 	q->ringinuse = 1;
+	q->setinterfacevar = 0;
 	q->autofill = autofill_default;
 	q->moh[0] = '\0';
 	q->announce[0] = '\0';
@@ -633,6 +637,8 @@
 			q->timeout = DEFAULT_TIMEOUT;
 	} else if (!strcasecmp(param, "ringinuse")) {
 		q->ringinuse = ast_true(val);
+	} else if (!strcasecmp(param, "setinterfacevar")) {
+		q->setinterfacevar = ast_true(val);
 	} else if (!strcasecmp(param, "monitor-join")) {
 		q->monjoin = ast_true(val);
 	} else if (!strcasecmp(param, "monitor-format")) {
@@ -2068,7 +2074,7 @@
 	return 0;
 }
 
-static int try_calling(struct queue_ent *qe, const char *options, char *announceoverride, const char *url, int *go_on)
+static int try_calling(struct queue_ent *qe, const char *options, char *announceoverride, const char *url, int *go_on, const char *agi)
 {
 	struct member *cur;
 	struct callattempt *outgoing=NULL; /* the queue we are building */
@@ -2080,6 +2086,7 @@
 	struct ast_channel *which;
 	struct callattempt *lpeer;
 	struct member *member;
+	struct ast_app *app;
 	int res = 0, bridge = 0;
 	int numbusies = 0;
 	int x=0;
@@ -2089,6 +2096,8 @@
 	time_t now = time(NULL);
 	struct ast_bridge_config bridge_config;
 	char nondataquality = 1;
+	char *agiexec = NULL;
+	int ret = 0;
 
 	memset(&bridge_config, 0, sizeof(bridge_config));
 	time(&now);
@@ -2299,6 +2308,18 @@
 	 			ast_log(LOG_DEBUG, "app_queue: sendurl=%s.\n", url);
  			ast_channel_sendurl(peer, url);
  		}
+		if (qe->parent->setinterfacevar)
+				pbx_builtin_setvar_helper(qe->chan, "MEMBERINTERFACE", member->interface);
+		if (!ast_strlen_zero(agi)) {
+			if (option_debug)
+				ast_log(LOG_DEBUG, "app_queue: agi=%s.\n", agi);
+			app = pbx_findapp("agi");
+			if (app) {
+				agiexec = ast_strdupa(agi);
+				ret = pbx_exec(qe->chan, app, agiexec);
+			} else 
+				ast_log(LOG_WARNING, "Asked to execute an AGI on this channel, but could not find application (agi)!\n");
+		}
 		ast_queue_log(queuename, qe->chan->uniqueid, peer->name, "CONNECT", "%ld|%s", (long)time(NULL) - qe->start, peer->uniqueid);
 		if (qe->parent->eventwhencalled)
 			manager_event(EVENT_FLAG_AGENT, "AgentConnect",
@@ -2909,6 +2930,7 @@
 		 AST_APP_ARG(url);
 		 AST_APP_ARG(announceoverride);
 		 AST_APP_ARG(queuetimeoutstr);
+		 AST_APP_ARG(agi);
 	);
 	
 	/* Our queue entry */
@@ -3057,7 +3079,7 @@
 				}
 
 				/* Try calling all queue members for 'timeout' seconds */
-				res = try_calling(&qe, args.options, args.announceoverride, args.url, &go_on);
+				res = try_calling(&qe, args.options, args.announceoverride, args.url, &go_on, args.agi);
 
 				if (res) {
 					if (res < 0) {

Modified: trunk/configs/queues.conf.sample
URL: http://svn.digium.com/view/asterisk/trunk/configs/queues.conf.sample?rev=25056&r1=25055&r2=25056&view=diff
==============================================================================
--- trunk/configs/queues.conf.sample (original)
+++ trunk/configs/queues.conf.sample Fri May  5 16:22:45 2006
@@ -98,7 +98,7 @@
 ; 
 ;autofill=yes
 ;
-; Autopause will pause a queue member if the y fail to answer a call
+; Autopause will pause a queue member if they fail to answer a call
 ;
 ;autopause=yes
 ;
@@ -106,6 +106,12 @@
 ;
 ;maxlen = 0
 ;
+; If set to yes, just prior to the caller being bridged with a queue member 
+; the MEMBERINTERFACE variable will be set with the interface name (eg. Agent/1234)
+; of the queue member that was chosen and is now connected to be bridged with
+; the caller
+;
+;setinterfacevar=no
 ;
 ; How often to announce queue position and/or estimated 
 ; holdtime to caller (0=off)



More information about the asterisk-commits mailing list