2005-02-07 Helge Hess <helge.hess@opengroupware.org>
+ * 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
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
=====
@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",
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 {
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<EOQualifierEvaluation>)internetDetectQualifier
+ evaluateWithObject:[rq headers]];
+}
+
+- (BOOL)showInternetMarker {
+ if (!showInternetMarker)
+ return NO;
+ return [self isInternetRequest];
+}
+
/* info loading */
- (void)loadInfo:(NSDictionary *)_info {
}
- (id)sendAction {
- NSException *error;
- NSString *mailPath;
+ NSException *error;
+ NSString *mailPath;
+ NSDictionary *h;
// TODO: need to validate whether we have a To etc
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 */