*/
#include "SOGoDraftObject.h"
+#include <SoObjects/SOGo/WOContext+Agenor.h>
#include <NGMail/NGMimeMessage.h>
#include <NGMail/NGMimeMessageGenerator.h>
#include <NGMail/NGSendMail.h>
@implementation SOGoDraftObject
-static NGMimeType *TextPlainType = nil;
-static NGMimeType *MultiMixedType = nil;
-static NSString *userAgent = @"SOGoMail 1.0";
-static BOOL draftDeleteDisabled = NO; // for debugging
-static BOOL debugOn = NO;
-static BOOL showTextAttachmentsInline = NO;
+static NGMimeType *TextPlainType = nil;
+static NGMimeType *MultiMixedType = nil;
+static NSString *userAgent = @"SOGoMail 1.0";
+static BOOL draftDeleteDisabled = NO; // for debugging
+static BOOL debugOn = NO;
+static BOOL showTextAttachmentsInline = NO;
+static NSString *fromInternetSuffix = nil;
+static NSData *fromInternetSuffixData = nil;
+ (int)version {
return [super version] + 0 /* v1 */;
+ (void)initialize {
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
-
+
NSAssert2([super version] == 1,
@"invalid superclass (%@) version %i !",
NSStringFromClass([self superclass]), [super version]);
if ((draftDeleteDisabled = [ud boolForKey:@"SOGoNoDraftDeleteAfterSend"]))
NSLog(@"WARNING: draft delete is disabled! (SOGoNoDraftDeleteAfterSend)");
+ fromInternetSuffix = [ud stringForKey:@"SOGoInternetMailSuffix"];
+ if ([fromInternetSuffix length] == 0)
+ NSLog(@"Note: no 'SOGoInternetMailSuffix' is configured.");
+ else {
+ fromInternetSuffix = [@"\n" stringByAppendingString:fromInternetSuffix];
+ fromInternetSuffixData =
+ [fromInternetSuffix dataUsingEncoding:NSUTF8StringEncoding];
+ }
+
TextPlainType = [[NGMimeType mimeType:@"text" subType:@"plain"] copy];
MultiMixedType = [[NGMimeType mimeType:@"multipart" subType:@"mixed"] copy];
}
- (NGMimeMessage *)mimeMessageForContentWithHeaderMap:(NGMutableHashMap *)map {
NSDictionary *lInfo;
NGMimeMessage *message;
+ BOOL addSuffix;
id body;
if ((lInfo = [self fetchInfo]) == nil)
return nil;
+ addSuffix =
+ [[[WOApplication application] context] isAccessFromIntranet] ? NO : YES;
+ if (addSuffix)
+ addSuffix = [fromInternetSuffix length] > 0 ? YES : NO;
+
[map setObject:@"text/plain" forKey:@"content-type"];
if ((body = [lInfo objectForKey:@"text"]) != nil) {
if ([body isKindOfClass:[NSString class]]) {
+ if (addSuffix)
+ body = [body stringByAppendingString:fromInternetSuffix];
+
/* Note: just 'utf8' is displayed wrong in Mail.app */
[map setObject:@"text/plain; charset=utf-8" forKey:@"content-type"];
body = [body dataUsingEncoding:NSUTF8StringEncoding];
}
+ else if ([body isKindOfClass:[NSData class]] && addSuffix) {
+ body = [[body mutableCopy] autorelease];
+ [(NSMutableData *)body appendData:fromInternetSuffixData];
+ }
+ else if (addSuffix) {
+ [self warnWithFormat:@"Note: cannot add Internet marker to body: %@",
+ NSStringFromClass([body class])];
+ }
}
+ else if (addSuffix)
+ body = fromInternetSuffixData;
message = [[[NGMimeMessage alloc] initWithHeader:map] autorelease];
[message setBody:body];