From 126b69f80e9e99cbac8490d618b6bb5db739e70d Mon Sep 17 00:00:00 2001 From: helge Date: Mon, 31 Jan 2005 00:44:57 +0000 Subject: [PATCH] properly handle body part lookups in embedded messages git-svn-id: http://svn.opengroupware.org/SOGo/trunk@511 d1b88da0-ebda-0310-925b-ed51d893ca5b --- SOGo/SoObjects/Mailer/ChangeLog | 5 +++ SOGo/SoObjects/Mailer/SOGoMailObject.m | 36 ++++++++++++++++--- .../Mailer/SOGoMessageMailBodyPart.m | 2 ++ SOGo/SoObjects/Mailer/Version | 2 +- 4 files changed, 40 insertions(+), 5 deletions(-) diff --git a/SOGo/SoObjects/Mailer/ChangeLog b/SOGo/SoObjects/Mailer/ChangeLog index 0f90c473..84c84130 100644 --- a/SOGo/SoObjects/Mailer/ChangeLog +++ b/SOGo/SoObjects/Mailer/ChangeLog @@ -1,3 +1,8 @@ +2005-01-31 Helge Hess + + * SOGoMailObject.m: properly handle part lookup in the context of + embedded message/rfc822 content (v0.9.62) + 2005-01-30 Helge Hess * v0.9.61 diff --git a/SOGo/SoObjects/Mailer/SOGoMailObject.m b/SOGo/SoObjects/Mailer/SOGoMailObject.m index f87e20b6..3ea384f6 100644 --- a/SOGo/SoObjects/Mailer/SOGoMailObject.m +++ b/SOGo/SoObjects/Mailer/SOGoMailObject.m @@ -31,6 +31,7 @@ static NSArray *coreInfoKeys = nil; static BOOL heavyDebug = NO; static BOOL debugOn = NO; +static BOOL debugBodyStructure = NO; + (void)initialize { /* Note: see SOGoMailManager.m for allowed IMAP4 keys */ @@ -147,7 +148,12 @@ static BOOL debugOn = NO; } - (id)bodyStructure { - return [[self fetchCoreInfos] valueForKey:@"body"]; + id body; + + body = [[self fetchCoreInfos] valueForKey:@"body"]; + if (debugBodyStructure) + [self logWithFormat:@"BODY: %@", body]; + return body; } - (NGImap4Envelope *)envelope { @@ -179,18 +185,40 @@ static BOOL debugOn = NO; return nil; } - /* for each path component, eg 1,1,3 */ + /* + For each path component, eg 1,1,3 + + Remember that we need special processing for message/rfc822 which maps the + namespace of multiparts directly into the main namespace. + */ pe = [_path objectEnumerator]; while ((p = [pe nextObject]) != nil && [info isNotNull]) { unsigned idx; NSArray *parts; + NSString *mt; [self debugWithFormat:@"check PATH: %@", p]; idx = [p intValue] - 1; + + mt = [[info valueForKey:@"type"] lowercaseString]; + if ([mt isEqualToString:@"message"]) { + /* we have special behaviour for message types */ + id body; + + if ((body = [info valueForKey:@"body"]) != nil) { + mt = [body valueForKey:@"type"]; + if ([mt isEqualToString:@"multipart"]) + parts = [body valueForKey:@"parts"]; + else + parts = [NSArray arrayWithObject:body]; + } + } + else + parts = [info valueForKey:@"parts"]; - parts = [info valueForKey:@"parts"]; if (idx >= [parts count]) { - [self errorWithFormat:@"body part index out of bounds(%d vs %d): %@", + [self errorWithFormat: + @"body part index out of bounds(idx=%d vs count=%d): %@", (idx + 1), [parts count], info]; return nil; } diff --git a/SOGo/SoObjects/Mailer/SOGoMessageMailBodyPart.m b/SOGo/SoObjects/Mailer/SOGoMessageMailBodyPart.m index 90e03777..cfc5ad29 100644 --- a/SOGo/SoObjects/Mailer/SOGoMessageMailBodyPart.m +++ b/SOGo/SoObjects/Mailer/SOGoMessageMailBodyPart.m @@ -27,6 +27,8 @@ A specialized SOGoMailBodyPart subclass for message attachments. Can be used to attach special SoMethods. + This object should allow the user to peek inside the message contents. + See the superclass for more information on part objects. */ diff --git a/SOGo/SoObjects/Mailer/Version b/SOGo/SoObjects/Mailer/Version index fed4e8c1..9e9133eb 100644 --- a/SOGo/SoObjects/Mailer/Version +++ b/SOGo/SoObjects/Mailer/Version @@ -1,6 +1,6 @@ # Version file -SUBMINOR_VERSION:=61 +SUBMINOR_VERSION:=62 # v0.9.55 requires NGExtensions v4.5.136 # v0.9.44 requires libNGMime v4.3.194 -- 2.39.5