Monotone-Parent: 6223f47e26b3dedfd23e6559da23309cfecc4449
Monotone-Revision: 5967de9b0e184b1ee595f3e376d640dbeef5f801 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2011-02-13T22:58:29 Monotone-Branch: ca.inverse.sogomaint-2.0.2
parent
75b199d27a
commit
01a83c9405
|
@ -17,6 +17,8 @@
|
|||
available, by selecting the first one only. This requires the
|
||||
prior detection of text/html parts in order to exclude the
|
||||
property or not.
|
||||
Make use of the category methods offered in NSData+Mail to
|
||||
properly decode the body data for PR_BODY_UNICODE and PR_HTML.
|
||||
|
||||
2011-02-11 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#import <Foundation/NSCharacterSet.h>
|
||||
#import <Foundation/NSDictionary.h>
|
||||
#import <Foundation/NSException.h>
|
||||
#import <Foundation/NSRange.h>
|
||||
|
||||
#import <NGExtensions/NSObject+Logs.h>
|
||||
|
||||
|
@ -31,6 +32,7 @@
|
|||
|
||||
#import <SOGo/NSArray+Utilities.h>
|
||||
|
||||
#import <Mailer/NSData+Mail.h>
|
||||
#import <Mailer/SOGoMailFolder.h>
|
||||
#import <Mailer/SOGoMailObject.h>
|
||||
|
||||
|
@ -46,6 +48,33 @@
|
|||
#include <mapistore/mapistore.h>
|
||||
#include <mapistore/mapistore_nameid.h>
|
||||
|
||||
@interface NSString (MAPIStoreMIME)
|
||||
|
||||
- (NSString *) _strippedBodyKey;
|
||||
|
||||
@end
|
||||
|
||||
@implementation NSString (MAPIStoreMIME)
|
||||
|
||||
- (NSString *) _strippedBodyKey
|
||||
{
|
||||
NSRange bodyRange;
|
||||
NSString *strippedKey;
|
||||
|
||||
bodyRange = [self rangeOfString: @"body["];
|
||||
if (bodyRange.length > 0)
|
||||
{
|
||||
strippedKey = [self substringFromIndex: NSMaxRange (bodyRange)];
|
||||
strippedKey = [strippedKey substringToIndex: [strippedKey length] - 1];
|
||||
}
|
||||
else
|
||||
strippedKey = nil;
|
||||
|
||||
return strippedKey;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation MAPIStoreMailMessageTable
|
||||
|
||||
static Class NSDataK, NSStringK;
|
||||
|
@ -355,15 +384,23 @@ static EOQualifier *nonDeletedQualifier = nil;
|
|||
{
|
||||
id result;
|
||||
NSData *content;
|
||||
NSString *key;
|
||||
|
||||
NSDictionary *partHeaderData;
|
||||
NSString *key, *encoding, *charset;
|
||||
|
||||
result = [child fetchParts: [keys objectsForKey: @"key"
|
||||
notFoundMarker: nil]];
|
||||
result = [[result valueForKey: @"RawResponse"] objectForKey: @"fetch"];
|
||||
key = [[keys objectAtIndex: 0] objectForKey: @"key"];
|
||||
content = [[result objectForKey: key] objectForKey: @"data"];
|
||||
stringValue = [[NSString alloc] initWithData: content
|
||||
encoding: NSISOLatin1StringEncoding];
|
||||
|
||||
partHeaderData
|
||||
= [child lookupInfoForBodyPart: [key _strippedBodyKey]];
|
||||
encoding = [partHeaderData objectForKey: @"encoding"];
|
||||
charset = [[partHeaderData objectForKey: @"parameterList"]
|
||||
objectForKey: @"charset"];
|
||||
stringValue = [[content bodyDataFromEncoding: encoding]
|
||||
bodyStringFromCharset: charset];
|
||||
|
||||
*data = [stringValue asUnicodeInMemCtx: memCtx];
|
||||
if (strlen (*data) > 16384)
|
||||
{
|
||||
|
@ -407,8 +444,9 @@ static EOQualifier *nonDeletedQualifier = nil;
|
|||
if ([keys count] > 0)
|
||||
{
|
||||
id result;
|
||||
NSString *key;
|
||||
NSData *content;
|
||||
NSDictionary *partHeaderData;
|
||||
NSString *key, *encoding;
|
||||
|
||||
result = [child fetchParts: [keys objectsForKey: @"key"
|
||||
notFoundMarker: nil]];
|
||||
|
@ -416,6 +454,12 @@ static EOQualifier *nonDeletedQualifier = nil;
|
|||
@"fetch"];
|
||||
key = [[keys objectAtIndex: 0] objectForKey: @"key"];
|
||||
content = [[result objectForKey: key] objectForKey: @"data"];
|
||||
|
||||
partHeaderData
|
||||
= [child lookupInfoForBodyPart: [key _strippedBodyKey]];
|
||||
encoding = [partHeaderData objectForKey: @"encoding"];
|
||||
content = [content bodyDataFromEncoding: encoding];
|
||||
|
||||
if ([content length] > 16384)
|
||||
{
|
||||
[context registerValue: content
|
||||
|
|
Loading…
Reference in New Issue