Mercurial > pidgin.yaz
changeset 6826:2adf21e70601
[gaim-migrate @ 7371]
Fixed message length problems for binary and text.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Sat, 13 Sep 2003 23:28:08 +0000 |
parents | 936133f7c755 |
children | 1cfbb731aa1f |
files | src/protocols/msn/msg.c src/protocols/msn/msg.h src/protocols/msn/servconn.c src/protocols/msn/switchboard.c |
diffstat | 4 files changed, 15 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/src/protocols/msn/msg.c Sat Sep 13 21:01:26 2003 +0000 +++ b/src/protocols/msn/msg.c Sat Sep 13 23:28:08 2003 +0000 @@ -298,7 +298,7 @@ } char * -msn_message_build_string(const MsnMessage *msg) +msn_message_to_string(const MsnMessage *msg, size_t *ret_size) { GList *l; char *msg_start; @@ -332,7 +332,7 @@ len = strlen(buf) + msg->size + 1; - str = g_new0(char, len); + str = g_new0(char, len + 1); g_strlcpy(str, buf, len); @@ -434,6 +434,9 @@ } } + if (ret_size != NULL) + *ret_size = len - 1; + return str; }
--- a/src/protocols/msn/msg.h Sat Sep 13 21:01:26 2003 +0000 +++ b/src/protocols/msn/msg.h Sat Sep 13 23:28:08 2003 +0000 @@ -133,11 +133,12 @@ /** * Converts a message to a string. * - * @param msg The message. + * @param msg The message. + * @param ret_size The returned size of the string. * * @return The string representation of a message. */ -char *msn_message_build_string(const MsnMessage *msg); +char *msn_message_to_string(const MsnMessage *msg, size_t *ret_size); /** * Returns TRUE if the message is outgoing.
--- a/src/protocols/msn/servconn.c Sat Sep 13 21:01:26 2003 +0000 +++ b/src/protocols/msn/servconn.c Sat Sep 13 23:28:08 2003 +0000 @@ -336,10 +336,8 @@ { g_return_val_if_fail(servconn != NULL, 0); -#if 0 gaim_debug(GAIM_DEBUG_MISC, "msn", "C: %s%s", buf, (*(buf + size - 1) == '\n' ? "" : "\n")); -#endif return write(servconn->fd, buf, size); }
--- a/src/protocols/msn/switchboard.c Sat Sep 13 21:01:26 2003 +0000 +++ b/src/protocols/msn/switchboard.c Sat Sep 13 23:28:08 2003 +0000 @@ -46,6 +46,9 @@ msn_message_set_body(msg, MSN_CLIENTINFO); if (!msn_switchboard_send_msg(swboard, msg)) { + gaim_debug_warning("msn", + "Unable to send clientcaps. " + "Disconnecting from switchboard.\n"); msn_switchboard_destroy(swboard); msn_message_destroy(msg); @@ -110,7 +113,7 @@ } #endif - return FALSE; + return TRUE; } static gboolean @@ -634,13 +637,14 @@ msn_switchboard_send_msg(MsnSwitchBoard *swboard, MsnMessage *msg) { char *buf; + size_t len; int ret; g_return_val_if_fail(swboard != NULL, FALSE); g_return_val_if_fail(msg != NULL, FALSE); msn_message_set_transaction_id(msg, ++swboard->trId); - buf = msn_message_build_string(msg); + buf = msn_message_to_string(msg, &len); g_return_val_if_fail(buf != NULL, FALSE); @@ -653,7 +657,7 @@ return TRUE; } - ret = msn_servconn_write(swboard->servconn, buf, strlen(buf)); + ret = msn_servconn_write(swboard->servconn, buf, len); g_free(buf);