Mercurial > pidgin.yaz
changeset 6101:e4a5085fb870
[gaim-migrate @ 6560]
This should fix some icon uploading looping.
Sean, the problem was that, when adding the md5 sum to ssi, the code was
checking if it existed by looking for an item named "0", but it was
actually adding an item named "1." So for accounts with no icon info yet,
Gaim would end up getting in a loop and spiraling into oblivion, only far
less dramatic.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sat, 12 Jul 2003 19:08:19 +0000 |
parents | 5823ed7e2583 |
children | c2273728aea1 |
files | src/gaimrc.c src/protocols/oscar/aim.h src/protocols/oscar/service.c src/protocols/oscar/ssi.c src/protocols/oscar/tlv.c |
diffstat | 5 files changed, 47 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/src/gaimrc.c Sat Jul 12 17:38:06 2003 +0000 +++ b/src/gaimrc.c Sat Jul 12 19:08:19 2003 +0000 @@ -29,6 +29,7 @@ #include "proxy.h" #include "prpl.h" #include "sound.h" +#include "status.h" #include "ui.h" #include "util.h"
--- a/src/protocols/oscar/aim.h Sat Jul 12 17:38:06 2003 +0000 +++ b/src/protocols/oscar/aim.h Sat Jul 12 19:08:19 2003 +0000 @@ -1349,6 +1349,7 @@ faim_internal aim_tlvlist_t *aim_readtlvchain_num(aim_bstream_t *bs, fu16_t num); faim_internal aim_tlvlist_t *aim_readtlvchain_len(aim_bstream_t *bs, fu16_t len); faim_internal aim_tlvlist_t *aim_tlvlist_copy(aim_tlvlist_t *orig); +faim_internal int aim_tlvlist_cmp(aim_tlvlist_t *one, aim_tlvlist_t *two); faim_internal void aim_freetlvchain(aim_tlvlist_t **list); faim_internal aim_tlv_t *aim_gettlv(aim_tlvlist_t *, fu16_t t, const int n); faim_internal char *aim_gettlv_str(aim_tlvlist_t *, const fu16_t t, const int n);
--- a/src/protocols/oscar/service.c Sat Jul 12 17:38:06 2003 +0000 +++ b/src/protocols/oscar/service.c Sat Jul 12 19:08:19 2003 +0000 @@ -1016,12 +1016,13 @@ if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) { switch (type) { case 0x0000: - case 0x0001: { /* not sure what the difference between 1 and 0 is */ + case 0x0001: { /* buddy icon checksum */ + /* not sure what the difference between 1 and 0 is */ fu8_t *md5 = aimbs_getraw(bs, length); ret = userfunc(sess, rx, type, flags, length, md5); free(md5); } break; - case 0x0002: { + case 0x0002: { /* available message */ /* there is a second length that is just for the message */ char *msg = aimbs_getstr(bs, aimbs_get16(bs)); ret = userfunc(sess, rx, msg);
--- a/src/protocols/oscar/ssi.c Sat Jul 12 17:38:06 2003 +0000 +++ b/src/protocols/oscar/ssi.c Sat Jul 12 19:08:19 2003 +0000 @@ -214,29 +214,9 @@ if (!cur1->data && cur2->data) return 3; - if (cur1->data && cur2->data) { - /* Write each TLV list to a bstream and then memcmp them */ - aim_bstream_t bs1, bs2; - - if (aim_sizetlvchain(&cur1->data) != aim_sizetlvchain(&cur2->data)) + if ((cur1->data && cur2->data) && (aim_tlvlist_cmp(cur1->data, cur2->data))) return 4; - aim_bstream_init(&bs1, ((fu8_t *)malloc(aim_sizetlvchain(&cur1->data)*sizeof(fu8_t))), aim_sizetlvchain(&cur1->data)); - aim_bstream_init(&bs2, ((fu8_t *)malloc(aim_sizetlvchain(&cur2->data)*sizeof(fu8_t))), aim_sizetlvchain(&cur2->data)); - - aim_writetlvchain(&bs1, &cur1->data); - aim_writetlvchain(&bs2, &cur2->data); - - if (memcmp(bs1.data, bs2.data, bs1.len)) { - free(bs1.data); - free(bs2.data); - return 4; - } - - free(bs1.data); - free(bs2.data); - } - if (cur1->name && !cur2->name) return 5; @@ -1047,7 +1027,14 @@ /* This TLV is added to cache the icon. */ aim_addtlvtochain_noval(&data, 0x0131); - if ((tmp = aim_ssi_itemlist_finditem(sess->ssi.local, NULL, "0", AIM_SSI_TYPE_ICONINFO))) { + if ((tmp = aim_ssi_itemlist_finditem(sess->ssi.local, NULL, "1", AIM_SSI_TYPE_ICONINFO))) { + /* If the new tlvchain and oldtlvchain are the same, then do nothing */ + if (!aim_tlvlist_cmp(tmp->data, data)) { + /* The new tlvlist is the identical to the old one */ + aim_freetlvchain(&data); + free(csumdata); + return 0; + } aim_freetlvchain(&tmp->data); tmp->data = data; } else {
--- a/src/protocols/oscar/tlv.c Sat Jul 12 17:38:06 2003 +0000 +++ b/src/protocols/oscar/tlv.c Sat Jul 12 19:08:19 2003 +0000 @@ -262,6 +262,39 @@ return new; } +/* + * Compare two TLV lists for equality. This probably is not the most + * efficient way to do this. + * + * @param one One of the TLV chains to compare. + * @param two The other TLV chain to compare. + * @preturn Retrun 0 if the lists are the same, return 1 if they are different. + */ +faim_internal int aim_tlvlist_cmp(aim_tlvlist_t *one, aim_tlvlist_t *two) +{ + aim_bstream_t bs1, bs2; + + if (aim_sizetlvchain(&one) != aim_sizetlvchain(&two)) + return 1; + + aim_bstream_init(&bs1, ((fu8_t *)malloc(aim_sizetlvchain(&one)*sizeof(fu8_t))), aim_sizetlvchain(&one)); + aim_bstream_init(&bs2, ((fu8_t *)malloc(aim_sizetlvchain(&two)*sizeof(fu8_t))), aim_sizetlvchain(&two)); + + aim_writetlvchain(&bs1, &one); + aim_writetlvchain(&bs2, &two); + + if (memcmp(bs1.data, bs2.data, bs1.len)) { + free(bs1.data); + free(bs2.data); + return 1; + } + + free(bs1.data); + free(bs2.data); + + return 0; +} + /** * aim_freetlvchain - Free a TLV chain structure * @list: Chain to be freed