changeset 11024:1d58cc6c4552

[gaim-migrate @ 12897] sf patch #1222377, from Evan Schoenberg "Improve buddy icon retrieval" committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Thu, 23 Jun 2005 02:24:22 +0000
parents 9a99b0815459
children 8d2007d738d5
files src/protocols/oscar/aim.h src/protocols/oscar/bart.c src/protocols/oscar/locate.c src/protocols/oscar/oscar.c
diffstat 4 files changed, 17 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/protocols/oscar/aim.h	Wed Jun 22 23:23:14 2005 +0000
+++ b/src/protocols/oscar/aim.h	Thu Jun 23 02:24:22 2005 +0000
@@ -1007,6 +1007,7 @@
 	} icqinfo;
 	fu32_t present;
 
+	fu8_t iconcsumtype;
 	fu16_t iconcsumlen;
 	fu8_t *iconcsum;
 
@@ -1173,7 +1174,7 @@
 
 /* 0x0010 - icon.c */
 faim_export int aim_bart_upload(aim_session_t *sess, const fu8_t *icon, fu16_t iconlen);
-faim_export int aim_bart_request(aim_session_t *sess, const char *sn, const fu8_t *iconstr, fu16_t iconstrlen);
+faim_export int aim_bart_request(aim_session_t *sess, const char *sn, fu8_t iconcsumtype, const fu8_t *iconstr, fu16_t iconstrlen);
 
 
 
--- a/src/protocols/oscar/bart.c	Wed Jun 22 23:23:14 2005 +0000
+++ b/src/protocols/oscar/bart.c	Thu Jun 23 02:24:22 2005 +0000
@@ -76,7 +76,7 @@
  * @param iconcsumlen Length of the MD5 checksum given above.  Should be 10 bytes.
  * @return Return 0 if no errors, otherwise return the error number.
  */
-faim_export int aim_bart_request(aim_session_t *sess, const char *sn, const fu8_t *iconcsum, fu16_t iconcsumlen)
+faim_export int aim_bart_request(aim_session_t *sess, const char *sn, fu8_t iconcsumtype, const fu8_t *iconcsum, fu16_t iconcsumlen)
 {
 	aim_conn_t *conn;
 	aim_frame_t *fr;
@@ -97,7 +97,7 @@
 	/* Some numbers.  You like numbers, right? */
 	aimbs_put8(&fr->data, 0x01);
 	aimbs_put16(&fr->data, 0x0001);
-	aimbs_put8(&fr->data, 0x01);
+	aimbs_put8(&fr->data, iconcsumtype);
 
 	/* Icon string */
 	aimbs_put8(&fr->data, iconcsumlen);
@@ -119,18 +119,18 @@
 	aim_rxcallback_t userfunc;
 	char *sn;
 	fu16_t flags, iconlen;
-	fu8_t number, iconcsumlen, *iconcsum, *icon;
+	fu8_t iconcsumtype, iconcsumlen, *iconcsum, *icon;
 
 	sn = aimbs_getstr(bs, aimbs_get8(bs));
 	flags = aimbs_get16(bs);
-	number = aimbs_get8(bs);
+	iconcsumtype = aimbs_get8(bs);
 	iconcsumlen = aimbs_get8(bs);
 	iconcsum = aimbs_getraw(bs, iconcsumlen);
 	iconlen = aimbs_get16(bs);
 	icon = aimbs_getraw(bs, iconlen);
 
 	if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
-		ret = userfunc(sess, rx, sn, iconcsum, iconcsumlen, icon, iconlen);
+		ret = userfunc(sess, rx, sn, iconcsumtype, iconcsum, iconcsumlen, icon, iconlen);
 
 	free(sn);
 	free(iconcsum);
--- a/src/protocols/oscar/locate.c	Wed Jun 22 23:23:14 2005 +0000
+++ b/src/protocols/oscar/locate.c	Thu Jun 23 02:24:22 2005 +0000
@@ -746,8 +746,9 @@
 					} break;
 
 					case 0x0001: { /* A buddy icon checksum */
-						if ((length2 > 0) && (number == 0x01)) {
+						if ((length2 > 0) && ((number == 0x00) || (number == 0x01))) {
 							free(outinfo->iconcsum);
+							outinfo->iconcsumtype = number;
 							outinfo->iconcsum = aimbs_getraw(bs, length2);
 							outinfo->iconcsumlen = length2;
 						} else
--- a/src/protocols/oscar/oscar.c	Wed Jun 22 23:23:14 2005 +0000
+++ b/src/protocols/oscar/oscar.c	Thu Jun 23 02:24:22 2005 +0000
@@ -4632,18 +4632,23 @@
 	GSList *cur;
 	va_list ap;
 	char *sn;
-	fu8_t *iconcsum, *icon;
+	fu8_t iconcsumtype, *iconcsum, *icon;
 	fu16_t iconcsumlen, iconlen;
 
 	va_start(ap, fr);
 	sn = va_arg(ap, char *);
+	iconcsumtype = va_arg(ap, int);
 	iconcsum = va_arg(ap, fu8_t *);
 	iconcsumlen = va_arg(ap, int);
 	icon = va_arg(ap, fu8_t *);
 	iconlen = va_arg(ap, int);
 	va_end(ap);
 
-	if (iconlen > 0) {
+	/*
+	 * Some AIM clients will send a blank GIF image with iconlen 90 when
+	 * no icon is set.  Ignore these.
+	 */
+	if ((iconlen > 0) && (iconlen != 90)) {
 		char *b16;
 		GaimBuddy *b = gaim_find_buddy(gc->account, sn);
 		gaim_buddy_icons_set_for_user(gaim_connection_get_account(gc),
@@ -4722,7 +4727,7 @@
 
 	userinfo = aim_locate_finduserinfo(od->sess, (char *)od->requesticon->data);
 	if ((userinfo != NULL) && (userinfo->iconcsumlen > 0)) {
-		aim_bart_request(od->sess, od->requesticon->data, userinfo->iconcsum, userinfo->iconcsumlen);
+		aim_bart_request(od->sess, od->requesticon->data, userinfo->iconcsumtype, userinfo->iconcsum, userinfo->iconcsumlen);
 		return FALSE;
 	} else {
 		char *sn = od->requesticon->data;