aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xlib/native/mac/libjmacosxaddrbook.jnilibbin74536 -> 91580 bytes
-rw-r--r--src/native/addrbook/macosx/net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery.h398
-rw-r--r--src/native/addrbook/macosx/net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery.m342
-rw-r--r--src/native/addrbook/macosx/net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactSourceService.h8
-rw-r--r--src/native/addrbook/macosx/net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactSourceService.m185
-rw-r--r--src/net/java/sip/communicator/impl/netaddr/NetworkConfigurationWatcher.java14
-rw-r--r--src/net/java/sip/communicator/plugin/addrbook/AbstractAddrBookContactQuery.java122
-rw-r--r--src/net/java/sip/communicator/plugin/addrbook/macosx/MacOSXAddrBookContactQuery.java981
-rw-r--r--src/net/java/sip/communicator/plugin/addrbook/macosx/MacOSXAddrBookContactSourceService.java62
-rw-r--r--src/net/java/sip/communicator/service/contactsource/AbstractContactQuery.java48
-rw-r--r--src/net/java/sip/communicator/service/contactsource/ContactDetail.java14
-rw-r--r--src/net/java/sip/communicator/service/contactsource/GenericSourceContact.java2
12 files changed, 2103 insertions, 73 deletions
diff --git a/lib/native/mac/libjmacosxaddrbook.jnilib b/lib/native/mac/libjmacosxaddrbook.jnilib
index 04f8ebd..35e1b0f 100755
--- a/lib/native/mac/libjmacosxaddrbook.jnilib
+++ b/lib/native/mac/libjmacosxaddrbook.jnilib
Binary files differ
diff --git a/src/native/addrbook/macosx/net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery.h b/src/native/addrbook/macosx/net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery.h
index d1ea08c..0f4d218 100644
--- a/src/native/addrbook/macosx/net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery.h
+++ b/src/native/addrbook/macosx/net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery.h
@@ -7,6 +7,76 @@
#ifdef __cplusplus
extern "C" {
#endif
+#undef net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABAIMInstantProperty
+#define net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABAIMInstantProperty 0L
+#undef net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABEmailProperty
+#define net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABEmailProperty 1L
+#undef net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABFirstNameProperty
+#define net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABFirstNameProperty 2L
+#undef net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABFirstNamePhoneticProperty
+#define net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABFirstNamePhoneticProperty 3L
+#undef net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABICQInstantProperty
+#define net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABICQInstantProperty 4L
+#undef net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABJabberInstantProperty
+#define net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABJabberInstantProperty 5L
+#undef net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABLastNameProperty
+#define net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABLastNameProperty 6L
+#undef net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABLastNamePhoneticProperty
+#define net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABLastNamePhoneticProperty 7L
+#undef net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABMiddleNameProperty
+#define net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABMiddleNameProperty 8L
+#undef net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABMiddleNamePhoneticProperty
+#define net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABMiddleNamePhoneticProperty 9L
+#undef net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABMSNInstantProperty
+#define net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABMSNInstantProperty 10L
+#undef net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABNicknameProperty
+#define net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABNicknameProperty 11L
+#undef net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABOrganizationProperty
+#define net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABOrganizationProperty 15L
+#undef net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABPersonFlags
+#define net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABPersonFlags 14L
+#undef net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABPhoneProperty
+#define net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABPhoneProperty 12L
+#undef net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABShowAsCompany
+#define net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABShowAsCompany 1LL
+#undef net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABShowAsMask
+#define net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABShowAsMask 7LL
+#undef net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABYahooInstantProperty
+#define net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABYahooInstantProperty 13L
+#undef net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABMaidenNameProperty
+#define net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABMaidenNameProperty 16L
+#undef net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABBirthdayProperty
+#define net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABBirthdayProperty 17L
+#undef net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABBirthdayComponentsProperty
+#define net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABBirthdayComponentsProperty 18L
+#undef net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABJobTitleProperty
+#define net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABJobTitleProperty 19L
+#undef net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABHomePageProperty
+#define net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABHomePageProperty 20L
+#undef net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABURLsProperty
+#define net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABURLsProperty 21L
+#undef net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABCalendarURIsProperty
+#define net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABCalendarURIsProperty 22L
+#undef net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABAddressProperty
+#define net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABAddressProperty 23L
+#undef net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABOtherDatesProperty
+#define net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABOtherDatesProperty 24L
+#undef net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABOtherDateComponentsProperty
+#define net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABOtherDateComponentsProperty 25L
+#undef net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABRelatedNamesProperty
+#define net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABRelatedNamesProperty 26L
+#undef net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABDepartmentProperty
+#define net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABDepartmentProperty 27L
+#undef net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABInstantMessageProperty
+#define net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABInstantMessageProperty 28L
+#undef net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABNoteProperty
+#define net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABNoteProperty 29L
+#undef net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABSocialProfileProperty
+#define net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABSocialProfileProperty 30L
+#undef net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABTitleProperty
+#define net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABTitleProperty 31L
+#undef net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABSuffixProperty
+#define net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABSuffixProperty 32L
/*
* Class: net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery
* Method: ABPerson_imageData
@@ -25,6 +95,30 @@ JNIEXPORT jobjectArray JNICALL Java_net_java_sip_communicator_plugin_addrbook_ma
/*
* Class: net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery
+ * Method: ABRecord_uniqueId
+ * Signature: (J)Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL Java_net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_ABRecord_1uniqueId
+ (JNIEnv *, jclass, jlong);
+
+/*
+ * Class: net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery
+ * Method: setProperty
+ * Signature: (Ljava/lang/String;JLjava/lang/String;Ljava/lang/Object;)Z
+ */
+JNIEXPORT jboolean JNICALL Java_net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_setProperty
+ (JNIEnv *, jclass, jstring, jlong, jstring, jobject);
+
+/*
+ * Class: net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery
+ * Method: removeProperty
+ * Signature: (Ljava/lang/String;J)Z
+ */
+JNIEXPORT jboolean JNICALL Java_net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_removeProperty
+ (JNIEnv *, jclass, jstring, jlong);
+
+/*
+ * Class: net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery
* Method: foreachPerson
* Signature: (Ljava/lang/String;Lnet/java/sip/communicator/plugin/addrbook/PtrCallback;)V
*/
@@ -159,6 +253,310 @@ JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_plugin_addrbook_macosx_Ma
JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABYahooInstantProperty
(JNIEnv *, jclass);
+/*
+ * Class: net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery
+ * Method: kABMaidenNameProperty
+ * Signature: ()J
+ */
+JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABMaidenNameProperty
+ (JNIEnv *, jclass);
+
+/*
+ * Class: net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery
+ * Method: kABBirthdayProperty
+ * Signature: ()J
+ */
+JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABBirthdayProperty
+ (JNIEnv *, jclass);
+
+/*
+ * Class: net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery
+ * Method: kABBirthdayComponentsProperty
+ * Signature: ()J
+ */
+JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABBirthdayComponentsProperty
+ (JNIEnv *, jclass);
+
+/*
+ * Class: net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery
+ * Method: kABJobTitleProperty
+ * Signature: ()J
+ */
+JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABJobTitleProperty
+ (JNIEnv *, jclass);
+
+/*
+ * Class: net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery
+ * Method: kABHomePageProperty
+ * Signature: ()J
+ */
+JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABHomePageProperty
+ (JNIEnv *, jclass);
+
+/*
+ * Class: net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery
+ * Method: kABURLsProperty
+ * Signature: ()J
+ */
+JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABURLsProperty
+ (JNIEnv *, jclass);
+
+/*
+ * Class: net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery
+ * Method: kABCalendarURIsProperty
+ * Signature: ()J
+ */
+JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABCalendarURIsProperty
+ (JNIEnv *, jclass);
+
+/*
+ * Class: net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery
+ * Method: kABAddressProperty
+ * Signature: ()J
+ */
+JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABAddressProperty
+ (JNIEnv *, jclass);
+
+/*
+ * Class: net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery
+ * Method: kABOtherDatesProperty
+ * Signature: ()J
+ */
+JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABOtherDatesProperty
+ (JNIEnv *, jclass);
+
+/*
+ * Class: net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery
+ * Method: kABOtherDateComponentsProperty
+ * Signature: ()J
+ */
+JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABOtherDateComponentsProperty
+ (JNIEnv *, jclass);
+
+/*
+ * Class: net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery
+ * Method: kABRelatedNamesProperty
+ * Signature: ()J
+ */
+JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABRelatedNamesProperty
+ (JNIEnv *, jclass);
+
+/*
+ * Class: net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery
+ * Method: kABDepartmentProperty
+ * Signature: ()J
+ */
+JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABDepartmentProperty
+ (JNIEnv *, jclass);
+
+/*
+ * Class: net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery
+ * Method: kABInstantMessageProperty
+ * Signature: ()J
+ */
+JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABInstantMessageProperty
+ (JNIEnv *, jclass);
+
+/*
+ * Class: net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery
+ * Method: kABNoteProperty
+ * Signature: ()J
+ */
+JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABNoteProperty
+ (JNIEnv *, jclass);
+
+/*
+ * Class: net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery
+ * Method: kABSocialProfileProperty
+ * Signature: ()J
+ */
+JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABSocialProfileProperty
+ (JNIEnv *, jclass);
+
+/*
+ * Class: net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery
+ * Method: kABTitleProperty
+ * Signature: ()J
+ */
+JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABTitleProperty
+ (JNIEnv *, jclass);
+
+/*
+ * Class: net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery
+ * Method: kABSuffixProperty
+ * Signature: ()J
+ */
+JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABSuffixProperty
+ (JNIEnv *, jclass);
+
+/*
+ * Class: net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery
+ * Method: kABEmailWorkLabel
+ * Signature: ()Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL Java_net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABEmailWorkLabel
+ (JNIEnv *, jclass);
+
+/*
+ * Class: net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery
+ * Method: kABEmailHomeLabel
+ * Signature: ()Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL Java_net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABEmailHomeLabel
+ (JNIEnv *, jclass);
+
+/*
+ * Class: net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery
+ * Method: kABAddressHomeLabel
+ * Signature: ()Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL Java_net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABAddressHomeLabel
+ (JNIEnv *, jclass);
+
+/*
+ * Class: net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery
+ * Method: kABAddressWorkLabel
+ * Signature: ()Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL Java_net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABAddressWorkLabel
+ (JNIEnv *, jclass);
+
+/*
+ * Class: net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery
+ * Method: kABPhoneWorkLabel
+ * Signature: ()Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL Java_net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABPhoneWorkLabel
+ (JNIEnv *, jclass);
+
+/*
+ * Class: net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery
+ * Method: kABPhoneHomeLabel
+ * Signature: ()Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL Java_net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABPhoneHomeLabel
+ (JNIEnv *, jclass);
+
+/*
+ * Class: net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery
+ * Method: kABPhoneMobileLabel
+ * Signature: ()Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL Java_net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABPhoneMobileLabel
+ (JNIEnv *, jclass);
+
+/*
+ * Class: net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery
+ * Method: kABPhoneMainLabel
+ * Signature: ()Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL Java_net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABPhoneMainLabel
+ (JNIEnv *, jclass);
+
+/*
+ * Class: net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery
+ * Method: kABPhoneWorkFAXLabel
+ * Signature: ()Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL Java_net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABPhoneWorkFAXLabel
+ (JNIEnv *, jclass);
+
+/*
+ * Class: net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery
+ * Method: kABInstantMessageServiceAIM
+ * Signature: ()Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL Java_net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABInstantMessageServiceAIM
+ (JNIEnv *, jclass);
+
+/*
+ * Class: net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery
+ * Method: kABInstantMessageServiceFacebook
+ * Signature: ()Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL Java_net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABInstantMessageServiceFacebook
+ (JNIEnv *, jclass);
+
+/*
+ * Class: net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery
+ * Method: kABInstantMessageServiceGoogleTalk
+ * Signature: ()Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL Java_net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABInstantMessageServiceGoogleTalk
+ (JNIEnv *, jclass);
+
+/*
+ * Class: net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery
+ * Method: kABInstantMessageServiceICQ
+ * Signature: ()Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL Java_net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABInstantMessageServiceICQ
+ (JNIEnv *, jclass);
+
+/*
+ * Class: net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery
+ * Method: kABInstantMessageServiceJabber
+ * Signature: ()Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL Java_net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABInstantMessageServiceJabber
+ (JNIEnv *, jclass);
+
+/*
+ * Class: net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery
+ * Method: kABInstantMessageServiceMSN
+ * Signature: ()Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL Java_net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABInstantMessageServiceMSN
+ (JNIEnv *, jclass);
+
+/*
+ * Class: net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery
+ * Method: kABInstantMessageServiceSkype
+ * Signature: ()Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL Java_net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABInstantMessageServiceSkype
+ (JNIEnv *, jclass);
+
+/*
+ * Class: net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery
+ * Method: kABInstantMessageServiceYahoo
+ * Signature: ()Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL Java_net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABInstantMessageServiceYahoo
+ (JNIEnv *, jclass);
+
+/*
+ * Class: net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery
+ * Method: kABAddressStreetKey
+ * Signature: ()Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL Java_net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABAddressStreetKey
+ (JNIEnv *, jclass);
+
+/*
+ * Class: net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery
+ * Method: kABAddressCityKey
+ * Signature: ()Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL Java_net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABAddressCityKey
+ (JNIEnv *, jclass);
+
+/*
+ * Class: net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery
+ * Method: kABAddressZIPKey
+ * Signature: ()Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL Java_net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABAddressZIPKey
+ (JNIEnv *, jclass);
+
+/*
+ * Class: net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery
+ * Method: kABAddressCountryKey
+ * Signature: ()Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL Java_net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_kABAddressCountryKey
+ (JNIEnv *, jclass);
+
#ifdef __cplusplus
}
#endif
diff --git a/src/native/addrbook/macosx/net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery.m b/src/native/addrbook/macosx/net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery.m
index 1dcf235..88a01b1 100644
--- a/src/native/addrbook/macosx/net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery.m
+++ b/src/native/addrbook/macosx/net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery.m
@@ -131,6 +131,211 @@ Java_net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery
[autoreleasePool release];
}
+/*
+ * Class: net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery
+ * Method: ABRecord_uniqueId
+ * Signature: (J)Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL Java_net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_ABRecord_1uniqueId
+ (JNIEnv *jniEnv, jclass clazz, jlong record)
+{
+ return (*jniEnv)->NewStringUTF(jniEnv, [[(ABRecord *)record uniqueId] UTF8String]);
+}
+
+NSString *JavaStringToNSString(JNIEnv *env, jstring aString)
+{
+ if(aString == NULL)
+ return nil;
+
+ const jchar *chars = (*env)->GetStringChars(env, aString, NULL);
+ NSString *resultString = [NSString stringWithCharacters:(UniChar *)chars length:(*env)->GetStringLength(env, aString)];
+ (*env)->ReleaseStringChars(env, aString, chars);
+ return resultString;
+}
+
+/*
+ * Class: net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery
+ * Method: setProperty
+ * Signature: (Ljava/lang/String;JLjava/lang/String;Ljava/lang/Object;)Z
+ */
+JNIEXPORT jboolean JNICALL Java_net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_setProperty
+ (JNIEnv *jniEnv, jclass clazz, jstring id, jlong prop, jstring subProperty, jobject value)
+{
+ void* data;
+ ABAddressBook *addressBook;
+ ABRecord *r;
+ NSAutoreleasePool *autoreleasePool;
+ NSString *property;
+ BOOL res = FALSE;
+ int i;
+
+ autoreleasePool = [[NSAutoreleasePool alloc] init];
+
+ addressBook = [ABAddressBook sharedAddressBook];
+ r = [addressBook recordForUniqueId:JavaStringToNSString(jniEnv, id)];
+
+ property = (NSString *)prop;
+
+ if(property == kABFirstNameProperty
+ || property == kABLastNameProperty
+ || property == kABFirstNamePhoneticProperty
+ || property == kABLastNamePhoneticProperty
+ || property == kABNicknameProperty
+ || property == kABMaidenNameProperty
+ || property == kABOrganizationProperty
+ || property == kABJobTitleProperty
+ || property == kABHomePageProperty
+ || property == kABDepartmentProperty
+ || property == kABNoteProperty
+ || property == kABMiddleNameProperty
+ || property == kABMiddleNamePhoneticProperty
+ || property == kABTitleProperty
+ || property == kABSuffixProperty)
+ {
+ data = JavaStringToNSString(jniEnv, (jstring)value);
+ }
+ else if(property == kABBirthdayProperty)
+ {
+ data = [NSDate dateWithTimeIntervalSince1970:(jlong)value];
+ }
+ //else if(property == kABBirthdayComponentsProperty: not used for now
+ else if(property == kABURLsProperty
+ || property == kABCalendarURIsProperty
+ || property == kABEmailProperty
+ || property == kABRelatedNamesProperty
+ || property == kABPhoneProperty
+ || property == kABAIMInstantProperty
+ || property == kABJabberInstantProperty
+ || property == kABMSNInstantProperty
+ || property == kABYahooInstantProperty
+ || property == kABICQInstantProperty)
+ {
+ data=[[ABMutableMultiValue alloc] init];
+ jobjectArray arr = (jobjectArray)value;
+ jsize propertyCount = (*jniEnv)->GetArrayLength(jniEnv, arr);
+
+ for (i = 0; i < propertyCount; i+=2)
+ {
+ jstring value = (jstring) (*jniEnv)->GetObjectArrayElement(jniEnv, arr, i);
+ jstring label = (jstring) (*jniEnv)->GetObjectArrayElement(jniEnv, arr, i+1);
+
+ [(ABMutableMultiValue *) data
+ addValue:JavaStringToNSString(jniEnv, value)
+ withLabel:JavaStringToNSString(jniEnv, label)];
+ }
+ }
+ else if(property == kABAddressProperty)
+ {
+ jobjectArray arr = (jobjectArray)value;
+ jsize propertyCount = (*jniEnv)->GetArrayLength(jniEnv, arr);
+
+ NSMutableDictionary *addr;
+ addr = [NSMutableDictionary dictionary];
+
+ for (i = 0; i < propertyCount; i+=2)
+ {
+ jstring value = (jstring) (*jniEnv)->GetObjectArrayElement(jniEnv, arr, i);
+ jstring label = (jstring) (*jniEnv)->GetObjectArrayElement(jniEnv, arr, i+1);
+
+ //NSLog(@"key:%@, value:%@", JavaStringToNSString(jniEnv, label), JavaStringToNSString(jniEnv, value));
+ [addr setObject:JavaStringToNSString(jniEnv, value)
+ forKey:JavaStringToNSString(jniEnv, label)];
+ }
+
+ data=[[ABMutableMultiValue alloc] init];
+ [(ABMutableMultiValue *) data
+ addValue:addr
+ withLabel:JavaStringToNSString(jniEnv, subProperty)];
+ }
+ //else if(property == kABOtherDatesProperty)//kABMultiDateProperty
+ //else if(property == kABOtherDateComponentsProperty: not used for now
+ else if(property == kABInstantMessageProperty)
+ {
+ jobjectArray arr = (jobjectArray)value;
+ jsize propertyCount = (*jniEnv)->GetArrayLength(jniEnv, arr);
+
+ data=[[ABMutableMultiValue alloc] init];
+
+ // The values are
+ // kABInstantMessageUsernameKey -> the user set username
+ // kABInstantMessageServiceKey -> one of
+ // (kABInstantMessageServiceICQ,
+ // kABInstantMessageServiceJabber,
+ // kABInstantMessageServiceGoogleTalk
+ // ...)
+ for (i = 0; i < propertyCount; i+=4)
+ {
+ NSMutableDictionary *addr;
+ addr = [NSMutableDictionary dictionary];
+
+ jstring value = (jstring) (*jniEnv)->GetObjectArrayElement(
+ jniEnv, arr, i);
+ jstring label = (jstring) (*jniEnv)->GetObjectArrayElement(
+ jniEnv, arr, i+1);
+ jstring value2 = (jstring) (*jniEnv)->GetObjectArrayElement(
+ jniEnv, arr, i+2);
+ jstring label2 = (jstring) (*jniEnv)->GetObjectArrayElement(
+ jniEnv, arr, i+3);
+
+ //NSLog(@"key:%@, value:%@", JavaStringToNSString(jniEnv, label), JavaStringToNSString(jniEnv, value));
+ if(label)
+ [addr setObject:JavaStringToNSString(jniEnv, value)
+ forKey:JavaStringToNSString(jniEnv, label)];
+ if(label2)
+ [addr setObject:JavaStringToNSString(jniEnv, value2)
+ forKey:JavaStringToNSString(jniEnv, label2)];
+
+ [(ABMutableMultiValue *) data
+ addValue:addr
+ withLabel:JavaStringToNSString(jniEnv, subProperty)];
+ }
+ }
+ /*else if(property == kABSocialProfileProperty)
+ {
+ // kABSocialProfileURLKey, kABSocialProfileServiceKey,
+ // kABSocialProfileUsernameKey, kABSocialProfileUserIdentifierKey
+ }*/
+ else
+ {
+ data = NULL;
+ }
+
+ if(data)
+ res = [r setValue:data forProperty:(NSString *)property];
+
+ [addressBook save];
+
+ [autoreleasePool release];
+
+ return res;
+}
+
+/*
+ * Class: net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery
+ * Method: removeProperty
+ * Signature: (Ljava/lang/String;J)Z
+ */
+JNIEXPORT jboolean JNICALL Java_net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_removeProperty
+ (JNIEnv *jniEnv, jclass clazz, jstring id, jlong property)
+{
+ ABAddressBook *addressBook;
+ ABRecord *r;
+ NSAutoreleasePool *autoreleasePool;
+
+ autoreleasePool = [[NSAutoreleasePool alloc] init];
+
+ addressBook = [ABAddressBook sharedAddressBook];
+ r = [addressBook recordForUniqueId:JavaStringToNSString(jniEnv, id)];
+
+ BOOL res = [r removeValueForProperty:(NSString *)property];
+
+ [addressBook save];
+
+ [autoreleasePool release];
+
+ return res;
+}
+
#define DEFINE_ABPERSON_PROPERTY_GETTER(property) \
JNIEXPORT jlong JNICALL \
Java_net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_##property \
@@ -155,6 +360,86 @@ DEFINE_ABPERSON_PROPERTY_GETTER(kABOrganizationProperty)
DEFINE_ABPERSON_PROPERTY_GETTER(kABPersonFlags)
DEFINE_ABPERSON_PROPERTY_GETTER(kABPhoneProperty)
DEFINE_ABPERSON_PROPERTY_GETTER(kABYahooInstantProperty)
+DEFINE_ABPERSON_PROPERTY_GETTER(kABMaidenNameProperty)
+DEFINE_ABPERSON_PROPERTY_GETTER(kABBirthdayProperty)
+DEFINE_ABPERSON_PROPERTY_GETTER(kABBirthdayComponentsProperty)
+DEFINE_ABPERSON_PROPERTY_GETTER(kABJobTitleProperty)
+DEFINE_ABPERSON_PROPERTY_GETTER(kABHomePageProperty)
+DEFINE_ABPERSON_PROPERTY_GETTER(kABURLsProperty)
+DEFINE_ABPERSON_PROPERTY_GETTER(kABCalendarURIsProperty)
+DEFINE_ABPERSON_PROPERTY_GETTER(kABAddressProperty)
+DEFINE_ABPERSON_PROPERTY_GETTER(kABOtherDatesProperty)
+DEFINE_ABPERSON_PROPERTY_GETTER(kABOtherDateComponentsProperty)
+DEFINE_ABPERSON_PROPERTY_GETTER(kABRelatedNamesProperty)
+DEFINE_ABPERSON_PROPERTY_GETTER(kABDepartmentProperty)
+DEFINE_ABPERSON_PROPERTY_GETTER(kABInstantMessageProperty)
+DEFINE_ABPERSON_PROPERTY_GETTER(kABNoteProperty)
+DEFINE_ABPERSON_PROPERTY_GETTER(kABSocialProfileProperty)
+DEFINE_ABPERSON_PROPERTY_GETTER(kABTitleProperty)
+DEFINE_ABPERSON_PROPERTY_GETTER(kABSuffixProperty)
+
+#define DEFINE_ABLABEL_PROPERTY_GETTER(property) \
+ JNIEXPORT jstring JNICALL \
+ Java_net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery_##property \
+ (JNIEnv *jniEnv, jclass clazz) \
+ { \
+ return (*jniEnv)->NewStringUTF(jniEnv, [((NSString *) property) UTF8String]); \
+ }
+DEFINE_ABLABEL_PROPERTY_GETTER(kABHomePageLabel)
+DEFINE_ABLABEL_PROPERTY_GETTER(kABEmailWorkLabel)
+DEFINE_ABLABEL_PROPERTY_GETTER(kABEmailHomeLabel)
+//DEFINE_ABLABEL_PROPERTY_GETTER(kABEmailMobileMeLabel)
+DEFINE_ABLABEL_PROPERTY_GETTER(kABAddressHomeLabel)
+DEFINE_ABLABEL_PROPERTY_GETTER(kABAddressWorkLabel)
+DEFINE_ABLABEL_PROPERTY_GETTER(kABAnniversaryLabel)
+DEFINE_ABLABEL_PROPERTY_GETTER(kABFatherLabel)
+DEFINE_ABLABEL_PROPERTY_GETTER(kABMotherLabel)
+DEFINE_ABLABEL_PROPERTY_GETTER(kABParentLabel)
+DEFINE_ABLABEL_PROPERTY_GETTER(kABBrotherLabel)
+DEFINE_ABLABEL_PROPERTY_GETTER(kABSisterLabel)
+DEFINE_ABLABEL_PROPERTY_GETTER(kABChildLabel)
+DEFINE_ABLABEL_PROPERTY_GETTER(kABFriendLabel)
+DEFINE_ABLABEL_PROPERTY_GETTER(kABSpouseLabel)
+DEFINE_ABLABEL_PROPERTY_GETTER(kABPartnerLabel)
+DEFINE_ABLABEL_PROPERTY_GETTER(kABAssistantLabel)
+DEFINE_ABLABEL_PROPERTY_GETTER(kABManagerLabel)
+DEFINE_ABLABEL_PROPERTY_GETTER(kABPhoneWorkLabel)
+DEFINE_ABLABEL_PROPERTY_GETTER(kABPhoneHomeLabel)
+DEFINE_ABLABEL_PROPERTY_GETTER(kABPhoneiPhoneLabel)
+DEFINE_ABLABEL_PROPERTY_GETTER(kABPhoneMobileLabel)
+DEFINE_ABLABEL_PROPERTY_GETTER(kABPhoneMainLabel)
+DEFINE_ABLABEL_PROPERTY_GETTER(kABPhoneHomeFAXLabel)
+DEFINE_ABLABEL_PROPERTY_GETTER(kABPhoneWorkFAXLabel)
+DEFINE_ABLABEL_PROPERTY_GETTER(kABPhonePagerLabel)
+DEFINE_ABLABEL_PROPERTY_GETTER(kABAIMWorkLabel)
+DEFINE_ABLABEL_PROPERTY_GETTER(kABAIMHomeLabel)
+//DEFINE_ABLABEL_PROPERTY_GETTER(kABAIMMobileMeLabel)
+DEFINE_ABLABEL_PROPERTY_GETTER(kABJabberWorkLabel)
+DEFINE_ABLABEL_PROPERTY_GETTER(kABJabberHomeLabel)
+DEFINE_ABLABEL_PROPERTY_GETTER(kABMSNWorkLabel)
+DEFINE_ABLABEL_PROPERTY_GETTER(kABMSNHomeLabel)
+DEFINE_ABLABEL_PROPERTY_GETTER(kABYahooWorkLabel)
+DEFINE_ABLABEL_PROPERTY_GETTER(kABYahooHomeLabel)
+DEFINE_ABLABEL_PROPERTY_GETTER(kABICQWorkLabel)
+DEFINE_ABLABEL_PROPERTY_GETTER(kABICQHomeLabel)
+DEFINE_ABLABEL_PROPERTY_GETTER(kABInstantMessageServiceAIM)
+DEFINE_ABLABEL_PROPERTY_GETTER(kABInstantMessageServiceFacebook)
+DEFINE_ABLABEL_PROPERTY_GETTER(kABInstantMessageServiceGoogleTalk)
+DEFINE_ABLABEL_PROPERTY_GETTER(kABInstantMessageServiceICQ)
+DEFINE_ABLABEL_PROPERTY_GETTER(kABInstantMessageServiceJabber)
+DEFINE_ABLABEL_PROPERTY_GETTER(kABInstantMessageServiceMSN)
+DEFINE_ABLABEL_PROPERTY_GETTER(kABInstantMessageServiceSkype)
+DEFINE_ABLABEL_PROPERTY_GETTER(kABInstantMessageServiceYahoo)
+DEFINE_ABLABEL_PROPERTY_GETTER(kABAddressStreetKey)
+DEFINE_ABLABEL_PROPERTY_GETTER(kABAddressCityKey)
+DEFINE_ABLABEL_PROPERTY_GETTER(kABAddressZIPKey)
+DEFINE_ABLABEL_PROPERTY_GETTER(kABAddressCountryKey)
+DEFINE_ABLABEL_PROPERTY_GETTER(kABWorkLabel)
+DEFINE_ABLABEL_PROPERTY_GETTER(kABHomeLabel)
+DEFINE_ABLABEL_PROPERTY_GETTER(kABOtherLabel)
+DEFINE_ABLABEL_PROPERTY_GETTER(kABMobileMeLabel)
+DEFINE_ABLABEL_PROPERTY_GETTER(kABInstantMessageUsernameKey)
+DEFINE_ABLABEL_PROPERTY_GETTER(kABInstantMessageServiceKey)
static void
MacOSXAddrBookContactQuery_idToJObject
@@ -185,7 +470,8 @@ MacOSXAddrBookContactQuery_idToJObject
jobjectArray joArray
= (*jniEnv)->NewObjectArray(
jniEnv,
- mvCount * 2 /* value, label */, objectClass, NULL);
+ mvCount * 2 /* value, label */,
+ objectClass, NULL);
jo = joArray;
if (joArray)
@@ -195,6 +481,10 @@ MacOSXAddrBookContactQuery_idToJObject
for (j = 0; j < mvCount; j++)
{
j2 = j * 2;
+
+ //NSLog(@"key:%@, label:%@",
+ // [mv valueAtIndex:j], [mv labelAtIndex:j]);
+
MacOSXAddrBookContactQuery_idToJObject(
jniEnv,
[mv valueAtIndex:j],
@@ -240,8 +530,58 @@ MacOSXAddrBookContactQuery_idToJObject
}
}
}
+ else if ([o isKindOfClass:[NSDictionary class]])
+ {
+ NSDictionary *dict = (NSDictionary *)o;
+
+ NSUInteger dictCount = [dict count];
+ jobjectArray joArray
+ = (*jniEnv)->NewObjectArray(
+ jniEnv,
+ dictCount * 2, objectClass, NULL);
+ jo = joArray;
+ if (joArray)
+ {
+ NSEnumerator *enumerator = [dict keyEnumerator];
+ id key;
+ NSUInteger j, j2;
+ j = 0;
+ while ((key = [enumerator nextObject]))
+ {
+ //NSLog(@"key:%@, value:%@", key, [dict objectForKey: key]);
+
+ j2 = j * 2;
+
+ MacOSXAddrBookContactQuery_idToJObject(
+ jniEnv,
+ [dict objectForKey: key],
+ joArray, j2,
+ objectClass);
+ if (JNI_TRUE == (*jniEnv)->ExceptionCheck(jniEnv))
+ {
+ jo = NULL;
+ break;
+ }
+ MacOSXAddrBookContactQuery_idToJObject(
+ jniEnv,
+ key,
+ joArray, j2 + 1,
+ objectClass);
+ if (JNI_TRUE == (*jniEnv)->ExceptionCheck(jniEnv))
+ {
+ jo = NULL;
+ break;
+ }
+
+ j++;
+ }
+ }
+ }
else
+ {
+ //NSLog(@"type:%@", NSStringFromClass([o class]));
jo = NULL;
+ }
if (jo)
(*jniEnv)->SetObjectArrayElement(jniEnv, jos, i, jo);
}
diff --git a/src/native/addrbook/macosx/net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactSourceService.h b/src/native/addrbook/macosx/net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactSourceService.h
index ae75978..f200da0 100644
--- a/src/native/addrbook/macosx/net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactSourceService.h
+++ b/src/native/addrbook/macosx/net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactSourceService.h
@@ -23,6 +23,14 @@ JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_plugin_addrbook_macosx_Ma
JNIEXPORT void JNICALL Java_net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactSourceService_stop
(JNIEnv *, jclass, jlong);
+/*
+ * Class: net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactSourceService
+ * Method: setDelegate
+ * Signature: (JLnet/java/sip/communicator/plugin/addrbook/macosx/MacOSXAddrBookContactSourceService/NotificationsDelegate;)V
+ */
+JNIEXPORT void JNICALL Java_net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactSourceService_setDelegate
+ (JNIEnv *, jclass, jlong, jobject);
+
#ifdef __cplusplus
}
#endif
diff --git a/src/native/addrbook/macosx/net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactSourceService.m b/src/native/addrbook/macosx/net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactSourceService.m
index 6645bc5..1a769ce 100644
--- a/src/native/addrbook/macosx/net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactSourceService.m
+++ b/src/native/addrbook/macosx/net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactSourceService.m
@@ -8,16 +8,24 @@
#include "net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactSourceService.h"
#import <AddressBook/ABGlobals.h>
+#import <AddressBook/AddressBook.h>
#import <Foundation/NSAutoreleasePool.h>
#import <Foundation/NSNotification.h>
#import <Foundation/NSObject.h>
@interface MacOSXAddrBookContactSourceService : NSObject
{
+@private
+ jobject delegateObject;
+ JavaVM *vm;
}
- (void)abDatabaseChangedExternallyNotification:(NSNotification *)notification;
- (void)abDatabaseChangedNotification:(NSNotification *)notification;
+
+-(void)clean;
+-(void) setDelegate:(jobject)delegate inJNIEnv:(JNIEnv *)jniEnv;
+-(void) notify:(id)param methodName:(NSString *)mtdName;
@end /* MacOSXAddrBookContactSourceService */
JNIEXPORT jlong JNICALL
@@ -62,14 +70,191 @@ Java_net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactSourc
pool = [[NSAutoreleasePool alloc] init];
[[NSNotificationCenter defaultCenter] removeObserver:mabcss];
+ [mabcss clean];
[mabcss release];
[pool release];
}
+/*
+ * Class: net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactSourceService
+ * Method: setDelegate
+ * Signature: (JLnet/java/sip/communicator/plugin/addrbook/macosx/MacOSXAddrBookContactSourceService/NotificationsDelegate;)V
+ */
+JNIEXPORT void JNICALL Java_net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactSourceService_setDelegate
+ (JNIEnv *jniEnv, jclass clazz, jlong ptr, jobject m_delegate)
+{
+ MacOSXAddrBookContactSourceService *oDelegate;
+
+ if (m_delegate)
+ {
+ oDelegate = (MacOSXAddrBookContactSourceService *) ptr;
+ [oDelegate setDelegate:m_delegate inJNIEnv:jniEnv];
+ }
+ else
+ oDelegate = nil;
+}
+
@implementation MacOSXAddrBookContactSourceService
+- (void)clean
+{
+ [self setDelegate:NULL inJNIEnv:NULL];
+}
+
+- (void)setDelegate:(jobject) delegate inJNIEnv:(JNIEnv *)jniEnv
+{
+ if (self->delegateObject)
+ {
+ if (!jniEnv)
+ (*(self->vm))->AttachCurrentThread(self->vm, (void **)&jniEnv, NULL);
+ (*jniEnv)->DeleteGlobalRef(jniEnv, self->delegateObject);
+ self->delegateObject = NULL;
+ self->vm = NULL;
+ }
+ if (delegate)
+ {
+ delegate = (*jniEnv)->NewGlobalRef(jniEnv, delegate);
+ if (delegate)
+ {
+ (*jniEnv)->GetJavaVM(jniEnv, &(self->vm));
+ self->delegateObject = delegate;
+ }
+ }
+}
+
+-(void) notify:(id)param methodName:(NSString *)mName
+{
+ jobject delegate;
+ JNIEnv *jniEnv;
+ jclass delegateClass = NULL;
+
+ delegate = self->delegateObject;
+ if (!delegate)
+ return;
+
+ vm = self->vm;
+ if (0 != (*vm)->AttachCurrentThreadAsDaemon(vm, (void **)&jniEnv, NULL))
+ return;
+
+ delegateClass = (*jniEnv)->GetObjectClass(jniEnv, delegate);
+ if(delegateClass)
+ {
+ jmethodID methodid = NULL;
+
+ if ([param isKindOfClass:[NSString class]])
+ {
+ methodid = (*jniEnv)->GetMethodID(jniEnv,
+ delegateClass,
+ [mName UTF8String],
+ "(Ljava/lang/String;)V");
+
+ if(methodid)
+ (*jniEnv)->CallVoidMethod(jniEnv,
+ delegate,
+ methodid,
+ (*jniEnv)->NewStringUTF(
+ jniEnv,
+ [param UTF8String]));
+
+ }
+ else
+ {
+ methodid = (*jniEnv)->GetMethodID(jniEnv,
+ delegateClass,
+ [mName UTF8String],
+ "(J)V");
+ if(methodid)
+ (*jniEnv)->CallVoidMethod(jniEnv,
+ delegate,
+ methodid,
+ (jlong)param);
+ }
+ }
+ (*jniEnv)->ExceptionClear(jniEnv);
+}
+
- (void)abDatabaseChangedExternallyNotification:(NSNotification *)notification
{
+ ABAddressBook *addressBook;
+ id inserted =
+ [[notification userInfo] objectForKey:kABInsertedRecords];
+ id updated =
+ [[notification userInfo] objectForKey:kABUpdatedRecords];
+ id deleted =
+ [[notification userInfo] objectForKey:kABDeletedRecords];
+
+ addressBook = [ABAddressBook sharedAddressBook];
+
+ NSUInteger peopleCount;
+ NSUInteger i;
+ NSString *personID;
+
+ if (inserted)
+ {
+ NSArray *people;
+
+ if ([inserted isKindOfClass:[NSArray class]])
+ {
+ people = inserted;
+ } else
+ {
+ people = [NSArray arrayWithObject:(ABPerson *)[addressBook recordForUniqueId:inserted]];
+ }
+
+ peopleCount = [people count];
+ for (i = 0; i < peopleCount; i++)
+ {
+ personID = [people objectAtIndex:i];
+ ABPerson *person =
+ (ABPerson *)[addressBook recordForUniqueId:personID];
+ [self notify:person methodName:@"inserted"];
+ }
+ }
+
+ if (updated)
+ {
+ NSArray *people;
+
+ if ([updated isKindOfClass:[NSArray class]])
+ {
+ people = updated;
+ }
+ else
+ {
+ people = [NSArray arrayWithObject:(ABPerson *)[addressBook recordForUniqueId:updated]];
+ }
+
+ peopleCount = [people count];
+ for (i = 0; i < peopleCount; i++)
+ {
+ personID = [people objectAtIndex:i];
+ ABPerson *person =
+ (ABPerson *)[addressBook recordForUniqueId:personID];
+ [self notify:person methodName:@"updated"];
+ }
+ }
+
+ if (deleted)
+ {
+ NSArray *people;
+
+ if ([deleted isKindOfClass:[NSArray class]])
+ {
+ people = deleted;
+ }
+ else
+ {
+ people = [NSArray arrayWithObject:(ABPerson *)[addressBook recordForUniqueId:deleted]];
+ }
+
+ peopleCount = [people count];
+ for (i = 0; i < peopleCount; i++)
+ {
+ personID = [people objectAtIndex:i];
+
+ [self notify:personID methodName:@"deleted"];
+ }
+ }
}
- (void)abDatabaseChangedNotification:(NSNotification *)notification
diff --git a/src/net/java/sip/communicator/impl/netaddr/NetworkConfigurationWatcher.java b/src/net/java/sip/communicator/impl/netaddr/NetworkConfigurationWatcher.java
index 502ee39..d96d09a 100644
--- a/src/net/java/sip/communicator/impl/netaddr/NetworkConfigurationWatcher.java
+++ b/src/net/java/sip/communicator/impl/netaddr/NetworkConfigurationWatcher.java
@@ -69,7 +69,7 @@ public class NetworkConfigurationWatcher
{
try
{
- checkNetworkInterfaces(false, 0);
+ checkNetworkInterfaces(false, 0, true);
} catch (SocketException e)
{
logger.error("Error checking network interfaces", e);
@@ -341,7 +341,7 @@ public class NetworkConfigurationWatcher
{
try
{
- checkNetworkInterfaces(true, 0);
+ checkNetworkInterfaces(true, 0, true);
} catch (SocketException e)
{
logger.error("Error checking network interfaces", e);
@@ -385,10 +385,14 @@ public class NetworkConfigurationWatcher
* @param waitBeforeFiringUpEvents milliseconds to wait before
* firing events for interfaces up, sometimes we must wait a little bit
* and give time for interfaces to configure fully (dns on linux).
+ * @param printDebugInfo whether to print debug info, do not print
+ * anything if we are constantly checking as it will flood logs and made
+ * them unusable.
*/
private void checkNetworkInterfaces(
boolean fireEvents,
- int waitBeforeFiringUpEvents)
+ int waitBeforeFiringUpEvents,
+ boolean printDebugInfo)
throws SocketException
{
Enumeration<NetworkInterface> e =
@@ -429,7 +433,7 @@ public class NetworkConfigurationWatcher
}
// add network debug info, to track wake up problems
- if(logger.isInfoEnabled())
+ if(logger.isInfoEnabled() && printDebugInfo)
{
for(Map.Entry<String, List<InetAddress>> en :
activeInterfaces.entrySet())
@@ -627,7 +631,7 @@ public class NetworkConfigurationWatcher
{
boolean networkIsUP = activeInterfaces.size() > 0;
- checkNetworkInterfaces(true, 1000);
+ checkNetworkInterfaces(true, 1000, false);
// fire that network has gone up
if(!networkIsUP && activeInterfaces.size() > 0)
diff --git a/src/net/java/sip/communicator/plugin/addrbook/AbstractAddrBookContactQuery.java b/src/net/java/sip/communicator/plugin/addrbook/AbstractAddrBookContactQuery.java
new file mode 100644
index 0000000..74ff461
--- /dev/null
+++ b/src/net/java/sip/communicator/plugin/addrbook/AbstractAddrBookContactQuery.java
@@ -0,0 +1,122 @@
+/*
+ * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package net.java.sip.communicator.plugin.addrbook;
+
+import net.java.sip.communicator.service.contactsource.*;
+
+import java.util.*;
+import java.util.regex.*;
+
+/**
+ * Abstract query that keep tracks of the source contacts
+ * that were created.
+ *
+ * @author Damian Minkov
+ */
+public abstract class AbstractAddrBookContactQuery<T extends ContactSourceService>
+ extends AsyncContactQuery<T>
+{
+ /**
+ * The key we used for the id of the source contact.
+ */
+ protected static final String SOURCE_CONTACT_ID_DATA_KEY =
+ AbstractAddrBookContactQuery.class.getName() + ".id";
+
+ /**
+ * A list of all source contact results.
+ */
+ protected final List<SourceContact> sourceContacts
+ = new LinkedList<SourceContact>();
+
+ /**
+ * Initializes a new <tt>AbstractAddrBookContactQuery</tt> which is to perform
+ * a specific <tt>query</tt> in the Address Book on behalf of a
+ * specific <tt>ContactSourceService</tt>.
+ *
+ * @param contactSource the <tt>ContactSourceService</tt> which is to
+ * perform the new <tt>ContactQuery</tt> instance
+ * @param query the <tt>Pattern</tt> for which <tt>contactSource</tt> is
+ * being queried
+ **/
+ public AbstractAddrBookContactQuery(
+ T contactSource,
+ Pattern query)
+ {
+ super(contactSource, query);
+ }
+
+ /**
+ * Notifies the <tt>ContactQueryListener</tt>s registered with this
+ * <tt>ContactQuery</tt> that a new <tt>SourceContact</tt> has been
+ * received.
+ *
+ * @param contact the <tt>SourceContact</tt> which has been received and
+ * which the registered <tt>ContactQueryListener</tt>s are to be notified
+ * about
+ */
+ protected void fireContactReceived(SourceContact contact)
+ {
+ synchronized (sourceContacts)
+ {
+ sourceContacts.add(contact);
+ }
+
+ super.fireContactReceived(contact);
+ }
+
+ /**
+ * Notifies the <tt>ContactQueryListener</tt>s registered with this
+ * <tt>ContactQuery</tt> that a <tt>SourceContact</tt> has been
+ * removed.
+ *
+ * @param contact the <tt>SourceContact</tt> which has been removed and
+ * which the registered <tt>ContactQueryListener</tt>s are to be notified
+ * about
+ */
+ protected void fireContactRemoved(SourceContact contact)
+ {
+ synchronized (sourceContacts)
+ {
+ sourceContacts.remove(contact);
+ }
+
+ super.fireContactRemoved(contact);
+ }
+
+ /**
+ * Clear.
+ */
+ public void clear()
+ {
+ synchronized (sourceContacts)
+ {
+ sourceContacts.clear();
+ }
+ }
+
+ /**
+ * Searches for source contact with the specified id.
+ * @param id the id to search for
+ * @return the source contact found or null.
+ */
+ protected SourceContact findSourceContactByID(String id)
+ {
+ synchronized(sourceContacts)
+ {
+ for(SourceContact sc : sourceContacts)
+ {
+ Object scID = sc.getData(SOURCE_CONTACT_ID_DATA_KEY);
+
+ if(id.equals(scID))
+ return sc;
+ }
+ }
+
+ // not found
+ return null;
+ }
+}
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 f3ad1c5..b9c4afa 100644
--- a/src/net/java/sip/communicator/plugin/addrbook/macosx/MacOSXAddrBookContactQuery.java
+++ b/src/net/java/sip/communicator/plugin/addrbook/macosx/MacOSXAddrBookContactQuery.java
@@ -12,6 +12,7 @@ import java.util.regex.*;
import net.java.sip.communicator.plugin.addrbook.*;
import net.java.sip.communicator.service.contactsource.*;
import net.java.sip.communicator.service.protocol.*;
+import net.java.sip.communicator.util.*;
/**
* Implements <tt>ContactQuery</tt> for the Address Book of Mac OS X.
@@ -19,14 +20,20 @@ import net.java.sip.communicator.service.protocol.*;
* @author Lyubomir Marinov
*/
public class MacOSXAddrBookContactQuery
- extends AsyncContactQuery<MacOSXAddrBookContactSourceService>
+ extends AbstractAddrBookContactQuery<MacOSXAddrBookContactSourceService>
{
+ /**
+ * The <tt>Logger</tt> used by the <tt>MacOSXAddrBookContactQuery</tt> class
+ * and its instances for logging output.
+ */
+ private static final Logger logger
+ = Logger.getLogger(MacOSXAddrBookContactQuery.class);
/**
* The properties of <tt>ABPerson</tt> which are to be queried by the
* <tt>MacOSXAddrBookContactQuery</tt> instances.
*/
- private static final long[] ABPERSON_PROPERTIES
+ public static final long[] ABPERSON_PROPERTIES
= new long[]
{
kABAIMInstantProperty(),
@@ -44,7 +51,24 @@ public class MacOSXAddrBookContactQuery
kABPhoneProperty(),
kABYahooInstantProperty(),
kABPersonFlags(),
- kABOrganizationProperty()
+ kABOrganizationProperty(),
+ kABMaidenNameProperty(),
+ kABBirthdayProperty(),
+ kABBirthdayComponentsProperty(),
+ kABJobTitleProperty(),
+ kABHomePageProperty(),
+ kABURLsProperty(),
+ kABCalendarURIsProperty(),
+ kABAddressProperty(),
+ kABOtherDatesProperty(),
+ kABOtherDateComponentsProperty(),
+ kABRelatedNamesProperty(),
+ kABDepartmentProperty(),
+ kABInstantMessageProperty(),
+ kABNoteProperty(),
+ kABSocialProfileProperty(),
+ kABTitleProperty(),
+ kABSuffixProperty()
};
/**
@@ -156,22 +180,106 @@ public class MacOSXAddrBookContactQuery
private static final int kABYahooInstantProperty = 13;
/**
- * The indexes in {@link #ABPERSON_PROPERTIES} of the properties which are
- * to be represented in <tt>SourceContact</tt> as <tt>ContactDetail</tt>s.
+ * The index of the <tt>kABMaidenNameProperty</tt> <tt>ABPerson</tt>
+ * property in {@link #ABPERSON_PROPERTIES}.
*/
- private static final int[] CONTACT_DETAIL_PROPERTY_INDEXES
- = new int[]
- {
- kABEmailProperty,
+ private static final int kABMaidenNameProperty = 16;
- kABPhoneProperty,
+ /**
+ * The index of the <tt>kABBirthdayProperty</tt> <tt>ABPerson</tt>
+ * property in {@link #ABPERSON_PROPERTIES}.
+ */
+ private static final int kABBirthdayProperty = 17;
- kABAIMInstantProperty,
- kABICQInstantProperty,
- kABJabberInstantProperty,
- kABMSNInstantProperty,
- kABYahooInstantProperty
- };
+ /**
+ * The index of the <tt>kABBirthdayComponentsProperty</tt> <tt>ABPerson</tt>
+ * property in {@link #ABPERSON_PROPERTIES}.
+ */
+ private static final int kABBirthdayComponentsProperty = 18;
+
+ /**
+ * The index of the <tt>kABJobTitleProperty</tt> <tt>ABPerson</tt>
+ * property in {@link #ABPERSON_PROPERTIES}.
+ */
+ private static final int kABJobTitleProperty = 19;
+
+ /**
+ * The index of the <tt>kABHomePageProperty</tt> <tt>ABPerson</tt>
+ * property in {@link #ABPERSON_PROPERTIES}.
+ */
+ private static final int kABHomePageProperty = 20;
+
+ /**
+ * The index of the <tt>kABURLsProperty</tt> <tt>ABPerson</tt>
+ * property in {@link #ABPERSON_PROPERTIES}.
+ */
+ private static final int kABURLsProperty = 21;
+
+ /**
+ * The index of the <tt>kABCalendarURIsProperty</tt> <tt>ABPerson</tt>
+ * property in {@link #ABPERSON_PROPERTIES}.
+ */
+ private static final int kABCalendarURIsProperty = 22;
+
+ /**
+ * The index of the <tt>kABAddressProperty</tt> <tt>ABPerson</tt>
+ * property in {@link #ABPERSON_PROPERTIES}.
+ */
+ private static final int kABAddressProperty = 23;
+
+ /**
+ * The index of the <tt>kABOtherDatesProperty</tt> <tt>ABPerson</tt>
+ * property in {@link #ABPERSON_PROPERTIES}.
+ */
+ private static final int kABOtherDatesProperty = 24;
+
+ /**
+ * The index of the <tt>kABOtherDateComponentsProperty</tt> <tt>ABPerson</tt>
+ * property in {@link #ABPERSON_PROPERTIES}.
+ */
+ private static final int kABOtherDateComponentsProperty = 25;
+
+ /**
+ * The index of the <tt>kABRelatedNamesProperty</tt> <tt>ABPerson</tt>
+ * property in {@link #ABPERSON_PROPERTIES}.
+ */
+ private static final int kABRelatedNamesProperty = 26;
+
+ /**
+ * The index of the <tt>kABDepartmentProperty</tt> <tt>ABPerson</tt>
+ * property in {@link #ABPERSON_PROPERTIES}.
+ */
+ private static final int kABDepartmentProperty = 27;
+
+ /**
+ * The index of the <tt>kABInstantMessageProperty</tt> <tt>ABPerson</tt>
+ * property in {@link #ABPERSON_PROPERTIES}.
+ */
+ private static final int kABInstantMessageProperty = 28;
+
+ /**
+ * The index of the <tt>kABNoteProperty</tt> <tt>ABPerson</tt>
+ * property in {@link #ABPERSON_PROPERTIES}.
+ */
+ private static final int kABNoteProperty = 29;
+
+ /**
+ * The index of the <tt>kABSocialProfileProperty</tt> <tt>ABPerson</tt>
+ * property in {@link #ABPERSON_PROPERTIES}.
+ */
+ private static final int kABSocialProfileProperty = 30;
+
+ /**
+ * The index of the <tt>kABTitleProperty</tt> <tt>ABPerson</tt>
+ * property in {@link #ABPERSON_PROPERTIES}.
+ */
+ private static final int kABTitleProperty = 31;
+
+ /**
+ * The index of the <tt>kABSuffixProperty</tt> <tt>ABPerson</tt>
+ * property in {@link #ABPERSON_PROPERTIES}.
+ */
+ private static final int kABSuffixProperty = 32;
/**
* The regex which matches the superfluous parts of an <tt>ABMultiValue</tt>
@@ -212,7 +320,7 @@ public class MacOSXAddrBookContactQuery
* @return the <tt>imageData</tt> of the specified <tt>ABPerson</tt>
* instance
*/
- private static native byte[] ABPerson_imageData(long person);
+ public static native byte[] ABPerson_imageData(long person);
/**
* Gets the values of a specific set of <tt>ABRecord</tt> properties for a
@@ -225,11 +333,37 @@ public class MacOSXAddrBookContactQuery
* @return the values of the specified set of <tt>ABRecord</tt> properties
* for the specified <tt>ABRecord</tt> instance
*/
- private static native Object[] ABRecord_valuesForProperties(
+ public static native Object[] ABRecord_valuesForProperties(
long record,
long[] properties);
/**
+ * Returns the unique id of a record.
+ * @param record the record which id is retrieved.
+ * @return the record id.
+ */
+ public static native String ABRecord_uniqueId(long record);
+
+ /**
+ * Sets property for the supplied person id.
+ * @param id the person id
+ * @param property the property to use.
+ * @param subPropety any sub property if available.
+ * @param value the value to set.
+ * @return whether the result was successfully added.
+ */
+ public static native boolean setProperty(
+ String id, long property, String subPropety, Object value);
+
+ /**
+ * Remove a property.
+ * @param id the person id.
+ * @param property the property.
+ * @return whether the result was successfully removed.
+ */
+ public static native boolean removeProperty(String id, long property);
+
+ /**
* Initializes a new <tt>ContactDetail</tt> instance which is to reperesent
* a specific contact address that is the value of a specific
* <tt>ABPerson</tt> property and, optionally, has a specific label.
@@ -246,7 +380,8 @@ public class MacOSXAddrBookContactQuery
private ContactDetail createContactDetail(
int property,
String contactAddress,
- Object label)
+ Object label,
+ String additionalProperty)
{
ContactDetail.Category c;
ContactDetail.SubCategory sc = null;
@@ -279,6 +414,58 @@ public class MacOSXAddrBookContactQuery
sc = ContactDetail.SubCategory.Yahoo;
c = ContactDetail.Category.InstantMessaging;
break;
+ case kABInstantMessageProperty:
+ sc = ContactDetail.SubCategory.fromString(contactAddress);
+ c = ContactDetail.Category.InstantMessaging;
+ break;
+ case kABMaidenNameProperty:
+ case kABFirstNameProperty:
+ sc = ContactDetail.SubCategory.Name;
+ c = ContactDetail.Category.Personal;
+ break;
+ case kABFirstNamePhoneticProperty:
+ sc = ContactDetail.SubCategory.Name;
+ c = ContactDetail.Category.Personal;
+ break;
+ case kABLastNameProperty:
+ sc = ContactDetail.SubCategory.LastName;
+ c = ContactDetail.Category.Personal;
+ break;
+ case kABLastNamePhoneticProperty:
+ sc = ContactDetail.SubCategory.LastName;
+ c = ContactDetail.Category.Personal;
+ break;
+ case kABMiddleNameProperty:
+ case kABMiddleNamePhoneticProperty:
+ case kABNicknameProperty:
+ sc = ContactDetail.SubCategory.Nickname;
+ c = ContactDetail.Category.Personal;
+ break;
+ case kABBirthdayProperty:
+ case kABURLsProperty:
+ case kABHomePageProperty:
+ sc = ContactDetail.SubCategory.HomePage;
+ c = ContactDetail.Category.Personal;
+ break;
+ case kABOtherDatesProperty:
+ case kABRelatedNamesProperty:
+ case kABNoteProperty:
+ case kABSocialProfileProperty:
+ case kABTitleProperty:
+ case kABSuffixProperty:
+ c = ContactDetail.Category.Personal;
+ break;
+ case kABOrganizationProperty:
+ case kABJobTitleProperty:
+ sc = ContactDetail.SubCategory.JobTitle;
+ c = ContactDetail.Category.Organization;
+ break;
+ case kABDepartmentProperty:
+ c = ContactDetail.Category.Organization;
+ break;
+ case kABAddressProperty:
+ c = ContactDetail.Category.Address;
+ break;
default:
c = null;
break;
@@ -294,8 +481,12 @@ public class MacOSXAddrBookContactQuery
}
}
- return new ContactDetail(contactAddress,
- c, new ContactDetail.SubCategory[] { sc });
+ return new AddressBookContactDetail(
+ property,
+ contactAddress,
+ c,
+ new ContactDetail.SubCategory[] { sc },
+ additionalProperty);
}
/**
@@ -367,9 +558,9 @@ public class MacOSXAddrBookContactQuery
{
List<ContactDetail> contactDetails = new LinkedList<ContactDetail>();
- for (int i = 0; i < CONTACT_DETAIL_PROPERTY_INDEXES.length; i++)
+ for (int i = 0; i < ABPERSON_PROPERTIES.length; i++)
{
- int property = CONTACT_DETAIL_PROPERTY_INDEXES[i];
+ int property = i;
Object value = values[property];
if (value instanceof String)
@@ -387,45 +578,84 @@ public class MacOSXAddrBookContactQuery
createContactDetail(
property,
stringValue,
+ null,
null),
property));
}
}
else if (value instanceof Object[])
{
- Object[] multiValue = (Object[]) value;
+ parseMultiDetails(contactDetails,
+ (Object[]) value,
+ property,
+ null);
+ }
+ }
+ return contactDetails;
+ }
- for (int multiValueIndex = 0;
- multiValueIndex < multiValue.length;
- multiValueIndex += 2)
- {
- Object subValue = multiValue[multiValueIndex];
+ /**
+ * Parses the multi value data resulting it in contact details.
+ * @param contactDetails the result list
+ * @param multiValue the values to parse.
+ * @param property the current property being parsed.
+ */
+ private void parseMultiDetails(
+ List<ContactDetail> contactDetails,
+ Object[] multiValue,
+ int property,
+ String label)
+ {
+ if(multiValue == null)
+ return;
- if (subValue instanceof String)
- {
- String stringSubValue = (String) subValue;
+ for (int multiValueIndex = 0;
+ multiValueIndex < multiValue.length;
+ multiValueIndex += 2)
+ {
+ Object subValue = multiValue[multiValueIndex];
- if (stringSubValue.length() != 0)
- {
- if (kABPhoneProperty == property)
- {
- stringSubValue = PhoneNumberI18nService
- .normalize(stringSubValue);
- }
+ if (subValue instanceof String)
+ {
+ String stringSubValue = (String) subValue;
- contactDetails.add(
- setCapabilities(
- createContactDetail(
- property,
- stringSubValue,
- multiValue[multiValueIndex + 1]),
- property));
- }
+ if (stringSubValue.length() != 0)
+ {
+ if (kABPhoneProperty == property)
+ {
+ stringSubValue = PhoneNumberI18nService
+ .normalize(stringSubValue);
}
+
+ Object l = multiValue[multiValueIndex + 1];
+
+ if(kABInstantMessageServiceKey().equals(l))
+ continue;
+
+ contactDetails.add(
+ setCapabilities(
+ createContactDetail(
+ property,
+ stringSubValue,
+ l,
+ label),
+ property));
}
}
+ else if (subValue instanceof Object[])
+ {
+ String l = null;
+
+ Object lObject = multiValue[multiValueIndex + 1];
+ if(lObject instanceof String)
+ l = (String)lObject;
+
+ parseMultiDetails(contactDetails,
+ (Object[]) subValue,
+ property,
+ l);
+ }
}
- return contactDetails;
}
/**
@@ -438,7 +668,7 @@ public class MacOSXAddrBookContactQuery
* @return the <tt>displayName</tt> to be set on a <tt>SourceContact</tt>
* which is to represent the <tt>ABPerson</tt> specified by <tt>values</tt>
*/
- private String getDisplayName(Object[] values)
+ static String getDisplayName(Object[] values)
{
long personFlags
= (values[kABPersonFlags] instanceof Long)
@@ -501,9 +731,9 @@ public class MacOSXAddrBookContactQuery
if (displayName.length() != 0)
return displayName;
- for (int i = 0; i < CONTACT_DETAIL_PROPERTY_INDEXES.length; i++)
+ for (int i = 0; i < ABPERSON_PROPERTIES.length; i++)
{
- Object value = values[CONTACT_DETAIL_PROPERTY_INDEXES[i]];
+ Object value = values[i];
if (value instanceof String)
{
@@ -654,6 +884,154 @@ public class MacOSXAddrBookContactQuery
private static native long kABYahooInstantProperty();
/**
+ * Gets the value of the <tt>kABMaidenNameProperty</tt> constant.
+ *
+ * @return the value of the <tt>kABMaidenNameProperty</tt> constant
+ */
+ private static native long kABMaidenNameProperty();
+
+ /**
+ * Gets the value of the <tt>kABBirthdayProperty</tt> constant.
+ *
+ * @return the value of the <tt>kABBirthdayProperty</tt> constant
+ */
+ private static native long kABBirthdayProperty();
+
+ /**
+ * Gets the value of the <tt>kABBirthdayComponentsProperty</tt> constant.
+ *
+ * @return the value of the <tt>kABBirthdayComponentsProperty</tt> constant
+ */
+ private static native long kABBirthdayComponentsProperty();
+
+ /**
+ * Gets the value of the <tt>kABJobTitleProperty</tt> constant.
+ *
+ * @return the value of the <tt>kABJobTitleProperty</tt> constant
+ */
+ private static native long kABJobTitleProperty();
+
+ /**
+ * Gets the value of the <tt>kABHomePageProperty</tt> constant.
+ *
+ * @return the value of the <tt>kABHomePageProperty</tt> constant
+ */
+ private static native long kABHomePageProperty();
+
+ /**
+ * Gets the value of the <tt>kABURLsProperty</tt> constant.
+ *
+ * @return the value of the <tt>kABURLsProperty</tt> constant
+ */
+ private static native long kABURLsProperty();
+
+ /**
+ * Gets the value of the <tt>kABCalendarURIsProperty</tt> constant.
+ *
+ * @return the value of the <tt>kABCalendarURIsProperty</tt> constant
+ */
+ private static native long kABCalendarURIsProperty();
+
+ /**
+ * Gets the value of the <tt>kABAddressProperty</tt> constant.
+ *
+ * @return the value of the <tt>kABAddressProperty</tt> constant
+ */
+ private static native long kABAddressProperty();
+
+ /**
+ * Gets the value of the <tt>kABOtherDatesProperty</tt> constant.
+ *
+ * @return the value of the <tt>kABOtherDatesProperty</tt> constant
+ */
+ private static native long kABOtherDatesProperty();
+
+ /**
+ * Gets the value of the <tt>kABOtherDateComponentsProperty</tt> constant.
+ *
+ * @return the value of the <tt>kABOtherDateComponentsProperty</tt> constant
+ */
+ private static native long kABOtherDateComponentsProperty();
+
+ /**
+ * Gets the value of the <tt>kABRelatedNamesProperty</tt> constant.
+ *
+ * @return the value of the <tt>kABRelatedNamesProperty</tt> constant
+ */
+ private static native long kABRelatedNamesProperty();
+
+ /**
+ * Gets the value of the <tt>kABDepartmentProperty</tt> constant.
+ *
+ * @return the value of the <tt>kABDepartmentProperty</tt> constant
+ */
+ private static native long kABDepartmentProperty();
+
+ /**
+ * Gets the value of the <tt>kABInstantMessageProperty</tt> constant.
+ *
+ * @return the value of the <tt>kABInstantMessageProperty</tt> constant
+ */
+ private static native long kABInstantMessageProperty();
+
+ /**
+ * Gets the value of the <tt>kABNoteProperty</tt> constant.
+ *
+ * @return the value of the <tt>kABNoteProperty</tt> constant
+ */
+ private static native long kABNoteProperty();
+
+ /**
+ * Gets the value of the <tt>kABSocialProfileProperty</tt> constant.
+ *
+ * @return the value of the <tt>kABSocialProfileProperty</tt> constant
+ */
+ private static native long kABSocialProfileProperty();
+
+ /**
+ * Gets the value of the <tt>kABTitleProperty</tt> constant.
+ *
+ * @return the value of the <tt>kABTitleProperty</tt> constant
+ */
+ private static native long kABTitleProperty();
+
+ /**
+ * Gets the value of the <tt>kABSuffixProperty</tt> constant.
+ *
+ * @return the value of the <tt>kABSuffixProperty</tt> constant
+ */
+ private static native long kABSuffixProperty();
+
+ private static native String kABEmailWorkLabel();
+ private static native String kABEmailHomeLabel();
+ private static native String kABAddressHomeLabel();
+ private static native String kABAddressWorkLabel();
+ private static native String kABPhoneWorkLabel();
+ private static native String kABPhoneHomeLabel();
+ private static native String kABPhoneMobileLabel();
+ private static native String kABPhoneMainLabel();
+ private static native String kABPhoneWorkFAXLabel();
+ private static native String kABHomeLabel();
+ private static native String kABWorkLabel();
+ private static native String kABOtherLabel();
+ private static native String kABMobileMeLabel();
+ private static native String kABInstantMessageServiceAIM();
+ private static native String kABInstantMessageServiceFacebook();
+ private static native String kABInstantMessageServiceGoogleTalk();
+ private static native String kABInstantMessageServiceICQ();
+ private static native String kABInstantMessageServiceJabber();
+ private static native String kABInstantMessageServiceMSN();
+ private static native String kABInstantMessageServiceSkype();
+ private static native String kABInstantMessageServiceYahoo();
+ private static native String kABAddressStreetKey();
+ private static native String kABAddressCityKey();
+ private static native String kABAddressZIPKey();
+ private static native String kABAddressCountryKey();
+ private static native String kABInstantMessageUsernameKey();
+ private static native String kABInstantMessageServiceKey();
+
+
+ /**
* Determines whether a specific <tt>ABPerson</tt> property with a specific
* <tt>value</tt> matches the {@link #query} of this
* <tt>AsyncContactQuery</tt>.
@@ -724,8 +1102,9 @@ public class MacOSXAddrBookContactQuery
{
Object[] values
= ABRecord_valuesForProperties(person, ABPERSON_PROPERTIES);
- String displayName = getDisplayName(values);
+ final String id = ABRecord_uniqueId(person);
+ String displayName = getDisplayName(values);
if ((displayName.length() != 0)
&& (query.matcher(displayName).find() || matches(values)))
{
@@ -733,11 +1112,20 @@ public class MacOSXAddrBookContactQuery
if (!contactDetails.isEmpty())
{
- GenericSourceContact sourceContact
- = new GenericSourceContact(
+ final AddressBookSourceContact sourceContact
+ = new AddressBookSourceContact(
getContactSource(),
displayName,
contactDetails);
+ sourceContact.setData(
+ SOURCE_CONTACT_ID_DATA_KEY,
+ id);
+
+ for(ContactDetail cd : contactDetails)
+ {
+ if(cd instanceof AddressBookContactDetail)
+ ((AddressBookContactDetail)cd).setId(id);
+ }
try
{
@@ -848,4 +1236,489 @@ public class MacOSXAddrBookContactQuery
return contactDetail;
}
+
+ /**
+ * Callback method when receiving notifications for inserted items.
+ */
+ public void inserted(long person)
+ {
+ onPerson(person);
+ }
+
+ /**
+ * Callback method when receiving notifications for updated items.
+ */
+ public void updated(long person)
+ {
+ SourceContact sourceContact =
+ findSourceContactByID(ABRecord_uniqueId(person));
+ if(sourceContact != null
+ && sourceContact instanceof AddressBookSourceContact)
+ {
+ // let's update the the details
+ Object[] values
+ = ABRecord_valuesForProperties(person, ABPERSON_PROPERTIES);
+
+ AddressBookSourceContact editableSourceContact
+ = (AddressBookSourceContact)sourceContact;
+
+ List<ContactDetail> contactDetails = getContactDetails(values);
+ editableSourceContact.setDetails(contactDetails);
+
+ fireContactChanged(sourceContact);
+ }
+ }
+
+ /**
+ * Callback method when receiving notifications for deleted items.
+ */
+ public void deleted(String id)
+ {
+ SourceContact sourceContact = findSourceContactByID(id);
+
+ if(sourceContact != null)
+ fireContactRemoved(sourceContact);
+ }
+
+ /**
+ * Whether the value for the category are multiline.
+ * @param category
+ * @return
+ */
+ private boolean isMultiline(AddressBookContactDetail.Category category)
+ {
+ switch(category)
+ {
+ case Personal:
+ return false;
+ case Organization:
+ return false;
+ case Email:
+ return true;
+ case InstantMessaging:
+ return true;
+ case Phone:
+ return true;
+ case Address:
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ /**
+ * Find the property from category and subcategories.
+ *
+ * @param category
+ * @param subCategories
+ * @return
+ */
+ public static int getProperty(
+ AddressBookContactDetail.Category category,
+ Collection<AddressBookContactDetail.SubCategory> subCategories)
+ {
+ switch(category)
+ {
+ case Personal:
+ if(subCategories.contains(ContactDetail.SubCategory.Name))
+ return kABFirstNameProperty;
+ else if(subCategories.contains(ContactDetail.SubCategory.LastName))
+ return kABLastNameProperty;
+ else if(subCategories.contains(ContactDetail.SubCategory.Nickname))
+ return kABLastNameProperty;
+ else if(subCategories.contains(ContactDetail.SubCategory.HomePage))
+ return kABHomePageProperty;
+ break;
+ case Organization:
+ if(subCategories.contains(ContactDetail.SubCategory.JobTitle))
+ return kABJobTitleProperty;
+ else
+ return kABDepartmentProperty;
+ case Email:
+ return kABEmailProperty;
+ case InstantMessaging:
+ return kABInstantMessageProperty;
+ case Phone:
+ return kABPhoneProperty;
+ case Address:
+ return kABAddressProperty;
+ default: return -1;
+ }
+
+ return -1;
+ }
+
+ /**
+ * Finds the label from category and sub categories.
+ * @param subCategory
+ * @return
+ */
+ public static String getLabel(
+ int property,
+ AddressBookContactDetail.SubCategory subCategory)
+ {
+ switch(property)
+ {
+ case kABEmailProperty:
+ if(subCategory == ContactDetail.SubCategory.Home)
+ return kABEmailHomeLabel();
+ if(subCategory == ContactDetail.SubCategory.Work)
+ return kABEmailWorkLabel();
+ break;
+ case kABInstantMessageProperty:
+ switch(subCategory)
+ {
+ case AIM:
+ return kABInstantMessageServiceAIM();
+ case Facebook:
+ return kABInstantMessageServiceFacebook();
+ case GoogleTalk:
+ return kABInstantMessageServiceGoogleTalk();
+ case ICQ:
+ return kABInstantMessageServiceICQ();
+ case Jabber:
+ return kABInstantMessageServiceJabber();
+ case MSN:
+ return kABInstantMessageServiceMSN();
+ case Skype:
+ return kABInstantMessageServiceSkype();
+ case Yahoo:
+ return kABInstantMessageServiceYahoo();
+ default:
+ return null;
+ }
+ case kABPhoneProperty:
+ if(subCategory == ContactDetail.SubCategory.Home)
+ return kABPhoneHomeLabel();
+ if(subCategory == ContactDetail.SubCategory.Work)
+ return kABPhoneWorkLabel();
+ if(subCategory == ContactDetail.SubCategory.Fax)
+ return kABPhoneWorkFAXLabel();
+ break;
+ case kABAddressProperty:
+ if(subCategory == ContactDetail.SubCategory.Street)
+ return kABAddressStreetKey();
+ if(subCategory == ContactDetail.SubCategory.City)
+ return kABAddressCityKey();
+ if(subCategory == ContactDetail.SubCategory.Country)
+ return kABAddressCountryKey();
+ if(subCategory == ContactDetail.SubCategory.PostalCode)
+ return kABAddressZIPKey();
+ break;
+ default: return null;
+ }
+
+ return null;
+ }
+
+ /**
+ * Our editable source contact, we store changes in the addressbook.
+ */
+ private class AddressBookSourceContact
+ extends GenericSourceContact
+ implements EditableSourceContact
+ {
+ /**
+ * Initializes a new <tt>AddrBookSourceContact</tt> instance.
+ *
+ * @param contactSource the <tt>ContactSourceService</tt> which is creating
+ * the new instance
+ * @param displayName the display name of the new instance
+ * @param contactDetails the <tt>ContactDetail</tt>s of the new instance
+ */
+ public AddressBookSourceContact(
+ ContactSourceService contactSource,
+ String displayName,
+ List<ContactDetail> contactDetails)
+ {
+ super(contactSource, displayName, contactDetails);
+
+ // let's save the parent so we can reuse it later when editing
+ // the detail
+ for(ContactDetail cd : contactDetails)
+ {
+ if(cd instanceof AddressBookContactDetail)
+ {
+ ((AddressBookContactDetail)cd).setParent(this);
+ }
+ }
+ }
+
+ /**
+ * Adds a contact detail to the list of contact details.
+ *
+ * @param detail the <tt>ContactDetail</tt> to add
+ */
+ @SuppressWarnings("unchecked")
+ public void addContactDetail(ContactDetail detail)
+ {
+ String id = (String)getData(SOURCE_CONTACT_ID_DATA_KEY);
+
+ if(id == null)
+ {
+ logger.warn("No id or wrong ContactDetail");
+ return;
+ }
+
+ int property = getProperty(
+ detail.getCategory(), detail.getSubCategories());
+
+ if(isMultiline(detail.getCategory()))
+ {
+ String subProperty = null;
+
+ if(detail instanceof AddressBookContactDetail)
+ {
+ subProperty = ((AddressBookContactDetail)detail)
+ .getSubPropertyLabel();
+ }
+
+ List<ContactDetail> details =
+ getContactDetails(detail.getCategory());
+
+ // first add existing one
+ ArrayList values = new ArrayList();
+
+ for(ContactDetail cd : details)
+ {
+ if(subProperty != null
+ && cd instanceof AddressBookContactDetail
+ && !subProperty.equals(
+ ((AddressBookContactDetail) cd)
+ .getSubPropertyLabel()))
+ {
+ continue;
+ }
+
+ String det = cd.getDetail();
+
+ for(ContactDetail.SubCategory sub : cd.getSubCategories())
+ {
+ String label = getLabel(property, sub);
+ if(label != null)
+ {
+ if(property == kABInstantMessageProperty)
+ {
+ values.add(det);
+ values.add(kABInstantMessageUsernameKey());
+ values.add(label);
+ values.add(kABInstantMessageServiceKey());
+ }
+ else
+ {
+ values.add(det);
+ values.add(label);
+ }
+ }
+ else
+ logger.warn("Missing label fo prop:" + property
+ + " and sub:" + sub);
+ }
+ }
+
+ // now the new value to add
+ for(ContactDetail.SubCategory sub : detail.getSubCategories())
+ {
+ String label = getLabel(property, sub);
+ if(label != null)
+ {
+ if(property == kABInstantMessageProperty)
+ {
+ values.add(detail.getDetail());
+ values.add(kABInstantMessageUsernameKey());
+ values.add(label);
+ values.add(kABInstantMessageServiceKey());
+ }
+ else
+ {
+ values.add(detail.getDetail());
+ values.add(label);
+ }
+ }
+ else
+ logger.warn("Missing label fo prop:" + property
+ + " and sub:" + sub);
+ }
+
+ setProperty(id, ABPERSON_PROPERTIES[property], subProperty,
+ values.toArray(new Object[values.size()]));
+
+ }
+ else
+ {
+ setProperty(id, ABPERSON_PROPERTIES[property], null,
+ detail.getDetail());
+ }
+
+ // make sure we add AddressBookContactDetail
+ Collection<ContactDetail.SubCategory> subCategories
+ = detail.getSubCategories();
+ contactDetails.add(
+ new AddressBookContactDetail(
+ property,
+ detail.getDetail(),
+ detail.getCategory(),
+ subCategories.toArray(
+ new ContactDetail.SubCategory[
+ subCategories.size()]),
+ null));
+ }
+
+ /**
+ * Removes the given <tt>ContactDetail</tt> from the list of details for
+ * this <tt>SourceContact</tt>.
+ *
+ * @param detail the <tt>ContactDetail</tt> to remove
+ */
+ public void removeContactDetail(ContactDetail detail)
+ {
+ //remove the detail from the addressbook
+ String id = (String)getData(SOURCE_CONTACT_ID_DATA_KEY);
+ if(id != null && detail instanceof AddressBookContactDetail)
+ {
+ removeProperty(id,
+ ((AddressBookContactDetail)detail).property);
+ }
+ else
+ logger.warn("No id or wrong ContactDetail");
+
+ contactDetails.remove(detail);
+ }
+
+ /**
+ * Changes the details list with the supplied one.
+ * @param details the details.
+ */
+ public void setDetails(List<ContactDetail> details)
+ {
+ contactDetails.clear();
+ contactDetails.addAll(details);
+ }
+ }
+
+ /**
+ * The editable detail, change get changed and in addressbook.
+ */
+ private class AddressBookContactDetail
+ extends EditableContactDetail
+ {
+ /**
+ * The property index for this detail.
+ */
+ private final int property;
+
+ /**
+ * The id of the detail.
+ */
+ private String id;
+
+ /**
+ * The parent contact source.
+ */
+ private AddressBookSourceContact parent;
+
+ private String subPropertyLabel;
+
+ /**
+ * Initializes a new <tt>ContactDetail</tt> instance which is to represent a
+ * specific contact address and which is to be optionally labeled with a
+ * specific set of labels.
+ *
+ * @param contactDetailValue the contact detail value to be represented by
+ * the new <tt>ContactDetail</tt> instance
+ * @param category
+ * @param subCategories the set of sub categories with which the new
+ * <tt>ContactDetail</tt> instance is to be labeled.
+ */
+ public AddressBookContactDetail(
+ int property,
+ String contactDetailValue,
+ ContactDetail.Category category,
+ ContactDetail.SubCategory[] subCategories,
+ String subPropertyLabel)
+ {
+ super(contactDetailValue, category, subCategories);
+ this.property = property;
+ this.subPropertyLabel = subPropertyLabel;
+ }
+
+ /**
+ * Sets the given detail value.
+ *
+ * @param value the new value of the detail
+ */
+ @SuppressWarnings("unchecked")
+ public void setDetail(String value)
+ {
+ //let's save in addressbook
+ if(isMultiline(getCategory()))
+ {
+ // get others
+ List<ContactDetail> details =
+ parent.getContactDetails(getCategory());
+
+ // first add existing one
+ ArrayList values = new ArrayList();
+ for(ContactDetail cd : details)
+ {
+ String det = cd.getDetail();
+
+ for(ContactDetail.SubCategory sub : cd.getSubCategories())
+ {
+ String label = getLabel(property, sub);
+
+ if(label != null)
+ {
+ if(getSubCategories().contains(sub))
+ values.add(value);
+ else
+ values.add(det);
+
+ values.add(label);
+ }
+ }
+ }
+
+ // now the real edit
+ setProperty(
+ id,
+ ABPERSON_PROPERTIES[property],
+ subPropertyLabel,
+ values.toArray(new Object[values.size()]));
+ }
+ else
+ {
+ setProperty(id, ABPERSON_PROPERTIES[property], null, value);
+ }
+
+ super.setDetail(value);
+ }
+
+ /**
+ * Sets the id of the parent contact source.
+ * @param id
+ */
+ public void setId(String id)
+ {
+ this.id = id;
+ }
+
+ /**
+ * Sets the parent source contact.
+ * @param parent the parent source contact
+ */
+ public void setParent(AddressBookSourceContact parent)
+ {
+ this.parent = parent;
+ }
+
+ /**
+ * Returns the sub property.
+ * @return
+ */
+ public String getSubPropertyLabel()
+ {
+ return subPropertyLabel;
+ }
+ }
}
diff --git a/src/net/java/sip/communicator/plugin/addrbook/macosx/MacOSXAddrBookContactSourceService.java b/src/net/java/sip/communicator/plugin/addrbook/macosx/MacOSXAddrBookContactSourceService.java
index 1e75e7e..7129ad2 100644
--- a/src/net/java/sip/communicator/plugin/addrbook/macosx/MacOSXAddrBookContactSourceService.java
+++ b/src/net/java/sip/communicator/plugin/addrbook/macosx/MacOSXAddrBookContactSourceService.java
@@ -37,6 +37,11 @@ public class MacOSXAddrBookContactSourceService
private long ptr;
/**
+ * The latest query created.
+ */
+ private MacOSXAddrBookContactQuery latestQuery;
+
+ /**
* Initializes a new <tt>MacOSXAddrBookContactSourceService</tt> instance.
*/
public MacOSXAddrBookContactSourceService()
@@ -44,6 +49,7 @@ public class MacOSXAddrBookContactSourceService
ptr = start();
if (0 == ptr)
throw new IllegalStateException("ptr");
+ setDelegate(ptr, new NotificationsDelegate());
}
/**
@@ -86,11 +92,13 @@ public class MacOSXAddrBookContactSourceService
*/
public ContactQuery queryContactSource(Pattern query)
{
- MacOSXAddrBookContactQuery mosxabcq
- = new MacOSXAddrBookContactQuery(this, query);
+ if(latestQuery != null)
+ latestQuery.clear();
- mosxabcq.start();
- return mosxabcq;
+ latestQuery = new MacOSXAddrBookContactQuery(this, query);
+
+ latestQuery.start();
+ return latestQuery;
}
/**
@@ -111,6 +119,12 @@ public class MacOSXAddrBookContactSourceService
{
if (0 != ptr)
{
+ if(latestQuery != null)
+ {
+ latestQuery.clear();
+ latestQuery = null;
+ }
+
stop(ptr);
ptr = 0;
}
@@ -145,4 +159,44 @@ public class MacOSXAddrBookContactSourceService
* <tt>MacOSXAddrBookContactSourceService</tt> to stop
*/
private static native void stop(long ptr);
+
+ /**
+ * Sets notifier delegate.
+ * @param ptr
+ * @param delegate
+ */
+ public static native void setDelegate(long ptr, NotificationsDelegate delegate);
+
+ /**
+ * Delegate class to be notified for addressbook changes.
+ */
+ public class NotificationsDelegate
+ {
+ /**
+ * Callback method when receiving notifications for inserted items.
+ */
+ public void inserted(long person)
+ {
+ if(latestQuery != null)
+ latestQuery.inserted(person);
+ }
+
+ /**
+ * Callback method when receiving notifications for updated items.
+ */
+ public void updated(long person)
+ {
+ if(latestQuery != null)
+ latestQuery.updated(person);
+ }
+
+ /**
+ * Callback method when receiving notifications for deleted items.
+ */
+ public void deleted(String id)
+ {
+ if(latestQuery != null)
+ latestQuery.deleted(id);
+ }
+ }
}
diff --git a/src/net/java/sip/communicator/service/contactsource/AbstractContactQuery.java b/src/net/java/sip/communicator/service/contactsource/AbstractContactQuery.java
index 8d85b81..523e350 100644
--- a/src/net/java/sip/communicator/service/contactsource/AbstractContactQuery.java
+++ b/src/net/java/sip/communicator/service/contactsource/AbstractContactQuery.java
@@ -116,6 +116,54 @@ public abstract class AbstractContactQuery<T extends ContactSourceService>
/**
* Notifies the <tt>ContactQueryListener</tt>s registered with this
+ * <tt>ContactQuery</tt> that a <tt>SourceContact</tt> has been
+ * removed.
+ *
+ * @param contact the <tt>SourceContact</tt> which has been removed and
+ * which the registered <tt>ContactQueryListener</tt>s are to be notified
+ * about
+ */
+ protected void fireContactRemoved(SourceContact contact)
+ {
+ ContactQueryListener[] ls;
+
+ synchronized (listeners)
+ {
+ ls = listeners.toArray(new ContactQueryListener[listeners.size()]);
+ }
+
+ ContactRemovedEvent ev = new ContactRemovedEvent(this, contact);
+
+ for (ContactQueryListener l : ls)
+ l.contactRemoved(ev);
+ }
+
+ /**
+ * Notifies the <tt>ContactQueryListener</tt>s registered with this
+ * <tt>ContactQuery</tt> that a <tt>SourceContact</tt> has been
+ * changed.
+ *
+ * @param contact the <tt>SourceContact</tt> which has been changed and
+ * which the registered <tt>ContactQueryListener</tt>s are to be notified
+ * about
+ */
+ protected void fireContactChanged(SourceContact contact)
+ {
+ ContactQueryListener[] ls;
+
+ synchronized (listeners)
+ {
+ ls = listeners.toArray(new ContactQueryListener[listeners.size()]);
+ }
+
+ ContactChangedEvent ev = new ContactChangedEvent(this, contact);
+
+ for (ContactQueryListener l : ls)
+ l.contactChanged(ev);
+ }
+
+ /**
+ * Notifies the <tt>ContactQueryListener</tt>s registered with this
* <tt>ContactQuery</tt> that its state has changed.
*
* @param eventType the type of the <tt>ContactQueryStatusEvent</tt> to be
diff --git a/src/net/java/sip/communicator/service/contactsource/ContactDetail.java b/src/net/java/sip/communicator/service/contactsource/ContactDetail.java
index 1ba941e..b1ef1eb 100644
--- a/src/net/java/sip/communicator/service/contactsource/ContactDetail.java
+++ b/src/net/java/sip/communicator/service/contactsource/ContactDetail.java
@@ -277,8 +277,7 @@ public class ContactDetail
}
/**
- * The category of this <tt>ContactQuery</tt>. For example,
- * {@link #CATEGORY_PHONE} or {@link #CATEGORY_EMAIL}.
+ * The category of this <tt>ContactQuery</tt>.
*/
private final Category category;
@@ -409,8 +408,7 @@ public class ContactDetail
}
/**
- * Gets the category, if any, of this <tt>ContactQuery</tt>. For example,
- * {@link #CATEGORY_PHONE} or {@link #CATEGORY_EMAIL}.
+ * Gets the category, if any, of this <tt>ContactQuery</tt>.
*
* @return the category of this <tt>ContactQuery</tt> if it has any;
* otherwise, <tt>null</tt>
@@ -488,14 +486,14 @@ public class ContactDetail
* any of the standard/well-known labels defined by the <tt>LABEL_XXX</tt>
* constants of the <tt>ContactDetail</tt> class.
*
- * @param label the label to be determined whether it is contained in the
- * set of labels of this <tt>ContactDetail</tt>
+ * @param subCategory the subCategory to be determined whether
+ * it is contained in this <tt>ContactDetail</tt>
* @return <tt>true</tt> if the specified <tt>label</tt> is contained in the
* set of labels of this <tt>ContactDetail</tt>
*/
- public boolean containsSubCategory(SubCategory label)
+ public boolean containsSubCategory(SubCategory subCategory)
{
- return subCategories.contains(label);
+ return subCategories.contains(subCategory);
}
/**
diff --git a/src/net/java/sip/communicator/service/contactsource/GenericSourceContact.java b/src/net/java/sip/communicator/service/contactsource/GenericSourceContact.java
index 5dbb6fd..44fcdd4 100644
--- a/src/net/java/sip/communicator/service/contactsource/GenericSourceContact.java
+++ b/src/net/java/sip/communicator/service/contactsource/GenericSourceContact.java
@@ -24,7 +24,7 @@ public class GenericSourceContact
/**
* The <tt>ContactDetail</tt>s of this <tt>SourceContact</tt>.
*/
- private final List<ContactDetail> contactDetails;
+ protected final List<ContactDetail> contactDetails;
/**
* The <tt>ContactSourceService</tt> which has created this