From 09d688c00a58854d5f0eb066f752feea061e135e Mon Sep 17 00:00:00 2001 From: Lyubomir Marinov Date: Fri, 7 Jan 2011 20:07:54 +0000 Subject: Displays kABOrganizationProperty as the displayName of SourceContact for companies fetched from the Address Book of Mac OS X. --- .../macosx/MacOSXAddrBookContactQuery.java | 61 ++++++++++++++++++++-- 1 file changed, 58 insertions(+), 3 deletions(-) (limited to 'src/net/java/sip') 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 525ebd9..4dbd609 100644 --- a/src/net/java/sip/communicator/plugin/addrbook/macosx/MacOSXAddrBookContactQuery.java +++ b/src/net/java/sip/communicator/plugin/addrbook/macosx/MacOSXAddrBookContactQuery.java @@ -40,7 +40,9 @@ public class MacOSXAddrBookContactQuery kABMSNInstantProperty(), kABNicknameProperty(), kABPhoneProperty(), - kABYahooInstantProperty() + kABYahooInstantProperty(), + kABPersonFlags(), + kABOrganizationProperty() }; /** @@ -116,12 +118,36 @@ public class MacOSXAddrBookContactQuery private static final int kABNicknameProperty = 11; /** + * The index of the kABOrganizationProperty ABPerson + * property in {@link #ABPERSON_PROPERTIES}. + */ + private static final int kABOrganizationProperty = 15; + + /** + * The index of the kABPersonFlags ABPerson property in + * {@link #ABPERSON_PROPERTIES}. + */ + private static final int kABPersonFlags = 14; + + /** * The index of the kABPhoneProperty ABPerson property in * {@link #ABPERSON_PROPERTIES}. */ private static final int kABPhoneProperty = 12; /** + * The flag which indicates that an ABRecord is to be displayed as + * a company. + */ + private static final long kABShowAsCompany = 1; + + /** + * The mask which extracts the kABShowAsXXX flag from the + * personFlags of an ABPerson. + */ + private static final long kABShowAsMask = 7; + + /** * The index of the kABYahooInstantProperty ABPerson * property in {@link #ABPERSON_PROPERTIES}. */ @@ -242,11 +268,26 @@ public class MacOSXAddrBookContactQuery */ private String getDisplayName(Object[] values) { - String displayName + long personFlags + = (values[kABPersonFlags] instanceof Long) + ? ((Long) values[kABPersonFlags]).longValue() + : 0; + String displayName; + + if ((personFlags & kABShowAsMask) == kABShowAsCompany) + { + displayName + = (values[kABOrganizationProperty] instanceof String) + ? (String) values[kABOrganizationProperty] + : ""; + if (displayName.length() != 0) + return displayName; + } + + displayName = (values[kABNicknameProperty] instanceof String) ? (String) values[kABNicknameProperty] : ""; - if (displayName.length() != 0) return displayName; @@ -407,6 +448,20 @@ public class MacOSXAddrBookContactQuery private static native long kABNicknameProperty(); /** + * Gets the value of the kABOrganizationProperty constant. + * + * @return the value of the kABOrganizationProperty constant + */ + private static native long kABOrganizationProperty(); + + /** + * Gets the value of the kABPersonFlags constant. + * + * @return the value of the kABPersonFlags constant + */ + private static native long kABPersonFlags(); + + /** * Gets the value of the kABPhoneProperty constant. * * @return the value of the kABPhoneProperty constant -- cgit v1.1