Mercurial > pidgin
changeset 22414:67f62f55fc5a
Prefer more available resources to less available ones when priorities are the same. Fixes #5079.
author | Evan Schoenberg <evan.s@dreskin.net> |
---|---|
date | Tue, 04 Mar 2008 18:50:16 +0000 |
parents | b77c8a87e15e |
children | 9a12b7f5b1f5 |
files | libpurple/protocols/jabber/buddy.c |
diffstat | 1 files changed, 29 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/protocols/jabber/buddy.c Tue Mar 04 16:23:07 2008 +0000 +++ b/libpurple/protocols/jabber/buddy.c Tue Mar 04 18:50:16 2008 +0000 @@ -101,8 +101,36 @@ if(!jbr && !resource) { jbr = l->data; } else if(!resource) { - if(((JabberBuddyResource *)l->data)->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(((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 = 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 = 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 = l->data; + break; + case JABBER_BUDDY_STATE_UNKNOWN: + case JABBER_BUDDY_STATE_ERROR: + /* These are never preferable. */ + break; + } + } } else if(((JabberBuddyResource *)l->data)->name) { if(!strcmp(((JabberBuddyResource *)l->data)->name, resource)) { jbr = l->data;