[svn-commits] eliel: branch group/data_api_gsoc2009 r206189 - in /team/group/data_api_gsoc2...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Jul 13 12:05:48 CDT 2009


Author: eliel
Date: Mon Jul 13 12:05:44 2009
New Revision: 206189

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=206189
Log:
First compare internal nodes, if something is added then added the external nodes.
We have the first match! (app_queue/queues/queue/members/member/interface=Agent/3000)! :-)


Modified:
    team/group/data_api_gsoc2009/apps/app_queue.c
    team/group/data_api_gsoc2009/include/asterisk/data.h
    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=206189&r1=206188&r2=206189
==============================================================================
--- team/group/data_api_gsoc2009/apps/app_queue.c (original)
+++ team/group/data_api_gsoc2009/apps/app_queue.c Mon Jul 13 12:05:44 2009
@@ -7451,6 +7451,7 @@
 	MEMBER(call_queue, rrpos, AST_DATA_INTEGER)			\
 	MEMBER(call_queue, memberdelay, AST_DATA_INTEGER)		\
 	MEMBER(call_queue, autofill, AST_DATA_INTEGER)			\
+	MEMBER(call_queue, members, AST_DATA_CONTAINER)			\
 	MEMBER(call_queue, membercount, AST_DATA_INTEGER)
 
 AST_DATA_STRUCTURE(call_queue, DATA_EXPORT_CALL_QUEUE);
@@ -7483,6 +7484,7 @@
 	struct call_queue *queue;
 	struct member *member;
 	struct ast_data *data_root, *data_queue, *data_member, *data_members;
+	int member_added;
 
 	data_root = ast_data_create("queues");
 	if (!data_root) {
@@ -7495,6 +7497,7 @@
 
 		/* compare the search pattern. */
 		if (ast_data_search_cmp_structure(search, call_queue, queue, "queues/queue")) {
+			ast_log(LOG_ERROR, "Queue doesn't match! %s\n", queue->name);
 			/* this doesn't match! continue! */
 			ao2_unlock(queue);
 			queue_unref(queue);
@@ -7509,8 +7512,7 @@
 			continue;
 		}
 
-		ast_data_add_structure(call_queue, data_queue, queue); 
-
+		member_added = 1;
 		if (queue->members) {
 			data_members = ast_data_add_node(data_queue, "members");
 			if (!data_members) {
@@ -7519,6 +7521,7 @@
 				continue;
 			}
 
+			member_added = 0;
 			im = ao2_iterator_init(queue->members, 0);
 			while ((member = ao2_iterator_next(&im))) {
 				data_member = ast_data_add_node(data_members, "member");
@@ -7527,11 +7530,24 @@
 					continue;
 				}
 
+				/* compare the member structure. */
+				if (ast_data_search_cmp_structure(search, member, member, "queues/queue/members/member")) {
+					ast_log(LOG_ERROR, "Member %s doesn't match!\n", member->interface);
+					ao2_ref(member, -1);
+					continue;
+				} else {
+					ast_log(LOG_ERROR, "We have a match! %s\n", member->interface);
+				}
+
 				ast_data_add_structure(member, data_member, member);
+				member_added = 1;
 				ao2_ref(member, -1);
 			}
 		}
-
+		if (member_added) {
+			ast_data_add_structure(call_queue, data_queue, queue); 
+		}
+	
 		ao2_unlock(queue);
 		queue_unref(queue);
 	}

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=206189&r1=206188&r2=206189
==============================================================================
--- team/group/data_api_gsoc2009/include/asterisk/data.h (original)
+++ team/group/data_api_gsoc2009/include/asterisk/data.h Mon Jul 13 12:05:44 2009
@@ -154,6 +154,7 @@
 		unsigned int (*AST_DATA_BOOLEAN)(void *ptr);
 		void *(*AST_DATA_POINTER)(void *ptr);
 		struct in_addr (*AST_DATA_IPADDR)(void *ptr);
+		void *(*AST_DATA_CONTAINER)(void *ptr);
 	} get;
 };
 
@@ -184,6 +185,8 @@
 	__AST_DATA_MAPPING_FUNCTION_TYPE(__structure, __member, AST_DATA_IPADDR, struct in_addr)
 #define __AST_DATA_MAPPING_FUNCTION_AST_DATA_DOUBLE(__structure, __member)				\
 	__AST_DATA_MAPPING_FUNCTION_TYPE(__structure, __member, AST_DATA_DBL, double)
+#define __AST_DATA_MAPPING_FUNCTION_AST_DATA_CONTAINER(__structure, __member)				\
+	__AST_DATA_MAPPING_FUNCTION_TYPE(__structure, __member, AST_DATA_CONTAINER, void *)
 
 #define __AST_DATA_MAPPING_FUNCTION(__structure, __member, __type)		\
 	__AST_DATA_MAPPING_FUNCTION_##__type(__structure, __member)

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=206189&r1=206188&r2=206189
==============================================================================
--- team/group/data_api_gsoc2009/tests/test_data.c (original)
+++ team/group/data_api_gsoc2009/tests/test_data.c Mon Jul 13 12:05:44 2009
@@ -215,7 +215,7 @@
 	struct ast_data_query query = {
 		.version = AST_DATA_QUERY_VERSION,
 		.path = "asterisk/application/app_queue",
-		.search = "app_queue/queues/queue/name=cola2"
+		.search = "app_queue/queues/queue/members/member/interface=Agent/3000"
 	};
 
 	switch (cmd) {




More information about the svn-commits mailing list