From 38563e60d86b5a9c020e4c22d0763695f473203a Mon Sep 17 00:00:00 2001 From: helge Date: Tue, 19 Jul 2005 10:29:16 +0000 Subject: [PATCH] made the internet-access suffix a pattern git-svn-id: http://svn.opengroupware.org/SOGo/trunk@822 d1b88da0-ebda-0310-925b-ed51d893ca5b --- SOGo/SoObjects/Mailer/ChangeLog | 3 ++ SOGo/SoObjects/Mailer/README | 5 +++- SOGo/SoObjects/Mailer/SOGoDraftObject.m | 38 +++++++++++++++---------- SOGo/SoObjects/Mailer/Version | 19 +++++++------ 4 files changed, 40 insertions(+), 25 deletions(-) diff --git a/SOGo/SoObjects/Mailer/ChangeLog b/SOGo/SoObjects/Mailer/ChangeLog index 29551aee..b23b9809 100644 --- a/SOGo/SoObjects/Mailer/ChangeLog +++ b/SOGo/SoObjects/Mailer/ChangeLog @@ -1,5 +1,8 @@ 2005-07-19 Helge Hess + * SOGoDraftObject.m: made 'SOGoInternetMailSuffix' a pattern which can + access request values (v0.9.111) + * SOGoDraftObject.m: added support for adding a marker to the textpart of the message in case the client is accessing the server from the Internet. The text can be specified using the diff --git a/SOGo/SoObjects/Mailer/README b/SOGo/SoObjects/Mailer/README index dca7ba44..9f1b4389 100644 --- a/SOGo/SoObjects/Mailer/README +++ b/SOGo/SoObjects/Mailer/README @@ -44,6 +44,9 @@ SOGoSharedFolderName IMAP4-Name SOGoOtherUsersFolderName IMAP4-Name - corresponds to the Cyrus setting: userprefix -SOGoInternetMailSuffix String - suffix to add to mails sent via Internet +SOGoInternetMailSuffix String-Pattern + - suffix to add to mails sent via Internet - eg: -SOGoInternetMailSuffix \ '"*** This email was composed using SOGo on the public Internet ***"' + you can access request values inside the pattern, eg: + "$headers.host$" diff --git a/SOGo/SoObjects/Mailer/SOGoDraftObject.m b/SOGo/SoObjects/Mailer/SOGoDraftObject.m index d33367ac..e8411e99 100644 --- a/SOGo/SoObjects/Mailer/SOGoDraftObject.m +++ b/SOGo/SoObjects/Mailer/SOGoDraftObject.m @@ -40,9 +40,8 @@ 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; +static BOOL showTextAttachmentsInline = NO; +static NSString *fromInternetSuffixPattern = nil; + (int)version { return [super version] + 0 /* v1 */; @@ -61,13 +60,12 @@ static NSData *fromInternetSuffixData = nil; if ((draftDeleteDisabled = [ud boolForKey:@"SOGoNoDraftDeleteAfterSend"])) NSLog(@"WARNING: draft delete is disabled! (SOGoNoDraftDeleteAfterSend)"); - fromInternetSuffix = [ud stringForKey:@"SOGoInternetMailSuffix"]; - if ([fromInternetSuffix length] == 0) + fromInternetSuffixPattern = [ud stringForKey:@"SOGoInternetMailSuffix"]; + if ([fromInternetSuffixPattern length] == 0) NSLog(@"Note: no 'SOGoInternetMailSuffix' is configured."); else { - fromInternetSuffix = [@"\n" stringByAppendingString:fromInternetSuffix]; - fromInternetSuffixData = - [fromInternetSuffix dataUsingEncoding:NSUTF8StringEncoding]; + fromInternetSuffixPattern = + [@"\n" stringByAppendingString:fromInternetSuffixPattern]; } TextPlainType = [[NGMimeType mimeType:@"text" subType:@"plain"] copy]; @@ -311,16 +309,24 @@ static NSData *fromInternetSuffixData = nil; - (NGMimeMessage *)mimeMessageForContentWithHeaderMap:(NGMutableHashMap *)map { NSDictionary *lInfo; NGMimeMessage *message; - BOOL addSuffix; - id body; + WOContext *ctx; + NSString *fromInternetSuffix; + BOOL addSuffix; + id body; if ((lInfo = [self fetchInfo]) == nil) return nil; - addSuffix = - [[[WOApplication application] context] isAccessFromIntranet] ? NO : YES; - if (addSuffix) + ctx = [[WOApplication application] context]; + addSuffix = [ctx isAccessFromIntranet] ? NO : YES; + if (addSuffix) { + fromInternetSuffix = + [fromInternetSuffixPattern stringByReplacingVariablesWithBindings: + [ctx request] + stringForUnknownBindings:@""]; + addSuffix = [fromInternetSuffix length] > 0 ? YES : NO; + } [map setObject:@"text/plain" forKey:@"content-type"]; if ((body = [lInfo objectForKey:@"text"]) != nil) { @@ -334,7 +340,9 @@ static NSData *fromInternetSuffixData = nil; } else if ([body isKindOfClass:[NSData class]] && addSuffix) { body = [[body mutableCopy] autorelease]; - [(NSMutableData *)body appendData:fromInternetSuffixData]; + [(NSMutableData *)body appendData: + [fromInternetSuffix dataUsingEncoding: + NSUTF8StringEncoding]]; } else if (addSuffix) { [self warnWithFormat:@"Note: cannot add Internet marker to body: %@", @@ -342,7 +350,7 @@ static NSData *fromInternetSuffixData = nil; } } else if (addSuffix) - body = fromInternetSuffixData; + body = [fromInternetSuffix dataUsingEncoding:NSUTF8StringEncoding]; message = [[[NGMimeMessage alloc] initWithHeader:map] autorelease]; [message setBody:body]; diff --git a/SOGo/SoObjects/Mailer/Version b/SOGo/SoObjects/Mailer/Version index e8532a11..6d6868c7 100644 --- a/SOGo/SoObjects/Mailer/Version +++ b/SOGo/SoObjects/Mailer/Version @@ -1,12 +1,13 @@ # Version file -SUBMINOR_VERSION:=110 +SUBMINOR_VERSION:=111 -# v0.9.96 requires libNGMime v4.5.223 -# v0.9.91 requires libNGMime v4.5.222 -# v0.9.69 requires libNGMime v4.5.210 -# v0.9.55 requires libNGExtensions v4.5.136 -# v0.9.44 requires libNGMime v4.3.194 -# v0.9.41 requires libNGMime v4.3.190 -# v0.9.35 requires libSOGoLogic v0.9.24 -# v0.9.34 requires libSOGoLogic v0.9.22 +# v0.9.111 requires libNGExtensions v4.5.163 +# v0.9.96 requires libNGMime v4.5.223 +# v0.9.91 requires libNGMime v4.5.222 +# v0.9.69 requires libNGMime v4.5.210 +# v0.9.55 requires libNGExtensions v4.5.136 +# v0.9.44 requires libNGMime v4.3.194 +# v0.9.41 requires libNGMime v4.3.190 +# v0.9.35 requires libSOGoLogic v0.9.24 +# v0.9.34 requires libSOGoLogic v0.9.22 -- 2.39.5