--- a/ChangeLog Sat Apr 02 09:24:44 2005 -0500
+++ b/ChangeLog Sat Apr 02 11:36:07 2005 -0500
@@ -6,6 +6,7 @@
* Fix signing on ICQ accounts with passwords greater than 8 characters
* Fix bug with going away while in a jabber chat
+ * MSN bug fixes (Felipe Contreras) version 1.2.0 (3/17/2005):
* Yahoo file receiving and buddy icon receiving work again.
--- a/src/protocols/msn/msn.c Sat Apr 02 09:24:44 2005 -0500
+++ b/src/protocols/msn/msn.c Sat Apr 02 11:36:07 2005 -0500
@@ -338,6 +338,7 @@
/* TODO: This might move somewhere else, after USR might be */
swboard->chat_id = session->conv_seq++;
swboard->conv = serv_got_joined_chat(gc, swboard->chat_id, "MSN Chat");
+ swboard->flag = MSN_SB_FLAG_IM; gaim_conv_chat_add_user(GAIM_CONV_CHAT(swboard->conv),
gaim_account_get_username(buddy->account), NULL, GAIM_CBFLAGS_NONE, TRUE);
@@ -696,7 +697,7 @@
session = gc->proto_data;
- swboard = msn_session_get_swboard(session, who);
+ swboard = msn_session_get_swboard(session, who, MSN_SB_FLAG_IM); msn_switchboard_send_msg(swboard, msg, TRUE);
@@ -757,6 +758,8 @@
if (swboard == NULL || !msn_switchboard_can_send(swboard))
+ swboard->flag |= MSN_SB_FLAG_IM; msg = msn_message_new(MSN_MSG_TYPING);
msn_message_set_content_type(msg, "text/x-msmsgscontrol");
msn_message_set_flag(msg, 'U');
@@ -1066,6 +1069,8 @@
swboard->conv = gaim_find_chat(gc, id);
+ swboard->flag |= MSN_SB_FLAG_IM; msn_switchboard_request_add_user(swboard, who);
@@ -1086,7 +1091,7 @@
- msn_switchboard_close(swboard);
+ msn_switchboard_release(swboard, MSN_SB_FLAG_IM); /* If other switchboards managed to associate themselves with this
* conv, make sure they know it's gone! */
@@ -1117,6 +1122,8 @@
+ swboard->flag |= MSN_SB_FLAG_IM; msn_import_html(message, &msgformat, &msgtext);
if (strlen(msgtext) + strlen(msgformat) + strlen(VERSION) > 1564)
@@ -1218,10 +1225,7 @@
- if (!(swboard->flag & MSN_SB_FLAG_FT))
- msn_switchboard_close(swboard);
+ msn_switchboard_release(swboard, MSN_SB_FLAG_IM); /* If other switchboards managed to associate themselves with this
* conv, make sure they know it's gone! */
--- a/src/protocols/msn/servconn.c Sat Apr 02 09:24:44 2005 -0500
+++ b/src/protocols/msn/servconn.c Sat Apr 02 11:36:07 2005 -0500
@@ -384,9 +384,9 @@
msn_cmdproc_process_cmd_text(servconn->cmdproc, cur);
- } while (servconn->connected && servconn->rx_len > 0);
+ } while (servconn->connected && !servconn->wasted && servconn->rx_len > 0); - if (servconn->connected)
+ if (servconn->connected && !servconn->wasted) if (servconn->rx_len > 0)
servconn->rx_buf = g_memdup(cur, servconn->rx_len);
--- a/src/protocols/msn/session.h Sat Apr 02 09:24:44 2005 -0500
+++ b/src/protocols/msn/session.h Sat Apr 02 11:36:07 2005 -0500
@@ -192,11 +192,12 @@
* @param session The MSN session.
* @param username The username to search for.
+ * @param flag The flag of the switchboard * @return The switchboard.
MsnSwitchBoard *msn_session_get_swboard(MsnSession *session,
+ const char *username, MsnSBFlag flag); * Sets an error for the MSN session.
--- a/src/protocols/msn/slp.c Sat Apr 02 09:24:44 2005 -0500
+++ b/src/protocols/msn/slp.c Sat Apr 02 11:36:07 2005 -0500
@@ -31,9 +31,6 @@
-/* #include "slplink.h" */
-/* #include "directconn.h" */
static void send_ok(MsnSlpCall *slpcall, const char *branch,
const char *type, const char *content);
@@ -124,6 +121,8 @@
msn_slplink_unleash(slpcall->slplink);
+ msn_slp_call_destroy(slpcall); @@ -746,7 +745,9 @@
got_emoticon(MsnSlpCall *slpcall,
const char *data, long long size)
gaim_debug_info("msn", "Got smiley: %s\n", slpcall->data_info);
serv_got_smiley(slpcall->slplink->session->account->gc,
@@ -825,7 +826,9 @@
g_return_if_fail(userlist != NULL);
gaim_debug_info("msn", "Releasing buddy icon request\n");
while (userlist->buddy_icon_window > 0)
@@ -846,8 +849,10 @@
msn_request_user_display(user);
userlist->buddy_icon_window--;
gaim_debug_info("msn", "buddy_icon_window=%d\n",
userlist->buddy_icon_window);
@@ -890,13 +895,17 @@
userlist = user->userlist;
queue = userlist->buddy_icon_requests;
gaim_debug_info("msn", "Queueing buddy icon request: %s\n",
g_queue_push_tail(queue, user);
gaim_debug_info("msn", "buddy_icon_window=%d\n",
userlist->buddy_icon_window);
if (userlist->buddy_icon_window > 0)
msn_release_buddy_icon_request(userlist);
@@ -915,7 +924,9 @@
g_return_if_fail(slpcall != NULL);
info = slpcall->data_info;
gaim_debug_info("msn", "Got User Display: %s\n", info);
userlist = slpcall->slplink->session->userlist;
account = slpcall->slplink->session->account;
@@ -950,7 +961,13 @@
g_return_if_fail(slpcall != NULL);
gaim_debug_info("msn", "End User Display\n");
+ /* Maybe the slplink was destroyed. */ + if (slpcall->slplink == NULL) userlist = slpcall->slplink->session->userlist;
@@ -961,8 +978,10 @@
/* Free one window slot */
userlist->buddy_icon_window++;
gaim_debug_info("msn", "buddy_icon_window=%d\n",
userlist->buddy_icon_window);
msn_release_buddy_icon_request(userlist);
@@ -1000,7 +1019,9 @@
const char *my_info = NULL;
gaim_debug_info("msn", "Requesting our own user display\n");
my_obj = msn_user_get_object(session->user);
@@ -1028,8 +1049,10 @@
/* Free one window slot */
session->userlist->buddy_icon_window++;
gaim_debug_info("msn", "buddy_icon_window=%d\n",
session->userlist->buddy_icon_window);
msn_release_buddy_icon_request(session->userlist);
--- a/src/protocols/msn/slpcall.c Sat Apr 02 09:24:44 2005 -0500
+++ b/src/protocols/msn/slpcall.c Sat Apr 02 11:36:07 2005 -0500
@@ -27,6 +27,8 @@
+/* #define MSN_DEBUG_SLPCALL */ /**************************************************************************
**************************************************************************/
@@ -58,6 +60,10 @@
slpcall = g_new0(MsnSlpCall, 1);
+#ifdef MSN_DEBUG_SLPCALL + gaim_debug_info("msn", "slpcall_new: slpcall(%p)\n", slpcall); slpcall->slplink = slplink;
msn_slplink_add_slpcall(slplink, slpcall);
@@ -72,6 +78,10 @@
+#ifdef MSN_DEBUG_SLPCALL + gaim_debug_info("msn", "slpcall_destroy: slpcall(%p)\n", slpcall); g_return_if_fail(slpcall != NULL);
@@ -86,17 +96,13 @@
if (slpcall->data_info != NULL)
g_free(slpcall->data_info);
- msn_slplink_remove_slpcall(slpcall->slplink, slpcall);
for (e = slpcall->slplink->slp_msgs; e != NULL; )
MsnSlpMessage *slpmsg = e->data;
- g_return_if_fail(slpmsg != NULL);
- gaim_debug_info("msn", "slpcall destroy: trying slp_msg (%p)\n",
+#ifdef MSN_DEBUG_SLPCALL_VERBOSE + gaim_debug_info("msn", "slpcall_destroy: trying slpmsg(%p)\n", @@ -106,6 +112,8 @@
+ msn_slplink_remove_slpcall(slpcall->slplink, slpcall); if (slpcall->end_cb != NULL)
slpcall->end_cb(slpcall);
@@ -164,6 +172,7 @@
slpmsg = msn_slpmsg_sip_new(slpcall, 0, header, slpcall->branch,
"application/x-msnmsgr-sessionreqbody", content);
slpmsg->info = "SLP INVITE";
slpmsg->text_body = TRUE;
@@ -193,7 +202,9 @@
- gaim_debug_info("msn", "slpcall timeout (%p)\n", slpcall);
+#ifdef MSN_DEBUG_SLPCALL + gaim_debug_info("msn", "slpcall_timeout: slpcall(%p)\n", slpcall); if (!slpcall->pending && !slpcall->progress)
@@ -232,12 +243,6 @@
slpcall->cb(slpcall, body, body_len);
- /* TODO: Shall we send a BYE? I don't think so*/
- send_bye(slpcall, "application/x-msnmsgr-sessionclosebody");
- msn_slplink_unleash(slpcall->slplink);
--- a/src/protocols/msn/slplink.c Sat Apr 02 09:24:44 2005 -0500
+++ b/src/protocols/msn/slplink.c Sat Apr 02 11:36:07 2005 -0500
@@ -67,6 +67,10 @@
slplink = g_new0(MsnSlpLink, 1);
+#ifdef MSN_DEBUG_SLPLINK + gaim_debug_info("msn", "slplink_new: slplink(%p)\n", slplink); slplink->session = session;
slplink->slp_seq_id = rand() % 0xFFFFFF00 + 4;
@@ -86,6 +90,10 @@
+#ifdef MSN_DEBUG_SLPLINK + gaim_debug_info("msn", "slplink_destroy: slplink(%p)\n", slplink); g_return_if_fail(slplink != NULL);
if (slplink->swboard != NULL)
@@ -173,11 +181,18 @@
slplink->slp_calls = g_list_remove(slplink->slp_calls, slpcall);
- /* The slplink has no slpcalls in it, maybe we should destroy it. */
+ /* The slplink has no slpcalls in it. If no one is using it, we might + * destroy the switchboard, but we should be careful not to use the slplink if (slplink->slp_calls == NULL)
if (slplink->swboard != NULL)
- slplink->swboard->flag &= ~MSN_SB_FLAG_FT;
+ if (msn_switchboard_release(slplink->swboard, MSN_SB_FLAG_FT)) + /* I'm not sure this is the best thing to do, but it's better + slpcall->slplink = NULL; @@ -230,7 +245,7 @@
if (slplink->swboard == NULL)
slplink->swboard = msn_session_get_swboard(slplink->session,
+ slplink->remote_user, MSN_SB_FLAG_FT); if (slplink->swboard == NULL)
--- a/src/protocols/msn/switchboard.c Sat Apr 02 09:24:44 2005 -0500
+++ b/src/protocols/msn/switchboard.c Sat Apr 02 11:36:07 2005 -0500
@@ -29,6 +29,8 @@
+/* #define MSN_DEBUG_SWBOARD */ static MsnTable *cbs_table;
static void msg_error_helper(MsnCmdProc *cmdproc, MsnMessage *msg,
@@ -70,8 +72,17 @@
+#ifdef MSN_DEBUG_SWBOARD + gaim_debug_info("msn", "switchboard_destroy: swboard(%p)\n", swboard); g_return_if_fail(swboard != NULL);
+ if (swboard->destroying) + swboard->destroying = TRUE; /* If it linked us is because its looking for trouble */
if (swboard->slplink != NULL)
msn_slplink_destroy(swboard->slplink);
@@ -210,8 +221,19 @@
swboard->current_users++;
- /* gaim_debug_info("msn", "user=[%s], total=%d\n", user,
- * swboard->current_users); */
+ gaim_debug_info("msn", "user=[%s], total=%d\n", user, + swboard->current_users); + if (!(swboard->flag & MSN_SB_FLAG_IM)) + /* This is a helper switchboard. */ + if (swboard->conv != NULL) + gaim_debug_error("msn", "switchboard_add_user: conv != NULL\n"); if ((swboard->conv != NULL) &&
(gaim_conversation_get_type(swboard->conv) == GAIM_CONV_CHAT))
@@ -226,7 +248,10 @@
- /* gaim_debug_info("msn", "[chat] Switching to chat.\n"); */
+ gaim_debug_info("msn", "[chat] Switching to chat.\n"); /* this is bad - it causes msn_switchboard_close to be called on the
* switchboard we're in the middle of using :( */
@@ -247,14 +272,17 @@
- /* gaim_debug_info("msn", "[chat] Adding [%s].\n",
+ gaim_debug_info("msn", "[chat] Adding [%s].\n", tmp_user); gaim_conv_chat_add_user(GAIM_CONV_CHAT(swboard->conv),
tmp_user, NULL, GAIM_CBFLAGS_NONE, TRUE);
- /* gaim_debug_info("msn", "[chat] We add ourselves.\n"); */
+ gaim_debug_info("msn", "[chat] We add ourselves.\n"); gaim_conv_chat_add_user(GAIM_CONV_CHAT(swboard->conv),
gaim_account_get_username(account),
@@ -270,8 +298,7 @@
- gaim_debug_warning("msn", "This should not happen!"
- "(msn_switchboard_add_user)\n");
+ gaim_debug_warning("msn", "switchboard_add_user: This should not happen!\n"); @@ -353,6 +380,9 @@
+ /* This is not good, and should be fixed somewhere else. */ + g_return_if_fail(swboard != NULL); if (msg->type == MSN_MSG_TEXT)
const char *format, *str_reason;
@@ -609,6 +639,20 @@
+ if (!(swboard->flag & MSN_SB_FLAG_IM)) + /* TODO: This is a helper switchboard. It would be better if + * swboard->conv is NULL, but it isn't. */ + /* Umm? I think swboard->conv is NULL for all helper switchboards now? */ + msn_switchboard_destroy(swboard); + if (!(swboard->flag & MSN_SB_FLAG_IM)) + gaim_debug_error("msn_switchboard", "bye_cmd: helper bug\n"); if (swboard->conv == NULL)
/* This is a helper switchboard */
@@ -860,21 +904,35 @@
+ swboard->flag |= MSN_SB_FLAG_IM; if (swboard->current_users > 1 ||
((swboard->conv != NULL) &&
gaim_conversation_get_type(swboard->conv) == GAIM_CONV_CHAT))
+ /* If current_users is always ok as it should then there is no need to + * check if this is a chat. */ + if (swboard->current_users <= 1) + gaim_debug_misc("msn", "plain_msg: current_users(%d)\n", + swboard->current_users); serv_got_chat_in(gc, swboard->chat_id, passport, 0, body_final,
if (swboard->conv == NULL)
swboard->conv = gaim_find_chat(gc, swboard->chat_id);
+ swboard->flag |= MSN_SB_FLAG_IM; serv_got_im(gc, passport, body_final, 0, time(NULL));
if (swboard->conv == NULL)
swboard->conv = gaim_find_conversation_with_account(passport,
gaim_connection_get_account(gc));
+ swboard->flag |= MSN_SB_FLAG_IM; @@ -1114,9 +1172,6 @@
g_return_if_fail(swboard != NULL);
- /* forget any conversation that used to be associated with this swboard */
if (swboard->error != MSN_SB_ERROR_NONE)
msn_switchboard_destroy(swboard);
@@ -1136,6 +1191,27 @@
+msn_switchboard_release(MsnSwitchBoard *swboard, MsnSBFlag flag) + g_return_val_if_fail(swboard != NULL, FALSE); + swboard->flag &= ~flag; + if (flag == MSN_SB_FLAG_IM) + /* Forget any conversation that used to be associated with this + if (swboard->flag == 0) + msn_switchboard_close(swboard); /**************************************************************************
**************************************************************************/
--- a/src/protocols/msn/switchboard.h Sat Apr 02 09:24:44 2005 -0500
+++ b/src/protocols/msn/switchboard.h Sat Apr 02 11:36:07 2005 -0500
@@ -54,7 +54,8 @@
- MSN_SB_FLAG_FT = 0x01, /**< This switchboard is being used for file transfer. */
+ MSN_SB_FLAG_IM = 0x01, /**< This switchboard is being used for a conversation. */ + MSN_SB_FLAG_FT = 0x02, /**< This switchboard is being used for file transfer. */ @@ -86,6 +87,8 @@
gboolean closed; /**< A flag that states if the switchboard has
been closed by the user. */
+ gboolean destroying; /**< A flag that states if the switchboard is + alredy on the process of destruction. */ @@ -207,6 +210,16 @@
void msn_switchboard_close(MsnSwitchBoard *swboard);
+ * Release a switchboard from a certain function. + * @param swboard The switchboard to release. + * @param flag The flag that states the function. + * @return @c TRUE if the switchboard was closed, @c FALSE otherwise. +gboolean msn_switchboard_release(MsnSwitchBoard *swboard, MsnSBFlag flag); * Returns whether or not we currently can send a message through this