WOContext *context; /* non-retained! */
NSDictionary *flatContents; /* IMAP4 name to NSData */
- WOComponent *alternativeViewer;
- WOComponent *mixedViewer;
- WOComponent *textViewer;
- WOComponent *imageViewer;
- WOComponent *linkViewer;
- WOComponent *messageViewer;
- WOComponent *iCalViewer;
- WOComponent *htmlViewer;
+ WOComponent *textViewer;
+ WOComponent *imageViewer;
+ WOComponent *linkViewer;
+ WOComponent *messageViewer;
+ WOComponent *iCalViewer;
+ WOComponent *htmlViewer;
}
- (id)initWithViewer:(WOComponent *)_viewer context:(WOContext *)_ctx;
}
- (void)dealloc {
- [self->alternativeViewer release];
- [self->iCalViewer release];
- [self->htmlViewer release];
- [self->mixedViewer release];
+ [self->iCalViewer release];
+ [self->htmlViewer release];
[self->textViewer release];
[self->imageViewer release];
[self->linkViewer release];
/* resetting state */
- (void)reset {
- [self->flatContents release]; self->flatContents = nil;
- [self->alternativeViewer release]; self->alternativeViewer = nil;
- [self->mixedViewer release]; self->mixedViewer = nil;
- [self->textViewer release]; self->textViewer = nil;
- [self->htmlViewer release]; self->htmlViewer = nil;
- [self->imageViewer release]; self->imageViewer = nil;
- [self->linkViewer release]; self->linkViewer = nil;
- [self->messageViewer release]; self->messageViewer = nil;
- [self->iCalViewer release]; self->iCalViewer = nil;
+ [self->flatContents release]; self->flatContents = nil;
+ [self->textViewer release]; self->textViewer = nil;
+ [self->htmlViewer release]; self->htmlViewer = nil;
+ [self->imageViewer release]; self->imageViewer = nil;
+ [self->linkViewer release]; self->linkViewer = nil;
+ [self->messageViewer release]; self->messageViewer = nil;
+ [self->iCalViewer release]; self->iCalViewer = nil;
}
/* fetching */
/* viewer components */
- (WOComponent *)mixedViewer {
- if (self->mixedViewer == nil) {
- self->mixedViewer =
- [[self->viewer pageWithName:@"UIxMailPartMixedViewer"] retain];
- }
- return self->mixedViewer;
+ /* Note: we cannot cache the multipart viewers, because it can be nested */
+ return [self->viewer pageWithName:@"UIxMailPartMixedViewer"];
+}
+
+- (WOComponent *)signedViewer {
+ /* Note: we cannot cache the multipart viewers, because it can be nested */
+ // TODO: temporary workaround (treat it like a plain mixed part)
+ return [self mixedViewer];
}
- (WOComponent *)alternativeViewer {
- if (self->alternativeViewer == nil) {
- self->alternativeViewer =
- [[self->viewer pageWithName:@"UIxMailPartAlternativeViewer"] retain];
- }
- return self->alternativeViewer;
+ /* Note: we cannot cache the multipart viewers, because it can be nested */
+ return [self->viewer pageWithName:@"UIxMailPartAlternativeViewer"];
}
- (WOComponent *)textViewer {
if ([mt isEqualToString:@"multipart"]) {
if ([st isEqualToString:@"mixed"])
return [self mixedViewer];
- if ([st isEqualToString:@"signed"]) // TODO: temporary workaround
- return [self mixedViewer];
+ if ([st isEqualToString:@"signed"])
+ return [self signedViewer];
if ([st isEqualToString:@"alternative"])
return [self alternativeViewer];
}
else if ([mt isEqualToString:@"message"] && [st isEqualToString:@"rfc822"])
return [self messageViewer];
else if ([mt isEqualToString:@"application"]) {
- /*
- octet-stream (generate download link?, autodetect type?)
- pgp-viewer
- */
+ // octet-stream (generate download link?, autodetect type?)
+
+#if 0 /* the link viewer looks better than plain text ;-) */
+ if ([st isEqualToString:@"pgp-signature"]) // TODO: real PGP viewer
+ return [self textViewer];
+#endif
}
// TODO: always fallback to octet viewer?!
-#if 0
+#if 1
[self errorWithFormat:@"found no viewer for MIME type: %@/%@", mt, st];
#endif
return [self linkViewer];