From 48f210e151a8e91e63cb27312faa9d23ac4bcf4d Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Wed, 11 Apr 2007 19:17:20 +0000 Subject: [PATCH] Monotone-Parent: d690ff1fe2dd685ce9e4e5a8773578c039ec1bf4 Monotone-Revision: be3f824ea546882828787185ebfdd086e3742f87 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2007-04-11T19:17:20 Monotone-Branch: ca.inverse.sogo --- SoObjects/Appointments/SOGoFreeBusyObject.m | 2 +- SoObjects/Appointments/SOGoTaskObject.m | 2 +- SoObjects/Mailer/SOGoDraftObject.m | 6 ++--- SoObjects/Mailer/SOGoMailAccount.m | 14 +++-------- SoObjects/Mailer/SOGoMailAccounts.m | 28 +++------------------ SoObjects/Mailer/SOGoMailBaseObject.m | 2 +- SoObjects/SOGo/SOGoGroupFolder.m | 5 +--- 7 files changed, 13 insertions(+), 46 deletions(-) diff --git a/SoObjects/Appointments/SOGoFreeBusyObject.m b/SoObjects/Appointments/SOGoFreeBusyObject.m index b76cb819e..155e488cd 100644 --- a/SoObjects/Appointments/SOGoFreeBusyObject.m +++ b/SoObjects/Appointments/SOGoFreeBusyObject.m @@ -81,7 +81,7 @@ sm = [SoSecurityManager sharedSecurityManager]; if (![sm validatePermission: SOGoPerm_FreeBusyLookup onObject: calFolder - inContext: context]]) + inContext: context]) infos = [calFolder fetchFreeBusyInfosFrom: _startDate to: _endDate]; else diff --git a/SoObjects/Appointments/SOGoTaskObject.m b/SoObjects/Appointments/SOGoTaskObject.m index 9f539b78f..861b32c0f 100644 --- a/SoObjects/Appointments/SOGoTaskObject.m +++ b/SoObjects/Appointments/SOGoTaskObject.m @@ -142,7 +142,7 @@ static NSString *mailTemplateDefaultLanguage = nil; if (![folder isNotNull]) /* no folder was found for given UID */ continue; - task = [folder lookupName:[self nameInContainer] inContext:ctx + task = [folder lookupName:[self nameInContainer] inContext: context acquire:NO]; if ([task isKindOfClass: [NSException class]]) { diff --git a/SoObjects/Mailer/SOGoDraftObject.m b/SoObjects/Mailer/SOGoDraftObject.m index e82cd1ff7..9f66bb9e7 100644 --- a/SoObjects/Mailer/SOGoDraftObject.m +++ b/SoObjects/Mailer/SOGoDraftObject.m @@ -344,7 +344,6 @@ static NSString *fromInternetSuffixPattern = nil; { NSDictionary *lInfo; NGMimeMessage *message; - WOContext *ctx; NSString *fromInternetSuffix; BOOL addSuffix; id body; @@ -352,12 +351,11 @@ static NSString *fromInternetSuffixPattern = nil; if ((lInfo = [self fetchInfo]) == nil) return nil; - ctx = [[WOApplication application] context]; - addSuffix = [ctx isAccessFromIntranet] ? NO : YES; + addSuffix = [context isAccessFromIntranet] ? NO : YES; if (addSuffix) { fromInternetSuffix = [fromInternetSuffixPattern stringByReplacingVariablesWithBindings: - [ctx request] + [context request] stringForUnknownBindings:@""]; addSuffix = [fromInternetSuffix length] > 0 ? YES : NO; diff --git a/SoObjects/Mailer/SOGoMailAccount.m b/SoObjects/Mailer/SOGoMailAccount.m index 8a362fddf..a1c6285d9 100644 --- a/SoObjects/Mailer/SOGoMailAccount.m +++ b/SoObjects/Mailer/SOGoMailAccount.m @@ -124,16 +124,8 @@ static BOOL useAltNamespace = NO; /* identity */ - (SOGoMailIdentity *)preferredIdentity { - WOContext *ctx; - - if ((ctx = [[WOApplication application] context]) == nil) { - [self logWithFormat:@"ERROR(%s): cannot procede without context!", - __PRETTY_FUNCTION__]; - return nil; - } - - return [[ctx activeUser] primaryMailIdentityForAccount: - [self nameInContainer]]; + return [[context activeUser] primaryMailIdentityForAccount: + [self nameInContainer]]; } /* hierarchy */ @@ -161,7 +153,7 @@ static BOOL useAltNamespace = NO; NSString *s; NSArray *creds; - rq = [[(WOApplication *)[WOApplication application] context] request]; + rq = [context request]; s = [rq headerForKey:@"x-webobjects-remote-user"]; if ([s length] > 0) diff --git a/SoObjects/Mailer/SOGoMailAccounts.m b/SoObjects/Mailer/SOGoMailAccounts.m index d88bb9d5b..ed041aa38 100644 --- a/SoObjects/Mailer/SOGoMailAccounts.m +++ b/SoObjects/Mailer/SOGoMailAccounts.m @@ -32,8 +32,7 @@ static NSString *AgenorShareLoginMarker = @".-."; /* detect webmail being accessed from the outside */ - (BOOL)isInternetRequest { - return [[(WOApplication *)[WOApplication application] context] - isAccessFromIntranet] ? NO : YES; + return ([context isAccessFromIntranet] ? NO : YES); } /* listing the available mailboxes */ @@ -41,28 +40,15 @@ static NSString *AgenorShareLoginMarker = @".-."; - (BOOL)isInHomeFolderBranchOfLoggedInAccount:(id)_ctx { id user; - if (_ctx == nil) _ctx = [[WOApplication application] context]; - if (_ctx == nil) { - [self errorWithFormat:@"Missing context!"]; - return NO; - } - user = [_ctx activeUser]; return [[[self container] nameInContainer] isEqualToString:[user login]]; } - (NSArray *)toManyRelationshipKeys { - WOContext *ctx; id user; id account; NSArray *shares; - if ((ctx = [[WOApplication application] context]) == nil) { - [self logWithFormat:@"ERROR(%s): cannot procede without context!", - __PRETTY_FUNCTION__]; - return nil; - } - /* Note: this is not strictly correct. The accounts being retrieved should be the accounts based on the container object of this folder. Given @@ -73,10 +59,10 @@ static NSString *AgenorShareLoginMarker = @".-."; functionality which isn't perfect either. => TODO */ - user = [ctx activeUser]; + user = [context activeUser]; /* for now: return nothing if the home-folder does not belong to the login */ - if (![self isInHomeFolderBranchOfLoggedInAccount:ctx]) { + if (![self isInHomeFolderBranchOfLoggedInAccount: context]) { [self warnWithFormat:@"User %@ tried to access mail hierarchy of %@", [user login], [[self container] nameInContainer]]; return nil; @@ -97,17 +83,11 @@ static NSString *AgenorShareLoginMarker = @".-."; - (NSArray *)fetchIdentitiesWithOnlyEmitterAccess:(BOOL)_flag { WOContext *ctx; - if ((ctx = [[WOApplication application] context]) == nil) { - [self logWithFormat:@"ERROR(%s): cannot procede without context!", - __PRETTY_FUNCTION__]; - return nil; - } - if ([self isInternetRequest]) { /* only show primary mailbox in Internet */ // just return the primary identity id identity; - identity = [[ctx activeUser] primaryMailIdentity]; + identity = [[context activeUser] primaryMailIdentity]; return [identity isNotNull] ? [NSArray arrayWithObject:identity] : nil; } diff --git a/SoObjects/Mailer/SOGoMailBaseObject.m b/SoObjects/Mailer/SOGoMailBaseObject.m index 26d996b86..7fbbbfc6b 100644 --- a/SoObjects/Mailer/SOGoMailBaseObject.m +++ b/SoObjects/Mailer/SOGoMailBaseObject.m @@ -149,7 +149,7 @@ static BOOL debugOn = YES; NSString *auth; NSArray *creds; - rq = [[(WOApplication *)[WOApplication application] context] request]; + rq = [context request]; if ((auth = [rq headerForKey:@"authorization"]) == nil) { /* no basic auth */ return nil; diff --git a/SoObjects/SOGo/SOGoGroupFolder.m b/SoObjects/SOGo/SOGoGroupFolder.m index 189f0781c..054e4681d 100644 --- a/SoObjects/SOGo/SOGoGroupFolder.m +++ b/SoObjects/SOGo/SOGoGroupFolder.m @@ -92,7 +92,6 @@ static NGLogger *logger = nil; } - (void)_setupFolders { - WOContext *ctx; NSMutableDictionary *md; NSMutableArray *ma; NSArray *luids; @@ -103,8 +102,6 @@ static NGLogger *logger = nil; if ((luids = [self uids]) == nil) return; - ctx = [[WOApplication application] context]; - count = [luids count]; ma = [NSMutableArray arrayWithCapacity:count + 1]; md = [NSMutableDictionary dictionaryWithCapacity:count]; @@ -114,7 +111,7 @@ static NGLogger *logger = nil; id folder; uid = [luids objectAtIndex:i]; - folder = [self _primaryLookupFolderForUID:uid inContext:ctx]; + folder = [self _primaryLookupFolderForUID:uid inContext: context]; if ([folder isNotNull]) { [md setObject:folder forKey:uid];