From 188fda54d45999608484864350b64c2c33e5c677 Mon Sep 17 00:00:00 2001 From: Francis Lachapelle Date: Tue, 12 May 2009 19:56:39 +0000 Subject: [PATCH] See ChangeLog Monotone-Parent: 968254dd9df1cf87e5269ec6f7f31e31acc794bc Monotone-Revision: 6423f19a5a08e1fed0683fb1ab86ffb6e2519da7 Monotone-Author: flachapelle@inverse.ca Monotone-Date: 2009-05-12T19:56:39 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 18 +++++++++++++++++ NEWS | 2 ++ SoObjects/Mailer/SOGoMailAccount.m | 2 +- SoObjects/SOGo/LDAPSource.h | 2 ++ SoObjects/SOGo/LDAPSource.m | 32 +++++++++++++++++++++++------- SoObjects/SOGo/LDAPUserManager.m | 10 +++++++--- SoObjects/SOGo/SOGoUser.m | 9 ++++++--- 7 files changed, 61 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index c5cfb501f..db357eccd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,21 @@ +2009-05-12 Francis Lachapelle + + * SoObjects/SOGo/LDAPSource.m ([LDAPSource -initFromSource:]): + retrieves the user default attribute "IMAPHostFieldName" so the + IMAP server name can be fetched from the LDAP directory. + ([LDAPSource -_fillEmailsOfEntry:intoContactEntry:]): if a IMAP + hostname field is specified for the source, retrieve the LDAP + attribute and set the value to the key "c_imaphostname". + + * SoObjects/Mailer/SOGoMailAccount.m (SOGoMailAccount + -_urlHostString]): the IMAP server name is now retrieved from the + SOGoUser object and no longer hardcoded to the fallbackIMAP4Server + user default. + + * SoObjects/SOGo/LDAPUserManager.m ([LDAPUserManager + -_fillContactInfosForUser:withUIDorEmail:]): now fills the user + attributes dictionary with the IMAP hostname if specified and defined. + 2009-05-06 Francis Lachapelle * SoObjects/SOGo/SOGoGCSFolder.m ([SOGoGCSFolder diff --git a/NEWS b/NEWS index 78d1e22e4..e767c1b9f 100644 --- a/NEWS +++ b/NEWS @@ -7,6 +7,8 @@ - improvements to the underlying SOGo cache infrastructure - fixed bug with LDAP-based address books and the entries references (ID vs UID) - added "scope" parameter to LDAP sources +- added groups support in attendees in ACLs +- added support for user-based IMAP hostname 1.0-20090407 (1.0.1) -------------------- diff --git a/SoObjects/Mailer/SOGoMailAccount.m b/SoObjects/Mailer/SOGoMailAccount.m index 11e5857a6..a7731fbae 100644 --- a/SoObjects/Mailer/SOGoMailAccount.m +++ b/SoObjects/Mailer/SOGoMailAccount.m @@ -271,7 +271,7 @@ static NSString *fallbackIMAP4Server = nil; escUsername = [[username stringByEscapingURL] stringByReplacingString: @"@" withString: @"%40"]; -#if 0 +#if 1 // see comment about fallbackIMAP4Server above hostString = [NSString stringWithFormat: @"%@@%@", escUsername, [mailAccount objectForKey: @"serverName"]]; diff --git a/SoObjects/SOGo/LDAPSource.h b/SoObjects/SOGo/LDAPSource.h index ea216489d..4a4e923c3 100644 --- a/SoObjects/SOGo/LDAPSource.h +++ b/SoObjects/SOGo/LDAPSource.h @@ -46,6 +46,7 @@ NSString *CNField; NSString *UIDField; NSArray *mailFields; + NSString *IMAPHostField; NSString *bindFields; NSDictionary *modulesConstraints; @@ -69,6 +70,7 @@ CNField: (NSString *) newCNField UIDField: (NSString *) newUIDField mailFields: (NSArray *) newMailFields + IMAPHostField: (NSString *) newIMAPHostField andBindFields: (NSString *) newBindFields; - (BOOL) checkLogin: (NSString *) login diff --git a/SoObjects/SOGo/LDAPSource.m b/SoObjects/SOGo/LDAPSource.m index 5b247908e..2d80df39b 100644 --- a/SoObjects/SOGo/LDAPSource.m +++ b/SoObjects/SOGo/LDAPSource.m @@ -166,6 +166,7 @@ static NSLock *lock; UIDField = @"uid"; mailFields = [NSArray arrayWithObject: @"mail"]; [mailFields retain]; + IMAPHostField = nil; bindFields = nil; _scope = @"sub"; _filter = nil; @@ -188,6 +189,7 @@ static NSLock *lock; [CNField release]; [UIDField release]; [mailFields release]; + [IMAPHostField release]; [bindFields release]; [_filter release]; [ldapConnection release]; @@ -213,6 +215,7 @@ static NSLock *lock; CNField: [udSource objectForKey: @"CNFieldName"] UIDField: [udSource objectForKey: @"UIDFieldName"] mailFields: [udSource objectForKey: @"MailFieldNames"] + IMAPHostField: [udSource objectForKey: @"IMAPHostFieldName"] andBindFields: [udSource objectForKey: @"bindFields"]]; ASSIGN(modulesConstraints, [udSource objectForKey: @"ModulesConstraints"]); ASSIGN(_filter, [udSource objectForKey: @"filter"]); @@ -242,6 +245,7 @@ static NSLock *lock; CNField: (NSString *) newCNField UIDField: (NSString *) newUIDField mailFields: (NSArray *) newMailFields + IMAPHostField: (NSString *) newIMAPHostField andBindFields: (NSString *) newBindFields { ASSIGN (baseDN, newBaseDN); @@ -251,6 +255,8 @@ static NSLock *lock; ASSIGN (CNField, newCNField); if (newUIDField) ASSIGN (UIDField, newUIDField); + if (newIMAPHostField) + ASSIGN (IMAPHostField, newIMAPHostField); if (newMailFields) ASSIGN (mailFields, newMailFields); if (newBindFields) @@ -495,7 +501,7 @@ static NSLock *lock; if (!searchAttributes) { NSUserDefaults *ud; - NSString *contactInfo; + NSString *attribute; ud = [NSUserDefaults standardUserDefaults]; searchAttributes = [NSMutableArray new]; @@ -508,12 +514,17 @@ static NSLock *lock; [searchAttributes addObjectsFromArray: commonSearchFields]; // Add SOGoLDAPContactInfoAttribute from user defaults - contactInfo = [ud stringForKey: @"SOGoLDAPContactInfoAttribute"]; - if ([contactInfo length] > 0 && - ![searchAttributes containsObject: contactInfo]) - [searchAttributes addObject: contactInfo]; - } + attribute = [ud stringForKey: @"SOGoLDAPContactInfoAttribute"]; + if ([attribute length] > 0 && + ![searchAttributes containsObject: attribute]) + [searchAttributes addObject: attribute]; + // Add IMAP hostname from user defaults + if (IMAPHostField && [IMAPHostField length] > 0 && + ![searchAttributes containsObject: IMAPHostField]) + [searchAttributes addObject: IMAPHostField]; + } + return searchAttributes; } @@ -577,7 +588,7 @@ static NSLock *lock; intoContactEntry: (NSMutableDictionary *) contactEntry { NSEnumerator *emailFields; - NSString *currentFieldName; + NSString *currentFieldName, *ldapValue; NSMutableArray *emails; NSArray *allValues; @@ -591,6 +602,13 @@ static NSLock *lock; } [contactEntry setObject: emails forKey: @"c_emails"]; [emails release]; + + if (IMAPHostField) + { + ldapValue = [[ldapEntry attributeWithName: IMAPHostField] stringValueAtIndex: 0]; + if ([ldapValue length] > 0) + [contactEntry setObject: ldapValue forKey: @"c_imaphostname"]; + } } - (void) _fillConstraints: (NGLdapEntry *) ldapEntry diff --git a/SoObjects/SOGo/LDAPUserManager.m b/SoObjects/SOGo/LDAPUserManager.m index be16d0621..bca7e18c3 100644 --- a/SoObjects/SOGo/LDAPUserManager.m +++ b/SoObjects/SOGo/LDAPUserManager.m @@ -342,13 +342,14 @@ static NSLock *lock = nil; NSDictionary *userEntry; NSEnumerator *ldapSources; LDAPSource *currentSource; - NSString *sourceID, *cn, *c_uid; + NSString *sourceID, *cn, *c_uid, *c_imaphostname; NSArray *c_emails; BOOL access; emails = [NSMutableArray array]; cn = nil; c_uid = nil; + c_imaphostname = nil; [currentUser setObject: [NSNumber numberWithBool: YES] forKey: @"CalendarAccess"]; @@ -369,6 +370,8 @@ static NSLock *lock = nil; c_emails = [userEntry objectForKey: @"c_emails"]; if ([c_emails count]) [emails addObjectsFromArray: c_emails]; + if (!c_imaphostname) + c_imaphostname = [userEntry objectForKey: @"c_imaphostname"]; access = [[userEntry objectForKey: @"CalendarAccess"] boolValue]; if (!access) [currentUser setObject: [NSNumber numberWithBool: NO] @@ -377,7 +380,6 @@ static NSLock *lock = nil; if (!access) [currentUser setObject: [NSNumber numberWithBool: NO] forKey: @"MailAccess"]; - break; } } @@ -385,7 +387,9 @@ static NSLock *lock = nil; cn = @""; if (!c_uid) c_uid = @""; - + + if (c_imaphostname) + [currentUser setObject: c_imaphostname forKey: @"c_imaphostname"]; [currentUser setObject: emails forKey: @"emails"]; [currentUser setObject: cn forKey: @"cn"]; [currentUser setObject: c_uid forKey: @"c_uid"]; diff --git a/SoObjects/SOGo/SOGoUser.m b/SoObjects/SOGo/SOGoUser.m index 8a1e37611..3a12e643f 100644 --- a/SoObjects/SOGo/SOGoUser.m +++ b/SoObjects/SOGo/SOGoUser.m @@ -742,16 +742,19 @@ _timeValue (NSString *key) { NSMutableDictionary *mailAccount, *identity; NSMutableArray *identities, *mailAccounts; - NSString *name, *fullName, *imapLogin; + NSString *name, *fullName, *imapLogin, *imapServer; NSArray *mails; unsigned int count, max; imapLogin = [[LDAPUserManager sharedUserManager] getImapLoginForUID: login]; + imapServer = [self _fetchFieldForUser: @"c_imaphostname"]; + if (!imapServer) + imapServer = fallbackIMAP4Server; mailAccount = [NSMutableDictionary dictionary]; name = [NSString stringWithFormat: @"%@@%@", - imapLogin, fallbackIMAP4Server]; + imapLogin, imapServer]; [mailAccount setObject: imapLogin forKey: @"userName"]; - [mailAccount setObject: fallbackIMAP4Server forKey: @"serverName"]; + [mailAccount setObject: imapServer forKey: @"serverName"]; [mailAccount setObject: name forKey: @"name"]; identities = [NSMutableArray array];