changeset 26753:09dc63a697e1

Fetch and track capabilities for MUC members. Add a further constraint for fetching that *node && *ver (someone in chat@c.j.o was advertising <c node="" ver="">).
author Paul Aurich <paul@darkrain42.org>
date Wed, 29 Apr 2009 06:06:41 +0000
parents 50db9eb2499a
children 836a36564ff5
files libpurple/protocols/jabber/presence.c
diffstat 1 files changed, 21 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/jabber/presence.c	Wed Apr 29 05:37:58 2009 +0000
+++ b/libpurple/protocols/jabber/presence.c	Wed Apr 29 06:06:41 2009 +0000
@@ -778,26 +778,6 @@
 			} else {
 				jbr->idle = 0;
 			}
-
-			if(caps) {
-				/* handle XEP-0115 */
-				const char *node = xmlnode_get_attrib(caps,"node");
-				const char *ver = xmlnode_get_attrib(caps,"ver");
-				const char *hash = xmlnode_get_attrib(caps,"hash");
-				const char *ext = xmlnode_get_attrib(caps,"ext");
-
-				/* v1.3 uses: node, ver, and optionally ext.
-				 * v1.5 uses: node, ver, and hash. */
-				if (node && ver) {
-					JabberPresenceCapabilities *userdata = g_new0(JabberPresenceCapabilities, 1);
-					userdata->js = js;
-					userdata->jb = jb;
-					userdata->from = g_strdup(from);
-					jabber_caps_get_info(js, from, node, ver, hash, ext,
-					    (jabber_caps_get_info_cb)jabber_presence_set_capabilities,
-					    userdata);
-				}
-			}
 		}
 
 		if((found_jbr = jabber_buddy_find_resource(jb, NULL))) {
@@ -809,6 +789,27 @@
 		}
 		g_free(buddy_name);
 	}
+
+	if (caps && (!type || g_str_equal(type, "available"))) {
+		/* handle Entity Capabilities (XEP-0115) */
+		const char *node = xmlnode_get_attrib(caps, "node");
+		const char *ver  = xmlnode_get_attrib(caps, "ver");
+		const char *hash = xmlnode_get_attrib(caps, "hash");
+		const char *ext  = xmlnode_get_attrib(caps, "ext");
+
+		/* v1.3 uses: node, ver, and optionally ext.
+		 * v1.5 uses: node, ver, and hash. */
+		if (node && *node && ver && *ver) {
+			JabberPresenceCapabilities *userdata = g_new0(JabberPresenceCapabilities, 1);
+			userdata->js = js;
+			userdata->jb = jb;
+			userdata->from = g_strdup(from);
+			jabber_caps_get_info(js, from, node, ver, hash, ext,
+			    (jabber_caps_get_info_cb)jabber_presence_set_capabilities,
+			    userdata);
+		}
+	}
+
 	g_free(status);
 	jabber_id_free(jid);
 	g_free(avatar_hash);