See ChangeLog

Monotone-Parent: a0f83515485c5754a47ce96dd157fbafe1cdd459
Monotone-Revision: b4cdf2c0fe2ace70d873c007f3fd15f64aa0f91a

Monotone-Author: ludovic@Sophos.ca
Monotone-Date: 2009-03-13T19:48:15
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Ludovic Marcotte
2009-03-13 19:48:15 +00:00
parent 624ff85d71
commit c3bc74e116
4 changed files with 52 additions and 24 deletions
+36 -19
View File
@@ -289,7 +289,18 @@ static NSString *spoolFolder = nil;
client = [[self imap4Connection] client];
[imap4 selectFolder: [self imap4URL]];
folderName = [imap4 imap4FolderNameForURL: [trashFolder imap4URL]];
result = [client copyUids: uids toFolder: folderName];
// If our Trash folder doesn't exist when we try to copy messages
// to it, we create it.
result = [[client status: folderName flags: [NSArray arrayWithObject: @"UIDVALIDITY"]]
objectForKey: @"result"];
if (![result boolValue])
result = [[self imap4Connection] createMailbox: folderName atURL: [[self mailAccountFolder] imap4URL]];
if (!result || [result boolValue])
result = [client copyUids: uids toFolder: folderName];
if ([[result valueForKey: @"result"] boolValue])
{
result = [client storeFlags: [NSArray arrayWithObject: @"Deleted"]
@@ -423,7 +434,15 @@ static NSString *spoolFolder = nil;
client = [[self imap4Connection] client];
[imap4 selectFolder: [self imap4URL]];
result = [client copyUids: uids toFolder: imapDestinationFolder];
// We make sure the destination IMAP folder exist, if not, we create it.
result = [[client status: imapDestinationFolder flags: [NSArray arrayWithObject: @"UIDVALIDITY"]]
objectForKey: @"result"];
if (![result boolValue])
result = [[self imap4Connection] createMailbox: imapDestinationFolder atURL: [[self mailAccountFolder] imap4URL]];
if (!result || [result boolValue])
result = [client copyUids: uids toFolder: imapDestinationFolder];
if ([[result valueForKey: @"result"] boolValue])
result = nil;
@@ -475,8 +494,15 @@ static NSString *spoolFolder = nil;
- (NSException *) postData: (NSData *) _data
flags: (id) _flags
{
return [[self imap4Connection] postData: _data flags: _flags
toFolderURL: [self imap4URL]];
// We check for the existence of the IMAP folder (likely to be the
// Sent mailbox) prior to appending messages to it.
if ([[self imap4Connection] doesMailboxExistAtURL: [self imap4URL]] ||
![[self imap4Connection] createMailbox: [self relativeImap4Name] atURL: [[self mailAccountFolder] imap4URL]])
return [[self imap4Connection] postData: _data flags: _flags
toFolderURL: [self imap4URL]];
return [NSException exceptionWithHTTPStatus: 502 /* Bad Gateway */
reason: [NSString stringWithFormat: @"%@ is not an IMAP4 folder", [self relativeImap4Name]]];
}
- (NSException *) expunge
@@ -577,7 +603,12 @@ static NSString *spoolFolder = nil;
}
else
{
if ([[self imap4Connection] doesMailboxExistAtURL: [self imap4URL]])
// We automatically create mailboxes that don't exist but that we're
// trying to open. This shouldn't happen unless a mailbox has been
// deleted "behind our back" or if we're trying to open a special
// mailbox that doesn't yet exist.
if ([[self imap4Connection] doesMailboxExistAtURL: [self imap4URL]] ||
![[self imap4Connection] createMailbox: [self relativeImap4Name] atURL: [[self mailAccountFolder] imap4URL]])
{
if (isdigit ([_key characterAtIndex: 0]))
obj = [SOGoMailObject objectWithName: _key inContainer: self];
@@ -1069,20 +1100,6 @@ static NSString *spoolFolder = nil;
@implementation SOGoSpecialMailFolder
- (id) initWithName: (NSString *) newName
inContainer: (id) newContainer
{
if ((self = [super initWithName: newName
inContainer: newContainer]))
{
if (![[self imap4Connection] doesMailboxExistAtURL: [self imap4URL]])
[imap4 createMailbox: [self relativeImap4Name]
atURL: [newContainer imap4URL]];
}
return self;
}
- (BOOL) isSpecialFolder
{
return YES;