# HG changeset patch # User Stu Tomlinson # Date 1102873056 0 # Node ID bbf738a0ce7b455e1372fd1e667799c55f9712dc # Parent 2e01c503aa4fb45aace7ea70081a4ff7f098ace1 [gaim-migrate @ 11560] More more MSN bug fixes from Felipe Contreras, and I fixed up the display of messages that failed to send so that it matches what you tried to send and doesn't have kittens with html entities and such. I added a GAIM_MESSAGE_RAW type in HEAD to make the display of such messages even more accurate, but I don't think such a cosmetic change, which would bump us to 1.2.0, is all that important for oldstatus. committer: Tailor Script diff -r 2e01c503aa4f -r bbf738a0ce7b src/conversation.h --- a/src/conversation.h Sat Dec 11 20:01:58 2004 +0000 +++ b/src/conversation.h Sun Dec 12 17:37:36 2004 +0000 @@ -118,7 +118,8 @@ GAIM_MESSAGE_NO_LOG = 0x0040, /**< Do not log. */ GAIM_MESSAGE_WHISPER = 0x0080, /**< Whispered message. */ GAIM_MESSAGE_ERROR = 0x0200, /**< Error message. */ - GAIM_MESSAGE_DELAYED = 0x0400 /**< Delayed message. */ + GAIM_MESSAGE_DELAYED = 0x0400, /**< Delayed message. */ + GAIM_MESSAGE_RAW = 0x0800 /**< "Raw" message - don't apply formatting */ } GaimMessageFlags; diff -r 2e01c503aa4f -r bbf738a0ce7b src/gtkconv.c --- a/src/gtkconv.c Sat Dec 11 20:01:58 2004 +0000 +++ b/src/gtkconv.c Sun Dec 12 17:37:36 2004 +0000 @@ -5028,8 +5028,11 @@ sml_attrib, message); gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf, 0); - } - else { + } else if (flags & GAIM_MESSAGE_RAW) { + g_snprintf(buf, BUF_LONG, "%s", message); + + gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf, 0); + } else { char *new_message = g_memdup(message, length); char *who_escaped = (who ? g_markup_escape_text(who, strlen(who)) : g_strdup("")); @@ -5079,7 +5082,7 @@ col.green = col.green * scale; col.blue = col.blue * scale; } - + g_snprintf(color, sizeof(color), "#%02X%02X%02X", col.red >> 8, col.green >> 8, col.blue >> 8); } else diff -r 2e01c503aa4f -r bbf738a0ce7b src/protocols/msn/msg.h --- a/src/protocols/msn/msg.h Sat Dec 11 20:01:58 2004 +0000 +++ b/src/protocols/msn/msg.h Sun Dec 12 17:37:36 2004 +0000 @@ -109,13 +109,16 @@ GHashTable *attr_table; GList *attr_list; + gboolean ack_ref; /**< A flag that states if this message has + been ref'ed for using it in a callback. */ + MsnCommand *cmd; MsnTransaction *trans; MsnMsgCb ack_cb; /**< The callback to call when we receive an ACK of this - message. */ + message. */ MsnMsgCb nak_cb; /**< The callback to call when we receive a NAK of this - message. */ + message. */ void *ack_data; /**< The data used by callbacks. */ MsnMsgErrorType error; /**< The error of the message. */ diff -r 2e01c503aa4f -r bbf738a0ce7b src/protocols/msn/msn.c --- a/src/protocols/msn/msn.c Sat Dec 11 20:01:58 2004 +0000 +++ b/src/protocols/msn/msn.c Sun Dec 12 17:37:36 2004 +0000 @@ -781,6 +781,7 @@ format = msn_message_get_attr(msg, "X-MMS-IM-Format"); msn_parse_format(format, &pre, &post); body_str = g_strdup_printf("%s%s%s", pre, body_enc, post); + g_free(body_enc); g_free(pre); g_free(post); @@ -824,6 +825,9 @@ if (swboard->empty) return 0; + if (!g_queue_is_empty(swboard->im_queue)) + return 0; + msg = msn_message_new(MSN_MSG_TYPING); msn_message_set_content_type(msg, "text/x-msmsgscontrol"); msn_message_set_flag(msg, 'U'); @@ -831,16 +835,7 @@ gaim_account_get_username(account)); msn_message_set_bin_data(msg, "\r\n", 2); - swboard = msn_session_get_swboard(session, who); - - if (!g_queue_is_empty(swboard->im_queue) || swboard->empty) - { - msn_switchboard_queue_msg(swboard, msg); - } - else - { - msn_switchboard_send_msg(swboard, msg); - } + msn_switchboard_send_msg(swboard, msg); msn_message_destroy(msg); diff -r 2e01c503aa4f -r bbf738a0ce7b src/protocols/msn/slp.h --- a/src/protocols/msn/slp.h Sat Dec 11 20:01:58 2004 +0000 +++ b/src/protocols/msn/slp.h Sun Dec 12 17:37:36 2004 +0000 @@ -24,7 +24,7 @@ #ifndef _MSN_SLP_H_ #define _MSN_SLP_H_ -/* #define MSN_DEBUG_MSG 1 */ +#define MSN_DEBUG_MSG 1 /* #define MSN_DEBUG_SLPMSG 1 */ /* #define MSN_DEBUG_SLP 1 */ diff -r 2e01c503aa4f -r bbf738a0ce7b src/protocols/msn/slplink.c --- a/src/protocols/msn/slplink.c Sat Dec 11 20:01:58 2004 +0000 +++ b/src/protocols/msn/slplink.c Sun Dec 12 17:37:36 2004 +0000 @@ -209,7 +209,7 @@ if (slplink->swboard == NULL) return; - /* If swboard is destroyed we will too */ + /* If swboard is destroyed we will be too */ slplink->swboard->slplink = slplink; } diff -r 2e01c503aa4f -r bbf738a0ce7b src/protocols/msn/switchboard.c --- a/src/protocols/msn/switchboard.c Sat Dec 11 20:01:58 2004 +0000 +++ b/src/protocols/msn/switchboard.c Sun Dec 12 17:37:36 2004 +0000 @@ -201,6 +201,7 @@ swboard->users = g_list_prepend(swboard->users, g_strdup(user)); swboard->current_users++; + swboard->empty = FALSE; /* gaim_debug_info("msn", "user=[%s], total=%d\n", user, * swboard->current_users); */ @@ -276,7 +277,7 @@ if (swboard->conv != NULL) return swboard->conv; - gaim_debug_error("msn", "Switchboard with unnasigned conversation\n"); + gaim_debug_error("msn", "Switchboard with unassigned conversation\n"); account = swboard->session->account; @@ -341,8 +342,8 @@ if (msg->type == MSN_MSG_TEXT) { MsnSwitchBoard *swboard; - char *body; - char *report; + const char *format; + char *body_str, *body_enc, *pre, *post; char *str_reason; swboard = cmdproc->servconn->data; @@ -350,61 +351,68 @@ #if 0 if (swboard->conv == NULL) { - msn_message_unref(msg); + if (msg->ack_ref) + msn_message_unref(msg); + return; } #endif - if (msg->error == MSN_MSG_ERROR_TIMEOUT) + if (error == MSN_MSG_ERROR_TIMEOUT) { str_reason = _("Message may have not been sent " - "because a time out occured."); + "because a time out occured:"); } - else if (msg->error == MSN_MSG_ERROR_SB) + else if (error == MSN_MSG_ERROR_SB) { switch (swboard->error) { case MSN_SB_ERROR_OFFLINE: str_reason = _("Message could not be sent, " - "not allowed while invisible"); + "not allowed while invisible:"); break; case MSN_SB_ERROR_USER_OFFLINE: str_reason = _("Message could not be sent " - "because the user is offline"); + "because the user is offline:"); break; case MSN_SB_ERROR_CONNECTION: str_reason = _("Message could not be sent " - "because a connection error occured"); + "because a connection error occured:"); break; default: str_reason = _("Message could not be sent " "because an error with " - "the switchboard occured"); + "the switchboard occured:"); break; } } else { str_reason = _("Message may have not been sent " - "because an unkwown error occured"); + "because an unkwown error occured:"); } - body = msn_message_to_string(msg); - report = g_strdup_printf(_("%s:\n%s"), str_reason, body); + body_str = msn_message_to_string(msg); + body_enc = gaim_escape_html(body_str); + g_free(body_str); + + format = msn_message_get_attr(msg, "X-MMS-IM-Format"); + msn_parse_format(format, &pre, &post); + body_str = g_strdup_printf("%s%s%s", pre, body_enc, post); + g_free(body_enc); + g_free(pre); + g_free(post); msn_switchboard_report_user(cmdproc->servconn->data, - GAIM_MESSAGE_ERROR, report); - - g_free(report); - g_free(body); + GAIM_MESSAGE_ERROR, str_reason); + msn_switchboard_report_user(cmdproc->servconn->data, + GAIM_MESSAGE_RAW, body_str); - msn_message_unref(msg); - } - else if (msg->type == MSN_MSG_SLP) - { - msn_message_unref(msg); + g_free(body_str); } + if (msg->ack_ref) + msn_message_unref(msg); } /************************************************************************** @@ -515,8 +523,6 @@ msn_switchboard_add_user(swboard, passport); - swboard->empty = FALSE; - msn_switchboard_process_queue(swboard); send_clientcaps(swboard); @@ -789,11 +795,13 @@ if (msg->type == MSN_MSG_TEXT) { + msg->ack_ref = TRUE; msn_message_ref(msg); msn_transaction_set_timeout_cb(trans, msg_timeout); } else if (msg->type == MSN_MSG_SLP) { + msg->ack_ref = TRUE; msn_message_ref(msg); msn_transaction_set_timeout_cb(trans, msg_timeout); #if 0 @@ -862,10 +870,10 @@ swboard = servconn->data; g_return_if_fail(swboard != NULL); - swboard->empty = FALSE; - if (msn_switchboard_is_invited(swboard)) { + swboard->empty = FALSE; + msn_cmdproc_send(cmdproc, "ANS", "%s %s %s", gaim_account_get_username(account), swboard->auth_key, swboard->session_id); diff -r 2e01c503aa4f -r bbf738a0ce7b src/protocols/msn/switchboard.h --- a/src/protocols/msn/switchboard.h Sat Dec 11 20:01:58 2004 +0000 +++ b/src/protocols/msn/switchboard.h Sun Dec 12 17:37:36 2004 +0000 @@ -40,12 +40,12 @@ */ typedef enum { - MSN_SB_ERROR_NONE, /**< No error */ - MSN_SB_ERROR_CAL, /**< The user could not join (answer the call) */ - MSN_SB_ERROR_OFFLINE, /**< The account is offline */ - MSN_SB_ERROR_USER_OFFLINE, /**< The user to call is offline */ - MSN_SB_ERROR_CONNECTION, /**< There was a connection error */ - MSN_SB_ERROR_UNKNOWN /**< An unknown error occured */ + MSN_SB_ERROR_NONE, /**< No error. */ + MSN_SB_ERROR_CAL, /**< The user could not join (answer the call). */ + MSN_SB_ERROR_OFFLINE, /**< The account is offline. */ + MSN_SB_ERROR_USER_OFFLINE, /**< The user to call is offline. */ + MSN_SB_ERROR_CONNECTION, /**< There was a connection error. */ + MSN_SB_ERROR_UNKNOWN /**< An unknown error occured. */ } MsnSBErrorType;