/* message */
- (id)fetchParts:(NSArray *)_parts {
+ // TODO: explain what it does
+ /*
+ Called by -fetchPlainTextParts:
+ */
return [[self imap4Connection] fetchURL:[self imap4URL] parts:_parts];
}
/* 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];
if ([_type isEqualToString:@"application"]) {
if ([_subtype isEqualToString:@"pgp-signature"])
return YES;
+ if ([_subtype hasPrefix:@"x-vnd.kolab."])
+ return YES;
}
return 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) {
NSString *sp;
id childInfo;
- sp = [_p length] > 0
+ sp = ([_p length] > 0)
? [_p stringByAppendingFormat:@".%d", i + 1]
: [NSString stringWithFormat:@"%d", i + 1];
}
- (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];
}
- (NSDictionary *)fetchPlainTextParts:(NSArray *)_fetchKeys {
+ // TODO: is the name correct or does it also fetch other parts?
NSMutableDictionary *flatContents;
unsigned i, count;
id result;
result = [self fetchParts:_fetchKeys];
result = [result valueForKey:@"RawResponse"]; // hackish
-
+
// Note: -valueForKey: doesn't work!
result = [(NSDictionary *)result objectForKey:@"fetch"];
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;