Changes the behaviour of showing add contact and call buttons in the contact list for source contacts, don't show them by default but check for supported operation sets.

cusax-fix
Damian Minkov 13 years ago
parent c7386f332a
commit 98a0d907fa

@ -186,6 +186,9 @@ private void initPeerDetails()
supportedOpSets.add(OperationSetBasicTelephony.class); supportedOpSets.add(OperationSetBasicTelephony.class);
} }
// can be added as contacts
supportedOpSets.add(OperationSetPersistentPresence.class);
contactDetail.setSupportedOpSets(supportedOpSets); contactDetail.setSupportedOpSets(supportedOpSets);
contactDetails.add(contactDetail); contactDetails.add(contactDetail);
@ -285,8 +288,10 @@ else if (callRecord.getDirection().equals(CallRecord.OUT))
public List<ContactDetail> getContactDetails( public List<ContactDetail> getContactDetails(
Class<? extends OperationSet> operationSet) Class<? extends OperationSet> operationSet)
{ {
// We support only call details. // We support only call details
if (!operationSet.equals(OperationSetBasicTelephony.class)) // or persistence presence so we can add contacts.
if (!(operationSet.equals(OperationSetBasicTelephony.class)
|| operationSet.equals(OperationSetPersistentPresence.class)))
return null; return null;
return new LinkedList<ContactDetail>(contactDetails); return new LinkedList<ContactDetail>(contactDetails);
@ -318,8 +323,10 @@ public List<ContactDetail> getContactDetails(String category)
public ContactDetail getPreferredContactDetail( public ContactDetail getPreferredContactDetail(
Class<? extends OperationSet> operationSet) Class<? extends OperationSet> operationSet)
{ {
// We support only call details. // We support only call details
if (!operationSet.equals(OperationSetBasicTelephony.class)) // or persistence presence so we can add contacts.
if (!(operationSet.equals(OperationSetBasicTelephony.class)
|| operationSet.equals(OperationSetPersistentPresence.class)))
return null; return null;
return contactDetails.get(0); return contactDetails.get(0);

@ -155,23 +155,37 @@ private List<ContactDetail> getContactDetails(GoogleContactsEntry entry)
for(String mail : homeMails) for(String mail : homeMails)
{ {
List<Class<? extends OperationSet>> supportedOpSets
= new ArrayList<Class<? extends OperationSet>>(1);
// can be added as contacts
supportedOpSets.add(OperationSetPersistentPresence.class);
detail = new ContactDetail(mail, ContactDetail.CATEGORY_EMAIL, detail = new ContactDetail(mail, ContactDetail.CATEGORY_EMAIL,
new String[]{ContactDetail.LABEL_HOME}); new String[]{ContactDetail.LABEL_HOME});
detail.setSupportedOpSets(supportedOpSets);
ret.add(detail); ret.add(detail);
} }
for(String mail : workMails) for(String mail : workMails)
{ {
List<Class<? extends OperationSet>> supportedOpSets
= new ArrayList<Class<? extends OperationSet>>(1);
// can be added as contacts
supportedOpSets.add(OperationSetPersistentPresence.class);
detail = new ContactDetail(mail, ContactDetail.CATEGORY_EMAIL, detail = new ContactDetail(mail, ContactDetail.CATEGORY_EMAIL,
new String[]{ContactDetail.LABEL_WORK}); new String[]{ContactDetail.LABEL_WORK});
detail.setSupportedOpSets(supportedOpSets);
ret.add(detail); ret.add(detail);
} }
for(String homePhone : homePhones) for(String homePhone : homePhones)
{ {
List<Class<? extends OperationSet>> supportedOpSets List<Class<? extends OperationSet>> supportedOpSets
= new ArrayList<Class<? extends OperationSet>>(1); = new ArrayList<Class<? extends OperationSet>>(2);
supportedOpSets.add(OperationSetBasicTelephony.class); supportedOpSets.add(OperationSetBasicTelephony.class);
// can be added as contacts
supportedOpSets.add(OperationSetPersistentPresence.class);
homePhone = PhoneNumberI18nService.normalize(homePhone); homePhone = PhoneNumberI18nService.normalize(homePhone);
detail = new ContactDetail(homePhone, detail = new ContactDetail(homePhone,
ContactDetail.CATEGORY_PHONE, ContactDetail.CATEGORY_PHONE,
@ -183,9 +197,11 @@ private List<ContactDetail> getContactDetails(GoogleContactsEntry entry)
for(String workPhone : workPhones) for(String workPhone : workPhones)
{ {
List<Class<? extends OperationSet>> supportedOpSets List<Class<? extends OperationSet>> supportedOpSets
= new ArrayList<Class<? extends OperationSet>>(1); = new ArrayList<Class<? extends OperationSet>>(2);
supportedOpSets.add(OperationSetBasicTelephony.class); supportedOpSets.add(OperationSetBasicTelephony.class);
// can be added as contacts
supportedOpSets.add(OperationSetPersistentPresence.class);
workPhone = PhoneNumberI18nService.normalize(workPhone); workPhone = PhoneNumberI18nService.normalize(workPhone);
detail = new ContactDetail(workPhone, detail = new ContactDetail(workPhone,
ContactDetail.CATEGORY_PHONE, ContactDetail.CATEGORY_PHONE,
@ -197,9 +213,11 @@ private List<ContactDetail> getContactDetails(GoogleContactsEntry entry)
for(String mobilePhone : mobilePhones) for(String mobilePhone : mobilePhones)
{ {
List<Class<? extends OperationSet>> supportedOpSets List<Class<? extends OperationSet>> supportedOpSets
= new ArrayList<Class<? extends OperationSet>>(1); = new ArrayList<Class<? extends OperationSet>>(2);
supportedOpSets.add(OperationSetBasicTelephony.class); supportedOpSets.add(OperationSetBasicTelephony.class);
// can be added as contacts
supportedOpSets.add(OperationSetPersistentPresence.class);
mobilePhone = PhoneNumberI18nService.normalize(mobilePhone); mobilePhone = PhoneNumberI18nService.normalize(mobilePhone);
detail = new ContactDetail(mobilePhone, detail = new ContactDetail(mobilePhone,
ContactDetail.CATEGORY_PHONE, ContactDetail.CATEGORY_PHONE,
@ -218,6 +236,11 @@ private List<ContactDetail> getContactDetails(GoogleContactsEntry entry)
new String[]{im.getValue().toString()}); new String[]{im.getValue().toString()});
setIMCapabilities(detail, im.getValue()); setIMCapabilities(detail, im.getValue());
// can be added as contacts
detail.getSupportedOperationSets()
.add(OperationSetPersistentPresence.class);
ret.add(detail); ret.add(detail);
} }
} }

@ -689,7 +689,7 @@ private void addLabels(int nameLabelGridWidth)
/** /**
* Initializes the display details component for the given * Initializes the display details component for the given
* <tt>UIContact</tt>. * <tt>UIContact</tt>.
* @param details the display details to show * @param displayDetails the display details to show
*/ */
private void initDisplayDetails(String displayDetails) private void initDisplayDetails(String displayDetails)
{ {
@ -831,8 +831,7 @@ private void initButtonsPanel(UIContact uiContact)
null); null);
if ((telephonyContact != null && telephonyContact.getAddress() != 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); x += addButton(callButton, ++gridX, x, false);
} }
@ -869,7 +868,14 @@ private void initButtonsPanel(UIContact uiContact)
x += addButton(desktopSharingButton, ++gridX, x, false); 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()) && !ConfigurationUtils.isAddContactDisabled())
{ {
x += addButton(addContactButton, ++gridX, x, false); x += addButton(addContactButton, ++gridX, x, false);
@ -1359,7 +1365,8 @@ private void addContact(SourceUIContact contact)
{ {
SourceContact sourceContact = (SourceContact) contact.getDescriptor(); SourceContact sourceContact = (SourceContact) contact.getDescriptor();
List<ContactDetail> details = sourceContact.getContactDetails(); List<ContactDetail> details = sourceContact.getContactDetails(
OperationSetPersistentPresence.class);
int detailsCount = details.size(); int detailsCount = details.size();
if (detailsCount > 1) if (detailsCount > 1)

@ -140,17 +140,25 @@ private List<ContactDetail> getContactDetails(LdapPersonFound person)
for(String mail : mailAddresses) for(String mail : mailAddresses)
{ {
List<Class<? extends OperationSet>> supportedOpSets
= new ArrayList<Class<? extends OperationSet>>(1);
// can be added as contacts
supportedOpSets.add(OperationSetPersistentPresence.class);
detail = new ContactDetail(mail, ContactDetail.CATEGORY_EMAIL, detail = new ContactDetail(mail, ContactDetail.CATEGORY_EMAIL,
null); null);
detail.setSupportedOpSets(supportedOpSets);
ret.add(detail); ret.add(detail);
} }
for(String homePhone : homePhones) for(String homePhone : homePhones)
{ {
List<Class<? extends OperationSet>> supportedOpSets List<Class<? extends OperationSet>> supportedOpSets
= new ArrayList<Class<? extends OperationSet>>(1); = new ArrayList<Class<? extends OperationSet>>(2);
supportedOpSets.add(OperationSetBasicTelephony.class); supportedOpSets.add(OperationSetBasicTelephony.class);
// can be added as contacts
supportedOpSets.add(OperationSetPersistentPresence.class);
homePhone = PhoneNumberI18nService.normalize(homePhone); homePhone = PhoneNumberI18nService.normalize(homePhone);
detail = new ContactDetail(homePhone, detail = new ContactDetail(homePhone,
ContactDetail.CATEGORY_PHONE, ContactDetail.CATEGORY_PHONE,
@ -162,9 +170,11 @@ private List<ContactDetail> getContactDetails(LdapPersonFound person)
for(String workPhone : workPhones) for(String workPhone : workPhones)
{ {
List<Class<? extends OperationSet>> supportedOpSets List<Class<? extends OperationSet>> supportedOpSets
= new ArrayList<Class<? extends OperationSet>>(1); = new ArrayList<Class<? extends OperationSet>>(2);
supportedOpSets.add(OperationSetBasicTelephony.class); supportedOpSets.add(OperationSetBasicTelephony.class);
// can be added as contacts
supportedOpSets.add(OperationSetPersistentPresence.class);
workPhone = PhoneNumberI18nService.normalize(workPhone); workPhone = PhoneNumberI18nService.normalize(workPhone);
detail = new ContactDetail(workPhone, detail = new ContactDetail(workPhone,
ContactDetail.CATEGORY_PHONE, ContactDetail.CATEGORY_PHONE,
@ -176,9 +186,11 @@ private List<ContactDetail> getContactDetails(LdapPersonFound person)
for(String mobilePhone : mobilePhones) for(String mobilePhone : mobilePhones)
{ {
List<Class<? extends OperationSet>> supportedOpSets List<Class<? extends OperationSet>> supportedOpSets
= new ArrayList<Class<? extends OperationSet>>(1); = new ArrayList<Class<? extends OperationSet>>(2);
supportedOpSets.add(OperationSetBasicTelephony.class); supportedOpSets.add(OperationSetBasicTelephony.class);
// can be added as contacts
supportedOpSets.add(OperationSetPersistentPresence.class);
mobilePhone = PhoneNumberI18nService.normalize(mobilePhone); mobilePhone = PhoneNumberI18nService.normalize(mobilePhone);
detail = new ContactDetail(mobilePhone, detail = new ContactDetail(mobilePhone,
ContactDetail.CATEGORY_PHONE, ContactDetail.CATEGORY_PHONE,

@ -738,6 +738,9 @@ private ContactDetail setCapabilities(
Map<Class<? extends OperationSet>, String> preferredProtocols Map<Class<? extends OperationSet>, String> preferredProtocols
= new HashMap<Class<? extends OperationSet>, String>(); = new HashMap<Class<? extends OperationSet>, String>();
// can be added as contacts
supportedOpSets.add(OperationSetPersistentPresence.class);
switch (property) switch (property)
{ {
case kABAIMInstantProperty: case kABAIMInstantProperty:

@ -354,9 +354,11 @@ private boolean onMailUser(long iUnknown)
if (matches) if (matches)
{ {
List<Class<? extends OperationSet>> supportedOpSets List<Class<? extends OperationSet>> supportedOpSets
= new ArrayList<Class<? extends OperationSet>>(1); = new ArrayList<Class<? extends OperationSet>>(2);
supportedOpSets.add(OperationSetBasicTelephony.class); supportedOpSets.add(OperationSetBasicTelephony.class);
// can be added as contacts
supportedOpSets.add(OperationSetPersistentPresence.class);
List<ContactDetail> contactDetails List<ContactDetail> contactDetails
= new LinkedList<ContactDetail>(); = new LinkedList<ContactDetail>();

Loading…
Cancel
Save