[asterisk-commits] snuffy: branch snuffy/ao2_jabber r141623 - /team/snuffy/ao2_jabber/channels/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sat Sep 6 18:15:28 CDT 2008


Author: snuffy
Date: Sat Sep  6 18:15:27 2008
New Revision: 141623

URL: http://svn.digium.com/view/asterisk?view=rev&rev=141623
Log:
Make it compile.. now can has run?

Modified:
    team/snuffy/ao2_jabber/channels/chan_gtalk.c
    team/snuffy/ao2_jabber/channels/chan_jingle.c

Modified: team/snuffy/ao2_jabber/channels/chan_gtalk.c
URL: http://svn.digium.com/view/asterisk/team/snuffy/ao2_jabber/channels/chan_gtalk.c?view=diff&rev=141623&r1=141622&r2=141623
==============================================================================
--- team/snuffy/ao2_jabber/channels/chan_gtalk.c (original)
+++ team/snuffy/ao2_jabber/channels/chan_gtalk.c Sat Sep  6 18:15:27 2008
@@ -63,6 +63,7 @@
 #include "asterisk/utils.h"
 #include "asterisk/causes.h"
 #include "asterisk/astobj.h"
+#include "asterisk/astobj2.h"
 #include "asterisk/abstract_jb.h"
 #include "asterisk/jabber.h"
 
@@ -880,14 +881,15 @@
 {
 	struct gtalk_pvt *tmp = NULL;
 	struct aji_resource *resources = NULL;
-	struct aji_buddy *buddy;
+	struct aji_buddy *buddy, tmp_buddy;
 	char idroster[200];
 	char *data, *exten = NULL;
 
 	ast_debug(1, "The client is %s for alloc\n", client->name);
 	if (!sid && !strchr(them, '/')) {	/* I started call! */
 		if (!strcasecmp(client->name, "guest")) {
-			buddy = ASTOBJ_CONTAINER_FIND(&client->connection->buddies, them);
+			ast_copy_string(tmp_buddy.name, them, sizeof(tmp_buddy.name));
+			buddy = ao2_t_find(client->connection->buddies, &tmp_buddy, OBJ_POINTER, "find buddy");
 			if (buddy)
 				resources = buddy->resources;
 		} else if (client->buddy)
@@ -1844,9 +1846,11 @@
 		}
 		var = var->next;
 	}
-	if (member->connection && member->user)
-		member->buddy = ASTOBJ_CONTAINER_FIND(&member->connection->buddies, member->user);
-	else {
+	if (member->connection && member->user) {
+		struct aji_buddy tmp_buddy;
+		ast_copy_string(tmp_buddy.name, member->user, sizeof(tmp_buddy.name));
+		member->buddy = ao2_t_find(member->connection->buddies, &tmp_buddy, OBJ_POINTER, "find buddy");
+	} else {
 		ast_log(LOG_ERROR, "No Connection or Username!\n");
 	}
 	return 1;
@@ -1862,7 +1866,7 @@
 	struct ast_variable *var;
 	struct gtalk *member;
 	struct ast_codec_pref prefs;
-	struct aji_client_container *clients;
+	struct ao2_container *clients;
 	struct gtalk_candidate *global_candidates = NULL;
 	struct hostent *hp;
 	struct ast_hostent ahp;
@@ -1951,15 +1955,20 @@
 				ASTOBJ_UNLOCK(member);
 				clients = ast_aji_get_clients();
 				if (clients) {
-					ASTOBJ_CONTAINER_TRAVERSE(clients, 1, {
-						ASTOBJ_WRLOCK(iterator);
+					struct ao2_iterator iter;
+					struct aji_client *c;
+
+					iter = ao2_iterator_init(clients, 0);
+					while ((c =ao2_t_iterator_next(&iter,"iter clients"))) {
+						ao2_lock(c);
 						ASTOBJ_WRLOCK(member);
 						member->connection = NULL;
-						iks_filter_add_rule(iterator->f, gtalk_parser, member, IKS_RULE_TYPE, IKS_PAK_IQ, IKS_RULE_NS, "http://www.google.com/session", IKS_RULE_DONE);
-						iks_filter_add_rule(iterator->f, gtalk_parser, member, IKS_RULE_TYPE, IKS_PAK_IQ, IKS_RULE_NS, "http://jabber.org/protocol/gtalk", IKS_RULE_DONE);
+						iks_filter_add_rule(c->f, gtalk_parser, member, IKS_RULE_TYPE, IKS_PAK_IQ, IKS_RULE_NS, "http://www.google.com/session", IKS_RULE_DONE);
+						iks_filter_add_rule(c->f, gtalk_parser, member, IKS_RULE_TYPE, IKS_PAK_IQ, IKS_RULE_NS, "http://jabber.org/protocol/gtalk", IKS_RULE_DONE);
 						ASTOBJ_UNLOCK(member);
-						ASTOBJ_UNLOCK(iterator);
-					});
+						ao2_unlock(c);
+						ao2_ref(c, -1);
+					}
 					ASTOBJ_CONTAINER_LINK(&gtalk_list, member);
 					ASTOBJ_UNREF(member, gtalk_member_destroy);
 				} else {

Modified: team/snuffy/ao2_jabber/channels/chan_jingle.c
URL: http://svn.digium.com/view/asterisk/team/snuffy/ao2_jabber/channels/chan_jingle.c?view=diff&rev=141623&r1=141622&r2=141623
==============================================================================
--- team/snuffy/ao2_jabber/channels/chan_jingle.c (original)
+++ team/snuffy/ao2_jabber/channels/chan_jingle.c Sat Sep  6 18:15:27 2008
@@ -65,6 +65,7 @@
 #include "asterisk/utils.h"
 #include "asterisk/causes.h"
 #include "asterisk/astobj.h"
+#include "asterisk/astobj2.h"
 #include "asterisk/abstract_jb.h"
 #include "asterisk/jabber.h"
 #include "asterisk/jingle.h"
@@ -741,13 +742,14 @@
 {
 	struct jingle_pvt *tmp = NULL;
 	struct aji_resource *resources = NULL;
-	struct aji_buddy *buddy;
+	struct aji_buddy *buddy,tmp_buddy;
 	char idroster[200];
 
 	ast_debug(1, "The client is %s for alloc\n", client->name);
 	if (!sid && !strchr(from, '/')) {	/* I started call! */
 		if (!strcasecmp(client->name, "guest")) {
-			buddy = ASTOBJ_CONTAINER_FIND(&client->connection->buddies, from);
+			ast_copy_string(tmp_buddy.name, from, sizeof(tmp_buddy.name));
+			buddy = ao2_t_find(client->connection->buddies, &tmp_buddy, OBJ_POINTER, "find client");
 			if (buddy)
 				resources = buddy->resources;
 		} else if (client->buddy)
@@ -1712,9 +1714,11 @@
 		}
 		var = var->next;
 	}
-	if (member->connection && member->user)
-		member->buddy = ASTOBJ_CONTAINER_FIND(&member->connection->buddies, member->user);
-	else {
+	if (member->connection && member->user) {
+		struct aji_buddy tmp_buddy;
+		ast_copy_string(tmp_buddy.name, member->user, sizeof(tmp_buddy.name));
+		member->buddy = ao2_t_find(member->connection->buddies, &tmp_buddy, OBJ_POINTER, "find buddy");
+	} else {
 		ast_log(LOG_ERROR, "No Connection or Username!\n");
 	}
 	return 1;
@@ -1731,7 +1735,7 @@
 	struct hostent *hp;
 	struct ast_hostent ahp;
 	struct ast_codec_pref prefs;
-	struct aji_client_container *clients;
+	struct ao2_container *clients;
 	struct jingle_candidate *global_candidates = NULL;
 	struct ast_flags config_flags = { 0 };
 
@@ -1817,15 +1821,20 @@
 				ASTOBJ_UNLOCK(member);
 				clients = ast_aji_get_clients();
 				if (clients) {
-					ASTOBJ_CONTAINER_TRAVERSE(clients, 1, {
-						ASTOBJ_WRLOCK(iterator);
+					struct ao2_iterator iter;
+					struct aji_client *c;
+					
+					iter = ao2_iterator_init(clients, 0);
+					while ((c = ao2_t_iterator_next(&iter,"client iter"))) {
+						ao2_lock(c);
 						ASTOBJ_WRLOCK(member);
 						member->connection = NULL;
-						iks_filter_add_rule(iterator->f, jingle_parser, member, IKS_RULE_TYPE, IKS_PAK_IQ, IKS_RULE_NS,	JINGLE_NS, IKS_RULE_DONE);
-						iks_filter_add_rule(iterator->f, jingle_parser, member, IKS_RULE_TYPE, IKS_PAK_IQ, IKS_RULE_NS,	JINGLE_DTMF_NS, IKS_RULE_DONE);
+						iks_filter_add_rule(c->f, jingle_parser, member, IKS_RULE_TYPE, IKS_PAK_IQ, IKS_RULE_NS,	JINGLE_NS, IKS_RULE_DONE);
+						iks_filter_add_rule(c->f, jingle_parser, member, IKS_RULE_TYPE, IKS_PAK_IQ, IKS_RULE_NS,	JINGLE_DTMF_NS, IKS_RULE_DONE);
 						ASTOBJ_UNLOCK(member);
-						ASTOBJ_UNLOCK(iterator);
-					});
+						ao2_unlock(c);
+						ao2_ref(c, -1);
+					}
 					ASTOBJ_CONTAINER_LINK(&jingle_list, member);
 				} else {
 					ASTOBJ_UNLOCK(member);




More information about the asterisk-commits mailing list