diff --git a/src/net/java/sip/communicator/impl/callhistory/CallHistorySourceContact.java b/src/net/java/sip/communicator/impl/callhistory/CallHistorySourceContact.java index 3fe42c55c..5506b1104 100644 --- a/src/net/java/sip/communicator/impl/callhistory/CallHistorySourceContact.java +++ b/src/net/java/sip/communicator/impl/callhistory/CallHistorySourceContact.java @@ -186,6 +186,9 @@ private void initPeerDetails() supportedOpSets.add(OperationSetBasicTelephony.class); } + // can be added as contacts + supportedOpSets.add(OperationSetPersistentPresence.class); + contactDetail.setSupportedOpSets(supportedOpSets); contactDetails.add(contactDetail); @@ -285,8 +288,10 @@ else if (callRecord.getDirection().equals(CallRecord.OUT)) public List getContactDetails( Class operationSet) { - // We support only call details. - if (!operationSet.equals(OperationSetBasicTelephony.class)) + // We support only call details + // or persistence presence so we can add contacts. + if (!(operationSet.equals(OperationSetBasicTelephony.class) + || operationSet.equals(OperationSetPersistentPresence.class))) return null; return new LinkedList(contactDetails); @@ -318,8 +323,10 @@ public List getContactDetails(String category) public ContactDetail getPreferredContactDetail( Class operationSet) { - // We support only call details. - if (!operationSet.equals(OperationSetBasicTelephony.class)) + // We support only call details + // or persistence presence so we can add contacts. + if (!(operationSet.equals(OperationSetBasicTelephony.class) + || operationSet.equals(OperationSetPersistentPresence.class))) return null; return contactDetails.get(0); diff --git a/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsQuery.java b/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsQuery.java index 5fa2b77df..b1cc8cc5d 100644 --- a/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsQuery.java +++ b/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsQuery.java @@ -155,23 +155,37 @@ private List getContactDetails(GoogleContactsEntry entry) for(String mail : homeMails) { + List> supportedOpSets + = new ArrayList>(1); + // can be added as contacts + supportedOpSets.add(OperationSetPersistentPresence.class); + detail = new ContactDetail(mail, ContactDetail.CATEGORY_EMAIL, new String[]{ContactDetail.LABEL_HOME}); + detail.setSupportedOpSets(supportedOpSets); ret.add(detail); } for(String mail : workMails) { + List> supportedOpSets + = new ArrayList>(1); + // can be added as contacts + supportedOpSets.add(OperationSetPersistentPresence.class); + detail = new ContactDetail(mail, ContactDetail.CATEGORY_EMAIL, new String[]{ContactDetail.LABEL_WORK}); + detail.setSupportedOpSets(supportedOpSets); ret.add(detail); } for(String homePhone : homePhones) { List> supportedOpSets - = new ArrayList>(1); + = new ArrayList>(2); supportedOpSets.add(OperationSetBasicTelephony.class); + // can be added as contacts + supportedOpSets.add(OperationSetPersistentPresence.class); homePhone = PhoneNumberI18nService.normalize(homePhone); detail = new ContactDetail(homePhone, ContactDetail.CATEGORY_PHONE, @@ -183,9 +197,11 @@ private List getContactDetails(GoogleContactsEntry entry) for(String workPhone : workPhones) { List> supportedOpSets - = new ArrayList>(1); + = new ArrayList>(2); supportedOpSets.add(OperationSetBasicTelephony.class); + // can be added as contacts + supportedOpSets.add(OperationSetPersistentPresence.class); workPhone = PhoneNumberI18nService.normalize(workPhone); detail = new ContactDetail(workPhone, ContactDetail.CATEGORY_PHONE, @@ -197,9 +213,11 @@ private List getContactDetails(GoogleContactsEntry entry) for(String mobilePhone : mobilePhones) { List> supportedOpSets - = new ArrayList>(1); + = new ArrayList>(2); supportedOpSets.add(OperationSetBasicTelephony.class); + // can be added as contacts + supportedOpSets.add(OperationSetPersistentPresence.class); mobilePhone = PhoneNumberI18nService.normalize(mobilePhone); detail = new ContactDetail(mobilePhone, ContactDetail.CATEGORY_PHONE, @@ -218,6 +236,11 @@ private List getContactDetails(GoogleContactsEntry entry) new String[]{im.getValue().toString()}); setIMCapabilities(detail, im.getValue()); + + // can be added as contacts + detail.getSupportedOperationSets() + .add(OperationSetPersistentPresence.class); + ret.add(detail); } } diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListTreeCellRenderer.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListTreeCellRenderer.java index 594b74208..3d46c4c1e 100644 --- a/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListTreeCellRenderer.java +++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListTreeCellRenderer.java @@ -689,7 +689,7 @@ private void addLabels(int nameLabelGridWidth) /** * Initializes the display details component for the given * UIContact. - * @param details the display details to show + * @param displayDetails the display details to show */ private void initDisplayDetails(String displayDetails) { @@ -831,8 +831,7 @@ private void initButtonsPanel(UIContact uiContact) null); if ((telephonyContact != null && telephonyContact.getAddress() != null) - || uiContact.getDescriptor() instanceof SourceContact || - (hasPhone && providers.size() > 0)) + || (hasPhone && providers.size() > 0)) { x += addButton(callButton, ++gridX, x, false); } @@ -869,7 +868,14 @@ private void initButtonsPanel(UIContact uiContact) x += addButton(desktopSharingButton, ++gridX, x, false); } - if (uiContact.getDescriptor() instanceof SourceContact + // enable add contact button if contact source has indicated + // that this is possible + if (uiContact.getDefaultContactDetail( + OperationSetPersistentPresence.class) != null + && GuiActivator.getOpSetRegisteredProviders( + OperationSetPersistentPresence.class, + null, + null).size() > 0 && !ConfigurationUtils.isAddContactDisabled()) { x += addButton(addContactButton, ++gridX, x, false); @@ -1359,7 +1365,8 @@ private void addContact(SourceUIContact contact) { SourceContact sourceContact = (SourceContact) contact.getDescriptor(); - List details = sourceContact.getContactDetails(); + List details = sourceContact.getContactDetails( + OperationSetPersistentPresence.class); int detailsCount = details.size(); if (detailsCount > 1) diff --git a/src/net/java/sip/communicator/impl/ldap/LdapContactQuery.java b/src/net/java/sip/communicator/impl/ldap/LdapContactQuery.java index 3f325d57d..2b0d95bc3 100644 --- a/src/net/java/sip/communicator/impl/ldap/LdapContactQuery.java +++ b/src/net/java/sip/communicator/impl/ldap/LdapContactQuery.java @@ -140,17 +140,25 @@ private List getContactDetails(LdapPersonFound person) for(String mail : mailAddresses) { + List> supportedOpSets + = new ArrayList>(1); + // can be added as contacts + supportedOpSets.add(OperationSetPersistentPresence.class); + detail = new ContactDetail(mail, ContactDetail.CATEGORY_EMAIL, null); + detail.setSupportedOpSets(supportedOpSets); ret.add(detail); } for(String homePhone : homePhones) { List> supportedOpSets - = new ArrayList>(1); + = new ArrayList>(2); supportedOpSets.add(OperationSetBasicTelephony.class); + // can be added as contacts + supportedOpSets.add(OperationSetPersistentPresence.class); homePhone = PhoneNumberI18nService.normalize(homePhone); detail = new ContactDetail(homePhone, ContactDetail.CATEGORY_PHONE, @@ -162,9 +170,11 @@ private List getContactDetails(LdapPersonFound person) for(String workPhone : workPhones) { List> supportedOpSets - = new ArrayList>(1); + = new ArrayList>(2); supportedOpSets.add(OperationSetBasicTelephony.class); + // can be added as contacts + supportedOpSets.add(OperationSetPersistentPresence.class); workPhone = PhoneNumberI18nService.normalize(workPhone); detail = new ContactDetail(workPhone, ContactDetail.CATEGORY_PHONE, @@ -176,9 +186,11 @@ private List getContactDetails(LdapPersonFound person) for(String mobilePhone : mobilePhones) { List> supportedOpSets - = new ArrayList>(1); + = new ArrayList>(2); supportedOpSets.add(OperationSetBasicTelephony.class); + // can be added as contacts + supportedOpSets.add(OperationSetPersistentPresence.class); mobilePhone = PhoneNumberI18nService.normalize(mobilePhone); detail = new ContactDetail(mobilePhone, ContactDetail.CATEGORY_PHONE, diff --git a/src/net/java/sip/communicator/plugin/addrbook/macosx/MacOSXAddrBookContactQuery.java b/src/net/java/sip/communicator/plugin/addrbook/macosx/MacOSXAddrBookContactQuery.java index ad4ebea0e..71e9ce34f 100644 --- a/src/net/java/sip/communicator/plugin/addrbook/macosx/MacOSXAddrBookContactQuery.java +++ b/src/net/java/sip/communicator/plugin/addrbook/macosx/MacOSXAddrBookContactQuery.java @@ -738,6 +738,9 @@ private ContactDetail setCapabilities( Map, String> preferredProtocols = new HashMap, String>(); + // can be added as contacts + supportedOpSets.add(OperationSetPersistentPresence.class); + switch (property) { case kABAIMInstantProperty: diff --git a/src/net/java/sip/communicator/plugin/addrbook/msoutlook/MsOutlookAddrBookContactQuery.java b/src/net/java/sip/communicator/plugin/addrbook/msoutlook/MsOutlookAddrBookContactQuery.java index 2c45d5969..05d25ced9 100644 --- a/src/net/java/sip/communicator/plugin/addrbook/msoutlook/MsOutlookAddrBookContactQuery.java +++ b/src/net/java/sip/communicator/plugin/addrbook/msoutlook/MsOutlookAddrBookContactQuery.java @@ -354,9 +354,11 @@ private boolean onMailUser(long iUnknown) if (matches) { List> supportedOpSets - = new ArrayList>(1); + = new ArrayList>(2); supportedOpSets.add(OperationSetBasicTelephony.class); + // can be added as contacts + supportedOpSets.add(OperationSetPersistentPresence.class); List contactDetails = new LinkedList();