+2005-07-07 Helge Hess <helge.hess@opengroupware.org>
+
+ * SOGoMailObject.m: implemented -trashInContext: method (v0.9.88)
+
2005-07-06 Helge Hess <helge.hess@opengroupware.org>
* SOGoMailObject.m: prefetch pgp-signature parts (v0.9.87)
- (NSException *)addFlags:(id)_f;
- (NSException *)removeFlags:(id)_f;
+/* deletion */
+
+- (BOOL)isDeletionAllowed;
+- (NSException *)trashInContext:(id)_ctx;
+
@end
#endif /* __Mailer_SOGoMailObject_H__ */
Also: we cannot really take a target resource, the ID will be assigned by
the IMAP4 server.
- TODO: return a 'location' header instead?
+ We even cannot return a 'location' header instead because IMAP4
+ doesn't tell us the new ID.
*/
NSURL *destImap4URL;
/* operations */
-- (NSException *)trashAction:(id)_ctx {
+- (NSException *)trashInContext:(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 *trashFolder;
NSException *error;
return [NSException exceptionWithHTTPStatus:500 /* Server Error */
reason:@"Did not find Trash folder!"];
}
+ [trashFolder flushMailCaches];
+
+ /* a) copy */
+
+ error = [self davCopyToTargetObject:trashFolder
+ newName:@"fakeNewUnusedByIMAP4" /* autoassigned */
+ inContext:_ctx];
+ if (error != nil) return error;
+
+ /* b) mark deleted */
- error = [self davCopyToTargetObject:trashFolder newName:nil inContext:_ctx];
+ error = [[self mailManager] markURLDeleted:[self imap4URL]
+ password:[self imap4Password]];
if (error != nil) return error;
+
+ /* c) expunge */
+ error = [[self mailManager] expungeAtURL:[[self container] imap4URL]
+ password:[self imap4Password]];
+ if (error != nil) return error; // TODO: unflag as deleted?
+ [self flushMailCaches];
+
return nil;
}
# Version file
-SUBMINOR_VERSION:=87
+SUBMINOR_VERSION:=88
# v0.9.69 requires libNGMime v4.5.210
# v0.9.55 requires libNGExtensions v4.5.136
+2005-07-07 Helge Hess <helge.hess@opengroupware.org>
+
+ * UIxMailView.m, product.plist: added -trash button and action
+ (v0.9.127)
+
2005-07-06 Helge Hess <helge.hess@opengroupware.org>
* product.plist: hide expunge button on mail folder when deleting is
return s;
}
+/* expunge / delete setup and permissions */
+
+- (BOOL)showMarkDeletedButton {
+ if (![[self clientObject] isDeletionAllowed])
+ return NO;
+
+ return NO; // TODO: make configurable in profile
+}
+
+- (BOOL)showTrashButton {
+ if (![[self clientObject] isDeletionAllowed])
+ return NO;
+ // TODO: should also check for Trash write access (or add -isTrashingAllowed)
+
+ return YES; // TODO: make configurable in profile
+}
+
/* links (DUP to UIxMailPartViewer!) */
- (NSString *)linkToEnvelopeAddress:(NGImap4EnvelopeAddress *)_address {
- (id)deleteAction {
NSException *ex;
-
+
if (![self isDeletableClientObject]) {
return [NSException exceptionWithHTTPStatus:400 /* Bad Request */
reason:@"method cannot be invoked on "
}
if ((ex = [[self clientObject] delete]) != nil) {
- // TODO: improve error handling
id url;
- [self debugWithFormat:@"failed to delete: %@", ex];
-
url = [[ex reason] stringByEscapingURL];
url = [@"view?error=" stringByAppendingString:url];
return [self redirectToLocation:url];
return [self redirectToParentFolder];
}
+- (id)trashAction {
+ NSException *ex;
+
+ if ([self isInvokedBySafeMethod]) {
+ // TODO: fix UI to use POST for unsafe actions
+ [self logWithFormat:@"WARNING: method is invoked using safe HTTP method!"];
+ }
+
+ if ((ex = [[self clientObject] trashInContext:[self context]]) != nil) {
+ id url;
+
+ url = [[ex reason] stringByEscapingURL];
+ url = [@"view?error=" stringByAppendingString:url];
+ return [self redirectToLocation:url];
+ }
+
+ if (![self isInlineViewer]) {
+ // if everything is ok, close the window (send a JS closing the Window)
+ id page;
+
+ page = [self pageWithName:@"UIxMailWindowCloser"];
+ [page takeValue:@"YES" forKey:@"refreshOpener"];
+ return page;
+ }
+
+ return [self redirectToParentFolder];
+}
+
- (id)getMailAction {
// TODO: we might want to flush the caches?
return [self redirectToLocation:@"view"];
# version file
-SUBMINOR_VERSION:=126
+SUBMINOR_VERSION:=127
# v0.9.100 requires libNGMime v4.5.213
# v0.9.99 requires libNGMime v4.5.212
cssClass = "tbicon_forward"; label = "Forward"; },
),
( // third group
- { link = "delete";
- isSafe = NO;
- enabled = clientObject.isDeletionAllowed;
+ { link = "delete"; isSafe = NO;
+ enabled = showMarkDeletedButton;
+ cssClass = "tbicon_delete"; label = "Delete"; },
+ { link = "trash"; isSafe = NO;
+ enabled = showTrashButton;
cssClass = "tbicon_delete"; label = "Delete"; },
/* TODO: enable when we know how to mark junk (#971)
{ link = "#";
pageName = "UIxMailView";
actionName = "delete";
};
+ trash = {
+ protectedBy = "View";
+ pageName = "UIxMailView";
+ actionName = "trash";
+ };
junk = {
protectedBy = "View";
pageName = "UIxMailView";