Merge pull request #256 from zentyal/jag/multipart-nested-2

oc-mail: Better management of nested multipart types
This commit is contained in:
Enrique J. Hernández
2016-02-23 17:40:55 +01:00
4 changed files with 93 additions and 43 deletions
+3 -3
View File
@@ -129,9 +129,9 @@ NSArray *SOGoMailCoreInfoKeys;
inContext: (id)_ctx;
- (void) addRequiredKeysOfStructure: (NSDictionary *) info
path: (NSString *) p
toArray: (NSMutableArray *) keys
acceptedTypes: (NSArray *) types
path: (NSString *) p
toArray: (NSMutableArray *) keys
acceptedTypes: (NSArray *) types
withPeek: (BOOL) withPeek;
@end
+39 -10
View File
@@ -516,12 +516,15 @@ static BOOL debugSoParts = NO;
return s;
}
/* This is defined before the public version without parentMimeType
argument to be able to call it recursively */
/* bulk fetching of plain/text content */
- (void) addRequiredKeysOfStructure: (NSDictionary *) info
path: (NSString *) p
toArray: (NSMutableArray *) keys
acceptedTypes: (NSArray *) types
path: (NSString *) p
toArray: (NSMutableArray *) keys
acceptedTypes: (NSArray *) types
withPeek: (BOOL) withPeek
parentMultipart: (NSString *) parentMPart
{
/*
This is used to collect the set of IMAP4 fetch-keys required to fetch
@@ -536,6 +539,7 @@ static BOOL debugSoParts = NO;
id body;
NSString *bodyToken, *sp, *mimeType;
id childInfo;
NSString *multipart;
bodyToken = (withPeek ? @"body.peek" : @"body");
@@ -543,6 +547,12 @@ static BOOL debugSoParts = NO;
[info valueForKey: @"type"],
[info valueForKey: @"subtype"]]
lowercaseString];
if ([[info valueForKey: @"type"] isEqualToString: @"multipart"])
multipart = mimeType;
else
multipart = parentMPart;
if ([types containsObject: mimeType])
{
if ([p length] > 0)
@@ -557,7 +567,8 @@ static BOOL debugSoParts = NO;
k = [NSString stringWithFormat: @"%@[text]", bodyToken];
}
[keys addObject: [NSDictionary dictionaryWithObjectsAndKeys: k, @"key",
mimeType, @"mimeType", nil]];
mimeType, @"mimeType",
multipart, @"multipart", nil]];
}
parts = [info objectForKey: @"parts"];
@@ -571,9 +582,11 @@ static BOOL debugSoParts = NO;
childInfo = [parts objectAtIndex: i];
[self addRequiredKeysOfStructure: childInfo
path: sp toArray: keys
acceptedTypes: types
withPeek: withPeek];
path: sp
toArray: keys
acceptedTypes: types
withPeek: withPeek
parentMultipart: multipart];
}
/* check body */
@@ -597,12 +610,28 @@ static BOOL debugSoParts = NO;
else
sp = [p length] > 0 ? (id)[p stringByAppendingString: @".1"] : (id)@"1";
[self addRequiredKeysOfStructure: body
path: sp toArray: keys
acceptedTypes: types
withPeek: withPeek];
path: sp
toArray: keys
acceptedTypes: types
withPeek: withPeek
parentMultipart: multipart];
}
}
- (void) addRequiredKeysOfStructure: (NSDictionary *) info
path: (NSString *) p
toArray: (NSMutableArray *) keys
acceptedTypes: (NSArray *) types
withPeek: (BOOL) withPeek
{
[self addRequiredKeysOfStructure: (NSDictionary *) info
path: (NSString *) p
toArray: (NSMutableArray *) keys
acceptedTypes: (NSArray *) types
withPeek: (BOOL) withPeek
parentMultipart: @""];
}
- (NSArray *) plainTextContentFetchKeys
{
/*