mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-08-28 17:57:38 +00:00
(fix) integrated latest OC changes
This commit is contained in:
@@ -3387,12 +3387,60 @@ firstInstanceCalendarDateRange: (NGCalendarDateRange *) fir
|
||||
}
|
||||
|
||||
/* acls */
|
||||
|
||||
/* Compare two permissions to set first the highest access right, if unknown, then
|
||||
do nothing */
|
||||
static NSComparisonResult _comparePermissions (id perm1, id perm2, void *context)
|
||||
{
|
||||
static NSDictionary *permMap = nil;
|
||||
NSNumber *num_1, *num_2;
|
||||
|
||||
if (!permMap)
|
||||
{
|
||||
NSMutableArray *numberObjs;
|
||||
NSUInteger i, max = 16;
|
||||
|
||||
numberObjs = [NSMutableArray arrayWithCapacity: max];
|
||||
for (i = 0; i < max; i++)
|
||||
[numberObjs addObject: [NSNumber numberWithInteger: i]];
|
||||
|
||||
/* Build the map to compare easily */
|
||||
permMap = [[NSDictionary alloc] initWithObjects: numberObjs
|
||||
forKeys: [NSArray arrayWithObjects:
|
||||
SOGoRole_ObjectEraser,
|
||||
SOGoRole_ObjectCreator,
|
||||
SOGoRole_ObjectEditor,
|
||||
SOGoCalendarRole_ConfidentialModifier,
|
||||
SOGoCalendarRole_ConfidentialResponder,
|
||||
SOGoCalendarRole_ConfidentialViewer,
|
||||
SOGoCalendarRole_ConfidentialDAndTViewer,
|
||||
SOGoCalendarRole_PrivateModifier,
|
||||
SOGoCalendarRole_PrivateResponder,
|
||||
SOGoCalendarRole_PrivateViewer,
|
||||
SOGoCalendarRole_PrivateDAndTViewer,
|
||||
SOGoCalendarRole_PublicModifier,
|
||||
SOGoCalendarRole_PublicResponder,
|
||||
SOGoCalendarRole_PublicViewer,
|
||||
SOGoCalendarRole_PublicDAndTViewer,
|
||||
SOGoCalendarRole_FreeBusyReader, nil]];
|
||||
[permMap retain];
|
||||
}
|
||||
|
||||
num_1 = [permMap objectForKey: perm1];
|
||||
if (!num_1)
|
||||
num_1 = [NSNumber numberWithInteger: 255];
|
||||
num_2 = [permMap objectForKey: perm2];
|
||||
if (!num_2)
|
||||
num_2 = [NSNumber numberWithInteger: 255];
|
||||
|
||||
return [num_1 compare: num_2];
|
||||
}
|
||||
|
||||
- (NSArray *) aclsForUser: (NSString *) uid
|
||||
forObjectAtPath: (NSArray *) objectPathArray
|
||||
{
|
||||
NSMutableArray *aclsForUser;
|
||||
NSArray *superAcls;
|
||||
static NSArray *rolesClassifications = nil;
|
||||
|
||||
superAcls = [super aclsForUser: uid forObjectAtPath: objectPathArray];
|
||||
if ([uid isEqualToString: [self defaultUserID]])
|
||||
@@ -3408,44 +3456,12 @@ firstInstanceCalendarDateRange: (NGCalendarDateRange *) fir
|
||||
}
|
||||
else
|
||||
{
|
||||
aclsForUser = [NSMutableArray array];
|
||||
if (!rolesClassifications)
|
||||
{
|
||||
rolesClassifications =
|
||||
[NSArray arrayWithObjects:
|
||||
[NSArray arrayWithObjects:
|
||||
SOGoCalendarRole_PublicModifier,
|
||||
SOGoCalendarRole_PublicResponder,
|
||||
SOGoCalendarRole_PublicViewer,
|
||||
SOGoCalendarRole_PublicDAndTViewer,
|
||||
nil],
|
||||
[NSArray arrayWithObjects:
|
||||
SOGoCalendarRole_ConfidentialModifier,
|
||||
SOGoCalendarRole_ConfidentialResponder,
|
||||
SOGoCalendarRole_ConfidentialViewer,
|
||||
SOGoCalendarRole_ConfidentialDAndTViewer,
|
||||
nil],
|
||||
[NSArray arrayWithObjects:
|
||||
SOGoCalendarRole_PrivateModifier,
|
||||
SOGoCalendarRole_PrivateResponder,
|
||||
SOGoCalendarRole_PrivateViewer,
|
||||
SOGoCalendarRole_PrivateDAndTViewer,
|
||||
nil],
|
||||
[NSArray arrayWithObject: SOGoRole_ObjectCreator],
|
||||
[NSArray arrayWithObject: SOGoRole_ObjectEraser],
|
||||
nil];
|
||||
[rolesClassifications retain];
|
||||
}
|
||||
// When a user is a member of many groups for which there are access rights, multiple access rights
|
||||
// can be returned for each classification. In this case, we only keep the highest access right.
|
||||
int i, count = [rolesClassifications count];
|
||||
NSString *role;
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
role = [[rolesClassifications objectAtIndex: i] firstObjectCommonWithArray: superAcls];
|
||||
if (role)
|
||||
[aclsForUser addObject: role];
|
||||
}
|
||||
/* Sort setting the highest access right first, so in the case
|
||||
of a user member of several groups, the highest access right
|
||||
is checked first, for instance, in
|
||||
[SOGoAppointmentFolder:roleForComponentsWithAccessClass:forUser] */
|
||||
aclsForUser = (NSMutableArray *) [superAcls sortedArrayUsingFunction: _comparePermissions
|
||||
context: NULL];
|
||||
}
|
||||
|
||||
return aclsForUser;
|
||||
|
||||
@@ -47,10 +47,13 @@
|
||||
{
|
||||
NSURL *imap4URL;
|
||||
NGImap4Connection *imap4;
|
||||
BOOL imap4ExceptionsEnabled;
|
||||
}
|
||||
|
||||
- (BOOL) isFolderish;
|
||||
|
||||
- (id) init;
|
||||
|
||||
- (id) initWithImap4URL: (NSURL *) _url
|
||||
inContainer: (id) _container;
|
||||
|
||||
|
||||
@@ -40,11 +40,25 @@
|
||||
|
||||
@implementation SOGoMailBaseObject
|
||||
|
||||
|
||||
- (id)init
|
||||
{
|
||||
if ((self = [super init]))
|
||||
{
|
||||
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
|
||||
// With this to YES, imap4Connection will raise exception if a working
|
||||
// connection cannot be provided
|
||||
imap4ExceptionsEnabled = [ud boolForKey:@"SoIMAP4ExceptionsEnabled"];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id) initWithImap4URL: (NSURL *) _url
|
||||
inContainer: (id) _container
|
||||
{
|
||||
NSString *n;
|
||||
|
||||
|
||||
n = [[_url path] lastPathComponent];
|
||||
if ((self = [self initWithName: n inContainer:_container]))
|
||||
{
|
||||
@@ -143,7 +157,10 @@
|
||||
if (!newConnection)
|
||||
{
|
||||
newConnection = (NGImap4Connection *) [NSNull null];
|
||||
[self errorWithFormat:@"Could not connect IMAP4"];
|
||||
if (imap4ExceptionsEnabled)
|
||||
[NSException raise: @"IOException" format: @"IMAP connection failed"];
|
||||
else
|
||||
[self errorWithFormat:@"Could not connect IMAP4"];
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -201,6 +218,22 @@
|
||||
[imap4 retain];
|
||||
}
|
||||
|
||||
// Connection broken, try to reconnect
|
||||
if (![imap4 isKindOfClass: [NSNull class]] && ![[[imap4 client] isConnected] boolValue])
|
||||
{
|
||||
[self warnWithFormat: @"IMAP connection is broken, trying to reconnect..."];
|
||||
[[imap4 client] reconnect];
|
||||
|
||||
// Still broken, give up
|
||||
if (![[[imap4 client] isConnected] boolValue])
|
||||
{
|
||||
if (imap4ExceptionsEnabled)
|
||||
[NSException raise: @"IOException" format: @"IMAP connection failed"];
|
||||
else
|
||||
[self errorWithFormat: @"Could not get a valid IMAP connection"];
|
||||
}
|
||||
}
|
||||
|
||||
return [imap4 isKindOfClass: [NSNull class]] ? nil : imap4;
|
||||
}
|
||||
|
||||
|
||||
@@ -129,9 +129,9 @@ NSArray *SOGoMailCoreInfoKeys;
|
||||
inContext: (id)_ctx;
|
||||
|
||||
- (void) addRequiredKeysOfStructure: (NSDictionary *) info
|
||||
path: (NSString *) p
|
||||
toArray: (NSMutableArray *) keys
|
||||
acceptedTypes: (NSArray *) types
|
||||
path: (NSString *) p
|
||||
toArray: (NSMutableArray *) keys
|
||||
acceptedTypes: (NSArray *) types
|
||||
withPeek: (BOOL) withPeek;
|
||||
|
||||
@end
|
||||
|
||||
@@ -507,12 +507,15 @@ static BOOL debugSoParts = NO;
|
||||
return s;
|
||||
}
|
||||
|
||||
/* This is defined before the public version without parentMimeType
|
||||
argument to be able to call it recursively */
|
||||
/* bulk fetching of plain/text content */
|
||||
- (void) addRequiredKeysOfStructure: (NSDictionary *) info
|
||||
path: (NSString *) p
|
||||
toArray: (NSMutableArray *) keys
|
||||
acceptedTypes: (NSArray *) types
|
||||
path: (NSString *) p
|
||||
toArray: (NSMutableArray *) keys
|
||||
acceptedTypes: (NSArray *) types
|
||||
withPeek: (BOOL) withPeek
|
||||
parentMultipart: (NSString *) parentMPart
|
||||
{
|
||||
/*
|
||||
This is used to collect the set of IMAP4 fetch-keys required to fetch
|
||||
@@ -527,6 +530,7 @@ static BOOL debugSoParts = NO;
|
||||
id body;
|
||||
NSString *bodyToken, *sp, *mimeType;
|
||||
id childInfo;
|
||||
NSString *multipart;
|
||||
|
||||
bodyToken = (withPeek ? @"body.peek" : @"body");
|
||||
|
||||
@@ -534,6 +538,12 @@ static BOOL debugSoParts = NO;
|
||||
[info valueForKey: @"type"],
|
||||
[info valueForKey: @"subtype"]]
|
||||
lowercaseString];
|
||||
|
||||
if ([[info valueForKey: @"type"] isEqualToString: @"multipart"])
|
||||
multipart = mimeType;
|
||||
else
|
||||
multipart = parentMPart;
|
||||
|
||||
if ([types containsObject: mimeType])
|
||||
{
|
||||
if ([p length] > 0)
|
||||
@@ -548,7 +558,8 @@ static BOOL debugSoParts = NO;
|
||||
k = [NSString stringWithFormat: @"%@[text]", bodyToken];
|
||||
}
|
||||
[keys addObject: [NSDictionary dictionaryWithObjectsAndKeys: k, @"key",
|
||||
mimeType, @"mimeType", nil]];
|
||||
mimeType, @"mimeType",
|
||||
multipart, @"multipart", nil]];
|
||||
}
|
||||
|
||||
parts = [info objectForKey: @"parts"];
|
||||
@@ -562,9 +573,11 @@ static BOOL debugSoParts = NO;
|
||||
childInfo = [parts objectAtIndex: i];
|
||||
|
||||
[self addRequiredKeysOfStructure: childInfo
|
||||
path: sp toArray: keys
|
||||
acceptedTypes: types
|
||||
withPeek: withPeek];
|
||||
path: sp
|
||||
toArray: keys
|
||||
acceptedTypes: types
|
||||
withPeek: withPeek
|
||||
parentMultipart: multipart];
|
||||
}
|
||||
|
||||
/* check body */
|
||||
@@ -588,12 +601,28 @@ static BOOL debugSoParts = NO;
|
||||
else
|
||||
sp = [p length] > 0 ? (id)[p stringByAppendingString: @".1"] : (id)@"1";
|
||||
[self addRequiredKeysOfStructure: body
|
||||
path: sp toArray: keys
|
||||
acceptedTypes: types
|
||||
withPeek: withPeek];
|
||||
path: sp
|
||||
toArray: keys
|
||||
acceptedTypes: types
|
||||
withPeek: withPeek
|
||||
parentMultipart: multipart];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) addRequiredKeysOfStructure: (NSDictionary *) info
|
||||
path: (NSString *) p
|
||||
toArray: (NSMutableArray *) keys
|
||||
acceptedTypes: (NSArray *) types
|
||||
withPeek: (BOOL) withPeek
|
||||
{
|
||||
[self addRequiredKeysOfStructure: (NSDictionary *) info
|
||||
path: (NSString *) p
|
||||
toArray: (NSMutableArray *) keys
|
||||
acceptedTypes: (NSArray *) types
|
||||
withPeek: (BOOL) withPeek
|
||||
parentMultipart: @""];
|
||||
}
|
||||
|
||||
- (NSArray *) plainTextContentFetchKeys
|
||||
{
|
||||
/*
|
||||
|
||||
@@ -57,6 +57,7 @@
|
||||
|
||||
#include "SOGoCache.h"
|
||||
#include "SOGoSource.h"
|
||||
#include "SOGoSystemDefaults.h"
|
||||
#include "SOGoUserManager.h"
|
||||
#include "SOGoUser.h"
|
||||
|
||||
@@ -102,13 +103,29 @@
|
||||
+ (id) groupWithIdentifier: (NSString *) theID
|
||||
inDomain: (NSString *) domain
|
||||
{
|
||||
NSString *uid;
|
||||
NSRange r;
|
||||
NSString *uid, *inDomain;
|
||||
SOGoSystemDefaults *sd;
|
||||
|
||||
uid = [theID hasPrefix: @"@"] ? [theID substringFromIndex: 1] : theID;
|
||||
inDomain = domain;
|
||||
|
||||
sd = [SOGoSystemDefaults sharedSystemDefaults];
|
||||
if ([sd enableDomainBasedUID])
|
||||
{
|
||||
/* Split domain from uid */
|
||||
r = [uid rangeOfString: @"@" options: NSBackwardsSearch];
|
||||
if (r.location != NSNotFound)
|
||||
{
|
||||
if (!domain)
|
||||
inDomain = [uid substringFromIndex: r.location + 1];
|
||||
uid = [uid substringToIndex: r.location];
|
||||
}
|
||||
}
|
||||
|
||||
return [SOGoGroup groupWithValue: uid
|
||||
andSourceSelector: @selector (lookupGroupEntryByUID:inDomain:)
|
||||
inDomain: domain];
|
||||
inDomain: inDomain];
|
||||
}
|
||||
|
||||
+ (id) groupWithEmail: (NSString *) theEmail
|
||||
|
||||
Reference in New Issue
Block a user