mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-08-02 21:52:19 +00:00
Monotone-Parent: 2783c3f8316773bc75dad5afe9cf58e43b8a0f9f
Monotone-Revision: 138d10664c297f2945644209ec2c4b488844af1b Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2007-12-12T23:59:36 Monotone-Branch: ca.inverse.sogo
This commit is contained in:
@@ -1,3 +1,20 @@
|
||||
2007-12-12 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
|
||||
* SoObjects/Mailer/SOGoMailObject.m ([SOGoMailObject
|
||||
-fetchAttachmentIds]): new method that wanders through the mail
|
||||
structure to collect the attachment content ids and to associate
|
||||
them with their url.
|
||||
|
||||
* UI/MailPartViewers/UIxMailPartHTMLViewer.m
|
||||
([_UIxHTMLMailContentHandler
|
||||
-startElement:_localNamenamespace:_nsrawName:_rawNameattributes:_attributes]):
|
||||
the content-ids are now enclosed between "<>" before retrieval
|
||||
from the attachment dictionary.
|
||||
([UIxMailPartHTMLViewer -cssContent])
|
||||
([UIxMailPartHTMLViewer -flatContentAsString]): the content-ids
|
||||
are now fetch from the clientobject (an instance of
|
||||
SOGoMailObject) with the new "fetchAttachmentIds" method.
|
||||
|
||||
2007-12-12 Francis Lachapelle <flachapelle@inverse.ca>
|
||||
|
||||
* UI/Scheduler/UIxCalListingActions.m ([UIxCalListingActions
|
||||
|
||||
@@ -89,6 +89,8 @@
|
||||
- (NSDictionary *) fetchPlainTextParts;
|
||||
- (NSDictionary *) fetchPlainTextStrings:(NSArray *)_fetchKeys;
|
||||
|
||||
- (NSDictionary *) fetchAttachmentIds;
|
||||
|
||||
/* flags */
|
||||
|
||||
- (NSException *) addFlags:(id)_f;
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#import <Foundation/NSDictionary.h>
|
||||
#import <Foundation/NSEnumerator.h>
|
||||
#import <Foundation/NSString.h>
|
||||
#import <Foundation/NSURL.h>
|
||||
#import <Foundation/NSUserDefaults.h>
|
||||
#import <Foundation/NSValue.h>
|
||||
|
||||
@@ -644,6 +645,72 @@ static BOOL debugSoParts = NO;
|
||||
return [self fetchPlainTextParts: [self plainTextContentFetchKeys]];
|
||||
}
|
||||
|
||||
- (NSString *) _urlToPart: (NSDictionary *) infos
|
||||
withPrefix: (NSString *) urlPrefix
|
||||
{
|
||||
NSDictionary *parameters;
|
||||
NSString *urlToPart, *filename;
|
||||
|
||||
parameters = [infos objectForKey: @"parameterList"];
|
||||
filename = [parameters objectForKey: @"name"];
|
||||
if (!filename)
|
||||
{
|
||||
parameters = [[infos objectForKey: @"disposition"]
|
||||
objectForKey: @"parameterList"];
|
||||
filename = [parameters objectForKey: @"filename"];
|
||||
}
|
||||
|
||||
if ([filename length])
|
||||
urlToPart = [NSString stringWithFormat: @"%@/%@", urlPrefix, filename];
|
||||
else
|
||||
urlToPart = nil;
|
||||
|
||||
return urlToPart;
|
||||
}
|
||||
|
||||
- (void) _feedAttachmentIds: (NSMutableDictionary *) attachmentIds
|
||||
withInfos: (NSDictionary *) infos
|
||||
andPrefix: (NSString *) prefix
|
||||
{
|
||||
NSArray *parts;
|
||||
NSDictionary *currentPart;
|
||||
unsigned int count, max;
|
||||
NSString *url, *cid;
|
||||
|
||||
cid = [infos objectForKey: @"bodyId"];
|
||||
if ([cid length])
|
||||
{
|
||||
url = [self _urlToPart: infos withPrefix: prefix];
|
||||
if (url)
|
||||
[attachmentIds setObject: url forKey: cid];
|
||||
}
|
||||
|
||||
parts = [infos objectForKey: @"parts"];
|
||||
max = [parts count];
|
||||
for (count = 0; count < max; count++)
|
||||
{
|
||||
currentPart = [parts objectAtIndex: count];
|
||||
[self _feedAttachmentIds: attachmentIds
|
||||
withInfos: currentPart
|
||||
andPrefix: [NSString stringWithFormat: @"%@/%d",
|
||||
prefix, count + 1]];
|
||||
}
|
||||
}
|
||||
|
||||
- (NSDictionary *) fetchAttachmentIds
|
||||
{
|
||||
NSMutableDictionary *attachmentIds;
|
||||
|
||||
attachmentIds = [NSMutableDictionary dictionary];
|
||||
|
||||
[self fetchCoreInfos];
|
||||
[self _feedAttachmentIds: attachmentIds
|
||||
withInfos: [coreInfos objectForKey: @"body"]
|
||||
andPrefix: [[self soURL] absoluteString]];
|
||||
|
||||
return attachmentIds;
|
||||
}
|
||||
|
||||
/* convert parts to strings */
|
||||
- (NSString *) stringForData: (NSData *) _data
|
||||
partInfo: (NSDictionary *) _info
|
||||
|
||||
@@ -35,6 +35,8 @@
|
||||
|
||||
#include <libxml/encoding.h>
|
||||
|
||||
#import <SoObjects/Mailer/SOGoMailObject.h>
|
||||
|
||||
#import "UIxMailPartHTMLViewer.h"
|
||||
|
||||
#if 0
|
||||
@@ -207,7 +209,7 @@
|
||||
attributes: (id <SaxAttributes>) _attributes
|
||||
{
|
||||
unsigned int count, max;
|
||||
NSString *name, *value;
|
||||
NSString *name, *value, *cid;
|
||||
NSMutableString *resultPart;
|
||||
BOOL skipAttribute;
|
||||
|
||||
@@ -237,8 +239,9 @@
|
||||
value = [_attributes valueAtIndex: count];
|
||||
if ([value hasPrefix: @"cid:"])
|
||||
{
|
||||
value = [attachmentIds
|
||||
objectForKey: [value substringFromIndex: 4]];
|
||||
cid = [NSString stringWithFormat: @"<%@>",
|
||||
[value substringFromIndex: 4]];
|
||||
value = [attachmentIds objectForKey: cid];
|
||||
skipAttribute = (value == nil);
|
||||
}
|
||||
else
|
||||
@@ -433,68 +436,6 @@
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void) _convertReferencesForPart: (NSDictionary *) part
|
||||
withCount: (unsigned int) count
|
||||
andBaseURL: (NSString *) url
|
||||
intoDictionary: (NSMutableDictionary *) attachmentIds
|
||||
{
|
||||
NSString *bodyId, *filename;
|
||||
NSMutableString *attachmentURL;
|
||||
|
||||
bodyId = [part objectForKey: @"bodyId"];
|
||||
if ([bodyId length] > 0)
|
||||
{
|
||||
filename = [[part objectForKey: @"parameterList"] objectForKey: @"name"];
|
||||
if (!filename)
|
||||
filename = [[[part objectForKey: @"disposition"]
|
||||
objectForKey: @"parameterList"]
|
||||
objectForKey: @"filename"];
|
||||
if ([bodyId hasPrefix: @"<"])
|
||||
bodyId = [bodyId substringFromIndex: 1];
|
||||
if ([bodyId hasSuffix: @">"])
|
||||
bodyId = [bodyId substringToIndex: [bodyId length] - 1];
|
||||
attachmentURL = [NSMutableString stringWithString: url];
|
||||
[attachmentURL appendFormat: @"/%d", count];
|
||||
if ([filename length])
|
||||
[attachmentURL appendFormat: @"/%@", filename];
|
||||
[attachmentIds setObject: attachmentURL forKey: bodyId];
|
||||
}
|
||||
}
|
||||
|
||||
- (NSDictionary *) _attachmentIds
|
||||
{
|
||||
NSMutableDictionary *attachmentIds;
|
||||
UIxMailPartViewer *parent;
|
||||
unsigned int count, max;
|
||||
// NSMutableString *url;
|
||||
NSString *baseURL;
|
||||
NSArray *parts;
|
||||
|
||||
attachmentIds = [NSMutableDictionary new];
|
||||
[attachmentIds autorelease];
|
||||
|
||||
parent = [self parent];
|
||||
if ([NSStringFromClass ([parent class])
|
||||
isEqualToString: @"UIxMailPartAlternativeViewer"])
|
||||
{
|
||||
baseURL = [[self clientObject] baseURLInContext: context];
|
||||
// url = [NSMutableString new];
|
||||
// [url appendString: baseURL];
|
||||
// [url appendFormat: @"/%@", [partPath componentsJoinedByString: @"/"]];
|
||||
// [url deleteCharactersInRange: NSMakeRange([url length] - 4, 4)];
|
||||
parts = [[[parent parent] bodyInfo] objectForKey: @"parts"];
|
||||
max = [parts count];
|
||||
for (count = 0; count < max; count++)
|
||||
[self _convertReferencesForPart: [parts objectAtIndex: count]
|
||||
withCount: count + 1
|
||||
andBaseURL: baseURL
|
||||
intoDictionary: attachmentIds];
|
||||
// [url release];
|
||||
}
|
||||
|
||||
return attachmentIds;
|
||||
}
|
||||
|
||||
- (xmlCharEncoding) _xmlCharsetForCharset: (NSString *) charset
|
||||
{
|
||||
struct { NSString *name; xmlCharEncoding encoding; } xmlEncodings[] = {
|
||||
@@ -557,13 +498,16 @@
|
||||
{
|
||||
NSObject <SaxXMLReader> *parser;
|
||||
NSData *preparsedContent;
|
||||
SOGoMailObject *mail;
|
||||
|
||||
mail = [self clientObject];
|
||||
|
||||
preparsedContent = [super decodedFlatContent];
|
||||
parser = [[SaxXMLReaderFactory standardXMLReaderFactory]
|
||||
createXMLReaderForMimeType: @"text/html"];
|
||||
|
||||
handler = [_UIxHTMLMailContentHandler new];
|
||||
[handler setAttachmentIds: [self _attachmentIds]];
|
||||
[handler setAttachmentIds: [mail fetchAttachmentIds]];
|
||||
[handler setContentEncoding: [self _xmlCharEncoding]];
|
||||
[parser setContentHandler: handler];
|
||||
[parser parseFromSource: preparsedContent];
|
||||
|
||||
Reference in New Issue
Block a user