2 Copyright (C) 2004-2005 SKYRIX Software AG
4 This file is part of OpenGroupware.org.
6 OGo is free software; you can redistribute it and/or modify it under
7 the terms of the GNU Lesser General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 OGo is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with OGo; see the file COPYING. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
22 #include "UIxMailPartViewer.h"
25 UIxMailPartMessageViewer
27 Show message/rfc822 mail parts. Note that the IMAP4 server already returns a
28 proper body structure of the message.
30 Relevant body-info keys:
31 to/sender/from/cc/bcc/in-reply-to/reply-to - array of addr-dicts
32 type/subtype - message/RFC822
35 parameterList - dict (eg 'name')
40 bodyId - (empty string?)
41 description - (empty string?, content-description?)
43 body - a body structure?
46 hostName / mailboxName / personalName / sourceRoute
49 @class NGImap4Envelope;
51 @interface UIxMailPartMessageViewer : UIxMailPartViewer
53 NGImap4Envelope *envelope;
59 #include <UI/MailerUI/WOContext+UIxMailer.h>
60 #include "UIxMailRenderingContext.h"
61 #include <NGImap4/NGImap4Envelope.h>
62 #include <NGImap4/NGImap4EnvelopeAddress.h>
65 @implementation UIxMailPartMessageViewer
68 [self->currentAddress release];
69 [self->envelope release];
73 /* cache maintenance */
75 - (void)resetBodyInfoCaches {
76 [super resetBodyInfoCaches];
77 [self->envelope release]; self->envelope = nil;
78 [self->currentAddress release]; self->currentAddress = nil;
84 [self->currentAddress release]; self->currentAddress = nil;
90 - (void)setCurrentAddress:(id)_addr {
91 ASSIGN(self->currentAddress, _addr);
93 - (id)currentAddress {
94 return self->currentAddress;
97 /* nested body structure */
100 return [[self bodyInfo] valueForKey:@"body"];
103 - (id)contentPartPath {
105 Path processing is a bit weird in the context of message/rfc822. If we have
106 a multipart, the multipart itself has no own identifier! Instead the
107 children of the multipart are directly mapped into the message namespace.
109 If the message has just a plain content, ids seems to be as expected (that
115 mt = [[[self contentInfo] valueForKey:@"type"] lowercaseString];
116 if ([mt isEqualToString:@"multipart"])
117 return [self partPath];
119 pp = [self partPath];
120 return [pp count] > 0
121 ? [pp arrayByAddingObject:@"1"]
122 : [NSArray arrayWithObject:@"1"];
125 - (id)contentViewerComponent {
128 info = [self contentInfo];
129 return [[[self context] mailRenderingContext] viewerForBodyInfo:info];
132 /* generating envelope */
134 - (NGImap4Envelope *)envelope {
135 if (self->envelope == nil) {
136 self->envelope = [[NGImap4Envelope alloc] initWithBodyStructureInfo:
139 return self->envelope;
142 /* links to recipients */
144 - (NSString *)linkToEnvelopeAddress:(NGImap4EnvelopeAddress *)_address {
145 // TODO: make some web-link, eg open a new compose panel?
146 return [@"mailto:" stringByAppendingString:[_address baseEMail]];
149 - (NSString *)currentAddressLink {
150 return [self linkToEnvelopeAddress:[self currentAddress]];
153 @end /* UIxMailPartMessageViewer */