diff --git a/UI/Contacts/UIxContactsListActions.m b/UI/Contacts/UIxContactsListActions.m index 6bc794889..43d9b4801 100644 --- a/UI/Contacts/UIxContactsListActions.m +++ b/UI/Contacts/UIxContactsListActions.m @@ -189,14 +189,26 @@ } } - // Flatten email for global address book instead of array + // Process for global address book instead of array if (globalAddressBookResults) { for (i = 0 ; i < [globalAddressBookResults count] ; i++) { tmpDict = [NSMutableDictionary dictionaryWithDictionary: [globalAddressBookResults objectAtIndex: i]]; if ([tmpDict objectForKey: @"c_mail"] && [[tmpDict objectForKey: @"c_mail"] isKindOfClass:[NSArray class]] && [[tmpDict objectForKey: @"c_mail"] count] > 0) { - [tmpDict setObject:[[tmpDict objectForKey: @"c_mail"] componentsJoinedByString: @","] forKey:@"c_mail"]; - [globalAddressBookResults replaceObjectAtIndex:i withObject: tmpDict]; + // Flatten emails + [tmpDict setObject:[[tmpDict objectForKey: @"c_mail"] componentsJoinedByString: @","] forKey:@"c_mail"]; } + + if ((![tmpDict objectForKey:@"c_cn"] || [tmpDict objectForKey:@"c_cn"] == [NSNull null]) && [tmpDict objectForKey:@"c_name"]) { + // Replace c_cn if not filled + [tmpDict setObject:[tmpDict objectForKey:@"c_name"] forKey:@"c_cn"]; + } + + if ((![tmpDict objectForKey:@"c_uid"] || [tmpDict objectForKey:@"c_uid"] == [NSNull null]) && [tmpDict objectForKey:@"c_id"]) { + // Replace c_uid if not filled + [tmpDict setObject:[tmpDict objectForKey:@"c_uid"] forKey:@"c_id"]; + } + + [globalAddressBookResults replaceObjectAtIndex:i withObject: tmpDict]; } } @@ -211,6 +223,7 @@ // Add sourceid for current AB for (i = 0 ; i < [results count] ; i++) { tmpDict = [NSMutableDictionary dictionaryWithDictionary: [results objectAtIndex: i]]; + // Add sourceid [tmpDict setObject:[folder nameInContainer] forKey:@"sourceid"]; [results replaceObjectAtIndex:i withObject: tmpDict]; } diff --git a/UI/Contacts/UIxListEditor.m b/UI/Contacts/UIxListEditor.m index dd57360bc..9e9c67309 100644 --- a/UI/Contacts/UIxListEditor.m +++ b/UI/Contacts/UIxListEditor.m @@ -35,6 +35,8 @@ #import #import +#import + #import #import @@ -173,12 +175,14 @@ { NSAutoreleasePool *pool; NSDictionary *values; - NSArray *initialReferences, *refs, *emails; + NSArray *initialReferences, *refs, *emails, *folders; NSDictionary *currentReference; NSString *uid, *workMail, *fn, *newUID; int i, count; NGVCardReference *cardReference; SOGoContactGCSFolder *folder; + NSMutableArray *publicSourceIDs; + id f; folder = [co container]; @@ -200,6 +204,15 @@ count = [references count]; pool = [[NSAutoreleasePool alloc] init]; + // List container name of global AB + folders = [[[co lookupUserFolder] privateContacts: @"Contacts" inContext: nil] subFolders]; + publicSourceIDs = [[NSMutableArray alloc] init]; + for (f in folders) { + if ([f isKindOfClass:[SOGoContactSourceFolder class]]) { + [publicSourceIDs addObject: [f nameInContainer]]; + } + } + for (i = 0; i < count; i++) { @@ -226,7 +239,7 @@ [list addCardReference: cardReference]; } - else if ([currentReference objectForKey:@"sourceid"] && [[currentReference objectForKey:@"sourceid"] isEqualToString: @"public"]) { + else if ([currentReference objectForKey:@"sourceid"] && [publicSourceIDs containsObject:[currentReference objectForKey:@"sourceid"]]) { // Create reference for shared AB (public) uid = [currentReference objectForKey: @"id"]; emails = [[currentReference objectForKey: @"c_mail"] componentsSeparatedByString: @","]; @@ -278,6 +291,8 @@ pool = [[NSAutoreleasePool alloc] init]; } } + + [publicSourceIDs release]; } - (BOOL) cardReferences: (NSArray *) references