Mercurial > pidgin
changeset 25243:ae544623840b
propagate from branch 'im.pidgin.pidgin' (head f018e11a7ea08e07f22667e6daca2ec7e64f9710)
to branch 'org.darkrain42.pidgin.buddy-add' (head e4fae922272cfd510a1f55595c374c2b9f665767)
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Fri, 02 Jan 2009 19:27:02 +0000 |
parents | 6eecd6ba2862 (diff) b26e8a41a937 (current diff) |
children | 300cf4e16720 |
files | libpurple/protocols/myspace/myspace.c libpurple/protocols/myspace/user.c libpurple/protocols/myspace/user.h pidgin/gtkblist.c |
diffstat | 11 files changed, 92 insertions(+), 38 deletions(-) [+] |
line wrap: on
line diff
--- a/finch/gntblist.c Fri Jan 02 07:43:30 2009 +0000 +++ b/finch/gntblist.c Fri Jan 02 19:27:02 2009 +0000 @@ -643,10 +643,14 @@ purple_blist_add_group(grp, NULL); } - /* XXX: Ask if there's already the same buddy in the same group (#4553) */ - - buddy = purple_buddy_new(account, username, alias); - purple_blist_add_buddy(buddy, NULL, grp, NULL); + /* XXX: Ask to merge if there's already a buddy with the same alias in the same group (#4553) */ + + if ((buddy = purple_find_buddy_in_group(account, username, grp)) == NULL) + { + buddy = purple_buddy_new(account, username, alias); + purple_blist_add_buddy(buddy, NULL, grp, NULL); + } + purple_account_add_buddy(account, buddy); }
--- a/libpurple/protocols/irc/irc.c Fri Jan 02 07:43:30 2009 +0000 +++ b/libpurple/protocols/irc/irc.c Fri Jan 02 19:27:02 2009 +0000 @@ -565,7 +565,7 @@ struct irc_conn *irc = (struct irc_conn *)gc->proto_data; struct irc_buddy *ib = g_new0(struct irc_buddy, 1); ib->name = g_strdup(buddy->name); - g_hash_table_insert(irc->buddies, ib->name, ib); + g_hash_table_replace(irc->buddies, ib->name, ib); /* if the timer isn't set, this is during signon, so we don't want to flood * ourself off with ISON's, so we don't, but after that we want to know when
--- a/libpurple/protocols/myspace/myspace.c Fri Jan 02 07:43:30 2009 +0000 +++ b/libpurple/protocols/myspace/myspace.c Fri Jan 02 19:27:02 2009 +0000 @@ -386,7 +386,7 @@ g_return_val_if_fail(buddy != NULL, NULL); - user = msim_get_user_from_buddy(buddy); + user = msim_get_user_from_buddy(buddy, TRUE); session = (MsimSession *)buddy->account->gc->proto_data; g_return_val_if_fail(MSIM_SESSION_VALID(session), NULL); @@ -431,7 +431,7 @@ g_return_if_fail(buddy != NULL); g_return_if_fail(user_info != NULL); - user = msim_get_user_from_buddy(buddy); + user = msim_get_user_from_buddy(buddy, TRUE); if (PURPLE_BUDDY_IS_ONLINE(buddy)) { MsimSession *session; @@ -1039,7 +1039,7 @@ g_free(display_name); /* 3. Update buddy information */ - user = msim_get_user_from_buddy(buddy); + user = msim_get_user_from_buddy(buddy, TRUE); user->id = uid; /* Keep track of the user ID across sessions */ @@ -1365,7 +1365,7 @@ buddy = purple_buddy_new(session->account, username, NULL); purple_blist_add_buddy(buddy, NULL, NULL, NULL); - user = msim_get_user_from_buddy(buddy); + user = msim_get_user_from_buddy(buddy, TRUE); user->id = msim_msg_get_integer(msg, "f"); /* Keep track of the user ID across sessions */ @@ -2625,6 +2625,10 @@ MsimMessage *body; session = (MsimSession *)gc->proto_data; + + if (msim_get_user_from_buddy(buddy, FALSE) != NULL) + return; + purple_debug_info("msim", "msim_add_buddy: want to add %s to %s\n", buddy->name, (group && group->name) ? group->name : "(no group)");
--- a/libpurple/protocols/myspace/user.c Fri Jan 02 07:43:30 2009 +0000 +++ b/libpurple/protocols/myspace/user.c Fri Jan 02 19:27:02 2009 +0000 @@ -41,10 +41,10 @@ } /** - * Get the MsimUser from a PurpleBuddy, creating it if needed. + * Get the MsimUser from a PurpleBuddy, optionally creating it if needed. */ MsimUser * -msim_get_user_from_buddy(PurpleBuddy *buddy) +msim_get_user_from_buddy(PurpleBuddy *buddy, gboolean create) { MsimUser *user; @@ -52,17 +52,17 @@ return NULL; } - if (!buddy->proto_data) { + if (create && !buddy->proto_data) { /* No MsimUser for this buddy; make one. */ user = g_new0(MsimUser, 1); user->buddy = buddy; user->id = purple_blist_node_get_int((PurpleBlistNode*)buddy, "UserID"); buddy->proto_data = (gpointer)user; + } else { + user = (MsimUser *)(buddy->proto_data); } - user = (MsimUser *)(buddy->proto_data); - return user; } @@ -97,7 +97,7 @@ return NULL; } - user = msim_get_user_from_buddy(buddy); + user = msim_get_user_from_buddy(buddy, TRUE); return user; }
--- a/libpurple/protocols/novell/novell.c Fri Jan 02 07:43:30 2009 +0000 +++ b/libpurple/protocols/novell/novell.c Fri Jan 02 19:27:02 2009 +0000 @@ -2553,6 +2553,10 @@ if (!user->clist_synched) return; + /* Don't re-add a buddy that is already on our contact list */ + if (nm_find_user_record(user, buddy->name) != NULL) + return; + contact = nm_create_contact(); nm_contact_set_dn(contact, buddy->name);
--- a/libpurple/protocols/oscar/oscar.c Fri Jan 02 07:43:30 2009 +0000 +++ b/libpurple/protocols/oscar/oscar.c Fri Jan 02 19:27:02 2009 +0000 @@ -4814,19 +4814,26 @@ return; } - if ((od->ssi.received_data) && !(aim_ssi_itemlist_finditem(od->ssi.local, group->name, buddy->name, AIM_SSI_TYPE_BUDDY))) { - purple_debug_info("oscar", - "ssi: adding buddy %s to group %s\n", buddy->name, group->name); - aim_ssi_addbuddy(od, buddy->name, group->name, NULL, purple_buddy_get_alias_only(buddy), NULL, NULL, 0); - - /* Mobile users should always be online */ - if (buddy->name[0] == '+') { - purple_prpl_got_user_status(account, - purple_buddy_get_name(buddy), - OSCAR_STATUS_ID_AVAILABLE, NULL); - purple_prpl_got_user_status(account, - purple_buddy_get_name(buddy), - OSCAR_STATUS_ID_MOBILE, NULL); + if (od->ssi.received_data) { + if (!aim_ssi_itemlist_finditem(od->ssi.local, group->name, buddy->name, AIM_SSI_TYPE_BUDDY)) { + purple_debug_info("oscar", + "ssi: adding buddy %s to group %s\n", buddy->name, group->name); + aim_ssi_addbuddy(od, buddy->name, group->name, NULL, purple_buddy_get_alias_only(buddy), NULL, NULL, 0); + + /* Mobile users should always be online */ + if (buddy->name[0] == '+') { + purple_prpl_got_user_status(account, + purple_buddy_get_name(buddy), + OSCAR_STATUS_ID_AVAILABLE, NULL); + purple_prpl_got_user_status(account, + purple_buddy_get_name(buddy), + OSCAR_STATUS_ID_MOBILE, NULL); + } + } else if (aim_ssi_waitingforauth(od->ssi.local, + aim_ssi_itemlist_findparentname(od->ssi.local, purple_buddy_get_name(buddy)), + purple_buddy_get_name(buddy))) { + /* Not authorized -- Re-request authorization */ + purple_auth_sendrequest(gc, purple_buddy_get_name(buddy)); } }
--- a/libpurple/protocols/silc/buddy.c Fri Jan 02 07:43:30 2009 +0000 +++ b/libpurple/protocols/silc/buddy.c Fri Jan 02 19:27:02 2009 +0000 @@ -1390,7 +1390,12 @@ void silcpurple_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) { - silcpurple_add_buddy_i(gc, buddy, FALSE); + /* Don't add if the buddy is already on the list. + * + * SILC doesn't have groups, so we also don't need to do anything + * for a move. */ + if (buddy->proto_data == NULL) + silcpurple_add_buddy_i(gc, buddy, FALSE); } void silcpurple_send_buddylist(PurpleConnection *gc)
--- a/libpurple/protocols/silc10/buddy.c Fri Jan 02 07:43:30 2009 +0000 +++ b/libpurple/protocols/silc10/buddy.c Fri Jan 02 19:27:02 2009 +0000 @@ -1390,7 +1390,12 @@ void silcpurple_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) { - silcpurple_add_buddy_i(gc, buddy, FALSE); + /* Don't add if the buddy is already on the list. + * + * SILC doesn't have groups, so we don't need to do anything + * for a move. */ + if (buddy->proto_data == NULL) + silcpurple_add_buddy_i(gc, buddy, FALSE); } void silcpurple_send_buddylist(PurpleConnection *gc)
--- a/libpurple/prpl.h Fri Jan 02 07:43:30 2009 +0000 +++ b/libpurple/prpl.h Fri Jan 02 19:27:02 2009 +0000 @@ -294,6 +294,14 @@ void (*set_idle)(PurpleConnection *, int idletime); void (*change_passwd)(PurpleConnection *, const char *old_pass, const char *new_pass); + /** + * Add a buddy to a group on the server. + * + * This PRPL function may be called in situations in which the buddy is + * already in the specified group. If the protocol supports + * authorization and the user is not already authorized to see the + * status of \a buddy, \a add_buddy should request authorization. + */ void (*add_buddy)(PurpleConnection *, PurpleBuddy *buddy, PurpleGroup *group); void (*add_buddies)(PurpleConnection *, GList *buddies, GList *groups); void (*remove_buddy)(PurpleConnection *, PurpleBuddy *buddy, PurpleGroup *group);
--- a/pidgin/gtkblist.c Fri Jan 02 07:43:30 2009 +0000 +++ b/pidgin/gtkblist.c Fri Jan 02 19:27:02 2009 +0000 @@ -6504,14 +6504,27 @@ whoalias = NULL; g = NULL; - if ((grp != NULL) && (*grp != '\0') && ((g = purple_find_group(grp)) == NULL)) + if ((grp != NULL) && (*grp != '\0')) { - g = purple_group_new(grp); - purple_blist_add_group(g, NULL); + if ((g = purple_find_group(grp)) == NULL) + { + g = purple_group_new(grp); + purple_blist_add_group(g, NULL); + } + + b = purple_find_buddy_in_group(data->account, who, g); } - - b = purple_buddy_new(data->account, who, whoalias); - purple_blist_add_buddy(b, NULL, g, NULL); + else if ((b = purple_find_buddy(data->account, who)) != NULL) + { + g = purple_buddy_get_group(b); + } + + if (b == NULL) + { + b = purple_buddy_new(data->account, who, whoalias); + purple_blist_add_buddy(b, NULL, g, NULL); + } + purple_account_add_buddy(data->account, b); /* Offer to merge people with the same alias. */
--- a/pidgin/plugins/gevolution/gevo-util.c Fri Jan 02 07:43:30 2009 +0000 +++ b/pidgin/plugins/gevolution/gevo-util.c Fri Jan 02 19:27:02 2009 +0000 @@ -41,8 +41,12 @@ purple_blist_add_group(group, NULL); } - buddy = purple_buddy_new(account, screenname, alias); - purple_blist_add_buddy(buddy, NULL, group, NULL); + if ((buddy = purple_find_buddy_in_group(account, screenname, group)) == NULL) + { + buddy = purple_buddy_new(account, screenname, alias); + purple_blist_add_buddy(buddy, NULL, group, NULL); + } + purple_account_add_buddy(account, buddy); if (conv != NULL)