comparison libpurple/protocols/myspace/myspace.c @ 25172:125cac3e24ee

The Add Buddy dialog should not blindly create a duplicate buddy in a group Fix up a subset of the prpls add_buddy functions to properly handle this situation. * Everything that comes before oscar alphabetically should work properly (except Gadu-Gadu and MSN, which need testing/another set of eyes)
author Paul Aurich <paul@darkrain42.org>
date Sat, 29 Nov 2008 18:46:49 +0000
parents 3a3d36791a47
children 401f548e3544
comparison
equal deleted inserted replaced
24563:5cd0188892f6 25172:125cac3e24ee
1982 purple_debug_info("msim", 1982 purple_debug_info("msim",
1983 "msim_status: making new buddy for %s\n", username); 1983 "msim_status: making new buddy for %s\n", username);
1984 buddy = purple_buddy_new(session->account, username, NULL); 1984 buddy = purple_buddy_new(session->account, username, NULL);
1985 purple_blist_add_buddy(buddy, NULL, NULL, NULL); 1985 purple_blist_add_buddy(buddy, NULL, NULL, NULL);
1986 1986
1987 user = msim_get_user_from_buddy(buddy); 1987 user = msim_get_user_from_buddy(buddy, TRUE);
1988 1988
1989 /* All buddies on list should have a UserID integer associated with them. */ 1989 /* All buddies on list should have a UserID integer associated with them. */
1990 purple_blist_node_set_int(&buddy->node, "UserID", msim_msg_get_integer(msg, "f")); 1990 purple_blist_node_set_int(&buddy->node, "UserID", msim_msg_get_integer(msg, "f"));
1991 1991
1992 msim_store_user_info(session, msg, NULL); 1992 msim_store_user_info(session, msg, NULL);
2080 MsimMessage *msg; 2080 MsimMessage *msg;
2081 MsimMessage *msg_persist; 2081 MsimMessage *msg_persist;
2082 MsimMessage *body; 2082 MsimMessage *body;
2083 2083
2084 session = (MsimSession *)gc->proto_data; 2084 session = (MsimSession *)gc->proto_data;
2085
2086 if (msim_get_user_from_buddy(buddy, FALSE) != NULL)
2087 return;
2088
2085 purple_debug_info("msim", "msim_add_buddy: want to add %s to %s\n", 2089 purple_debug_info("msim", "msim_add_buddy: want to add %s to %s\n",
2086 buddy->name, (group && group->name) ? group->name : "(no group)"); 2090 buddy->name, (group && group->name) ? group->name : "(no group)");
2087 2091
2088 msg = msim_msg_new( 2092 msg = msim_msg_new(
2089 "addbuddy", MSIM_TYPE_BOOLEAN, TRUE, 2093 "addbuddy", MSIM_TYPE_BOOLEAN, TRUE,
2748 MsimUser *user; 2752 MsimUser *user;
2749 const gchar *display_name, *headline; 2753 const gchar *display_name, *headline;
2750 2754
2751 g_return_val_if_fail(buddy != NULL, NULL); 2755 g_return_val_if_fail(buddy != NULL, NULL);
2752 2756
2753 user = msim_get_user_from_buddy(buddy); 2757 user = msim_get_user_from_buddy(buddy, TRUE);
2754 2758
2755 session = (MsimSession *)buddy->account->gc->proto_data; 2759 session = (MsimSession *)buddy->account->gc->proto_data;
2756 g_return_val_if_fail(MSIM_SESSION_VALID(session), NULL); 2760 g_return_val_if_fail(MSIM_SESSION_VALID(session), NULL);
2757 2761
2758 display_name = headline = NULL; 2762 display_name = headline = NULL;
2794 MsimUser *user; 2798 MsimUser *user;
2795 2799
2796 g_return_if_fail(buddy != NULL); 2800 g_return_if_fail(buddy != NULL);
2797 g_return_if_fail(user_info != NULL); 2801 g_return_if_fail(user_info != NULL);
2798 2802
2799 user = msim_get_user_from_buddy(buddy); 2803 user = msim_get_user_from_buddy(buddy, TRUE);
2800 2804
2801 if (PURPLE_BUDDY_IS_ONLINE(buddy)) { 2805 if (PURPLE_BUDDY_IS_ONLINE(buddy)) {
2802 MsimSession *session; 2806 MsimSession *session;
2803 2807
2804 session = (MsimSession *)buddy->account->gc->proto_data; 2808 session = (MsimSession *)buddy->account->gc->proto_data;
2877 2881
2878 /* TODO: use 'Position' in contact_info to take into account where buddy is */ 2882 /* TODO: use 'Position' in contact_info to take into account where buddy is */
2879 purple_blist_add_buddy(buddy, NULL, group, NULL /* insertion point */); 2883 purple_blist_add_buddy(buddy, NULL, group, NULL /* insertion point */);
2880 2884
2881 /* 3. Update buddy information */ 2885 /* 3. Update buddy information */
2882 user = msim_get_user_from_buddy(buddy); 2886 user = msim_get_user_from_buddy(buddy, TRUE);
2883 2887
2884 /* All buddies on list should have 'uid' integer associated with them. */ 2888 /* All buddies on list should have 'uid' integer associated with them. */
2885 purple_blist_node_set_int(&buddy->node, "UserID", uid); 2889 purple_blist_node_set_int(&buddy->node, "UserID", uid);
2886 2890
2887 /* Stores a few fields in the MsimUser, relevant to the buddy itself. 2891 /* Stores a few fields in the MsimUser, relevant to the buddy itself.