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 */
}
- (NSString *)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
- (NSMutableString *) imap4URLString
{
/* imap://agenortest@mail.opengroupware.org/ */
NSString *s;
if (!imap4URL)
{
s = [self imap4URLString];
if (s)
imap4URL = [[NSURL alloc] initWithString: s];
}
return imap4URL;
/* private, overridden by SOGoSharedMailAccount */
NSMutableString *urlString;
NSString *host;
urlString = [NSMutableString string];
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];
}

View file

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

View file

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

View file

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

View file

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