diff options
author | Damian Minkov <damencho@jitsi.org> | 2013-10-04 16:26:58 +0300 |
---|---|---|
committer | Damian Minkov <damencho@jitsi.org> | 2013-10-07 09:37:16 +0300 |
commit | d75a60650a28230e6ed887c1cde44e2e9627306b (patch) | |
tree | 531e307e0d79b224cbb9bbc39ce1fb2733c37b73 /src/net/java/sip/communicator/impl/protocol | |
parent | a69d1510469757d35518a3d02e7630be0808c2e5 (diff) | |
download | jitsi-d75a60650a28230e6ed887c1cde44e2e9627306b.zip jitsi-d75a60650a28230e6ed887c1cde44e2e9627306b.tar.gz jitsi-d75a60650a28230e6ed887c1cde44e2e9627306b.tar.bz2 |
Adds mobile flag to the ContactResource.
Diffstat (limited to 'src/net/java/sip/communicator/impl/protocol')
3 files changed, 40 insertions, 23 deletions
diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/ContactResourceJabberImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/ContactResourceJabberImpl.java index 96c680d..4a2cec9 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/ContactResourceJabberImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/ContactResourceJabberImpl.java @@ -32,12 +32,14 @@ public class ContactResourceJabberImpl Contact contact, String resourceName, PresenceStatus presenceStatus, - int priority) + int priority, + boolean isMobile) { super( contact, resourceName, presenceStatus, - priority); + priority, + isMobile); this.fullJid = fullJid; } diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/MobileIndicator.java b/src/net/java/sip/communicator/impl/protocol/jabber/MobileIndicator.java index 28caec9..85ce45b 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/MobileIndicator.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/MobileIndicator.java @@ -143,7 +143,7 @@ public class MobileIndicator boolean allMobile = false; for(ContactResource res : highestPriorityResources) { - if(startsWithStrings(res.getResourceName(), checkStrings)) + if(res.isMobile()) allMobile = true; else { @@ -159,6 +159,34 @@ public class MobileIndicator } /** + * Checks a resource whether it is mobile or not, by checking the + * cache. + * @param resourceName the resource name to check. + * @param fullJid the jid to check. + * @return whether resource with that name is mobile or not. + */ + boolean isMobileResource(String resourceName, String fullJid) + { + if(isCapsMobileIndicator) + { + EntityCapsManager capsManager = ssclCallback.getParentProvider() + .getDiscoveryManager().getCapsManager(); + + EntityCapsManager.Caps caps = capsManager.getCapsByUser(fullJid); + + if(caps != null && containsStrings(caps.node, checkStrings)) + return true; + else + return false; + } + + if(startsWithStrings(resourceName, checkStrings)) + return true; + else + return false; + } + + /** * The method is called by a ProtocolProvider implementation whenever * a change in the registration state of the corresponding provider had * occurred. @@ -210,10 +238,6 @@ public class MobileIndicator if(contact == null) return; - // Now lets check for mobile indicator - EntityCapsManager capsManager = ssclCallback.getParentProvider() - .getDiscoveryManager().getCapsManager(); - // 1. Find most connected resources and if all are mobile int currentMostConnectedStatus = 0; List<ContactResource> mostAvailableResources = @@ -241,17 +265,7 @@ public class MobileIndicator boolean allMobile = false; for(ContactResource res : mostAvailableResources) { - EntityCapsManager.Caps caps = capsManager.getCapsByUser( - ((ContactResourceJabberImpl)res).getFullJid()); - - if(caps == null) - { - // missing caps, no indicator so its not mobile - allMobile = false; - break; - } - - if(containsStrings(caps.node, checkStrings)) + if(res.isMobile()) allMobile = true; else { diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetPersistentPresenceJabberImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetPersistentPresenceJabberImpl.java index 6704d5b..c9515cc 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetPersistentPresenceJabberImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetPersistentPresenceJabberImpl.java @@ -1009,11 +1009,12 @@ public class OperationSetPersistentPresenceJabberImpl if (contactResource == null) { contactResource = new ContactResourceJabberImpl( - fullJid, - contact, - resource, - newPresenceStatus, - presence.getPriority()); + fullJid, + contact, + resource, + newPresenceStatus, + presence.getPriority(), + mobileIndicator.isMobileResource(resource, fullJid)); resources.put(fullJid, contactResource); |