Monotone-Parent: c9dd4206ad3d7a913acb09680d854a19153d46a7

Monotone-Revision: e8bfb90da0079ca2c3e5079818a7e7532b26ea31

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2007-07-27T19:59:46
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Wolfgang Sourdeau
2007-07-27 19:59:46 +00:00
parent a450325cb7
commit 55bd55f9ae
3 changed files with 144 additions and 150 deletions
+5
View File
@@ -1,5 +1,10 @@
2007-07-27 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* UI/MailPartViewers/UIxMailPartMessageViewer.m ([UIxMailPartMessageViewer -fromAddresses])
([UIxMailPartMessageViewer -toAddresses])
([UIxMailPartMessageViewer -ccAddresses]): new methods returning
the corresponding fields separated with a ", " (if needed).
* SoObjects/Mailer/SOGoDraftObject.m ([SOGoDraftObject
-saveAttachment:_attachwithMetadata:metadata]): new method
replacing -saveAttachment:withName: and which takes a dictionary
+105 -76
View File
@@ -10,40 +10,46 @@
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
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
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"
#import <NGImap4/NGImap4Envelope.h>
#import <NGImap4/NGImap4EnvelopeAddress.h>
#import <UI/MailerUI/WOContext+UIxMailer.h>
#import "UIxMailRenderingContext.h"
#import "UIxMailPartViewer.h"
/*
UIxMailPartMessageViewer
Show message/rfc822 mail parts. Note that the IMAP4 server already returns a
proper body structure of the message.
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
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
*/
@class NGImap4Envelope;
@@ -51,103 +57,126 @@
@interface UIxMailPartMessageViewer : UIxMailPartViewer
{
NGImap4Envelope *envelope;
id currentAddress;
}
@end
#include <UI/MailerUI/WOContext+UIxMailer.h>
#include "UIxMailRenderingContext.h"
#include <NGImap4/NGImap4Envelope.h>
#include <NGImap4/NGImap4EnvelopeAddress.h>
#include "common.h"
@implementation UIxMailPartMessageViewer
- (void)dealloc {
[self->currentAddress release];
[self->envelope release];
- (void) dealloc
{
[envelope release];
[super dealloc];
}
/* cache maintenance */
- (void)resetBodyInfoCaches {
- (void) resetBodyInfoCaches
{
[super resetBodyInfoCaches];
[self->envelope release]; self->envelope = nil;
[self->currentAddress release]; self->currentAddress = nil;
}
/* notifications */
- (void)sleep {
[self->currentAddress release]; self->currentAddress = nil;
[super sleep];
}
/* accessors */
- (void)setCurrentAddress:(id)_addr {
ASSIGN(self->currentAddress, _addr);
}
- (id)currentAddress {
return self->currentAddress;
[envelope release]; envelope = nil;
}
/* nested body structure */
- (id)contentInfo {
- (id) contentInfo
{
return [[self bodyInfo] valueForKey:@"body"];
}
- (id)contentPartPath {
- (id) contentPartPath
{
/*
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.
If the message has just a plain content, ids seems to be as expected (that
is, its just a "1").
*/
NSArray *pp;
NSArray *pp;
NSString *mt;
mt = [[[self contentInfo] valueForKey:@"type"] lowercaseString];
if ([mt isEqualToString:@"multipart"])
return [self partPath];
pp = [self partPath];
return [pp count] > 0
? [pp arrayByAddingObject:@"1"]
: [NSArray arrayWithObject:@"1"];
return (([pp count] > 0)
? [pp arrayByAddingObject: @"1"]
: [NSArray arrayWithObject: @"1"]);
}
- (id)contentViewerComponent {
id info;
info = [self contentInfo];
return [[[self context] mailRenderingContext] viewerForBodyInfo:info];
- (id) contentViewerComponent
{
UIxMailRenderingContext *mailContext;
mailContext = [[self context] mailRenderingContext];
return [mailContext viewerForBodyInfo: [self contentInfo]];
}
/* generating envelope */
- (NGImap4Envelope *)envelope {
if (self->envelope == nil) {
self->envelope = [[NGImap4Envelope alloc] initWithBodyStructureInfo:
[self bodyInfo]];
}
return self->envelope;
- (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];
[formattedComponents addObject: component];
}
return [formattedComponents componentsJoinedByString: @", "];
}
- (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];
}
/* links to recipients */
- (NSString *)linkToEnvelopeAddress:(NGImap4EnvelopeAddress *)_address {
- (NSString *) linkToEnvelopeAddress: (NGImap4EnvelopeAddress *) _address
{
// TODO: make some web-link, eg open a new compose panel?
return [@"mailto:" stringByAppendingString:[_address baseEMail]];
}
- (NSString *)currentAddressLink {
return [self linkToEnvelopeAddress:[self currentAddress]];
}
@end /* UIxMailPartMessageViewer */
@@ -1,80 +1,40 @@
<?xml version="1.0" standalone="yes"?>
<!DOCTYPE div>
<div xmlns="http://www.w3.org/1999/xhtml"
xmlns:var="http://www.skyrix.com/od/binding"
xmlns:label="OGo:label"
class="linked_attachment_frame"
>
xmlns:var="http://www.skyrix.com/od/binding"
xmlns:label="OGo:label"
class="linked_attachment_frame">
<div class="linked_attachment_body">
<hr>
<!-- TODO: the table is a DUP to UIxMailView, own component? -->
<div class="bodyFields">
<span class="fieldName"><var:string label:value="Subject"/>:</span>
<var:string value="envelope.subject"
formatter="context.mailSubjectFormatter"/><br/>
<span class="fieldName"><var:string label:value="From"/>:</span>
<var:string value="fromAddresses"/><br/>
<span class="fieldName"><var:string label:value="Date"/>:</span>
<var:string value="envelope.date"
formatter="context.mailDateFormatter"/><br/>
<div class="bodyAdditionalFields">
<span class="fieldName"><var:string label:value="To"/>:</span>
<var:string value="toAddresses"/><br/>
<var:if condition="envelope.hasCC">
<span class="fieldName"><var:string label:value="CC"/>:</span>
<var:string value="ccAddresses"/>
</var:if>
</div>
</div>
<div class="bodyMailContent">
<var:component value="contentViewerComponent"
bodyInfo="contentInfo"
partPath="contentPartPath" />
</div>
<!-- TODO: the table is a DUP to UIxMailView, own component? -->
<table class="mailer_fieldtable">
<tr class="mailer_fieldrow">
<td class="mailer_fieldname" ><var:string label:value="Subject"/>:</td>
<td class="mailer_subjectfieldvalue">
<var:string value="envelope.subject"
formatter="context.mailSubjectFormatter"/>
<!--
<a var:href="pathToAttachment"
var:title="filenameForDisplay"
>(<var:string label:value="download" />)</a>
-->
</td>
</tr>
<tr class="mailer_fieldrow">
<td class="mailer_fieldname" ><var:string label:value="From"/>:</td>
<td class="mailer_fieldvalue">
<!-- compose link? -->
<var:foreach list="envelope.from" item="currentAddress">
<a var:href="currentAddressLink">
<var:string value="currentAddress"
formatter="context.mailEnvelopeFullAddressFormatter" /></a>
</var:foreach>
</td>
</tr>
<tr class="mailer_fieldrow">
<td class="mailer_fieldname" ><var:string label:value="Date"/>:</td>
<td class="mailer_fieldvalue">
<var:string value="envelope.date"
formatter="context.mailDateFormatter"/>
</td>
</tr>
<tr class="mailer_fieldrow">
<td class="mailer_fieldname" ><var:string label:value="To"/>:</td>
<td class="mailer_fieldvalue">
<!-- compose link? -->
<var:foreach list="envelope.to" item="currentAddress">
<a var:href="currentAddressLink">
<var:string value="currentAddress"
formatter="context.mailEnvelopeFullAddressFormatter" /></a>
</var:foreach>
</td>
</tr>
<var:if condition="envelope.hasCC">
<tr class="mailer_fieldrow">
<td class="mailer_fieldname" ><var:string label:value="CC"/>:</td>
<td class="mailer_fieldvalue">
<!-- compose link? -->
<var:foreach list="envelope.cc" item="currentAddress">
<a var:href="currentAddressLink">
<var:string value="currentAddress"
formatter="context.mailEnvelopeFullAddressFormatter" /></a>
<br /> <!-- TODO: better to use li+CSS -->
</var:foreach>
</td>
</tr>
</var:if>
</table>
<div class="mailer_mailcontent">
<var:component value="contentViewerComponent"
bodyInfo="contentInfo"
partPath="contentPartPath" />
</div>
<!-- debug
<pre><var:string value="envelope"/></pre>
<pre><var:string value="bodyInfo.body"/></pre>
-->
<!-- debug
<pre><var:string value="envelope"/></pre>
<pre><var:string value="bodyInfo.body"/></pre>
-->
</div>
</div>