From 777a7f75e7570cc06e82980d7a5da05e5f1ff4c9 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Thu, 14 Jun 2007 21:23:14 +0000 Subject: [PATCH] Monotone-Parent: 41d1207879302957d2bb9e04793e78a7966863a0 Monotone-Revision: dc11ca564098f1f86ef07bafa645a1bc433e3cd7 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2007-06-14T21:23:14 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 4 + SoObjects/Mailer/SOGoDraftObject.m | 83 +++++++++------------ SoObjects/Mailer/SOGoMailAccounts.m | 1 - SoObjects/Mailer/common.h | 2 + SoObjects/SOGo/GNUmakefile | 2 - SoObjects/SOGo/SOGoAuthenticator.h | 5 -- SoObjects/SOGo/SOGoAuthenticator.m | 47 ++++-------- SoObjects/SOGo/SOGoLRUCache.h | 40 ---------- SoObjects/SOGo/SOGoLRUCache.m | 112 ---------------------------- SoObjects/SOGo/SOGoUserFolder.m | 2 +- SoObjects/SOGo/common.h | 2 + UI/MailerUI/UIxMailEditor.m | 19 +---- 12 files changed, 62 insertions(+), 257 deletions(-) delete mode 100644 SoObjects/SOGo/SOGoLRUCache.h delete mode 100644 SoObjects/SOGo/SOGoLRUCache.m diff --git a/ChangeLog b/ChangeLog index 4ba411021..b4ad8eccb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2007-06-14 Wolfgang Sourdeau + + * SoObjects/SOGo/SOGoLRUCache.m: removed unused module. + 2007-06-13 Wolfgang Sourdeau * UI/Scheduler/NSArray+Scheduler.m ([NSArray diff --git a/SoObjects/Mailer/SOGoDraftObject.m b/SoObjects/Mailer/SOGoDraftObject.m index fb871988c..92e99648f 100644 --- a/SoObjects/Mailer/SOGoDraftObject.m +++ b/SoObjects/Mailer/SOGoDraftObject.m @@ -19,21 +19,38 @@ 02111-1307, USA. */ -#include "SOGoDraftObject.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "common.h" +#import +#import +#import +#import +#import +#import + +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import + +#import + +#import "SOGoDraftObject.h" static NSString *contentTypeValue = @"text/plain; charset=utf-8"; @@ -70,7 +87,6 @@ static NSString *userAgent = @"SOGoMail 1.0"; static BOOL draftDeleteDisabled = NO; // for debugging static BOOL debugOn = NO; static BOOL showTextAttachmentsInline = NO; -static NSString *fromInternetSuffixPattern = nil; + (int)version { return [super version] + 0 /* v1 */; @@ -89,14 +105,6 @@ static NSString *fromInternetSuffixPattern = nil; if ((draftDeleteDisabled = [ud boolForKey:@"SOGoNoDraftDeleteAfterSend"])) NSLog(@"WARNING: draft delete is disabled! (SOGoNoDraftDeleteAfterSend)"); - fromInternetSuffixPattern = [ud stringForKey:@"SOGoInternetMailSuffix"]; - if ([fromInternetSuffixPattern length] == 0) - NSLog(@"Note: no 'SOGoInternetMailSuffix' is configured."); - else { - fromInternetSuffixPattern = - [@"\n" stringByAppendingString:fromInternetSuffixPattern]; - } - TextPlainType = [[NGMimeType mimeType:@"text" subType:@"plain"] copy]; MultiMixedType = [[NGMimeType mimeType:@"multipart" subType:@"mixed"] copy]; } @@ -341,49 +349,31 @@ static NSString *fromInternetSuffixPattern = nil; { NSDictionary *lInfo; NGMimeMessage *message; - NSString *fromInternetSuffix; BOOL addSuffix; id body; if ((lInfo = [self fetchInfo]) == nil) return nil; - addSuffix = [context isAccessFromIntranet] ? NO : YES; - if (addSuffix) { - fromInternetSuffix = - [fromInternetSuffixPattern stringByReplacingVariablesWithBindings: - [context request] - stringForUnknownBindings:@""]; - - addSuffix = [fromInternetSuffix length] > 0 ? YES : NO; - } - - [map setObject:@"text/plain" forKey:@"content-type"]; + [map setObject: @"text/plain" forKey: @"content-type"]; if ((body = [lInfo objectForKey:@"text"]) != nil) { - if ([body isKindOfClass:[NSString class]]) { - if (addSuffix) - body = [body stringByAppendingString:fromInternetSuffix]; - + if ([body isKindOfClass:[NSString class]]) /* Note: just 'utf8' is displayed wrong in Mail.app */ [map setObject: contentTypeValue forKey: @"content-type"]; // body = [body dataUsingEncoding:NSUTF8StringEncoding]; - } else if ([body isKindOfClass:[NSData class]] && addSuffix) { body = [[body mutableCopy] autorelease]; - [(NSMutableData *)body - appendData: [fromInternetSuffix dataUsingEncoding:NSUTF8StringEncoding]]; } else if (addSuffix) { [self warnWithFormat:@"Note: cannot add Internet marker to body: %@", NSStringFromClass([body class])]; } } - else if (addSuffix) - body = fromInternetSuffix; message = [[[NGMimeMessage alloc] initWithHeader:map] autorelease]; [message setBody:body]; + return message; } @@ -934,7 +924,8 @@ static NSString *fromInternetSuffixPattern = nil; return [NSNumber numberWithBool:YES]; /* delete worked out ... */ } -- (id)GETAction:(id)_ctx { +- (id) GETAction: (id) _ctx +{ /* Override, because SOGoObject's GETAction uses the less efficient -contentAsString method. diff --git a/SoObjects/Mailer/SOGoMailAccounts.m b/SoObjects/Mailer/SOGoMailAccounts.m index 8e7c8a582..03ea7d01c 100644 --- a/SoObjects/Mailer/SOGoMailAccounts.m +++ b/SoObjects/Mailer/SOGoMailAccounts.m @@ -23,7 +23,6 @@ #include "SOGoUser+Mail.h" #include "common.h" #include -#include @implementation SOGoMailAccounts diff --git a/SoObjects/Mailer/common.h b/SoObjects/Mailer/common.h index a11785e59..c694a6dc5 100644 --- a/SoObjects/Mailer/common.h +++ b/SoObjects/Mailer/common.h @@ -19,6 +19,8 @@ 02111-1307, USA. */ +#warning importing common is baaad + #import #import diff --git a/SoObjects/SOGo/GNUmakefile b/SoObjects/SOGo/GNUmakefile index 03916b358..1ec3ad1d8 100644 --- a/SoObjects/SOGo/GNUmakefile +++ b/SoObjects/SOGo/GNUmakefile @@ -31,7 +31,6 @@ libSOGo_HEADER_FILES = \ LDAPUserManager.h \ LDAPSource.h \ SOGoPermissions.h \ - SOGoLRUCache.h \ WOContext+Agenor.h \ SOGoDAVRendererTypes.h \ NSArray+Utilities.h \ @@ -57,7 +56,6 @@ libSOGo_OBJC_FILES = \ SOGoCustomGroupFolder.m \ \ SOGoPermissions.m \ - SOGoLRUCache.m \ LDAPUserManager.m \ LDAPSource.m \ WOContext+Agenor.m \ diff --git a/SoObjects/SOGo/SOGoAuthenticator.h b/SoObjects/SOGo/SOGoAuthenticator.h index a56ac4267..248829673 100644 --- a/SoObjects/SOGo/SOGoAuthenticator.h +++ b/SoObjects/SOGo/SOGoAuthenticator.h @@ -38,17 +38,12 @@ @interface SOGoAuthenticator : SoHTTPAuthenticator { - NSUserDefaults *ud; NSString *authMethod; - NSString *LDAPBaseDN; - NSString *LDAPHost; int LDAPPort; } + (id) sharedSOGoAuthenticator; -- (BOOL) LDAPCheckLogin: (NSString *) _login password: (NSString *) _pwd; - - (SOGoUser *) userInContext: (WOContext *) _ctx; @end diff --git a/SoObjects/SOGo/SOGoAuthenticator.m b/SoObjects/SOGo/SOGoAuthenticator.m index 134dba023..19d1fbdc2 100644 --- a/SoObjects/SOGo/SOGoAuthenticator.m +++ b/SoObjects/SOGo/SOGoAuthenticator.m @@ -30,32 +30,25 @@ @implementation SOGoAuthenticator -static SOGoAuthenticator *auth = nil; - + (id) sharedSOGoAuthenticator { - if (auth == nil) - auth = [[self alloc] init]; + static SOGoAuthenticator *auth = nil; + + if (!auth) + auth = [self new]; + return auth; } - (id) init { + NSUserDefaults *ud; + if ((self = [super init])) { ud = [NSUserDefaults standardUserDefaults]; - LDAPBaseDN = nil; - LDAPHost = nil; - LDAPPort = -1; - authMethod = [[ud stringForKey:@"AuthentificationMethod"] retain]; - if ([authMethod isEqualToString: @"LDAP"]) - { -// LDAPBaseDN = [[ud stringForKey:@"LDAPRootDN"] retain]; -// LDAPHost = [[ud stringForKey:@"LDAPHost"] retain]; -// LDAPPort = [ud integerForKey:@"LDAPPort"]; - } } return self; @@ -63,10 +56,6 @@ static SOGoAuthenticator *auth = nil; - (void) dealloc { - if (LDAPBaseDN) - [LDAPBaseDN release]; - if (LDAPHost) - [LDAPHost release]; [authMethod release]; [super dealloc]; } @@ -75,25 +64,19 @@ static SOGoAuthenticator *auth = nil; password: (NSString *) _pwd { BOOL accept; + LDAPUserManager *um; if ([authMethod isEqualToString: @"LDAP"]) - accept = [self LDAPCheckLogin: _login password: _pwd]; + { + um = [LDAPUserManager sharedUserManager]; + accept = [um checkLogin: _login andPassword: _pwd]; + } else accept = ([_login length] > 0); - return (([_login isEqualToString: @"freebusy"] - && [_pwd isEqualToString: @"freebusy"]) - || accept); -} - -- (BOOL) LDAPCheckLogin: (NSString *) _login - password: (NSString *) _pwd -{ - LDAPUserManager *um; - - um = [LDAPUserManager sharedUserManager]; - - return [um checkLogin: _login andPassword: _pwd]; + return (accept + || ([_login isEqualToString: @"freebusy"] + && [_pwd isEqualToString: @"freebusy"])); } /* create SOGoUser */ diff --git a/SoObjects/SOGo/SOGoLRUCache.h b/SoObjects/SOGo/SOGoLRUCache.h deleted file mode 100644 index a7cee3c21..000000000 --- a/SoObjects/SOGo/SOGoLRUCache.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - Copyright (C) 2000-2004 SKYRIX Software AG - - This file is part of OGo - - OGo is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License as published by the - Free Software Foundation; either version 2, or (at your option) any - later version. - - OGo is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with OGo; see the file COPYING. If not, write to the - Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. - */ - -#ifndef __SOGoLRUCache_H_ -#define __SOGoLRUCache_H_ - -#import - -@interface SOGoLRUCache : NSObject -{ - unsigned size; - NSMutableDictionary *entries; -} - -- (id)initWithCacheSize:(unsigned)_size; - -- (void)addObject:(id)_obj forKey:(id)_key; -- (id)objectForKey:(id)_key; - -@end - -#endif /* __SOGoLRUCache_H_ */ diff --git a/SoObjects/SOGo/SOGoLRUCache.m b/SoObjects/SOGo/SOGoLRUCache.m deleted file mode 100644 index 9fdacf5ca..000000000 --- a/SoObjects/SOGo/SOGoLRUCache.m +++ /dev/null @@ -1,112 +0,0 @@ -/* - Copyright (C) 2000-2004 SKYRIX Software AG - - This file is part of OGo - - OGo is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License as published by the - Free Software Foundation; either version 2, or (at your option) any - later version. - - OGo is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with OGo; see the file COPYING. If not, write to the - Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. - */ - -#include "SOGoLRUCache.h" -#include "common.h" - -@interface SOGoLRUCacheItem : NSObject -{ - id object; - unsigned useCount; -} - -- (id)initWithObject:(id)_obj; -- (id)object; - -- (unsigned)useCount; - -@end - -@implementation SOGoLRUCacheItem - -- (id)initWithObject:(id)_obj { - self = [super init]; - if(self) { - ASSIGN(self->object, _obj); - self->useCount = 1; - } - return self; -} - -- (id)object { - self->useCount++; - return self->object; -} - -- (unsigned)useCount { - return self->useCount; -} - -@end - -@implementation SOGoLRUCache - -- (id)initWithCacheSize:(unsigned)_size { - self = [super init]; - if(self) { - self->size = _size; - self->entries = [[NSMutableDictionary alloc] initWithCapacity:_size]; - } - return self; -} - -- (void)dealloc { - [self->entries release]; - [super dealloc]; -} - -- (void)addObject:(id)_obj forKey:(id)_key { - SOGoLRUCacheItem *item; - - NSAssert(_obj, @"Attempt to insert nil object!"); - - if([self->entries count] >= self->size) { - /* need to find minimum and get rid of it */ - NSEnumerator *keyEnum; - SOGoLRUCacheItem *item; - id key, leastUsedItemKey; - unsigned minimumUseCount = INT_MAX; - - keyEnum = [self->entries keyEnumerator]; - while((key = [keyEnum nextObject])) { - item = [self->entries objectForKey:key]; - if([item useCount] < minimumUseCount) { - minimumUseCount = [item useCount]; - leastUsedItemKey = key; - } - } - [self->entries removeObjectForKey:leastUsedItemKey]; - } - item = [[SOGoLRUCacheItem alloc] initWithObject:_obj]; - [self->entries setObject:item forKey:_key]; - [item release]; -} - -- (id)objectForKey:(id)_key { - SOGoLRUCacheItem *item; - - item = [self->entries objectForKey:_key]; - if(!item) - return nil; - return [item object]; -} - -@end diff --git a/SoObjects/SOGo/SOGoUserFolder.m b/SoObjects/SOGo/SOGoUserFolder.m index 8664beeda..ca0ec34e6 100644 --- a/SoObjects/SOGo/SOGoUserFolder.m +++ b/SoObjects/SOGo/SOGoUserFolder.m @@ -19,8 +19,8 @@ 02111-1307, USA. */ -#import "WOContext+Agenor.h" #import "common.h" + #import "SOGoUser.h" #import "Appointments/SOGoAppointmentFolder.h" diff --git a/SoObjects/SOGo/common.h b/SoObjects/SOGo/common.h index 47b267035..accf3cf26 100644 --- a/SoObjects/SOGo/common.h +++ b/SoObjects/SOGo/common.h @@ -20,6 +20,8 @@ */ // $Id: common.h 96 2004-06-30 08:35:34Z helge $ +#warning importing common is baaad + #import #if NeXT_Foundation_LIBRARY || COCOA_Foundation_LIBRARY diff --git a/UI/MailerUI/UIxMailEditor.m b/UI/MailerUI/UIxMailEditor.m index cb4954e47..6b530be21 100644 --- a/UI/MailerUI/UIxMailEditor.m +++ b/UI/MailerUI/UIxMailEditor.m @@ -40,7 +40,6 @@ #import #import #import -#import #import /* @@ -226,19 +225,6 @@ static NSArray *infoKeys = nil; return [self labelForKey:@"Compose Mail"]; } -/* detect webmail being accessed from the outside */ - -- (BOOL)isInternetRequest { - // DEPRECATED - return [[self context] isAccessFromIntranet] ? NO : YES; -} - -- (BOOL)showInternetMarker { - if (!showInternetMarker) - return NO; - return [[self context] isAccessFromIntranet] ? NO : YES; -} - /* info loading */ - (void)loadInfo:(NSDictionary *)_info { @@ -507,7 +493,6 @@ static NSArray *infoKeys = nil; { NSException *error; NSString *mailPath; - NSDictionary *h; id result; // TODO: need to validate whether we have a To etc @@ -529,12 +514,10 @@ static NSArray *infoKeys = nil; /* setup some extra headers if required */ - h = [[self context] isAccessFromIntranet] ? nil : internetMailHeaders; - /* save mail to file (so that we can upload the mail to Cyrus) */ // TODO: all this could be handled by the SOGoDraftObject? - mailPath = [[self clientObject] saveMimeMessageToTemporaryFileWithHeaders:h]; + mailPath = [[self clientObject] saveMimeMessageToTemporaryFileWithHeaders: internetMailHeaders]; /* then, send mail */