* SoObjects/Mailer/SOGoDraftObject.m (bodyPartForAttachmentWithName):

Merge back lost code to handle encoding of binary and rcf822 attachments.

Monotone-Parent: e4c701f2293beb98253d68bb64b7fa0133b1dda5
Monotone-Revision: a4d3a18ad2c918187328e23c7ab29824357cd199

Monotone-Author: jraby@inverse.ca
Monotone-Date: 2012-05-18T15:02:42
maint-2.0.2
Jean Raby 2012-05-18 15:02:42 +00:00
parent 7f0eb1b8db
commit 395a1b16e1
2 changed files with 22 additions and 1 deletions

View File

@ -1,3 +1,8 @@
2012-05-18 Jean Raby <jraby@inverse.ca>
* SoObjects/Mailer/SOGoDraftObject.m (bodyPartForAttachmentWithName):
Merge back lost code to handle encoding of binary and rcf822 attachments.
2012-05-15 Jean Raby <jraby@inverse.ca>
* SoObjects/Appointments/SOGoAppointmentObject.m (_handleResourcesConflicts):

View File

@ -1119,7 +1119,7 @@ static NSString *userAgent = nil;
NGMimeBodyPart *bodyPart;
NSString *s;
NSData *content;
BOOL attachAsString;
BOOL attachAsString, attachAsRFC822;
NSString *p;
id body;
@ -1134,6 +1134,7 @@ static NSString *userAgent = nil;
return nil;
}
attachAsString = NO;
attachAsRFC822 = NO;
/* prepare header of body part */
@ -1143,6 +1144,8 @@ static NSString *userAgent = nil;
[map setObject:s forKey: @"content-type"];
if ([s hasPrefix: @"text/plain"] || [s hasPrefix: @"text/html"])
attachAsString = YES;
else if ([s hasPrefix: @"message/rfc822"])
attachAsRFC822 = YES;
}
if ((s = [self contentDispositionForAttachmentWithName:_name]))
{
@ -1181,6 +1184,19 @@ static NSString *userAgent = nil;
content = [[NSData alloc] initWithContentsOfMappedFile:p];
[content autorelease];
if (attachAsRFC822)
{
[map setObject: @"8bit" forKey: @"content-transfer-encoding"];
[map setObject: @"inline" forKey: @"content-disposition"];
}
else
{
content = [content dataByEncodingBase64];
[map setObject: @"base64" forKey: @"content-transfer-encoding"];
}
[map setObject:[NSNumber numberWithInt:[content length]]
forKey: @"content-length"];
/* Note: the -init method will create a temporary file! */
body = [[NGMimeFileData alloc] initWithBytes:[content bytes]
length:[content length]];