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 */
}
- (id)bodyStructure {
- return [[self fetchCoreInfos] valueForKey:@"body"];
+ id body;
+
+ body = [[self fetchCoreInfos] valueForKey:@"body"];
+ if (debugBodyStructure)
+ [self logWithFormat:@"BODY: %@", body];
+ return body;
}
- (NGImap4Envelope *)envelope {
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;
}