From ad6d79e68b80de4184c7e51627a677a507b29add Mon Sep 17 00:00:00 2001 From: mmichelson Date: Mon, 29 Oct 2007 20:13:23 +0000 Subject: Adding the more flexible QUEUE_MEMBER function to replace the QUEUE_MEMBER_COUNT function. A deprecation notice will be issued the first time QUEUE_MEMBER_COUNT is used. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@87395 f38db490-d61c-443f-a65b-d21fe96a405b --- UPGRADE.txt | 5 ++++ apps/app_queue.c | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 85 insertions(+), 2 deletions(-) diff --git a/UPGRADE.txt b/UPGRADE.txt index 3036d0e0b..48c4eb5cd 100644 --- a/UPGRADE.txt +++ b/UPGRADE.txt @@ -79,6 +79,11 @@ Applications: these functions in any location where you desire to ensure that only one channel is executing that path at any one time. +Dialplan Functions: + +* QUEUE_MEMBER_COUNT() has been deprecated in favor of the QUEUE_MEMBER() function. For + more information, issue a "show function QUEUE_MEMBER" from the CLI. + CDR: * The cdr_sqlite module has been marked as deprecated in favor of diff --git a/apps/app_queue.c b/apps/app_queue.c index d62acb490..5ac4c26fb 100644 --- a/apps/app_queue.c +++ b/apps/app_queue.c @@ -4033,6 +4033,67 @@ static int queue_function_qac(struct ast_channel *chan, const char *cmd, char *d struct call_queue *q, tmpq; struct member *m; struct ao2_iterator mem_iter; + char *queuename, *option; + + buf[0] = '\0'; + + if (ast_strlen_zero(data)) { + ast_log(LOG_ERROR, "%s requires an argument: queuename\n", cmd); + return -1; + } + + queuename = data; + if ((option = strchr(data, ','))) + *option++ = '\0'; + else + option = "logged"; + + ast_copy_string(tmpq.name, queuename, sizeof(tmpq.name)); + + if ((q = ao2_find(queues, &tmpq, OBJ_POINTER))) { + ao2_lock(q); + if(!strcasecmp(option, "logged")) { + mem_iter = ao2_iterator_init(q->members, 0); + while ((m = ao2_iterator_next(&mem_iter))) { + /* Count the agents who are logged in and presently answering calls */ + if ((m->status != AST_DEVICE_UNAVAILABLE) && (m->status != AST_DEVICE_INVALID)) { + count++; + } + ao2_ref(m, -1); + } + } else if(!strcasecmp(option, "free")) { + mem_iter = ao2_iterator_init(q->members, 0); + while ((m = ao2_iterator_next(&mem_iter))) { + /* Count the agents who are logged in and presently answering calls */ + if ((m->status == AST_DEVICE_NOT_INUSE) && (!m->paused)) { + count++; + } + ao2_ref(m, -1); + } + } else /* must be "count" */ + count = q->membercount; + ao2_unlock(q); + queue_unref(q); + } else + ast_log(LOG_WARNING, "queue %s was not found\n", data); + + snprintf(buf, len, "%d", count); + + return 0; +} + +static int queue_function_qac_dep(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len) +{ + int count = 0; + struct call_queue *q, tmpq; + struct member *m; + struct ao2_iterator mem_iter; + static int depflag = 1; + if(depflag) + { + depflag = 0; + ast_log(LOG_NOTICE, "The function QUEUE_MEMBER_COUNT has been deprecated in favor of the QUEUE_MEMBER function and will not be in further releases.\n"); + } buf[0] = '\0'; @@ -4063,6 +4124,7 @@ static int queue_function_qac(struct ast_channel *chan, const char *cmd, char *d return 0; } + static int queue_function_queuewaitingcount(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len) { int count = 0; @@ -4156,12 +4218,26 @@ static struct ast_custom_function queuevar_function = { }; static struct ast_custom_function queuemembercount_function = { + .name = "QUEUE_MEMBER", + .synopsis = "Count number of members answering a queue", + .syntax = "QUEUE_MEMBER(,