From 4b9b23ca052c1b04bc6342eaa795d6fc141866af Mon Sep 17 00:00:00 2001 From: Vincent Lucas Date: Thu, 11 Apr 2013 08:31:20 +0000 Subject: [PATCH] Adds organization name in MacOSX Contacts search results. --- .../macosx/MacOSXAddrBookContactQuery.java | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) 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 ebf1f039c..cfd51b49e 100644 --- a/src/net/java/sip/communicator/plugin/addrbook/macosx/MacOSXAddrBookContactQuery.java +++ b/src/net/java/sip/communicator/plugin/addrbook/macosx/MacOSXAddrBookContactQuery.java @@ -689,7 +689,7 @@ else if (subValue instanceof Object[]) * @return the displayName to be set on a SourceContact * which is to represent the ABPerson specified by values */ - static String getDisplayName(Object[] values) + private static String getDisplayName(Object[] values) { long personFlags = (values[kABPersonFlags] instanceof Long) @@ -792,6 +792,32 @@ else if (value instanceof Object[]) return displayName; } + /** + * Gets the organization name to be set on a SourceContact. + * + * @param values the values of the ABPERSON_PROPERTIES which + * represent the ABPerson to get the organization name of. + * + * @return The organization name to be set on a SourceContact. + */ + private static String getOrganization(Object[] values) + { + String organization = ""; + long personFlags + = (values[kABPersonFlags] instanceof Long) + ? ((Long) values[kABPersonFlags]).longValue() + : 0; + + if ((personFlags & kABShowAsMask) != kABShowAsCompany) + { + organization = (values[kABOrganizationProperty] instanceof String) + ? (String) values[kABOrganizationProperty] + : ""; + } + + return organization; + } + /** * Gets the value of the kABAIMInstantProperty constant. * @@ -1108,6 +1134,7 @@ private boolean onPerson(long person) displayName, contactDetails); sourceContact.setData(SourceContact.DATA_ID, id); + sourceContact.setDisplayDetails(getOrganization(values)); try { @@ -1247,6 +1274,7 @@ public void updated(long person) = (MacOSXAddrBookSourceContact)sourceContact; editableSourceContact.setDisplayName(displayName); + editableSourceContact.setDisplayDetails(getOrganization(values)); List contactDetails = getContactDetails(values, id); editableSourceContact.setDetails(contactDetails);