Monotone-Parent: 066bfc11f82275269e5bf2cc1cbbf0e9427e8d96

Monotone-Revision: 716ad11e755f3a78bb0353df886cf08096149a36

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2007-07-10T19:23:39
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Wolfgang Sourdeau 2007-07-10 19:23:39 +00:00
parent 8d1c0726bb
commit 87a3d613b3
5 changed files with 80 additions and 82 deletions

View file

@ -175,49 +175,29 @@ static BOOL useAltNamespace = NO;
return [creds objectAtIndex:0]; /* the user */ return [creds objectAtIndex:0]; /* the user */
} }
- (NSString *)imap4URLString { - (NSMutableString *) imap4URLString
/* private, overridden by SOGoSharedMailAccount */
NSString *s;
NSRange r;
s = [self nameInContainer];
r = [s rangeOfString:@"@"];
if (r.length == 0) {
NSString *u;
u = [self imap4LoginFromHTTP];
if ([u length] == 0) {
[self errorWithFormat:@"missing login in account folder name: %@", s];
return nil;
}
s = [[u stringByAppendingString:@"@"] stringByAppendingString:s];
}
if ([s hasSuffix:@":80"]) { // HACK
[self logWithFormat:@"WARNING: incorrect value for IMAP4 URL: '%@'", s];
s = [s substringToIndex:([s length] - 3)];
}
s = [([self useSSL] ? @"imaps://" : @"imap://") stringByAppendingString:s];
s = [s stringByAppendingString:@"/"];
return s;
}
- (NSURL *) imap4URL
{ {
/* imap://agenortest@mail.opengroupware.org/ */ /* private, overridden by SOGoSharedMailAccount */
NSString *s; NSMutableString *urlString;
NSString *host;
if (!imap4URL) urlString = [NSMutableString string];
{
s = [self imap4URLString];
if (s)
imap4URL = [[NSURL alloc] initWithString: s];
}
return imap4URL; if ([self useSSL])
[urlString appendString: @"imaps://"];
else
[urlString appendString: @"imap://"];
host = [self nameInContainer];
if (![host rangeOfString: @"@"].length)
[urlString appendFormat: @"%@@", [self imap4LoginFromHTTP]];
[urlString appendFormat: @"%@/", host];
return urlString;
} }
- (NSString *)imap4Login { - (NSString *) imap4Login
{
return [[self imap4URL] user]; return [[self imap4URL] user];
} }

View file

@ -139,24 +139,23 @@ static BOOL debugOn = YES;
return url; return url;
} }
- (NSMutableString *) imap4URLString
{
NSMutableString *urlString;
urlString = [container imap4URLString];
[urlString appendFormat: @"%@/", [nameInContainer stringByEscapingURL]];
return urlString;
}
- (NSURL *) imap4URL - (NSURL *) imap4URL
{ {
NSString *thisName, *urlFormat, *urlString; /* this could probably be handled better from NSURL but it's buggy in
GNUstep */
if (!imap4URL) if (!imap4URL)
{ {
/* this could probably be handled better from NSURL but it's buggy in imap4URL = [[NSURL alloc] initWithString: [self imap4URLString]];
GNUstep */
urlString = [[container imap4URL] absoluteString];
thisName = [[self relativeImap4Name] stringByEscapingURL];
if ([urlString hasSuffix: @"/"])
urlFormat = @"%@%@";
else
urlFormat = @"%@/%@";
imap4URL = [[NSURL alloc]
initWithString: [NSString stringWithFormat: urlFormat,
urlString,
thisName]];
} }
return imap4URL; return imap4URL;

View file

@ -260,10 +260,12 @@ static BOOL useAltNamespace = NO;
/* check whether URL exists */ /* check whether URL exists */
sf = [self imap4URL]; sf = [self imap4URL];
sf = [NSURL URLWithString:[[sf path] stringByAppendingPathComponent:_key] sf = [NSURL URLWithString: _key relativeToURL: sf];
relativeToURL:sf];
if (![[self imap4Connection] doesMailboxExistAtURL:sf]) { // - sf = [NSURL URLWithString:[[sf path] stringByAppendingPathComponent:_key]
// - relativeToURL:sf];
if (![[self imap4Connection] doesMailboxExistAtURL: sf]) {
/* /*
We may not return 404, confuses path traversal - but we still do in the We may not return 404, confuses path traversal - but we still do in the
calling method. Probably the traversal process should be fixed to calling method. Probably the traversal process should be fixed to
@ -351,9 +353,11 @@ static BOOL useAltNamespace = NO;
/* build IMAP4 URL for target */ /* build IMAP4 URL for target */
destImapURL = [_target imap4URL]; destImapURL = [_target imap4URL];
destImapURL = [NSURL URLWithString:[[destImapURL path] // - destImapURL = [NSURL URLWithString:[[destImapURL path]
stringByAppendingPathComponent:_name] // - stringByAppendingPathComponent:_name]
relativeToURL:destImapURL]; // - relativeToURL:destImapURL];
destImapURL = [NSURL URLWithString: _name
relativeToURL: destImapURL];
[self logWithFormat:@"TODO: should move collection as '%@' to: %@", [self logWithFormat:@"TODO: should move collection as '%@' to: %@",
[[self imap4URL] absoluteString], [[self imap4URL] absoluteString],

View file

@ -22,7 +22,7 @@
#ifndef __Mailer_SOGoMailObject_H__ #ifndef __Mailer_SOGoMailObject_H__
#define __Mailer_SOGoMailObject_H__ #define __Mailer_SOGoMailObject_H__
#include <SoObjects/Mailer/SOGoMailBaseObject.h> #import <SoObjects/Mailer/SOGoMailBaseObject.h>
/* /*
SOGoMailObject SOGoMailObject

View file

@ -36,6 +36,7 @@
#import <NGExtensions/NSObject+Logs.h> #import <NGExtensions/NSObject+Logs.h>
#import <NGExtensions/NGQuotedPrintableCoding.h> #import <NGExtensions/NGQuotedPrintableCoding.h>
#import <NGExtensions/NSString+Encoding.h> #import <NGExtensions/NSString+Encoding.h>
#import <NGExtensions/NSString+misc.h>
#import <NGImap4/NGImap4Connection.h> #import <NGImap4/NGImap4Connection.h>
#import <NGImap4/NGImap4Envelope.h> #import <NGImap4/NGImap4Envelope.h>
#import <NGImap4/NGImap4EnvelopeAddress.h> #import <NGImap4/NGImap4EnvelopeAddress.h>
@ -100,16 +101,27 @@ static BOOL debugSoParts = NO;
} }
- (void)dealloc { - (void)dealloc {
[self->headers release]; [headers release];
[self->headerPart release]; [headerPart release];
[self->coreInfos release]; [coreInfos release];
[super dealloc]; [super dealloc];
} }
/* IMAP4 */ /* IMAP4 */
- (NSString *)relativeImap4Name { - (NSString *) relativeImap4Name
return [[self nameInContainer] stringByDeletingPathExtension]; {
return [nameInContainer stringByDeletingPathExtension];
}
- (NSMutableString *) imap4URLString
{
NSMutableString *urlString;
urlString = [container imap4URLString];
[urlString appendFormat: @"%@", [nameInContainer stringByEscapingURL]];
return urlString;
} }
/* hierarchy */ /* hierarchy */
@ -200,8 +212,8 @@ static BOOL debugSoParts = NO;
static NSArray *existsKey = nil; static NSArray *existsKey = nil;
id msgs; id msgs;
if (self->coreInfos != nil) /* if we have coreinfos, we can use them */ if (coreInfos != nil) /* if we have coreinfos, we can use them */
return [self->coreInfos isNotNull]; return [coreInfos isNotNull];
/* otherwise fetch something really simple */ /* otherwise fetch something really simple */
@ -216,8 +228,8 @@ static BOOL debugSoParts = NO;
- (id)fetchCoreInfos { - (id)fetchCoreInfos {
id msgs; id msgs;
if (self->coreInfos != nil) if (coreInfos != nil)
return [self->coreInfos isNotNull] ? self->coreInfos : nil; return [coreInfos isNotNull] ? coreInfos : nil;
#if 0 // TODO: old code, why was it using clientObject?? #if 0 // TODO: old code, why was it using clientObject??
msgs = [[self clientObject] fetchParts:coreInfoKeys]; // returns dict msgs = [[self clientObject] fetchParts:coreInfoKeys]; // returns dict
@ -229,8 +241,8 @@ static BOOL debugSoParts = NO;
if ([msgs count] == 0) if ([msgs count] == 0)
return nil; return nil;
self->coreInfos = [[msgs objectAtIndex:0] retain]; coreInfos = [[msgs objectAtIndex:0] retain];
return self->coreInfos; return coreInfos;
} }
- (id)bodyStructure { - (id)bodyStructure {
@ -284,27 +296,30 @@ static BOOL debugSoParts = NO;
NGMimeMessageParser *parser; NGMimeMessageParser *parser;
NSData *data; NSData *data;
if (self->headerPart != nil) if (headerPart != nil)
return [self->headerPart isNotNull] ? self->headerPart : nil; return [headerPart isNotNull] ? headerPart : nil;
if ([(data = [self mailHeaderData]) length] == 0) if ([(data = [self mailHeaderData]) length] == 0)
return nil; return nil;
// TODO: do we need to set some delegate method which stops parsing the body? // TODO: do we need to set some delegate method which stops parsing the body?
parser = [[NGMimeMessageParser alloc] init]; parser = [[NGMimeMessageParser alloc] init];
self->headerPart = [[parser parsePartFromData:data] retain]; headerPart = [[parser parsePartFromData:data] retain];
[parser release]; parser = nil; [parser release]; parser = nil;
if (self->headerPart == nil) { if (headerPart == nil) {
self->headerPart = [[NSNull null] retain]; headerPart = [[NSNull null] retain];
return nil; return nil;
} }
return self->headerPart; return headerPart;
} }
- (NSDictionary *)mailHeaders {
if (self->headers == nil) - (NSDictionary *) mailHeaders
self->headers = [[[self mailHeaderPart] headers] copy]; {
return self->headers; if (!headers)
headers = [[[self mailHeaderPart] headers] copy];
return headers;
} }
- (id)lookupInfoForBodyPart:(id)_path { - (id)lookupInfoForBodyPart:(id)_path {