# HG changeset patch # User masca@cpw.pidgin.im # Date 1274904065 0 # Node ID 1ba9f3167de088f2626c6255e41a532a2c81800e # Parent 2bc54dfae6271c0e8bd3b5012f242df14d03e497# Parent 7fa07adbe482e57531f89df51d1e3c2fd93a45ca propagate from branch 'im.pidgin.cpw.qulogic.msnp16' (head 6f45ed65a9417053e242214f5c2bc51028f8e01f) to branch 'im.pidgin.soc.2010.msn-tlc' (head a95c8c315e1110ef7d9ee619ddf3ab101bf7fa08) diff -r 2bc54dfae627 -r 1ba9f3167de0 libpurple/protocols/msn/contact.c --- a/libpurple/protocols/msn/contact.c Wed May 26 19:47:56 2010 +0000 +++ b/libpurple/protocols/msn/contact.c Wed May 26 20:01:05 2010 +0000 @@ -30,6 +30,7 @@ #include "group.h" #include "soap.h" #include "nexus.h" +#include "user.h" const char *MsnSoapPartnerScenarioText[] = { @@ -1167,7 +1168,7 @@ msn_userlist_add_buddy_to_list(userlist, state->who, MSN_LIST_AL); msn_userlist_add_buddy_to_list(userlist, state->who, MSN_LIST_FL); - if (msn_userlist_user_is_in_list(user, MSN_LIST_PL)) { + if (msn_user_is_in_list(user, MSN_LIST_PL)) { msn_del_contact_from_list(state->session, NULL, state->who, MSN_LIST_PL); return; } diff -r 2bc54dfae627 -r 1ba9f3167de0 libpurple/protocols/msn/msg.c --- a/libpurple/protocols/msn/msg.c Wed May 26 19:47:56 2010 +0000 +++ b/libpurple/protocols/msn/msg.c Wed May 26 20:01:05 2010 +0000 @@ -883,8 +883,9 @@ swboard->flag |= MSN_SB_FLAG_IM; } } - else + else if (!g_str_equal(passport, purple_account_get_username(gc->account))) { + /* Don't im ourselves ... */ serv_got_im(gc, passport, body_final, 0, time(NULL)); if (swboard->conv == NULL) { diff -r 2bc54dfae627 -r 1ba9f3167de0 libpurple/protocols/msn/switchboard.c --- a/libpurple/protocols/msn/switchboard.c Wed May 26 19:47:56 2010 +0000 +++ b/libpurple/protocols/msn/switchboard.c Wed May 26 20:01:05 2010 +0000 @@ -25,6 +25,7 @@ #include "prefs.h" #include "switchboard.h" #include "notification.h" +#include "userlist.h" #include "msnutils.h" #include "error.h" @@ -123,7 +124,6 @@ g_free(swboard->session_id); for (; swboard->users; swboard->users = g_list_delete_link(swboard->users, swboard->users)) - g_free(swboard->users->data); session = swboard->session; session->switches = g_list_remove(session->switches, swboard); @@ -226,11 +226,23 @@ msn_message_destroy(msg); } +static int +user_passport_cmp(MsnUser *user, const char *passport) +{ + const char *pass; + + pass = msn_user_get_passport(user); + + return strcmp(pass, passport); +} + static void msn_switchboard_add_user(MsnSwitchBoard *swboard, const char *user) { MsnCmdProc *cmdproc; PurpleAccount *account; + MsnUserList *userlist; + MsnUser *msnuser; char *semicolon; char *passport; @@ -246,8 +258,14 @@ else passport = g_strdup(user); + userlist = swboard->session->userlist; + msnuser = msn_userlist_find_user(userlist, passport); + + if (!msnuser) + purple_debug_error("msn","User %s is not on our list.\n", passport); + /* Don't add multiple endpoints to the conversation. */ - if (g_list_find_custom(swboard->users, passport, (GCompareFunc)strcmp)) { + if (g_list_find_custom(swboard->users, passport, (GCompareFunc)user_passport_cmp)) { g_free(passport); return; } @@ -257,8 +275,10 @@ g_free(passport); return; } + + g_free(passport); - swboard->users = g_list_prepend(swboard->users, passport); + swboard->users = g_list_prepend(swboard->users, msnuser); swboard->current_users++; swboard->empty = FALSE; @@ -276,7 +296,7 @@ if ((swboard->conv != NULL) && (purple_conversation_get_type(swboard->conv) == PURPLE_CONV_TYPE_CHAT)) { - purple_conv_chat_add_user(PURPLE_CONV_CHAT(swboard->conv), user, NULL, + purple_conv_chat_add_user(PURPLE_CONV_CHAT(swboard->conv), msnuser->passport, NULL, PURPLE_CBFLAGS_NONE, TRUE); msn_servconn_set_idle_timeout(swboard->servconn, 0); } @@ -304,8 +324,9 @@ for (l = swboard->users; l != NULL; l = l->next) { const char *tmp_user; + user = l->data; - tmp_user = l->data; + tmp_user = msnuser->passport; purple_conv_chat_add_user(PURPLE_CONV_CHAT(swboard->conv), tmp_user, NULL, PURPLE_CBFLAGS_NONE, TRUE); @@ -322,7 +343,7 @@ else if (swboard->conv == NULL) { swboard->conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, - user, account); + msnuser->passport, account); } else { diff -r 2bc54dfae627 -r 1ba9f3167de0 libpurple/protocols/msn/user.c --- a/libpurple/protocols/msn/user.c Wed May 26 19:47:56 2010 +0000 +++ b/libpurple/protocols/msn/user.c Wed May 26 20:01:05 2010 +0000 @@ -632,3 +632,29 @@ return (user->clientid & capability) && (user->extcaps & extcap); } + +/************************************************************************** + * Utility functions + **************************************************************************/ + +gboolean +msn_user_is_in_group(MsnUser *user, const char * group_id) +{ + if (user == NULL) + return FALSE; + + if (group_id == NULL) + return FALSE; + + return (g_list_find_custom(user->group_ids, group_id, (GCompareFunc)strcmp)) != NULL; +} + +gboolean +msn_user_is_in_list(MsnUser *user, MsnListId list_id) +{ + if (user == NULL) + return FALSE; + + return (user->list_op & (1 << list_id)); +} + diff -r 2bc54dfae627 -r 1ba9f3167de0 libpurple/protocols/msn/user.h --- a/libpurple/protocols/msn/user.h Wed May 26 19:47:56 2010 +0000 +++ b/libpurple/protocols/msn/user.h Wed May 26 20:01:05 2010 +0000 @@ -406,6 +406,30 @@ */ guint msn_user_get_extcaps(const MsnUser *user); +/************************************************************************** + * Utility functions + **************************************************************************/ + + +/** + * Check if the user is part of the group. + * + * @param user The user we are asking group membership. + * @param group_id The group where the user may be in. + * + * @return TRUE if user is part of the group. Otherwise, FALSE. + */ +gboolean msn_user_is_in_group(MsnUser *user, const char * group_id); + +/** + * Check if user is on list. + * + * @param user The user we are asking list membership. + * @param list_id The list where the user may be in. + * + * @return TRUE if the user is on the list, else FALSE. + */ +gboolean msn_user_is_in_list(MsnUser *user, MsnListId list_id); /** * Returns the network id for a user. * diff -r 2bc54dfae627 -r 1ba9f3167de0 libpurple/protocols/msn/userlist.c --- a/libpurple/protocols/msn/userlist.c Wed May 26 19:47:56 2010 +0000 +++ b/libpurple/protocols/msn/userlist.c Wed May 26 20:01:05 2010 +0000 @@ -107,31 +107,6 @@ } /************************************************************************** - * Utility functions - **************************************************************************/ - -gboolean -msn_userlist_user_is_in_group(MsnUser *user, const char * group_id) -{ - if (user == NULL) - return FALSE; - - if (group_id == NULL) - return FALSE; - - return (g_list_find_custom(user->group_ids, group_id, (GCompareFunc)strcmp)) != NULL; -} - -gboolean -msn_userlist_user_is_in_list(MsnUser *user, MsnListId list_id) -{ - if (user == NULL) - return FALSE; - - return (user->list_op & (1 << list_id)); -} - -/************************************************************************** * Server functions **************************************************************************/ @@ -503,7 +478,7 @@ g_return_if_fail(user != NULL); - if ( !msn_userlist_user_is_in_list(user, list_id)) { + if ( !msn_user_is_in_list(user, list_id)) { list = lists[list_id]; purple_debug_info("msn", "User %s is not in list %s, not removing.\n", who, list); return; @@ -569,13 +544,13 @@ user = msn_userlist_find_add_user(userlist, who, who); - if ( msn_userlist_user_is_in_list(user, MSN_LIST_FL) ) { + if ( msn_user_is_in_list(user, MSN_LIST_FL) ) { purple_debug_info("msn", "User %s already exists\n", who); msn_userlist_rem_buddy_from_list(userlist, who, MSN_LIST_BL); - if (msn_userlist_user_is_in_group(user, group_id)) { + if (msn_user_is_in_group(user, group_id)) { purple_debug_info("msn", "User %s is already in group %s, returning\n", who, new_group_name); msn_callback_state_free(state); return; @@ -604,7 +579,7 @@ user = msn_userlist_find_add_user(userlist, who, who); /* First we're going to check if it's already there. */ - if (msn_userlist_user_is_in_list(user, list_id)) + if (msn_user_is_in_list(user, list_id)) { list = lists[list_id]; purple_debug_info("msn", "User '%s' is already in list: %s\n", who, list); diff -r 2bc54dfae627 -r 1ba9f3167de0 libpurple/protocols/msn/userlist.h --- a/libpurple/protocols/msn/userlist.h Wed May 26 19:47:56 2010 +0000 +++ b/libpurple/protocols/msn/userlist.h Wed May 26 20:01:05 2010 +0000 @@ -52,9 +52,6 @@ }; -gboolean msn_userlist_user_is_in_group(MsnUser *user, const char * group_id); -gboolean msn_userlist_user_is_in_list(MsnUser *user, MsnListId list_id); - void msn_got_lst_user(MsnSession *session, MsnUser *user, MsnListOp list_op, GSList *group_ids);