From 0f6dbf7f9425b797838dab69c2aecad5e285f0a3 Mon Sep 17 00:00:00 2001 From: helge Date: Mon, 31 Jan 2005 02:57:49 +0000 Subject: [PATCH] implemented folder expunge git-svn-id: http://svn.opengroupware.org/SOGo/trunk@516 d1b88da0-ebda-0310-925b-ed51d893ca5b --- SOGo/SoObjects/Mailer/ChangeLog | 6 +++++ SOGo/SoObjects/Mailer/SOGoMailFolder.h | 2 ++ SOGo/SoObjects/Mailer/SOGoMailFolder.m | 5 +++++ SOGo/SoObjects/Mailer/SOGoMailManager.h | 2 ++ SOGo/SoObjects/Mailer/SOGoMailManager.m | 29 +++++++++++++++++++++++++ SOGo/SoObjects/Mailer/SOGoMailObject.m | 15 ++++++++----- SOGo/SoObjects/Mailer/Version | 2 +- SOGo/UI/Mailer/ChangeLog | 3 +++ SOGo/UI/Mailer/UIxMailListView.m | 18 +++++++++++++++ SOGo/UI/Mailer/Version | 3 ++- SOGo/UI/Mailer/product.plist | 11 ++++++++-- 11 files changed, 87 insertions(+), 9 deletions(-) diff --git a/SOGo/SoObjects/Mailer/ChangeLog b/SOGo/SoObjects/Mailer/ChangeLog index d1c11d8a..312caaf7 100644 --- a/SOGo/SoObjects/Mailer/ChangeLog +++ b/SOGo/SoObjects/Mailer/ChangeLog @@ -1,5 +1,11 @@ 2005-01-31 Helge Hess + * v0.9.65 + + * SOGoMailManager.m, SOGoMailFolder.m: added expunge method + + * SOGoMailObject.m: improve bulk key collector + * SOGoMailObject.m: moved more bulk fetching to SoObject (v0.9.64) * SOGoMailObject.m: moved in plain/text bulk fetch method from mail diff --git a/SOGo/SoObjects/Mailer/SOGoMailFolder.h b/SOGo/SoObjects/Mailer/SOGoMailFolder.h index ad9d6acb..ddb014d1 100644 --- a/SOGo/SoObjects/Mailer/SOGoMailFolder.h +++ b/SOGo/SoObjects/Mailer/SOGoMailFolder.h @@ -47,6 +47,8 @@ - (NSException *)postData:(NSData *)_data flags:(id)_flags; +- (NSException *)expunge; + @end #endif /* __Mailer_SOGoMailFolder_H__ */ diff --git a/SOGo/SoObjects/Mailer/SOGoMailFolder.m b/SOGo/SoObjects/Mailer/SOGoMailFolder.m index 05b2d905..7493989d 100644 --- a/SOGo/SoObjects/Mailer/SOGoMailFolder.m +++ b/SOGo/SoObjects/Mailer/SOGoMailFolder.m @@ -96,6 +96,11 @@ password:[self imap4Password]]; } +- (NSException *)expunge { + return [[self mailManager] expungeAtURL:[self imap4URL] + password:[self imap4Password]]; +} + /* name lookup */ - (BOOL)isMessageKey:(NSString *)_key inContext:(id)_ctx { diff --git a/SOGo/SoObjects/Mailer/SOGoMailManager.h b/SOGo/SoObjects/Mailer/SOGoMailManager.h index 0888bf84..726226c7 100644 --- a/SOGo/SoObjects/Mailer/SOGoMailManager.h +++ b/SOGo/SoObjects/Mailer/SOGoMailManager.h @@ -62,6 +62,8 @@ - (NSArray *)fetchUIDs:(NSArray *)_uids inURL:(NSURL *)_url parts:(NSArray *)_parts password:(NSString *)_pwd; +- (NSException *)expungeAtURL:(NSURL *)_url password:(NSString *)_pwd; + /* individual message */ - (id)fetchURL:(NSURL *)_url parts:(NSArray *)_parts password:(NSString *)_pwd; diff --git a/SOGo/SoObjects/Mailer/SOGoMailManager.m b/SOGo/SoObjects/Mailer/SOGoMailManager.m index 3bdbfe7e..d92c2000 100644 --- a/SOGo/SoObjects/Mailer/SOGoMailManager.m +++ b/SOGo/SoObjects/Mailer/SOGoMailManager.m @@ -518,6 +518,35 @@ static NSString *imap4Separator = nil; return (id)result; } +- (NSException *)expungeAtURL:(NSURL *)_url password:(NSString *)_pwd { + NGImap4Client *client; + NSString *p; + id result; + + if ((client = [self imap4ClientForURL:_url password:_pwd]) == nil) + return nil; // TODO: return error? + + /* select folder */ + + p = [self imap4FolderNameForURL:_url removeFileName:NO]; + result = [client select:p]; + if (![[result valueForKey:@"result"] boolValue]) { + [self errorWithFormat:@"could not select URL: %@: %@", _url, result]; + return nil; + } + + /* expunge */ + + result = [client expunge]; + + if (![[result valueForKey:@"result"] boolValue]) { + [self errorWithFormat:@"could not expunge url: %@", _url]; + return nil; + } + //[self logWithFormat:@"RESULT: %@", result]; + return nil; +} + - (id)fetchURL:(NSURL *)_url parts:(NSArray *)_parts password:(NSString *)_pwd{ // currently returns a dict NGImap4Client *client; diff --git a/SOGo/SoObjects/Mailer/SOGoMailObject.m b/SOGo/SoObjects/Mailer/SOGoMailObject.m index 0935ed30..008fc8f6 100644 --- a/SOGo/SoObjects/Mailer/SOGoMailObject.m +++ b/SOGo/SoObjects/Mailer/SOGoMailObject.m @@ -200,6 +200,7 @@ static BOOL debugBodyStructure = NO; [self debugWithFormat:@"check PATH: %@", p]; idx = [p intValue] - 1; + parts = [info valueForKey:@"parts"]; mt = [[info valueForKey:@"type"] lowercaseString]; if ([mt isEqualToString:@"message"]) { /* we have special behaviour for message types */ @@ -213,8 +214,6 @@ static BOOL debugBodyStructure = NO; parts = [NSArray arrayWithObject:body]; } } - else - parts = [info valueForKey:@"parts"]; if (idx >= [parts count]) { [self errorWithFormat: @@ -301,6 +300,7 @@ static BOOL debugBodyStructure = NO; - (void)addRequiredKeysOfStructure:(id)_info path:(NSString *)_p toArray:(NSMutableArray *)_keys + recurse:(BOOL)_recurse { NSArray *parts; unsigned i, count; @@ -326,6 +326,9 @@ static BOOL debugBodyStructure = NO; [_keys addObject:k]; } + if (!_recurse) + return; + /* recurse */ parts = [_info objectForKey:@"parts"]; @@ -339,7 +342,8 @@ static BOOL debugBodyStructure = NO; childInfo = [parts objectAtIndex:i]; - [self addRequiredKeysOfStructure:childInfo path:sp toArray:_keys]; + [self addRequiredKeysOfStructure:childInfo path:sp toArray:_keys + recurse:YES]; } /* check body */ @@ -352,7 +356,8 @@ static BOOL debugBodyStructure = NO; sp = _p; else sp = [_p length] > 0 ? [_p stringByAppendingString:@".1"] : @"1"; - [self addRequiredKeysOfStructure:body path:sp toArray:_keys]; + [self addRequiredKeysOfStructure:body path:sp toArray:_keys + recurse:YES]; } } @@ -361,7 +366,7 @@ static BOOL debugBodyStructure = NO; ma = [NSMutableArray arrayWithCapacity:4]; [self addRequiredKeysOfStructure:[[self clientObject] bodyStructure] - path:@"" toArray:ma]; + path:@"" toArray:ma recurse:YES]; return ma; } diff --git a/SOGo/SoObjects/Mailer/Version b/SOGo/SoObjects/Mailer/Version index 4d027ef1..9c2c63c6 100644 --- a/SOGo/SoObjects/Mailer/Version +++ b/SOGo/SoObjects/Mailer/Version @@ -1,6 +1,6 @@ # Version file -SUBMINOR_VERSION:=64 +SUBMINOR_VERSION:=65 # v0.9.55 requires NGExtensions v4.5.136 # v0.9.44 requires libNGMime v4.3.194 diff --git a/SOGo/UI/Mailer/ChangeLog b/SOGo/UI/Mailer/ChangeLog index 2a11a029..be1020b7 100644 --- a/SOGo/UI/Mailer/ChangeLog +++ b/SOGo/UI/Mailer/ChangeLog @@ -1,5 +1,8 @@ 2005-01-31 Helge Hess + * UIxMailView.m: implemented 'expunge' action (delete button in the + toolbar) (v0.9.87) + * UIxMailView.m, UIxMailRenderingContext.m: moved more bulk fetching to SoObject (v0.9.86) diff --git a/SOGo/UI/Mailer/UIxMailListView.m b/SOGo/UI/Mailer/UIxMailListView.m index 3e061676..8b36b5d6 100644 --- a/SOGo/UI/Mailer/UIxMailListView.m +++ b/SOGo/UI/Mailer/UIxMailListView.m @@ -439,4 +439,22 @@ static int attachmentFlagSize = 8096; return [self redirectToLocation:@"view"]; } +- (id)expungeAction { + // TODO: we might want to flush the caches? + NSException *error; + id client; + + if ((client = [self clientObject]) == nil) { + return [NSException exceptionWithHTTPStatus:404 /* Not Found */ + reason:@"did not find mail folder"]; + } + + if ((error = [[self clientObject] expunge]) != nil) + return error; + + if ([client respondsToSelector:@selector(flushMailCaches)]) + [client flushMailCaches]; + return [self redirectToLocation:@"view"]; +} + @end /* UIxMailListView */ diff --git a/SOGo/UI/Mailer/Version b/SOGo/UI/Mailer/Version index 22c1ab47..53efe523 100644 --- a/SOGo/UI/Mailer/Version +++ b/SOGo/UI/Mailer/Version @@ -1,7 +1,8 @@ # version file -SUBMINOR_VERSION:=86 +SUBMINOR_VERSION:=87 +# v0.9.87 requires SoObjects/Mailer v0.9.65 # v0.9.86 requires SoObjects/Mailer v0.9.64 # v0.9.85 requires SoObjects/Mailer v0.9.63 # v0.9.84 requires libNGMime v4.5.209 diff --git a/SOGo/UI/Mailer/product.plist b/SOGo/UI/Mailer/product.plist index 1b9774ce..fda2a6a7 100644 --- a/SOGo/UI/Mailer/product.plist +++ b/SOGo/UI/Mailer/product.plist @@ -103,16 +103,18 @@ { link = "#"; cssClass = "tbicon_forward"; label = "Forward"; }, ), */ -/* TODO: enable when implemented ( // third group + { link = "expunge"; + cssClass = "tbicon_delete"; label = "Expunge"; }, +/* TODO: enable when implemented // TODO: enable when delete works (#1212) { link = "#"; cssClass = "tbicon_delete"; label = "Delete"; }, // TODO: enable when we know how to mark junk (#971) { link = "#"; cssClass = "tbicon_junk"; label = "Junk"; }, - ), */ + ), ( /* fourth group */ /* TODO: enable when we can print (#1207) { link = "#"; cssClass = "tbicon_print"; label = "Print"; }, @@ -147,6 +149,11 @@ pageName = "UIxMailListView"; actionName = "getMail"; }; + expunge = { + protectedBy = "View"; + pageName = "UIxMailListView"; + actionName = "expunge"; + }; compose = { protectedBy = "View"; -- 2.39.5