changeset 29735:54289a753667

merge of 'd3c0fb0d541e286033c180e2104c09174255a31b' and 'e86a2edf1a808d62825fa1e6109ead33f72982d6'
author Paul Aurich <paul@darkrain42.org>
date Thu, 15 Apr 2010 04:21:55 +0000
parents b00abe5ec15e (current diff) c66e766acb06 (diff)
children 787d82881a3e
files
diffstat 5 files changed, 20 insertions(+), 37 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Apr 14 21:06:00 2010 +0000
+++ b/ChangeLog	Thu Apr 15 04:21:55 2010 +0000
@@ -65,6 +65,7 @@
 	  password on reconnect when "Remember Password" is not checked and
 	  authentication fails due to an incorrect password.  (This is the same
 	  behavior as the legacy authentication method)
+	* Support sending and receiving HTML-formatted messages for ICQ.
 
 	MSN:
 	* Support for version 9 of the MSN protocol has been removed.  This
--- a/doc/PERL-HOWTO.dox	Wed Apr 14 21:06:00 2010 +0000
+++ b/doc/PERL-HOWTO.dox	Thu Apr 15 04:21:55 2010 +0000
@@ -72,8 +72,8 @@
 sub plugin_load {
 	$plugin = shift;
 
-	# Testing was done using Oscar, but this should work regardless of the protocol chosen
-	my $protocol = "prpl-oscar";
+	# Testing was done using AIM, but this should work regardless of the protocol chosen
+	my $protocol = "prpl-aim";
 	my $account_name = "test";
 
 	# Create a new Account
@@ -149,7 +149,7 @@
 sub plugin_load {
 	my $plugin = shift;
 
-	my $protocol = "prpl-oscar";
+	my $protocol = "prpl-aim";
 	my $account_name = "test";
 
 	# This is how we get an account to use in the following tests.  You should replace the username
@@ -232,7 +232,7 @@
 @code
 sub plugin_load {
 	my $plugin = shift;
-	my $protocol = "prpl-oscar";
+	my $protocol = "prpl-aim";
 	my $account_name = "test";
 
 	$account = Purple::Accounts::find($account_name, $protocol);
--- a/libpurple/protocols/oscar/family_icbm.c	Wed Apr 14 21:06:00 2010 +0000
+++ b/libpurple/protocols/oscar/family_icbm.c	Thu Apr 15 04:21:55 2010 +0000
@@ -274,6 +274,7 @@
 			| AIM_IMPARAM_FLAG_MISSED_CALLS_ENABLED
 			| AIM_IMPARAM_FLAG_EVENTS_ALLOWED
 			| AIM_IMPARAM_FLAG_SMS_SUPPORTED
+			| AIM_IMPARAM_FLAG_SEND_ME_HTML_FOR_ICQ
 			| AIM_IMPARAM_FLAG_OFFLINE_MSGS_ALLOWED;
 	params.maxmsglen = 8000;
 	params.minmsginterval = 0;
--- a/libpurple/protocols/oscar/oscar.c	Wed Apr 14 21:06:00 2010 +0000
+++ b/libpurple/protocols/oscar/oscar.c	Thu Apr 15 04:21:55 2010 +0000
@@ -85,8 +85,7 @@
 		| OSCAR_CAPABILITY_XTRAZ;
 
 static guint8 features_aim[] = {0x01, 0x01, 0x01, 0x02};
-static guint8 features_icq[] = {0x01, 0x06};
-static guint8 features_icq_offline[] = {0x01};
+static guint8 features_icq[] = {0x01};
 static guint8 ck[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
 
 struct create_room {
@@ -1578,11 +1577,11 @@
 		return;
 	}
 
+	gc->flags |= PURPLE_CONNECTION_HTML;
 	if (oscar_util_valid_name_icq((purple_account_get_username(account)))) {
 		od->icq = TRUE;
 		gc->flags |= PURPLE_CONNECTION_SUPPORT_MOODS;
 	} else {
-		gc->flags |= PURPLE_CONNECTION_HTML;
 		gc->flags |= PURPLE_CONNECTION_AUTO_RESP;
 	}
 
@@ -2494,8 +2493,15 @@
 	 *
 	 * Note: There *may* be some clients which send messages as HTML formatted -
 	 *       they need to be special-cased somehow.
+	 *
+	 * Update: Newer ICQ clients have started sending IMs as HTML.  We can
+	 * distinguish HTML IMs from non-HTML IMs by looking at the features.  If
+	 * the features are "0x 01 06" then the message is plain text.  If the
+	 * features are "0x 01" then the message is HTML.
 	 */
-	if (od->icq && oscar_util_valid_name_icq(userinfo->bn)) {
+	if (od->icq && oscar_util_valid_name_icq(userinfo->bn)
+			&& (args->featureslen != 1 || args->features[0] != 0x01))
+	{
 		/* being recevied by ICQ from ICQ - escape HTML so it is displayed as sent */
 		gchar *tmp2 = g_markup_escape_text(tmp, -1);
 		g_free(tmp);
@@ -4724,20 +4730,8 @@
 			args.flags |= AIM_IMFLAGS_OFFLINE;
 
 		if (od->icq) {
-			/* We have to present different "features" (whose meaning
-			   is unclear and are merely a result of protocol inspection)
-			   to offline ICQ buddies. Otherwise, the official
-			   ICQ client doesn't treat those messages as being "ANSI-
-			   encoded" (and instead, assumes them to be UTF-8).
-			   For more details, see SF issue 1179452.
-			*/
-			if (buddy && PURPLE_BUDDY_IS_ONLINE(buddy)) {
-				args.features = features_icq;
-				args.featureslen = sizeof(features_icq);
-			} else {
-				args.features = features_icq_offline;
-				args.featureslen = sizeof(features_icq_offline);
-			}
+			args.features = features_icq;
+			args.featureslen = sizeof(features_icq);
 		} else {
 			args.features = features_aim;
 			args.featureslen = sizeof(features_aim);
@@ -4787,25 +4781,11 @@
 
 		args.destbn = name;
 
-		/*
-		 * If we're IMing an SMS user or an ICQ user from an ICQ account, then strip HTML.
-		 */
 		if (oscar_util_valid_name_sms(name)) {
-			/* Messaging an SMS (mobile) user */
+			/* Messaging an SMS (mobile) user--strip HTML */
 			tmp2 = purple_markup_strip_html(tmp1);
 			is_html = FALSE;
-		} else if (od->icq) {
-			if (oscar_util_valid_name_icq(name)) {
-				/* From ICQ to ICQ */
-				tmp2 = purple_markup_strip_html(tmp1);
-				is_html = FALSE;
-			} else {
-				/* From ICQ to AIM */
-				tmp2 = g_strdup(tmp1);
-				is_html = TRUE;
-			}
 		} else {
-			/* From AIM to AIM and AIM to ICQ */
 			tmp2 = g_strdup(tmp1);
 			is_html = TRUE;
 		}
--- a/libpurple/protocols/oscar/oscar.h	Wed Apr 14 21:06:00 2010 +0000
+++ b/libpurple/protocols/oscar/oscar.h	Thu Apr 15 04:21:55 2010 +0000
@@ -746,6 +746,7 @@
 #define AIM_IMPARAM_FLAG_EVENTS_ALLOWED         0x00000008
 #define AIM_IMPARAM_FLAG_SMS_SUPPORTED          0x00000010
 #define AIM_IMPARAM_FLAG_OFFLINE_MSGS_ALLOWED   0x00000100
+#define AIM_IMPARAM_FLAG_SEND_ME_HTML_FOR_ICQ   0x00000400
 
 /* This is what the server will give you if you don't set them yourself. */
 /* This is probably out of date. */