# HG changeset patch # User Jeffrey Connelly # Date 1186944483 0 # Node ID c32fcdef2809eeda60f1da4bab61432a13cf55b5 # Parent 6541b0edee26778731bdb2eebb25da5e4ca76182 Only say we are connected after the MsimSession structure is fully setup. (Also change a few debugging statements to help find this bug.) Previously, purple_connection_set_state(..., PURPLE_CONNECTED) was called too early, so that if a client called any msimprpl functions that operated on MsimSession (pretty much all of them) within the signed-on signal handler, the userid etc., would not yet be correct and the call would fail. Now, the call is called at the right time so it works as expected. Closes #2520. diff -r 6541b0edee26 -r c32fcdef2809 libpurple/protocols/myspace/message.c --- a/libpurple/protocols/myspace/message.c Sun Aug 12 18:20:24 2007 +0000 +++ b/libpurple/protocols/myspace/message.c Sun Aug 12 18:48:03 2007 +0000 @@ -425,7 +425,9 @@ return; } +#ifdef MSIM_MSG_DEBUG_FREE msim_msg_dump("msim_msg_free: freeing %s", msg); +#endif g_list_foreach(msg, msim_msg_free_element, NULL); g_list_free(msg); diff -r 6541b0edee26 -r c32fcdef2809 libpurple/protocols/myspace/myspace.c --- a/libpurple/protocols/myspace/myspace.c Sun Aug 12 18:20:24 2007 +0000 +++ b/libpurple/protocols/myspace/myspace.c Sun Aug 12 18:48:03 2007 +0000 @@ -2324,9 +2324,6 @@ g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); g_return_val_if_fail(msg != NULL, FALSE); - purple_connection_update_progress(session->gc, _("Connected"), 3, 4); - purple_connection_set_state(session->gc, PURPLE_CONNECTED); - session->sesskey = msim_msg_get_integer(msg, "sesskey"); purple_debug_info("msim", "SESSKEY=<%d>\n", session->sesskey); @@ -2347,6 +2344,16 @@ * address and not username. Will be freed in msim_session_destroy(). */ session->username = msim_msg_get_string(msg, "uniquenick"); + /* The session is now set up, ready to be connected. This emits the + * signedOn signal, so clients can now do anything with msimprpl, and + * we're ready for it (session key, userid, username all setup). */ + purple_connection_update_progress(session->gc, _("Connected"), 3, 4); + purple_connection_set_state(session->gc, PURPLE_CONNECTED); + + + /* Additional post-connect operations */ + + if (msim_msg_get_integer(msg, "uniquenick") == session->userid) { purple_debug_info("msim_we_are_logged_on", "TODO: pick username"); } @@ -2670,7 +2677,8 @@ g_free(errmsg); - purple_debug_info("msim", "msim_error: %s\n", full_errmsg); + purple_debug_info("msim", "msim_error (sesskey=%d): %s\n", + session->sesskey, full_errmsg); purple_notify_error(session->account, g_strdup(_("MySpaceIM Error")), full_errmsg, NULL); @@ -3154,6 +3162,13 @@ account = purple_connection_get_account(gc); session = gc->proto_data; + /* libpurple/eventloop.h only defines these two */ + if (cond != PURPLE_INPUT_READ && cond != PURPLE_INPUT_WRITE) { + purple_debug_info("msim_input_cb", "unknown condition=%d\n", cond); + purple_connection_error(gc, _("Invalid input condition")); + return; + } + g_return_if_fail(cond == PURPLE_INPUT_READ); g_return_if_fail(MSIM_SESSION_VALID(session));