diff options
author | Damian Minkov <damencho@jitsi.org> | 2011-03-23 14:40:06 +0000 |
---|---|---|
committer | Damian Minkov <damencho@jitsi.org> | 2011-03-23 14:40:06 +0000 |
commit | 090a97e81ad0a4aa29577edc177fd125cf09e2ec (patch) | |
tree | 9011f9641ed77dedfac0faf5ae957dfc46afd9f0 /src/net/java/sip/communicator | |
parent | a59ece990413ad0c89c9b12c7a7f489cf61641ab (diff) | |
download | jitsi-090a97e81ad0a4aa29577edc177fd125cf09e2ec.zip jitsi-090a97e81ad0a4aa29577edc177fd125cf09e2ec.tar.gz jitsi-090a97e81ad0a4aa29577edc177fd125cf09e2ec.tar.bz2 |
Check all resources when doing jabber file-transfer and choose the most appropriate one.
Diffstat (limited to 'src/net/java/sip/communicator')
-rw-r--r-- | src/net/java/sip/communicator/impl/protocol/jabber/OperationSetFileTransferJabberImpl.java | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetFileTransferJabberImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetFileTransferJabberImpl.java index 203680d..6a70036 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetFileTransferJabberImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetFileTransferJabberImpl.java @@ -105,15 +105,39 @@ public class OperationSetFileTransferJabberImpl throw new IllegalArgumentException( "File length exceeds the allowed one for this protocol"); - String fullJid = jabberProvider.getFullJid(toContact); + // Find the jid of the contact which support file transfer + // and is with highest priority if more than one found + Iterator<Presence> iter = jabberProvider.getConnection().getRoster() + .getPresences(toContact.getAddress()); + int bestPriority = -1; + String fullJid = null; + + while(iter.hasNext()) + { + Presence presence = iter.next(); + + if(jabberProvider.isFeatureListSupported(presence.getFrom(), + new String[]{"http://jabber.org/protocol/si", + "http://jabber.org/protocol/si/profile/file-transfer"})) + { + + int priority = + (presence.getPriority() == Integer.MIN_VALUE) ? + 0 : presence.getPriority(); + + if(priority > bestPriority) + { + bestPriority = priority; + fullJid = presence.getFrom(); + } + } + } // First we check if file transfer is at all supported for this // contact. - if (!jabberProvider.isFeatureListSupported(fullJid, - new String[]{"http://jabber.org/protocol/si", - "http://jabber.org/protocol/si/profile/file-transfer"})) + if (fullJid == null) { - new OperationNotSupportedException( + throw new OperationNotSupportedException( "Contact client or server does not support file transfers."); } |