soc.2009.transport: 0a635a80: Support for XHTML-IM messages

hanzz at soc.pidgin.im hanzz at soc.pidgin.im
Tue Jun 23 11:00:35 EDT 2009


-----------------------------------------------------------------
Revision: 0a635a8038b05bd7f6a5a36850a387a572ea501b
Ancestor: 669444a27ac7f3dbe0fd60ec24413e9c94a23476
Author: hanzz at soc.pidgin.im
Date: 2009-06-23T14:56:36
Branch: im.pidgin.soc.2009.transport
URL: http://d.pidgin.im/viewmtn/revision/info/0a635a8038b05bd7f6a5a36850a387a572ea501b

Modified files:
        caps.h user.cpp

ChangeLog: 

Support for XHTML-IM messages

-------------- next part --------------
============================================================
--- caps.h	6dc86197fa2aac623e4d20af98540d936806bfb7
+++ caps.h	74f862cf51540d0ddba195bcf6fe5a6a21153c79
@@ -28,7 +28,7 @@ typedef enum { 	GLOOX_FEATURE_ROSTERX = 
 typedef enum { 	GLOOX_FEATURE_ROSTERX = 2,
 				GLOOX_FEATURE_XHTML_IM = 4,
 				GLOOX_FEATURE_FILETRANSFER = 8,
-				GLOOX_FEATURE_CHATSTATES = 16
+				GLOOX_FEATURE_CHATSTATES = 16,
 				} GlooxImportantFeatures;
 
 
============================================================
--- user.cpp	d3def4b2bb98839b9b938bc7a56b6cd1af0c24c7
+++ user.cpp	d7bed0e53262fe352bffa5e9d9de906293963851
@@ -543,7 +543,10 @@ void User::purpleConversationWriteIM(Pur
 	Log().Get(m_jid) <<  "purpleConversationWriteIM:" << name;
 
 	// send message to user
-	std::string message(purple_unescape_html(msg));
+	char *newline = purple_strdup_withhtml(msg);
+	char *strip = purple_markup_strip_html(newline);
+
+	std::string message(strip);
 	Message s(Message::Chat, m_jid, message);
 	std::string from;
 	from.append(name);
@@ -568,7 +571,21 @@ void User::purpleConversationWriteIM(Pur
 		s.addExtension(d);
 	}
 
-	p->j->send( s );
+	Tag *stanzaTag = s.tag();
+
+	if (hasFeature(GLOOX_FEATURE_XHTML_IM)) {
+		Tag *html = new Tag("html");
+		html->addAttribute("xmlns", "http://jabber.org/protocol/xhtml-im");
+		Tag *body = new Tag("body", (std::string) msg);
+		body->addAttribute("xmlns", "http://www.w3.org/1999/xhtml");
+		html->addChild(body);
+		stanzaTag->addChild(html);
+	}
+
+	p->j->send( stanzaTag );
+	
+	g_free(newline);
+	g_free(strip);
 }
 
 void User::purpleChatTopicChanged(PurpleConversation *conv, const char *who, const char *topic) {


More information about the Commits mailing list