Index: apps/app_queue.c =================================================================== --- apps/app_queue.c (revision 85852) +++ apps/app_queue.c (working copy) @@ -3951,6 +3951,7 @@ struct call_queue *q, tmpq; struct member *m; struct ao2_iterator mem_iter; + char *queuename, *option; buf[0] = '\0'; @@ -3959,18 +3960,36 @@ return -1; } - ast_copy_string(tmpq.name, data, sizeof(tmpq.name)); + 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); - 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++; + 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); } - 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 @@ -4074,11 +4093,15 @@ }; static struct ast_custom_function queuemembercount_function = { - .name = "QUEUE_MEMBER_COUNT", + .name = "QUEUE_MEMBER", .synopsis = "Count number of members answering a queue", - .syntax = "QUEUE_MEMBER_COUNT()", + .syntax = "QUEUE_MEMBER(,