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 #import <NGImap4/NGImap4Envelope.h>
23 #import <NGImap4/NGImap4EnvelopeAddress.h>
25 #import <UI/MailerUI/WOContext+UIxMailer.h>
26 #import "UIxMailRenderingContext.h"
28 #import "UIxMailPartViewer.h"
31 UIxMailPartMessageViewer
33 Show message/rfc822 mail parts. Note that the IMAP4 server already returns a
34 proper body structure of the message.
36 Relevant body-info keys:
37 to/sender/from/cc/bcc/in-reply-to/reply-to - array of addr-dicts
38 type/subtype - message/RFC822
41 parameterList - dict (eg 'name')
46 bodyId - (empty string?)
47 description - (empty string?, content-description?)
49 body - a body structure?
52 hostName / mailboxName / personalName / sourceRoute
55 @class NGImap4Envelope;
57 @interface UIxMailPartMessageViewer : UIxMailPartViewer
59 NGImap4Envelope *envelope;
64 @implementation UIxMailPartMessageViewer
72 /* cache maintenance */
74 - (void) resetBodyInfoCaches
76 [super resetBodyInfoCaches];
77 [envelope release]; envelope = nil;
80 /* nested body structure */
84 return [[self bodyInfo] valueForKey:@"body"];
87 - (id) contentPartPath
90 Path processing is a bit weird in the context of message/rfc822. If we have
91 a multipart, the multipart itself has no own identifier! Instead the
92 children of the multipart are directly mapped into the message namespace.
94 If the message has just a plain content, ids seems to be as expected (that
100 mt = [[[self contentInfo] valueForKey:@"type"] lowercaseString];
101 if ([mt isEqualToString:@"multipart"])
102 return [self partPath];
104 pp = [self partPath];
105 return (([pp count] > 0)
106 ? [pp arrayByAddingObject: @"1"]
107 : [NSArray arrayWithObject: @"1"]);
110 - (id) contentViewerComponent
112 UIxMailRenderingContext *mailContext;
114 mailContext = [[self context] mailRenderingContext];
116 return [mailContext viewerForBodyInfo: [self contentInfo]];
119 /* generating envelope */
121 - (NGImap4Envelope *) envelope
124 envelope = [[NGImap4Envelope alloc] initWithBodyStructureInfo:
130 - (NSString *) formattedComponents: (NSArray *) components
132 NSMutableArray *formattedComponents;
133 unsigned int count, max;
136 max = [components count];
137 formattedComponents = [NSMutableArray arrayWithCapacity: max];
138 for (count = 0; count < max; count++)
140 component = [[components objectAtIndex: count] email];
141 [formattedComponents addObject: component];
144 return [formattedComponents componentsJoinedByString: @", "];
147 - (NSString *) fromAddresses
151 from = [[self envelope] from];
153 return [self formattedComponents: from];
156 - (NSString *) toAddresses
160 to = [[self envelope] to];
162 return [self formattedComponents: to];
165 - (NSString *) ccAddresses
169 cc = [[self envelope] cc];
171 return [self formattedComponents: cc];
174 /* links to recipients */
176 - (NSString *) linkToEnvelopeAddress: (NGImap4EnvelopeAddress *) _address
178 // TODO: make some web-link, eg open a new compose panel?
179 return [@"mailto:" stringByAppendingString:[_address baseEMail]];
182 @end /* UIxMailPartMessageViewer */