Mercurial > pidgin
changeset 29614:24b7fa9c0c8b
merge of '4f0c3aedc3b013ab2175e57b71bab92988e4f812'
and 'fe4644296ed29ff3456121616137d3b6c04d9ee8'
author | Elliott Sales de Andrade <qulogic@pidgin.im> |
---|---|
date | Fri, 19 Mar 2010 02:44:22 +0000 |
parents | a7875e67ad9c (current diff) 79c6f28e44ec (diff) |
children | 97005a2e99d7 |
files | |
diffstat | 4 files changed, 23 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Thu Mar 18 08:30:02 2010 +0000 +++ b/ChangeLog Fri Mar 19 02:44:22 2010 +0000 @@ -47,6 +47,8 @@ * Direct messages to a specific resource only upon receipt of a message with content (as opposed to a typing notification, etc). (Thanks to rjoly for testing) + * When sending data using in-band-bytestreams, interpret the block-size + attribute as the size of the BASE64-encoded representation of the data. Yahoo: * Attempt to better handle transparent proxies interfering with HTTP-based
--- a/libpurple/protocols/jabber/ibb.c Thu Mar 18 08:30:02 2010 +0000 +++ b/libpurple/protocols/jabber/ibb.c Fri Mar 19 02:44:22 2010 +0000 @@ -157,6 +157,12 @@ } } +gsize +jabber_ibb_session_get_max_data_size(const JabberIBBSession *sess) +{ + return (gsize) floor((sess->block_size - 2) * (float) 3 / 4); +} + gpointer jabber_ibb_session_get_user_data(JabberIBBSession *sess) { @@ -321,7 +327,7 @@ if (state != JABBER_IBB_SESSION_OPENED) { purple_debug_error("jabber", "trying to send data on a non-open IBB session\n"); - } else if (size > jabber_ibb_session_get_block_size(sess)) { + } else if (size > jabber_ibb_session_get_max_data_size(sess)) { purple_debug_error("jabber", "trying to send a too large packet in the IBB session\n"); } else { @@ -416,6 +422,10 @@ purple_debug_info("jabber", "got %" G_GSIZE_FORMAT " bytes of data on IBB stream\n", size); + /* we accept other clients to send up to block-size + of _unencoded_ data, since there's been some confusions + regarding the interpretation of this attribute + (including previous versions of libpurple) */ if (size > jabber_ibb_session_get_block_size(sess)) { purple_debug_error("jabber", "IBB: received a too large packet\n");
--- a/libpurple/protocols/jabber/ibb.h Thu Mar 18 08:30:02 2010 +0000 +++ b/libpurple/protocols/jabber/ibb.h Fri Mar 19 02:44:22 2010 +0000 @@ -107,6 +107,10 @@ gsize jabber_ibb_session_get_block_size(const JabberIBBSession *sess); void jabber_ibb_session_set_block_size(JabberIBBSession *sess, gsize size); +/* get maximum size data block to send (in bytes) + (before encoded to BASE64) */ +gsize jabber_ibb_session_get_max_data_size(const JabberIBBSession *sess); + gpointer jabber_ibb_session_get_user_data(JabberIBBSession *sess); /* handle incoming packet */
--- a/libpurple/protocols/jabber/si.c Thu Mar 18 08:30:02 2010 +0000 +++ b/libpurple/protocols/jabber/si.c Fri Mar 19 02:44:22 2010 +0000 @@ -1075,6 +1075,9 @@ jabber_si_xfer_ibb_error_cb); jsx->ibb_session = sess; + /* we handle up to block-size bytes of decoded data, to handle + clients interpreting the block-size attribute as that + (see also remark in ibb.c) */ jsx->ibb_buffer = purple_circ_buffer_new(jabber_ibb_session_get_block_size(sess)); @@ -1103,8 +1106,8 @@ { JabberSIXfer *jsx = (JabberSIXfer *) xfer->data; JabberIBBSession *sess = jsx->ibb_session; - gsize packet_size = len < jabber_ibb_session_get_block_size(sess) ? - len : jabber_ibb_session_get_block_size(sess); + gsize packet_size = len < jabber_ibb_session_get_max_data_size(sess) ? + len : jabber_ibb_session_get_max_data_size(sess); jabber_ibb_session_send_data(sess, buffer, packet_size); @@ -1170,7 +1173,7 @@ purple_xfer_set_write_fnc(xfer, jabber_si_xfer_ibb_write); jsx->ibb_buffer = - purple_circ_buffer_new(jabber_ibb_session_get_block_size(jsx->ibb_session)); + purple_circ_buffer_new(jabber_ibb_session_get_max_data_size(jsx->ibb_session)); /* open the IBB session */ jabber_ibb_session_open(jsx->ibb_session);