[asterisk-commits] phsultan: branch 1.6.0 r124873 - in /branches/1.6.0: ./ res/res_jabber.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jun 24 12:52:02 CDT 2008


Author: phsultan
Date: Tue Jun 24 12:52:02 2008
New Revision: 124873

URL: http://svn.digium.com/view/asterisk?view=rev&rev=124873
Log:
Merged revisions 124872 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

........
r124872 | phsultan | 2008-06-24 19:50:22 +0200 (Tue, 24 Jun 2008) | 6 lines

Subscribe to buddy's presence only if we really need to. That is, if
the corresponding roster item has a subscription value set to "none"
or "from".

Make the code more readable.

........

Modified:
    branches/1.6.0/   (props changed)
    branches/1.6.0/res/res_jabber.c

Propchange: branches/1.6.0/
------------------------------------------------------------------------------
Binary property 'trunk-merged' - no diff available.

Modified: branches/1.6.0/res/res_jabber.c
URL: http://svn.digium.com/view/asterisk/branches/1.6.0/res/res_jabber.c?view=diff&rev=124873&r1=124872&r2=124873
==============================================================================
--- branches/1.6.0/res/res_jabber.c (original)
+++ branches/1.6.0/res/res_jabber.c Tue Jun 24 12:52:02 2008
@@ -2137,26 +2137,33 @@
 				ASTOBJ_UNLOCK(iterator);
 			});
 
-			if (!flag) {
-				buddy = ast_calloc(1, sizeof(*buddy));
-				if (!buddy) {
-					ast_log(LOG_WARNING, "Out of memory\n");
-					return 0;
-				}
-				ASTOBJ_INIT(buddy);
-				ASTOBJ_WRLOCK(buddy);
-				ast_copy_string(buddy->name, iks_find_attrib(x, "jid"), sizeof(buddy->name));
-				ast_clear_flag(&buddy->flags, AST_FLAGS_ALL);
-				if(ast_test_flag(&client->flags, AJI_AUTOPRUNE)) {
-					ast_set_flag(&buddy->flags, AJI_AUTOPRUNE);
-					ASTOBJ_MARK(buddy);
-				} else
-					ast_set_flag(&buddy->flags, AJI_AUTOREGISTER);
-				ASTOBJ_UNLOCK(buddy);
-				if (buddy) {
-					ASTOBJ_CONTAINER_LINK(&client->buddies, buddy);
-					ASTOBJ_UNREF(buddy, aji_buddy_destroy);
-				}
+			if (flag) {
+				/* found buddy, don't create a new one */
+				x = iks_next(x);
+				continue;
+			}
+			
+			buddy = ast_calloc(1, sizeof(*buddy));
+			if (!buddy) {
+				ast_log(LOG_WARNING, "Out of memory\n");
+				return 0;
+			}
+			ASTOBJ_INIT(buddy);
+			ASTOBJ_WRLOCK(buddy);
+			ast_copy_string(buddy->name, iks_find_attrib(x, "jid"), sizeof(buddy->name));
+			ast_clear_flag(&buddy->flags, AST_FLAGS_ALL);
+			if(ast_test_flag(&client->flags, AJI_AUTOPRUNE)) {
+				ast_set_flag(&buddy->flags, AJI_AUTOPRUNE);
+				ASTOBJ_MARK(buddy);
+			} else if (!iks_strcmp(iks_find_attrib(x, "subscription"), "none") || !iks_strcmp(iks_find_attrib(x, "subscription"), "from")) {
+				/* subscribe to buddy's presence only 
+				   if we really need to */
+				ast_set_flag(&buddy->flags, AJI_AUTOREGISTER);
+			}
+			ASTOBJ_UNLOCK(buddy);
+			if (buddy) {
+				ASTOBJ_CONTAINER_LINK(&client->buddies, buddy);
+				ASTOBJ_UNREF(buddy, aji_buddy_destroy);
 			}
 		}
 		x = iks_next(x);




More information about the asterisk-commits mailing list