Mercurial > pidgin
diff libpurple/protocols/oscar/tlv.c @ 30398:be056399ae5f
Fixes #12044. We send a dummy packet with DC version = 8 to make
Miranda and QIP think we come from a respectable family and deserve
being sent channel 2 messages (which we now treat as plain text).
Also, we now send HTML_MSGS capability to convince Trillian
to not strip HTML before sending us messages.
author | ivan.komarov@soc.pidgin.im |
---|---|
date | Thu, 05 Aug 2010 21:19:47 +0000 |
parents | bbb27d65681f |
children | 9b55bc3e2640 |
line wrap: on
line diff
--- a/libpurple/protocols/oscar/tlv.c Sat Jul 31 20:08:52 2010 +0000 +++ b/libpurple/protocols/oscar/tlv.c Thu Aug 05 21:19:47 2010 +0000 @@ -371,6 +371,17 @@ return aim_tlvlist_add_raw(list, type, strlen(value), (guint8 *)value); } +static int +count_caps(guint64 caps) +{ + int set_bits = 0; + while (caps) { + set_bits += caps & 1; + caps >>= 1; + } + return set_bits; +} + /** * Adds a block of capability blocks to a TLV chain. The bitfield * passed in should be a bitwise %OR of any of the %AIM_CAPS constants: @@ -389,23 +400,24 @@ */ int aim_tlvlist_add_caps(GSList **list, const guint16 type, const guint64 caps, const char *mood) { - guint8 buf[256]; /* TODO: Don't use a fixed length buffer */ ByteStream bs; + guint32 bs_size; guint8 *data; if (caps == 0) return 0; /* nothing there anyway */ - byte_stream_init(&bs, buf, sizeof(buf)); + data = icq_get_custom_icon_data(mood); + bs_size = 16*(count_caps(caps) + (data != NULL ? 1 : 0)); + byte_stream_new(&bs, bs_size); byte_stream_putcaps(&bs, caps); - + /* adding of custom icon GUID */ - data = icq_get_custom_icon_data(mood); if (data != NULL) byte_stream_putraw(&bs, data, 16); - return aim_tlvlist_add_raw(list, type, byte_stream_curpos(&bs), buf); + return aim_tlvlist_add_raw(list, type, byte_stream_curpos(&bs), bs.data); } /**