From: helge Date: Mon, 7 Feb 2005 13:39:20 +0000 (+0000) Subject: made Internet request detection configurable, X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=18c571a8b5ba1e479ae9a06d0129006ab5961042;p=scalable-opengroupware.org made Internet request detection configurable, added ability to add special MIME headers for such requests git-svn-id: http://svn.opengroupware.org/SOGo/trunk@526 d1b88da0-ebda-0310-925b-ed51d893ca5b --- diff --git a/SOGo/UI/Mailer/ChangeLog b/SOGo/UI/Mailer/ChangeLog index 44325bd5..795bc8a3 100644 --- a/SOGo/UI/Mailer/ChangeLog +++ b/SOGo/UI/Mailer/ChangeLog @@ -1,5 +1,12 @@ 2005-02-07 Helge Hess + * UIxMailEditor.m: disabled Internet warning in the mail editor per + default, can be enabled using the 'SOGoShowInternetMarker' default, + made Internet header detection qualifier configurable, see README + (SOGoInternetDetectQualifier string default), when the request is + from the Internet, add headers as specified in the + 'SOGoInternetMailHeaders' dictionary default (v0.9.91) + * UIxMailTree.m: added support for special folder icons (v0.9.90) * v0.9.89 diff --git a/SOGo/UI/Mailer/README b/SOGo/UI/Mailer/README index 96ab0eef..7f893ff0 100644 --- a/SOGo/UI/Mailer/README +++ b/SOGo/UI/Mailer/README @@ -20,6 +20,27 @@ UIxMailMainFrame.wox UIxMailTree.wox UIxMailView.wox +Defaults +======== + +SOGoShowInternetMarker - bool +- show a marker in the editor that the request is from the outside + +SOGoInternetDetectQualifier - string +- an EOQualifier to detect whether a set of HTTP headers is from the outside, + eg: "NOT (minequprovenance = 'intranet')" + -SOGoInternetDetectQualifier '"NOT (minequprovenance = \"intranet\")"' + Note: all header field names are lowercase + +SOGoInternetMailHeaders - dictionary +- if a request was detected as coming from the Internet, add the mail headers + specified in this default + eg: { received = "sogo depuis internet"; } + -SOGoInternetMailHeaders "{received=\"sogo depuis internet\"; }" + +SOGoMailEditorKeepTmpFile +- for debugging, if a mail was send, keep the file containing the MIME in the + temporary directory for review instead of deleting it Notes ===== diff --git a/SOGo/UI/Mailer/UIxMailEditor.m b/SOGo/UI/Mailer/UIxMailEditor.m index b79884a9..568a5d91 100644 --- a/SOGo/UI/Mailer/UIxMailEditor.m +++ b/SOGo/UI/Mailer/UIxMailEditor.m @@ -55,11 +55,15 @@ @implementation UIxMailEditor -static BOOL keepMailTmpFile = NO; -static NSArray *infoKeys = nil; +static BOOL keepMailTmpFile = NO; +static BOOL showInternetMarker = NO; +static EOQualifier *internetDetectQualifier = nil; +static NSDictionary *internetMailHeaders = nil; +static NSArray *infoKeys = nil; + (void)initialize { NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; + NSString *s; infoKeys = [[NSArray alloc] initWithObjects: @"subject", @"text", @"to", @"cc", @"bcc", @@ -69,6 +73,30 @@ static NSArray *infoKeys = nil; keepMailTmpFile = [ud boolForKey:@"SOGoMailEditorKeepTmpFile"]; if (keepMailTmpFile) NSLog(@"WARNING: keeping mail files."); + + /* Internet mail settings */ + + showInternetMarker = [ud boolForKey:@"SOGoShowInternetMarker"]; + if (!showInternetMarker) { + NSLog(@"Note: visual Internet marker on mail editor disabled " + @"(SOGoShowInternetMarker)"); + } + + if ((s = [ud stringForKey:@"SOGoInternetDetectQualifier"]) != nil) { + internetDetectQualifier = + [[EOQualifier qualifierWithQualifierFormat:s] retain]; + if (internetDetectQualifier == nil) + NSLog(@"ERROR: could not parse qualifier: '%@'", s); + } + if (internetDetectQualifier == nil) + NSLog(@"Note: no 'SOGoInternetDetectQualifier' configured."); + else + NSLog(@"Note: detect Internet access using: %@", internetDetectQualifier); + + internetMailHeaders = + [[ud dictionaryForKey:@"SOGoInternetMailHeaders"] copy]; + NSLog(@"Note: specified %d headers for mails send via the Internet.", + [internetMailHeaders count]); } - (void)dealloc { @@ -136,6 +164,23 @@ static NSArray *infoKeys = nil; return [self labelForKey:@"Compose Mail"]; } +/* detect webmail being accessed from the outside */ + +- (BOOL)isInternetRequest { + // TODO: make configurable! (eg allow specification of a qualifier) + WORequest *rq; + + rq = [[self context] request]; + return [(id)internetDetectQualifier + evaluateWithObject:[rq headers]]; +} + +- (BOOL)showInternetMarker { + if (!showInternetMarker) + return NO; + return [self isInternetRequest]; +} + /* info loading */ - (void)loadInfo:(NSDictionary *)_info { @@ -242,8 +287,9 @@ static NSArray *infoKeys = nil; } - (id)sendAction { - NSException *error; - NSString *mailPath; + NSException *error; + NSString *mailPath; + NSDictionary *h; // TODO: need to validate whether we have a To etc @@ -251,11 +297,15 @@ static NSArray *infoKeys = nil; if (![self _saveFormInfo]) return [self failedToSaveFormResponse]; + + /* setup some extra headers if required */ + + h = [self isInternetRequest] ? internetMailHeaders : nil; /* save mail to file (so that we can upload the mail to Cyrus) */ // TODO: all this could be handled by the SOGoDraftObject? - mailPath = [[self clientObject] saveMimeMessageToTemporaryFile]; + mailPath = [[self clientObject] saveMimeMessageToTemporaryFileWithHeaders:h]; /* then, send mail */ diff --git a/SOGo/UI/Mailer/UIxMailEditor.wox b/SOGo/UI/Mailer/UIxMailEditor.wox index c51c4dad..5196c0e6 100644 --- a/SOGo/UI/Mailer/UIxMailEditor.wox +++ b/SOGo/UI/Mailer/UIxMailEditor.wox @@ -22,8 +22,7 @@ --> - +
diff --git a/SOGo/UI/Mailer/Version b/SOGo/UI/Mailer/Version index ec1d8ba8..df435c35 100644 --- a/SOGo/UI/Mailer/Version +++ b/SOGo/UI/Mailer/Version @@ -1,7 +1,8 @@ # version file -SUBMINOR_VERSION:=90 +SUBMINOR_VERSION:=91 +# v0.9.91 requires SoObjects/Mailer v0.9.68 # v0.9.89 requires SoObjects/Mailer v0.9.67 # v0.9.87 requires SoObjects/Mailer v0.9.65 # v0.9.86 requires SoObjects/Mailer v0.9.64