diff libpurple/protocols/jabber/buddy.c @ 26670:538b4175fd24

propagate from branch 'im.pidgin.pidgin' (head 079a5ca1aa110ee9f6661eba31e5ea3f0b5a07e7) to branch 'im.pidgin.cpw.darkrain42.xmpp.bosh' (head ed4fe6175c781745fd0c94a6a54a0ffcc10828ad)
author Paul Aurich <paul@darkrain42.org>
date Sat, 11 Apr 2009 04:39:48 +0000
parents b87843de7c6a 061df5754d20
children 3912f55a1633
line wrap: on
line diff
--- a/libpurple/protocols/jabber/buddy.c	Sat Apr 11 02:55:46 2009 +0000
+++ b/libpurple/protocols/jabber/buddy.c	Sat Apr 11 04:39:48 2009 +0000
@@ -181,8 +181,10 @@
 		jbr->commands = g_list_delete_link(jbr->commands, jbr->commands);
 	}
 
-	jabber_caps_free_clientinfo(jbr->caps);
-
+	if (jbr->caps.exts) {
+		g_list_foreach(jbr->caps.exts, (GFunc)g_free, NULL);
+		g_list_free(jbr->caps.exts);
+	}
 	g_free(jbr->name);
 	g_free(jbr->status);
 	g_free(jbr->thread_id);
@@ -490,9 +492,6 @@
 
 void jabber_set_buddy_icon(PurpleConnection *gc, PurpleStoredImage *img)
 {
-	PurplePresence *gpresence;
-	PurpleStatus *status;
-
 	if(((JabberStream*)purple_connection_get_protocol_data(gc))->pep) {
 		/* XEP-0084: User Avatars */
 		if(img) {
@@ -610,9 +609,7 @@
 	 */
 	jabber_set_info(gc, purple_account_get_user_info(gc->account));
 
-	gpresence = purple_account_get_presence(gc->account);
-	status = purple_presence_get_active_status(gpresence);
-	jabber_presence_send(gc->account, status);
+	jabber_presence_send(gc->proto_data, FALSE);
 }
 
 /*
@@ -1850,7 +1847,7 @@
 		}
 
 		if (jbr->tz_off == PURPLE_NO_TZ_OFF &&
-				(!jbr->caps ||
+				(!jbr->caps.info ||
 				 	jabber_resource_has_capability(jbr, "urn:xmpp:time"))) {
 			xmlnode *child;
 			iq = jabber_iq_new(js, JABBER_IQ_GET);
@@ -2589,23 +2586,35 @@
 gboolean
 jabber_resource_has_capability(const JabberBuddyResource *jbr, const gchar *cap)
 {
-	const GList *iter = NULL;
+	const GList *node = NULL;
+	const JabberCapsNodeExts *exts;
 
-	if (!jbr->caps) {
+	if (!jbr->caps.info) {
 		purple_debug_error("jabber",
 			"Unable to find caps: nothing known about buddy\n");
 		return FALSE;
 	}
 
-	for (iter = jbr->caps->features ; iter ; iter = g_list_next(iter)) {
-		if (strcmp(iter->data, cap) == 0) {
-			purple_debug_info("jabber", "Found cap: %s\n", (char *)iter->data);
-			return TRUE;
+	node = g_list_find_custom(jbr->caps.info->features, cap, (GCompareFunc)strcmp);
+	if (!node && jbr->caps.exts && jbr->caps.info->exts) {
+		const GList *ext;
+		exts = jbr->caps.info->exts;
+		/* Walk through all the enabled caps, checking each list for the cap.
+		 * Don't check it twice, though. */
+		for (ext = jbr->caps.exts; ext && !node; ext = ext->next) {
+			GList *features = g_hash_table_lookup(exts->exts, ext->data);
+			if (features)
+				node = g_list_find_custom(features, cap, (GCompareFunc)strcmp);
 		}
 	}
 
-	purple_debug_info("jabber", "Cap %s not found\n", cap);
-	return FALSE;
+	/* TODO: Are these messages actually useful? */
+	if (node)
+		purple_debug_info("jabber", "Found cap: %s\n", cap);
+	else
+		purple_debug_info("jabber", "Cap %s not found\n", cap); 
+
+	return (node != NULL);
 }
 
 gboolean