From 0f9b580c59411933ebdfb4d2ae014a75a3c64755 Mon Sep 17 00:00:00 2001 From: Ludovic Marcotte Date: Mon, 13 Apr 2009 15:01:21 +0000 Subject: [PATCH] See ChangeLog Monotone-Parent: e290f01a5006f7dc9a5dec96622f04d6bcdb008c Monotone-Revision: ee481548c9940bbd1cea617d613818d78b722854 Monotone-Author: ludovic@Sophos.ca Monotone-Date: 2009-04-13T15:01:21 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 14 ++--- SoObjects/Contacts/SOGoContactLDAPFolder.m | 4 +- SoObjects/SOGo/LDAPSource.h | 4 +- SoObjects/SOGo/LDAPSource.m | 57 +++++++++++++------ .../ContactsUI/UIxContactsListView.wox | 2 +- 5 files changed, 51 insertions(+), 30 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8bde7e7c9..1ec09a0e1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,11 +1,11 @@ 2009-04-13 Ludovic Marcotte - - * SoObjects/Contacts/SOGoContactLDAPFolder.m and - SoObjects/SOGo/LDAPSource.h: renamed allEntryIDs to - allEntryUIDs and we now use the UID instead of the ID - when returning all entries since when the callback - is invoked, we use the UID and NOT the ID. - + + * SoObjects/SOGo/LDAPSource.m: cleaned up and + also correctly implemented -lookupContactEntry. + * SoObjects/Contacts/SOGoContactLDAPFolder.m: + we now use the correctly implemented -lookupContactEntry + method instead of -lookupContactEntryWithUIDorEmail + 2009-04-09 Ludovic Marcotte * Reverted previous patch and provided the correct diff --git a/SoObjects/Contacts/SOGoContactLDAPFolder.m b/SoObjects/Contacts/SOGoContactLDAPFolder.m index f5bdaad9c..4ff97084e 100644 --- a/SoObjects/Contacts/SOGoContactLDAPFolder.m +++ b/SoObjects/Contacts/SOGoContactLDAPFolder.m @@ -176,7 +176,7 @@ if (!obj) { - ldifEntry = [ldapSource lookupContactEntryWithUIDorEmail: objectName]; + ldifEntry = [ldapSource lookupContactEntry: objectName]; if (ldifEntry) obj = [SOGoContactLDIFEntry contactEntryWithName: objectName withLDIFEntry: ldifEntry @@ -190,7 +190,7 @@ - (NSArray *) toOneRelationshipKeys { - return [ldapSource allEntryUIDs]; + return [ldapSource allEntryIDs]; } - (NSArray *) _flattenedRecords: (NSArray *) records diff --git a/SoObjects/SOGo/LDAPSource.h b/SoObjects/SOGo/LDAPSource.h index b56dd734c..ab1f35a8a 100644 --- a/SoObjects/SOGo/LDAPSource.h +++ b/SoObjects/SOGo/LDAPSource.h @@ -72,9 +72,9 @@ - (BOOL) checkLogin: (NSString *) login andPassword: (NSString *) password; -- (NSDictionary *) lookupContactEntry: (NSString *) entryID; +- (NSDictionary *) lookupContactEntry: (NSString *) theID; - (NSDictionary *) lookupContactEntryWithUIDorEmail: (NSString *) entryID; -- (NSArray *) allEntryUIDs; +- (NSArray *) allEntryIDs; - (NSArray *) fetchContactsMatching: (NSString *) filter; - (NSString *) sourceID; diff --git a/SoObjects/SOGo/LDAPSource.m b/SoObjects/SOGo/LDAPSource.m index 20c14030e..ea7b737d5 100644 --- a/SoObjects/SOGo/LDAPSource.m +++ b/SoObjects/SOGo/LDAPSource.m @@ -355,7 +355,7 @@ static NSLock *lock; qualifier: qualifier attributes: attributes]; } - else /* else we do like it was before */ + else { entries = [ldapConnection deepSearchAtBaseDN: baseDN qualifier: qualifier @@ -492,11 +492,11 @@ static NSLock *lock; - (NSArray *) _searchAttributes { - NSUserDefaults *ud; - NSString *contactInfo; - if (!searchAttributes) { + NSUserDefaults *ud; + NSString *contactInfo; + ud = [NSUserDefaults standardUserDefaults]; searchAttributes = [NSMutableArray new]; if (CNField) @@ -517,7 +517,7 @@ static NSLock *lock; return searchAttributes; } -- (NSArray *) allEntryUIDs +- (NSArray *) allEntryIDs { NSMutableArray *ids; NSEnumerator *entries; @@ -534,7 +534,7 @@ static NSLock *lock; { NSArray *attributes; - attributes = [NSArray arrayWithObject: UIDField]; + attributes = [NSArray arrayWithObject: IDField]; if ([_scope caseInsensitiveCompare: @"BASE"] == NSOrderedSame) entries = [ldapConnection baseSearchAtBaseDN: baseDN qualifier: nil @@ -543,7 +543,7 @@ static NSLock *lock; entries = [ldapConnection flatSearchAtBaseDN: baseDN qualifier: nil attributes: attributes]; - else /* else we do like it was before */ + else entries = [ldapConnection deepSearchAtBaseDN: baseDN qualifier: nil attributes: attributes]; @@ -556,7 +556,7 @@ static NSLock *lock; currentEntry = [entries nextObject]; while (currentEntry) { - value = [[currentEntry attributeWithName: UIDField] + value = [[currentEntry attributeWithName: IDField] stringValueAtIndex: 0]; if ([value length] > 0) [ids addObject: value]; @@ -714,7 +714,7 @@ static NSLock *lock; return contacts; } -- (NSDictionary *) lookupContactEntry: (NSString *) entryID; +- (NSDictionary *) lookupContactEntry: (NSString *) theID { NSDictionary *contactEntry; NGLdapEntry *ldapEntry; @@ -725,13 +725,34 @@ static NSLock *lock; contactEntry = nil; - if ([entryID length] > 0) + if ([theID length] > 0) { if ([self _initLDAPConnection]) - ldapEntry - = [ldapConnection entryAtDN: [NSString stringWithFormat: @"%@=%@,%@", - IDField, entryID, baseDN] - attributes: [self _searchAttributes]]; + { + NSEnumerator *entries; + EOQualifier *qualifier; + NSArray *attributes; + NSString *s; + + s = [NSString stringWithFormat: @"(%@='%@')", IDField, theID]; + qualifier = [EOQualifier qualifierWithQualifierFormat: s]; + attributes = [self _searchAttributes]; + + 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 + entries = [ldapConnection deepSearchAtBaseDN: baseDN + qualifier: qualifier + attributes: attributes]; + + ldapEntry = [entries nextObject]; + } else ldapEntry = nil; @@ -748,11 +769,10 @@ static NSLock *lock; return contactEntry; } -- (NSDictionary *) lookupContactEntryWithUIDorEmail: (NSString *) uid; +- (NSDictionary *) lookupContactEntryWithUIDorEmail: (NSString *) uid { NSDictionary *contactEntry; NGLdapEntry *ldapEntry; - NSEnumerator *entries; #if defined(THREADSAFE) [lock lock]; @@ -763,7 +783,8 @@ static NSLock *lock; if ([uid length] > 0) { if ([self _initLDAPConnection]) - { + { + NSEnumerator *entries; EOQualifier *qualifier; NSArray *attributes; @@ -778,7 +799,7 @@ static NSLock *lock; entries = [ldapConnection flatSearchAtBaseDN: baseDN qualifier: qualifier attributes: attributes]; - else /* else we do like it was before */ + else entries = [ldapConnection deepSearchAtBaseDN: baseDN qualifier: qualifier attributes: attributes]; diff --git a/UI/Templates/ContactsUI/UIxContactsListView.wox b/UI/Templates/ContactsUI/UIxContactsListView.wox index 5dba56529..b4082f143 100644 --- a/UI/Templates/ContactsUI/UIxContactsListView.wox +++ b/UI/Templates/ContactsUI/UIxContactsListView.wox @@ -40,4 +40,4 @@ - \ No newline at end of file +