- (NSArray *)toEnvelopeAddresses;
- (NSArray *)ccEnvelopeAddresses;
+- (id)bodyStructure;
- (id)lookupInfoForBodyPart:(NSArray *)_path;
@end
2004-10-04 Helge Hess <helge.hess@opengroupware.org>
+ * added MIME content viewer infrastructure (v0.9.15)
+
* UIxMailView.m: added 'currentAddress' accessors (v0.9.14)
* UIxMailView.m: use core infos stored in message SoObject for display
UIxSubjectFormatter.m \
UIxEnvelopeAddressFormatter.m \
WOContext+UIxMailer.m \
+ UIxMailRenderingContext.m \
\
UIxMailMainFrame.m \
UIxMailTree.m \
UIxMailListView.m \
UIxMailView.m \
UIxMailEditor.m \
+ \
+ UIxMailPartViewer.m \
+ UIxMailPartTextViewer.m \
+ UIxMailPartImageViewer.m\
+ UIxMailPartMixedViewer.m
MailerUI_RESOURCE_FILES += \
Version \
UIxMailListView.wox \
UIxMailView.wox \
UIxMailEditor.wox \
+ \
+ UIxMailPartTextViewer.wox \
+ UIxMailPartMixedViewer.wox \
+ UIxMailPartImageViewer.wox \
MailerUI_RESOURCE_FILES += \
uix.css \
--- /dev/null
+/*
+ Copyright (C) 2004 SKYRIX Software AG
+
+ This file is part of OpenGroupware.org.
+
+ OGo is free software; you can redistribute it and/or modify it under
+ the terms of the GNU Lesser General Public License as published by the
+ Free Software Foundation; either version 2, or (at your option) any
+ later version.
+
+ OGo is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with OGo; see the file COPYING. If not, write to the
+ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA.
+*/
+
+#include "UIxMailPartViewer.h"
+
+@interface UIxMailPartImageViewer : UIxMailPartViewer
+{
+}
+
+@end
+
+#include "common.h"
+
+@implementation UIxMailPartImageViewer
+
+- (void)dealloc {
+ [super dealloc];
+}
+
+/* URLs */
+
+- (NSString *)pathToImage {
+ NSString *url;
+
+ url = [[self clientObject] baseURLInContext:[self context]];
+ if (![url hasSuffix:@"/"]) url = [url stringByAppendingString:@"/"];
+ return [url stringByAppendingString:
+ [[self partPath] componentsJoinedByString:@"/"]];
+}
+
+@end /* UIxMailPartImageViewer */
--- /dev/null
+<?xml version="1.0" standalone="yes"?>
+<img
+ xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:var="http://www.skyrix.com/od/binding"
+
+ var:src="pathToImage"
+ var:title="bodyInfo"
+ class="mailer_imagecontent"
+></img>
--- /dev/null
+/*
+ Copyright (C) 2004 SKYRIX Software AG
+
+ This file is part of OpenGroupware.org.
+
+ OGo is free software; you can redistribute it and/or modify it under
+ the terms of the GNU Lesser General Public License as published by the
+ Free Software Foundation; either version 2, or (at your option) any
+ later version.
+
+ OGo is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with OGo; see the file COPYING. If not, write to the
+ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA.
+*/
+
+#include "UIxMailPartViewer.h"
+
+@interface UIxMailPartMixedViewer : UIxMailPartViewer
+{
+ id childInfo;
+ unsigned int childIndex;
+}
+
+@end
+
+#include "UIxMailRenderingContext.h"
+#include "WOContext+UIxMailer.h"
+#include "common.h"
+
+@implementation UIxMailPartMixedViewer
+
+- (void)dealloc {
+ [self->childInfo release];
+ [super dealloc];
+}
+
+/* notifications */
+
+- (void)sleep {
+ [self->childInfo release]; self->childInfo = nil;
+ [super sleep];
+}
+
+/* accessors */
+
+- (void)setChildInfo:(id)_info {
+ ASSIGN(self->childInfo, _info);
+}
+- (id)childInfo {
+ return self->childInfo;
+}
+
+- (void)setChildIndex:(unsigned int)_index {
+ self->childIndex = _index;
+}
+- (unsigned int)childIndex {
+ return self->childIndex;
+}
+
+- (NSString *)childPartName {
+ unsigned char buf[8];
+ sprintf(buf, "%d", [self childIndex] + 1);
+ return [NSString stringWithCString:buf];
+}
+
+- (id)childPartPath {
+ NSArray *pp;
+
+ pp = [self partPath];
+ return [pp count] > 0
+ ? [pp arrayByAddingObject:[self childPartName]]
+ : [NSArray arrayWithObject:[self childPartName]];
+}
+
+/* nested viewers */
+
+- (id)contentViewerComponent {
+ id info;
+
+ info = [self childInfo];
+ return [[[self context] mailRenderingContext] viewerForBodyInfo:info];
+}
+
+@end /* UIxMailPartMixedViewer */
--- /dev/null
+<?xml version="1.0" standalone="yes"?>
+<div xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:var="http://www.skyrix.com/od/binding"
+ xmlns:const="http://www.skyrix.com/od/constant"
+ xmlns:rsrc="OGo:url"
+ xmlns:label="OGo:label"
+>
+ <div>
+ <var:foreach list="bodyInfo.parts" item="childInfo" index="childIndex">
+ <div>
+ <var:component value="contentViewerComponent"
+ bodyInfo="childInfo"
+ partPath="childPartPath" />
+ </div>
+ </var:foreach>
+ </div>
+</div>
--- /dev/null
+/*
+ Copyright (C) 2004 SKYRIX Software AG
+
+ This file is part of OpenGroupware.org.
+
+ OGo is free software; you can redistribute it and/or modify it under
+ the terms of the GNU Lesser General Public License as published by the
+ Free Software Foundation; either version 2, or (at your option) any
+ later version.
+
+ OGo is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with OGo; see the file COPYING. If not, write to the
+ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA.
+*/
+
+#include "UIxMailPartViewer.h"
+
+@interface UIxMailPartTextViewer : UIxMailPartViewer
+{
+}
+
+@end
+
+#include "common.h"
+
+@implementation UIxMailPartTextViewer
+
+- (void)dealloc {
+ [super dealloc];
+}
+
+@end /* UIxMailPartTextViewer */
--- /dev/null
+<?xml version="1.0" standalone="yes"?>
+<pre
+ xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:var="http://www.skyrix.com/od/binding"
+ xmlns:const="http://www.skyrix.com/od/constant"
+ xmlns:rsrc="OGo:url"
+ xmlns:label="OGo:label"
+ class="mailer_plaincontent"
+>
+ text
+</pre>
--- /dev/null
+/*
+ Copyright (C) 2004 SKYRIX Software AG
+
+ This file is part of OpenGroupware.org.
+
+ OGo is free software; you can redistribute it and/or modify it under
+ the terms of the GNU Lesser General Public License as published by the
+ Free Software Foundation; either version 2, or (at your option) any
+ later version.
+
+ OGo is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with OGo; see the file COPYING. If not, write to the
+ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA.
+*/
+
+#ifndef __Mailer_UIxMailPartViewer_H__
+#define __Mailer_UIxMailPartViewer_H__
+
+#include <SOGoUI/UIxComponent.h>
+
+/*
+ UIxMailPartViewer
+
+ This class is the superclass for MIME content viewers.
+*/
+
+@class NSArray;
+
+@interface UIxMailPartViewer : UIxComponent
+{
+ NSArray *partPath;
+ id bodyInfo;
+}
+
+/* accessors */
+
+- (void)setPartPath:(NSArray *)_path;
+- (NSArray *)partPath;
+
+- (void)setBodyInfo:(id)_info;
+- (id)bodyInfo;
+
+@end
+
+#endif /* __Mailer_UIxMailPartViewer_H__ */
--- /dev/null
+/*
+ Copyright (C) 2004 SKYRIX Software AG
+
+ This file is part of OpenGroupware.org.
+
+ OGo is free software; you can redistribute it and/or modify it under
+ the terms of the GNU Lesser General Public License as published by the
+ Free Software Foundation; either version 2, or (at your option) any
+ later version.
+
+ OGo is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with OGo; see the file COPYING. If not, write to the
+ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA.
+*/
+
+#include "UIxMailPartViewer.h"
+#include "common.h"
+
+@implementation UIxMailPartViewer
+
+- (void)dealloc {
+ [self->bodyInfo release];
+ [self->partPath release];
+ [super dealloc];
+}
+
+/* accessors */
+
+- (void)setPartPath:(NSArray *)_path {
+ ASSIGN(self->partPath, _path);
+}
+- (NSArray *)partPath {
+ return self->partPath;
+}
+
+- (void)setBodyInfo:(id)_info {
+ ASSIGN(self->bodyInfo, _info);
+}
+- (id)bodyInfo {
+ return self->bodyInfo;
+}
+
+@end /* UIxMailPartViewer */
--- /dev/null
+/*
+ Copyright (C) 2004 SKYRIX Software AG
+
+ This file is part of OpenGroupware.org.
+
+ OGo is free software; you can redistribute it and/or modify it under
+ the terms of the GNU Lesser General Public License as published by the
+ Free Software Foundation; either version 2, or (at your option) any
+ later version.
+
+ OGo is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with OGo; see the file COPYING. If not, write to the
+ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA.
+*/
+
+#ifndef __Mailer_UIxMailRenderingContext_H__
+#define __Mailer_UIxMailRenderingContext_H__
+
+#import <Foundation/NSObject.h>
+
+/*
+ UIxMailRenderingContext
+
+ The rendering context is used to track nesting of mail part viewers.
+*/
+
+@class WOContext, WOComponent;
+
+@interface UIxMailRenderingContext : NSObject
+{
+ WOComponent *viewer; /* non-retained! */
+ WOContext *context; /* non-retained! */
+
+ WOComponent *mixedViewer;
+ WOComponent *textViewer;
+ WOComponent *imageViewer;
+}
+
+- (id)initWithViewer:(WOComponent *)_viewer context:(WOContext *)_ctx;
+
+/* state */
+
+- (void)reset;
+
+/* viewer components */
+
+- (WOComponent *)viewerForBodyInfo:(id)_info;
+
+@end
+
+#endif /* __Mailer_UIxMailRenderingContext_H__ */
--- /dev/null
+/*
+ Copyright (C) 2004 SKYRIX Software AG
+
+ This file is part of OpenGroupware.org.
+
+ OGo is free software; you can redistribute it and/or modify it under
+ the terms of the GNU Lesser General Public License as published by the
+ Free Software Foundation; either version 2, or (at your option) any
+ later version.
+
+ OGo is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with OGo; see the file COPYING. If not, write to the
+ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA.
+*/
+
+#include "UIxMailRenderingContext.h"
+#include "common.h"
+
+@implementation UIxMailRenderingContext
+
+- (id)initWithViewer:(WOComponent *)_viewer context:(WOContext *)_ctx {
+ if ((self = [super init])) {
+ self->viewer = _viewer;
+ self->context = _ctx;
+ }
+ return self;
+}
+- (id)init {
+ return [self initWithViewer:nil context:nil];
+}
+
+- (void)dealloc {
+ [self->mixedViewer release];
+ [self->textViewer release];
+ [self->imageViewer release];
+ [super dealloc];
+}
+
+/* resetting state */
+
+- (void)reset {
+ [self->mixedViewer release]; self->mixedViewer = nil;
+ [self->textViewer release]; self->textViewer = nil;
+ [self->imageViewer release]; self->imageViewer = nil;
+}
+
+/* viewer components */
+
+- (WOComponent *)mixedViewer {
+ if (self->mixedViewer == nil) {
+ self->mixedViewer =
+ [[self->viewer pageWithName:@"UIxMailPartMixedViewer"] retain];
+ }
+ return self->mixedViewer;
+}
+
+- (WOComponent *)textViewer {
+ if (self->textViewer == nil) {
+ self->textViewer =
+ [[self->viewer pageWithName:@"UIxMailPartTextViewer"] retain];
+ }
+ return self->textViewer;
+}
+
+- (WOComponent *)imageViewer {
+ if (self->imageViewer == nil) {
+ self->imageViewer =
+ [[self->viewer pageWithName:@"UIxMailPartImageViewer"] retain];
+ }
+ return self->imageViewer;
+}
+
+- (WOComponent *)viewerForBodyInfo:(id)_info {
+ NSString *mt, *st;
+
+ mt = [[_info valueForKey:@"type"] lowercaseString];
+ st = [[_info valueForKey:@"subtype"] lowercaseString];
+
+ if ([mt isEqualToString:@"multipart"]) {
+ if ([st isEqualToString:@"mixed"])
+ return [self mixedViewer];
+ }
+ else if ([mt isEqualToString:@"text"]) {
+ if ([st isEqualToString:@"plain"])
+ return [self textViewer];
+ }
+ else if ([mt isEqualToString:@"image"])
+ return [self imageViewer];
+
+ [self logWithFormat:@"ERROR: found no viewer for MIME type: %@/%@", mt, st];
+ return nil;
+}
+
+@end /* UIxMailRenderingContext */
@end
+#include "UIxMailRenderingContext.h"
+#include "WOContext+UIxMailer.h"
#include <SoObjects/Mailer/SOGoMailObject.h>
#include <NGImap4/NGImap4Envelope.h>
#include "common.h"
return [[self clientObject] fetchCoreInfos];
}
-/* derived accessors */
-
- (BOOL)hasCC {
return [[[self clientObject] ccEnvelopeAddresses] count] > 0 ? YES : NO;
}
+/* process body structure */
+
+- (BOOL)shouldFetchPartOfType:(NSString *)_type subtype:(NSString *)_subtype {
+ _type = [_type lowercaseString];
+ _subtype = [_subtype lowercaseString];
+
+ if ([_type isEqualToString:@"text"])
+ return [_subtype isEqualToString:@"plain"];
+ return NO;
+}
+
+- (void)addRequiredKeysOfStructure:(id)_info path:(NSString *)_p
+ toArray:(NSMutableArray *)_keys
+{
+ NSArray *parts;
+ unsigned i, count;
+ BOOL fetchPart;
+
+ fetchPart = [self shouldFetchPartOfType:[_info valueForKey:@"type"]
+ subtype:[_info valueForKey:@"subtype"]];
+ if (fetchPart) {
+ NSString *k;
+
+ k = [[@"body[" stringByAppendingString:_p] stringByAppendingString:@"]"];
+ [_keys addObject:k];
+ }
+
+ /* recurse */
+
+ parts = [_info objectForKey:@"parts"];
+ for (i = 0, count = [parts count]; i < count; i++) {
+ NSString *sp;
+ id childInfo;
+
+ sp = [_p length] > 0
+ ? [_p stringByAppendingFormat:@".%d", i + 1]
+ : [NSString stringWithFormat:@"%d", i + 1];
+
+ childInfo = [parts objectAtIndex:i];
+
+ [self addRequiredKeysOfStructure:childInfo path:sp toArray:_keys];
+ }
+}
+
+- (NSArray *)contentFetchKeys {
+ NSMutableArray *ma;
+
+ ma = [NSMutableArray arrayWithCapacity:4];
+ [self addRequiredKeysOfStructure:[[self clientObject] bodyStructure]
+ path:@"" toArray:ma];
+ return ma;
+}
+
+/* viewers */
+
+- (id)contentViewerComponent {
+ id info;
+
+ info = [[self clientObject] bodyStructure];
+ return [[[self context] mailRenderingContext] viewerForBodyInfo:info];
+}
+
/* actions */
- (id)defaultAction {
return [NSException exceptionWithHTTPStatus:404 /* Not Found */
reason:@"did not find specified message!"];
}
+ [self logWithFormat:@"FETCH BODY PARTS: %@", [self contentFetchKeys]];
return self;
}
return [self redirectToLocation:@"view"];
}
+/* generating response */
+
+- (void)appendToResponse:(WOResponse *)_response inContext:(WOContext *)_ctx {
+ UIxMailRenderingContext *mctx;
+
+ mctx = [[UIxMailRenderingContext alloc] initWithViewer:self context:_ctx];
+ [_ctx pushMailRenderingContext:mctx];
+ [mctx release];
+
+ [super appendToResponse:_response inContext:_ctx];
+
+ [[_ctx popMailRenderingContext] reset];
+}
+
@end /* UIxMailView */
<td class="mailer_fieldvalue">
<var:string value="clientObject.date"
formatter="context.mailDateFormatter"/>
+
+ <!-- TODO: -->
+ (<a rsrc:href="tbird_073_viewer.png">screenshot</a>)
</td>
</tr>
</table>
<div class="mailer_mailcontent">
+ <var:component value="contentViewerComponent"
+ bodyInfo="clientObject.bodyStructure" />
+ </div>
+
<!--
- <pre><var:string value="message" /></pre><br />
+ <pre><var:string value="message" /></pre><br />
+ <pre><var:string value="message.body" /></pre><br />
-->
- <pre><var:string value="message.body" /></pre><br />
-
- <a rsrc:href="tbird_073_viewer.png">screenshot</a>
- </div>
</var:component>
# $Id$
-SUBMINOR_VERSION:=14
+SUBMINOR_VERSION:=15
*/
@class NSFormatter;
+@class UIxMailRenderingContext;
@interface WOContext(UIxMailer)
- (NSFormatter *)mailEnvelopeAddressFormatter;
- (NSFormatter *)mailEnvelopeFullAddressFormatter;
+- (void)pushMailRenderingContext:(UIxMailRenderingContext *)_mctx;
+- (UIxMailRenderingContext *)popMailRenderingContext;
+- (UIxMailRenderingContext *)mailRenderingContext;
+
@end
#endif /* __Mailer_WOContext_UIxMailer_H__ */
*/
#include "WOContext+UIxMailer.h"
+#include "UIxMailRenderingContext.h"
#include "UIxMailFormatter.h"
#include "common.h"
initWithMaxLength:256 generateFullEMail:YES] autorelease];
}
+/* mail rendering */
+
+static NSString *MRK = @"UIxMailRenderingContext";
+
+- (void)pushMailRenderingContext:(UIxMailRenderingContext *)_mctx {
+ [self setObject:_mctx forKey:MRK];
+}
+- (UIxMailRenderingContext *)popMailRenderingContext {
+ UIxMailRenderingContext *mctx;
+
+ if ((mctx = [self objectForKey:MRK]) == nil)
+ return nil;
+
+ mctx = [[mctx retain] autorelease];
+ [self removeObjectForKey:MRK];
+ return mctx;
+}
+- (UIxMailRenderingContext *)mailRenderingContext {
+ return [self objectForKey:MRK];
+}
+
@end /* WOContext(UIxMailer) */
background-color: white;
padding: 8px;
}
+
+img.mailer_imagecontent {
+ border: 0px;
+}
+pre.mailer_plaincontent {
+}