# HG changeset patch # User Sean Egan # Date 1054827455 0 # Node ID 666b04f93c55a6fad91e2cbc805323f88cfd8c9a # Parent f5773332fbed2eff5ba6a65a2db93e87a90c6244 [gaim-migrate @ 6183] Now buddies who are in two groups on your list will have their statuses updated for both. gaim_find_buddy can be used in a loop to find all buddies with the specified name on an account. As such, gaim_find_buddy is somewhat slower, but considering that people tend to have far fewer groups than buddies the performance isn't hurt that much. committer: Tailor Script diff -r f5773332fbed -r 666b04f93c55 src/blist.c --- a/src/blist.c Thu Jun 05 10:22:02 2003 +0000 +++ b/src/blist.c Thu Jun 05 15:37:35 2003 +0000 @@ -70,6 +70,7 @@ struct _gaim_hbuddy { char *name; GaimAccount *account; + GaimBlistNode *group; }; static guint _gaim_blist_hbuddy_hash (struct _gaim_hbuddy *hb) @@ -79,7 +80,7 @@ static guint _gaim_blist_hbuddy_equal (struct _gaim_hbuddy *hb1, struct _gaim_hbuddy *hb2) { - return ((!strcmp(hb1->name, hb2->name)) && hb1->account == hb2->account); + return ((!strcmp(hb1->name, hb2->name)) && hb1->account == hb2->account && hb1->group == hb2->group); } /***************************************************************************** @@ -506,6 +507,7 @@ hb = g_malloc(sizeof(struct _gaim_hbuddy)); hb->name = g_strdup(normalize(buddy->name)); hb->account = buddy->account; + hb->group = ((GaimBlistNode*)buddy)->parent; if (g_hash_table_lookup(gaimbuddylist->buddies, (gpointer)hb)) { /* This guy already exists */ @@ -628,6 +630,7 @@ hb.name = normalize(buddy->name); hb.account = buddy->account; + hb.group = ((GaimBlistNode*)buddy)->parent; if (g_hash_table_lookup_extended(gaimbuddylist->buddies, &hb, (gpointer *)&key, (gpointer *)&val)) { g_hash_table_remove(gaimbuddylist->buddies, &hb); g_free(key->name); @@ -736,17 +739,33 @@ struct buddy *gaim_find_buddy(GaimAccount *account, const char *name) { - struct buddy *buddy; + static struct buddy *buddy = NULL; struct _gaim_hbuddy hb; + GaimBlistNode *group; + const char *n = NULL; if (!gaimbuddylist) return NULL; + + if (!name && !buddy); - hb.name = normalize(name); - hb.account = account; - buddy = g_hash_table_lookup(gaimbuddylist->buddies, &hb); + if (name) { + group = gaimbuddylist->root; + n = name; + } else { + group = ((GaimBlistNode*)buddy)->parent->next; + n = buddy->name; + } - return buddy; + while (group) { + hb.name = normalize(n); + hb.account = account; + hb.group = group; + if (buddy = g_hash_table_lookup(gaimbuddylist->buddies, &hb)) + return buddy; + group = ((GaimBlistNode*)group)->next; + } + return NULL; } struct group *gaim_find_group(const char *name) diff -r f5773332fbed -r 666b04f93c55 src/blist.h --- a/src/blist.h Thu Jun 05 10:22:02 2003 +0000 +++ b/src/blist.h Thu Jun 05 15:37:35 2003 +0000 @@ -384,7 +384,8 @@ /** * Finds the buddy struct given a screenname and an account * - * @param name The buddy's screenname + * @param name The buddy's screenname or NULL to search for more buddies with the same screenname + * as the previous search * @param account The account this buddy belongs to * @return The buddy or NULL if the buddy does not exist */ diff -r f5773332fbed -r 666b04f93c55 src/server.c --- a/src/server.c Thu Jun 05 10:22:02 2003 +0000 +++ b/src/server.c Thu Jun 05 15:37:35 2003 +0000 @@ -1148,6 +1148,13 @@ gaim_blist_update_buddy_presence(b, loggedin); + /* Now, update the rest of the buddies in the list */ + while (b = gaim_find_buddy(gc->account, NULL)) { + gaim_blist_update_buddy_presence(b, loggedin); + gaim_blist_update_buddy_idle(b, idle); + gaim_blist_update_buddy_evil(b, evil); + gaim_blist_update_buddy_status(b, type); + } }