Monotone-Parent: 41d1207879302957d2bb9e04793e78a7966863a0

Monotone-Revision: dc11ca564098f1f86ef07bafa645a1bc433e3cd7

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2007-06-14T21:23:14
Monotone-Branch: ca.inverse.sogo
maint-2.0.2
Wolfgang Sourdeau 2007-06-14 21:23:14 +00:00
parent 2cc3f8684d
commit 777a7f75e7
12 changed files with 62 additions and 257 deletions

View File

@ -1,3 +1,7 @@
2007-06-14 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* SoObjects/SOGo/SOGoLRUCache.m: removed unused module.
2007-06-13 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* UI/Scheduler/NSArray+Scheduler.m ([NSArray

View File

@ -19,21 +19,38 @@
02111-1307, USA.
*/
#include "SOGoDraftObject.h"
#include <SoObjects/SOGo/WOContext+Agenor.h>
#include <SoObjects/SOGo/NSCalendarDate+SOGo.h>
#include <NGMail/NGMimeMessage.h>
#include <NGMail/NGMimeMessageGenerator.h>
#include <NGMail/NGSendMail.h>
#include <NGMime/NGMimeBodyPart.h>
#include <NGMime/NGMimeFileData.h>
#include <NGMime/NGMimeMultipartBody.h>
#include <NGMime/NGMimeType.h>
#include <NGMime/NGMimeHeaderFieldGenerator.h>
#include <NGImap4/NGImap4Envelope.h>
#include <NGImap4/NGImap4EnvelopeAddress.h>
#include <NGExtensions/NSFileManager+Extensions.h>
#include "common.h"
#import <Foundation/NSArray.h>
#import <Foundation/NSAutoreleasePool.h>
#import <Foundation/NSDictionary.h>
#import <Foundation/NSKeyValueCoding.h>
#import <Foundation/NSUserDefaults.h>
#import <Foundation/NSValue.h>
#import <NGObjWeb/NSException+HTTP.h>
#import <NGObjWeb/SoObject+SoDAV.h>
#import <NGObjWeb/WOContext.h>
#import <NGObjWeb/WORequest+So.h>
#import <NGObjWeb/WOResponse.h>
#import <NGExtensions/NGBase64Coding.h>
#import <NGExtensions/NSFileManager+Extensions.h>
#import <NGExtensions/NGHashMap.h>
#import <NGExtensions/NSNull+misc.h>
#import <NGExtensions/NSObject+Logs.h>
#import <NGExtensions/NGQuotedPrintableCoding.h>
#import <NGImap4/NGImap4Envelope.h>
#import <NGImap4/NGImap4EnvelopeAddress.h>
#import <NGMail/NGMimeMessage.h>
#import <NGMail/NGMimeMessageGenerator.h>
#import <NGMail/NGSendMail.h>
#import <NGMime/NGMimeBodyPart.h>
#import <NGMime/NGMimeFileData.h>
#import <NGMime/NGMimeMultipartBody.h>
#import <NGMime/NGMimeType.h>
#import <NGMime/NGMimeHeaderFieldGenerator.h>
#import <SoObjects/SOGo/NSCalendarDate+SOGo.h>
#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.

View File

@ -23,7 +23,6 @@
#include "SOGoUser+Mail.h"
#include "common.h"
#include <NGObjWeb/SoObject+SoDAV.h>
#include <SOGo/WOContext+Agenor.h>
@implementation SOGoMailAccounts

View File

@ -19,6 +19,8 @@
02111-1307, USA.
*/
#warning importing common is baaad
#import <Foundation/Foundation.h>
#import <Foundation/NSObjCRuntime.h>

View File

@ -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 \

View File

@ -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

View File

@ -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 */

View File

@ -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 <Foundation/Foundation.h>
@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_ */

View File

@ -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

View File

@ -19,8 +19,8 @@
02111-1307, USA.
*/
#import "WOContext+Agenor.h"
#import "common.h"
#import "SOGoUser.h"
#import "Appointments/SOGoAppointmentFolder.h"

View File

@ -20,6 +20,8 @@
*/
// $Id: common.h 96 2004-06-30 08:35:34Z helge $
#warning importing common is baaad
#import <Foundation/Foundation.h>
#if NeXT_Foundation_LIBRARY || COCOA_Foundation_LIBRARY

View File

@ -40,7 +40,6 @@
#import <SoObjects/Mailer/SOGoMailAccounts.h>
#import <SoObjects/Mailer/SOGoMailIdentity.h>
#import <SoObjects/SOGo/SOGoUser.h>
#import <SoObjects/SOGo/WOContext+Agenor.h>
#import <SOGoUI/UIxComponent.h>
/*
@ -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 <WOActionResults> 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 */