merge of '566c52eecd68ab1a6fbb711a337a83289ec7b3b4'

and '917b856310d41617cad0757859d22615b99fed50'

Monotone-Parent: 566c52eecd68ab1a6fbb711a337a83289ec7b3b4
Monotone-Parent: 917b856310d41617cad0757859d22615b99fed50
Monotone-Revision: b5051834282e52ed3ada41a862242574f4f3016d

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2007-11-20T22:18:49
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Wolfgang Sourdeau committed 2007-11-20 22:18:49 +00:00
commit 6718be9192
4 files changed
+211 -219

No files matched your search

+1 -1
View File
@@ -40,7 +40,7 @@ MailPartViewers_LOCALIZED_RESOURCE_FILES += \
# make
ADDITIONAL_INCLUDE_DIRS += -I../../SOPE/
ADDITIONAL_INCLUDE_DIRS += $(shell xml2-config --cflags)
ADDITIONAL_LIB_DIRS += -L../../SOPE/GDLContentStore/obj/
-include GNUmakefile.preamble
+80 -1
View File
@@ -22,6 +22,9 @@
#import <Foundation/NSArray.h>
#import <Foundation/NSDictionary.h>
#import <Foundation/NSKeyValueCoding.h>
#import <Foundation/NSValue.h>
#import <SaxObjC/SaxAttributes.h>
#import <SaxObjC/SaxContentHandler.h>
#import <SaxObjC/SaxLexicalHandler.h>
@@ -30,6 +33,8 @@
#import <NGExtensions/NSString+misc.h>
#import <NGObjWeb/SoObjects.h>
#include <libxml/encoding.h>
#import "UIxMailPartHTMLViewer.h"
#if 0
@@ -49,6 +54,7 @@
BOOL inCSSDeclaration;
BOOL hasEmbeddedCSS;
NSMutableArray *crumb;
xmlCharEncoding contentEncoding;
}
- (NSString *) result;
@@ -65,6 +71,7 @@
css = nil;
result = nil;
attachmentIds = nil;
contentEncoding = XML_CHAR_ENCODING_UTF8;
}
return self;
@@ -78,6 +85,16 @@
[super dealloc];
}
- (void) setContentEncoding: (xmlCharEncoding) newContentEncoding
{
contentEncoding = newContentEncoding;
}
- (xmlCharEncoding) contentEncoding
{
return contentEncoding;
}
- (void) setAttachmentIds: (NSDictionary *) newAttachmentIds
{
attachmentIds = newAttachmentIds;
@@ -463,17 +480,79 @@
return attachmentIds;
}
- (xmlCharEncoding) _xmlCharsetForCharset: (NSString *) charset
{
struct { NSString *name; xmlCharEncoding encoding; } xmlEncodings[] = {
{ @"us-ascii", XML_CHAR_ENCODING_NONE},
{ @"utf-8", XML_CHAR_ENCODING_UTF8},
{ @"utf-16le", XML_CHAR_ENCODING_UTF16LE},
{ @"utf-16be", XML_CHAR_ENCODING_UTF16BE},
{ @"ucs-4le", XML_CHAR_ENCODING_UCS4LE},
{ @"ucs-4be", XML_CHAR_ENCODING_UCS4BE},
{ @"ebcdic", XML_CHAR_ENCODING_EBCDIC},
// { @"iso-10646" , XML_CHAR_ENCODING_UCS4_2143},
// { , XML_CHAR_ENCODING_UCS4_3412},
// { @"ucs-2", XML_CHAR_ENCODING_UCS2},
{ @"iso8859_1", XML_CHAR_ENCODING_8859_1},
{ @"iso-8859-1", XML_CHAR_ENCODING_8859_1},
{ @"iso-8859-2", XML_CHAR_ENCODING_8859_2},
{ @"iso-8859-3", XML_CHAR_ENCODING_8859_3},
{ @"iso-8859-4", XML_CHAR_ENCODING_8859_4},
{ @"iso-8859-5", XML_CHAR_ENCODING_8859_5},
{ @"iso-8859-6", XML_CHAR_ENCODING_8859_6},
{ @"iso-8859-7", XML_CHAR_ENCODING_8859_7},
{ @"iso-8859-8", XML_CHAR_ENCODING_8859_8},
{ @"iso-8859-9", XML_CHAR_ENCODING_8859_9},
{ @"iso-2022-jp", XML_CHAR_ENCODING_2022_JP},
// { @"iso-2022-jp", XML_CHAR_ENCODING_SHIFT_JIS},
{ @"euc-jp", XML_CHAR_ENCODING_EUC_JP},
{ @"us-ascii", XML_CHAR_ENCODING_ASCII}};
unsigned count;
xmlCharEncoding encoding;
encoding = XML_CHAR_ENCODING_NONE;
count = 0;
while (encoding == XML_CHAR_ENCODING_NONE
&& count < (sizeof (xmlEncodings) / sizeof (xmlEncodings[0])))
if ([charset isEqualToString: xmlEncodings[count].name])
encoding = xmlEncodings[count].encoding;
else
count++;
if (encoding == XML_CHAR_ENCODING_NONE)
encoding = XML_CHAR_ENCODING_8859_1;
return encoding;
}
- (xmlCharEncoding) _xmlCharEncoding
{
NSString *charset;
charset = [[bodyInfo objectForKey:@"parameterList"]
objectForKey: @"charset"];
if (![charset length])
charset = @"us-ascii";
return [self _xmlCharsetForCharset: [charset lowercaseString]];
}
- (void) _parseContent
{
id <NSObject, SaxXMLReader> parser;
NSObject <SaxXMLReader> *parser;
NSData *preparsedContent;
preparsedContent = [super decodedFlatContent];
parser = [[SaxXMLReaderFactory standardXMLReaderFactory]
createXMLReaderForMimeType: @"text/html"];
[parser setValue: [NSNumber numberWithBool: NO]
forKey: @"encodeEntities"];
handler = [_UIxHTMLMailContentHandler new];
[handler setAttachmentIds: [self _attachmentIds]];
[handler setContentEncoding: [self _xmlCharEncoding]];
[parser setContentHandler: handler];
[parser parseFromSource: preparsedContent];
}