Monotone-Parent: f6dcf8a9dfda51ed37550dae7830efbd1d417317

Monotone-Revision: a0db3f538581c7b491b49f0e21b754544b33477b

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2007-10-25T15:25:39
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Wolfgang Sourdeau committed 2007-10-25 15:25:39 +00:00
1 parent 854ee96841
commit ec5b15c2bb
2 files changed
+42 -15

No files matched your search

+6
View File
@@ -1,5 +1,11 @@
2007-10-25 Wolfgang Sourdeau <wsourdeau@inverse.ca> 2007-10-25 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* SoObjects/Mailer/SOGoDraftObject.m ([SOGoDraftObject
-fetchMailForEditing:sourceMail]): work-around a bug in SOPE-mime
where only the body part of the first of the keys fetched was
returned. Also decodes the body parts properly following their
encoding.
* SoObjects/Mailer/NSData+Mail.[hm]: new extension module that * SoObjects/Mailer/NSData+Mail.[hm]: new extension module that
extends the NSData class with utility methods useful for handling extends the NSData class with utility methods useful for handling
mail. mail.
+36 -15
View File
@@ -56,6 +56,8 @@
#import <SoObjects/SOGo/NSString+Utilities.h> #import <SoObjects/SOGo/NSString+Utilities.h>
#import <SoObjects/SOGo/SOGoMailer.h> #import <SoObjects/SOGo/SOGoMailer.h>
#import <SoObjects/SOGo/SOGoUser.h> #import <SoObjects/SOGo/SOGoUser.h>
#import "NSData+Mail.h"
#import "SOGoMailAccount.h" #import "SOGoMailAccount.h"
#import "SOGoMailFolder.h" #import "SOGoMailFolder.h"
#import "SOGoMailObject.h" #import "SOGoMailObject.h"
@@ -411,30 +413,49 @@ static BOOL showTextAttachmentsInline = NO;
} }
} }
- (NSArray *) _attachmentBodiesFromPaths: (NSArray *) paths
fromResponseFetch: (NSDictionary *) fetch;
{
NSEnumerator *attachmentKeys;
NSMutableArray *bodies;
NSString *currentKey;
NSDictionary *body;
bodies = [NSMutableArray array];
attachmentKeys = [paths objectEnumerator];
while ((currentKey = [attachmentKeys nextObject]))
{
body = [fetch objectForKey: [currentKey lowercaseString]];
[bodies addObject: [body objectForKey: @"data"]];
}
return bodies;
}
- (void) _fetchAttachments: (NSArray *) parts - (void) _fetchAttachments: (NSArray *) parts
fromMail: (SOGoMailObject *) sourceMail fromMail: (SOGoMailObject *) sourceMail
{ {
unsigned int count, max; unsigned int count, max;
NSDictionary *currentPart, *attachment, *body; NSArray *paths, *bodies;
NSArray *paths, *result; NSData *body;
NSDictionary *currentInfo;
NGHashMap *response;
max = [parts count]; max = [parts count];
if (max > 0) if (max > 0)
{ {
paths = [parts keysWithFormat: @"BODY[%{path}]"]; paths = [parts keysWithFormat: @"BODY[%{path}]"];
result = [[sourceMail fetchParts: paths] objectForKey: @"fetch"]; response = [[sourceMail fetchParts: paths] objectForKey: @"RawResponse"];
bodies = [self _attachmentBodiesFromPaths: paths
fromResponseFetch: [response objectForKey: @"fetch"]];
for (count = 0; count < max; count++) for (count = 0; count < max; count++)
{ {
currentPart = [parts objectAtIndex: count]; currentInfo = [parts objectAtIndex: count];
body = [[result objectAtIndex: count] objectForKey: @"body"]; body = [[bodies objectAtIndex: count]
attachment = [NSDictionary dictionaryWithObjectsAndKeys: bodyDataFromEncoding: [currentInfo
[currentPart objectForKey: @"filename"], objectForKey: @"encoding"]];
@"filename", [self saveAttachment: body withMetadata: currentInfo];
[currentPart objectForKey: @"mimetype"],
@"mime-type",
nil];
[self saveAttachment: [body objectForKey: @"data"]
withMetadata: attachment];
} }
} }
} }
@@ -529,7 +550,7 @@ static BOOL showTextAttachmentsInline = NO;
// error = [newDraft saveAttachment:content withName:@"forward.mail"]; // error = [newDraft saveAttachment:content withName:@"forward.mail"];
attachment = [NSDictionary dictionaryWithObjectsAndKeys: attachment = [NSDictionary dictionaryWithObjectsAndKeys:
[sourceMail filenameForForward], @"filename", [sourceMail filenameForForward], @"filename",
@"message/rfc822", @"mime-type", @"message/rfc822", @"mimetype",
nil]; nil];
[self saveAttachment: [sourceMail content] [self saveAttachment: [sourceMail content]
withMetadata: attachment]; withMetadata: attachment];
@@ -639,7 +660,7 @@ static BOOL showTextAttachmentsInline = NO;
reason: @"Could not write attachment to draft!"]; reason: @"Could not write attachment to draft!"];
} }
mimeType = [metadata objectForKey: @"mime-type"]; mimeType = [metadata objectForKey: @"mimetype"];
if ([mimeType length] > 0) if ([mimeType length] > 0)
{ {
p = [self pathToAttachmentWithName: p = [self pathToAttachmentWithName: