feat(addressbook): Add global address book autocomplete on vlist

This commit is contained in:
smizrahi
2023-11-08 22:36:40 +01:00
parent 0560efd1f6
commit 0b1f2b0405
2 changed files with 33 additions and 5 deletions
+16 -3
View File
@@ -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];
}
+17 -2
View File
@@ -35,6 +35,8 @@
#import <SOGo/NSDictionary+Utilities.h>
#import <SOGo/NSString+Utilities.h>
#import <SoObjects/Contacts/SOGoContactSourceFolder.h>
#import <Contacts/SOGoContactGCSEntry.h>
#import <Contacts/SOGoContactGCSFolder.h>
@@ -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