Monotone-Parent: 84ca160658d36fe85ed06cb0e19ed9f385489e47

Monotone-Revision: 288cd149fa53f2ec3619c4b4918b9f4752626301

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2006-11-10T22:53:57
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Wolfgang Sourdeau
2006-11-10 22:53:57 +00:00
parent af836d4bc9
commit 794e6f15ef
3 changed files with 73 additions and 0 deletions

View File

@@ -1,3 +1,9 @@
2006-11-10 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* SoObjects/Mailer/SOGoMailObject.m ([SOGoMailObject
-moveToFolderNamed:folderNameinContext:]): new method base on
-trashInContext:.
2006-11-09 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* UI/WebServerResources/generic.js: added and activated many

View File

@@ -87,6 +87,8 @@
- (BOOL)isDeletionAllowed;
- (NSException *)trashInContext:(id)_ctx;
- (NSException *) moveToFolderNamed: (NSString *) folderName
inContext: (id)_ctx;
@end

View File

@@ -800,6 +800,71 @@ static BOOL debugSoParts = NO;
return nil;
}
- (NSException *) moveToFolderNamed: (NSString *) folderName
inContext: (id)_ctx
{
/*
Trashing is three actions:
a) copy to trash folder
b) mark mail as deleted
c) expunge folder
In case b) or c) fails, we can't do anything because IMAP4 doesn't tell us
the ID used in the trash folder.
*/
SOGoMailFolder *destFolder;
NSEnumerator *folders;
NSString *currentFolderName, *reason;
NSException *error;
// TODO: check for safe HTTP method
destFolder = [self mailAccountsFolder];
folders = [[folderName componentsSeparatedByString: @"/"] objectEnumerator];
currentFolderName = [folders nextObject];
currentFolderName = [folders nextObject];
while (currentFolderName)
{
destFolder = [destFolder lookupName: currentFolderName
inContext: _ctx
acquire: NO];
if ([destFolder isKindOfClass: [NSException class]])
return (NSException *) destFolder;
currentFolderName = [folders nextObject];
}
if (!([destFolder isKindOfClass: [SOGoMailFolder class]]
&& [destFolder isNotNull]))
{
reason = [NSString stringWithFormat: @"Did not find folder name '%@'!",
folderName];
return [NSException exceptionWithHTTPStatus:500 /* Server Error */
reason: reason];
}
[destFolder flushMailCaches];
/* a) copy */
error = [self davCopyToTargetObject: destFolder
newName:@"fakeNewUnusedByIMAP4" /* autoassigned */
inContext:_ctx];
if (error != nil) return error;
/* b) mark deleted */
error = [[self imap4Connection] markURLDeleted: [self imap4URL]];
if (error != nil) return error;
/* c) expunge */
error = [[self imap4Connection] expungeAtURL:[[self container] imap4URL]];
if (error != nil) return error; // TODO: unflag as deleted?
[self flushMailCaches];
return nil;
}
- (NSException *)delete {
/*
Note: delete is different to DELETEAction: for mails! The 'delete' runs