static NGMimeType *TextPlainType = nil;
static NGMimeType *MultiMixedType = nil;
+static NSString *userAgent = @"SOGoMail 1.0";
static BOOL draftDeleteDisabled = NO; // for debugging
static BOOL debugOn = NO;
return message;
}
-- (NGMutableHashMap *)mimeHeaderMap {
+- (void)_addHeaders:(NSDictionary *)_h toHeaderMap:(NGMutableHashMap *)_map {
+ NSEnumerator *names;
+ NSString *name;
+
+ if ([_h count] == 0)
+ return;
+
+ names = [_h keyEnumerator];
+ while ((name = [names nextObject]) != nil) {
+ id value;
+
+ value = [_h objectForKey:name];
+ [_map addObject:value forKey:name];
+ }
+}
+
+- (NGMutableHashMap *)mimeHeaderMapWithHeaders:(NSDictionary *)_headers {
NGMutableHashMap *map;
- NSDictionary *lInfo;
+ NSDictionary *lInfo; // TODO: this should be some kind of object?
NSArray *emails;
NSString *s;
[map addObject:[NSCalendarDate date] forKey:@"date"];
[map addObject:@"1.0" forKey:@"MIME-Version"];
- [map addObject:@"SOGoMail 1.0" forKey:@"X-Mailer"];
+ [map addObject:userAgent forKey:@"X-Mailer"];
+
+ /* add custom headers */
+
+ [self _addHeaders:[lInfo objectForKey:@"headers"] toHeaderMap:map];
+ [self _addHeaders:_headers toHeaderMap:map];
return map;
}
-- (NGMimeMessage *)mimeMessage {
+- (NGMimeMessage *)mimeMessageWithHeaders:(NSDictionary *)_headers {
NSAutoreleasePool *pool;
NGMutableHashMap *map;
NSArray *bodyParts;
return nil;
}
- if ((map = [self mimeHeaderMap]) == nil)
+ if ((map = [self mimeHeaderMapWithHeaders:_headers]) == nil)
return nil;
[self debugWithFormat:@"MIME Envelope: %@", map];
[pool release];
return [message autorelease];
}
+- (NGMimeMessage *)mimeMessage {
+ return [self mimeMessageWithHeaders:nil];
+}
-- (NSString *)saveMimeMessageToTemporaryFile {
+- (NSString *)saveMimeMessageToTemporaryFileWithHeaders:(NSDictionary *)_h {
NGMimeMessageGenerator *gen;
NSAutoreleasePool *pool;
NGMimeMessage *message;
pool = [[NSAutoreleasePool alloc] init];
- message = [self mimeMessage];
+ message = [self mimeMessageWithHeaders:_h];
if (![message isNotNull])
return nil;
if ([message isKindOfClass:[NSException class]]) {
[pool release];
return [tmpPath autorelease];
}
+- (NSString *)saveMimeMessageToTemporaryFile {
+ return [self saveMimeMessageToTemporaryFileWithHeaders:nil];
+}
- (void)deleteTemporaryMessageFile:(NSString *)_path {
NSFileManager *fm;