# HG changeset patch # User Christian Hammond # Date 1063495688 0 # Node ID 2adf21e7060194eff6869e7f8b28afa3f747c833 # Parent 936133f7c7550281d3322806d26e7e6ce8123b03 [gaim-migrate @ 7371] Fixed message length problems for binary and text. committer: Tailor Script diff -r 936133f7c755 -r 2adf21e70601 src/protocols/msn/msg.c --- 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; } diff -r 936133f7c755 -r 2adf21e70601 src/protocols/msn/msg.h --- 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. diff -r 936133f7c755 -r 2adf21e70601 src/protocols/msn/servconn.c --- 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); } diff -r 936133f7c755 -r 2adf21e70601 src/protocols/msn/switchboard.c --- 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);