Monotone-Parent: b015c73d47df799fb1f9dc241b015ec5b2153d4b
Monotone-Revision: 753e863b1e3ac69df91f82bcd8d13909de69ea5b Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2011-09-26T15:25:25 Monotone-Branch: ca.inverse.sogo
This commit is contained in:
parent
9a50d18d15
commit
ec515b984e
|
@ -1,5 +1,10 @@
|
||||||
2011-09-26 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
2011-09-26 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||||
|
|
||||||
|
* OpenChange/MAPIStoreMemMailMessage.m (-save): fixed "subject"
|
||||||
|
header, "to" and other recipients. Fixed "content-type", that was
|
||||||
|
deduced after "message" was generated. Take the client-provided
|
||||||
|
PR_CHANGE_KEY into account to avoid synchronisation errors.
|
||||||
|
|
||||||
* OpenChange/MAPIStoreDraftsMessage.m (-_commitProperties): make
|
* OpenChange/MAPIStoreDraftsMessage.m (-_commitProperties): make
|
||||||
use of "PR_SUBJECT_PREFIX_UNICODE" and
|
use of "PR_SUBJECT_PREFIX_UNICODE" and
|
||||||
"PR_NORMALIZED_SUBJECT_UNICODE" to construct the "subject" header.
|
"PR_NORMALIZED_SUBJECT_UNICODE" to construct the "subject" header.
|
||||||
|
|
|
@ -24,19 +24,22 @@
|
||||||
#import <Foundation/NSDictionary.h>
|
#import <Foundation/NSDictionary.h>
|
||||||
#import <Foundation/NSString.h>
|
#import <Foundation/NSString.h>
|
||||||
#import <Foundation/NSValue.h>
|
#import <Foundation/NSValue.h>
|
||||||
#import <NGExtensions/NSString+Encoding.h>
|
|
||||||
#import <NGExtensions/NGHashMap.h>
|
#import <NGExtensions/NGHashMap.h>
|
||||||
|
#import <NGExtensions/NSObject+Logs.h>
|
||||||
|
#import <NGExtensions/NSString+Encoding.h>
|
||||||
#import <NGMail/NGMimeMessage.h>
|
#import <NGMail/NGMimeMessage.h>
|
||||||
#import <NGMail/NGMimeMessageGenerator.h>
|
#import <NGMail/NGMimeMessageGenerator.h>
|
||||||
#import <NGImap4/NGImap4Client.h>
|
#import <NGImap4/NGImap4Client.h>
|
||||||
#import <NGImap4/NGImap4Connection.h>
|
#import <NGImap4/NGImap4Connection.h>
|
||||||
|
#import <SOGo/NSArray+Utilities.h>
|
||||||
#import <SOGo/NSCalendarDate+SOGo.h>
|
#import <SOGo/NSCalendarDate+SOGo.h>
|
||||||
#import <SOGo/NSString+Utilities.h>
|
#import <SOGo/NSString+Utilities.h>
|
||||||
#import <Mailer/SOGoMailFolder.h>
|
#import <Mailer/SOGoMailFolder.h>
|
||||||
#import <Mailer/NSString+Mail.h>
|
#import <Mailer/NSString+Mail.h>
|
||||||
|
|
||||||
#import "MAPIStoreMapping.h"
|
|
||||||
#import "MAPIStoreContext.h"
|
#import "MAPIStoreContext.h"
|
||||||
|
#import "MAPIStoreMailFolder.h"
|
||||||
|
#import "MAPIStoreMapping.h"
|
||||||
#import "MAPIStoreTypes.h"
|
#import "MAPIStoreTypes.h"
|
||||||
#import "NSObject+MAPIStore.h"
|
#import "NSObject+MAPIStore.h"
|
||||||
#import "NSString+MAPIStore.h"
|
#import "NSString+MAPIStore.h"
|
||||||
|
@ -206,48 +209,70 @@ Class NSNumberK;
|
||||||
|
|
||||||
- (void) save
|
- (void) save
|
||||||
{
|
{
|
||||||
|
static NSString *recIds[] = { @"to", @"cc", @"bcc" };
|
||||||
NSDictionary *properties;
|
NSDictionary *properties;
|
||||||
NSString *from, *to, *messageId, *subject, *body, *folderName, *flag,
|
NSMutableString *subject;
|
||||||
|
NSString *from, *recId, *messageId, *subjectData, *body, *folderName, *flag,
|
||||||
*newIdString, *charset;
|
*newIdString, *charset;
|
||||||
|
NSData *changeKey, *htmlData, *messageData;
|
||||||
|
NSArray *list;
|
||||||
NSNumber *codePage;
|
NSNumber *codePage;
|
||||||
NSCalendarDate *date;
|
NSCalendarDate *date;
|
||||||
|
NSDictionary *recipients;
|
||||||
NGMimeMessage *message;
|
NGMimeMessage *message;
|
||||||
NGMutableHashMap *map;
|
NGMutableHashMap *map;
|
||||||
NGMimeMessageGenerator *generator;
|
NGMimeMessageGenerator *generator;
|
||||||
NSData *htmlData, *messageData;
|
|
||||||
NGImap4Connection *connection;
|
NGImap4Connection *connection;
|
||||||
NGImap4Client *client;
|
NGImap4Client *client;
|
||||||
SOGoMailFolder *containerFolder;
|
SOGoMailFolder *containerFolder;
|
||||||
NSDictionary *result, *responseResult;
|
NSDictionary *result, *responseResult;
|
||||||
MAPIStoreMapping *mapping;
|
MAPIStoreMapping *mapping;
|
||||||
uint64_t mid;
|
uint64_t mid;
|
||||||
|
NSUInteger count;
|
||||||
|
|
||||||
properties = [sogoObject properties];
|
properties = [sogoObject properties];
|
||||||
|
|
||||||
/* headers */
|
/* headers */
|
||||||
from = [self _quoteSpecials: [properties objectForKey: MAPIPropertyKey (PR_SENT_REPRESENTING_EMAIL_ADDRESS_UNICODE)]];
|
|
||||||
to = [self _quoteSpecials: [properties objectForKey: MAPIPropertyKey (PR_DISPLAY_TO_UNICODE)]];
|
|
||||||
subject = [properties objectForKey: MAPIPropertyKey (PR_SUBJECT_UNICODE)];
|
|
||||||
date = [properties objectForKey: MAPIPropertyKey (PR_CLIENT_SUBMIT_TIME)];
|
|
||||||
messageId = [properties objectForKey: MAPIPropertyKey (PR_INTERNET_MESSAGE_ID_UNICODE)];
|
|
||||||
|
|
||||||
map = [[[NGMutableHashMap alloc] initWithCapacity:16] autorelease];
|
map = [[[NGMutableHashMap alloc] initWithCapacity:16] autorelease];
|
||||||
if ([to length])
|
|
||||||
[map setObject: to forKey: @"to"];
|
from = [self _quoteSpecials: [properties objectForKey: MAPIPropertyKey (PR_ORIGINAL_AUTHOR_NAME_UNICODE)]];
|
||||||
if ([from length])
|
if ([from length])
|
||||||
[map setObject: from forKey: @"from"];
|
[map setObject: from forKey: @"from"];
|
||||||
if ([subject length])
|
|
||||||
[map setObject: [subject asQPSubjectString: @"utf-8"]
|
/* save the recipients */
|
||||||
forKey: @"subject"];
|
recipients = [properties objectForKey: @"recipients"];
|
||||||
|
if (recipients)
|
||||||
|
{
|
||||||
|
for (count = 0; count < 3; count++)
|
||||||
|
{
|
||||||
|
recId = recIds[count];
|
||||||
|
list = [recipients objectForKey: recId];
|
||||||
|
if ([list count] > 0)
|
||||||
|
[map setObjects: [list keysWithFormat: @"%{fullName} <%{email}>"]
|
||||||
|
forKey: recId];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
[self errorWithFormat: @"message without recipients"];
|
||||||
|
|
||||||
|
subject = [NSMutableString stringWithCapacity: 128];
|
||||||
|
subjectData = [properties objectForKey: MAPIPropertyKey (PR_SUBJECT_PREFIX_UNICODE)];
|
||||||
|
if (subjectData)
|
||||||
|
[subject appendString: subjectData];
|
||||||
|
subjectData = [properties objectForKey: MAPIPropertyKey (PR_NORMALIZED_SUBJECT_UNICODE)];
|
||||||
|
if (subjectData)
|
||||||
|
[subject appendString: subjectData];
|
||||||
|
[map setObject: [subject asQPSubjectString: @"utf-8"] forKey: @"subject"];
|
||||||
|
|
||||||
|
messageId = [properties objectForKey: MAPIPropertyKey (PR_INTERNET_MESSAGE_ID_UNICODE)];
|
||||||
if ([messageId length])
|
if ([messageId length])
|
||||||
[map setObject: messageId forKey: @"message-id"];
|
[map setObject: messageId forKey: @"message-id"];
|
||||||
|
|
||||||
|
date = [properties objectForKey: MAPIPropertyKey (PR_CLIENT_SUBMIT_TIME)];
|
||||||
if (date)
|
if (date)
|
||||||
[map addObject: [date rfc822DateString] forKey: @"date"];
|
[map addObject: [date rfc822DateString] forKey: @"date"];
|
||||||
[map addObject: @"1.0" forKey: @"MIME-Version"];
|
[map addObject: @"1.0" forKey: @"MIME-Version"];
|
||||||
|
|
||||||
message = [[[NGMimeMessage alloc] initWithHeader: map] autorelease];
|
|
||||||
|
|
||||||
/* body */
|
|
||||||
htmlData = [properties objectForKey: MAPIPropertyKey (PR_HTML)];
|
htmlData = [properties objectForKey: MAPIPropertyKey (PR_HTML)];
|
||||||
if (htmlData)
|
if (htmlData)
|
||||||
{
|
{
|
||||||
|
@ -269,24 +294,29 @@ Class NSNumberK;
|
||||||
default:
|
default:
|
||||||
charset = @"iso-8859-1";
|
charset = @"iso-8859-1";
|
||||||
}
|
}
|
||||||
|
|
||||||
body = [NSString stringWithData: htmlData
|
|
||||||
usingEncodingNamed: charset];
|
|
||||||
[map setObject: [NSString stringWithFormat: @"text/html; charset=%@",
|
[map setObject: [NSString stringWithFormat: @"text/html; charset=%@",
|
||||||
charset]
|
charset]
|
||||||
forKey: @"content-type"];
|
forKey: @"content-type"];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
[map setObject: @"text/plain; charset=utf-8"
|
||||||
|
forKey: @"content-type"];
|
||||||
|
|
||||||
|
message = [[[NGMimeMessage alloc] initWithHeader: map] autorelease];
|
||||||
|
|
||||||
|
/* body */
|
||||||
|
if (htmlData)
|
||||||
|
{
|
||||||
|
body = [NSString stringWithData: htmlData
|
||||||
|
usingEncodingNamed: charset];
|
||||||
[message setBody: body];
|
[message setBody: body];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
body = [properties objectForKey: MAPIPropertyKey (PR_BODY_UNICODE)];
|
body = [properties objectForKey: MAPIPropertyKey (PR_BODY_UNICODE)];
|
||||||
if (body)
|
if (body)
|
||||||
{
|
|
||||||
[map setObject: @"text/plain; charset=utf-8"
|
|
||||||
forKey: @"content-type"];
|
|
||||||
[message setBody: body];
|
[message setBody: body];
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* mime message generation */
|
/* mime message generation */
|
||||||
generator = [NGMimeMessageGenerator new];
|
generator = [NGMimeMessageGenerator new];
|
||||||
|
@ -314,6 +344,14 @@ Class NSNumberK;
|
||||||
[sogoObject setNameInContainer: [NSString stringWithFormat: @"%@.eml", newIdString]];
|
[sogoObject setNameInContainer: [NSString stringWithFormat: @"%@.eml", newIdString]];
|
||||||
[mapping registerURL: [self url] withID: mid];
|
[mapping registerURL: [self url] withID: mid];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* synchronise the cache and update the change key with the one provided by
|
||||||
|
the client */
|
||||||
|
[(MAPIStoreMailFolder *) container synchroniseCache];
|
||||||
|
changeKey = [properties objectForKey: MAPIPropertyKey (PR_CHANGE_KEY)];
|
||||||
|
if (changeKey)
|
||||||
|
[(MAPIStoreMailFolder *) container
|
||||||
|
setChangeKey: changeKey forMessageWithKey: [self nameInContainer]];
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
Loading…
Reference in a new issue