Mercurial > pidgin.yaz
comparison src/blist.c @ 9928:5d8d73c2eebe
[gaim-migrate @ 10820]
this shouldn't break anything, and doesn't seem to
it might even fix the stupid negative buddy count problem
thanks datallah
committer: Tailor Script <tailor@pidgin.im>
author | Nathan Walp <nwalp@pidgin.im> |
---|---|
date | Wed, 01 Sep 2004 01:13:21 +0000 |
parents | fb08a0973b3e |
children | e4a27c9aec4c |
comparison
equal
deleted
inserted
replaced
9927:fb08a0973b3e | 9928:5d8d73c2eebe |
---|---|
963 void gaim_blist_add_contact(GaimContact *contact, GaimGroup *group, GaimBlistNode *node) | 963 void gaim_blist_add_contact(GaimContact *contact, GaimGroup *group, GaimBlistNode *node) |
964 { | 964 { |
965 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; | 965 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; |
966 GaimGroup *g; | 966 GaimGroup *g; |
967 GaimBlistNode *gnode, *cnode, *bnode; | 967 GaimBlistNode *gnode, *cnode, *bnode; |
968 gboolean empty_contact = FALSE; | |
969 | 968 |
970 g_return_if_fail(contact != NULL); | 969 g_return_if_fail(contact != NULL); |
971 g_return_if_fail(GAIM_BLIST_NODE_IS_CONTACT((GaimBlistNode*)contact)); | 970 g_return_if_fail(GAIM_BLIST_NODE_IS_CONTACT((GaimBlistNode*)contact)); |
972 | 971 |
973 if ((GaimBlistNode*)contact == node) | 972 if ((GaimBlistNode*)contact == node) |
993 if (cnode->prev) | 992 if (cnode->prev) |
994 cnode->prev->next = cnode->next; | 993 cnode->prev->next = cnode->next; |
995 if (cnode->next) | 994 if (cnode->next) |
996 cnode->next->prev = cnode->prev; | 995 cnode->next->prev = cnode->prev; |
997 | 996 |
998 | |
999 if (contact->online > 0) | |
1000 ((GaimGroup*)cnode->parent)->online--; | |
1001 if (contact->currentsize > 0) | |
1002 ((GaimGroup*)cnode->parent)->currentsize--; | |
1003 ((GaimGroup*)cnode->parent)->totalsize--; | |
1004 | |
1005 ops->remove(gaimbuddylist, cnode); | |
1006 | |
1007 schedule_blist_save(); | |
1008 | |
1009 if (cnode->parent != gnode) { | 997 if (cnode->parent != gnode) { |
1010 for (bnode = cnode->child; bnode; bnode = bnode->next) { | 998 bnode = cnode->child; |
999 while (bnode) { | |
1000 GaimBlistNode *next_bnode = bnode->next; | |
1011 GaimBuddy *b = (GaimBuddy*)bnode; | 1001 GaimBuddy *b = (GaimBuddy*)bnode; |
1012 | 1002 |
1013 struct _gaim_hbuddy *hb = g_new(struct _gaim_hbuddy, 1); | 1003 struct _gaim_hbuddy *hb = g_new(struct _gaim_hbuddy, 1); |
1014 hb->name = g_strdup(gaim_normalize(b->account, b->name)); | 1004 hb->name = g_strdup(gaim_normalize(b->account, b->name)); |
1015 hb->account = b->account; | 1005 hb->account = b->account; |
1022 g_hash_table_replace(gaimbuddylist->buddies, hb, b); | 1012 g_hash_table_replace(gaimbuddylist->buddies, hb, b); |
1023 | 1013 |
1024 if (b->account->gc) | 1014 if (b->account->gc) |
1025 serv_move_buddy(b, (GaimGroup *)cnode->parent, g); | 1015 serv_move_buddy(b, (GaimGroup *)cnode->parent, g); |
1026 } else { | 1016 } else { |
1017 gboolean empty_contact = FALSE; | |
1018 | |
1027 /* this buddy already exists in the group, so we're | 1019 /* this buddy already exists in the group, so we're |
1028 * gonna delete it instead */ | 1020 * gonna delete it instead */ |
1029 g_free(hb->name); | 1021 g_free(hb->name); |
1030 g_free(hb); | 1022 g_free(hb); |
1031 if (b->account->gc) | 1023 if (b->account->gc) |
1032 serv_remove_buddy(b->account->gc, b, (GaimGroup *)cnode->parent); | 1024 serv_remove_buddy(b->account->gc, b, (GaimGroup *)cnode->parent); |
1033 | 1025 |
1034 if (!cnode->child->next) | 1026 if (!cnode->child->next) |
1035 empty_contact = TRUE; | 1027 empty_contact = TRUE; |
1036 gaim_blist_remove_buddy(b); | 1028 gaim_blist_remove_buddy(b); |
1029 | |
1030 /** in gaim_blist_remove_buddy(), if the last buddy in a | |
1031 * contact is removed, the contact is cleaned up and | |
1032 * g_free'd, so we mustn't try to reference bnode->next */ | |
1033 if (empty_contact) | |
1034 return; | |
1037 } | 1035 } |
1036 bnode = next_bnode; | |
1038 } | 1037 } |
1039 } | 1038 } |
1040 } | 1039 |
1041 | 1040 if (contact->online > 0) |
1042 if (empty_contact) | 1041 ((GaimGroup*)cnode->parent)->online--; |
1043 return; | 1042 if (contact->currentsize > 0) |
1044 | 1043 ((GaimGroup*)cnode->parent)->currentsize--; |
1044 ((GaimGroup*)cnode->parent)->totalsize--; | |
1045 | |
1046 ops->remove(gaimbuddylist, cnode); | |
1047 | |
1048 schedule_blist_save(); | |
1049 } | |
1045 | 1050 |
1046 if (node && (GAIM_BLIST_NODE_IS_CONTACT(node) || | 1051 if (node && (GAIM_BLIST_NODE_IS_CONTACT(node) || |
1047 GAIM_BLIST_NODE_IS_CHAT(node))) { | 1052 GAIM_BLIST_NODE_IS_CHAT(node))) { |
1048 if (node->next) | 1053 if (node->next) |
1049 node->next->prev = cnode; | 1054 node->next->prev = cnode; |