comparison src/blist.c @ 10726:00e3dc1a0206

[gaim-migrate @ 12326] " Correctly updates the group counts in HEAD when you sign off. I didn't do anything with current size since I'm not to familiar with the blist node stuff, but it does hide the groups now. I just updated the online member of the blistnode struct to reflect the account signing off." --grim committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Fri, 25 Mar 2005 13:14:28 +0000
parents a4ae4fb7f939
children d07ebadef09d
comparison
equal deleted inserted replaced
10725:de26e6e198a4 10726:00e3dc1a0206
2197 2197
2198 void gaim_blist_remove_account(GaimAccount *account) 2198 void gaim_blist_remove_account(GaimAccount *account)
2199 { 2199 {
2200 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; 2200 GaimBlistUiOps *ops = gaimbuddylist->ui_ops;
2201 GaimBlistNode *gnode, *cnode, *bnode; 2201 GaimBlistNode *gnode, *cnode, *bnode;
2202 GaimBuddy *buddy;
2203 GaimChat *chat;
2204 GaimContact *contact;
2205 GaimGroup *group;
2202 2206
2203 g_return_if_fail(gaimbuddylist != NULL); 2207 g_return_if_fail(gaimbuddylist != NULL);
2204 2208
2205 for (gnode = gaimbuddylist->root; gnode; gnode = gnode->next) { 2209 for (gnode = gaimbuddylist->root; gnode; gnode = gnode->next) {
2206 if (!GAIM_BLIST_NODE_IS_GROUP(gnode)) 2210 if (!GAIM_BLIST_NODE_IS_GROUP(gnode))
2207 continue; 2211 continue;
2212
2213 group = (GaimGroup *)gnode;
2214
2208 for (cnode = gnode->child; cnode; cnode = cnode->next) { 2215 for (cnode = gnode->child; cnode; cnode = cnode->next) {
2209 if (GAIM_BLIST_NODE_IS_CONTACT(cnode)) { 2216 if (GAIM_BLIST_NODE_IS_CONTACT(cnode)) {
2217 contact = (GaimContact *)cnode;
2210 gboolean recompute = FALSE; 2218 gboolean recompute = FALSE;
2219
2211 for (bnode = cnode->child; bnode; bnode = bnode->next) { 2220 for (bnode = cnode->child; bnode; bnode = bnode->next) {
2212 if (!GAIM_BLIST_NODE_IS_BUDDY(bnode)) 2221 if (!GAIM_BLIST_NODE_IS_BUDDY(bnode))
2213 continue; 2222 continue;
2214 if (account == ((GaimBuddy *)bnode)->account) { 2223
2224 buddy = (GaimBuddy *)bnode;
2225 if (account == buddy->account) {
2215 GaimPresence *presence; 2226 GaimPresence *presence;
2216 recompute = TRUE; 2227 recompute = TRUE;
2217 if (((GaimBuddy*)bnode)->present == GAIM_BUDDY_ONLINE || 2228
2218 ((GaimBuddy*)bnode)->present == GAIM_BUDDY_SIGNING_ON) { 2229 presence = gaim_buddy_get_presence(buddy);
2219 ((GaimContact*)cnode)->online--; 2230
2220 if (((GaimContact*)cnode)->online == 0) 2231 if(!gaim_presence_is_online(presence)) {
2221 ((GaimGroup*)gnode)->online--; 2232 contact->online--;
2222 gaim_blist_node_set_int(&((GaimBuddy *)bnode)->node, 2233 if (contact->online == 0)
2234 group->online--;
2235
2236 gaim_blist_node_set_int(&buddy->node,
2223 "last_seen", time(NULL)); 2237 "last_seen", time(NULL));
2224 } 2238 }
2225 ((GaimContact*)cnode)->currentsize--; 2239
2226 if (((GaimContact*)cnode)->currentsize == 0) 2240 contact->online--;
2227 ((GaimGroup*)gnode)->currentsize--; 2241 if (contact->online == 0)
2228 2242 group->online--;
2229 ((GaimBuddy*)bnode)->present = GAIM_BUDDY_OFFLINE; 2243
2230
2231 presence = gaim_buddy_get_presence((GaimBuddy*)bnode);
2232 gaim_presence_set_status_active(presence, "offline", TRUE); 2244 gaim_presence_set_status_active(presence, "offline", TRUE);
2233
2234 ((GaimBuddy*)bnode)->uc = 0;
2235 /* TODO: ((GaimBuddy*)bnode)->idle = 0; */
2236 2245
2237 if (ops && ops->remove) 2246 if (ops && ops->remove)
2238 ops->remove(gaimbuddylist, bnode); 2247 ops->remove(gaimbuddylist, bnode);
2239 } 2248 }
2240 } 2249 }
2241 if (recompute) { 2250 if (recompute) {
2242 gaim_contact_invalidate_priority_buddy((GaimContact*)cnode); 2251 gaim_contact_invalidate_priority_buddy(contact);
2243 if (ops && ops->update) 2252 if (ops && ops->update)
2244 ops->update(gaimbuddylist, cnode); 2253 ops->update(gaimbuddylist, cnode);
2245 } 2254 }
2246 } else if (GAIM_BLIST_NODE_IS_CHAT(cnode) && 2255 } else if (GAIM_BLIST_NODE_IS_CHAT(cnode)) {
2247 ((GaimChat*)cnode)->account == account) { 2256 chat = (GaimChat *)cnode;
2248 ((GaimGroup*)gnode)->currentsize--; 2257
2249 ((GaimGroup*)gnode)->online--; 2258 if(chat->account == account) {
2250 if (ops && ops->remove) 2259 group->currentsize--;
2251 ops->remove(gaimbuddylist, cnode); 2260 group->online--;
2261
2262 if (ops && ops->remove)
2263 ops->remove(gaimbuddylist, cnode);
2264 }
2252 } 2265 }
2253 } 2266 }
2254 } 2267 }
2255 } 2268 }
2256 2269