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:
parent
8d1c0726bb
commit
87a3d613b3
|
@ -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 */
|
/* private, overridden by SOGoSharedMailAccount */
|
||||||
NSString *s;
|
NSMutableString *urlString;
|
||||||
NSRange r;
|
NSString *host;
|
||||||
|
|
||||||
s = [self nameInContainer];
|
urlString = [NSMutableString string];
|
||||||
r = [s rangeOfString:@"@"];
|
|
||||||
if (r.length == 0) {
|
|
||||||
NSString *u;
|
|
||||||
|
|
||||||
u = [self imap4LoginFromHTTP];
|
if ([self useSSL])
|
||||||
if ([u length] == 0) {
|
[urlString appendString: @"imaps://"];
|
||||||
[self errorWithFormat:@"missing login in account folder name: %@", s];
|
else
|
||||||
return nil;
|
[urlString appendString: @"imap://"];
|
||||||
}
|
|
||||||
s = [[u stringByAppendingString:@"@"] stringByAppendingString:s];
|
host = [self nameInContainer];
|
||||||
}
|
if (![host rangeOfString: @"@"].length)
|
||||||
if ([s hasSuffix:@":80"]) { // HACK
|
[urlString appendFormat: @"%@@", [self imap4LoginFromHTTP]];
|
||||||
[self logWithFormat:@"WARNING: incorrect value for IMAP4 URL: '%@'", s];
|
[urlString appendFormat: @"%@/", host];
|
||||||
s = [s substringToIndex:([s length] - 3)];
|
|
||||||
|
return urlString;
|
||||||
}
|
}
|
||||||
|
|
||||||
s = [([self useSSL] ? @"imaps://" : @"imap://") stringByAppendingString:s];
|
- (NSString *) imap4Login
|
||||||
s = [s stringByAppendingString:@"/"];
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (NSURL *) imap4URL
|
|
||||||
{
|
{
|
||||||
/* imap://agenortest@mail.opengroupware.org/ */
|
|
||||||
NSString *s;
|
|
||||||
|
|
||||||
if (!imap4URL)
|
|
||||||
{
|
|
||||||
s = [self imap4URLString];
|
|
||||||
if (s)
|
|
||||||
imap4URL = [[NSURL alloc] initWithString: s];
|
|
||||||
}
|
|
||||||
|
|
||||||
return imap4URL;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (NSString *)imap4Login {
|
|
||||||
return [[self imap4URL] user];
|
return [[self imap4URL] user];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -139,24 +139,23 @@ static BOOL debugOn = YES;
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSURL *) imap4URL
|
- (NSMutableString *) imap4URLString
|
||||||
{
|
{
|
||||||
NSString *thisName, *urlFormat, *urlString;
|
NSMutableString *urlString;
|
||||||
|
|
||||||
if (!imap4URL)
|
urlString = [container imap4URLString];
|
||||||
|
[urlString appendFormat: @"%@/", [nameInContainer stringByEscapingURL]];
|
||||||
|
|
||||||
|
return urlString;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSURL *) imap4URL
|
||||||
{
|
{
|
||||||
/* this could probably be handled better from NSURL but it's buggy in
|
/* this could probably be handled better from NSURL but it's buggy in
|
||||||
GNUstep */
|
GNUstep */
|
||||||
urlString = [[container imap4URL] absoluteString];
|
if (!imap4URL)
|
||||||
thisName = [[self relativeImap4Name] stringByEscapingURL];
|
{
|
||||||
if ([urlString hasSuffix: @"/"])
|
imap4URL = [[NSURL alloc] initWithString: [self imap4URLString]];
|
||||||
urlFormat = @"%@%@";
|
|
||||||
else
|
|
||||||
urlFormat = @"%@/%@";
|
|
||||||
imap4URL = [[NSURL alloc]
|
|
||||||
initWithString: [NSString stringWithFormat: urlFormat,
|
|
||||||
urlString,
|
|
||||||
thisName]];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return imap4URL;
|
return imap4URL;
|
||||||
|
|
|
@ -260,8 +260,10 @@ 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];
|
|
||||||
|
// - sf = [NSURL URLWithString:[[sf path] stringByAppendingPathComponent:_key]
|
||||||
|
// - relativeToURL:sf];
|
||||||
|
|
||||||
if (![[self imap4Connection] doesMailboxExistAtURL: sf]) {
|
if (![[self imap4Connection] doesMailboxExistAtURL: sf]) {
|
||||||
/*
|
/*
|
||||||
|
@ -351,8 +353,10 @@ 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];
|
||||||
|
destImapURL = [NSURL URLWithString: _name
|
||||||
relativeToURL: destImapURL];
|
relativeToURL: destImapURL];
|
||||||
|
|
||||||
[self logWithFormat:@"TODO: should move collection as '%@' to: %@",
|
[self logWithFormat:@"TODO: should move collection as '%@' to: %@",
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
Loading…
Reference in a new issue