From: helge Date: Sat, 30 Jul 2005 16:42:04 +0000 (+0000) Subject: fetch Kolab parts as inline parts X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a60de03d2f6e709c805c1860781a0b67e3993dd2;p=scalable-opengroupware.org fetch Kolab parts as inline parts git-svn-id: http://svn.opengroupware.org/SOGo/trunk@923 d1b88da0-ebda-0310-925b-ed51d893ca5b --- diff --git a/SoObjects/Mailer/ChangeLog b/SoObjects/Mailer/ChangeLog index c9701a4f..2bd9f6d9 100644 --- a/SoObjects/Mailer/ChangeLog +++ b/SoObjects/Mailer/ChangeLog @@ -1,5 +1,7 @@ 2005-07-30 Helge Hess + * SOGoMailObject.m: fetch Kolab parts for inline display (v0.9.126) + * SOGoMailObject.m: added 'outlookMessageClass' property with some mail tagging for Kolab entities (v0.9.125) diff --git a/SoObjects/Mailer/SOGoMailObject.m b/SoObjects/Mailer/SOGoMailObject.m index 9fc1978f..69f1457a 100644 --- a/SoObjects/Mailer/SOGoMailObject.m +++ b/SoObjects/Mailer/SOGoMailObject.m @@ -173,6 +173,10 @@ static BOOL debugSoParts = NO; /* message */ - (id)fetchParts:(NSArray *)_parts { + // TODO: explain what it does + /* + Called by -fetchPlainTextParts: + */ return [[self imap4Connection] fetchURL:[self imap4URL] parts:_parts]; } @@ -406,6 +410,10 @@ static BOOL debugSoParts = NO; /* bulk fetching of plain/text content */ - (BOOL)shouldFetchPartOfType:(NSString *)_type subtype:(NSString *)_subtype { + /* + This method decides which parts are 'prefetched' for display. Those are + usually text parts (the set is currently hardcoded in this method ...). + */ _type = [_type lowercaseString]; _subtype = [_subtype lowercaseString]; @@ -420,6 +428,8 @@ static BOOL debugSoParts = NO; if ([_type isEqualToString:@"application"]) { if ([_subtype isEqualToString:@"pgp-signature"]) return YES; + if ([_subtype hasPrefix:@"x-vnd.kolab."]) + return YES; } return NO; @@ -429,11 +439,19 @@ static BOOL debugSoParts = NO; toArray:(NSMutableArray *)_keys recurse:(BOOL)_recurse { + /* + This is used to collect the set of IMAP4 fetch-keys required to fetch + the basic parts of the body structure. That is, to fetch all parts which + are displayed 'inline' in a single IMAP4 fetch. + + The method calls itself recursively to walk the body structure. + */ NSArray *parts; unsigned i, count; BOOL fetchPart; id body; + /* Note: if the part itself doesn't qualify, we still check subparts */ fetchPart = [self shouldFetchPartOfType:[_info valueForKey:@"type"] subtype:[_info valueForKey:@"subtype"]]; if (fetchPart) { @@ -463,7 +481,7 @@ static BOOL debugSoParts = NO; NSString *sp; id childInfo; - sp = [_p length] > 0 + sp = ([_p length] > 0) ? [_p stringByAppendingFormat:@".%d", i + 1] : [NSString stringWithFormat:@"%d", i + 1]; @@ -489,6 +507,10 @@ static BOOL debugSoParts = NO; } - (NSArray *)plainTextContentFetchKeys { + /* + The name is not 100% correct. The method returns all body structure fetch + keys which are marked by the -shouldFetchPartOfType:subtype: method. + */ NSMutableArray *ma; ma = [NSMutableArray arrayWithCapacity:4]; @@ -498,6 +520,7 @@ static BOOL debugSoParts = NO; } - (NSDictionary *)fetchPlainTextParts:(NSArray *)_fetchKeys { + // TODO: is the name correct or does it also fetch other parts? NSMutableDictionary *flatContents; unsigned i, count; id result; @@ -506,7 +529,7 @@ static BOOL debugSoParts = NO; result = [self fetchParts:_fetchKeys]; result = [result valueForKey:@"RawResponse"]; // hackish - + // Note: -valueForKey: doesn't work! result = [(NSDictionary *)result objectForKey:@"fetch"]; @@ -521,12 +544,12 @@ static BOOL debugSoParts = NO; objectForKey:@"data"]; if (![data isNotNull]) { - [self debugWithFormat:@"got no data fork key: %@", key]; + [self errorWithFormat:@"got no data for key: %@", key]; continue; } - + if ([key isEqualToString:@"body[text]"]) - key = @""; // see key collector + key = @""; // see key collector for explanation (TODO: where?) else if ([key hasPrefix:@"body["]) { NSRange r; diff --git a/SoObjects/Mailer/Version b/SoObjects/Mailer/Version index 49ff5609..329d3f4a 100644 --- a/SoObjects/Mailer/Version +++ b/SoObjects/Mailer/Version @@ -1,6 +1,6 @@ # Version file -SUBMINOR_VERSION:=125 +SUBMINOR_VERSION:=126 # v0.9.114 requires libNGMime v4.5.229 # v0.9.114 requires libNGExtensions v4.5.165