changeset 5259:750e4801819f

[gaim-migrate @ 5631] i didn't mean to commit that committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Tue, 29 Apr 2003 00:23:19 +0000
parents 4ac135a2f422
children 5331d5f11089
files src/blist.c src/blist.h
diffstat 2 files changed, 31 insertions(+), 44 deletions(-) [+]
line wrap: on
line diff
--- a/src/blist.c	Tue Apr 29 00:17:36 2003 +0000
+++ b/src/blist.c	Tue Apr 29 00:23:19 2003 +0000
@@ -172,12 +172,10 @@
 		buddy->present = GAIM_BUDDY_SIGNING_ON;
 		gaim_event_broadcast(event_buddy_signon, buddy->account->gc, buddy->name);
 		do_timer = TRUE;
-		((struct group *)((GaimBlistNode *)buddy)->parent)->online++;
 	} else if(GAIM_BUDDY_IS_ONLINE(buddy) && !presence) {
 		buddy->present = GAIM_BUDDY_SIGNING_OFF;
 		gaim_event_broadcast(event_buddy_signoff, buddy->account->gc, buddy->name);
 		do_timer = TRUE;
-		((struct group *)((GaimBlistNode *)buddy)->parent)->online--;
 	}
 
 	if(do_timer) {
@@ -332,9 +330,6 @@
 		/* This chat was already in the list and is
 		 * being moved.
 		 */
-		((struct group *)cnode->parent)->totalsize--;
-		if (chat->account->gc)
-			((struct group *)cnode->parent)->currentsize--;
 		if(cnode->next)
 			cnode->next->prev = cnode->prev;
 		if(cnode->prev)
@@ -354,16 +349,10 @@
 		cnode->prev = n;
 		cnode->parent = n->parent;
 		n->next = cnode;
-		((struct group *)n->parent)->totalsize++;
-		if (chat->account->gc)
-			((struct group *)n->parent)->currentsize++;
 	} else {
 		((GaimBlistNode*)g)->child = cnode;
 		cnode->next = cnode->prev = NULL;
 		cnode->parent = (GaimBlistNode*)g;
-		g->totalsize++;
-		if (chat->account->gc)
-			g->currentsize++;
 	}
 
 	if (ops)
@@ -398,10 +387,6 @@
 		/* This buddy was already in the list and is
 		 * being moved.
 		 */
-		((struct group *)bnode->parent)->totalsize--;
-		if (buddy->account->gc)
-			((struct group *)bnode->parent)->currentsize--;
-
 		if(bnode->next)
 			bnode->next->prev = bnode->prev;
 		if(bnode->prev)
@@ -411,9 +396,8 @@
 
 		ops->remove(gaimbuddylist, bnode);
 
-		if (bnode->parent != ((GaimBlistNode*)g)) {
+		if (bnode->parent != ((GaimBlistNode*)g))
 			serv_move_buddy(buddy, (struct group*)bnode->parent, g);
-		}
 		save = TRUE;
 	}
 
@@ -424,17 +408,11 @@
 		((GaimBlistNode*)buddy)->prev = n;
 		((GaimBlistNode*)buddy)->parent = n->parent;
 		n->next = (GaimBlistNode*)buddy;
-		((struct group *)n->parent)->totalsize++;
-		if (buddy->account->gc)
-			((struct group *)n->parent)->currentsize++;
 	} else {
 		((GaimBlistNode*)g)->child = (GaimBlistNode*)buddy;
 		((GaimBlistNode*)buddy)->next = NULL;
 		((GaimBlistNode*)buddy)->prev = NULL;
 		((GaimBlistNode*)buddy)->parent = (GaimBlistNode*)g;
-		g->totalsize++;
-		if (buddy->account->gc)
-			g->currentsize++;
 	}
 
 	hb = g_malloc(sizeof(struct _gaim_hbuddy));
@@ -463,9 +441,6 @@
 		struct gaim_blist_ui_ops *ops;
 		g= g_new0(struct group, 1);
 		g->name = g_strdup(name);
-		g->totalsize = 0;
-		g->currentsize = 0;
-		g->online = 0;
 		g->settings = g_hash_table_new_full(g_str_hash, g_str_equal,
 				g_free, g_free);
 		((GaimBlistNode*)g)->type = GAIM_BLIST_GROUP_NODE;
@@ -549,9 +524,6 @@
 		node->prev->next = node->next;
 	if (node->next)
 		node->next->prev = node->prev;
-	group->totalsize--;
-	if (buddy->account->gc)
-		group->currentsize--;
 
 	hb.name = normalize(buddy->name);
 	hb.account = buddy->account;
@@ -584,9 +556,6 @@
 		node->prev->next = node->next;
 	if (node->next)
 		node->next->prev = node->prev;
-	group->totalsize--;
-	if (chat->account->gc)
-		group->currentsize--;
 
 	ops->remove(gaimbuddylist, node);
 	g_hash_table_destroy(chat->components);
@@ -711,13 +680,11 @@
 		for(buddy = group->child; buddy; buddy = buddy->next) {
 			if(GAIM_BLIST_NODE_IS_BUDDY(buddy)) {
 				if (account == ((struct buddy*)buddy)->account) {
-					((struct group *)group)->currentsize++;
 					if(ops)
 						ops->update(gaimbuddylist, buddy);
 				}
 			} else if(GAIM_BLIST_NODE_IS_CHAT(buddy)) {
 				if (account == ((struct chat*)buddy)->account) {
-					((struct group *)group)->currentsize++;
 					if(ops)
 						ops->update(gaimbuddylist, buddy);
 				}
@@ -740,17 +707,12 @@
 		for(buddy = group->child; buddy; buddy = buddy->next) {
 			if(GAIM_BLIST_NODE_IS_BUDDY(buddy)) {
 				if (account == ((struct buddy*)buddy)->account) {
-					if (((struct buddy *)buddy)->present)
-						((struct group *)group)->online--;
 					((struct buddy*)buddy)->present = GAIM_BUDDY_OFFLINE;
-					((struct group *)group)->currentsize--;
 					if(ops)
 						ops->remove(gaimbuddylist, buddy);
 				}
 			} else if(GAIM_BLIST_NODE_IS_CHAT(buddy)) {
 				if (account == ((struct chat*)buddy)->account) {
-					((struct group *)group)->online--;
-					((struct group *)group)->currentsize--;
 					if(ops)
 						ops->remove(gaimbuddylist, buddy);
 				}
@@ -1825,17 +1787,45 @@
 }
 
 int gaim_blist_get_group_size(struct group *group, gboolean offline) {
+	GaimBlistNode *node;
+	int count = 0;
+
 	if(!group)
 		return 0;
 
-	return offline ? group->totalsize : group->currentsize;
+	for(node = group->node.child; node; node = node->next) {
+		if(GAIM_BLIST_NODE_IS_BUDDY(node)) {
+			struct buddy *b = (struct buddy *)node;
+			if(b->account->gc || offline)
+				count++;
+		} else if(GAIM_BLIST_NODE_IS_CHAT(node)) {
+			struct chat *chat = (struct chat *)node;
+			if(chat->account->gc || offline)
+				count++;
+		}
+	}
+
+	return count;
 }
 
 int gaim_blist_get_group_online_count(struct group *group) {
+	GaimBlistNode *node;
+	int count = 0;
+
 	if(!group)
 		return 0;
 
-	return group->online;
+	for(node = group->node.child; node; node = node->next) {
+		if(GAIM_BLIST_NODE_IS_BUDDY(node)) {
+			struct buddy *b = (struct buddy *)node;
+			if(GAIM_BUDDY_IS_ONLINE(b))
+				count++;
+		} else if(GAIM_BLIST_NODE_IS_CHAT(node)) {
+			count++;
+		}
+	}
+
+	return count;
 }
 
 
--- a/src/blist.h	Tue Apr 29 00:17:36 2003 +0000
+++ b/src/blist.h	Tue Apr 29 00:23:19 2003 +0000
@@ -96,9 +96,6 @@
 struct group {
 	GaimBlistNode node;                    /**< The node that this group inherits from */
 	char *name;                            /**< The name of this group. */
-	int totalsize;			       /**< The number of buddies in this group */
-	int currentsize;		       /**< The number of buddies in this group corresponding to online accounts */
-	int online;			       /**< The number of buddies in this group who are currently online */
 	GHashTable *settings;                  /**< per-group settings from the XML buddy list, set by plugins and the likes. */
 };