Monotone-Parent: a8698cc119066cef660b176c3e956b5d0d843e7f

Monotone-Revision: f5b8996b9296ee950ea712c8de2c37e474163519

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2009-08-27T21:14:54
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Wolfgang Sourdeau committed 2009-08-27 21:14:54 +00:00
1 parent a38722d9cb
commit 06b296ddba
19 files changed
+698 -145

No files matched your search

+16
View File
@@ -245,6 +245,11 @@
return rType;
}
- (BOOL) davIsCollection
{
return YES;
}
/* web dav acl helper */
- (void) _fillArrayWithPrincipalsOwnedBySelf: (NSMutableArray *) hrefs
{
@@ -263,6 +268,17 @@
acquire: NO] _fillArrayWithPrincipalsOwnedBySelf: hrefs];
}
- (NSArray *) davGroupMemberSet
{
return [NSArray array];
}
- (NSArray *) davGroupMembership
{
return [NSArray array];
}
/* folder type */
- (BOOL) isEqual: (id) otherFolder
+3 -4
View File
@@ -87,10 +87,9 @@
- (NSException *) delete;
- (void) renameTo: (NSString *) newName;
- (WOResponse *) subscribe: (BOOL) reallyDo
inTheNamesOf: (NSArray *) delegatedUsers
fromMailInvitation: (BOOL) isMailInvitation
inContext: (WOContext *) localContext;
- (BOOL) subscribeUser: (NSString *) subscribingUser
reallyDo: (BOOL) reallyDo;
- (BOOL) userIsSubscriber: (NSString *) subscribingUser;
- (void) initializeQuickTablesAclsInContext: (WOContext *) localContext;
+82 -90
View File
@@ -650,26 +650,34 @@ static NSArray *childRecordFields = nil;
return cTag;
}
#warning this code should be cleaned up
- (void) _subscribeUser: (SOGoUser *) subscribingUser
reallyDo: (BOOL) reallyDo
fromMailInvitation: (BOOL) isMailInvitation
inResponse: (WOResponse *) response
- (BOOL) userIsSubscriber: (NSString *) subscribingUser
{
SOGoUser *sogoUser;
NSDictionary *moduleSettings;
NSArray *folderSubscription;
sogoUser = [SOGoUser userWithLogin: subscribingUser roles: nil];
moduleSettings = [[sogoUser userSettings]
objectForKey: [container nameInContainer]];
folderSubscription = [moduleSettings objectForKey: @"SubscribedFolders"];
return [folderSubscription containsObject: [self folderReference]];
}
- (BOOL) subscribeUser: (NSString *) subscribingUser
reallyDo: (BOOL) reallyDo
{
NSMutableArray *folderSubscription, *tmpA;
NSString *subscriptionPointer, *mailInvitationURL;
NSString *subscriptionPointer;
NSUserDefaults *ud;
NSMutableDictionary *moduleSettings, *tmpD;
SOGoUser *sogoUser;
BOOL rc;
if ([owner isEqualToString: [subscribingUser login]])
sogoUser = [SOGoUser userWithLogin: subscribingUser roles: nil];
if (sogoUser)
{
[response setStatus: 403];
[response appendContentString:
@"You cannot (un)subscribe to a folder that you own!"];
}
else
{
ud = [subscribingUser userSettings];
ud = [sogoUser userSettings];
moduleSettings = [ud objectForKey: [container nameInContainer]];
if (!(moduleSettings
&& [moduleSettings isKindOfClass: [NSMutableDictionary class]]))
@@ -687,7 +695,7 @@ static NSArray *childRecordFields = nil;
[moduleSettings setObject: folderSubscription
forKey: @"SubscribedFolders"];
}
subscriptionPointer = [self folderReference];
if (reallyDo)
[folderSubscription addObjectUniquely: subscriptionPointer];
@@ -717,82 +725,21 @@ static NSArray *childRecordFields = nil;
}
[ud synchronize];
if (isMailInvitation)
{
mailInvitationURL = [[self soURLToBaseContainerForCurrentUser]
absoluteString];
[response setStatus: 302];
[response setHeader: mailInvitationURL
forKey: @"location"];
}
else
[response setStatus: 204];
}
}
- (WOResponse *) subscribe: (BOOL) reallyDo
inTheNamesOf: (NSArray *) delegatedUsers
fromMailInvitation: (BOOL) isMailInvitation
inContext: (WOContext *) localContext
{
WOResponse *response;
SOGoUser *currentUser;
response = [localContext response];
[response setHeader: @"text/plain; charset=utf-8"
forKey: @"Content-Type"];
currentUser = [localContext activeUser];
if ([delegatedUsers count])
{
if (![currentUser isSuperUser])
{
[response setStatus: 403];
[response appendContentString:
@"You cannot subscribe another user to any folder"
@" unless you are a super-user."];
}
else
{
// The current user is a superuser...
SOGoUser *subscriptionUser;
int i;
for (i = 0; i < [delegatedUsers count]; i++)
{
// We trust the passed user ID here as it might generate tons or LDAP
// call but more importantly, cache propagation calls that will create
// contention on GDNC.
subscriptionUser = [SOGoUser userWithLogin: [delegatedUsers objectAtIndex: i]
roles: nil
trust: YES];
[self _subscribeUser: subscriptionUser
reallyDo: reallyDo
fromMailInvitation: isMailInvitation
inResponse: response];
}
}
rc = YES;
}
else
{
[self _subscribeUser: currentUser
reallyDo: reallyDo
fromMailInvitation: isMailInvitation
inResponse: response];
}
rc = NO;
return response;
return rc;
}
- (NSArray *) _parseDAVDelegatedUser: (WOContext *) queryContext
- (NSArray *) _parseDAVDelegatedUsers
{
id <DOMDocument> document;
id <DOMNamedNodeMap> attrs;
id o;
document = [[queryContext request] contentAsDOMDocument];
document = [[context request] contentAsDOMDocument];
attrs = [[document documentElement] attributes];
o = [attrs namedItem: @"users"];
@@ -802,20 +749,65 @@ static NSArray *childRecordFields = nil;
return nil;
}
- (WOResponse *) _davSubscribe: (BOOL) reallyDo
{
WOResponse *response;
SOGoUser *currentUser;
NSArray *delegatedUsers;
NSString *userLogin;
int count, max;
response = [context response];
[response setHeader: @"text/plain; charset=utf-8"
forKey: @"Content-Type"];
[response setStatus: 204];
currentUser = [context activeUser];
delegatedUsers = [self _parseDAVDelegatedUsers];
max = [delegatedUsers count];
if (max)
{
if ([currentUser isSuperUser])
{
/* We trust the passed user ID here as it might generate tons or
LDAP call but more importantly, cache propagation calls that will
create contention on GDNC. */
for (count = 0; count < max; count++)
[self subscribeUser: [delegatedUsers objectAtIndex: count]
reallyDo: reallyDo];
}
else
{
[response setStatus: 403];
[response appendContentString: @"You cannot subscribe another user"
@" to any folder unless you are a super-user."];
}
}
else
{
userLogin = [currentUser login];
if ([owner isEqualToString: userLogin])
{
[response setStatus: 403];
[response appendContentString:
@"You cannot (un)subscribe to a folder that you own!"];
}
else
[self subscribeUser: userLogin reallyDo: reallyDo];
}
return response;
}
- (id <WOActionResults>) davSubscribe: (WOContext *) queryContext
{
return [self subscribe: YES
inTheNamesOf: [self _parseDAVDelegatedUser: queryContext]
fromMailInvitation: NO
inContext: queryContext];
return [self _davSubscribe: YES];
}
- (id <WOActionResults>) davUnsubscribe: (WOContext *) queryContext
{
return [self subscribe: NO
inTheNamesOf: [self _parseDAVDelegatedUser: queryContext]
fromMailInvitation: NO
inContext: queryContext];
return [self _davSubscribe: NO];
}
- (NSDictionary *) davSQLFieldsTable
+1 -1
View File
@@ -1653,7 +1653,7 @@ SEL SOGoSelectorForPropertySetter (NSString *property)
}
else
exception
= [NSException exceptionWithHTTPStatus: 404
= [NSException exceptionWithHTTPStatus: 403
reason: [NSString stringWithFormat:
@"Property '%@' cannot be set.",
currentProp]];
+8 -14
View File
@@ -107,6 +107,7 @@ static SoSecurityManager *sm = nil;
{
subFolders = nil;
OCSPath = nil;
subscribedSubFolders = nil;
subFolderClass = Nil;
// hasSubscribedSources = NO;
}
@@ -116,6 +117,7 @@ static SoSecurityManager *sm = nil;
- (void) dealloc
{
[subscribedSubFolders release];
[subFolders release];
[OCSPath release];
[super dealloc];
@@ -353,29 +355,21 @@ static SoSecurityManager *sm = nil;
- (NSException *) initSubscribedSubFolders
{
NSArray *subscribedReferences;
NSUserDefaults *settings;
NSEnumerator *allKeys;
NSString *currentKey, *login;
NSString *login;
NSException *error;
if (!subFolderClass)
subFolderClass = [[self class] subFolderClass];
error = nil; /* we ignore non-DB errors at this time... */
login = [[context activeUser] login];
if (!subscribedSubFolders && [login isEqualToString: owner])
{
subscribedSubFolders = [NSMutableDictionary new];
settings = [[context activeUser] userSettings];
subscribedReferences = [[settings objectForKey: nameInContainer]
objectForKey: @"SubscribedFolders"];
if ([subscribedReferences isKindOfClass: [NSArray class]])
{
allKeys = [subscribedReferences objectEnumerator];
while ((currentKey = [allKeys nextObject]))
[self _appendSubscribedSource: currentKey];
}
error = [self appendSubscribedSources];
}
return error;
}
+54 -18
View File
@@ -43,6 +43,7 @@
#import <Appointments/SOGoAppointmentFolders.h>
#import <Appointments/SOGoFreeBusyObject.h>
#import <Appointments/SOGoCalendarProxy.h>
#import <Contacts/SOGoContactFolders.h>
#import <Mailer/SOGoMailAccounts.h>
@@ -53,6 +54,7 @@
#import "LDAPUserManager.h"
#import "SOGoPermissions.h"
#import "SOGoUser.h"
#import "WORequest+SOGo.h"
#import "SOGoUserFolder.h"
@@ -84,11 +86,21 @@ static NSString *LDAPContactInfoAttribute = nil;
currentUser = [context activeUser];
if ([currentUser canAccessModule: @"Calendar"])
[children addObject: @"Calendar"];
{
[children addObject: @"Calendar"];
/* support for caldav-proxy, which is currently limited to iCal but may
be enabled for others later, once we sort out the consistency between
subscribe folders and "proxy collections". */
if ([[context request] isICal])
{
[children addObject: @"calendar-proxy-write"];
[children addObject: @"calendar-proxy-read"];
}
}
[children addObject: @"Contacts"];
if ([currentUser canAccessModule: @"Mail"])
[children addObject: @"Mail"];
[children addObject: @"Preferences"];
// [children addObject: @"Preferences"];
return children;
}
@@ -529,6 +541,17 @@ static NSString *LDAPContactInfoAttribute = nil;
return [$(@"SOGoFreeBusyObject") objectWithName: _key inContainer: self];
}
- (id) calendarProxy: (NSString *) name withWriteAccess: (BOOL) hasWrite
{
id calendarProxy;
calendarProxy = [$(@"SOGoCalendarProxy") objectWithName: name
inContainer: self];
[calendarProxy setWriteAccess: hasWrite];
return calendarProxy;
}
- (id) lookupName: (NSString *) _key
inContext: (WOContext *) _ctx
acquire: (BOOL) _flag
@@ -541,23 +564,29 @@ static NSString *LDAPContactInfoAttribute = nil;
if (!obj)
{
currentUser = [_ctx activeUser];
if ([_key isEqualToString: @"Calendar"])
{
if ([currentUser canAccessModule: _key])
if ([currentUser canAccessModule: @"Calendar"])
{
if ([_key isEqualToString: @"Calendar"])
obj = [self privateCalendars: @"Calendar" inContext: _ctx];
else if ([_key isEqualToString: @"freebusy.ifb"])
obj = [self freeBusyObject:_key inContext: _ctx];
else if ([_key isEqualToString: @"calendar-proxy-write"])
obj = [self calendarProxy: _key withWriteAccess: YES];
else if ([_key isEqualToString: @"calendar-proxy-read"])
obj = [self calendarProxy: _key withWriteAccess: NO];
}
else if ([_key isEqualToString: @"Contacts"])
if (!obj
&& [_key isEqualToString: @"Mail"]
&& [currentUser canAccessModule: @"Mail"])
obj = [self mailAccountsFolder: _key inContext: _ctx];
if (!obj && [_key isEqualToString: @"Contacts"])
obj = [self privateContacts: _key inContext: _ctx];
else if ([_key isEqualToString: @"Mail"])
{
if ([currentUser canAccessModule: _key])
obj = [self mailAccountsFolder: _key inContext: _ctx];
}
else if ([_key isEqualToString: @"Preferences"])
obj = [$(@"SOGoPreferencesFolder") objectWithName: _key
inContainer: self];
else if ([_key isEqualToString: @"freebusy.ifb"])
obj = [self freeBusyObject:_key inContext: _ctx];
// else if ([_key isEqualToString: @"Preferences"])
// obj = [$(@"SOGoPreferencesFolder") objectWithName: _key
// inContainer: self];
if (!obj)
obj = [NSException exceptionWithHTTPStatus: 404 /* Not Found */];
@@ -584,9 +613,16 @@ static NSString *LDAPContactInfoAttribute = nil;
getCNForUID: nameInContainer];
}
- (BOOL) davIsCollection
- (NSArray *) davPrincipalURL
{
return YES;
NSArray *principalURL;
NSString *selfDAVPath;
selfDAVPath = [[self davURL] path];
principalURL = [NSArray arrayWithObjects: @"href", @"DAV:", @"D",
selfDAVPath, nil];
return [NSArray arrayWithObject: principalURL];
}
@end /* SOGoUserFolder */
+3
View File
@@ -29,7 +29,10 @@
- (BOOL) handledByDefaultHandler;
- (NSDictionary *) davPatchedPropertiesWithTopTag: (NSString *) topTag;
- (BOOL) isAppleDAVWithSubstring: (NSString *) osSubstring;
- (BOOL) isIPhone;
- (BOOL) isICal;
@end
+15 -5
View File
@@ -103,22 +103,32 @@
return patchedProperties;
}
- (BOOL) isIPhone
- (BOOL) isAppleDAVWithSubstring: (NSString *) osSubstring
{
WEClientCapabilities *cc;
BOOL rc;
NSRange r;
rc = NO;
cc = [self clientCapabilities];
if ([[cc userAgentType] isEqualToString: @"AppleDAVAccess"])
{
NSRange r = [[cc userAgent] rangeOfString: @"iPhone"];
if (r.location != NSNotFound)
rc = YES;
r = [[cc userAgent] rangeOfString: osSubstring];
rc = (r.location != NSNotFound);
}
else
rc = NO;
return rc;
}
- (BOOL) isIPhone
{
return [self isAppleDAVWithSubstring: @"iPhone/"];
}
- (BOOL) isICal
{
return [self isAppleDAVWithSubstring: @"Mac OS X/10."];
}
@end