Skip to content

Commit

Permalink
Now make use of a NGMimeFileData object to avoid broken SOPE behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
extrafu committed Feb 6, 2014
1 parent 3175a91 commit b95362f
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions ActiveSync/SOGoActiveSyncDispatcher.m
Expand Up @@ -62,6 +62,7 @@
#import <NGImap4/NSString+Imap4.h>

#import <NGMime/NGMimeBodyPart.h>
#import <NGMime/NGMimeFileData.h>
#import <NGMime/NGMimeMultipartBody.h>
#import <NGMail/NGMimeMessageParser.h>
#import <NGMail/NGMimeMessage.h>
Expand Down Expand Up @@ -1359,6 +1360,13 @@ - (void) processSmartForward: (id <DOMElement>) theDocumentElement
NGMimeMessageParser *parser;
NSData *data;

NGMimeMessageGenerator *generator;
NGMimeBodyPart *bodyPart;
NGMutableHashMap *map;
NGMimeFileData *fdata;
NSException *error;
id body;

userFolder = [[context activeUser] homeFolderInContext: context];
accountsFolder = [userFolder lookupName: @"Mail" inContext: context acquire: NO];
currentFolder = [accountsFolder lookupName: @"0" inContext: context acquire: NO];
Expand All @@ -1380,10 +1388,6 @@ - (void) processSmartForward: (id <DOMElement>) theDocumentElement
// We create a new MIME multipart/mixed message. The first part will be the text part
// of our "smart forward" and the second part will be the message/rfc822 part of the
// "smart forwarded" message.
NGMimeBodyPart *bodyPart;
NGMutableHashMap *map;
id body;

map = [NGHashMap hashMapWithDictionary: [messageFromSmartForward headers]];
[map setObject: @"multipart/mixed" forKey: @"content-type"];

Expand All @@ -1398,21 +1402,26 @@ - (void) processSmartForward: (id <DOMElement>) theDocumentElement
[body addBodyPart: bodyPart];

// Second part
// FIXME - SOPE (read "POS") generates garbage if we only have the content-type header
map = [[[NGMutableHashMap alloc] initWithCapacity: 1] autorelease];
[map setObject: @"message/rfc822" forKey: @"content-type"];
[map setObject: @"8bit" forKey: @"content-transfer-encoding"];
bodyPart = [[[NGMimeBodyPart alloc] initWithHeader:map] autorelease];
[bodyPart setBody: [mailObject content]];

data = [mailObject content];
fdata = [[NGMimeFileData alloc] initWithBytes:[data bytes]
length:[data length]];

[bodyPart setBody: fdata];
RELEASE(fdata);
[body addBodyPart: bodyPart];
[messageToSend setBody: body];

NGMimeMessageGenerator *generator;
generator = [[[NGMimeMessageGenerator alloc] init] autorelease];
data = [generator generateMimeFromPart: messageToSend];

NSException *error = [self _sendMail: data
recipients: [messageFromSmartForward allRecipients]
saveInSentItems: ([(id)[theDocumentElement getElementsByTagName: @"SaveInSentItems"] count] ? YES : NO)];
error = [self _sendMail: data
recipients: [messageFromSmartForward allRecipients]
saveInSentItems: ([(id)[theDocumentElement getElementsByTagName: @"SaveInSentItems"] count] ? YES : NO)];

if (error)
{
Expand Down

0 comments on commit b95362f

Please sign in to comment.