diff --git a/src/net/java/sip/communicator/util/call/MetaContactPhoneUtil.java b/src/net/java/sip/communicator/util/call/MetaContactPhoneUtil.java index 5cd11ecff..3db99b4ac 100644 --- a/src/net/java/sip/communicator/util/call/MetaContactPhoneUtil.java +++ b/src/net/java/sip/communicator/util/call/MetaContactPhoneUtil.java @@ -42,6 +42,13 @@ public class MetaContactPhoneUtil private Hashtable> phones = new Hashtable>(); + /** + * The video phones that have been discovered + * for metacontact child contacts. + */ + private Hashtable> videoPhones = + new Hashtable>(); + /** * True if there is any phone found for the metacontact. */ @@ -119,6 +126,11 @@ public List getVideoPhones( Contact contact, return new ArrayList(); } + if(videoPhones.containsKey(contact)) + { + return videoPhones.get(contact); + } + List phonesList = ContactPhoneUtil.getContactAdditionalPhones( contact, listener, true, true); @@ -127,6 +139,8 @@ public List getVideoPhones( Contact contact, else if (phonesList.size() > 0) hasVideoDetail = true; + videoPhones.put(contact, phonesList); + return phonesList; } @@ -180,7 +194,7 @@ else if (phonesList.size() > 0) public boolean isVideoCallEnabled(DetailsResponseListener listener) { // make sure children are checked - if(!checkMetaContactPhones(listener)) + if(!checkMetaContactVideoPhones(listener)) return false; return metaContact.getDefaultContact( @@ -242,7 +256,7 @@ && hasContactCapabilities(contact, public boolean isDesktopSharingEnabled(DetailsResponseListener listener) { // make sure children are checked - if(!checkMetaContactPhones(listener)) + if(!checkMetaContactVideoPhones(listener)) return false; return metaContact.getDefaultContact( @@ -407,7 +421,35 @@ private boolean checkMetaContactPhones(DetailsResponseListener l) if(phones.containsKey(contact)) continue; - List phones = getPhones(contact, l, true); + List phones = getPhones(contact, l, false); + if(phones == null) + return false; + } + + return true; + } + + /** + * Checking all contacts for the metacontact. + * Return false if there are listeners added for a contact + * and we need to stop executions cause listener will be used to be informed + * for result. + * + * @param l the DetailsResponseListener to listen for further + * details + * @return whether to continue or listeners present and will be informed + * for result. + */ + private boolean checkMetaContactVideoPhones(DetailsResponseListener l) + { + Iterator contactIterator = metaContact.getContacts(); + while(contactIterator.hasNext()) + { + Contact contact = contactIterator.next(); + if(videoPhones.containsKey(contact)) + continue; + + List phones = getVideoPhones(contact, l); if(phones == null) return false; }