Wednesday, July 6, 2011

Classes are starting soon

Get More Info





========================================================================================================================================================================== On Thursday 19 February 2009, Lenz Emilitri wrote: You can know if the queue is full before issuing the answer () or the queue() command, so you can avoid answering at all. I don't think the 'maxlen' option is available from the dialplan. Further, the QUEUE_MEMBER_COUNT function doesn't work with realtime queues. Anyway, I've patched the Queue application to accept an 'a' option, which will automatically answer a channel if it has successfully entered the queue. Patch against 1.4.21 is attached. Will submit for inclusion whenever I've upgraded to 1.6. -- Greetings, Alex Hermann Index: asterisk-1.4.speakup.21/apps/app_queue.c =================================================================== --- asterisk-1.4.speakup.21.orig/apps/app_queue.c 2009-02-19 15:48:32.000000000 +0100 +++ asterisk-1.4.speakup.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, ""), _______________________________________________ --Bandwidth and Colocation Provided by http://www.api-digital.com-- asterisk-dev mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-dev