Index: apps/app_queue.c =================================================================== --- apps/app_queue.c (revision 81491) +++ apps/app_queue.c (working copy) @@ -3633,6 +3633,12 @@ int count = 0; struct call_queue *q; struct ast_module_user *lu; + struct member *m; + char *parse; + AST_DECLARE_APP_ARGS(args, + AST_APP_ARG(queuename); + AST_APP_ARG(option); + ); buf[0] = '\0'; @@ -3641,11 +3647,14 @@ return -1; } + parse = ast_strdupa(data); + AST_STANDARD_APP_ARGS(args, parse); + lu = ast_module_user_add(chan); AST_LIST_LOCK(&queues); AST_LIST_TRAVERSE(&queues, q, list) { - if (!strcasecmp(q->name, data)) { + if (!strcasecmp(q->name, args.queuename)) { ast_mutex_lock(&q->lock); break; } @@ -3653,7 +3662,23 @@ AST_LIST_UNLOCK(&queues); if (q) { - count = q->membercount; + if (args.option && (strchr(args.option, 'l'))) { + for (m = q->members; m; m = m->next) { + /* Count the agents who are logged in and presently answering calls */ + if ((m->status != AST_DEVICE_UNAVAILABLE) && (m->status != AST_DEVICE_INVALID)) { + count++; + } + } + } else if (args.option && (strchr(args.option, 'f'))) { + for (m = q->members; m; m = m->next) { + /* Count the agents who are logged in and do not have a call at time */ + if (((m->status == AST_DEVICE_NOT_INUSE) || (m->status != AST_DEVICE_UNKNOWN)) && (!m->paused)) { + count++; + } + } + } else { + count = q->membercount; + } ast_mutex_unlock(&q->lock); } else ast_log(LOG_WARNING, "queue %s was not found\n", data); @@ -3765,9 +3790,13 @@ static struct ast_custom_function queuemembercount_function = { .name = "QUEUE_MEMBER_COUNT", .synopsis = "Count number of members answering a queue", - .syntax = "QUEUE_MEMBER_COUNT()", + .syntax = "QUEUE_MEMBER_COUNT(,option)", .desc = -"Returns the number of members currently associated with the specified queue.\n", +"Returns the number of members currently associated with the specified queue.\n" +"The option string may contain zero or one of the following characters:\n" +" 'l' -- return number of logged in members.\n" +" 'f' -- return number of members available to take next call.\n" +" 'c' -- default - return complete member count.\n", .read = queue_function_qac, };