[asterisk-commits] eliel: branch group/data_api_gsoc2009 r207355 - in /team/group/data_api_gsoc2...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Jul 20 09:17:02 CDT 2009
Author: eliel
Date: Mon Jul 20 09:17:00 2009
New Revision: 207355
URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=207355
Log:
Fix the search engine in the app_queue/queues node.
Modified:
team/group/data_api_gsoc2009/apps/app_queue.c
team/group/data_api_gsoc2009/include/asterisk/channel.h
team/group/data_api_gsoc2009/include/asterisk/data.h
team/group/data_api_gsoc2009/main/channel.c
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=207355&r1=207354&r2=207355
==============================================================================
--- team/group/data_api_gsoc2009/apps/app_queue.c (original)
+++ team/group/data_api_gsoc2009/apps/app_queue.c Mon Jul 20 09:17:00 2009
@@ -7539,7 +7539,8 @@
static void queues_data_provider_get_helper(const struct ast_data_search *search,
struct ast_data *data_root, struct call_queue *queue)
{
- int member_added = 0, caller_added = 0, member_notmatch = 0, caller_notmatch = 0;
+ int member_added = 0, caller_added = 0;
+ int member_notmatch = 1, caller_notmatch = 1, caller_channel_notmatch = 1;
struct ao2_iterator im;
struct member *member;
struct queue_ent *qe;
@@ -7549,6 +7550,7 @@
/* compare the search pattern. */
if (ast_data_search_cmp_structure(search, call_queue, queue, "queue")) {
/* this doesn't match! continue! */
+ ast_log(LOG_ERROR, "queue doesn't match!\n");
return;
}
@@ -7556,11 +7558,9 @@
im = ao2_iterator_init(queue->members, 0);
while ((member = ao2_iterator_next(&im))) {
/* compare the member structure. */
- if (ast_data_search_cmp_structure(search, member, member,
+ if (!ast_data_search_cmp_structure(search, member, member,
"queue/members/member")) {
- ao2_ref(member, -1);
- member_notmatch = 1;
- continue;
+ member_notmatch = 0;
}
if (!data_queue) {
@@ -7588,6 +7588,7 @@
ast_data_add_structure(member, data_member, member);
member_added++;
+
ao2_ref(member, -1);
}
@@ -7602,10 +7603,14 @@
if (queue->head) {
for (qe = queue->head; qe; qe = qe->next) {
/* compare the member structure. */
- if (ast_data_search_cmp_structure(search, queue_ent, qe,
+ if (!ast_data_search_cmp_structure(search, queue_ent, qe,
"queue/callers/caller")) {
- caller_notmatch = 1;
- continue;
+ caller_notmatch = 0;
+ }
+
+ if (!ast_channel_data_cmp_structure(search, qe->chan,
+ "queue/callers/caller/channel")) {
+ caller_channel_notmatch = 0;
}
if (!data_queue) {
@@ -7645,11 +7650,12 @@
/* if there is a condition to match, but this queue has nothing to compare,
* do not return it. */
caller_notmatch = ast_data_search_has_condition(search, "queue/callers/caller");
+ caller_channel_notmatch = ast_data_search_has_condition(search, "queue/callers/caller/channel");
}
/* if there was a member added to the tree, then added the following
* queue to the tree. */
- if (member_added || (!member_notmatch && !caller_notmatch)) {
+ if (!member_notmatch && !caller_notmatch && !caller_channel_notmatch) {
if (!data_queue) {
data_queue = ast_data_add_node(data_root, "queue");
if (!data_queue) {
@@ -7657,6 +7663,8 @@
}
}
ast_data_add_structure(call_queue, data_queue, queue);
+ } else {
+ ast_data_remove_node(data_root, data_queue);
}
}
Modified: team/group/data_api_gsoc2009/include/asterisk/channel.h
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/data_api_gsoc2009/include/asterisk/channel.h?view=diff&rev=207355&r1=207354&r2=207355
==============================================================================
--- team/group/data_api_gsoc2009/include/asterisk/channel.h (original)
+++ team/group/data_api_gsoc2009/include/asterisk/channel.h Mon Jul 20 09:17:00 2009
@@ -2651,6 +2651,17 @@
*/
int ast_channel_data_add_structure(struct ast_data *tree, struct ast_channel *chan);
+/*!
+ * \brief Compare to channel structures using the data api.
+ * \param[in] tree The search tree generated by the data api.
+ * \param[in] chan The channel to compare.
+ * \param[in] structure_name The name of the node of the channel structure.
+ * \retval 0 The structure matches.
+ * \retval 1 The structure doesn't matches.
+ */
+int ast_channel_data_cmp_structure(const struct ast_data_search *tree, struct ast_channel *chan,
+ const char *structure_name);
+
#if defined(__cplusplus) || defined(c_plusplus)
}
#endif
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=207355&r1=207354&r2=207355
==============================================================================
--- team/group/data_api_gsoc2009/include/asterisk/data.h (original)
+++ team/group/data_api_gsoc2009/include/asterisk/data.h Mon Jul 20 09:17:00 2009
@@ -416,14 +416,6 @@
void ast_data_free(struct ast_data *root);
/*!
- * \brief Allocate a 'data' node structure.
- * \param[in] name The root node name.
- * \retval NULL on error.
- * \retval non-NULL The allocated structure.
- */
-struct ast_data *ast_data_create(const char *name);
-
-/*!
* \brief Get a node type.
* \param[in] res A pointer to the ast_data result set.
* \param[in] path A path to the node to get the type.
@@ -524,13 +516,13 @@
unsigned int boolean);
/*!
- * \brief
- * \param[in] root
- * \param[in] mapping
- * \param[in] mapping_len
- * \param[in] structure
- * \retval 0
- * \retval 1
+ * \brief Add a complete structure to a node.
+ * \param[in] root Where to add the structure.
+ * \param[in] mapping The structure mapping array.
+ * \param[in] mapping_len The lenght of the mapping array.
+ * \param[in] structure The structure pointer.
+ * \retval 0 on success.
+ * \retval 1 on error.
*/
int __ast_data_add_structure(struct ast_data *root,
const struct ast_data_mapping_structure *mapping, size_t mapping_len,
@@ -540,6 +532,13 @@
ARRAY_LEN(__data_mapping_structure_##structure_name), structure)
/*!
+ * \brief Remove a node that was added using ast_data_add_
+ * \param[in] root The root node of the node to be removed.
+ * \param[in] child The node pointer to remove.
+ */
+void ast_data_remove_node(struct ast_data *root, struct ast_data *child);
+
+/*!
* \brief Initialize an iterator.
* \param[in] tree The returned tree by a call to ast_data_get.
* \param[in] elements Which elements to iterate through.
Modified: team/group/data_api_gsoc2009/main/channel.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/data_api_gsoc2009/main/channel.c?view=diff&rev=207355&r1=207354&r2=207355
==============================================================================
--- team/group/data_api_gsoc2009/main/channel.c (original)
+++ team/group/data_api_gsoc2009/main/channel.c Mon Jul 20 09:17:00 2009
@@ -260,6 +260,12 @@
int ast_channel_data_add_structure(struct ast_data *tree, struct ast_channel *chan)
{
return ast_data_add_structure(ast_channel, tree, chan);
+}
+
+int ast_channel_data_cmp_structure(const struct ast_data_search *tree,
+ struct ast_channel *chan, const char *structure_name)
+{
+ return ast_data_search_cmp_structure(tree, ast_channel, chan, structure_name);
}
/*! \brief Show channel types - CLI command */
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=207355&r1=207354&r2=207355
==============================================================================
--- team/group/data_api_gsoc2009/main/data.c (original)
+++ team/group/data_api_gsoc2009/main/data.c Mon Jul 20 09:17:00 2009
@@ -1209,7 +1209,7 @@
/* the structure member name doesn't match! */
ao2_ref(node, -1);
ao2_ref(struct_children, -1);
- return 1;
+ return 0;
}
notmatch = 0;
@@ -1862,6 +1862,8 @@
data_result_add_child(root, node);
+ ao2_ref(node, -1);
+
return node;
}
@@ -1963,15 +1965,9 @@
return 0;
}
-struct ast_data *ast_data_create(const char *name)
-{
- if (ast_strlen_zero(name)) {
- ast_log(LOG_ERROR, "You must specify a root node name in order to create "
- "a data result tree\n");
- return NULL;
- }
-
- return data_result_create(name);
+void ast_data_remove_node(struct ast_data *root, struct ast_data *child)
+{
+ ao2_unlink(root->children, child);
}
void ast_data_free(struct ast_data *root)
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=207355&r1=207354&r2=207355
==============================================================================
--- team/group/data_api_gsoc2009/tests/test_data.c (original)
+++ team/group/data_api_gsoc2009/tests/test_data.c Mon Jul 20 09:17:00 2009
@@ -210,6 +210,7 @@
struct ast_data_query query = {
.version = AST_DATA_QUERY_VERSION,
.path = "asterisk/application/app_queue/queues",
+ .search = "queues/queue/callers/caller/channel/data=cola1"
};
switch (cmd) {
More information about the asterisk-commits
mailing list