From a6288b5c35c8ea11c06ce6729bf1a7b739af703e Mon Sep 17 00:00:00 2001 From: Vincent Lucas Date: Mon, 11 Mar 2013 22:23:23 +0000 Subject: Adds edition for macosx address book contact properties. Avoids concurrent access to contact details. Corrects msoutlook subcategories for email and nickname. --- ...in_addrbook_macosx_MacOSXAddrBookContactQuery.m | 45 +++++++++++++++++----- 1 file changed, 35 insertions(+), 10 deletions(-) (limited to 'src/native/addrbook/macosx') 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 9db946f..fca3afa 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 @@ -231,20 +231,45 @@ JNIEXPORT jboolean JNICALL Java_net_java_sip_communicator_plugin_addrbook_macosx NSMutableDictionary *addr; addr = [NSMutableDictionary dictionary]; - for (i = 0; i < propertyCount; i+=2) + data=[[ABMutableMultiValue alloc] init]; + NSString *subProp = NULL; + NSString *lastSubProp; + for (i = 0; i < propertyCount; i+=3) { - jstring value = (jstring) (*jniEnv)->GetObjectArrayElement(jniEnv, arr, i); - jstring label = (jstring) (*jniEnv)->GetObjectArrayElement(jniEnv, arr, i+1); + jstring value + = (jstring) (*jniEnv)->GetObjectArrayElement(jniEnv, arr, i); + jstring label + = (jstring) (*jniEnv)->GetObjectArrayElement(jniEnv, arr, i+1); + jstring tmpLastSubProp + = (jstring) (*jniEnv)->GetObjectArrayElement(jniEnv, arr, i+2); + lastSubProp = JavaStringToNSString(jniEnv, tmpLastSubProp); + // Initiates the first sub-property value. + if(i == 0) + { + subProp = lastSubProp; + } - //NSLog(@"key:%@, value:%@", JavaStringToNSString(jniEnv, label), JavaStringToNSString(jniEnv, value)); + // If there is a change in the sub-property, then save the actual + // one to the address property and create a new sub-property list + // (Home, Work). + if(![lastSubProp isEqualToString: subProp]) + { + [(ABMutableMultiValue *) data addValue:addr withLabel:subProp]; + addr = [NSMutableDictionary dictionary]; + // Sets the new current proeperty + subProp = lastSubProp; + } + + //NSLog(@"key:%@, value:%@", JavaStringToNSString(jniEnv, label), + //JavaStringToNSString(jniEnv, value)); [addr setObject:JavaStringToNSString(jniEnv, value) - forKey:JavaStringToNSString(jniEnv, label)]; + forKey:JavaStringToNSString(jniEnv, label)]; + } + // Adds the last sub-property to the address book. + if(i > 0) + { + [(ABMutableMultiValue *) data addValue: addr withLabel: subProp]; } - - data=[[ABMutableMultiValue alloc] init]; - [(ABMutableMultiValue *) data - addValue:addr - withLabel:JavaStringToNSString(jniEnv, subProperty)]; } //else if(property == kABOtherDatesProperty)//kABMultiDateProperty else -- cgit v1.1