changeset 27211:a167106a439a

New versions of the official Yahoo Messenger client for Windows XP (tested with version 9.0.0.2162) seem to require us to acknowledge when we receive an IM. If we don't send an ack then they send us the same message 7 seconds later. Checking this in because it at least seems to fix the problem for me. Fixes http://trac.adium.im/ticket/12311
author Mark Doliner <mark@kingant.net>
date Fri, 19 Jun 2009 18:46:49 +0000
parents 0a8129263401
children 27ccab320d8a
files libpurple/protocols/yahoo/yahoo.c libpurple/protocols/yahoo/yahoo_packet.h
diffstat 2 files changed, 27 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/yahoo/yahoo.c	Fri Jun 19 07:20:49 2009 +0000
+++ b/libpurple/protocols/yahoo/yahoo.c	Fri Jun 19 18:46:49 2009 +0000
@@ -813,6 +813,7 @@
 	int time;
 	int utf8;
 	int buddy_icon;
+	char *id;
 	char *msg;
 };
 
@@ -930,6 +931,9 @@
 			{
 				imv = pair->value;
 			}
+			if (pair->key == 429)
+				if (im)
+					im->id = pair->value;
 			l = l->next;
 		}
 	} else if (pkt->status == 2) {
@@ -997,6 +1001,28 @@
 			return;
 		}
 
+		/*
+		 * TODO: Is there anything else we should check when determining whether
+		 *       we should send an acknowledgement?
+		 */
+		if (im->id != NULL) {
+			/* Send acknowledgement.  If we don't do this then the official
+			 * Yahoo Messenger client for Windows will send us the same
+			 * message 7 seconds later as an offline message.  This is true
+			 * for at least version 9.0.0.2162 on Windows XP. */
+			struct yahoo_packet *pkt2;
+			pkt2 = yahoo_packet_new(YAHOO_SERVICE_MESSAGE_ACK,
+					YAHOO_STATUS_AVAILABLE, pkt->id);
+			yahoo_packet_hash(pkt2, "ssisii",
+					1, purple_connection_get_display_name(gc),
+					5, im->from,
+					302, 430,
+					430, im->id,
+					303, 430,
+					450, 0);
+			yahoo_packet_send_and_free(pkt2, yd);
+		}
+
 		m = yahoo_string_decode(gc, im->msg, im->utf8);
 		/* This may actually not be necessary, but it appears
 		 * that at least at one point some clients were sending
--- a/libpurple/protocols/yahoo/yahoo_packet.h	Fri Jun 19 07:20:49 2009 +0000
+++ b/libpurple/protocols/yahoo/yahoo_packet.h	Fri Jun 19 18:46:49 2009 +0000
@@ -107,6 +107,7 @@
 	YAHOO_SERVICE_CHGRP_15 = 0xe7,
 	YAHOO_SERVICE_STATUS_15 = 0xf0,
 	YAHOO_SERVICE_LIST_15 = 0xf1,
+	YAHOO_SERVICE_MESSAGE_ACK = 0xfb,
 	YAHOO_SERVICE_WEBLOGIN = 0x0226,
 	YAHOO_SERVICE_SMS_MSG = 0x02ea
 	/* YAHOO_SERVICE_DISCONNECT = 0x07d1 Server forces us to disconnect. Is sent with TCP FIN flag set */