From 6b2ec7a2e75084359af75bcd3f473084eed09467 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Garc=C3=ADa=20S=C3=A1ez?= Date: Wed, 20 Jan 2016 11:01:27 +0100 Subject: [PATCH] Remove listRequiresDot option from *Source classes This option is not needed. SQLSource was not using it and LDAPSource will transform the filter to (UIDField=*) when there is nothing set as filter, before this patch it was needed to either insert '.' as filter or set listRequiresDot to NO --- SoObjects/Contacts/SOGoContactSourceFolder.m | 29 +++------- SoObjects/SOGo/LDAPSource.h | 2 - SoObjects/SOGo/LDAPSource.m | 59 +++++++------------- SoObjects/SOGo/SOGoSource.h | 4 -- SoObjects/SOGo/SQLSource.m | 11 ---- 5 files changed, 28 insertions(+), 77 deletions(-) diff --git a/SoObjects/Contacts/SOGoContactSourceFolder.m b/SoObjects/Contacts/SOGoContactSourceFolder.m index bf4f30bd8..464a787c4 100644 --- a/SoObjects/Contacts/SOGoContactSourceFolder.m +++ b/SoObjects/Contacts/SOGoContactSourceFolder.m @@ -353,26 +353,15 @@ NSArray *records, *result; EOSortOrdering *ordering; - result = nil; - - if (([filter length] > 0 && [criteria isEqualToString: @"name_or_address"]) - || ![source listRequiresDot]) - { - records = [source fetchContactsMatching: filter - inDomain: domain]; - [childRecords setObjects: records - forKeys: [records objectsForKey: @"c_name" - notFoundMarker: nil]]; - records = [self _flattenedRecords: records]; - ordering - = [EOSortOrdering sortOrderingWithKey: sortKey - selector: ((sortOrdering == NSOrderedDescending) - ? EOCompareCaseInsensitiveDescending - : EOCompareCaseInsensitiveAscending)]; - result - = [records sortedArrayUsingKeyOrderArray: - [NSArray arrayWithObject: ordering]]; - } + records = [source fetchContactsMatching: filter inDomain: domain]; + [childRecords setObjects: records forKeys: [records objectsForKey: @"c_name" + notFoundMarker: nil]]; + records = [self _flattenedRecords: records]; + ordering = [EOSortOrdering sortOrderingWithKey: sortKey + selector: ((sortOrdering == NSOrderedDescending) + ? EOCompareCaseInsensitiveDescending + : EOCompareCaseInsensitiveAscending)]; + result = [records sortedArrayUsingKeyOrderArray: [NSArray arrayWithObject: ordering]]; return result; } diff --git a/SoObjects/SOGo/LDAPSource.h b/SoObjects/SOGo/LDAPSource.h index 9081196be..4958b0cee 100644 --- a/SoObjects/SOGo/LDAPSource.h +++ b/SoObjects/SOGo/LDAPSource.h @@ -65,8 +65,6 @@ NSString *SieveHostField; NSArray *bindFields; - BOOL listRequiresDot; - NSString *domain; NSString *contactInfoAttribute; diff --git a/SoObjects/SOGo/LDAPSource.m b/SoObjects/SOGo/LDAPSource.m index 2fa8f3773..32553fe2d 100644 --- a/SoObjects/SOGo/LDAPSource.m +++ b/SoObjects/SOGo/LDAPSource.m @@ -110,7 +110,6 @@ static Class NSStringK; _scope = @"sub"; _filter = nil; _userPasswordAlgorithm = nil; - listRequiresDot = YES; searchAttributes = nil; passwordPolicy = NO; @@ -201,9 +200,6 @@ static Class NSStringK; kindField: [udSource objectForKey: @"KindFieldName"] andMultipleBookingsField: [udSource objectForKey: @"MultipleBookingsFieldName"]]; - dotValue = [udSource objectForKey: @"listRequiresDot"]; - if (dotValue) - [self setListRequiresDot: [dotValue boolValue]]; [self setContactMapping: [udSource objectForKey: @"mapping"] andObjectClasses: [udSource objectForKey: @"objectClasses"]]; @@ -371,16 +367,6 @@ groupObjectClasses: (NSArray *) newGroupObjectClasses ASSIGN(multipleBookingsField, [newMultipleBookingsField lowercaseString]); } -- (void) setListRequiresDot: (BOOL) aBool -{ - listRequiresDot = aBool; -} - -- (BOOL) listRequiresDot -{ - return listRequiresDot; -} - - (void) setContactMapping: (NSDictionary *) newMapping andObjectClasses: (NSArray *) newObjectClasses { @@ -790,15 +776,13 @@ groupObjectClasses: (NSArray *) newGroupObjectClasses qualifier = [EOQualifier qualifierWithQualifierFormat: qs]; } - else if (!listRequiresDot) + else { qs = [NSMutableString stringWithFormat: @"(%@='*')", CNField]; if ([_filter length]) [qs appendFormat: @" AND %@", _filter]; qualifier = [EOQualifier qualifierWithQualifierFormat: qs]; } - else - qualifier = nil; return qualifier; } @@ -1189,29 +1173,25 @@ groupObjectClasses: (NSArray *) newGroupObjectClasses contacts = [NSMutableArray array]; - if ([match length] > 0 || !listRequiresDot) - { - ldapConnection = [self _ldapConnection]; - qualifier = [self _qualifierForFilter: match]; - // attributes = [self _searchAttributes]; - attributes = [NSArray arrayWithObject: @"*"]; + ldapConnection = [self _ldapConnection]; + qualifier = [self _qualifierForFilter: match]; + // attributes = [self _searchAttributes]; + attributes = [NSArray arrayWithObject: @"*"]; - if ([_scope caseInsensitiveCompare: @"BASE"] == NSOrderedSame) - entries = [ldapConnection baseSearchAtBaseDN: baseDN - qualifier: qualifier - attributes: attributes]; - else if ([_scope caseInsensitiveCompare: @"ONE"] == NSOrderedSame) - entries = [ldapConnection flatSearchAtBaseDN: baseDN - qualifier: qualifier - attributes: attributes]; - else /* we do it like before */ - entries = [ldapConnection deepSearchAtBaseDN: baseDN - qualifier: qualifier - attributes: attributes]; - while ((currentEntry = [entries nextObject])) - [contacts addObject: - [self _convertLDAPEntryToContact: currentEntry]]; - } + if ([_scope caseInsensitiveCompare: @"BASE"] == NSOrderedSame) + entries = [ldapConnection baseSearchAtBaseDN: baseDN + qualifier: qualifier + attributes: attributes]; + else if ([_scope caseInsensitiveCompare: @"ONE"] == NSOrderedSame) + entries = [ldapConnection flatSearchAtBaseDN: baseDN + qualifier: qualifier + attributes: attributes]; + else /* we do it like before */ + entries = [ldapConnection deepSearchAtBaseDN: baseDN + qualifier: qualifier + attributes: attributes]; + while ((currentEntry = [entries nextObject])) + [contacts addObject: [self _convertLDAPEntryToContact: currentEntry]]; return contacts; } @@ -1721,7 +1701,6 @@ _makeLDAPChanges (NGLdapConnection *ldapConnection, bindFields: nil kindField: nil andMultipleBookingsField: nil]; - [ab setListRequiresDot: NO]; [ab setModifiers: modifier]; [sources addObject: ab]; [ab release]; diff --git a/SoObjects/SOGo/SOGoSource.h b/SoObjects/SOGo/SOGoSource.h index d59a81086..16ff54d19 100644 --- a/SoObjects/SOGo/SOGoSource.h +++ b/SoObjects/SOGo/SOGoSource.h @@ -41,10 +41,6 @@ - (NSString *) domain; -/* requires a "." to obtain the full list of contacts */ -- (void) setListRequiresDot: (BOOL) aBool; -- (BOOL) listRequiresDot; - - (BOOL) checkLogin: (NSString *) _login password: (NSString *) _pwd perr: (SOGoPasswordPolicyError *) _perr diff --git a/SoObjects/SOGo/SQLSource.m b/SoObjects/SOGo/SQLSource.m index 307348f80..9665cea2a 100644 --- a/SoObjects/SOGo/SQLSource.m +++ b/SoObjects/SOGo/SQLSource.m @@ -851,17 +851,6 @@ return _sourceID; } -- (void) setListRequiresDot: (BOOL) newListRequiresDot -{ -} - -- (BOOL) listRequiresDot -{ - /* This method is not implemented for SQLSource. It must enable a mechanism - where using "." is not required to list the content of addressbooks. */ - return YES; -} - /* card editing */ - (void) setModifiers: (NSArray *) newModifiers {