[asterisk-commits] eliel: branch group/data_api_gsoc2009 r205760 - /team/group/data_api_gsoc2009...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Jul 9 20:55:07 CDT 2009
Author: eliel
Date: Thu Jul 9 20:55:02 2009
New Revision: 205760
URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=205760
Log:
Start using the data API in the real life.
Modified:
team/group/data_api_gsoc2009/apps/app_queue.c
Modified: team/group/data_api_gsoc2009/apps/app_queue.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/data_api_gsoc2009/apps/app_queue.c?view=diff&rev=205760&r1=205759&r2=205760
==============================================================================
--- team/group/data_api_gsoc2009/apps/app_queue.c (original)
+++ team/group/data_api_gsoc2009/apps/app_queue.c Thu Jul 9 20:55:02 2009
@@ -96,6 +96,7 @@
#include "asterisk/taskprocessor.h"
#include "asterisk/callerid.h"
#include "asterisk/cel.h"
+#include "asterisk/data.h"
/*!
* \par Please read before modifying this file.
@@ -7388,6 +7389,50 @@
AST_CLI_DEFINE(handle_queue_reset, "Reset statistics for a queue"),
};
+/*!
+ * \internal
+ * \brief XXX-document this.
+ */
+static struct ast_data *queues_data_provider_get(const struct ast_data_search *search)
+{
+ struct ao2_iterator i;
+ struct call_queue *queue;
+ struct ast_data *res, *q;
+
+ res = ast_data_create("queues");
+ if (!res) {
+ return NULL;
+ }
+
+ i = ao2_iterator_init(queues, 0);
+ while ((queue = ao2_iterator_next(&i))) {
+ ao2_lock(queue);
+
+ q = ast_data_add_node(res, "queue");
+ if (!q) {
+ ao2_unlock(queue);
+ queue_unref(queue);
+ continue;
+ }
+
+ ast_data_add_str(q, "name", queue->name);
+
+ ao2_unlock(queue);
+ queue_unref(queue);
+ }
+
+ return res;
+}
+
+static const struct ast_data_handler queues_data_provider = {
+ .version = AST_DATA_HANDLER_VERSION,
+ .get = queues_data_provider_get
+};
+
+static const struct ast_data_entry queue_data_providers[] = {
+ AST_DATA_ENTRY("asterisk/application/queue", &queues_data_provider),
+};
+
static int unload_module(void)
{
int res;
@@ -7418,6 +7463,8 @@
res |= ast_custom_function_unregister(&queuewaitingcount_function);
res |= ast_custom_function_unregister(&queuememberpenalty_function);
+ res |= ast_data_unregister(NULL);
+
if (device_state_sub)
ast_event_unsubscribe(device_state_sub);
@@ -7458,6 +7505,8 @@
if (queue_persistent_members)
reload_queue_members();
+
+ ast_data_register_multiple(queue_data_providers, ARRAY_LEN(queue_data_providers));
ast_cli_register_multiple(cli_queue, ARRAY_LEN(cli_queue));
res = ast_register_application_xml(app, queue_exec);
More information about the asterisk-commits
mailing list