# HG changeset patch # User Stu Tomlinson # Date 1106239034 0 # Node ID ace8cd0de6ea686ab2627f5edbec1484b8ec42eb # Parent 8f2b74c5aa24dcfce0bf515d3279c88f7d941c77 [gaim-migrate @ 11862] Some minor MSN reorganization from Felipe and a bunch of MSN chat related fixes and improvements from me. committer: Tailor Script diff -r 8f2b74c5aa24 -r ace8cd0de6ea src/protocols/msn/httpconn.c --- a/src/protocols/msn/httpconn.c Thu Jan 20 14:40:56 2005 +0000 +++ b/src/protocols/msn/httpconn.c Thu Jan 20 16:37:14 2005 +0000 @@ -283,7 +283,6 @@ { gaim_debug_error("msn", "HTTP: Read error\n"); msn_servconn_got_error(httpconn->servconn, MSN_SERVCONN_ERROR_READ); - msn_httpconn_disconnect(httpconn); return; } @@ -310,11 +309,15 @@ { gaim_debug_error("msn", "HTTP: Special error\n"); msn_servconn_got_error(httpconn->servconn, MSN_SERVCONN_ERROR_READ); - msn_httpconn_disconnect(httpconn); return; } + if (httpconn->rx_buf != NULL) + g_free(httpconn->rx_buf); + httpconn->rx_buf = NULL; + httpconn->rx_len = 0; + if (result_len == 0) { /* Nothing to do here */ @@ -322,17 +325,11 @@ gaim_debug_info("msn", "HTTP: nothing to do here\n"); #endif g_free(result_msg); - g_free(httpconn->rx_buf); - httpconn->rx_buf = NULL; - httpconn->rx_len = 0; return; } - g_free(httpconn->rx_buf); - httpconn->rx_buf = NULL; - httpconn->rx_len = 0; - - g_free(servconn->rx_buf); + if (servconn->rx_buf != NULL) + g_free(servconn->rx_buf); servconn->rx_buf = result_msg; servconn->rx_len = result_len; @@ -702,8 +699,10 @@ servconn = httpconn->servconn; - if (servconn != NULL) - servconn->wasted = TRUE; + /* I'll be honest, I don't fully understand all this, but this + * causes crashes, Stu. */ + /* if (servconn != NULL) + servconn->wasted = TRUE; */ g_free(full_session_id); g_free(session_id); diff -r 8f2b74c5aa24 -r ace8cd0de6ea src/protocols/msn/msn.c --- a/src/protocols/msn/msn.c Thu Jan 20 14:40:56 2005 +0000 +++ b/src/protocols/msn/msn.c Thu Jan 20 16:37:14 2005 +0000 @@ -1076,16 +1076,21 @@ { MsnSession *session; MsnSwitchBoard *swboard; - MsnCmdProc *cmdproc; session = gc->proto_data; swboard = msn_session_find_switch_with_id(session, id); - g_return_if_fail(swboard != NULL); - cmdproc = swboard->servconn->cmdproc; + if (swboard == NULL) + { + /* if we have no switchboard, everyone else left the chat already */ + swboard = msn_switchboard_new(session); + msn_switchboard_request(swboard); + swboard->chat_id = id; + swboard->conv = gaim_find_chat(gc, id); + } - msn_cmdproc_send(cmdproc, "CAL", "%s", who); + msn_switchboard_request_add_user(swboard, who); } static void @@ -1097,11 +1102,12 @@ session = gc->proto_data; swboard = msn_session_find_switch_with_id(session, id); - g_return_if_fail(swboard != NULL); + + /* if swboard is NULL we were the only person left anyway */ + if (swboard == NULL) + return; msn_switchboard_close(swboard); - - /* serv_got_chat_left(gc, id); */ } static int diff -r 8f2b74c5aa24 -r ace8cd0de6ea src/protocols/msn/session.c --- a/src/protocols/msn/session.c Thu Jan 20 14:40:56 2005 +0000 +++ b/src/protocols/msn/session.c Thu Jan 20 16:37:14 2005 +0000 @@ -320,6 +320,7 @@ } msn_session_disconnect(session); + gaim_connection_error(gc, msg); g_free(msg); @@ -373,12 +374,12 @@ GaimAccount *account; GaimConnection *gc; + if (session->logged_in) + return; + account = session->account; gc = gaim_account_get_connection(account); - if (session->logged_in) - return; - msn_user_set_buddy_icon(session->user, gaim_account_get_buddy_icon(session->account)); diff -r 8f2b74c5aa24 -r ace8cd0de6ea src/protocols/msn/switchboard.c --- a/src/protocols/msn/switchboard.c Thu Jan 20 14:40:56 2005 +0000 +++ b/src/protocols/msn/switchboard.c Thu Jan 20 16:37:14 2005 +0000 @@ -227,9 +227,12 @@ GList *l; /* gaim_debug_info("msn", "[chat] Switching to chat.\n"); */ - +#if 0 + /* this is bad - it causes msn_switchboard_close to be called on the + * switchboard we're in the middle of using :( */ if (swboard->conv != NULL) gaim_conversation_destroy(swboard->conv); +#endif cmdproc->session->conv_seq++; swboard->chat_id = cmdproc->session->conv_seq; @@ -314,7 +317,9 @@ gaim_debug_info("msg", "Error: Unable to call the user %s\n", passport); - if (swboard->total_users == 0) + /* TODO: if current_users > 0, this is probably a chat and an invite failed, + * we should report that in the chat or something */ + if (swboard->current_users == 0) { swboard->error = reason; msn_switchboard_close(swboard); @@ -612,10 +617,14 @@ /* This is a helper switchboard */ msn_switchboard_destroy(swboard); } - else if (swboard->current_users > 1) + else if ((swboard->current_users > 1) || + (gaim_conversation_get_type(swboard->conv) == GAIM_CONV_CHAT)) { /* This is a switchboard used for a chat */ gaim_conv_chat_remove_user(GAIM_CONV_CHAT(swboard->conv), user, NULL); + swboard->current_users--; + if (swboard->current_users == 0) + msn_switchboard_destroy(swboard); } else { @@ -836,13 +845,22 @@ body_final = body_enc; } - if (swboard->current_users > 1) + if (swboard->current_users > 1 || + ((swboard->conv != NULL) && + gaim_conversation_get_type(swboard->conv) == GAIM_CONV_CHAT)) { serv_got_chat_in(gc, swboard->chat_id, passport, 0, body_final, time(NULL)); + if (swboard->conv == NULL) + swboard->conv = gaim_find_chat(gc, swboard->chat_id); } else + { serv_got_im(gc, passport, body_final, 0, time(NULL)); + if (swboard->conv == NULL) + swboard->conv = gaim_find_conversation_with_account(GAIM_CONV_IM, + passport, gaim_connection_get_account(gc)); + } g_free(body_final); } @@ -1080,6 +1098,9 @@ { g_return_if_fail(swboard != NULL); + /* forget any conversation that used to be associated with this swboard */ + swboard->conv = NULL; + if (swboard->error != MSN_SB_ERROR_NONE) { msn_switchboard_destroy(swboard); diff -r 8f2b74c5aa24 -r ace8cd0de6ea src/protocols/msn/userlist.c --- a/src/protocols/msn/userlist.c Thu Jan 20 14:40:56 2005 +0000 +++ b/src/protocols/msn/userlist.c Thu Jan 20 16:37:14 2005 +0000 @@ -153,10 +153,25 @@ g_return_val_if_fail(user != NULL, NULL); - if ((store_name = msn_user_get_store_name(user)) != NULL) - return gaim_url_encode(store_name); + store_name = msn_user_get_store_name(user); + + if (store_name != NULL) + store_name = gaim_url_encode(store_name); + else + store_name = msn_user_get_passport(user); - return msn_user_get_passport(user); + /* this might be a bit of a hack, but it should prevent notification server + * disconnections for people who have buddies with insane friendly names + * who added you to their buddy list from being disconnected. Stu. */ + /* Shx: What? Isn't the store_name obtained from the server, and hence it's + * below the BUDDY_ALIAS_MAXLEN ? */ + /* Stu: yeah, that's why it's a bit of a hack, as you pointed out, we're + * probably decoding the incoming store_name wrong, or something. bleh. */ + + if (strlen(store_name) > BUDDY_ALIAS_MAXLEN) + store_name = msn_user_get_passport(user); + + return store_name; } static void @@ -466,7 +481,6 @@ msn_userlist_remove_group(MsnUserList *userlist, MsnGroup *group) { userlist->groups = g_list_remove(userlist->groups, group); - msn_group_destroy(group); } MsnGroup * @@ -553,7 +567,10 @@ group = msn_userlist_find_group_with_id(userlist, group_id); if (group != NULL) + { msn_userlist_remove_group(userlist, group); + msn_group_destroy(group); + } } void @@ -630,13 +647,6 @@ store_name = (user != NULL) ? get_store_name(user) : who; - /* this might be a bit of a hack, but it should prevent notification server - * disconnections for people who have buddies with insane friendly names - * who added you to their buddy list from being disconnected. Stu. */ - /* ... No, that sentence didn't parse for me either. Stu. */ - if (strlen(store_name) > BUDDY_ALIAS_MAXLEN) - store_name = who; - /* Then request the add to the server. */ list = lists[list_id];