From: helge Date: Fri, 28 Jan 2005 17:04:53 +0000 (+0000) Subject: partially implemented mail delete #1212 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=008db7421a137049609a2589706e228df8b75c15;p=scalable-opengroupware.org partially implemented mail delete #1212 git-svn-id: http://svn.opengroupware.org/SOGo/trunk@504 d1b88da0-ebda-0310-925b-ed51d893ca5b --- diff --git a/SOGo/SoObjects/Mailer/ChangeLog b/SOGo/SoObjects/Mailer/ChangeLog index 6e87c5bb..93da62fa 100644 --- a/SOGo/SoObjects/Mailer/ChangeLog +++ b/SOGo/SoObjects/Mailer/ChangeLog @@ -1,5 +1,18 @@ 2005-01-28 Helge Hess - + + * v0.9.58 + + * SOGoMailObject.m: implemented a simple delete by setting the IMAP4 + delete flag + + * SOGoMailManager.m: added method to mark a message deleted + + * SOGoMailFolder.m: just override -delete instead of implementing + -DELETAction: directrly + + * SOGoMailAccount.m: added ability to retrieve Sent/Trash and INBOX + special mail folders + * v0.9.57 * SOGoMailBodyPart.m: enhanced lookup to allow for arbitary filenames diff --git a/SOGo/SoObjects/Mailer/SOGoMailAccount.h b/SOGo/SoObjects/Mailer/SOGoMailAccount.h index 2a19c958..20c30d6d 100644 --- a/SOGo/SoObjects/Mailer/SOGoMailAccount.h +++ b/SOGo/SoObjects/Mailer/SOGoMailAccount.h @@ -34,13 +34,23 @@ */ @class NSArray; +@class SOGoMailFolder; @interface SOGoMailAccount : SOGoMailBaseObject { + SOGoMailFolder *inboxFolder; + SOGoMailFolder *sentFolder; + SOGoMailFolder *trashFolder; } - (NSArray *)allFolderPathes; +/* special folders */ + +- (SOGoMailFolder *)inboxFolderInContext:(id)_ctx; +- (SOGoMailFolder *)sentFolderInContext:(id)_ctx; +- (SOGoMailFolder *)trashFolderInContext:(id)_ctx; + @end #endif /* __Mailer_SOGoMailAccount_H__ */ diff --git a/SOGo/SoObjects/Mailer/SOGoMailAccount.m b/SOGo/SoObjects/Mailer/SOGoMailAccount.m index bc3c0031..1e3c6741 100644 --- a/SOGo/SoObjects/Mailer/SOGoMailAccount.m +++ b/SOGo/SoObjects/Mailer/SOGoMailAccount.m @@ -142,6 +142,63 @@ static NSString *sieveFolderName = @"Filters"; return [NSException exceptionWithHTTPStatus:404 /* Not Found */]; } +/* special folders */ + +- (SOGoMailFolder *)inboxFolderInContext:(id)_ctx { + // TODO: use some profile to determine real location + SOGoMailFolder *folder; + + if (self->inboxFolder != nil) + return self->inboxFolder; + + folder = [self lookupName:@"INBOX" inContext:_ctx acquire:NO]; + if ([folder isKindOfClass:[NSException class]]) return folder; + + return ((self->inboxFolder = [folder retain])); +} + +- (SOGoMailFolder *)sentFolderInContext:(id)_ctx { + // TODO: use some profile to determine real location + SOGoMailFolder *folder; + + if (self->sentFolder != nil) + return self->sentFolder; + + folder = [self inboxFolderInContext:_ctx]; + if ([folder isKindOfClass:[NSException class]]) return folder; + + folder = [folder lookupName:@"Sent" inContext:_ctx acquire:NO]; + if ([folder isKindOfClass:[NSException class]]) return folder; + + if (![folder isNotNull]) { + return [NSException exceptionWithHTTPStatus:404 /* not found */ + reason:@"did not find Sent folder!"]; + } + + return ((self->sentFolder = [folder retain])); +} + +- (SOGoMailFolder *)trashFolderInContext:(id)_ctx { + // TODO: use some profile to determine real location + SOGoMailFolder *folder; + + if (self->trashFolder != nil) + return self->trashFolder; + + folder = [self inboxFolderInContext:_ctx]; + if ([folder isKindOfClass:[NSException class]]) return folder; + + folder = [folder lookupName:@"Trash" inContext:_ctx acquire:NO]; + if ([folder isKindOfClass:[NSException class]]) return folder; + + if (![folder isNotNull]) { + return [NSException exceptionWithHTTPStatus:404 /* not found */ + reason:@"did not find Trash folder!"]; + } + + return ((self->trashFolder = [folder retain])); +} + /* WebDAV */ - (BOOL)davIsCollection { diff --git a/SOGo/SoObjects/Mailer/SOGoMailFolder.m b/SOGo/SoObjects/Mailer/SOGoMailFolder.m index 5b5d87c3..05b2d905 100644 --- a/SOGo/SoObjects/Mailer/SOGoMailFolder.m +++ b/SOGo/SoObjects/Mailer/SOGoMailFolder.m @@ -156,15 +156,12 @@ password:[self imap4Password]]; } -- (id)DELETEAction:(id)_ctx { - id result; - - result = [[self mailManager] deleteMailboxAtURL:[self imap4URL] - password:[self imap4Password]]; - if (result != nil) - return result; - - return [NSNumber numberWithBool:YES]; +/* operations */ + +- (NSException *)delete { + /* Note: overrides SOGoObject -delete */ + return [[self mailManager] deleteMailboxAtURL:[self imap4URL] + password:[self imap4Password]]; } @end /* SOGoMailFolder */ diff --git a/SOGo/SoObjects/Mailer/SOGoMailManager.h b/SOGo/SoObjects/Mailer/SOGoMailManager.h index baa3bcbc..0888bf84 100644 --- a/SOGo/SoObjects/Mailer/SOGoMailManager.h +++ b/SOGo/SoObjects/Mailer/SOGoMailManager.h @@ -71,6 +71,7 @@ - (NSException *)addFlags:(id)_f toURL:(NSURL *)_u password:(NSString *)_p; - (NSException *)removeFlags:(id)_f toURL:(NSURL *)_u password:(NSString *)_p; +- (NSException *)markURLDeleted:(NSURL *)_u password:(NSString *)_p; - (NSException *)postData:(NSData *)_data flags:(id)_flags toFolderURL:(NSURL *)_url password:(NSString *)_p; diff --git a/SOGo/SoObjects/Mailer/SOGoMailManager.m b/SOGo/SoObjects/Mailer/SOGoMailManager.m index 633504b8..3bdbfe7e 100644 --- a/SOGo/SoObjects/Mailer/SOGoMailManager.m +++ b/SOGo/SoObjects/Mailer/SOGoMailManager.m @@ -23,7 +23,13 @@ #include "SOGoMailConnectionEntry.h" #include "common.h" -// TODO: need a way to refresh caches on get mail! +/* + Could check read-write state: + dict = [[self->context client] select:[self absoluteName]]; + self->isReadOnly = + [[dict objectForKey:@"access"] isEqualToString:@"READ-WRITE"] + ? NoNumber : YesNumber; +*/ @implementation SOGoMailManager @@ -616,6 +622,10 @@ static NSString *imap4Separator = nil; return [self addOrRemove:NO flags:_f toURL:_u password:_p]; } +- (NSException *)markURLDeleted:(NSURL *)_url password:(NSString *)_p { + return [self addOrRemove:YES flags:@"Deleted" toURL:_url password:_p]; +} + - (NSException *)postData:(NSData *)_data flags:(id)_f toFolderURL:(NSURL *)_url password:(NSString *)_p { diff --git a/SOGo/SoObjects/Mailer/SOGoMailObject.m b/SOGo/SoObjects/Mailer/SOGoMailObject.m index 4194cda3..43150091 100644 --- a/SOGo/SoObjects/Mailer/SOGoMailObject.m +++ b/SOGo/SoObjects/Mailer/SOGoMailObject.m @@ -335,4 +335,12 @@ static BOOL heavyDebug = NO; return r; } +/* operations */ + +- (NSException *)delete { + // TODO: copy to Trash folder + return [[self mailManager] markURLDeleted:[self imap4URL] + password:[self imap4Password]]; +} + @end /* SOGoMailObject */ diff --git a/SOGo/SoObjects/Mailer/Version b/SOGo/SoObjects/Mailer/Version index 20b1dd20..6d5b940e 100644 --- a/SOGo/SoObjects/Mailer/Version +++ b/SOGo/SoObjects/Mailer/Version @@ -1,6 +1,6 @@ # Version file -SUBMINOR_VERSION:=57 +SUBMINOR_VERSION:=58 # v0.9.55 requires NGExtensions v4.5.136 # v0.9.44 requires libNGMime v4.3.194 diff --git a/SOGo/SoObjects/SOGo/SOGoObject.m b/SOGo/SoObjects/SOGo/SOGoObject.m index f7b1c080..c871f450 100644 --- a/SOGo/SoObjects/SOGo/SOGoObject.m +++ b/SOGo/SoObjects/SOGo/SOGoObject.m @@ -1,5 +1,5 @@ /* - Copyright (C) 2004 SKYRIX Software AG + Copyright (C) 2004-2005 SKYRIX Software AG This file is part of OpenGroupware.org. @@ -18,7 +18,6 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -// $Id$ #include "SOGoObject.h" #include "SOGoUserFolder.h" diff --git a/SOGo/UI/Mailer/ChangeLog b/SOGo/UI/Mailer/ChangeLog index e76c3e97..6cd64481 100644 --- a/SOGo/UI/Mailer/ChangeLog +++ b/SOGo/UI/Mailer/ChangeLog @@ -1,5 +1,15 @@ 2005-01-28 Helge Hess + * v0.9.78 + + * UIxMailListView.m: properly mark deleted mails using line-through + + * UIxMailView.m: close mail viewer if mail delete was successful + + * mailer.css: added style classes for deleted cells + + * UIxMailEditor.m: moved some Sent folder lookup to SOGoMailAccount + * v0.9.77 * added UIxMailSizeFormatter to render big file size numbers with some diff --git a/SOGo/UI/Mailer/UIxMailEditor.m b/SOGo/UI/Mailer/UIxMailEditor.m index 57a04567..b6954df4 100644 --- a/SOGo/UI/Mailer/UIxMailEditor.m +++ b/SOGo/UI/Mailer/UIxMailEditor.m @@ -159,11 +159,6 @@ static NSArray *infoKeys = nil; } - (id)lookupSentFolder { - /* - Lookup INBOX/Sent folder. This must be in the UI layer, because the Sent - folder could be a user defined folder (so we cannot have a simple - -saveToSent action on the SOGoDraftObject). - */ SOGoMailAccount *account; SOGoMailFolder *folder; @@ -173,19 +168,9 @@ static NSArray *infoKeys = nil; account = [[self clientObject] mailAccountFolder]; if ([account isKindOfClass:[NSException class]]) return account; - folder = [account lookupName:@"INBOX" inContext:[self context] acquire:NO]; - if ([folder isKindOfClass:[NSException class]]) return folder; - - folder = [folder lookupName:@"Sent" inContext:[self context] acquire:NO]; + folder = [account sentFolderInContext:[self context]]; if ([folder isKindOfClass:[NSException class]]) return folder; - - if (![folder isNotNull]) { - return [NSException exceptionWithHTTPStatus:500 /* server error */ - reason:@"did not find Sent folder!"]; - } - - self->sentFolder = [folder retain]; - return self->sentFolder; + return ((self->sentFolder = [folder retain])); } - (NSException *)storeMailInSentFolder:(NSString *)_path { @@ -254,7 +239,8 @@ static NSArray *infoKeys = nil; if (![self _saveFormInfo]) return [self failedToSaveFormResponse]; - /* save mail to file (so that we can upload the mail to Cyrus */ + /* save mail to file (so that we can upload the mail to Cyrus) */ + // TODO: all this could be handled by the SOGoDraftObject? mailPath = [[self clientObject] saveMimeMessageToTemporaryFile]; diff --git a/SOGo/UI/Mailer/UIxMailListView.m b/SOGo/UI/Mailer/UIxMailListView.m index ca08bb2c..09c7338d 100644 --- a/SOGo/UI/Mailer/UIxMailListView.m +++ b/SOGo/UI/Mailer/UIxMailListView.m @@ -84,6 +84,13 @@ static int attachmentFlagSize = 8096; /* derived accessors */ +- (BOOL)isMessageDeleted { + NSArray *flags; + + flags = [[self message] valueForKey:@"flags"]; + return [flags containsObject:@"deleted"]; +} + - (BOOL)isMessageRead { NSArray *flags; @@ -94,6 +101,17 @@ static int attachmentFlagSize = 8096; return [[[self message] valueForKey:@"uid"] stringValue]; } +- (NSString *)messageSubjectStyleClass { + return [self isMessageRead] + ? @"mailer_readmailsubject" + : @"mailer_unreadmailsubject"; +} +- (NSString *)messageCellStyleClass { + return [self isMessageDeleted] + ? @"mailer_listcell_deleted" + : @"mailer_listcell_regular"; +} + - (BOOL)hasMessageAttachment { /* we detect attachments by size ... */ unsigned size; diff --git a/SOGo/UI/Mailer/UIxMailListView.wox b/SOGo/UI/Mailer/UIxMailListView.wox index 2c7ebeca..6b550ec1 100644 --- a/SOGo/UI/Mailer/UIxMailListView.wox +++ b/SOGo/UI/Mailer/UIxMailListView.wox @@ -123,29 +123,17 @@ /> --> - - -
- - - - -
-
- -
- - - - -
-
+ +
+ + + + +
- + @@ -179,7 +167,7 @@ - + diff --git a/SOGo/UI/Mailer/UIxMailView.m b/SOGo/UI/Mailer/UIxMailView.m index a1a6e8a2..351c5ddc 100644 --- a/SOGo/UI/Mailer/UIxMailView.m +++ b/SOGo/UI/Mailer/UIxMailView.m @@ -201,25 +201,35 @@ - (BOOL)isDeletableClientObject { return [[self clientObject] respondsToSelector:@selector(delete)]; } +- (BOOL)isInlineViewer { + return NO; +} - (id)deleteAction { NSException *ex; - id url; - + if (![self isDeletableClientObject]) { return [NSException exceptionWithHTTPStatus:400 /* Bad Request */ reason:@"method cannot be invoked on " @"the specified object"]; } - + if ((ex = [[self clientObject] delete]) != nil) { // TODO: improve error handling [self debugWithFormat:@"failed to delete: %@", ex]; return ex; } + + if (![self isInlineViewer]) { + // if everything is ok, close the window (send a JS closing the Window) + return [self pageWithName:@"UIxMailWindowCloser"]; + } + else { + id url; - url = [[[self clientObject] container] baseURLInContext:[self context]]; - return [self redirectToLocation:url]; + url = [[[self clientObject] container] baseURLInContext:[self context]]; + return [self redirectToLocation:url]; + } } - (id)getMailAction { diff --git a/SOGo/UI/Mailer/UIxMailView.wox b/SOGo/UI/Mailer/UIxMailView.wox index 47c70a13..154bb53c 100644 --- a/SOGo/UI/Mailer/UIxMailView.wox +++ b/SOGo/UI/Mailer/UIxMailView.wox @@ -11,7 +11,8 @@ const:hideFolderTree="1" > diff --git a/SOGo/UI/Mailer/Version b/SOGo/UI/Mailer/Version index 733f93ec..0069dec7 100644 --- a/SOGo/UI/Mailer/Version +++ b/SOGo/UI/Mailer/Version @@ -2,6 +2,7 @@ SUBMINOR_VERSION:=77 +# v0.9.78 requires SoObjects/Mailer v0.9.58 # v0.9.77 requires SoObjects/Mailer v0.9.57 # v0.9.74 requires SoObjects/Mailer v0.9.56 # v0.9.70 requires NGExtensions v4.5.136 diff --git a/SOGo/UI/Mailer/mailer.css b/SOGo/UI/Mailer/mailer.css index bc6bb1f7..f4763b0f 100644 --- a/SOGo/UI/Mailer/mailer.css +++ b/SOGo/UI/Mailer/mailer.css @@ -227,8 +227,6 @@ span.mailer_datefield { } div.mailer_readmailsubject { - /* TODO: use proper read icon */ - /* background-image: url(tbtv_leaf_corner_17x17.gif); */ background-image: url(message-mail-read.png); background-repeat: no-repeat; background-position: 0px 0px; @@ -236,8 +234,6 @@ div.mailer_readmailsubject { padding-left: 20px; } div.mailer_unreadmailsubject { - /* TODO: use proper unread icon */ - /* background-image: url(tbtv_leaf_corner_17x17.gif); */ background-image: url(message-mail.png); background-repeat: no-repeat; background-position: 0px 0px; @@ -254,6 +250,12 @@ div.mailer_unreadmailsubject a { text-decoration: none; } +td.mailer_listcell_deleted { + text-decoration: line-through; +} +td.mailer_listcell_regular { +} + div.mailer_readicon { /* TODO: use Thunderbird icon */ background-image: url(icon_read.gif); @@ -405,7 +407,7 @@ div.linked_attachment_frame { div.linked_attachment_body { font-family: Arial, Helvetica, Verdana, Geneva, Tahoma, sans-serif; - font-size: 10pt; + font-size: 10pt; padding: 4px; border-width: 1; diff --git a/SOGo/UI/Mailer/product.plist b/SOGo/UI/Mailer/product.plist index 78084786..edefca9b 100644 --- a/SOGo/UI/Mailer/product.plist +++ b/SOGo/UI/Mailer/product.plist @@ -177,6 +177,10 @@ cssClass = "tbicon_forward"; label = "Forward"; }, ), */ + ( // third group + { link = "delete"; + cssClass = "tbicon_delete"; label = "Delete"; }, + ), /* TODO: enable when implemented ( // third group // TODO: enable when delete works (#1212)