Displays kABOrganizationProperty as the displayName of SourceContact for companies fetched from the Address Book of Mac OS X.

cusax-fix
Lyubomir Marinov 15 years ago
parent 72bc56dbb3
commit 09d688c00a

@ -119,6 +119,22 @@ JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_plugin_addrbook_macosx_Ma
JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABNicknameProperty
(JNIEnv *, jclass);
/*
* Class: net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery
* Method: kABOrganizationProperty
* Signature: ()J
*/
JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABOrganizationProperty
(JNIEnv *, jclass);
/*
* Class: net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery
* Method: kABPersonFlags
* Signature: ()J
*/
JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABPersonFlags
(JNIEnv *, jclass);
/*
* Class: net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery
* Method: kABPhoneProperty

@ -121,6 +121,8 @@ DEFINE_ABPERSON_PROPERTY_GETTER(kABMiddleNameProperty)
DEFINE_ABPERSON_PROPERTY_GETTER(kABMiddleNamePhoneticProperty)
DEFINE_ABPERSON_PROPERTY_GETTER(kABMSNInstantProperty)
DEFINE_ABPERSON_PROPERTY_GETTER(kABNicknameProperty)
DEFINE_ABPERSON_PROPERTY_GETTER(kABOrganizationProperty)
DEFINE_ABPERSON_PROPERTY_GETTER(kABPersonFlags)
DEFINE_ABPERSON_PROPERTY_GETTER(kABPhoneProperty)
DEFINE_ABPERSON_PROPERTY_GETTER(kABYahooInstantProperty)
@ -166,6 +168,28 @@ MacOSXAddrBookContactQuery_idToJObject
}
}
}
else if ([o isKindOfClass:[NSNumber class]])
{
jclass longClass = (*jniEnv)->FindClass(jniEnv, "java/lang/Long");
jo = NULL;
if (longClass)
{
jmethodID longMethodID
= (*jniEnv)->GetMethodID(
jniEnv,
longClass, "<init>", "(J)V");
if (longMethodID)
{
jo
= (*jniEnv)->NewObject(
jniEnv,
longClass, longMethodID,
(jlong) ([((NSNumber *) o) longValue]));
}
}
}
else
jo = NULL;
if (jo)

@ -40,7 +40,9 @@ public class MacOSXAddrBookContactQuery
kABMSNInstantProperty(),
kABNicknameProperty(),
kABPhoneProperty(),
kABYahooInstantProperty()
kABYahooInstantProperty(),
kABPersonFlags(),
kABOrganizationProperty()
};
/**
@ -115,12 +117,36 @@ public class MacOSXAddrBookContactQuery
*/
private static final int kABNicknameProperty = 11;
/**
* The index of the <tt>kABOrganizationProperty</tt> <tt>ABPerson</tt>
* property in {@link #ABPERSON_PROPERTIES}.
*/
private static final int kABOrganizationProperty = 15;
/**
* The index of the <tt>kABPersonFlags</tt> <tt>ABPerson</tt> property in
* {@link #ABPERSON_PROPERTIES}.
*/
private static final int kABPersonFlags = 14;
/**
* The index of the <tt>kABPhoneProperty</tt> <tt>ABPerson</tt> property in
* {@link #ABPERSON_PROPERTIES}.
*/
private static final int kABPhoneProperty = 12;
/**
* The flag which indicates that an <tt>ABRecord</tt> is to be displayed as
* a company.
*/
private static final long kABShowAsCompany = 1;
/**
* The mask which extracts the <tt>kABShowAsXXX</tt> flag from the
* <tt>personFlags</tt> of an <tt>ABPerson</tt>.
*/
private static final long kABShowAsMask = 7;
/**
* The index of the <tt>kABYahooInstantProperty</tt> <tt>ABPerson</tt>
* property in {@link #ABPERSON_PROPERTIES}.
@ -242,11 +268,26 @@ else if (value instanceof Object[])
*/
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;
@ -406,6 +447,20 @@ else if (value instanceof Object[])
*/
private static native long kABNicknameProperty();
/**
* Gets the value of the <tt>kABOrganizationProperty</tt> constant.
*
* @return the value of the <tt>kABOrganizationProperty</tt> constant
*/
private static native long kABOrganizationProperty();
/**
* Gets the value of the <tt>kABPersonFlags</tt> constant.
*
* @return the value of the <tt>kABPersonFlags</tt> constant
*/
private static native long kABPersonFlags();
/**
* Gets the value of the <tt>kABPhoneProperty</tt> constant.
*

Loading…
Cancel
Save