changeset 25207:b2f4964768d7

Merge
author Marcus Lundblad <ml@update.uu.se>
date Tue, 02 Dec 2008 22:45:25 +0000
parents 6986ae0cbb51
children 6f94b4a27372
files libpurple/protocols/jabber/buddy.c
diffstat 1 files changed, 15 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/jabber/buddy.c	Mon Nov 24 22:12:07 2008 +0000
+++ b/libpurple/protocols/jabber/buddy.c	Tue Dec 02 22:45:25 2008 +0000
@@ -99,36 +99,32 @@
 
 	for(l = jb->resources; l; l = l->next)
 	{
-		JabberBuddyResource *tmp = l->data;
 		if(!jbr && !resource) {
-			jbr = tmp;
+			jbr = l->data;
 		} else if(!resource) {
-			if(tmp->priority > jbr->priority)
-				jbr = tmp;
-			else if(tmp->priority == jbr->priority) {
+			if(((JabberBuddyResource *)l->data)->priority > jbr->priority)
+				jbr = l->data;
+			else if(((JabberBuddyResource *)l->data)->priority == jbr->priority) {
 				/* Determine if this resource is more available than the one we've currently chosen */
-				switch(tmp->state) {
+				switch(((JabberBuddyResource *)l->data)->state) {
 					case JABBER_BUDDY_STATE_ONLINE:
 					case JABBER_BUDDY_STATE_CHAT:
 						/* This resource is online/chatty. Prefer to one which isn't either. */
-						if (((jbr->state != JABBER_BUDDY_STATE_ONLINE) && (jbr->state != JABBER_BUDDY_STATE_CHAT)) ||
-							(jbr->idle && !tmp->idle) || (jbr->idle && tmp->idle && tmp->idle > jbr->idle))
-							jbr = tmp;
+						if ((jbr->state != JABBER_BUDDY_STATE_ONLINE) && (jbr->state != JABBER_BUDDY_STATE_CHAT))
+							jbr = l->data;
 						break;
 					case JABBER_BUDDY_STATE_AWAY:
 					case JABBER_BUDDY_STATE_DND:
 					case JABBER_BUDDY_STATE_UNAVAILABLE:
 						/* This resource is away/dnd/unavailable. Prefer to one which is extended away or unknown. */
-						if (((jbr->state == JABBER_BUDDY_STATE_XA) || 
-							(jbr->state == JABBER_BUDDY_STATE_UNKNOWN) || (jbr->state == JABBER_BUDDY_STATE_ERROR)) ||
-							(jbr->idle && !tmp->idle) || (jbr->idle && tmp->idle && tmp->idle > jbr->idle))
-							jbr = tmp;
+						if ((jbr->state == JABBER_BUDDY_STATE_XA) || 
+							(jbr->state == JABBER_BUDDY_STATE_UNKNOWN) || (jbr->state == JABBER_BUDDY_STATE_ERROR))
+							jbr = l->data;
 						break;
 					case JABBER_BUDDY_STATE_XA:
 						/* This resource is extended away. That's better than unknown. */
-						if (((jbr->state == JABBER_BUDDY_STATE_UNKNOWN) || (jbr->state == JABBER_BUDDY_STATE_ERROR)) ||
-							(jbr->idle && !tmp->idle) || (jbr->idle && tmp->idle && tmp->idle > jbr->idle))
-							jbr = tmp;
+						if ((jbr->state == JABBER_BUDDY_STATE_UNKNOWN) || (jbr->state == JABBER_BUDDY_STATE_ERROR))
+							jbr = l->data;
 						break;
 					case JABBER_BUDDY_STATE_UNKNOWN:
 					case JABBER_BUDDY_STATE_ERROR:
@@ -136,9 +132,9 @@
 						break;
 				}
 			}
-		} else if(tmp->name) {
-			if(!strcmp(tmp->name, resource)) {
-				jbr = tmp;
+		} else if(((JabberBuddyResource *)l->data)->name) {
+			if(!strcmp(((JabberBuddyResource *)l->data)->name, resource)) {
+				jbr = l->data;
 				break;
 			}
 		}