Mercurial > pidgin.yaz
changeset 25796:c5c4faef04ff
Patch from darkrain42
Introduce a temporary variable to aid in readability
author | Marcus Lundblad <ml@update.uu.se> |
---|---|
date | Tue, 18 Nov 2008 20:22:57 +0000 |
parents | f8e6484fa8ac |
children | cac2f6203505 |
files | libpurple/protocols/jabber/buddy.c |
diffstat | 1 files changed, 12 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/protocols/jabber/buddy.c Mon Nov 17 23:18:12 2008 +0000 +++ b/libpurple/protocols/jabber/buddy.c Tue Nov 18 20:22:57 2008 +0000 @@ -99,19 +99,20 @@ for(l = jb->resources; l; l = l->next) { + JabberBuddyResource *tmp = l->data; if(!jbr && !resource) { - jbr = l->data; + jbr = tmp; } else if(!resource) { - if(((JabberBuddyResource *)l->data)->priority > jbr->priority) - jbr = l->data; - else if(((JabberBuddyResource *)l->data)->priority == jbr->priority) { + if(tmp->priority > jbr->priority) + jbr = tmp; + else if(tmp->priority == jbr->priority) { /* Determine if this resource is more available than the one we've currently chosen */ - switch(((JabberBuddyResource *)l->data)->state) { + switch(tmp->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 = l->data; + jbr = tmp; break; case JABBER_BUDDY_STATE_AWAY: case JABBER_BUDDY_STATE_DND: @@ -119,12 +120,12 @@ /* 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 = l->data; + jbr = tmp; 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 = l->data; + jbr = tmp; break; case JABBER_BUDDY_STATE_UNKNOWN: case JABBER_BUDDY_STATE_ERROR: @@ -132,9 +133,9 @@ break; } } - } else if(((JabberBuddyResource *)l->data)->name) { - if(!strcmp(((JabberBuddyResource *)l->data)->name, resource)) { - jbr = l->data; + } else if(tmp->name) { + if(!strcmp(tmp->name, resource)) { + jbr = tmp; break; } }