From 6546f5d87181f6de5b4fc23d349c4494f939e4b0 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Fri, 10 Nov 2006 22:55:10 +0000 Subject: [PATCH] Monotone-Parent: 288cd149fa53f2ec3619c4b4918b9f4752626301 Monotone-Revision: 7085e2d34b73a7dabafe53dc2313675a5b2d8881 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2006-11-10T22:55:10 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 4 +++ UI/MailerUI/UIxMailView.m | 60 ++++++++++++++++++++++++++++++++------- 2 files changed, 53 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index cdd58059b..6e8fc040a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2006-11-10 Wolfgang Sourdeau + * UI/MailerUI/UIxMailView.m ([UIxMailView -moveAction]): new + action to move the current message to the mailbox named after the + value of parameter "tofolder". + * SoObjects/Mailer/SOGoMailObject.m ([SOGoMailObject -moveToFolderNamed:folderNameinContext:]): new method base on -trashInContext:. diff --git a/UI/MailerUI/UIxMailView.m b/UI/MailerUI/UIxMailView.m index 26142d93d..c775097dc 100644 --- a/UI/MailerUI/UIxMailView.m +++ b/UI/MailerUI/UIxMailView.m @@ -101,7 +101,7 @@ static NSString *mailETag = nil; id trash; trash = [[[self clientObject] mailAccountFolder] - trashFolderInContext:[self context]]; + trashFolderInContext:context]; if ([trash isKindOfClass:[NSException class]]) return NO; @@ -154,7 +154,7 @@ static NSString *mailETag = nil; id info; info = [[self clientObject] bodyStructure]; - return [[[self context] mailRenderingContext] viewerForBodyInfo:info]; + return [[context mailRenderingContext] viewerForBodyInfo:info]; } /* actions */ @@ -170,7 +170,7 @@ static NSString *mailETag = nil; */ NSString *s; - if ((s = [[[self context] request] headerForKey:@"if-none-match"])) { + if ((s = [[context request] headerForKey:@"if-none-match"])) { if ([s rangeOfString:mailETag].length > 0) { /* not perfectly correct */ /* client already has the proper entity */ // [self logWithFormat:@"MATCH: %@ (tag %@)", s, mailETag]; @@ -180,8 +180,8 @@ static NSString *mailETag = nil; reason:@"message got deleted"]; } - [[[self context] response] setStatus:304 /* Not Modified */]; - return [[self context] response]; + [[context response] setStatus:304 /* Not Modified */]; + return [context response]; } } } @@ -205,7 +205,7 @@ static NSString *mailETag = nil; - (id)redirectToParentFolder { id url; - url = [[[self clientObject] container] baseURLInContext:[self context]]; + url = [[[self clientObject] container] baseURLInContext:context]; return [self redirectToLocation:url]; } @@ -252,10 +252,10 @@ static NSString *mailETag = nil; [self logWithFormat:@"WARNING: method is invoked using safe HTTP method!"]; } - if ((ex = [[self clientObject] trashInContext:[self context]]) != nil) { + if ((ex = [[self clientObject] trashInContext:context]) != nil) { id url; - if ([[[[self context] request] formValueForKey:@"jsonly"] boolValue]) + if ([[[context request] formValueForKey:@"jsonly"] boolValue]) /* called using XMLHttpRequest */ return ex; @@ -264,10 +264,10 @@ static NSString *mailETag = nil; return [self redirectToLocation:url]; } - if ([[[[self context] request] formValueForKey:@"jsonly"] boolValue]) { + if ([[[context request] formValueForKey:@"jsonly"] boolValue]) { /* called using XMLHttpRequest */ - [[[self context] response] setStatus:200 /* OK */]; - return [[self context] response]; + [[context response] setStatus:200 /* OK */]; + return [context response]; } if (![self isInlineViewer]) { @@ -282,6 +282,44 @@ static NSString *mailETag = nil; return [self redirectToParentFolder]; } +- (id ) moveAction +{ + id *result; + NSString *destinationFolder; + id url; + + if ([self isInvokedBySafeMethod]) { + // TODO: fix UI to use POST for unsafe actions + [self logWithFormat:@"WARNING: method is invoked using safe HTTP method!"]; + } + + destinationFolder = [self queryParameterForKey: @"tofolder"]; + if ([destinationFolder length] > 0) + { + result = [[self clientObject] moveToFolderNamed: destinationFolder + inContext: context]; + if (result) + { + if (![[[context request] formValueForKey:@"jsonly"] boolValue]) + { + url = [NSString stringWithFormat: @"view?error=%@", + [[result reason] stringByEscapingURL]]; + result = [self redirectToLocation: url]; + } + } + else + { + result = [context response]; + [result setStatus: 200]; + } + } + else + result = [NSException exceptionWithHTTPStatus:500 /* Server Error */ + reason: @"No destination folder given"]; + + return result; +} + - (id)getMailAction { // TODO: we might want to flush the caches? return [self redirectToLocation:@"view"];