# HG changeset patch # User Elliott Sales de Andrade # Date 1218174713 0 # Node ID e8f75e7502601feaff5db9a40a2e1a9c3a4239c6 # Parent 7eeb81cbbcae9dcb93f947f0af3da9ff5cf10c4b# Parent 8ba3d69052521372557088bc65ef01310c9f5e36 merge of '521d7478a48ec5109a78fb66eab6ad7ced97c34a' and 'e661636ba7f9069593cfee6ad1c4f3a7a527118a' diff -r 7eeb81cbbcae -r e8f75e750260 libpurple/protocols/msn/msn.c --- a/libpurple/protocols/msn/msn.c Thu Aug 07 19:47:23 2008 +0000 +++ b/libpurple/protocols/msn/msn.c Fri Aug 08 05:51:53 2008 +0000 @@ -490,23 +490,19 @@ void msn_send_privacy(PurpleConnection *gc) { - PurpleAccount *account; - MsnSession *session; - MsnCmdProc *cmdproc; - - account = purple_connection_get_account(gc); - session = gc->proto_data; - cmdproc = session->notification->cmdproc; - - if (account->perm_deny == PURPLE_PRIVACY_ALLOW_ALL || - account->perm_deny == PURPLE_PRIVACY_DENY_USERS) - { - msn_cmdproc_send(cmdproc, "BLP", "%s", "AL"); - } - else - { - msn_cmdproc_send(cmdproc, "BLP", "%s", "BL"); - } + PurpleAccount *account; + MsnSession *session; + MsnCmdProc *cmdproc; + + account = purple_connection_get_account(gc); + session = gc->proto_data; + cmdproc = session->notification->cmdproc; + + if (account->perm_deny == PURPLE_PRIVACY_ALLOW_ALL || + account->perm_deny == PURPLE_PRIVACY_DENY_USERS) + msn_cmdproc_send(cmdproc, "BLP", "%s", "AL"); + else + msn_cmdproc_send(cmdproc, "BLP", "%s", "BL"); } static void @@ -518,6 +514,8 @@ MsnSession *session; MsnSwitchBoard *swboard; + const char *alias; + g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node)); buddy = (PurpleBuddy *) node; @@ -534,8 +532,13 @@ swboard->conv = serv_got_joined_chat(gc, swboard->chat_id, "MSN Chat"); swboard->flag = MSN_SB_FLAG_IM; + /* Local alias > Display name > Username */ + if ((alias = purple_account_get_alias(buddy->account)) == NULL) + if ((alias = purple_connection_get_display_name(gc)) == NULL) + alias = purple_account_get_username(buddy->account); + purple_conv_chat_add_user(PURPLE_CONV_CHAT(swboard->conv), - purple_account_get_username(buddy->account), NULL, PURPLE_CBFLAGS_NONE, TRUE); + alias, NULL, PURPLE_CBFLAGS_NONE, TRUE); } static void @@ -955,7 +958,7 @@ if (!purple_ssl_is_supported()) { - purple_connection_error_reason (gc, + purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NO_SSL_SUPPORT, _("SSL support is needed for MSN. Please install a supported " "SSL library.")); @@ -986,7 +989,7 @@ purple_account_set_username(account, username); if (!msn_session_connect(session, host, port, http_method)) - purple_connection_error_reason (gc, + purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _("Failed to connect to server.")); } @@ -1119,7 +1122,7 @@ char *msgtext; const char *username; - purple_debug_info("msn", "send IM {%s} to %s\n",message,who); + purple_debug_info("msn", "send IM {%s} to %s\n", message, who); account = purple_connection_get_account(gc); username = purple_account_get_username(account); @@ -1137,9 +1140,9 @@ } msn_import_html(message, &msgformat, &msgtext); - if (msn_user_is_online(account, who)|| + if (msn_user_is_online(account, who) || msn_user_is_yahoo(account, who) || - swboard != NULL){ + swboard != NULL) { /*User online or have a swboard open because it's invisible * and sent us a message,then send Online Instant Message*/ @@ -1165,11 +1168,11 @@ GSList *smileys; GString *emoticons = NULL; - if(msn_user_is_yahoo(account,who)){ + if (msn_user_is_yahoo(account, who)) { /*we send the online and offline Message to Yahoo User via UBM*/ purple_debug_info("msn", "send to Yahoo User\n"); - uum_send_msg(session,msg); - }else{ + uum_send_msg(session, msg); + } else { purple_debug_info("msn", "send via switchboard\n"); swboard = msn_session_get_swboard(session, who, MSN_SB_FLAG_IM); smileys = msn_msg_grab_emoticons(message, username); @@ -1817,7 +1820,7 @@ { p += strlen(PHOTO_URL); } - if (p && (strncmp(p, "http://",strlen("http://")) == 0) && ((q = strchr(p, '"')) != NULL)) + if (p && (strncmp(p, "http://", strlen("http://")) == 0) && ((q = strchr(p, '"')) != NULL)) return g_strndup(p, q - p); return NULL; diff -r 7eeb81cbbcae -r e8f75e750260 libpurple/protocols/msn/notification.c --- a/libpurple/protocols/msn/notification.c Thu Aug 07 19:47:23 2008 +0000 +++ b/libpurple/protocols/msn/notification.c Fri Aug 08 05:51:53 2008 +0000 @@ -1288,7 +1288,7 @@ const char *rru; const char *url; PurpleCipherContext *cipher; - gchar digest[33]; + gchar creds[33]; char *buf; gulong tmp_timestamp; @@ -1304,26 +1304,26 @@ tmp_timestamp = session->passport_info.mail_timestamp - session->passport_info.sl; buf = g_strdup_printf("%s%lu%s", - session->passport_info.mspauth ? session->passport_info.mspauth : "BOGUS", - tmp_timestamp, - purple_connection_get_password(gc)); + session->passport_info.mspauth ? session->passport_info.mspauth : "BOGUS", + tmp_timestamp, + purple_connection_get_password(gc)); cipher = purple_cipher_context_new_by_name("md5", NULL); purple_cipher_context_append(cipher, (const guchar *)buf, strlen(buf)); - purple_cipher_context_digest_to_str(cipher, sizeof(digest), digest, NULL); + purple_cipher_context_digest_to_str(cipher, sizeof(creds), creds, NULL); purple_cipher_context_destroy(cipher); - g_free(buf); g_free(session->passport_info.mail_url); - session->passport_info.mail_url = g_strdup_printf("%s&auth=%s&creds=%s&sl=%ld&username=%s&mode=ttl&sid=%s&id=2&rru=%ssvc_mail&js=yes", - url, - session->passport_info.mspauth ? session->passport_info.mspauth : "BOGUS", - buf, - tmp_timestamp, - msn_user_get_passport(session->user), - session->passport_info.sid, - rru); + session->passport_info.mail_url = + g_strdup_printf("%s&auth=%s&creds=%s&sl=%ld&username=%s&mode=ttl&sid=%s&id=2&rru=%s&svc=mail&js=yes", + url, + session->passport_info.mspauth ? purple_url_encode(session->passport_info.mspauth) : "BOGUS", + creds, + tmp_timestamp, + msn_user_get_passport(session->user), + session->passport_info.sid, + rru); /* The user wants to check his or her email */ if (cmd->trans && cmd->trans->data) diff -r 7eeb81cbbcae -r e8f75e750260 libpurple/protocols/msn/oim.c --- a/libpurple/protocols/msn/oim.c Thu Aug 07 19:47:23 2008 +0000 +++ b/libpurple/protocols/msn/oim.c Fri Aug 08 05:51:53 2008 +0000 @@ -42,14 +42,9 @@ /*Local Function Prototype*/ static void msn_parse_oim_xml(MsnOim *oim, xmlnode *node); -static void msn_oim_post_single_get_msg(MsnOim *oim, char *msgid); -static MsnOimSendReq *msn_oim_new_send_req(const char *from_member, - const char *friendname, - const char* to_member, - const char *msg); static void msn_oim_free_send_req(MsnOimSendReq *req); -static void msn_oim_report_to_user(MsnOimRecvData *rdata, const char *msg_str); -static char *msn_oim_msg_to_str(MsnOim *oim, const char *body); +static void msn_oim_recv_data_free(MsnOimRecvData *data); +static void msn_oim_post_single_get_msg(MsnOim *oim, MsnOimRecvData *data); /*new a OIM object*/ MsnOim * @@ -77,12 +72,12 @@ g_free(oim->run_id); g_free(oim->challenge); - while((request = g_queue_pop_head(oim->send_queue)) != NULL){ + while ((request = g_queue_pop_head(oim->send_queue)) != NULL) msn_oim_free_send_req(request); - } + g_queue_free(oim->send_queue); - g_queue_free(oim->send_queue); - g_list_free(oim->oim_list); + while (oim->oim_list != NULL) + msn_oim_recv_data_free((MsnOimRecvData *)oim->oim_list->data); g_free(oim); } @@ -114,6 +109,36 @@ g_free(req); } +static MsnOimRecvData * +msn_oim_recv_data_new(MsnOim *oim, char *msg_id) +{ + MsnOimRecvData *data; + + data = g_new0(MsnOimRecvData, 1); + data->oim = oim; + data->msg_id = msg_id; + + oim->oim_list = g_list_append(oim->oim_list, data); + + return data; +} + +/* Probably only good for g_list_find_custom */ +static gint +msn_recv_data_equal(MsnOimRecvData *a, const char *msg_id) +{ + return strcmp(a->msg_id, msg_id); +} + +static void +msn_oim_recv_data_free(MsnOimRecvData *data) +{ + data->oim->oim_list = g_list_remove(data->oim->oim_list, data); + g_free(data->msg_id); + + g_free(data); +} + /**************************************** * Manage OIM Tokens ****************************************/ @@ -465,16 +490,12 @@ { MsnOimRecvData *rdata = data; - if (response && xmlnode_get_child(response->xml, "Body/Fault") == NULL) { + if (response && xmlnode_get_child(response->xml, "Body/Fault") == NULL) purple_debug_info("msn", "Delete OIM success\n"); - rdata->oim->oim_list = g_list_remove(rdata->oim->oim_list, - rdata->msg_id); - g_free(rdata->msg_id); - } else { + else purple_debug_info("msn", "Delete OIM failed\n"); - } - g_free(rdata); + msn_oim_recv_data_free(rdata); } /*Post to get the Offline Instant Message*/ @@ -645,10 +666,13 @@ char *str = xmlnode_to_str(response->xml, NULL); purple_debug_info("msn", "Unknown OIM response: %s\n", str); g_free(str); + msn_oim_recv_data_free(rdata); } } else { purple_debug_info("msn", "Failed to get OIM\n"); + msn_oim_recv_data_free(rdata); } + } /* parse the oim XML data @@ -723,9 +747,9 @@ } /* purple_debug_info("msn", "E:{%s},I:{%s},rTime:{%s}\n",passport,msgid,rTime); */ - if (!g_list_find_custom(oim->oim_list, msgid, (GCompareFunc)strcmp)) { - oim->oim_list = g_list_append(oim->oim_list, msgid); - msn_oim_post_single_get_msg(oim, msgid); + if (!g_list_find_custom(oim->oim_list, msgid, (GCompareFunc)msn_recv_data_equal)) { + MsnOimRecvData *data = msn_oim_recv_data_new(oim, msgid); + msn_oim_post_single_get_msg(oim, data); msgid = NULL; } @@ -738,17 +762,13 @@ /*Post to get the Offline Instant Message*/ static void -msn_oim_post_single_get_msg(MsnOim *oim, char *msgid) +msn_oim_post_single_get_msg(MsnOim *oim, MsnOimRecvData *data) { char *soap_body; - MsnOimRecvData *data = g_new0(MsnOimRecvData, 1); purple_debug_info("msn", "Get single OIM Message\n"); - data->oim = oim; - data->msg_id = msgid; - - soap_body = g_strdup_printf(MSN_OIM_GET_TEMPLATE, msgid); + soap_body = g_strdup_printf(MSN_OIM_GET_TEMPLATE, data->msg_id); msn_oim_make_request(oim, FALSE, MSN_OIM_GET_SOAP_ACTION, MSN_OIM_RETRIEVE_HOST, MSN_OIM_RETRIEVE_URL, xmlnode_from_str(soap_body, -1), msn_oim_get_read_cb, @@ -756,3 +776,4 @@ g_free(soap_body); } + diff -r 7eeb81cbbcae -r e8f75e750260 libpurple/protocols/msn/session.c --- a/libpurple/protocols/msn/session.c Thu Aug 07 19:47:23 2008 +0000 +++ b/libpurple/protocols/msn/session.c Fri Aug 08 05:51:53 2008 +0000 @@ -57,17 +57,35 @@ session->destroying = TRUE; - if (session->connected) - msn_session_disconnect(session); + if (session->soap_cleanup_handle) + purple_timeout_remove(session->soap_cleanup_handle); + + if (session->soap_table != NULL) + g_hash_table_destroy(session->soap_table); + + while (session->slplinks != NULL) + msn_slplink_destroy(session->slplinks->data); + + while (session->switches != NULL) + msn_switchboard_destroy(session->switches->data); + + if (session->sync != NULL) + msn_sync_destroy(session->sync); + + if (session->oim != NULL) + msn_oim_destroy(session->oim); + + if (session->nexus != NULL) + msn_nexus_destroy(session->nexus); + + if (session->user != NULL) + msn_user_destroy(session->user); if (session->notification != NULL) msn_notification_destroy(session->notification); - while (session->switches != NULL) - msn_switchboard_destroy(session->switches->data); - - while (session->slplinks != NULL) - msn_slplink_destroy(session->slplinks->data); + if (session->connected) + msn_session_disconnect(session); msn_userlist_destroy(session->userlist); @@ -79,27 +97,8 @@ g_free(session->passport_info.sid); g_free(session->passport_info.mspauth); g_free(session->passport_info.client_ip); - g_free(session->passport_info.mail_url); - if (session->sync != NULL) - msn_sync_destroy(session->sync); - - if (session->nexus != NULL) - msn_nexus_destroy(session->nexus); - - if (session->oim != NULL) - msn_oim_destroy(session->oim); - - if (session->user != NULL) - msn_user_destroy(session->user); - - if (session->soap_table != NULL) - g_hash_table_destroy(session->soap_table); - - if (session->soap_cleanup_handle) - purple_timeout_remove(session->soap_cleanup_handle); - g_free(session); } @@ -343,6 +342,9 @@ PurpleConnectionError reason; char *msg; + if (session->destroying) + return; + gc = purple_account_get_connection(session->account); switch (error) diff -r 7eeb81cbbcae -r e8f75e750260 libpurple/protocols/msn/slp.c --- a/libpurple/protocols/msn/slp.c Thu Aug 07 19:47:23 2008 +0000 +++ b/libpurple/protocols/msn/slp.c Fri Aug 08 05:51:53 2008 +0000 @@ -814,6 +814,9 @@ if (!purple_account_get_bool(session->account, "custom_smileys", TRUE)) return; + swboard = cmdproc->data; + conv = swboard->conv; + body = msn_message_get_bin_data(msg, &body_len); body_str = g_strndup(body, body_len); @@ -838,10 +841,7 @@ sha1 = msn_object_get_sha1(obj); slplink = msn_session_get_slplink(session, who); - - swboard = cmdproc->data; slplink->swboard = swboard; - conv = swboard->conv; /* If the conversation doesn't exist then this is a custom smiley * used in the first message in a MSN conversation: we need to create diff -r 7eeb81cbbcae -r e8f75e750260 libpurple/protocols/msn/slpcall.c --- a/libpurple/protocols/msn/slpcall.c Thu Aug 07 19:47:23 2008 +0000 +++ b/libpurple/protocols/msn/slpcall.c Fri Aug 08 05:51:53 2008 +0000 @@ -70,10 +70,6 @@ if (slpcall->timer) purple_timeout_remove(slpcall->timer); - g_free(slpcall->id); - g_free(slpcall->branch); - g_free(slpcall->data_info); - for (e = slpcall->slplink->slp_msgs; e != NULL; ) { MsnSlpMessage *slpmsg = e->data; @@ -102,6 +98,10 @@ purple_xfer_unref(slpcall->xfer); } + g_free(slpcall->id); + g_free(slpcall->branch); + g_free(slpcall->data_info); + g_free(slpcall); } diff -r 7eeb81cbbcae -r e8f75e750260 libpurple/protocols/msn/slplink.c --- a/libpurple/protocols/msn/slplink.c Thu Aug 07 19:47:23 2008 +0000 +++ b/libpurple/protocols/msn/slplink.c Fri Aug 08 05:51:53 2008 +0000 @@ -101,9 +101,6 @@ session = slplink->session; - g_free(slplink->local_user); - g_free(slplink->remote_user); - #if 0 if (slplink->directconn != NULL) msn_directconn_destroy(slplink->directconn); @@ -117,6 +114,9 @@ session->slplinks = g_list_remove(session->slplinks, slplink); + g_free(slplink->local_user); + g_free(slplink->remote_user); + g_free(slplink); }