2006-06-15 21:34:10 +02:00
|
|
|
/*
|
|
|
|
Copyright (C) 2004-2005 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
|
2007-07-27 21:59:46 +02:00
|
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
2006-06-15 21:34:10 +02:00
|
|
|
License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
2007-07-27 21:59:46 +02:00
|
|
|
License along with OGo; see the file COPYING. If not, write to the
|
2006-06-15 21:34:10 +02:00
|
|
|
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
|
|
|
02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2007-07-27 21:59:46 +02:00
|
|
|
#import <NGImap4/NGImap4Envelope.h>
|
|
|
|
#import <NGImap4/NGImap4EnvelopeAddress.h>
|
|
|
|
|
2008-08-22 15:52:24 +02:00
|
|
|
#import <NGExtensions/NSString+Encoding.h>
|
|
|
|
|
2007-11-05 17:37:17 +01:00
|
|
|
#import <SoObjects/Mailer/NSData+Mail.h>
|
|
|
|
#import <SoObjects/Mailer/NSString+Mail.h>
|
|
|
|
|
2007-07-27 21:59:46 +02:00
|
|
|
#import <UI/MailerUI/WOContext+UIxMailer.h>
|
|
|
|
#import "UIxMailRenderingContext.h"
|
|
|
|
|
|
|
|
#import "UIxMailPartViewer.h"
|
2006-06-15 21:34:10 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
UIxMailPartMessageViewer
|
|
|
|
|
2007-07-27 21:59:46 +02:00
|
|
|
Show message/rfc822 mail parts. Note that the IMAP4 server already returns a
|
|
|
|
proper body structure of the message.
|
|
|
|
|
|
|
|
Relevant body-info keys:
|
|
|
|
to/sender/from/cc/bcc/in-reply-to/reply-to - array of addr-dicts
|
|
|
|
type/subtype - message/RFC822
|
|
|
|
size
|
|
|
|
subject
|
|
|
|
parameterList - dict (eg 'name')
|
|
|
|
messageId
|
|
|
|
date
|
|
|
|
encoding - 7BIT
|
|
|
|
bodyLines - 83
|
|
|
|
bodyId - (empty string?)
|
|
|
|
description - (empty string?, content-description?)
|
|
|
|
|
|
|
|
body - a body structure?
|
|
|
|
|
|
|
|
Addr-Dict:
|
|
|
|
hostName / mailboxName / personalName / sourceRoute
|
2006-06-15 21:34:10 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
@class NGImap4Envelope;
|
|
|
|
|
|
|
|
@interface UIxMailPartMessageViewer : UIxMailPartViewer
|
|
|
|
{
|
|
|
|
NGImap4Envelope *envelope;
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation UIxMailPartMessageViewer
|
|
|
|
|
2007-07-27 21:59:46 +02:00
|
|
|
- (void) dealloc
|
|
|
|
{
|
|
|
|
[envelope release];
|
2006-06-15 21:34:10 +02:00
|
|
|
[super dealloc];
|
|
|
|
}
|
|
|
|
|
|
|
|
/* cache maintenance */
|
|
|
|
|
2007-07-27 21:59:46 +02:00
|
|
|
- (void) resetBodyInfoCaches
|
|
|
|
{
|
2006-06-15 21:34:10 +02:00
|
|
|
[super resetBodyInfoCaches];
|
2007-07-27 21:59:46 +02:00
|
|
|
[envelope release]; envelope = nil;
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* nested body structure */
|
|
|
|
|
2007-07-27 21:59:46 +02:00
|
|
|
- (id) contentInfo
|
|
|
|
{
|
2006-06-15 21:34:10 +02:00
|
|
|
return [[self bodyInfo] valueForKey:@"body"];
|
|
|
|
}
|
|
|
|
|
2007-07-27 21:59:46 +02:00
|
|
|
- (id) contentPartPath
|
|
|
|
{
|
2006-06-15 21:34:10 +02:00
|
|
|
/*
|
|
|
|
Path processing is a bit weird in the context of message/rfc822. If we have
|
|
|
|
a multipart, the multipart itself has no own identifier! Instead the
|
|
|
|
children of the multipart are directly mapped into the message namespace.
|
2007-07-27 21:59:46 +02:00
|
|
|
|
2006-06-15 21:34:10 +02:00
|
|
|
If the message has just a plain content, ids seems to be as expected (that
|
|
|
|
is, its just a "1").
|
|
|
|
*/
|
2007-07-27 21:59:46 +02:00
|
|
|
NSArray *pp;
|
2006-06-15 21:34:10 +02:00
|
|
|
NSString *mt;
|
2007-07-27 21:59:46 +02:00
|
|
|
|
2006-06-15 21:34:10 +02:00
|
|
|
mt = [[[self contentInfo] valueForKey:@"type"] lowercaseString];
|
|
|
|
if ([mt isEqualToString:@"multipart"])
|
|
|
|
return [self partPath];
|
2007-07-27 21:59:46 +02:00
|
|
|
|
2006-06-15 21:34:10 +02:00
|
|
|
pp = [self partPath];
|
2007-07-27 21:59:46 +02:00
|
|
|
return (([pp count] > 0)
|
|
|
|
? [pp arrayByAddingObject: @"1"]
|
|
|
|
: [NSArray arrayWithObject: @"1"]);
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
|
|
|
|
2007-07-27 21:59:46 +02:00
|
|
|
- (id) contentViewerComponent
|
|
|
|
{
|
|
|
|
UIxMailRenderingContext *mailContext;
|
|
|
|
|
|
|
|
mailContext = [[self context] mailRenderingContext];
|
|
|
|
|
|
|
|
return [mailContext viewerForBodyInfo: [self contentInfo]];
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* generating envelope */
|
|
|
|
|
2007-07-27 21:59:46 +02:00
|
|
|
- (NGImap4Envelope *) envelope
|
|
|
|
{
|
|
|
|
if (!envelope)
|
|
|
|
envelope = [[NGImap4Envelope alloc] initWithBodyStructureInfo:
|
|
|
|
[self bodyInfo]];
|
|
|
|
|
|
|
|
return envelope;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) formattedComponents: (NSArray *) components
|
|
|
|
{
|
|
|
|
NSMutableArray *formattedComponents;
|
|
|
|
unsigned int count, max;
|
|
|
|
NSString *component;
|
|
|
|
|
|
|
|
max = [components count];
|
|
|
|
formattedComponents = [NSMutableArray arrayWithCapacity: max];
|
|
|
|
for (count = 0; count < max; count++)
|
|
|
|
{
|
|
|
|
component = [[components objectAtIndex: count] email];
|
2008-08-18 17:23:30 +02:00
|
|
|
if (component)
|
|
|
|
[formattedComponents addObject: component];
|
2007-07-27 21:59:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return [formattedComponents componentsJoinedByString: @", "];
|
|
|
|
}
|
|
|
|
|
2007-11-05 17:37:17 +01:00
|
|
|
- (NSString *) messageSubject
|
|
|
|
{
|
|
|
|
id baseSubject;
|
|
|
|
NSString *subject;
|
|
|
|
|
|
|
|
baseSubject = [[self envelope] subject];
|
2008-08-22 15:52:24 +02:00
|
|
|
|
|
|
|
// We avoid uber-lamenesses in SOPE - see sope-core/NGExtensions/NGQuotedPrintableCoding.m
|
|
|
|
// -stringByDecodingQuotedPrintable for all details
|
|
|
|
if ([baseSubject isKindOfClass: [NSString class]])
|
|
|
|
baseSubject = [baseSubject dataUsingEncoding: NSASCIIStringEncoding];
|
2007-11-05 17:37:17 +01:00
|
|
|
subject = [baseSubject decodedSubject];
|
2008-08-22 15:52:24 +02:00
|
|
|
|
2007-11-05 17:37:17 +01:00
|
|
|
if (![subject length])
|
|
|
|
subject = [self labelForKey: @"Untitled"];
|
|
|
|
|
|
|
|
return subject;
|
|
|
|
}
|
|
|
|
|
2007-07-27 21:59:46 +02:00
|
|
|
- (NSString *) fromAddresses
|
|
|
|
{
|
|
|
|
NSArray *from;
|
|
|
|
|
|
|
|
from = [[self envelope] from];
|
|
|
|
|
|
|
|
return [self formattedComponents: from];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) toAddresses
|
|
|
|
{
|
|
|
|
NSArray *to;
|
|
|
|
|
|
|
|
to = [[self envelope] to];
|
|
|
|
|
|
|
|
return [self formattedComponents: to];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) ccAddresses
|
|
|
|
{
|
|
|
|
NSArray *cc;
|
|
|
|
|
|
|
|
cc = [[self envelope] cc];
|
|
|
|
|
|
|
|
return [self formattedComponents: cc];
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* links to recipients */
|
|
|
|
|
2007-07-27 21:59:46 +02:00
|
|
|
- (NSString *) linkToEnvelopeAddress: (NGImap4EnvelopeAddress *) _address
|
|
|
|
{
|
2006-06-15 21:34:10 +02:00
|
|
|
// TODO: make some web-link, eg open a new compose panel?
|
|
|
|
return [@"mailto:" stringByAppendingString:[_address baseEMail]];
|
|
|
|
}
|
|
|
|
|
|
|
|
@end /* UIxMailPartMessageViewer */
|