Mercurial > pidgin.yaz
diff src/protocols/jabber/roster.c @ 9285:7a8aa87164ae
[gaim-migrate @ 10088]
Ok I'm done. This started out as shx's patch to make add/remove
buddy/buddies take GaimBuddy and GaimGroup's in various places.
I think his diff was like 2000 lines and mine is like 5000. I
tried to clean up blist.c a bit and make it more uniform. There
are some more g_return_if_fail() checks. Removed some code that
was deprecated--it's probably been long enough. Removed some
#include <multi.h>'s. Make blist.xml saving happen on a timer,
like prefs.xml and accounts.xml.
Sorry if this doesn't merge cleanly with whatever you're doing.
People should really test this a lot.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Tue, 15 Jun 2004 02:37:27 +0000 |
parents | 5d039bc19350 |
children | fb08a0973b3e |
line wrap: on
line diff
--- a/src/protocols/jabber/roster.c Tue Jun 15 01:17:16 2004 +0000 +++ b/src/protocols/jabber/roster.c Tue Jun 15 02:37:27 2004 +0000 @@ -195,8 +195,6 @@ add_gaim_buddies_in_groups(js, jid, name, groups); } } - - gaim_blist_save(); } static void jabber_roster_update(JabberStream *js, const char *name, @@ -246,8 +244,8 @@ jabber_iq_send(iq); } -void jabber_roster_add_buddy(GaimConnection *gc, const char *name, - GaimGroup *grp) +void jabber_roster_add_buddy(GaimConnection *gc, GaimBuddy *buddy, + GaimGroup *group) { JabberStream *js = gc->proto_data; char *who; @@ -259,13 +257,13 @@ if(!js->roster_parsed) return; - if(!(who = jabber_get_bare_jid(name))) + if(!(who = jabber_get_bare_jid(buddy->name))) return; - jb = jabber_buddy_find(js, name, FALSE); + jb = jabber_buddy_find(js, buddy->name, FALSE); if(!jb || !(jb->subscription & JABBER_SUB_TO)) { - groups = g_slist_append(groups, grp->name); + groups = g_slist_append(groups, group->name); } jabber_roster_update(js, who, groups); @@ -318,39 +316,41 @@ g_slist_free(groups); } -void jabber_roster_group_rename(GaimConnection *gc, const char *old_group, - const char *new_group, GList *members) +void jabber_roster_group_rename(GaimConnection *gc, const char *old_name, + GaimGroup *group, GList *moved_buddies) { GList *l; - if(old_group && new_group && strcmp(old_group, new_group)) { - for(l = members; l; l = l->next) { - jabber_roster_group_change(gc, l->data, old_group, new_group); - } + for(l = moved_buddies; l; l = l->next) { + GaimBuddy *buddy = l->data; + jabber_roster_group_change(gc, buddy->name, old_name, group->name); } } -void jabber_roster_remove_buddy(GaimConnection *gc, const char *name, const char *group) { - GSList *buddies = gaim_find_buddies(gc->account, name); +void jabber_roster_remove_buddy(GaimConnection *gc, GaimBuddy *buddy, + GaimGroup *group) { + GSList *buddies = gaim_find_buddies(gc->account, buddy->name); GSList *groups = NULL; - GaimGroup *g = gaim_find_group(group); - GaimBuddy *b = gaim_find_buddy_in_group(gc->account, name, g); - buddies = g_slist_remove(buddies, b); + buddies = g_slist_remove(buddies, buddy); if(g_slist_length(buddies)) { + GaimBuddy *tmpbuddy; + GaimGroup *tmpgroup; + while(buddies) { - b = buddies->data; - g = gaim_find_buddys_group(b); - groups = g_slist_append(groups, g->name); - buddies = g_slist_remove(buddies, b); + tmpbuddy = buddies->data; + tmpgroup = gaim_find_buddys_group(tmpbuddy); + groups = g_slist_append(groups, tmpgroup->name); + buddies = g_slist_remove(buddies, tmpbuddy); } - jabber_roster_update(gc->proto_data, name, groups); + + jabber_roster_update(gc->proto_data, buddy->name, groups); } else { JabberIq *iq = jabber_iq_new_query(gc->proto_data, JABBER_IQ_SET, "jabber:iq:roster"); xmlnode *query = xmlnode_get_child(iq->node, "query"); xmlnode *item = xmlnode_new_child(query, "item"); - xmlnode_set_attrib(item, "jid", name); + xmlnode_set_attrib(item, "jid", buddy->name); xmlnode_set_attrib(item, "subscription", "remove"); jabber_iq_send(iq);