From 9a24d0e329fd5c70b3ddc28a1107db9632aef540 Mon Sep 17 00:00:00 2001 From: helge Date: Mon, 31 Jan 2005 00:58:37 +0000 Subject: [PATCH] moved plain/text bulk fetches from UI to SoObject git-svn-id: http://svn.opengroupware.org/SOGo/trunk@514 d1b88da0-ebda-0310-925b-ed51d893ca5b --- SOGo/SoObjects/Mailer/ChangeLog | 3 + SOGo/SoObjects/Mailer/SOGoMailObject.h | 4 ++ SOGo/SoObjects/Mailer/SOGoMailObject.m | 77 +++++++++++++++++++++++++ SOGo/SoObjects/Mailer/Version | 2 +- SOGo/UI/Mailer/ChangeLog | 3 + SOGo/UI/Mailer/UIxMailView.m | 80 +------------------------- SOGo/UI/Mailer/Version | 3 +- SOGo/UI/Mailer/product.plist | 4 +- 8 files changed, 95 insertions(+), 81 deletions(-) diff --git a/SOGo/SoObjects/Mailer/ChangeLog b/SOGo/SoObjects/Mailer/ChangeLog index 84c84130..2adaa8fc 100644 --- a/SOGo/SoObjects/Mailer/ChangeLog +++ b/SOGo/SoObjects/Mailer/ChangeLog @@ -1,5 +1,8 @@ 2005-01-31 Helge Hess + * SOGoMailObject.m: moved in plain/text bulk fetch method from mail + viewer (since it is general purpose) (v0.9.63) + * SOGoMailObject.m: properly handle part lookup in the context of embedded message/rfc822 content (v0.9.62) diff --git a/SOGo/SoObjects/Mailer/SOGoMailObject.h b/SOGo/SoObjects/Mailer/SOGoMailObject.h index eea288f1..f497c5fd 100644 --- a/SOGo/SoObjects/Mailer/SOGoMailObject.h +++ b/SOGo/SoObjects/Mailer/SOGoMailObject.h @@ -68,6 +68,10 @@ - (NSData *)content; - (NSString *)contentAsString; +/* bulk fetching of plain/text content */ + +- (NSArray *)plainTextContentFetchKeys; + /* flags */ - (NSException *)addFlags:(id)_f; diff --git a/SOGo/SoObjects/Mailer/SOGoMailObject.m b/SOGo/SoObjects/Mailer/SOGoMailObject.m index 3ea384f6..310f0917 100644 --- a/SOGo/SoObjects/Mailer/SOGoMailObject.m +++ b/SOGo/SoObjects/Mailer/SOGoMailObject.m @@ -288,6 +288,83 @@ static BOOL debugBodyStructure = NO; return [s autorelease]; } +/* bulk fetching of plain/text content */ + +- (BOOL)shouldFetchPartOfType:(NSString *)_type subtype:(NSString *)_subtype { + _type = [_type lowercaseString]; + _subtype = [_subtype lowercaseString]; + + if ([_type isEqualToString:@"text"]) + return [_subtype isEqualToString:@"plain"]; + return NO; +} + +- (void)addRequiredKeysOfStructure:(id)_info path:(NSString *)_p + toArray:(NSMutableArray *)_keys +{ + NSArray *parts; + unsigned i, count; + BOOL fetchPart; + id body; + + fetchPart = [self shouldFetchPartOfType:[_info valueForKey:@"type"] + subtype:[_info valueForKey:@"subtype"]]; + if (fetchPart) { + NSString *k; + + if ([_p length] > 0) { + k = [[@"body[" stringByAppendingString:_p] stringByAppendingString:@"]"]; + } + else { + /* + for some reason we need to add ".TEXT" for plain text stuff on root + entities? + TODO: check with HTML + */ + k = @"body[text]"; + } + [_keys addObject:k]; + } + + /* recurse */ + + parts = [_info objectForKey:@"parts"]; + for (i = 0, count = [parts count]; i < count; i++) { + NSString *sp; + id childInfo; + + sp = [_p length] > 0 + ? [_p stringByAppendingFormat:@".%d", i + 1] + : [NSString stringWithFormat:@"%d", i + 1]; + + childInfo = [parts objectAtIndex:i]; + + [self addRequiredKeysOfStructure:childInfo path:sp toArray:_keys]; + } + + /* check body */ + + if ((body = [_info objectForKey:@"body"]) != nil) { + NSString *sp; + + sp = [[body valueForKey:@"type"] lowercaseString]; + if ([sp isEqualToString:@"multipart"]) + sp = _p; + else + sp = [_p length] > 0 ? [_p stringByAppendingString:@".1"] : @"1"; + [self addRequiredKeysOfStructure:body path:sp toArray:_keys]; + } +} + +- (NSArray *)plainTextContentFetchKeys { + NSMutableArray *ma; + + ma = [NSMutableArray arrayWithCapacity:4]; + [self addRequiredKeysOfStructure:[[self clientObject] bodyStructure] + path:@"" toArray:ma]; + return ma; +} + /* flags */ - (NSException *)addFlags:(id)_flags { diff --git a/SOGo/SoObjects/Mailer/Version b/SOGo/SoObjects/Mailer/Version index 9e9133eb..33634eae 100644 --- a/SOGo/SoObjects/Mailer/Version +++ b/SOGo/SoObjects/Mailer/Version @@ -1,6 +1,6 @@ # Version file -SUBMINOR_VERSION:=62 +SUBMINOR_VERSION:=63 # 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 0288835c..96c31d01 100644 --- a/SOGo/UI/Mailer/ChangeLog +++ b/SOGo/UI/Mailer/ChangeLog @@ -1,5 +1,8 @@ 2005-01-31 Helge Hess + * UIxMailView.m: moved plain/text bulkfetch method to SoObjects/Mailer, + since its general purpose (v0.9.85) + * v0.9.84 * UIxMailView.m: properly recurse into message/rfc822 bodies for flat diff --git a/SOGo/UI/Mailer/UIxMailView.m b/SOGo/UI/Mailer/UIxMailView.m index ec6754fd..2540560f 100644 --- a/SOGo/UI/Mailer/UIxMailView.m +++ b/SOGo/UI/Mailer/UIxMailView.m @@ -99,88 +99,13 @@ /* process body structure */ -- (BOOL)shouldFetchPartOfType:(NSString *)_type subtype:(NSString *)_subtype { - _type = [_type lowercaseString]; - _subtype = [_subtype lowercaseString]; - - if ([_type isEqualToString:@"text"]) - return [_subtype isEqualToString:@"plain"]; - return NO; -} - -- (void)addRequiredKeysOfStructure:(id)_info path:(NSString *)_p - toArray:(NSMutableArray *)_keys -{ - NSArray *parts; - unsigned i, count; - BOOL fetchPart; - id body; - - fetchPart = [self shouldFetchPartOfType:[_info valueForKey:@"type"] - subtype:[_info valueForKey:@"subtype"]]; - if (fetchPart) { - NSString *k; - - if ([_p length] > 0) { - k = [[@"body[" stringByAppendingString:_p] stringByAppendingString:@"]"]; - } - else { - /* - for some reason we need to add ".TEXT" for plain text stuff on root - entities? - TODO: check with HTML - */ - k = @"body[text]"; - } - [_keys addObject:k]; - } - - /* recurse */ - - parts = [_info objectForKey:@"parts"]; - for (i = 0, count = [parts count]; i < count; i++) { - NSString *sp; - id childInfo; - - sp = [_p length] > 0 - ? [_p stringByAppendingFormat:@".%d", i + 1] - : [NSString stringWithFormat:@"%d", i + 1]; - - childInfo = [parts objectAtIndex:i]; - - [self addRequiredKeysOfStructure:childInfo path:sp toArray:_keys]; - } - - /* check body */ - - if ((body = [_info objectForKey:@"body"]) != nil) { - NSString *sp; - - sp = [[body valueForKey:@"type"] lowercaseString]; - if ([sp isEqualToString:@"multipart"]) - sp = _p; - else - sp = [_p length] > 0 ? [_p stringByAppendingString:@".1"] : @"1"; - [self addRequiredKeysOfStructure:body path:sp toArray:_keys]; - } -} - -- (NSArray *)contentFetchKeys { - NSMutableArray *ma; - - ma = [NSMutableArray arrayWithCapacity:4]; - [self addRequiredKeysOfStructure:[[self clientObject] bodyStructure] - path:@"" toArray:ma]; - return ma; -} - - (NSDictionary *)fetchFlatContents { NSMutableDictionary *flatContents; unsigned i, count; NSArray *keys; id result; - keys = [self contentFetchKeys]; + keys = [[self clientObject] plainTextContentFetchKeys]; [self debugWithFormat:@"fetch keys: %@", keys]; result = [[self clientObject] fetchParts:keys]; @@ -235,7 +160,8 @@ reason:@"did not find specified message!"]; } #if 0 - [self logWithFormat:@"FETCH BODY PARTS: %@", [self contentFetchKeys]]; + [self logWithFormat:@"FETCH BODY PARTS: %@", + [[self clientObject] plainTextContentFetchKeys]]; [self logWithFormat:@"CORE: %@", [self fetchFlatContents]]; #endif return self; diff --git a/SOGo/UI/Mailer/Version b/SOGo/UI/Mailer/Version index 73d914ae..986ed409 100644 --- a/SOGo/UI/Mailer/Version +++ b/SOGo/UI/Mailer/Version @@ -1,7 +1,8 @@ # version file -SUBMINOR_VERSION:=84 +SUBMINOR_VERSION:=85 +# v0.9.85 requires SoObjects/Mailer v0.9.63 # v0.9.84 requires libNGMime v4.5.209 # v0.9.81 requires SoObjects/Sieve v0.9.5 # v0.9.80 requires SoObjects/Mailer v0.9.59 diff --git a/SOGo/UI/Mailer/product.plist b/SOGo/UI/Mailer/product.plist index 1b9774ce..1a124161 100644 --- a/SOGo/UI/Mailer/product.plist +++ b/SOGo/UI/Mailer/product.plist @@ -168,12 +168,12 @@ cssClass = "tbicon_compose"; label = "Write"; }, ), ( // second group -/* TODO: enable when implemented +///* TODO: enable when implemented { link = "reply"; cssClass = "tbicon_reply"; label = "Reply"; }, { link = "replyall"; cssClass = "tbicon_replyall"; label = "Reply All"; }, -*/ +//*/ { link = "forward"; cssClass = "tbicon_forward"; label = "Forward"; }, ), -- 2.39.5