Monotone-Parent: ace115b3b8955950a463b9c175ddcfadcd153e15

Monotone-Revision: 72ccbba45da9e854d8c8e440e4c7f41562d87e74

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2007-07-24T19:57:16
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Wolfgang Sourdeau
2007-07-24 19:57:16 +00:00
parent 33e459d41f
commit eff5105e7c
2 changed files with 68 additions and 2 deletions

View File

@@ -1,5 +1,9 @@
2007-07-24 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* 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,

View File

@@ -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;
}