[asterisk-commits] eliel: branch group/data_api_gsoc2009 r206633 - in /team/group/data_api_gsoc2...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Jul 15 08:43:59 CDT 2009
Author: eliel
Date: Wed Jul 15 08:43:53 2009
New Revision: 206633
URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=206633
Log:
Pass the root node to the callback, so it is not needed to create it there.
Modified:
team/group/data_api_gsoc2009/apps/app_queue.c
team/group/data_api_gsoc2009/include/asterisk/data.h
team/group/data_api_gsoc2009/main/data.c
team/group/data_api_gsoc2009/tests/test_data.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=206633&r1=206632&r2=206633
==============================================================================
--- team/group/data_api_gsoc2009/apps/app_queue.c (original)
+++ team/group/data_api_gsoc2009/apps/app_queue.c Wed Jul 15 08:43:53 2009
@@ -7547,29 +7547,21 @@
* \retval NULL on error.
* \retval non-NULL The generated tree.
*/
-static struct ast_data *queues_data_provider_get(const struct ast_data_search *search)
+static int queues_data_provider_get(const struct ast_data_search *search,
+ struct ast_data *data_root)
{
struct ao2_iterator i;
- struct call_queue *queue;
- struct ast_data *data_root;
+ struct call_queue *queue, *queue_realtime = NULL;
struct ast_config *cfg;
char *queuename;
- data_root = ast_data_create("queues");
- if (!data_root) {
- return NULL;
- }
-
- /* realtime queues. */
+ /* load realtime queues. */
cfg = ast_load_realtime_multientry("queues", "name LIKE", "%", SENTINEL);
if (cfg) {
for (queuename = ast_category_browse(cfg, NULL);
!ast_strlen_zero(queuename);
queuename = ast_category_browse(cfg, queuename)) {
if ((queue = load_realtime_queue(queuename))) {
- ao2_lock(queue);
- queues_data_provider_get_helper(search, data_root, queue);
- ao2_unlock(queue);
queue_unref(queue);
}
}
@@ -7580,12 +7572,20 @@
i = ao2_iterator_init(queues, 0);
while ((queue = ao2_iterator_next(&i))) {
ao2_lock(queue);
+ if (queue->realtime && !(queue_realtime = load_realtime_queue(queue->name))) {
+ ao2_unlock(queue);
+ queue_unref(queue);
+ continue;
+ } else if (queue->realtime) {
+ queue_unref(queue_realtime);
+ }
+
queues_data_provider_get_helper(search, data_root, queue);
ao2_unlock(queue);
queue_unref(queue);
}
- return data_root;
+ return 0;
}
static const struct ast_data_handler queues_data_provider = {
@@ -7594,7 +7594,7 @@
};
static const struct ast_data_entry queue_data_providers[] = {
- AST_DATA_ENTRY("asterisk/application/app_queue", &queues_data_provider),
+ AST_DATA_ENTRY("asterisk/application/app_queue/queues", &queues_data_provider),
};
static int unload_module(void)
Modified: team/group/data_api_gsoc2009/include/asterisk/data.h
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/data_api_gsoc2009/include/asterisk/data.h?view=diff&rev=206633&r1=206632&r2=206633
==============================================================================
--- team/group/data_api_gsoc2009/include/asterisk/data.h (original)
+++ team/group/data_api_gsoc2009/include/asterisk/data.h Wed Jul 15 08:43:53 2009
@@ -101,7 +101,7 @@
/*! \brief opaque definition of an ast_data_search structure. */
struct ast_data_search;
-typedef struct ast_data *(*ast_data_get_cb)(const struct ast_data_search *search);
+typedef int (*ast_data_get_cb)(const struct ast_data_search *search, struct ast_data *root);
typedef int *(*ast_data_put_cb)(void);
/*! \brief The structure of the node handler. */
Modified: team/group/data_api_gsoc2009/main/data.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/data_api_gsoc2009/main/data.c?view=diff&rev=206633&r1=206632&r2=206633
==============================================================================
--- team/group/data_api_gsoc2009/main/data.c (original)
+++ team/group/data_api_gsoc2009/main/data.c Wed Jul 15 08:43:53 2009
@@ -1466,6 +1466,7 @@
return leaf;
}
+#if 0
/*!
* \internal
* \XXX-document this.
@@ -1501,6 +1502,7 @@
return found;
}
+#endif
/*!
* \internal
@@ -1517,7 +1519,6 @@
struct data_filter_list *flist,
const struct ast_data_search *search)
{
- char *pathtmp;
struct ast_data *generated, *node;
struct ao2_iterator i;
struct data_provider *provider;
@@ -1539,13 +1540,7 @@
/* if this is a terminal node, just run the callback function. */
if (root_provider->handler && root_provider->handler->get) {
- generated = root_provider->handler->get(search);
- if (generated) {
- pathtmp = data_filter_get_last_leaf(parent_node_name);
- data_filter_add_result_child(flist, pathtmp, node, generated);
- ao2_ref(generated, -1);
- }
-
+ root_provider->handler->get(search, node);
ast_module_unref(root_provider->module);
return node;
}
@@ -1566,10 +1561,10 @@
}
if (generated) {
- pathtmp = data_filter_get_last_leaf(provider->name);
- data_filter_add_result_child(flist, pathtmp, node, generated);
+ data_result_add_child(node, generated);
ao2_ref(generated, -1);
}
+
ao2_ref(provider, -1);
}
Modified: team/group/data_api_gsoc2009/tests/test_data.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/data_api_gsoc2009/tests/test_data.c?view=diff&rev=206633&r1=206632&r2=206633
==============================================================================
--- team/group/data_api_gsoc2009/tests/test_data.c (original)
+++ team/group/data_api_gsoc2009/tests/test_data.c Wed Jul 15 08:43:53 2009
@@ -40,9 +40,9 @@
#include "asterisk/cli.h"
#include "asterisk/data.h"
-static struct ast_data *test_data_full_provider(const struct ast_data_search *search)
-{
- struct ast_data *res, *internal;
+static int test_data_full_provider(const struct ast_data_search *search, struct ast_data *root)
+{
+ struct ast_data *internal;
if (ast_data_search_cmp_int(search, "root_test/data1", 10)) {
ast_log(LOG_ERROR, "root_test/data1 doesn't match\n");
@@ -62,29 +62,24 @@
ast_log(LOG_ERROR, "root_test/data2 match!\n");
}
- res = ast_data_create("root_test");
- if (!res) {
- return NULL;
- }
-
- ast_data_add_int(res, "data1", 10);
- ast_data_add_dbl(res, "data2", 20);
- ast_data_add_bool(res, "data3", 1);
- ast_data_add_str(res, "name", "eliel");
-
- internal = ast_data_add_node(res, "internal");
+ ast_data_add_int(root, "data1", 10);
+ ast_data_add_dbl(root, "data2", 20);
+ ast_data_add_bool(root, "data3", 1);
+ ast_data_add_str(root, "name", "eliel");
+
+ internal = ast_data_add_node(root, "internal");
if (!internal) {
- return res;
+ return -1;
}
ast_data_add_str(internal, "name", "eliel");
- return res;
-}
-
-static struct ast_data *test_data_null_provider(const struct ast_data_search *search)
-{
- return NULL;
+ return 0;
+}
+
+static int test_data_null_provider(const struct ast_data_search *search, struct ast_data *root)
+{
+ return 0;
}
static const struct ast_data_handler full_provider = {
More information about the asterisk-commits
mailing list