This commit is contained in:
Ludovic Marcotte
2015-12-30 09:06:13 -05:00
55 changed files with 2398 additions and 1244 deletions
@@ -605,8 +605,16 @@ static Class iCalEventK = nil;
NSNumber *classNumber;
unsigned int grantedCount;
iCalAccessClass currentClass;
WOContext *localContext;
[self initializeQuickTablesAclsInContext: context];
/* FIXME: The stored context from initialisation may have changed
by setContext by other operations in OpenChange library,
so we keep tighly to use the current session one. Without
this, the login is set to nil and a NSException is raised
at [SOGoAppointmentFolder:roleForComponentsWithAccessClass:forUser]
inside [SOGoAppointmentFolder:initializeQuickTablesAclsInContext]. */
localContext = [[WOApplication application] context];
[self initializeQuickTablesAclsInContext: localContext];
grantedClasses = [NSMutableArray arrayWithCapacity: 3];
deniedClasses = [NSMutableArray arrayWithCapacity: 3];
for (currentClass = 0;
+13 -8
View File
@@ -165,9 +165,10 @@
ldifEntry = [childRecords objectForKey: objectName];
if (!ldifEntry)
{
ldifEntry = [source lookupContactEntry: objectName];
if (ldifEntry)
[childRecords setObject: ldifEntry forKey: objectName];
ldifEntry = [source lookupContactEntry: objectName
inDomain: [[context activeUser] domain]];
if (ldifEntry)
[childRecords setObject: ldifEntry forKey: objectName];
else if ([self isValidContentName: objectName])
{
url = [[[lookupContext request] uri] urlWithoutParameters];
@@ -332,10 +333,14 @@
NSDictionary *record;
if (aName && [aName length] > 0)
record = [self _flattenedRecord: [source lookupContactEntry: aName]];
{
record = [source lookupContactEntry: aName
inDomain: [[context activeUser] domain]];
record = [self _flattenedRecord: record];
}
else
record = nil;
return record;
}
@@ -570,7 +575,7 @@
toResponse: (WOResponse *) response
{
NSObject <DOMElement> *element;
NSString *url, *baseURL, *cname;
NSString *url, *baseURL, *cname, *domain;
NSString **propertiesArray;
NSMutableString *buffer;
NSDictionary *object;
@@ -587,13 +592,13 @@
max = [refs length];
buffer = [NSMutableString stringWithCapacity: max*512];
domain = [[context activeUser] domain];
for (count = 0; count < max; count++)
{
element = [refs objectAtIndex: count];
url = [[[element firstChild] nodeValue] stringByUnescapingURL];
cname = [self _deduceObjectNameFromURL: url fromBaseURL: baseURL];
object = [source lookupContactEntry: cname];
object = [source lookupContactEntry: cname inDomain: domain];
if (object)
[self appendObject: object
properties: propertiesArray
+31 -28
View File
@@ -30,14 +30,13 @@
{
NSDictionary *parameters;
NSString *filename;
filename = [[self objectForKey: @"parameterList"]
objectForKey: @"name"];
if (!filename)
filename = nil;
parameters = [[self objectForKey: @"disposition"]
objectForKey: @"parameterList"];
if (parameters)
{
parameters = [[self objectForKey: @"disposition"]
objectForKey: @"parameterList"];
filename = [parameters objectForKey: @"filename"];
@@ -45,29 +44,33 @@
// See RFC2231 for details. If it was folded before, it will
// be unfolded when we get here.
if (!filename)
{
filename = [parameters objectForKey: @"filename*"];
if (filename)
{
NSRange r;
filename = [filename stringByUnescapingURL];
// We skip up to the language
r = [filename rangeOfString: @"'"];
if (r.length)
{
r = [filename rangeOfString: @"'" options: 0 range: NSMakeRange(r.location+1, [filename length]-r.location-1)];
if (r.length)
filename = [filename substringFromIndex: r.location+1];
}
}
}
{
filename = [parameters objectForKey: @"filename*"];
if (filename)
{
NSRange r;
filename = [filename stringByUnescapingURL];
// We skip up to the language
r = [filename rangeOfString: @"'"];
if (r.length)
{
r = [filename rangeOfString: @"'" options: 0 range: NSMakeRange(r.location+1, [filename length]-r.location-1)];
if (r.length)
filename = [filename substringFromIndex: r.location+1];
}
}
}
}
if (!filename)
filename = [[self objectForKey: @"parameterList"]
objectForKey: @"name"];
return filename;
}
+6
View File
@@ -32,6 +32,12 @@ SOGo_HEADER_FILES = \
SOGoGCSFolder.h \
SOGoParentFolder.h \
SOGoUserFolder.h \
SOGoSource.h \
SOGoSystemDefaults.h \
SOGoDomainDefaults.h \
SOGoLDAPDefaults.h \
SOGoDefaultsSource.h \
SOGoUserDefaults.h \
\
SOGoSieveManager.h \
\
+4 -2
View File
@@ -120,8 +120,10 @@ andMultipleBookingsField: (NSString *) newMultipleBookingsField;
- (void) setContactMapping: (NSDictionary *) newMapping
andObjectClasses: (NSArray *) newObjectClasses;
- (NGLdapEntry *) lookupGroupEntryByUID: (NSString *) theUID;
- (NGLdapEntry *) lookupGroupEntryByEmail: (NSString *) theEmail;
- (NGLdapEntry *) lookupGroupEntryByUID: (NSString *) theUID
inDomain: (NSString *) domain;
- (NGLdapEntry *) lookupGroupEntryByEmail: (NSString *) theEmail
inDomain: (NSString *) domain;
@end
+4
View File
@@ -162,6 +162,7 @@ static Class NSStringK;
[multipleBookingsField release];
[MSExchangeHostname release];
[modifiers release];
[displayName release];
[super dealloc];
}
@@ -1242,6 +1243,7 @@ groupObjectClasses: (NSArray *) newGroupObjectClasses
}
- (NSDictionary *) lookupContactEntry: (NSString *) theID
inDomain: (NSString *) domain
{
NGLdapEntry *ldapEntry;
EOQualifier *qualifier;
@@ -1339,12 +1341,14 @@ groupObjectClasses: (NSArray *) newGroupObjectClasses
}
- (NGLdapEntry *) lookupGroupEntryByUID: (NSString *) theUID
inDomain: (NSString *) domain
{
return [self _lookupGroupEntryByAttributes: [NSArray arrayWithObject: UIDField]
andValue: theUID];
}
- (NGLdapEntry *) lookupGroupEntryByEmail: (NSString *) theEmail
inDomain: (NSString *) domain
{
return [self _lookupGroupEntryByAttributes: mailFields
andValue: theEmail];
+3
View File
@@ -50,6 +50,9 @@
andParentSource: systemDefaults];
}
if (!domainDefaults)
domainDefaults = [SOGoSystemDefaults sharedSystemDefaults];
return domainDefaults;
}
+5 -5
View File
@@ -113,7 +113,7 @@
uid = [theID hasPrefix: @"@"] ? [theID substringFromIndex: 1] : theID;
return [SOGoGroup groupWithValue: uid
andSourceSelector: @selector (lookupGroupEntryByUID:)
andSourceSelector: @selector (lookupGroupEntryByUID:inDomain:)
inDomain: domain];
}
@@ -121,7 +121,7 @@
inDomain: (NSString *) domain
{
return [SOGoGroup groupWithValue: theEmail
andSourceSelector: @selector (lookupGroupEntryByEmail:)
andSourceSelector: @selector (lookupGroupEntryByEmail:inDomain:)
inDomain: domain];
}
@@ -158,9 +158,9 @@
// Our different sources might not all implements groups support
if ([source respondsToSelector: theSelector])
entry = [source performSelector: theSelector
withObject: theValue];
entry = [source performSelector: theSelector
withObject: theValue
withObject: domain];
if (entry)
break;
+3
View File
@@ -180,6 +180,9 @@
[NSException raise: NSInvalidArgumentException
format: @"'_name' must not be an empty string"];
context = [[WOApplication application] context];
if (!context)
[self errorWithFormat: @"Error: initializing a SOGoObject (named %@) "
@"without wocontext", _name];
nameInContainer = [_name copy];
container = _container;
if ([self doesRetainContainer])
+2 -1
View File
@@ -41,6 +41,7 @@
#include <unistd.h>
#import "SOGoSystemDefaults.h"
#import "SOGoUserManager.h"
@implementation SOGoSession
@@ -262,7 +263,7 @@
// The domain is probably appended to the username;
// make sure it is defined as a domain in the configuration.
*theDomain = [*theLogin substringFromIndex: (r.location + r.length)];
if (![[sd domainIds] containsObject: *theDomain])
if (![[SOGoUserManager sharedUserManager] isDomainDefined: *theDomain])
*theDomain = nil;
}
}
+2 -1
View File
@@ -56,7 +56,8 @@
newPassword: (NSString *) newPassword
perr: (SOGoPasswordPolicyError *) perr;
- (NSDictionary *) lookupContactEntry: (NSString *) theID;
- (NSDictionary *) lookupContactEntry: (NSString *) theID
inDomain: (NSString *) domain;
- (NSDictionary *) lookupContactEntryWithUIDorEmail: (NSString *) entryID
inDomain: (NSString *) domain;
+1 -1
View File
@@ -261,7 +261,7 @@ _injectConfigurationFromFile (NSMutableDictionary *defaultsDict,
- (BOOL) enableDomainBasedUID
{
return ([[self domainIds] count] > 0 && [self boolForKey: @"SOGoEnableDomainBasedUID"]);
return [self boolForKey: @"SOGoEnableDomainBasedUID"];
}
- (NSArray *) loginDomains
+1 -1
View File
@@ -165,7 +165,7 @@
// The domain is probably appended to the username;
// make sure it is defined as a domain in the configuration.
domain = [newLogin substringFromIndex: (r.location + r.length)];
if ([[sd domainIds] containsObject: domain] &&
if ([[SOGoUserManager sharedUserManager] isDomainDefined: domain] &&
![sd enableDomainBasedUID])
newLogin = [newLogin substringToIndex: r.location];
+1
View File
@@ -58,6 +58,7 @@
- (NSArray *) sourceIDsInDomain: (NSString *) domain;
- (NSArray *) authenticationSourceIDsInDomain: (NSString *) domain;
- (NSArray *) addressBookSourceIDsInDomain: (NSString *) domain;
- (BOOL) isDomainDefined: (NSString *) domain;
- (NSObject <SOGoSource> *) sourceWithID: (NSString *) sourceID;
- (NSDictionary *) metadataForSourceID: (NSString *) sourceID;
+175 -148
View File
@@ -67,10 +67,12 @@ static Class NSNullK;
if (type)
{
if ([type isEqualToString: @"ldap"])
if ([type caseInsensitiveCompare: @"ldap"] == NSOrderedSame)
sourceClass = @"LDAPSource";
else if ([type isEqualToString: @"sql"])
else if ([type caseInsensitiveCompare: @"sql"] == NSOrderedSame)
sourceClass = @"SQLSource";
else if (NSClassFromString(type))
sourceClass = type;
else
{
[NSException raise: @"SOGoUserManagerRegistryException"
@@ -104,65 +106,58 @@ static Class NSNullK;
NSString *sourceID, *value, *type;
NSMutableDictionary *metadata;
NSObject <SOGoSource> *sogoSource;
BOOL isAddressBook, result;
BOOL isAddressBook;
Class c;
result = NO;
sourceID = [udSource objectForKey: @"id"];
if ([sourceID length] > 0)
if (!sourceID || [sourceID length] == 0)
{
if ([_sourcesMetadata objectForKey: sourceID])
[self errorWithFormat: @"attempted to register a contact/user source"
@" with duplicated id (%@)", sourceID];
else
{
type = [[udSource objectForKey: @"type"] lowercaseString];
c = NSClassFromString([_registry sourceClassForType: type]);
sogoSource = [c sourceFromUDSource: udSource inDomain: domain];
if (sourceID)
[_sources setObject: sogoSource forKey: sourceID];
else
[self errorWithFormat: @"id field missing in an user source,"
@" check the SOGoUserSources defaults"];
metadata = [NSMutableDictionary dictionary];
if (domain)
[metadata setObject: domain forKey: @"domain"];
value = [udSource objectForKey: @"canAuthenticate"];
if (value)
[metadata setObject: value forKey: @"canAuthenticate"];
value = [udSource objectForKey: @"isAddressBook"];
if (value)
{
[metadata setObject: value forKey: @"isAddressBook"];
isAddressBook = [value boolValue];
}
else
isAddressBook = NO;
value = [udSource objectForKey: @"displayName"];
if (value)
[metadata setObject: value forKey: @"displayName"];
else
{
if (isAddressBook)
[self errorWithFormat: @"addressbook source '%@' has"
@" no displayname", sourceID];
}
value = [udSource objectForKey: @"MailFieldNames"];
if (value)
[metadata setObject: value forKey: @"MailFieldNames"];
value = [udSource objectForKey: @"SearchFieldNames"];
if (value)
[metadata setObject: value forKey: @"SearchFieldNames"];
[_sourcesMetadata setObject: metadata forKey: sourceID];
result = YES;
}
[self errorWithFormat: @"attempted to register a contact/user source "
@"without id (skipped)"];
return NO;
}
if ([_sourcesMetadata objectForKey: sourceID])
{
[self errorWithFormat: @"attempted to register a contact/user source "
@"with duplicated id (%@)", sourceID];
return NO;
}
type = [udSource objectForKey: @"type"];
c = NSClassFromString([_registry sourceClassForType: type]);
sogoSource = [c sourceFromUDSource: udSource inDomain: domain];
[_sources setObject: sogoSource forKey: sourceID];
metadata = [NSMutableDictionary dictionary];
if (domain)
[metadata setObject: domain forKey: @"domain"];
value = [udSource objectForKey: @"canAuthenticate"];
if (value)
[metadata setObject: value forKey: @"canAuthenticate"];
value = [udSource objectForKey: @"isAddressBook"];
if (value)
{
[metadata setObject: value forKey: @"isAddressBook"];
isAddressBook = [value boolValue];
}
else
[self errorWithFormat: @"attempted to register a contact/user source"
@" without id (skipped)"];
isAddressBook = NO;
value = [udSource objectForKey: @"displayName"];
if (value)
[metadata setObject: value forKey: @"displayName"];
else if (isAddressBook)
[self errorWithFormat: @"addressbook source '%@' has no displayname", sourceID];
return result;
value = [udSource objectForKey: @"MailFieldNames"];
if (value)
[metadata setObject: value forKey: @"MailFieldNames"];
value = [udSource objectForKey: @"SearchFieldNames"];
if (value)
[metadata setObject: value forKey: @"SearchFieldNames"];
[_sourcesMetadata setObject: metadata forKey: sourceID];
return YES;
}
- (int) _registerSourcesInDomain: (NSString *) domain
@@ -171,11 +166,7 @@ static Class NSNullK;
unsigned int count, max, total;
SOGoDomainDefaults *dd;
if (domain)
dd = [SOGoDomainDefaults defaultsForDomain: domain];
else
dd = [SOGoSystemDefaults sharedSystemDefaults];
dd = [SOGoDomainDefaults defaultsForDomain: domain];
userSources = [dd userSources];
max = [userSources count];
total = 0;
@@ -305,6 +296,35 @@ static Class NSNullK;
return sourceIDs;
}
- (BOOL) isDomainDefined: (NSString *) domain
{
NSEnumerator *allIDs;
NSArray *ids;
NSString *currentID, *sourceDomain;
SOGoSystemDefaults *sd;
if (!domain) return NO;
ids = [_sources allKeys];
if ([ids containsObject: domain])
// FIXME check SOGoMailDomain?
// Now source id is being considered as the domain
return YES;
sd = [SOGoSystemDefaults sharedSystemDefaults];
if ([sd enableDomainBasedUID])
{
allIDs = [ids objectEnumerator];
while ((currentID = [allIDs nextObject]))
{
sourceDomain = [[_sources objectForKey: currentID] domain];
if (!sourceDomain) // source that can identify any domain
return YES;
}
}
return NO;
}
- (NSString *) displayNameForSourceWithID: (NSString *) sourceID
{
NSDictionary *metadata;
@@ -328,7 +348,6 @@ static Class NSNullK;
{
NSDictionary *contactInfos;
// NSLog (@"getEmailForUID: %@", uid);
contactInfos = [self contactInfosForUserWithUIDorEmail: uid];
return [contactInfos objectForKey: @"c_email"];
@@ -345,8 +364,7 @@ static Class NSNullK;
if ([cn length] > 0)
{
if ([email length] > 0)
fullEmail = [NSString stringWithFormat: @"%@ <%@>",
cn, email];
fullEmail = [NSString stringWithFormat: @"%@ <%@>", cn, email];
else
fullEmail = cn;
}
@@ -369,11 +387,7 @@ static Class NSNullK;
login = [contactInfos objectForKey: @"c_imaplogin"];
if (login == nil)
{
if ([domain length])
dd = [SOGoDomainDefaults defaultsForDomain: domain];
else
dd = [SOGoSystemDefaults sharedSystemDefaults];
dd = [SOGoDomainDefaults defaultsForDomain: domain];
if ([dd forceExternalLoginWithEmail])
{
sd = [SOGoSystemDefaults sharedSystemDefaults];
@@ -415,16 +429,16 @@ static Class NSNullK;
- (BOOL) _sourceChangePasswordForLogin: (NSString *) login
inDomain: (NSString *) domain
oldPassword: (NSString *) oldPassword
newPassword: (NSString *) newPassword
perr: (SOGoPasswordPolicyError *) perr
newPassword: (NSString *) newPassword
perr: (SOGoPasswordPolicyError *) perr
{
NSObject <SOGoSource> *sogoSource;
NSEnumerator *authIDs;
NSString *currentID;
BOOL didChange;
didChange = NO;
authIDs = [[self authenticationSourceIDsInDomain: domain] objectEnumerator];
while (!didChange && (currentID = [authIDs nextObject]))
{
@@ -449,8 +463,6 @@ static Class NSNullK;
NSEnumerator *authIDs;
NSString *currentID;
BOOL checkOK;
SOGoSystemDefaults *sd;
NSRange r;
checkOK = NO;
@@ -467,7 +479,24 @@ static Class NSNullK;
}
if (checkOK && *domain == nil)
*domain = [sogoSource domain];
{
SOGoSystemDefaults *sd = [SOGoSystemDefaults sharedSystemDefaults];
BOOL multidomainSource = [sd enableDomainBasedUID] &&
[sogoSource domain] == nil;
if (multidomainSource)
{
NSArray *parts = [login componentsSeparatedByString: @"@"];
if ([parts count] != 2)
{
[self errorWithFormat: @"Authenticated with multidomain source "
@"but login is not an email (%@).", login];
return NO;
}
*domain = [parts objectAtIndex: 1];
}
else
*domain = [sogoSource domain];
}
return checkOK;
}
@@ -548,7 +577,7 @@ static Class NSNullK;
delta = current_time - start_time;
block_time = [sd failedLoginBlockInterval];
if ([[failedCount objectForKey: @"FailedCount"] intValue] >= [sd maximumFailedLoginCount] &&
delta >= [sd maximumFailedLoginInterval] &&
delta <= block_time )
@@ -556,7 +585,7 @@ static Class NSNullK;
*_perr = PolicyAccountLocked;
return NO;
}
if (delta > block_time)
{
[[SOGoCache sharedCache] setFailedCount: 0
@@ -640,7 +669,7 @@ static Class NSNullK;
[[SOGoCache sharedCache] setFailedCount: ([[failedCount objectForKey: @"FailedCount"] intValue] + 1)
forLogin: username];
}
checkOK = NO;
}
@@ -651,7 +680,7 @@ static Class NSNullK;
{
NSObject <SOGoDNSource> *currentSource;
NSEnumerator *sources;
sources = [[_sources allValues] objectEnumerator];
while ((currentSource = [sources nextObject]))
if ([currentSource conformsToProtocol: @protocol(SOGoDNSource)] &&
@@ -671,9 +700,9 @@ static Class NSNullK;
//
- (BOOL) changePasswordForLogin: (NSString *) login
inDomain: (NSString *) domain
oldPassword: (NSString *) oldPassword
newPassword: (NSString *) newPassword
perr: (SOGoPasswordPolicyError *) perr
oldPassword: (NSString *) oldPassword
newPassword: (NSString *) newPassword
perr: (SOGoPasswordPolicyError *) perr
{
NSString *jsonUser, *userLogin;
NSMutableDictionary *currentUser;
@@ -722,21 +751,19 @@ static Class NSNullK;
SOGoDomainDefaults *dd;
domain = [contact objectForKey: @"c_domain"];
if ([domain length])
dd = [SOGoDomainDefaults defaultsForDomain: domain];
else
dd = [SOGoSystemDefaults sharedSystemDefaults];
dd = [SOGoDomainDefaults defaultsForDomain: domain];
emails = [contact objectForKey: @"emails"];
uid = [contact objectForKey: @"c_uid"];
if ([uid rangeOfString: @"@"].location == NSNotFound)
systemEmail
= [NSString stringWithFormat: @"%@@%@", uid, [dd mailDomain]];
else
systemEmail = uid;
// We always add the system email, which will always be returned
// by SOGoUser -systemEmail.
[emails addObject: systemEmail];
if ([emails count] == 0)
{
uid = [contact objectForKey: @"c_uid"];
if ([uid rangeOfString: @"@"].location == NSNotFound)
systemEmail = [NSString stringWithFormat: @"%@@%@", uid, [dd mailDomain]];
else
systemEmail = uid;
// We always add the system email, which will always be returned
// by SOGoUser -systemEmail.
[emails addObject: systemEmail];
}
[contact setObject: [emails objectAtIndex: 0] forKey: @"c_email"];
}
@@ -791,7 +818,7 @@ static Class NSNullK;
while (!userEntry && (sourceID = [sogoSources nextObject]))
{
currentSource = [_sources objectForKey: sourceID];
userEntry = [currentSource lookupContactEntryWithUIDorEmail: theUID
inDomain: theDomain];
if (userEntry)
@@ -906,7 +933,7 @@ static Class NSNullK;
[user setObject: [NSNumber numberWithBool: YES]
forKey: @"CalendarAccess"];
[user setObject: [NSNumber numberWithBool: NO]
forKey: @"MailAccess"];
forKey: @"MailAccess"];
}
return user;
@@ -935,7 +962,7 @@ static Class NSNullK;
// The domain is probably appended to the username;
// make sure it is a defined domain in the configuration.
domain = [uid substringFromIndex: (r.location + r.length)];
if ([[sd domainIds] containsObject: domain])
if ([self isDomainDefined: domain])
username = [uid substringToIndex: r.location];
else
domain = nil;
@@ -950,7 +977,7 @@ static Class NSNullK;
// search using the original uid.
infos = [self contactInfosForUserWithUIDorEmail: uid
inDomain: nil];
return infos;
}
@@ -979,29 +1006,29 @@ static Class NSNullK;
if ([currentUser isKindOfClass: NSNullK])
currentUser = nil;
else if (!([currentUser objectForKey: @"emails"]
&& [currentUser objectForKey: @"cn"]))
{
// We make sure that we either have no occurence of a cache entry or
// that we have an occurence with only a cached password. In the
// latter case, we update the entry with the remaining information
// and recache the value.
if (!currentUser ||
&& [currentUser objectForKey: @"cn"]))
{
// We make sure that we either have no occurence of a cache entry or
// that we have an occurence with only a cached password. In the
// latter case, we update the entry with the remaining information
// and recache the value.
if (!currentUser ||
([currentUser count] == 1 && [currentUser objectForKey: @"password"]) ||
([currentUser count] == 2 && [currentUser objectForKey: @"password"] && [currentUser objectForKey: @"DomainLessLogin"]))
{
newUser = YES;
newUser = YES;
if (!currentUser)
currentUser = [NSMutableDictionary dictionary];
}
else
newUser = NO;
[self _fillContactInfosForUser: currentUser
if (!currentUser)
currentUser = [NSMutableDictionary dictionary];
}
else
newUser = NO;
[self _fillContactInfosForUser: currentUser
withUIDorEmail: aUID
inDomain: domain];
if (newUser)
{
if ([[currentUser objectForKey: @"c_uid"] length] == 0)
if (newUser)
{
if ([[currentUser objectForKey: @"c_uid"] length] == 0)
{
[self _retainUser: (NSDictionary *) [NSNull null]
withLogin: cacheUid];
@@ -1024,7 +1051,7 @@ static Class NSNullK;
[self _retainUser: currentUser withLogin: cacheUid];
}
}
}
}
}
else
currentUser = nil;
@@ -1050,7 +1077,7 @@ static Class NSNullK;
while ((sourceID = [sources nextObject]))
{
currentSource = [_sources objectForKey: sourceID];
contact = [currentSource lookupContactEntry: uid];
contact = [currentSource lookupContactEntry: uid inDomain: domain];
if (contact)
[contacts addObject: contact];
}
@@ -1079,30 +1106,30 @@ static Class NSNullK;
{
uid = [userEntry objectForKey: @"c_uid"];
if ([uid length])
{
returnContact = [compactContacts objectForKey: uid];
if (!returnContact)
{
returnContact = [NSMutableDictionary dictionary];
[returnContact setObject: uid forKey: @"c_uid"];
{
returnContact = [compactContacts objectForKey: uid];
if (!returnContact)
{
returnContact = [NSMutableDictionary dictionary];
[returnContact setObject: uid forKey: @"c_uid"];
source = [userEntry objectForKey: @"source"];
if (source)
[returnContact setObject: source forKey: @"source"];
[compactContacts setObject: returnContact forKey: uid];
}
if (![[returnContact objectForKey: @"c_name"] length])
[returnContact setObject: [userEntry objectForKey: @"c_name"]
forKey: @"c_name"];
if (![[returnContact objectForKey: @"cn"] length])
[returnContact setObject: [userEntry objectForKey: @"c_cn"]
forKey: @"cn"];
emails = [returnContact objectForKey: @"emails"];
if (!emails)
{
emails = [NSMutableArray array];
[returnContact setObject: emails forKey: @"emails"];
}
email = [userEntry objectForKey: @"mail"];
if (![[returnContact objectForKey: @"c_name"] length])
[returnContact setObject: [userEntry objectForKey: @"c_name"]
forKey: @"c_name"];
if (![[returnContact objectForKey: @"cn"] length])
[returnContact setObject: [userEntry objectForKey: @"c_cn"]
forKey: @"cn"];
emails = [returnContact objectForKey: @"emails"];
if (!emails)
{
emails = [NSMutableArray array];
[returnContact setObject: emails forKey: @"emails"];
}
email = [userEntry objectForKey: @"mail"];
if ([email isKindOfClass: [NSArray class]])
{
allEmails = (NSArray *) email;
@@ -1114,22 +1141,22 @@ static Class NSNullK;
}
}
else if (email && ![emails containsObject: email])
[emails addObject: email];
email = [userEntry objectForKey: @"mozillasecondemail"];
if (email && ![emails containsObject: email])
[emails addObject: email];
email = [userEntry objectForKey: @"xmozillasecondemail"];
if (email && ![emails containsObject: email])
[emails addObject: email];
[emails addObject: email];
email = [userEntry objectForKey: @"mozillasecondemail"];
if (email && ![emails containsObject: email])
[emails addObject: email];
email = [userEntry objectForKey: @"xmozillasecondemail"];
if (email && ![emails containsObject: email])
[emails addObject: email];
info = [userEntry objectForKey: @"c_info"];
if ([info length] > 0
&& ![[returnContact objectForKey: @"c_info"] length])
[returnContact setObject: info forKey: @"c_info"];
[self _fillContactMailRecords: returnContact];
[self _fillContactMailRecords: returnContact];
isGroup = [userEntry objectForKey: @"isGroup"];
if (isGroup)
[returnContact setObject: isGroup forKey: @"isGroup"];
}
}
}
newContacts = [compactContacts allValues];
@@ -1138,7 +1165,7 @@ static Class NSNullK;
}
- (NSArray *) _fetchEntriesInSources: (NSArray *) sourcesList
matching: (NSString *) filter
matching: (NSString *) filter
inDomain: (NSString *) domain
{
NSMutableArray *contacts;
@@ -1152,7 +1179,7 @@ static Class NSNullK;
{
currentSource = [_sources objectForKey: sourceID];
[contacts addObjectsFromArray:
[currentSource fetchContactsMatching: filter
[currentSource fetchContactsMatching: filter
inDomain: domain]];
}
+2 -1
View File
@@ -620,8 +620,9 @@
- (NSDictionary *) lookupContactEntry: (NSString *) theID
inDomain: (NSString *) domain
{
return [self _lookupContactEntry: theID considerEmail: NO inDomain: nil];
return [self _lookupContactEntry: theID considerEmail: NO inDomain: domain];
}
- (NSDictionary *) lookupContactEntryWithUIDorEmail: (NSString *) entryID