From e4956f5d1fa45801c5478186efc926ba00b85b77 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Tue, 23 Nov 2010 13:53:54 +0000 Subject: [PATCH] Monotone-Parent: 50626dad4bfc5d3baa2556f6d16ca3eb3cc21bb6 Monotone-Revision: f6dd6e26aadfa52716bf3ca2c504de3593e5f35b Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2010-11-23T13:53:54 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 16 +++++++++++ SoObjects/Mailer/SOGoDraftObject.h | 3 +++ SoObjects/Mailer/SOGoDraftObject.m | 36 ++++++++++++++----------- UI/MailerUI/UIxMailEditor.m | 17 ++++++++++++ UI/Templates/MailerUI/UIxMailEditor.wox | 1 + 5 files changed, 57 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2b3120f13..1671bde50 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2010-11-23 Wolfgang Sourdeau + + * SoObjects/Mailer/SOGoDraftObject.m (-setIsHTML, -isHTML): new + accessors, which enables the setting of html mode from the caller + rather than from the user defaults. + (-mimeMessageForContentWithHeaderMap:, -bodyPartForText): make use + of "isHTML". + + * UI/MailerUI/UIxMailEditor.m (-setIsHTML, -isHTML): new + accessors. The former sets the "isHTML" ivar based on a previous + request on the latter, which actually returns the value stored in + the user defaults. This enables the user to change composition + type while editing a message without altering the proper logic + underneat. + (-_saveFormInfo): forward the value of "isHTML" to the co. + 2010-11-22 Wolfgang Sourdeau * OpenChange/MAPIStoreContext.m diff --git a/SoObjects/Mailer/SOGoDraftObject.h b/SoObjects/Mailer/SOGoDraftObject.h index f3a7b5ebd..c4aab2133 100644 --- a/SoObjects/Mailer/SOGoDraftObject.h +++ b/SoObjects/Mailer/SOGoDraftObject.h @@ -57,6 +57,7 @@ NSString *sourceURL; NSString *sourceFlag; NSString *sourceFolder; + BOOL isHTML; } /* contents */ @@ -72,6 +73,8 @@ - (NSDictionary *) headers; - (void) setText: (NSString *) newText; - (NSString *) text; +- (void) setIsHTML: (BOOL) aBool; +- (BOOL) isHTML; /* for replies and forwards */ - (void) setSourceURL: (NSString *) newSurceURL; diff --git a/SoObjects/Mailer/SOGoDraftObject.m b/SoObjects/Mailer/SOGoDraftObject.m index 30b6559e4..07d3dd74f 100644 --- a/SoObjects/Mailer/SOGoDraftObject.m +++ b/SoObjects/Mailer/SOGoDraftObject.m @@ -112,6 +112,7 @@ static NSString *userAgent = nil; sourceURL = nil; sourceFlag = nil; inReplyTo = nil; + isHTML = NO; } return self; @@ -252,6 +253,16 @@ static NSString *userAgent = nil; return text; } +- (void) setIsHTML: (BOOL) aBool +{ + isHTML = aBool; +} + +- (BOOL) isHTML +{ + return isHTML; +} + - (void) setInReplyTo: (NSString *) newInReplyTo { ASSIGN (inReplyTo, newInReplyTo); @@ -307,6 +318,8 @@ static NSString *userAgent = nil; [infos setObject: headers forKey: @"headers"]; if (text) [infos setObject: text forKey: @"text"]; + [infos setObject: [NSNumber numberWithBool: isHTML] + forKey: @"isHTML"]; if (inReplyTo) [infos setObject: inReplyTo forKey: @"inReplyTo"]; if (IMAP4ID > -1) @@ -351,6 +364,7 @@ static NSString *userAgent = nil; value = [infoDict objectForKey: @"text"]; if ([value length] > 0) [self setText: value]; + isHTML = [[infoDict objectForKey: @"isHTML"] boolValue]; value = [infoDict objectForKey: @"IMAP4ID"]; if (value) @@ -895,13 +909,8 @@ static NSString *userAgent = nil; // TODO: set charset in header! [map setObject: @"text/plain" forKey: @"content-type"]; if (text) - { - if ([[ud mailComposeMessageType] isEqualToString: @"html"]) - [map setObject: htmlContentTypeValue - forKey: @"content-type"]; - else - [map setObject: contentTypeValue forKey: @"content-type"]; - } + [map setObject: (isHTML ? htmlContentTypeValue : contentTypeValue) + forKey: @"content-type"]; // if ((body = text) != nil) { // if ([body isKindOfClass: [NSString class]]) { @@ -934,12 +943,8 @@ static NSString *userAgent = nil; { // if ([body isKindOfClass:[NSString class]]) /* Note: just 'utf8' is displayed wrong in Mail.app */ - if ([[ud mailComposeMessageType] isEqualToString: @"html"]) - [map setObject: htmlContentTypeValue - forKey: @"content-type"]; - else - [map setObject: contentTypeValue - forKey: @"content-type"]; + [map setObject: (isHTML ? htmlContentTypeValue : contentTypeValue) + forKey: @"content-type"]; // body = [body dataUsingEncoding:NSUTF8StringEncoding]; // else if ([body isKindOfClass:[NSData class]] && addSuffix) { // body = [[body mutableCopy] autorelease]; @@ -949,13 +954,12 @@ static NSString *userAgent = nil; // NSStringFromClass([body class])]; // } - message = [[[NGMimeMessage alloc] initWithHeader:map] autorelease]; - [message setBody: body]; + message = [[[NGMimeMessage alloc] initWithHeader:map] autorelease]; + [message setBody: body]; } else message = nil; - return message; } diff --git a/UI/MailerUI/UIxMailEditor.m b/UI/MailerUI/UIxMailEditor.m index 898ba1ef7..df65652fc 100644 --- a/UI/MailerUI/UIxMailEditor.m +++ b/UI/MailerUI/UIxMailEditor.m @@ -76,6 +76,7 @@ NSMutableArray *fromEMails; NSString *from; SOGoMailFolder *sentFolder; + BOOL isHTML; NSString *priority; NSString *receipt; @@ -179,6 +180,21 @@ static NSArray *infoKeys = nil; return receipt; } +- (void) setIsHTML: (BOOL) aBool +{ + isHTML = aBool; + NSLog (@"setIsHTML: %d", aBool); +} + +- (BOOL) isHTML +{ + SOGoUserDefaults *ud; + + ud = [[context activeUser] userDefaults]; + + return [[ud mailComposeMessageType] isEqualToString: @"html"]; +} + - (NSString *) itemPriorityText { return [self labelForKey: [NSString stringWithFormat: @"%@", [item lowercaseString]]]; @@ -480,6 +496,7 @@ static NSArray *infoKeys = nil; info = [self storeInfo]; [co setHeaders: info]; [co setText: text]; + [co setIsHTML: isHTML]; error = [co storeInfo]; if (error) { diff --git a/UI/Templates/MailerUI/UIxMailEditor.wox b/UI/Templates/MailerUI/UIxMailEditor.wox index 3a37c4bb9..da2e513ab 100644 --- a/UI/Templates/MailerUI/UIxMailEditor.wox +++ b/UI/Templates/MailerUI/UIxMailEditor.wox @@ -52,6 +52,7 @@
+