From eff5105e7c133ca38fc09f0a038b8cddd8b7df0c Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Tue, 24 Jul 2007 19:57:16 +0000 Subject: [PATCH] Monotone-Parent: ace115b3b8955950a463b9c175ddcfadcd153e15 Monotone-Revision: 72ccbba45da9e854d8c8e440e4c7f41562d87e74 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2007-07-24T19:57:16 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 4 ++ SoObjects/Contacts/SOGoContactLDAPFolder.m | 66 +++++++++++++++++++++- 2 files changed, 68 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index c530d7c28..a1e3d3ff8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2007-07-24 Wolfgang Sourdeau + * SoObjects/Contacts/SOGoContactGCSFolder.m ([SOGoContactGCSFolder + -lookupContactsWithFilter:filtersortBy:sortKeyordering:sortOrdering]): + translate the returned records to a normalized form. + * UI/Scheduler/UIxCalListingActions.m, UI/Contacts/UIxContactsListView.m, SoObjects/SOGo/SOGoUser.m, SoObjects/SOGo/AgenorUserDefaults.m, diff --git a/SoObjects/Contacts/SOGoContactLDAPFolder.m b/SoObjects/Contacts/SOGoContactLDAPFolder.m index f59c1917b..2704be332 100644 --- a/SoObjects/Contacts/SOGoContactLDAPFolder.m +++ b/SoObjects/Contacts/SOGoContactLDAPFolder.m @@ -137,6 +137,68 @@ return keys; } +- (NSArray *) _flattenedRecords: (NSArray *) records +{ + NSMutableArray *newRecords; + NSEnumerator *oldRecords; + NSDictionary *oldRecord; + NSMutableDictionary *newRecord; + NSString *data; + + newRecords = [[NSMutableArray alloc] initWithCapacity: [records count]]; + [newRecords autorelease]; + + oldRecords = [records objectEnumerator]; + oldRecord = [oldRecords nextObject]; + while (oldRecord) + { + newRecord = [NSMutableDictionary new]; + [newRecord autorelease]; + + [newRecord setObject: [oldRecord objectForKey: @"c_uid"] + forKey: @"c_uid"]; + [newRecord setObject: [oldRecord objectForKey: @"c_name"] + forKey: @"c_name"]; + + data = [oldRecord objectForKey: @"displayName"]; + if (!data) + data = @""; + [newRecord setObject: data + forKey: @"displayName"]; + + data = [oldRecord objectForKey: @"mail"]; + if (!data) + data = @""; + [newRecord setObject: data forKey: @"mail"]; + + data = [oldRecord objectForKey: @"nsAIMid"]; + if (![data length]) + data = [oldRecord objectForKey: @"nscpaimscreenname"]; + if (![data length]) + data = @""; + [newRecord setObject: data forKey: @"screenName"]; + + data = [oldRecord objectForKey: @"o"]; + if (!data) + data = @""; + [newRecord setObject: data forKey: @"org"]; + + data = [oldRecord objectForKey: @"telephoneNumber"]; + if (![data length]) + data = [oldRecord objectForKey: @"cellphone"]; + if (![data length]) + data = [oldRecord objectForKey: @"homePhone"]; + if (![data length]) + data = @""; + [newRecord setObject: data forKey: @"phone"]; + + [newRecords addObject: newRecord]; + oldRecord = [oldRecords nextObject]; + } + + return newRecords; +} + - (NSArray *) lookupContactsWithFilter: (NSString *) filter sortBy: (NSString *) sortKey ordering: (NSComparisonResult) sortOrdering @@ -148,7 +210,8 @@ if (filter && [filter length] > 0) { - records = [ldapSource fetchContactsMatching: filter]; + records = [self _flattenedRecords: + [ldapSource fetchContactsMatching: filter]]; ordering = [EOSortOrdering sortOrderingWithKey: sortKey selector: ((sortOrdering == NSOrderedDescending) @@ -159,7 +222,6 @@ [NSArray arrayWithObject: ordering]]; } - //[self debugWithFormat:@"fetched %i records.", [records count]]; return result; }