2007-11-01 Wolfgang Sourdeau <wsourdeau@inverse.ca>
+ * SoObjects/Mailer/SOGoDraftObject.m ([SOGoDraftObject
+ -setHeaders:newHeaders]): make sure there is a message id in the
+ headers dictionary, if not, generate one.
+ ([SOGoDraftObject -fetchMailForEditing:sourceMail]): retrieve the
+ message id from the existing draft.
+ ([SOGoDraftObject -mimeHeaderMapWithHeaders:_headers]): store the
+ message id in the header map.
+
* UI/MailerUI/UIxMailFolderActions.m ([UIxMailFolderActions
-deleteFolderAction]): no longer prefix the target folder with
"folder".
#import <Foundation/NSAutoreleasePool.h>
#import <Foundation/NSDictionary.h>
#import <Foundation/NSKeyValueCoding.h>
+#import <Foundation/NSProcessInfo.h>
#import <Foundation/NSURL.h>
#import <Foundation/NSUserDefaults.h>
#import <Foundation/NSValue.h>
static NSString *contentTypeValue = @"text/plain; charset=utf-8";
static NSString *headerKeys[] = {@"subject", @"to", @"cc", @"bcc",
- @"from", @"replyTo",
+ @"from", @"replyTo", @"message-id",
nil};
@implementation SOGoDraftObject
/* contents */
+- (NSString *) _generateMessageID
+{
+ NSMutableString *messageID;
+ NSString *pGUID;
+
+ messageID = [NSMutableString string];
+ [messageID appendFormat: @"<%@", [self globallyUniqueObjectId]];
+ pGUID = [[NSProcessInfo processInfo] globallyUniqueString];
+ [messageID appendFormat: @"@%u>", [pGUID hash]];
+
+ return [messageID lowercaseString];
+}
+
- (void) setHeaders: (NSDictionary *) newHeaders
{
id headerValue;
unsigned int count;
+ NSString *messageID;
- for (count = 0; count < 7; count++)
+ for (count = 0; count < 8; count++)
{
headerValue = [newHeaders objectForKey: headerKeys[count]];
if (headerValue)
else
[headers removeObjectForKey: headerKeys[count]];
}
+
+ messageID = [headers objectForKey: @"message-id"];
+ if (!messageID)
+ {
+ messageID = [self _generateMessageID];
+ [headers setObject: messageID forKey: @"message-id"];
+ }
}
- (NSDictionary *) headers
- (void) fetchMailForEditing: (SOGoMailObject *) sourceMail
{
- NSString *subject;
+ NSString *subject, *msgid;
NSMutableDictionary *info;
NSMutableArray *addresses;
NGImap4Envelope *sourceEnvelope;
[info setObject: subject forKey: @"subject"];
sourceEnvelope = [sourceMail envelope];
+ msgid = [sourceEnvelope messageID];
+ if ([msgid length] > 0)
+ [info setObject: msgid forKey: @"message-id"];
+
addresses = [NSMutableArray array];
[self _addEMailsOfAddresses: [sourceEnvelope to] toArray: addresses];
[info setObject: addresses forKey: @"to"];
[map setObject: [s asQPSubjectString: @"utf-8"]
forKey: @"subject"];
// [map setObject: [s asQPSubjectString: @"utf-8"] forKey: @"subject"];
-
+
+ [map setObject: [headers objectForKey: @"message-id"]
+ forKey: @"message-id"];
+
/* add standard headers */
dateString = [[NSCalendarDate date] rfc822DateString];