Monotone-Parent: 463195ab0268a4a769eab22f23b6aecf0c87ad79

Monotone-Revision: 9abbb51cbabcad645190865841814453369fa85f

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2007-11-18T10:16:25
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Wolfgang Sourdeau
2007-11-18 10:16:25 +00:00
parent e3cdb8ecbf
commit 73bfada6bf
50 changed files with 1751 additions and 1265 deletions
+2
View File
@@ -41,6 +41,7 @@
NSString *IDField; /* the first part of a user DN */
NSString *CNField;
NSString *UIDField;
NSArray *mailFields;
NSString *bindFields;
NGLdapConnection *ldapConnection;
@@ -59,6 +60,7 @@
IDField: (NSString *) newIDField
CNField: (NSString *) newCNField
UIDField: (NSString *) newUIDField
mailFields: (NSArray *) newMailFields
andBindFields: (NSString *) newBindFields;
- (BOOL) checkLogin: (NSString *) login
+29 -9
View File
@@ -146,6 +146,8 @@ static int sizeLimit;
IDField = @"cn"; /* the first part of a user DN */
CNField = @"cn";
UIDField = @"uid";
mailFields = [NSArray arrayWithObject: @"mail"];
[mailFields retain];
bindFields = nil;
ldapConnection = nil;
@@ -164,6 +166,7 @@ static int sizeLimit;
[IDField release];
[CNField release];
[UIDField release];
[mailFields release];
[bindFields release];
[ldapConnection release];
[sourceID release];
@@ -183,7 +186,8 @@ static int sizeLimit;
[self setBaseDN: [udSource objectForKey: @"baseDN"]
IDField: [udSource objectForKey: @"IDFieldName"]
CNField: [udSource objectForKey: @"CNFieldName"]
UIDField: [udSource objectForKey: @"UIDFieldName"]
UIDField: [udSource objectForKey: @"UIDFieldName"]
mailFields: [udSource objectForKey: @"MailFieldNames"]
andBindFields: [udSource objectForKey: @"bindFields"]];
return self;
@@ -205,6 +209,7 @@ static int sizeLimit;
IDField: (NSString *) newIDField
CNField: (NSString *) newCNField
UIDField: (NSString *) newUIDField
mailFields: (NSArray *) newMailFields
andBindFields: (NSString *) newBindFields
{
ASSIGN (baseDN, newBaseDN);
@@ -214,6 +219,8 @@ static int sizeLimit;
ASSIGN (CNField, newCNField);
if (UIDField)
ASSIGN (UIDField, newUIDField);
if (newMailFields)
ASSIGN (mailFields, newMailFields);
if (newBindFields)
ASSIGN (bindFields, newBindFields);
}
@@ -346,8 +353,6 @@ static int sizeLimit;
- (NSArray *) _searchAttributes
{
NSArray *attrs;
if (!searchAttributes)
{
searchAttributes = [NSMutableArray new];
@@ -355,15 +360,10 @@ static int sizeLimit;
[searchAttributes addObject: CNField];
if (UIDField)
[searchAttributes addObject: UIDField];
[searchAttributes addObjectsFromArray: mailFields];
[searchAttributes addObjectsFromArray: commonSearchFields];
}
// We also include our MailFieldNames in the search
if ((attrs = [[[LDAPUserManager sharedUserManager] metadataForSourceID: sourceID] objectForKey: @"MailFieldNames"]))
{
[searchAttributes addObjectsFromArray: attrs];
}
return searchAttributes;
}
@@ -397,6 +397,25 @@ static int sizeLimit;
return ids;
}
- (void) _fillEmailsOfEntry: (NGLdapEntry *) ldapEntry
intoContactEntry: (NSMutableDictionary *) contactEntry
{
NSEnumerator *emailFields;
NSString *currentFieldName, *value;
NSMutableArray *emails;
emails = [NSMutableArray new];
emailFields = [mailFields objectEnumerator];
while ((currentFieldName = [emailFields nextObject]))
{
value = [[ldapEntry attributeWithName: currentFieldName] stringValueAtIndex: 0];
if (value)
[emails addObject: value];
}
[emails autorelease];
[contactEntry setObject: emails forKey: @"c_emails"];
}
- (NSDictionary *) _convertLDAPEntryToContact: (NGLdapEntry *) ldapEntry
{
NSMutableDictionary *contactEntry;
@@ -426,6 +445,7 @@ static int sizeLimit;
if (!value)
value = @"";
[contactEntry setObject: value forKey: @"c_cn"];
[self _fillEmailsOfEntry: ldapEntry intoContactEntry: contactEntry];
return contactEntry;
}
+7 -17
View File
@@ -27,6 +27,7 @@
#import <Foundation/NSUserDefaults.h>
#import <Foundation/NSValue.h>
#import "NSArray+Utilities.h"
#import "LDAPSource.h"
#import "LDAPUserManager.h"
@@ -289,9 +290,7 @@ static NSString *defaultMailDomain = nil;
emails = [contact objectForKey: @"emails"];
uid = [contact objectForKey: @"c_uid"];
systemEmail = [NSString stringWithFormat: @"%@@%@", uid, defaultMailDomain];
if ([emails containsObject: systemEmail])
[emails removeObject: systemEmail];
[emails addObject: systemEmail];
[emails addObjectUniquely: systemEmail];
[contact setObject: [emails objectAtIndex: 0] forKey: @"c_email"];
}
@@ -302,8 +301,8 @@ static NSString *defaultMailDomain = nil;
NSDictionary *userEntry;
NSEnumerator *ldapSources;
LDAPSource *currentSource;
NSString *cn, *email, *c_uid;
NSArray *attrs;
NSString *cn, *c_uid;
NSArray *c_emails;
emails = [NSMutableArray array];
cn = nil;
@@ -320,18 +319,9 @@ static NSString *defaultMailDomain = nil;
cn = [userEntry objectForKey: @"c_cn"];
if (!c_uid)
c_uid = [userEntry objectForKey: @"c_uid"];
if ((attrs = [[sourcesMetadata objectForKey: [currentSource sourceID]] objectForKey: @"MailFieldNames"]))
{
int i;
for (i = 0; i < [attrs count]; i++)
{
email = [userEntry objectForKey: [attrs objectAtIndex: i]];
if (email && ![emails containsObject: email])
[emails addObject: email];
}
}
c_emails = [userEntry objectForKey: @"c_emails"];
if ([c_emails count])
[emails addObjectsFromArray: c_emails];
}
currentSource = [ldapSources nextObject];
}
+6 -1
View File
@@ -48,7 +48,6 @@
/* content */
- (BOOL) isNew;
- (void) setContentString: (NSString *) newContent;
- (NSString *) contentAsString;
- (NSException *) saveContentString: (NSString *) _str
baseVersion: (unsigned int) _baseVersion;
@@ -65,4 +64,10 @@
@end
@interface SOGoContentObject (OptionalMethods)
- (void) prepareDelete;
@end
#endif /* __SOGo_SOGoContentObject_H__ */
+3 -7
View File
@@ -138,11 +138,6 @@
return content;
}
- (void) setContentString: (NSString *) newContent
{
ASSIGN (content, newContent);
}
- (NSException *) saveContentString: (NSString *) newContent
baseVersion: (unsigned int) newBaseVersion
{
@@ -152,11 +147,12 @@
ex = nil;
[self setContentString: newContent];
ASSIGN (content, newContent);
folder = [container ocsFolder];
if (folder)
{
ex = [folder writeContent: content toName: nameInContainer
ex = [folder writeContent: newContent toName: nameInContainer
baseVersion: newBaseVersion];
if (ex)
[self errorWithFormat:@"write failed: %@", ex];
+5 -1
View File
@@ -350,7 +350,11 @@ static NSString *defaultUserID = @"<default>";
deleteObject = [self lookupName: currentID
inContext: context acquire: NO];
if (![deleteObject isKindOfClass: [NSException class]])
[deleteObject delete];
{
if ([deleteObject respondsToSelector: @selector (prepareDelete)])
[deleteObject prepareDelete];
[deleteObject delete];
}
}
}
+7 -4
View File
@@ -34,17 +34,19 @@
context.activeUser
*/
@class NSString;
@class NSArray;
@class NSDictionary;
@class NSString;
@class NSTimeZone;
@class NSURL;
@class NSUserDefaults;
@class NSTimeZone;
@class WOContext;
@class SOGoAppointmentFolder;
@class SOGoAppointmentFolders;
@class SOGoDateFormatter;
@class WOContext;
@class SOGoUserFolder;
extern NSString *SOGoWeekStartHideWeekNumbers;
extern NSString *SOGoWeekStartJanuary1;
@@ -68,6 +70,7 @@ extern NSString *SOGoWeekStartFirstFullWeek;
NSTimeZone *userTimeZone;
SOGoDateFormatter *dateFormatter;
NSMutableArray *mailAccounts;
SOGoUserFolder *homeFolder;
}
+ (NSString *) language;
@@ -119,7 +122,7 @@ extern NSString *SOGoWeekStartFirstFullWeek;
/* folders */
- (id) homeFolderInContext: (id) _ctx;
- (SOGoUserFolder *) homeFolderInContext: (id) context;
- (SOGoAppointmentFolders *) calendarsFolderInContext: (WOContext *) context;
- (SOGoAppointmentFolder *)
+12 -20
View File
@@ -142,6 +142,7 @@ NSString *SOGoWeekStartFirstFullWeek = @"FirstFullWeek";
language = nil;
currentPassword = nil;
dateFormatter = nil;
homeFolder = nil;
}
return self;
@@ -176,6 +177,7 @@ NSString *SOGoWeekStartFirstFullWeek = @"FirstFullWeek";
[allEmails release];
[language release];
[dateFormatter release];
[homeFolder release];
[super dealloc];
}
@@ -528,27 +530,17 @@ NSString *SOGoWeekStartFirstFullWeek = @"FirstFullWeek";
// TODO: those methods should check whether the traversal stack in the context
// already contains proper folders to improve caching behaviour
- (id) homeFolderInContext: (id) _ctx
- (SOGoUserFolder *) homeFolderInContext: (id) context
{
/* Note: watch out for cyclic references */
// TODO: maybe we should add an [activeUser reset] method to SOPE
id folder;
folder = [(WOContext *)_ctx objectForKey:@"ActiveUserHomeFolder"];
if (folder != nil)
return [folder isNotNull] ? folder : nil;
folder = [[WOApplication application] lookupName: [self login]
inContext: _ctx
acquire: NO];
if ([folder isKindOfClass:[NSException class]])
return folder;
[(WOContext *)_ctx setObject: ((folder)
? folder
: (id)[NSNull null])
forKey: @"ActiveUserHomeFolder"];
return folder;
if (!homeFolder)
{
homeFolder = [[WOApplication application] lookupName: [self login]
inContext: context
acquire: NO];
[homeFolder retain];
}
return homeFolder;
}
- (SOGoAppointmentFolders *) calendarsFolderInContext: (WOContext *) context