Index: app_queue.c =================================================================== --- app_queue.c (revision 22629) +++ app_queue.c (working copy) @@ -3139,6 +3139,44 @@ return 0; } +static int queue_function_queuewaitingcount(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) +{ + int count = 0; + struct ast_call_queue *q; + struct localuser *lu; + struct member *m; + + buf[0] = '\0'; + + if (ast_strlen_zero(data)) { + ast_log(LOG_ERROR, "%s requires an argument: queuename\n", cmd); + return -1; + } + + LOCAL_USER_ADD(lu); + + AST_LIST_LOCK(&queues); + + /* Find the right queue */ + AST_LIST_TRAVERSE(&queues, q, list) { + if (!strcasecmp(q->name, data)) { + ast_mutex_lock(&q->lock); + break; + } + } + + AST_LIST_UNLOCK(&queues); + + if (q) { + count = q->count; + ast_mutex_unlock(&q->lock); + } + + snprintf(buf, len, "%d", count); + LOCAL_USER_REMOVE(lu); + return 0; +} + static int queue_function_queuememberlist(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) { struct localuser *u; @@ -3211,6 +3249,15 @@ .read = queue_function_qac, }; +static struct ast_custom_function queuewaitingcount_function = { + .name = "QUEUE_WAITING_COUNT", + .synopsis = "Count number of calls currently waiting in a queue", + .syntax = "QUEUE_WAITING_COUNT()", + .desc = +"Returns the number of callers currently waiting in the specified queue.\n", + .read = queue_function_queuewaitingcount, +}; + static struct ast_custom_function queuememberlist_function = { .name = "QUEUE_MEMBER_LIST", .synopsis = "Returns a list of interfaces on a queue", @@ -3870,6 +3917,7 @@ res |= ast_custom_function_unregister(&queueagentcount_function); res |= ast_custom_function_unregister(&queuemembercount_function); res |= ast_custom_function_unregister(&queuememberlist_function); + res |= ast_custom_function_unregister(&queuewaitingcount_function); res |= ast_unregister_application(app); STANDARD_HANGUP_LOCALUSERS; @@ -3899,6 +3947,7 @@ res |= ast_custom_function_register(&queueagentcount_function); res |= ast_custom_function_register(&queuemembercount_function); res |= ast_custom_function_register(&queuememberlist_function); + res |= ast_custom_function_register(&queuewaitingcount_function); if (!res) { reload_queues();