[asterisk-commits] branch group/asterisk-xmpp r27267 - /team/group/asterisk-xmpp/res/res_jabber.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Mon May 15 14:05:46 MST 2006


Author: mogorman
Date: Mon May 15 16:05:46 2006
New Revision: 27267

URL: http://svn.digium.com/view/asterisk?rev=27267&view=rev
Log:
okay now it really works, reload support in res_jabber

Modified:
    team/group/asterisk-xmpp/res/res_jabber.c

Modified: team/group/asterisk-xmpp/res/res_jabber.c
URL: http://svn.digium.com/view/asterisk/team/group/asterisk-xmpp/res/res_jabber.c?rev=27267&r1=27266&r2=27267&view=diff
==============================================================================
--- team/group/asterisk-xmpp/res/res_jabber.c (original)
+++ team/group/asterisk-xmpp/res/res_jabber.c Mon May 15 16:05:46 2006
@@ -472,6 +472,7 @@
 							break;
 						if (client->authorized) {
 							if (features & IKS_STREAM_BIND) {
+								iks_filter_add_rule (client->f, aji_client_connect, client, IKS_RULE_TYPE, IKS_PAK_IQ, IKS_RULE_SUBTYPE, IKS_TYPE_RESULT, IKS_RULE_DONE);
 								auth = iks_make_resource_bind(client->jid);
 								if (auth) {
 									iks_insert_attrib(auth, "id", client->mid);
@@ -484,6 +485,7 @@
 								}
 							}
 							if (features & IKS_STREAM_SESSION) {
+								iks_filter_add_rule (client->f, aji_client_connect, client, IKS_RULE_TYPE, IKS_PAK_IQ, IKS_RULE_SUBTYPE, IKS_TYPE_RESULT, IKS_RULE_ID, "auth", IKS_RULE_DONE);
 								auth = iks_make_session();
 								if (auth) {
 									iks_insert_attrib(auth, "id", "auth");
@@ -1666,9 +1668,10 @@
 	int res = 0;
 	if (client) {
 		if (client->state == AJI_DISCONNECTED) {
+			iks_filter_add_rule(client->f, aji_filter_roster, client, IKS_RULE_TYPE, IKS_PAK_IQ, IKS_RULE_SUBTYPE, IKS_TYPE_RESULT, IKS_RULE_ID, "roster", IKS_RULE_DONE);
 			client->state = AJI_CONNECTED;
 			client->jid = (iks_find_cdata(pak->query, "jid")) ? iks_id_new(client->stack, iks_find_cdata(pak->query, "jid")) : client->jid;
-		//	iks_filter_remove_hook(client->f, aji_client_connect); DUMB
+			iks_filter_remove_hook(client->f, aji_client_connect);
 			if(client->component == AJI_CLIENT)
 				aji_get_roster(client);
 		}
@@ -1904,6 +1907,7 @@
 	int flag = 0;
 	client = ASTOBJ_CONTAINER_FIND(&clients,label);
 	if(!client) {
+		ast_verbose("CLIENT NOT FOUND!\n");
 		flag = 1;
 		client = (struct aji_client *) malloc(sizeof(struct aji_client));
 		if(client) {
@@ -1936,12 +1940,7 @@
 				}
 			} else
 				client->jid = iks_id_new(client->stack, client->user);
-			if (client->component == AJI_CLIENT) {
-				iks_filter_add_rule(client->f, aji_client_connect, client, IKS_RULE_TYPE, IKS_PAK_IQ, IKS_RULE_SUBTYPE, IKS_TYPE_RESULT, IKS_RULE_DONE);
-				iks_filter_add_rule(client->f, aji_client_connect, client, IKS_RULE_TYPE, IKS_PAK_IQ, IKS_RULE_SUBTYPE, IKS_TYPE_RESULT, IKS_RULE_ID, "auth", IKS_RULE_DONE);
-				iks_filter_add_rule(client->f, aji_client_info_handler, client, IKS_RULE_NS, "http://jabber.org/protocol/disco#info", IKS_RULE_DONE);
-			iks_filter_add_rule(client->f, aji_filter_roster, client, IKS_RULE_TYPE, IKS_PAK_IQ, IKS_RULE_SUBTYPE, IKS_TYPE_RESULT, IKS_RULE_NS, IKS_NS_ROSTER, IKS_RULE_ID, "roster", IKS_RULE_DONE);
-			} else {
+			if (client->component == AJI_COMPONENT) {
 				iks_filter_add_rule(client->f, aji_dinfo_handler, client, IKS_RULE_NS, "http://jabber.org/protocol/disco#info", IKS_RULE_DONE);
 				iks_filter_add_rule(client->f, aji_ditems_handler, client, IKS_RULE_NS, "http://jabber.org/protocol/disco#items", IKS_RULE_DONE);
 				iks_filter_add_rule(client->f, aji_register_query_handler, client, IKS_RULE_SUBTYPE, IKS_TYPE_GET, IKS_RULE_NS, "jabber:iq:register", IKS_RULE_DONE);
@@ -1966,9 +1965,9 @@
 	client->forcessl = 0;
 	client->keepalive = 1;
 	client->timeout = 20;
-	client->authorized = 0;
+	if (flag) client->authorized = 0;
 	client->usesasl = 0;
-	client->state = AJI_DISCONNECTED;
+	if (flag) client->state = AJI_DISCONNECTED;
 	if (!strcasecmp(utype, "component"))
 		client->component = AJI_COMPONENT;
 	if (!strcasecmp(utype, "client"))
@@ -2082,9 +2081,10 @@
 static int aji_create_buddy(char *label, struct aji_client *client)
 {
 	struct aji_buddy *buddy = NULL;
-
+	int flag = 0;
 	buddy = ASTOBJ_CONTAINER_FIND(&client->buddies,label);
 	if (!buddy) {
+		flag = 1;
 		buddy = malloc(sizeof(struct aji_buddy));
 		if(!buddy) {
 			ast_log(LOG_WARNING, "Out of memory\n");
@@ -2098,7 +2098,10 @@
 	ASTOBJ_WRLOCK(buddy);
 	ast_copy_string(buddy->name, label, sizeof(buddy->name));
 	ASTOBJ_UNLOCK(buddy);
-	ASTOBJ_CONTAINER_LINK(&client->buddies, buddy);
+	if(flag)
+		ASTOBJ_CONTAINER_LINK(&client->buddies, buddy);
+	else
+		ASTOBJ_UNREF(buddy, aji_buddy_destroy);
 	return 1;
 }
 
@@ -2174,11 +2177,11 @@
 		ASTOBJ_CONTAINER_PRUNE_MARKED(&clients, aji_client_destroy);
 		ASTOBJ_CONTAINER_TRAVERSE(&clients, 1, {
 			ASTOBJ_RDLOCK(iterator);
-			if(iterator->state == AJI_DISCONNECTED)
+			if(iterator->state == AJI_DISCONNECTED) {
 				res = aji_reconnect(iterator);
-			if (res != -1 && !iterator->thread)
-				ast_pthread_create(&iterator->thread, NULL, aji_recv_loop, iterator);
-			else if (iterator->state == AJI_CONNECTED) {
+				if (res != -1 && !iterator->thread)
+					ast_pthread_create(&iterator->thread, NULL, aji_recv_loop, iterator);
+			} else if (iterator->state == AJI_CONNECTED) {
 				aji_get_roster(iterator);
 			}
 			ASTOBJ_UNLOCK(iterator);



More information about the asterisk-commits mailing list