aboutsummaryrefslogtreecommitdiffstats
path: root/apps/app_queue.c
diff options
context:
space:
mode:
authoroej <oej@f38db490-d61c-443f-a65b-d21fe96a405b>2010-07-16 09:25:48 +0000
committeroej <oej@f38db490-d61c-443f-a65b-d21fe96a405b>2010-07-16 09:25:48 +0000
commit884f6d5489131ce6ae1ee0ed6a909092cfaca49f (patch)
tree76d2d0948c8fb4c4da141f0a1b2213d0cd69d211 /apps/app_queue.c
parent87c28faab41d45cb63d534c908f733679f3e1ac6 (diff)
Add a dialplan function to check if a queue exists: QUEUE_EXISTS
Review: https://reviewboard.asterisk.org/r/777/ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@276950 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps/app_queue.c')
-rw-r--r--apps/app_queue.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/apps/app_queue.c b/apps/app_queue.c
index 11de4d903..286d7a949 100644
--- a/apps/app_queue.c
+++ b/apps/app_queue.c
@@ -469,6 +469,17 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
<ref type="function">QUEUE_MEMBER_LIST</ref>
</see-also>
</function>
+ <function name="QUEUE_EXISTS" language="en_US">
+ <synopsis>
+ Check if a named queue exists on this server
+ </synopsis>
+ <syntax>
+ <parameter name="queuename" />
+ </syntax>
+ <description>
+ <para>Returns 1 if the specified queue exists, 0 if it does not</para>
+ </description>
+ </function>
<function name="QUEUE_WAITING_COUNT" language="en_US">
<synopsis>
Count number of calls currently waiting in a queue.
@@ -5926,6 +5937,29 @@ static int queue_function_var(struct ast_channel *chan, const char *cmd, char *d
return 0;
}
+/*!
+ * \brief Check if a given queue exists
+ *
+ */
+static int queue_function_exists(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
+{
+ struct call_queue *q;
+
+ buf[0] = '\0';
+
+ if (ast_strlen_zero(data)) {
+ ast_log(LOG_ERROR, "%s requires an argument: queuename\n", cmd);
+ return -1;
+ }
+ q = load_realtime_queue(data);
+ snprintf(buf, len, "%d", q != NULL? 1 : 0);
+ if (q) {
+ queue_t_unref(q, "Done with temporary reference in QUEUE_EXISTS()");
+ }
+
+ return 0;
+}
+
/*!
* \brief Get number either busy / free / ready or total members of a specific queue
* \retval number of members (busy / free / ready / total)
@@ -6192,6 +6226,11 @@ static int queue_function_memberpenalty_write(struct ast_channel *chan, const ch
return 0;
}
+static struct ast_custom_function queueexists_function = {
+ .name = "QUEUE_EXISTS",
+ .read = queue_function_exists,
+};
+
static struct ast_custom_function queuevar_function = {
.name = "QUEUE_VARIABLES",
.read = queue_function_var,
@@ -8038,6 +8077,7 @@ static int unload_module(void)
res |= ast_unregister_application(app_upqm);
res |= ast_unregister_application(app_ql);
res |= ast_unregister_application(app);
+ res |= ast_custom_function_unregister(&queueexists_function);
res |= ast_custom_function_unregister(&queuevar_function);
res |= ast_custom_function_unregister(&queuemembercount_function);
res |= ast_custom_function_unregister(&queuemembercount_dep);
@@ -8112,6 +8152,7 @@ static int load_module(void)
res |= ast_manager_register_xml("QueueReload", 0, manager_queue_reload);
res |= ast_manager_register_xml("QueueReset", 0, manager_queue_reset);
res |= ast_custom_function_register(&queuevar_function);
+ res |= ast_custom_function_register(&queueexists_function);
res |= ast_custom_function_register(&queuemembercount_function);
res |= ast_custom_function_register(&queuemembercount_dep);
res |= ast_custom_function_register(&queuememberlist_function);