[asterisk-dev] Queue Auto-Answer

João Castilho jcastilho at gmail.com
Fri Aug 28 11:23:59 CDT 2009


I found this patch  by Alex Hermann in the Asterisk mailing list, a
try it with the recommended 1.4.21 version and whih 1.4.25.1 and
doesn't work.
There a way, to have queue auto-answer, like this patch promissed?
Or there is a way to have auto-answer on-demand, with out the
softphone require a SIP Header like call-info?

Index: asterisk-1.4.21/apps/app_queue.c
===================================================================
--- asterisk-1.4..21.orig/apps/app_queue.c	2009-02-19 15:48:32.000000000 +0100
+++ asterisk-1.4.21/apps/app_queue.c	2009-02-19 16:22:50.000000000 +0100
@@ -155,6 +155,7 @@
 "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"
 "The option string may contain zero or more of the following characters:\n"
+"      'a' -- auto-answer the call when successfully entered the queue.\n"
 "      'd' -- data-quality (modem) call (minimum delay).\n"
 "      'h' -- allow callee to hang up by hitting *.\n"
 "      'H' -- allow caller to hang up by hitting *.\n"
@@ -177,7 +178,7 @@
 "seconds, checked between each queues.conf 'timeout' and 'retry' cycle.\n"
 "  This application sets the following channel variable upon completion:\n"
 "      QUEUESTATUS    The status of the call as a text string, one of\n"
-"             TIMEOUT | FULL | JOINEMPTY | LEAVEEMPTY | JOINUNAVAIL |
LEAVEUNAVAIL\n";
+"             TIMEOUT | FULL | JOINEMPTY | LEAVEEMPTY | JOINUNAVAIL |
LEAVEUNAVAIL | ANSWERFAILED\n";

 static char *app_aqm = "AddQueueMember" ;
 static char *app_aqm_synopsis = "Dynamically adds queue members" ;
@@ -280,6 +281,7 @@
 	QUEUE_JOINUNAVAIL = 4,
 	QUEUE_LEAVEUNAVAIL = 5,
 	QUEUE_FULL = 6,
+	QUEUE_ANSWER_FAILED = 7,
 };

 const struct {
@@ -293,6 +295,7 @@
 	{ QUEUE_JOINUNAVAIL, "JOINUNAVAIL" },
 	{ QUEUE_LEAVEUNAVAIL, "LEAVEUNAVAIL" },
 	{ QUEUE_FULL, "FULL" },
+	{ QUEUE_ANSWER_FAILED, "ANSWERFAILED" },
 };

 /*! \brief We define a custom "local user" structure because we
@@ -1403,7 +1406,7 @@
 	return q;
 }

-static int join_queue(char *queuename, struct queue_ent *qe, enum
queue_result *reason)
+static int join_queue(struct ast_channel *chan, char *queuename, int
auto_answer, struct queue_ent *qe, enum queue_result *reason)
 {
 	struct call_queue *q;
 	struct queue_ent *cur, *prev = NULL;
@@ -1427,6 +1430,15 @@
 	else if (q->maxlen && (q->count >= q->maxlen))
 		*reason = QUEUE_FULL;
 	else {
+
+		if (auto_answer && chan->_state != AST_STATE_UP) {
+			res = ast_answer(chan);
+			if (res) {
+				*reason = QUEUE_ANSWER_FAILED;
+				goto done;
+			}
+		}
+
 		/* There's space for us, put us at the right position inside
 		 * the queue.
 		 * Take into account the priority of the calling user */
@@ -1462,6 +1474,7 @@
 		if (option_debug)
 			ast_log(LOG_DEBUG, "Queue '%s' Join, Channel '%s', Position
'%d'\n", q->name, qe->chan->name, qe->pos );
 	}
+done:
 	ast_mutex_unlock(&q->lock);
 	AST_LIST_UNLOCK(&queues);

@@ -3694,6 +3707,7 @@
 {
 	int res=-1;
 	int ringing=0;
+	int auto_answer=0;
 	struct ast_module_user *lu;
 	const char *user_priority;
 	const char *max_penalty_str;
@@ -3771,6 +3785,9 @@
 	if (args.options && (strchr(args.options, 'r')))
 		ringing = 1;

+	if (args.options && (strchr(args.options, 'a')))
+		auto_answer = 1;
+
 	if (option_debug)
 		ast_log(LOG_DEBUG, "queue: %s, options: %s, url: %s, announce: %s,
expires: %ld, priority: %d\n",
 			args.queuename, args.options, args.url, args.announceoverride,
(long)qe.expire, prio);
@@ -3783,7 +3800,7 @@
 	qe.last_periodic_announce_time = time(NULL);
 	qe.last_periodic_announce_sound = 0;
 	qe.valid_digits = 0;
-	if (!join_queue(args.queuename, &qe, &reason)) {
+	if (!join_queue(chan, args.queuename, auto_answer, &qe, &reason)) {
 		int makeannouncement = 0;

 		ast_queue_log(args.queuename, chan->uniqueid, "NONE", "ENTERQUEUE",
"%s|%s", S_OR(args.url, ""),



More information about the asterisk-dev mailing list