diff src/blist.c @ 7420:53c86d59f20b

[gaim-migrate @ 8022] (19:08:24) deryni: Paco-Paco can stop wanting to kill Sean for using ctrl-f in conversations, and all the rest of you can have fun making offline buddies take priority over online ones (I'm sure you'll figure it out =) and a change from free() to g_free() in yahoo from zuperdee, since g_free is theoretically doing more error checking committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Tue, 04 Nov 2003 00:10:29 +0000
parents b8ce6e194cff
children 58a426e1bd1a
line wrap: on
line diff
--- a/src/blist.c	Mon Nov 03 16:42:32 2003 +0000
+++ b/src/blist.c	Tue Nov 04 00:10:29 2003 +0000
@@ -114,32 +114,34 @@
 static void gaim_contact_compute_priority_buddy(GaimContact *contact) {
 	GaimBlistNode *bnode;
 	contact->priority = NULL;
+	contact->score = INT_MAX;
 
 	for(bnode = ((GaimBlistNode*)contact)->child; bnode; bnode = bnode->next) {
 		GaimBuddy *buddy;
+		int score = 0;
+
 		if(!GAIM_BLIST_NODE_IS_BUDDY(bnode))
 			continue;
 		buddy = (GaimBuddy*)bnode;
 		if(!gaim_account_is_connected(buddy->account))
 			continue;
 
-		if(!contact->priority) {
+		if (!GAIM_BUDDY_IS_ONLINE(buddy))
+			score += gaim_prefs_get_int("/core/contact/offline_score");
+		if (buddy->uc & UC_UNAVAILABLE)
+			score += gaim_prefs_get_int("/core/contact/away_score");
+		if (buddy->idle)
+			score += gaim_prefs_get_int("/core/contact/idle_score");
+
+		score += gaim_account_get_int(buddy->account, "score", 0);
+
+		if (score < contact->score) {
 			contact->priority = buddy;
-		} else if(GAIM_BUDDY_IS_ONLINE(buddy)) {
-			if(!GAIM_BUDDY_IS_ONLINE(contact->priority)) {
-				contact->priority = buddy;
-			} else if(!(buddy->uc & UC_UNAVAILABLE) && !buddy->idle &&
-					(contact->priority->uc & UC_UNAVAILABLE ||
-					 contact->priority->idle)) {
+			contact->score = score;
+		}
+		if (gaim_prefs_get_bool("/core/contact/last_match"))
+			if (score == contact->score)
 				contact->priority = buddy;
-			} else if(!buddy->idle && contact->priority->idle) {
-				contact->priority = buddy;
-			} else if(contact->priority->uc & UC_UNAVAILABLE &&
-					contact->priority->idle && (!(buddy->uc & UC_UNAVAILABLE) ||
-						!buddy->idle)) {
-				contact->priority = buddy;
-			}
-		}
 	}
 }
 
@@ -747,6 +749,7 @@
 	((GaimBlistNode*)c)->type = GAIM_BLIST_CONTACT_NODE;
 
 	c->totalsize = c->currentsize = c->online = 0;
+	c->score = INT_MAX;
 
 	ops = gaim_blist_get_ui_ops();
 	if (ops != NULL && ops->new_node != NULL)