pidgin: 6bbe6f7a: Prefer more available resources to less ...
evands at pidgin.im
evands at pidgin.im
Tue Mar 4 13:56:38 EST 2008
-----------------------------------------------------------------
Revision: 6bbe6f7a6765c8a0f9b27b8723b3833656a6a2fa
Ancestor: dfdceb0b08475c3e5750b3e6430d154e9a747d67
Author: evands at pidgin.im
Date: 2008-03-04T18:50:16
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/6bbe6f7a6765c8a0f9b27b8723b3833656a6a2fa
Modified files:
libpurple/protocols/jabber/buddy.c
ChangeLog:
Prefer more available resources to less available ones when priorities are the same. Fixes #5079.
-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/buddy.c 30ccef8ae960bfa7d6e2007eaa0e15f6d2a8dbf2
+++ libpurple/protocols/jabber/buddy.c 6cc6a150f09b0d4256687f67848c3a2b6dea09c6
@@ -101,8 +101,36 @@ JabberBuddyResource *jabber_buddy_find_r
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;
More information about the Commits
mailing list