diff --git a/ChangeLog b/ChangeLog index afff8fd85..a8cc5eba0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2011-10-31 Wolfgang Sourdeau + * OpenChange/MAPIStoreMailMessage.m (-_fetchBodyData): fetch body + keys with BODY.PEEK rather than just BODY, to disabled the + automatic setting of the "\Seen" flag. + * SoObjects/Mailer/SOGoMailBodyPart.m (-fetchBLOBWithPeek:): new method that enables the fetching of body parts either via "BODY" or "BODY.PEEK". diff --git a/OpenChange/MAPIStoreMailAttachment.m b/OpenChange/MAPIStoreMailAttachment.m index 48eab0e50..2a7babc00 100644 --- a/OpenChange/MAPIStoreMailAttachment.m +++ b/OpenChange/MAPIStoreMailAttachment.m @@ -187,7 +187,7 @@ - (int) getPrAttachDataBin: (void **) data inMemCtx: (TALLOC_CTX *) memCtx { - *data = [[sogoObject fetchBLOB] asBinaryInMemCtx: memCtx]; + *data = [[sogoObject fetchBLOBWithPeek: YES] asBinaryInMemCtx: memCtx]; return MAPISTORE_SUCCESS; } diff --git a/OpenChange/MAPIStoreMailMessage.m b/OpenChange/MAPIStoreMailMessage.m index db648bcad..39debc361 100644 --- a/OpenChange/MAPIStoreMailMessage.m +++ b/OpenChange/MAPIStoreMailMessage.m @@ -76,7 +76,7 @@ static Class NSExceptionK, MAPIStoreSentItemsFolderK, MAPIStoreDraftsFolderK; NSRange bodyRange; NSString *strippedKey; - bodyRange = [self rangeOfString: @"body["]; + bodyRange = [self rangeOfString: @"body.peek["]; if (bodyRange.length > 0) { strippedKey = [self substringFromIndex: NSMaxRange (bodyRange)]; @@ -211,7 +211,8 @@ _compareBodyKeysByPriority (id entry1, id entry2, void *data) keys = [NSMutableArray array]; [sogoObject addRequiredKeysOfStructure: [sogoObject bodyStructure] path: @"" toArray: keys - acceptedTypes: acceptedTypes]; + acceptedTypes: acceptedTypes + withPeek: YES]; [keys sortUsingFunction: _compareBodyKeysByPriority context: acceptedTypes]; if ([keys count] > 0) { @@ -234,6 +235,7 @@ _compareBodyKeysByPriority (id entry1, id entry2, void *data) - (void) _fetchBodyData { NSData *rawContent; + NSString *resultKey; id result; if (!headerSetup) @@ -243,7 +245,12 @@ _compareBodyKeysByPriority (id entry1, id entry2, void *data) { result = [sogoObject fetchParts: [NSArray arrayWithObject: mimeKey]]; result = [[result valueForKey: @"RawResponse"] objectForKey: @"fetch"]; - rawContent = [[result objectForKey: mimeKey] objectForKey: @"data"]; + if ([mimeKey hasPrefix: @"body.peek"]) + resultKey = [NSString stringWithFormat: @"body[%@]", + [mimeKey _strippedBodyKey]]; + else + resultKey = mimeKey; + rawContent = [[result objectForKey: resultKey] objectForKey: @"data"]; ASSIGN (bodyContent, [rawContent bodyDataFromEncoding: headerEncoding]); }