#include "SOGoMailBodyPart.h"
#include <NGImap4/NGImap4Envelope.h>
#include <NGImap4/NGImap4EnvelopeAddress.h>
+#include <NGMail/NGMimeMessageParser.h>
#include "common.h"
@implementation SOGoMailObject
static NSArray *coreInfoKeys = nil;
static BOOL heavyDebug = NO;
+static BOOL fetchHeader = YES;
static BOOL debugOn = NO;
static BOOL debugBodyStructure = NO;
static BOOL debugSoParts = NO;
}
+ (void)initialize {
+ NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
+
NSAssert2([super version] == 1,
@"invalid superclass (%@) version %i !",
NSStringFromClass([self superclass]), [super version]);
-
+
+ if ((fetchHeader = ([ud boolForKey:@"SOGoDoNotFetchMailHeader"] ? NO : YES)))
+ NSLog(@"Note: fetching full mail header.");
+ else
+ NSLog(@"Note: not fetching full mail header: 'SOGoDoNotFetchMailHeader'");
+
/* Note: see SOGoMailManager.m for allowed IMAP4 keys */
/* Note: "BODY" actually returns the structure! */
- coreInfoKeys = [[NSArray alloc] initWithObjects:
- @"FLAGS", @"ENVELOPE", @"BODY",
- @"RFC822.SIZE",
- // not yet supported: @"INTERNALDATE",
- nil];
+ if (fetchHeader) {
+ coreInfoKeys = [[NSArray alloc] initWithObjects:
+ @"FLAGS", @"ENVELOPE", @"BODY",
+ @"RFC822.SIZE",
+ @"RFC822.HEADER",
+ // not yet supported: @"INTERNALDATE",
+ nil];
+ }
+ else {
+ coreInfoKeys = [[NSArray alloc] initWithObjects:
+ @"FLAGS", @"ENVELOPE", @"BODY",
+ @"RFC822.SIZE",
+ // not yet supported: @"INTERNALDATE",
+ nil];
+ }
}
- (void)dealloc {
- [self->coreInfos release];
+ [self->headerPart release];
+ [self->coreInfos release];
[super dealloc];
}
return [[self envelope] cc];
}
+- (NSData *)mailHeaderData {
+ return [[self fetchCoreInfos] valueForKey:@"header"];
+}
+- (BOOL)hasMailHeaderInCoreInfos {
+ return [[self mailHeaderData] length] > 0 ? YES : NO;
+}
+
+- (NSDictionary *)mailHeader {
+ // TODO: cache
+ NGMimeMessageParser *parser;
+ NSData *data;
+
+ if (self->headerPart != nil)
+ return [self->headerPart isNotNull] ? self->headerPart : nil;
+
+ if ([(data = [self mailHeaderData]) length] == 0)
+ return nil;
+
+ // TODO: do we need to set some delegate method which stops parsing the body?
+ parser = [[NGMimeMessageParser alloc] init];
+ self->headerPart = [[parser parsePartFromData:data] retain];
+ [parser release]; parser = nil;
+
+ if (self->headerPart == nil) {
+ self->headerPart = [[NSNull null] retain];
+ return nil;
+ }
+ return self->headerPart;
+}
+
- (id)lookupInfoForBodyPart:(id)_path {
NSEnumerator *pe;
NSString *p;
<input type="checkbox" var:name="msgRowID" value="0"
onchange="toggleMailSelect(this)" />
</td>
+ <!-- the td:onlick doesn't work on Safari -->
<td var:class="messageCellStyleClass" var:onclick="clickedMsgJS">
<div var:class="messageSubjectStyleClass" var:id="msgDivID">
- <a href="#" var:onclick="clickedMsgJS">
+ <!-- removed anker (resulted in two clicks on Moz -->
+ <!-- a href="#" var:onclick="clickedMsgJS" -->
<!-- Note: var:href="messageViewURL" (done by JS),
var:target="messageViewTarget" -->
<var:string value="message.envelope.subject"
formatter="context.mailSubjectFormatter"/>
- </a>
+ <!-- /a -->
</div>
</td>
<td var:class="messageCellStyleClass" var:onclick="clickedMsgJS">