aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Paul Young <paulyoungonline@gmail.com>2013-07-06 07:27:24 -0400
committerGravatar Paul Young <paulyoungonline@gmail.com>2013-07-06 07:27:24 -0400
commite7792ad0d839677410e4eecaf30095314d64f127 (patch)
treee3eb0f2c42fe611dfb58a31a12adae33a24084d6
parentf2f14f4dca0ae290890ed677d042f4c1142c84d7 (diff)
parentdd0b3c7a22eb957e5f2b9a71a2d3bdb342d62269 (diff)
Merge remote-tracking branch 'upstream/master' into message-rendering-with-session
-rw-r--r--build-mac/mailcore2.xcodeproj/project.pbxproj8
-rw-r--r--src/core/basetypes/MCLog.h10
-rw-r--r--src/core/renderer/HTMLBodyRendererTemplateCallback.cc16
-rw-r--r--src/core/renderer/HTMLBodyRendererTemplateCallback.h28
-rw-r--r--src/core/rfc822/MCMessageBuilder.cc19
-rw-r--r--src/core/rfc822/MCMessageBuilder.h4
-rw-r--r--src/core/rfc822/MCMessageParser.cc30
-rw-r--r--src/core/rfc822/MCMessageParser.h4
-rw-r--r--src/objc/abstract/MCOConstants.h2
-rw-r--r--src/objc/imap/MCOIMAPSession.h9
-rw-r--r--src/objc/imap/MCOIMAPSession.mm1
-rw-r--r--src/objc/rfc822/MCOMessageBuilder.h10
-rw-r--r--src/objc/rfc822/MCOMessageBuilder.mm16
-rw-r--r--src/objc/rfc822/MCOMessageParser.h10
-rw-r--r--src/objc/rfc822/MCOMessageParser.mm15
-rw-r--r--src/objc/utils/NSError+MCO.mm50
-rw-r--r--tests/test-all.mm3
17 files changed, 219 insertions, 16 deletions
diff --git a/build-mac/mailcore2.xcodeproj/project.pbxproj b/build-mac/mailcore2.xcodeproj/project.pbxproj
index 0c4cb130..7f5e5b4f 100644
--- a/build-mac/mailcore2.xcodeproj/project.pbxproj
+++ b/build-mac/mailcore2.xcodeproj/project.pbxproj
@@ -113,6 +113,8 @@
C64BB26416FD43A1000DB34C /* MCOMessageParser.mm in Sources */ = {isa = PBXBuildFile; fileRef = C64BB26316FD43A1000DB34C /* MCOMessageParser.mm */; };
C64BB26716FD43E2000DB34C /* MCOMessagePart.mm in Sources */ = {isa = PBXBuildFile; fileRef = C64BB26616FD43E2000DB34C /* MCOMessagePart.mm */; };
C64BB26A16FD44C2000DB34C /* MCOMultipart.mm in Sources */ = {isa = PBXBuildFile; fileRef = C64BB26916FD44C2000DB34C /* MCOMultipart.mm */; };
+ C64DBFFD1787CA050012CA0B /* HTMLBodyRendererTemplateCallback.cc in Sources */ = {isa = PBXBuildFile; fileRef = C64DBFFB1787CA050012CA0B /* HTMLBodyRendererTemplateCallback.cc */; };
+ C64DBFFE1787CA050012CA0B /* HTMLBodyRendererTemplateCallback.cc in Sources */ = {isa = PBXBuildFile; fileRef = C64DBFFB1787CA050012CA0B /* HTMLBodyRendererTemplateCallback.cc */; };
C64EA6F4169E847800778456 /* MCAbstractMessage.cc in Sources */ = {isa = PBXBuildFile; fileRef = C64EA694169E847800778456 /* MCAbstractMessage.cc */; };
C64EA6F6169E847800778456 /* MCAbstractMessagePart.cc in Sources */ = {isa = PBXBuildFile; fileRef = C64EA696169E847800778456 /* MCAbstractMessagePart.cc */; };
C64EA6F8169E847800778456 /* MCAbstractMultipart.cc in Sources */ = {isa = PBXBuildFile; fileRef = C64EA698169E847800778456 /* MCAbstractMultipart.cc */; };
@@ -1179,6 +1181,8 @@
C64BB26B16FD4C3B000DB34C /* MCORFC822.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MCORFC822.h; sourceTree = "<group>"; };
C64BB26C16FD62FB000DB34C /* MCOUtils.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MCOUtils.h; sourceTree = "<group>"; };
C64BB26D16FD63F6000DB34C /* MCOConstants.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MCOConstants.h; sourceTree = "<group>"; };
+ C64DBFFB1787CA050012CA0B /* HTMLBodyRendererTemplateCallback.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLBodyRendererTemplateCallback.cc; sourceTree = "<group>"; };
+ C64DBFFC1787CA050012CA0B /* HTMLBodyRendererTemplateCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLBodyRendererTemplateCallback.h; sourceTree = "<group>"; };
C64EA537169E772200778456 /* libMailCore.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libMailCore.a; sourceTree = BUILT_PRODUCTS_DIR; };
C64EA68C169E847800778456 /* MCIMAPAsyncConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MCIMAPAsyncConnection.h; sourceTree = "<group>"; };
C64EA68F169E847800778456 /* MCSMTPAsyncSession.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MCSMTPAsyncSession.cc; sourceTree = "<group>"; };
@@ -1542,6 +1546,8 @@
C63CD67616BDCDD300DB18F1 /* renderer */ = {
isa = PBXGroup;
children = (
+ C64DBFFB1787CA050012CA0B /* HTMLBodyRendererTemplateCallback.cc */,
+ C64DBFFC1787CA050012CA0B /* HTMLBodyRendererTemplateCallback.h */,
C63CD67716BDCDD400DB18F1 /* MCAddressDisplay.cc */,
C63CD67816BDCDD400DB18F1 /* MCAddressDisplay.h */,
C63CD67916BDCDD400DB18F1 /* MCDateFormatter.cc */,
@@ -2349,6 +2355,7 @@
C64EA6F6169E847800778456 /* MCAbstractMessagePart.cc in Sources */,
C64EA6F8169E847800778456 /* MCAbstractMultipart.cc in Sources */,
C64EA6FA169E847800778456 /* MCAbstractPart.cc in Sources */,
+ C64DBFFD1787CA050012CA0B /* HTMLBodyRendererTemplateCallback.cc in Sources */,
C64EA6FC169E847800778456 /* MCAddress.cc in Sources */,
C64EA6FF169E847800778456 /* MCMessageHeader.cc in Sources */,
C64EA701169E847800778456 /* MCAutoreleasePool.cc in Sources */,
@@ -2533,6 +2540,7 @@
C6BA2B9A1705F4E6003F0E9E /* MCAbstractMessagePart.cc in Sources */,
C6BA2B9B1705F4E6003F0E9E /* MCAbstractMultipart.cc in Sources */,
C6BA2B9C1705F4E6003F0E9E /* MCAbstractPart.cc in Sources */,
+ C64DBFFE1787CA050012CA0B /* HTMLBodyRendererTemplateCallback.cc in Sources */,
C6BA2B9D1705F4E6003F0E9E /* MCAddress.cc in Sources */,
C6BA2B9E1705F4E6003F0E9E /* MCMessageHeader.cc in Sources */,
C6BA2B9F1705F4E6003F0E9E /* MCAutoreleasePool.cc in Sources */,
diff --git a/src/core/basetypes/MCLog.h b/src/core/basetypes/MCLog.h
index de75314f..6911ab02 100644
--- a/src/core/basetypes/MCLog.h
+++ b/src/core/basetypes/MCLog.h
@@ -4,13 +4,9 @@
#include <stdio.h>
-#ifdef __cplusplus
-
#define MCLog(...) MCLogInternal(NULL, __FILE__, __LINE__, 0, __VA_ARGS__)
-
-namespace mailcore {
- extern int MCLogEnabled;
+extern int MCLogEnabled;
#ifndef __printflike
#define __printflike(a,b)
@@ -28,8 +24,4 @@ extern "C" {
}
#endif
-}
-
-#endif
-
#endif
diff --git a/src/core/renderer/HTMLBodyRendererTemplateCallback.cc b/src/core/renderer/HTMLBodyRendererTemplateCallback.cc
new file mode 100644
index 00000000..94ee6de7
--- /dev/null
+++ b/src/core/renderer/HTMLBodyRendererTemplateCallback.cc
@@ -0,0 +1,16 @@
+//
+// HTMLBodyRendererTemplateCallback.cc
+// mailcore2
+//
+// Created by Paul Young on 02/07/2013.
+// Copyright (c) 2013 MailCore. All rights reserved.
+//
+
+#include "HTMLBodyRendererTemplateCallback.h"
+
+using namespace mailcore;
+
+mailcore::String * HTMLBodyRendererTemplateCallback::templateForMainHeader(MessageHeader * header)
+{
+ return MCSTR("");
+}
diff --git a/src/core/renderer/HTMLBodyRendererTemplateCallback.h b/src/core/renderer/HTMLBodyRendererTemplateCallback.h
new file mode 100644
index 00000000..7901e265
--- /dev/null
+++ b/src/core/renderer/HTMLBodyRendererTemplateCallback.h
@@ -0,0 +1,28 @@
+//
+// HTMLBodyRendererTemplateCallback.h
+// mailcore2
+//
+// Created by Paul Young on 02/07/2013.
+// Copyright (c) 2013 MailCore. All rights reserved.
+//
+
+#ifndef __MAILCORE_MCHTMLBODYRENDERERTEMPLATECALLBACK_H_
+
+#define __MAILCORE_MCHTMLBODYRENDERERTEMPLATECALLBACK_H_
+
+#include <MailCore/MCHTMLRendererCallback.h>
+
+#ifdef __cplusplus
+
+namespace mailcore {
+
+ class HTMLBodyRendererTemplateCallback : public Object, public HTMLRendererTemplateCallback {
+ public:
+ virtual String * templateForMainHeader(MessageHeader * header);
+ };
+
+}
+
+#endif
+
+#endif
diff --git a/src/core/rfc822/MCMessageBuilder.cc b/src/core/rfc822/MCMessageBuilder.cc
index ea449fd6..7f902be1 100644
--- a/src/core/rfc822/MCMessageBuilder.cc
+++ b/src/core/rfc822/MCMessageBuilder.cc
@@ -691,3 +691,22 @@ String * MessageBuilder::htmlRendering(HTMLRendererTemplateCallback * htmlCallba
MessageParser * message = MessageParser::messageParserWithData(data());
return message->htmlRendering(htmlCallback);
}
+
+String * MessageBuilder::htmlBodyRendering()
+{
+ MessageParser * message = MessageParser::messageParserWithData(data());
+ return message->htmlBodyRendering();
+}
+
+String * MessageBuilder::plainTextRendering()
+{
+ MessageParser * message = MessageParser::messageParserWithData(data());
+ return message->plainTextRendering();
+}
+
+String * MessageBuilder::plainTextBodyRendering()
+{
+ MessageParser * message = MessageParser::messageParserWithData(data());
+ return message->plainTextBodyRendering();
+}
+
diff --git a/src/core/rfc822/MCMessageBuilder.h b/src/core/rfc822/MCMessageBuilder.h
index 409cd9ee..efbb1f47 100644
--- a/src/core/rfc822/MCMessageBuilder.h
+++ b/src/core/rfc822/MCMessageBuilder.h
@@ -41,6 +41,10 @@ namespace mailcore {
virtual Data * data();
virtual String * htmlRendering(HTMLRendererTemplateCallback * htmlCallback = NULL);
+ virtual String * htmlBodyRendering();
+
+ virtual String * plainTextRendering();
+ virtual String * plainTextBodyRendering();
public: // subclass behavior
MessageBuilder(MessageBuilder * other);
diff --git a/src/core/rfc822/MCMessageParser.cc b/src/core/rfc822/MCMessageParser.cc
index b936fabf..1de28d6b 100644
--- a/src/core/rfc822/MCMessageParser.cc
+++ b/src/core/rfc822/MCMessageParser.cc
@@ -5,6 +5,7 @@
#include "MCAttachment.h"
#include "MCMessageHeader.h"
#include "MCHTMLRenderer.h"
+#include "HTMLBodyRendererTemplateCallback.h"
using namespace mailcore;
@@ -96,3 +97,32 @@ String * MessageParser::htmlRendering(HTMLRendererTemplateCallback * htmlCallbac
return HTMLRenderer::htmlForRFC822Message(this, htmlCallback);
}
+String * MessageParser::htmlBodyRendering()
+{
+ HTMLBodyRendererTemplateCallback * callback = new HTMLBodyRendererTemplateCallback();
+ String * result = htmlRendering(callback);
+ MC_SAFE_RELEASE(callback);
+ return result;
+}
+
+String * MessageParser::plainTextRendering()
+{
+ String * html = htmlRendering(NULL);
+ return html->flattenHTML();
+}
+
+String * MessageParser::plainTextBodyRendering()
+{
+ String * html = htmlBodyRendering();
+ String * plainTextBodyString = html->flattenHTML();
+
+ plainTextBodyString->replaceOccurrencesOfString(MCSTR("\t"), MCSTR(" "));
+ plainTextBodyString->replaceOccurrencesOfString(MCSTR("\n"), MCSTR(" "));
+ plainTextBodyString->replaceOccurrencesOfString(MCSTR("\v"), MCSTR(" "));
+ plainTextBodyString->replaceOccurrencesOfString(MCSTR("\f"), MCSTR(" "));
+ plainTextBodyString->replaceOccurrencesOfString(MCSTR("\r"), MCSTR(" "));
+ while (plainTextBodyString->replaceOccurrencesOfString(MCSTR(" "), MCSTR(" "))) {
+ // do nothing.
+ }
+ return plainTextBodyString;
+}
diff --git a/src/core/rfc822/MCMessageParser.h b/src/core/rfc822/MCMessageParser.h
index 4f13299d..bed41793 100644
--- a/src/core/rfc822/MCMessageParser.h
+++ b/src/core/rfc822/MCMessageParser.h
@@ -24,6 +24,10 @@ namespace mailcore {
virtual Data * data();
virtual String * htmlRendering(HTMLRendererTemplateCallback * htmlCallback = NULL);
+ virtual String * htmlBodyRendering();
+
+ virtual String * plainTextRendering();
+ virtual String * plainTextBodyRendering();
public: // subclass behavior
MessageParser(MessageParser * other);
diff --git a/src/objc/abstract/MCOConstants.h b/src/objc/abstract/MCOConstants.h
index 5ec21422..58239811 100644
--- a/src/objc/abstract/MCOConstants.h
+++ b/src/objc/abstract/MCOConstants.h
@@ -324,6 +324,8 @@ typedef enum {
MCOErrorDeleteMessage,
/** SMTP: Error while checking account.*/
MCOErrorInvalidAccount,
+ /** The count of all errors */
+ MCOErrorCodeCount,
} MCOErrorCode;
/** Here's the list of connection log types.*/
diff --git a/src/objc/imap/MCOIMAPSession.h b/src/objc/imap/MCOIMAPSession.h
index 0358f7ad..3a6cbc6f 100644
--- a/src/objc/imap/MCOIMAPSession.h
+++ b/src/objc/imap/MCOIMAPSession.h
@@ -40,16 +40,19 @@
@interface MCOIMAPSession : NSObject
/** This is the hostname of the IMAP server to connect to. */
-@property (nonatomic, strong) NSString *hostname;
+@property (nonatomic, copy) NSString *hostname;
/** This is the port of the IMAP server to connect to. */
@property (nonatomic, assign) unsigned int port;
/** This is the username of the account. */
-@property (nonatomic, strong) NSString *username;
+@property (nonatomic, copy) NSString *username;
/** This is the password of the account. */
-@property (nonatomic, strong) NSString *password;
+@property (nonatomic, copy) NSString *password;
+
+/** This is the OAuth2 token. */
+@property (nonatomic, copy) NSString *OAuth2Token;
/**
This is the authentication type to use to connect.
diff --git a/src/objc/imap/MCOIMAPSession.mm b/src/objc/imap/MCOIMAPSession.mm
index 0c23f1e2..1dff0f1f 100644
--- a/src/objc/imap/MCOIMAPSession.mm
+++ b/src/objc/imap/MCOIMAPSession.mm
@@ -77,6 +77,7 @@ MCO_OBJC_SYNTHESIZE_STRING(setHostname, hostname)
MCO_OBJC_SYNTHESIZE_SCALAR(unsigned int, unsigned int, setPort, port)
MCO_OBJC_SYNTHESIZE_STRING(setUsername, username)
MCO_OBJC_SYNTHESIZE_STRING(setPassword, password)
+MCO_OBJC_SYNTHESIZE_STRING(setOAuth2Token, OAuth2Token)
MCO_OBJC_SYNTHESIZE_SCALAR(MCOAuthType, mailcore::AuthType, setAuthType, authType)
MCO_OBJC_SYNTHESIZE_SCALAR(MCOConnectionType, mailcore::ConnectionType, setConnectionType, connectionType)
MCO_OBJC_SYNTHESIZE_SCALAR(NSTimeInterval, time_t, setTimeout, timeout)
diff --git a/src/objc/rfc822/MCOMessageBuilder.h b/src/objc/rfc822/MCOMessageBuilder.h
index 217ec49c..5ba199a4 100644
--- a/src/objc/rfc822/MCOMessageBuilder.h
+++ b/src/objc/rfc822/MCOMessageBuilder.h
@@ -61,6 +61,16 @@
/** HTML rendering of the message to be displayed in a web view. The delegate can be nil.*/
- (NSString *) htmlRenderingWithDelegate:(id <MCOHTMLRendererDelegate>)delegate;
+/** HTML rendering of the body of the message to be displayed in a web view.*/
+- (NSString *) htmlBodyRendering;
+
+/** Text rendering of the message.*/
+- (NSString *) plainTextRendering;
+
+/** Text rendering of the body of the message. All end of line will be removed and white spaces cleaned up.
+ This method can be used to generate the summary of the message.*/
+- (NSString *) plainTextBodyRendering;
+
@end
#endif
diff --git a/src/objc/rfc822/MCOMessageBuilder.mm b/src/objc/rfc822/MCOMessageBuilder.mm
index 2cb26448..dfcf6028 100644
--- a/src/objc/rfc822/MCOMessageBuilder.mm
+++ b/src/objc/rfc822/MCOMessageBuilder.mm
@@ -75,4 +75,20 @@ MCO_OBJC_SYNTHESIZE_STRING(setBoundaryPrefix, boundaryPrefix)
return result;
}
+
+- (NSString *) htmlBodyRendering
+{
+ return MCO_OBJC_BRIDGE_GET(htmlBodyRendering);
+}
+
+- (NSString *) plainTextRendering
+{
+ return MCO_OBJC_BRIDGE_GET(plainTextRendering);
+}
+
+- (NSString *) plainTextBodyRendering
+{
+ return MCO_OBJC_BRIDGE_GET(plainTextBodyRendering);
+}
+
@end
diff --git a/src/objc/rfc822/MCOMessageParser.h b/src/objc/rfc822/MCOMessageParser.h
index fa46132b..82613403 100644
--- a/src/objc/rfc822/MCOMessageParser.h
+++ b/src/objc/rfc822/MCOMessageParser.h
@@ -38,6 +38,16 @@
/** HTML rendering of the message to be displayed in a web view. delegate can be nil.*/
- (NSString *) htmlRenderingWithDelegate:(id <MCOHTMLRendererDelegate>)delegate;
+/** HTML rendering of the body of the message to be displayed in a web view.*/
+- (NSString *) htmlBodyRendering;
+
+/** Text rendering of the message.*/
+- (NSString *) plainTextRendering;
+
+/** Text rendering of the body of the message. All end of line will be removed and white spaces cleaned up.
+ This method can be used to generate the summary of the message.*/
+- (NSString *) plainTextBodyRendering;
+
@end
#endif
diff --git a/src/objc/rfc822/MCOMessageParser.mm b/src/objc/rfc822/MCOMessageParser.mm
index 05f52f54..84631430 100644
--- a/src/objc/rfc822/MCOMessageParser.mm
+++ b/src/objc/rfc822/MCOMessageParser.mm
@@ -77,4 +77,19 @@
return result;
}
+- (NSString *) htmlBodyRendering
+{
+ return MCO_OBJC_BRIDGE_GET(htmlBodyRendering);
+}
+
+- (NSString *) plainTextRendering
+{
+ return MCO_OBJC_BRIDGE_GET(plainTextRendering);
+}
+
+- (NSString *) plainTextBodyRendering
+{
+ return MCO_OBJC_BRIDGE_GET(plainTextBodyRendering);
+}
+
@end
diff --git a/src/objc/utils/NSError+MCO.mm b/src/objc/utils/NSError+MCO.mm
index c9f4f998..47abf809 100644
--- a/src/objc/utils/NSError+MCO.mm
+++ b/src/objc/utils/NSError+MCO.mm
@@ -7,15 +7,59 @@
#import "MCOConstants.h"
+static NSString * MCOLocalizedDescriptionTable[] = {
+ @"The operation succeeded.", /** MCOErrorNone */
+ @"A stable connection to the server could not be established.", /** MCOErrorConnection */
+ @"The server does not support TLS/SSL connections.", /** MCOErrorTLSNotAvailable */
+ @"Unable to parse response from server.", /** MCOErrorParse */
+ @"The certificate for this server is invalid.", /** MCOErrorCertificate */
+ @"Unable to authenticate with the current session's credentials.", /** MCOErrorAuthentication */
+ @"IMAP is not enabled for this Gmail account.", /** MCOErrorGmailIMAPNotEnabled */
+ @"Bandwidth limits were exceeded while requesting data from this Gmail account.", /** MCOErrorGmailExceededBandwidthLimit */
+ @"Too many simultaneous connections were made to this Gmail account.", /** MCOErrorGmailTooManySimultaneousConnections */
+ @"MobileMe is no longer an active mail service.", /** MCOErrorMobileMeMoved */
+ @"Yahoo!'s servers are currently unavailable.", /** MCOErrorYahooUnavailable */
+ @"The requested folder does not exist. Folder selection failed", /** MCOErrorNonExistantFolder */
+ @"An error occured while renaming the requested folder.", /** MCOErrorRename */
+ @"An error occured while deleting the requested folder.", /** MCOErrorDelete */
+ @"An error occured while creating the requested folder.", /** MCOErrorCreate */
+ @"An error occured while (un)subscribing to the requested folder.", /** MCOErrorSubscribe */
+ @"An error occured while appending a message to the requested folder.", /** MCOErrorAppend */
+ @"An error occured while copying a message to the requested folder.", /** MCOErrorCopy */
+ @"An error occured while expunging a message in the requested folder.", /** MCOErrorExpunge */
+ @"An error occured while fetching messages in the requested folder.", /** MCOErrorFetch */
+ @"An error occured during an IDLE operation.", /** MCOErrorIdle */
+ @"An error occured while requesting the server's identity.", /** MCOErrorIdentity */
+ @"An error occured while requesting the server's namespace.", /** MCOErrorNamespace */
+ @"An error occured while storing flags.", /** MCOErrorStore */
+ @"An error occured while requesting the server's capabilities.", /** MCOErrorCapability */
+ @"The server does not support STARTTLS connections.", /** MCOErrorStartTLSNotAvailable */
+ @"Attempted to send a message with an illegal attachment.", /** MCOErrorSendMessageIllegalAttachment */
+ @"The SMTP storage limit was hit while trying to send a large message.", /** MCOErrorStorageLimit */
+ @"Sending messages is not allowed on this server.", /** MCOErrorSendMessageNotAllowed */
+ @"The current HotMail account cannot connect to WebMail.", /** MCOErrorNeedsConnectToWebmail */
+ @"An error occured while sending the message.", /** MCOErrorSendMessage */
+ @"Authentication is required for this SMTP server.", /** MCOErrorAuthenticationRequired */
+ @"An error occured while fetching a message list on the POP server.", /** MCOErrorFetchMessageList */
+ @"An error occured while deleting a message on the POP server.", /** MCOErrorDeleteMessage */
+ @"Account check failed because the account is invalid.", /** MCOErrorInvalidAccount */
+};
+
@implementation NSError (MCO)
+ (NSError *)mco_errorWithErrorCode:(mailcore::ErrorCode)code {
if (code == mailcore::ErrorNone) {
return nil;
}
-
+
+ NSMutableDictionary *userInfo = [[NSMutableDictionary alloc] init];
+ if (code < MCOErrorCodeCount) {
+ NSString * localizedString = NSLocalizedStringFromTable(MCOLocalizedDescriptionTable[code], @"description of errors of mailcore", @"MailCore");
+ [userInfo setObject:localizedString forKey:NSLocalizedDescriptionKey];
+ }
+
NSError *error = [NSError errorWithDomain:MCOErrorDomain
code:(int)code
- userInfo:nil];
+ userInfo:userInfo];
return error;
}
-@end \ No newline at end of file
+@end
diff --git a/tests/test-all.mm b/tests/test-all.mm
index fdb0888c..c58e5888 100644
--- a/tests/test-all.mm
+++ b/tests/test-all.mm
@@ -84,6 +84,7 @@ static void testMessageParser(mailcore::Data * data)
MCLog("%s", MCUTF8DESC(parser));
MCLog("HTML rendering");
MCLog("%s", MCUTF8(parser->htmlRendering()));
+ MCLog("%s", MCUTF8(parser->plainTextBodyRendering()));
}
static void testIMAP()
@@ -365,7 +366,7 @@ void testAll()
//testAddresses();
//testAttachments();
//testProviders();
- testObjC();
+ //testObjC();
MCLog("pool release");
pool->release();