changeset 27508:95c56191d26c

For contacts who advertise Entity Caps, check for XHTML-IM support. Refs #4650. For backward-compatibility (and what I, as someone who knows that Jabber supports rich-text, would expect), continue sending it if the contact is offline (i.e. not on the roster).
author Paul Aurich <paul@darkrain42.org>
date Sun, 12 Jul 2009 04:39:31 +0000
parents 2a19181b41fa
children ebd9630ffc77
files ChangeLog libpurple/protocols/jabber/buddy.c libpurple/protocols/jabber/jabber.h libpurple/protocols/jabber/message.c
diffstat 4 files changed, 13 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sun Jul 12 04:35:04 2009 +0000
+++ b/ChangeLog	Sun Jul 12 04:39:31 2009 +0000
@@ -96,6 +96,8 @@
 	  kicked.
 	* Fix issues with case-sensitivity of XMPP roster and case-insensitive
 	  Purple groups.
+	* For contacts who advertise Entity Capabilities, only send rich text
+	  markup if they support it.
 
 	Yahoo!/Yahoo! JAPAN:
 	* P2P file transfers.  (Sulabh Mahajan)
--- a/libpurple/protocols/jabber/buddy.c	Sun Jul 12 04:35:04 2009 +0000
+++ b/libpurple/protocols/jabber/buddy.c	Sun Jul 12 04:39:31 2009 +0000
@@ -161,7 +161,7 @@
 		jbr = g_new0(JabberBuddyResource, 1);
 		jbr->jb = jb;
 		jbr->name = g_strdup(resource);
-		jbr->capabilities = JABBER_CAP_XHTML;
+		jbr->capabilities = JABBER_CAP_NONE;
 		jbr->tz_off = PURPLE_NO_TZ_OFF;
 		jb->resources = g_list_append(jb->resources, jbr);
 	}
@@ -2244,12 +2244,6 @@
 		}
 	}
 
-	/* 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);
 }
 
--- a/libpurple/protocols/jabber/jabber.h	Sun Jul 12 04:35:04 2009 +0000
+++ b/libpurple/protocols/jabber/jabber.h	Sun Jul 12 04:39:31 2009 +0000
@@ -24,7 +24,7 @@
 
 typedef enum {
 	JABBER_CAP_NONE           = 0,
-	JABBER_CAP_XHTML          = 1 << 0,
+/*	JABBER_CAP_XHTML          = 1 << 0, */
 	JABBER_CAP_COMPOSING      = 1 << 1,
 	JABBER_CAP_SI             = 1 << 2,
 	JABBER_CAP_SI_FILE_XFER   = 1 << 3,
--- a/libpurple/protocols/jabber/message.c	Sun Jul 12 04:35:04 2009 +0000
+++ b/libpurple/protocols/jabber/message.c	Sun Jul 12 04:39:31 2009 +0000
@@ -1199,9 +1199,15 @@
 		xhtml = tmp;
 	}
 
-	if ((!jbr || jbr->capabilities & JABBER_CAP_XHTML) &&
-			!jabber_xhtml_plain_equal(xhtml, jm->body))
-		jm->xhtml = g_strdup_printf("<html xmlns='http://jabber.org/protocol/xhtml-im'><body xmlns='http://www.w3.org/1999/xhtml'>%s</body></html>", xhtml);
+	/*
+	 * For backward compatibility with user expectations or for those not on
+	 * the user's roster, allow sending XHTML-IM markup.
+	 */
+	if (!jbr || !jbr->caps.info ||
+			jabber_resource_has_capability(jbr, "http://jabber.org/protocol/xhtml-im")) {
+		if (!jabber_xhtml_plain_equal(xhtml, jm->body))
+			jm->xhtml = g_strdup_printf("<html xmlns='http://jabber.org/protocol/xhtml-im'><body xmlns='http://www.w3.org/1999/xhtml'>%s</body></html>", xhtml);
+	}
 
 	g_free(xhtml);