diff options
author | CodaFi <devteam.codafi@gmail.com> | 2013-07-08 09:17:18 -0600 |
---|---|---|
committer | CodaFi <devteam.codafi@gmail.com> | 2013-07-08 09:17:18 -0600 |
commit | 1b69c3bdedd080ee83911a1364c2bcb326e9fb91 (patch) | |
tree | 01d10fcf09eecd3ea643729dd65e3cd0c0dd97ae | |
parent | 1c7c1d4a5474b093f82f43d514bbb043047d4489 (diff) | |
parent | 4a66387ae118a620c1b09a1ae606cecf6bf70319 (diff) |
Merge remote-tracking branch 'upstream/master' into NSCoding-NSCopying
37 files changed, 426 insertions, 172 deletions
diff --git a/build-mac/mailcore2.xcodeproj/project.pbxproj b/build-mac/mailcore2.xcodeproj/project.pbxproj index c1b46c92..7ae5ee05 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 */; }; @@ -125,7 +127,7 @@ C64EA708169E847800778456 /* MCData.cc in Sources */ = {isa = PBXBuildFile; fileRef = C64EA6A9169E847800778456 /* MCData.cc */; }; C64EA70A169E847800778456 /* MCHash.cc in Sources */ = {isa = PBXBuildFile; fileRef = C64EA6AB169E847800778456 /* MCHash.cc */; }; C64EA70C169E847800778456 /* MCHashMap.cc in Sources */ = {isa = PBXBuildFile; fileRef = C64EA6AD169E847800778456 /* MCHashMap.cc */; }; - C64EA70E169E847800778456 /* MCLog.cc in Sources */ = {isa = PBXBuildFile; fileRef = C64EA6AF169E847800778456 /* MCLog.cc */; }; + C64EA70E169E847800778456 /* MCLog.c in Sources */ = {isa = PBXBuildFile; fileRef = C64EA6AF169E847800778456 /* MCLog.c */; }; C64EA710169E847800778456 /* MCObject.cc in Sources */ = {isa = PBXBuildFile; fileRef = C64EA6B1169E847800778456 /* MCObject.cc */; }; C64EA712169E847800778456 /* MCRange.cc in Sources */ = {isa = PBXBuildFile; fileRef = C64EA6B3169E847800778456 /* MCRange.cc */; }; C64EA714169E847800778456 /* MCSet.cc in Sources */ = {isa = PBXBuildFile; fileRef = C64EA6B5169E847800778456 /* MCSet.cc */; }; @@ -449,7 +451,7 @@ C6BA2BA21705F4E6003F0E9E /* MCData.cc in Sources */ = {isa = PBXBuildFile; fileRef = C64EA6A9169E847800778456 /* MCData.cc */; }; C6BA2BA31705F4E6003F0E9E /* MCHash.cc in Sources */ = {isa = PBXBuildFile; fileRef = C64EA6AB169E847800778456 /* MCHash.cc */; }; C6BA2BA41705F4E6003F0E9E /* MCHashMap.cc in Sources */ = {isa = PBXBuildFile; fileRef = C64EA6AD169E847800778456 /* MCHashMap.cc */; }; - C6BA2BA51705F4E6003F0E9E /* MCLog.cc in Sources */ = {isa = PBXBuildFile; fileRef = C64EA6AF169E847800778456 /* MCLog.cc */; }; + C6BA2BA51705F4E6003F0E9E /* MCLog.c in Sources */ = {isa = PBXBuildFile; fileRef = C64EA6AF169E847800778456 /* MCLog.c */; }; C6BA2BA61705F4E6003F0E9E /* MCObject.cc in Sources */ = {isa = PBXBuildFile; fileRef = C64EA6B1169E847800778456 /* MCObject.cc */; }; C6BA2BA71705F4E6003F0E9E /* MCRange.cc in Sources */ = {isa = PBXBuildFile; fileRef = C64EA6B3169E847800778456 /* MCRange.cc */; }; C6BA2BA81705F4E6003F0E9E /* MCSet.cc in Sources */ = {isa = PBXBuildFile; fileRef = C64EA6B5169E847800778456 /* MCSet.cc */; }; @@ -1175,6 +1177,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>"; }; @@ -1206,7 +1210,7 @@ C64EA6AC169E847800778456 /* MCHash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MCHash.h; sourceTree = "<group>"; }; C64EA6AD169E847800778456 /* MCHashMap.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MCHashMap.cc; sourceTree = "<group>"; }; C64EA6AE169E847800778456 /* MCHashMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MCHashMap.h; sourceTree = "<group>"; }; - C64EA6AF169E847800778456 /* MCLog.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MCLog.cc; sourceTree = "<group>"; }; + C64EA6AF169E847800778456 /* MCLog.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = MCLog.c; sourceTree = "<group>"; }; C64EA6B0169E847800778456 /* MCLog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MCLog.h; sourceTree = "<group>"; }; C64EA6B1169E847800778456 /* MCObject.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MCObject.cc; sourceTree = "<group>"; }; C64EA6B2169E847800778456 /* MCObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MCObject.h; sourceTree = "<group>"; }; @@ -1534,6 +1538,8 @@ C63CD67616BDCDD300DB18F1 /* renderer */ = { isa = PBXGroup; children = ( + C64DBFFB1787CA050012CA0B /* HTMLBodyRendererTemplateCallback.cc */, + C64DBFFC1787CA050012CA0B /* HTMLBodyRendererTemplateCallback.h */, C63CD67716BDCDD400DB18F1 /* MCAddressDisplay.cc */, C63CD67816BDCDD400DB18F1 /* MCAddressDisplay.h */, C63CD67916BDCDD400DB18F1 /* MCDateFormatter.cc */, @@ -1802,7 +1808,7 @@ C6D6F966171FCF9F006F5B28 /* MCJSONParser.h */, C6D6F950171E5CB8006F5B28 /* MCMD5.cc */, C6D6F951171E5CB8006F5B28 /* MCMD5.h */, - C64EA6AF169E847800778456 /* MCLog.cc */, + C64EA6AF169E847800778456 /* MCLog.c */, C64EA6B0169E847800778456 /* MCLog.h */, C6D6F952171E5CB8006F5B28 /* MCNull.cc */, C6D6F953171E5CB8006F5B28 /* MCNull.h */, @@ -2337,6 +2343,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 */, @@ -2345,7 +2352,7 @@ C64EA708169E847800778456 /* MCData.cc in Sources */, C64EA70A169E847800778456 /* MCHash.cc in Sources */, C64EA70C169E847800778456 /* MCHashMap.cc in Sources */, - C64EA70E169E847800778456 /* MCLog.cc in Sources */, + C64EA70E169E847800778456 /* MCLog.c in Sources */, C64EA710169E847800778456 /* MCObject.cc in Sources */, C64EA712169E847800778456 /* MCRange.cc in Sources */, C64EA714169E847800778456 /* MCSet.cc in Sources */, @@ -2519,6 +2526,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 */, @@ -2527,7 +2535,7 @@ C6BA2BA21705F4E6003F0E9E /* MCData.cc in Sources */, C6BA2BA31705F4E6003F0E9E /* MCHash.cc in Sources */, C6BA2BA41705F4E6003F0E9E /* MCHashMap.cc in Sources */, - C6BA2BA51705F4E6003F0E9E /* MCLog.cc in Sources */, + C6BA2BA51705F4E6003F0E9E /* MCLog.c in Sources */, C6BA2BA61705F4E6003F0E9E /* MCObject.cc in Sources */, C6BA2BA71705F4E6003F0E9E /* MCRange.cc in Sources */, C6BA2BA81705F4E6003F0E9E /* MCSet.cc in Sources */, diff --git a/example/ios/iOS UI Test/iOS UI Test/MasterViewController.m b/example/ios/iOS UI Test/iOS UI Test/MasterViewController.m index c9866ff8..3e5e4422 100644 --- a/example/ios/iOS UI Test/iOS UI Test/MasterViewController.m +++ b/example/ios/iOS UI Test/iOS UI Test/MasterViewController.m @@ -45,9 +45,16 @@ self.imapSession.username = username; self.imapSession.password = password; self.imapSession.connectionType = MCOConnectionTypeTLS; - + MasterViewController * __weak weakSelf = self; + self.imapSession.connectionLogger = ^(void * connectionID, MCOConnectionLogType type, NSData * data) { + @synchronized(weakSelf) { + if (type != MCOConnectionLogTypeSentPrivate) { + NSLog(@"event logged:%p %i withData: %@", connectionID, type, [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]); + } + } + }; + NSLog(@"checking account"); - __weak MasterViewController *weakSelf = self; self.imapCheckOp = [self.imapSession checkAccountOperation]; [self.imapCheckOp start:^(NSError *error) { MasterViewController *strongSelf = weakSelf; diff --git a/example/ios/iOS UI Test/iOS UI Test/main.mm b/example/ios/iOS UI Test/iOS UI Test/main.mm index 7793820a..e6253102 100644 --- a/example/ios/iOS UI Test/iOS UI Test/main.mm +++ b/example/ios/iOS UI Test/iOS UI Test/main.mm @@ -12,6 +12,6 @@ #import <MailCore/MailCore.h> int main(int argc, char *argv[]) { - mailcore::logEnabled = true; + MCLogEnabled = 1; return UIApplicationMain(argc, argv, nil, @"AppDelegate"); } diff --git a/scripts/prepare-libetpan-ios.sh b/scripts/prepare-libetpan-ios.sh index 7a5a054b..5e5684fd 100755 --- a/scripts/prepare-libetpan-ios.sh +++ b/scripts/prepare-libetpan-ios.sh @@ -2,7 +2,7 @@ sdkversion=6.1 url="https://github.com/dinhviethoa/libetpan.git" -rev=78427a0506be00e1e72ac8f88aa4b71bebd4137f +rev=20aa2b2b15b6f8db350ec07b6041e4951bb255d0 pushd `dirname $0` > /dev/null scriptpath=`pwd` diff --git a/scripts/prepare-libetpan-macos.sh b/scripts/prepare-libetpan-macos.sh index 81013fa6..e4bc3e82 100755 --- a/scripts/prepare-libetpan-macos.sh +++ b/scripts/prepare-libetpan-macos.sh @@ -1,7 +1,7 @@ #!/bin/sh url="https://github.com/dinhviethoa/libetpan.git" -rev=78427a0506be00e1e72ac8f88aa4b71bebd4137f +rev=20aa2b2b15b6f8db350ec07b6041e4951bb255d0 pushd `dirname $0` > /dev/null scriptpath=`pwd` diff --git a/src/async/imap/MCIMAPAsyncConnection.cc b/src/async/imap/MCIMAPAsyncConnection.cc index fc1935b7..1d07f79a 100644 --- a/src/async/imap/MCIMAPAsyncConnection.cc +++ b/src/async/imap/MCIMAPAsyncConnection.cc @@ -69,7 +69,7 @@ namespace mailcore { virtual ~IMAPConnectionLogger() { } - virtual void log(void * context, void * sender, ConnectionLogType logType, Data * buffer) + virtual void log(void * sender, ConnectionLogType logType, Data * buffer) { mConnection->logConnection(logType, buffer); } diff --git a/src/async/imap/MCIMAPFetchFoldersOperation.cc b/src/async/imap/MCIMAPFetchFoldersOperation.cc index 07533e6e..41a95572 100644 --- a/src/async/imap/MCIMAPFetchFoldersOperation.cc +++ b/src/async/imap/MCIMAPFetchFoldersOperation.cc @@ -55,8 +55,8 @@ void IMAPFetchFoldersOperation::main() char * delimiterData = (char *) malloc(1); * delimiterData = session()->session()->delimiter(); - session()->performMethodOnMainThread((Object::Method) &IMAPFetchFoldersOperation::setDelimiterDataOnMainThread, - delimiterData); + performMethodOnMainThread((Object::Method) &IMAPFetchFoldersOperation::setDelimiterDataOnMainThread, + delimiterData, true); } void IMAPFetchFoldersOperation::setDelimiterDataOnMainThread(char * delimiterData) diff --git a/src/async/imap/MCIMAPIdleOperation.cc b/src/async/imap/MCIMAPIdleOperation.cc index 42c58f90..8b48b77c 100644 --- a/src/async/imap/MCIMAPIdleOperation.cc +++ b/src/async/imap/MCIMAPIdleOperation.cc @@ -47,7 +47,7 @@ void IMAPIdleOperation::unprepare() void IMAPIdleOperation::main() { - performMethodOnMainThread((Object::Method) &IMAPIdleOperation::prepare, NULL); + performMethodOnMainThread((Object::Method) &IMAPIdleOperation::prepare, NULL, true); if (!mSetupSuccess) { return; @@ -57,7 +57,7 @@ void IMAPIdleOperation::main() session()->session()->idle(folder(), mLastKnownUid, &error); setError(error); - performMethodOnMainThread((Object::Method) &IMAPIdleOperation::unprepare, NULL); + performMethodOnMainThread((Object::Method) &IMAPIdleOperation::unprepare, NULL, true); } void IMAPIdleOperation::interruptIdle() diff --git a/src/async/pop/MCPOPAsyncSession.cc b/src/async/pop/MCPOPAsyncSession.cc index 342b0f5e..bfabc847 100644 --- a/src/async/pop/MCPOPAsyncSession.cc +++ b/src/async/pop/MCPOPAsyncSession.cc @@ -50,7 +50,7 @@ namespace mailcore { virtual ~POPConnectionLogger() { } - virtual void log(void * context, void * sender, ConnectionLogType logType, Data * buffer) + virtual void log(void * sender, ConnectionLogType logType, Data * buffer) { mSession->logConnection(logType, buffer); } diff --git a/src/async/smtp/MCSMTPAsyncSession.cc b/src/async/smtp/MCSMTPAsyncSession.cc index fafc2e82..f670894a 100644 --- a/src/async/smtp/MCSMTPAsyncSession.cc +++ b/src/async/smtp/MCSMTPAsyncSession.cc @@ -41,7 +41,7 @@ namespace mailcore { virtual ~SMTPConnectionLogger() { } - virtual void log(void * context, void * sender, ConnectionLogType logType, Data * buffer) + virtual void log(void * sender, ConnectionLogType logType, Data * buffer) { mSession->logConnection(logType, buffer); } @@ -113,6 +113,16 @@ String * SMTPAsyncSession::password() return mSession->password(); } +void SMTPAsyncSession::setOAuth2Token(String * token) +{ + mSession->setOAuth2Token(token); +} + +String * SMTPAsyncSession::OAuth2Token() +{ + return mSession->OAuth2Token(); +} + void SMTPAsyncSession::setAuthType(AuthType authType) { mSession->setAuthType(authType); diff --git a/src/async/smtp/MCSMTPAsyncSession.h b/src/async/smtp/MCSMTPAsyncSession.h index 9fa6dbdf..bbb81737 100644 --- a/src/async/smtp/MCSMTPAsyncSession.h +++ b/src/async/smtp/MCSMTPAsyncSession.h @@ -33,6 +33,9 @@ namespace mailcore { virtual void setPassword(String * password); virtual String * password(); + virtual void setOAuth2Token(String * token); + virtual String * OAuth2Token(); + virtual void setAuthType(AuthType authType); virtual AuthType authType(); diff --git a/src/core/abstract/MCAbstractMessagePart.cc b/src/core/abstract/MCAbstractMessagePart.cc index d2cb232e..b4ec4c9a 100644 --- a/src/core/abstract/MCAbstractMessagePart.cc +++ b/src/core/abstract/MCAbstractMessagePart.cc @@ -16,7 +16,7 @@ AbstractMessagePart::AbstractMessagePart() init(); } -AbstractMessagePart::AbstractMessagePart(AbstractMessagePart * other) +AbstractMessagePart::AbstractMessagePart(AbstractMessagePart * other) : AbstractPart(other) { init(); if (other->mainPart() != NULL) { diff --git a/src/core/basetypes/MCConnectionLogger.h b/src/core/basetypes/MCConnectionLogger.h index dd596857..bdb588bc 100644 --- a/src/core/basetypes/MCConnectionLogger.h +++ b/src/core/basetypes/MCConnectionLogger.h @@ -16,7 +16,6 @@ namespace mailcore { class Data; - class String; enum ConnectionLogType { // Received data diff --git a/src/core/basetypes/MCLog.cc b/src/core/basetypes/MCLog.c index 7db01b41..8744f2dd 100644 --- a/src/core/basetypes/MCLog.cc +++ b/src/core/basetypes/MCLog.c @@ -9,7 +9,7 @@ #include <unistd.h> static pid_t sPid = -1; -bool mailcore::logEnabled = false; +int MCLogEnabled = 0; __attribute__((constructor)) static void initialize() { @@ -20,7 +20,7 @@ static void logInternalv(FILE * file, const char * user, const char * filename, unsigned int line, int dumpStack, const char * format, va_list argp); -void mailcore::logInternal(const char * user, +void MCLogInternal(const char * user, const char * filename, unsigned int line, int dumpStack, @@ -37,7 +37,7 @@ static void logInternalv(FILE * file, const char * user, const char * filename, unsigned int line, int dumpStack, const char * format, va_list argp) { - if (!mailcore::logEnabled) + if (!MCLogEnabled) return; while (1) { diff --git a/src/core/basetypes/MCLog.h b/src/core/basetypes/MCLog.h index b84a2182..6911ab02 100644 --- a/src/core/basetypes/MCLog.h +++ b/src/core/basetypes/MCLog.h @@ -4,26 +4,24 @@ #include <stdio.h> -#ifdef __cplusplus - -#define MCLog(...) mailcore::logInternal(NULL, __FILE__, __LINE__, 0, __VA_ARGS__) - -namespace mailcore { +#define MCLog(...) MCLogInternal(NULL, __FILE__, __LINE__, 0, __VA_ARGS__) - extern bool logEnabled; +extern int MCLogEnabled; #ifndef __printflike #define __printflike(a,b) #endif - void logInternal(const char * user, - const char * filename, - unsigned int line, - int dumpStack, - const char * format, ...) __printflike(5, 6); - +#ifdef __cplusplus +extern "C" { +#endif + void MCLogInternal(const char * user, + const char * filename, + unsigned int line, + int dumpStack, + const char * format, ...) __printflike(5, 6); +#ifdef __cplusplus } - #endif #endif diff --git a/src/core/imap/MCIMAPMessage.cc b/src/core/imap/MCIMAPMessage.cc index e4a3aea5..ee9b6b0f 100644 --- a/src/core/imap/MCIMAPMessage.cc +++ b/src/core/imap/MCIMAPMessage.cc @@ -29,7 +29,7 @@ IMAPMessage::IMAPMessage() init(); } -IMAPMessage::IMAPMessage(IMAPMessage * other) +IMAPMessage::IMAPMessage(IMAPMessage * other) : AbstractMessage(other) { init(); setUid(other->uid()); diff --git a/src/core/imap/MCIMAPSession.cc b/src/core/imap/MCIMAPSession.cc index 8437cded..e013ac75 100644 --- a/src/core/imap/MCIMAPSession.cc +++ b/src/core/imap/MCIMAPSession.cc @@ -687,76 +687,76 @@ void IMAPSession::login(ErrorCode * pError) break; case AuthTypeSASLCRAMMD5: - r = mailimap_authenticate(mImap, "CRAM-MD5", - MCUTF8(mHostname), - NULL, - NULL, - utf8username, utf8username, - utf8password, NULL); - break; + r = mailimap_authenticate(mImap, "CRAM-MD5", + MCUTF8(mHostname), + NULL, + NULL, + utf8username, utf8username, + utf8password, NULL); + break; case AuthTypeSASLPlain: - r = mailimap_authenticate(mImap, "PLAIN", - MCUTF8(mHostname), - NULL, - NULL, - utf8username, utf8username, - utf8password, NULL); - break; + r = mailimap_authenticate(mImap, "PLAIN", + MCUTF8(mHostname), + NULL, + NULL, + utf8username, utf8username, + utf8password, NULL); + break; case AuthTypeSASLGSSAPI: // needs to be tested r = mailimap_authenticate(mImap, "GSSAPI", - MCUTF8(mHostname), - NULL, - NULL, - utf8username, utf8username, - utf8password, NULL /* realm */); + MCUTF8(mHostname), + NULL, + NULL, + utf8username, utf8username, + utf8password, NULL /* realm */); break; case AuthTypeSASLDIGESTMD5: r = mailimap_authenticate(mImap, "DIGEST-MD5", - MCUTF8(mHostname), - NULL, - NULL, - utf8username, utf8username, - utf8password, NULL); + MCUTF8(mHostname), + NULL, + NULL, + utf8username, utf8username, + utf8password, NULL); break; - - case AuthTypeSASLLogin: + + case AuthTypeSASLLogin: r = mailimap_authenticate(mImap, "LOGIN", - MCUTF8(mHostname), - NULL, - NULL, - utf8username, utf8username, - utf8password, NULL); + MCUTF8(mHostname), + NULL, + NULL, + utf8username, utf8username, + utf8password, NULL); break; - - case AuthTypeSASLSRP: + + case AuthTypeSASLSRP: r = mailimap_authenticate(mImap, "SRP", - MCUTF8(mHostname), - NULL, - NULL, - utf8username, utf8username, - utf8password, NULL); + MCUTF8(mHostname), + NULL, + NULL, + utf8username, utf8username, + utf8password, NULL); break; - case AuthTypeSASLNTLM: + case AuthTypeSASLNTLM: r = mailimap_authenticate(mImap, "NTLM", - MCUTF8(mHostname), - NULL, - NULL, - utf8username, utf8username, - utf8password, NULL/* realm */); + MCUTF8(mHostname), + NULL, + NULL, + utf8username, utf8username, + utf8password, NULL/* realm */); break; - case AuthTypeSASLKerberosV4: + case AuthTypeSASLKerberosV4: r = mailimap_authenticate(mImap, "KERBEROS_V4", - MCUTF8(mHostname), - NULL, - NULL, - utf8username, utf8username, - utf8password, NULL/* realm */); + MCUTF8(mHostname), + NULL, + NULL, + utf8username, utf8username, + utf8password, NULL/* realm */); break; case AuthTypeXOAuth2: @@ -773,7 +773,7 @@ void IMAPSession::login(ErrorCode * pError) } else if (hasError(r)) { String * response; - + response = MCSTR(""); if (mImap->imap_response != NULL) { response = String::stringWithUTF8Characters(mImap->imap_response); 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..fe9d6903 100644 --- a/src/core/rfc822/MCMessageBuilder.cc +++ b/src/core/rfc822/MCMessageBuilder.cc @@ -474,7 +474,7 @@ MessageBuilder::MessageBuilder() init(); } -MessageBuilder::MessageBuilder(MessageBuilder * other) +MessageBuilder::MessageBuilder(MessageBuilder * other) : AbstractMessage(other) { init(); setHTMLBody(other->mHTMLBody); @@ -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..3c3037d3 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; @@ -42,7 +43,7 @@ MessageParser::MessageParser(Data * data) mailmessage_free(msg); } -MessageParser::MessageParser(MessageParser * other) +MessageParser::MessageParser(MessageParser * other) : AbstractMessage(other) { init(); MC_SAFE_REPLACE_RETAIN(Data, mData, other->mData); @@ -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/core/smtp/MCSMTPSession.cc b/src/core/smtp/MCSMTPSession.cc index dcbad71e..0febf66e 100644 --- a/src/core/smtp/MCSMTPSession.cc +++ b/src/core/smtp/MCSMTPSession.cc @@ -24,6 +24,7 @@ void SMTPSession::init() mPort = 0; mUsername = NULL; mPassword = NULL; + mOAuth2Token = NULL; mAuthType = AuthTypeSASLNone; mConnectionType = ConnectionTypeClear; mTimeout = 30; @@ -50,6 +51,7 @@ SMTPSession::~SMTPSession() MC_SAFE_RELEASE(mHostname); MC_SAFE_RELEASE(mUsername); MC_SAFE_RELEASE(mPassword); + MC_SAFE_RELEASE(mOAuth2Token); } void SMTPSession::setHostname(String * hostname) @@ -92,6 +94,16 @@ String * SMTPSession::password() return mPassword; } +void SMTPSession::setOAuth2Token(String * token) +{ + MC_SAFE_REPLACE_COPY(String, mOAuth2Token, token); +} + +String * SMTPSession::OAuth2Token() +{ + return mOAuth2Token; +} + void SMTPSession::setAuthType(AuthType authType) { mAuthType = authType; @@ -404,86 +416,90 @@ void SMTPSession::login(ErrorCode * pError) switch (authType()) { case 0: default: - r = mailesmtp_auth_sasl(mSmtp, "PLAIN", - MCUTF8(mHostname), - NULL, - NULL, - MCUTF8(mUsername), MCUTF8(mUsername), - MCUTF8(mPassword), NULL); - break; - + r = mailesmtp_auth_sasl(mSmtp, "PLAIN", + MCUTF8(mHostname), + NULL, + NULL, + MCUTF8(mUsername), MCUTF8(mUsername), + MCUTF8(mPassword), NULL); + break; + case AuthTypeSASLCRAMMD5: - r = mailesmtp_auth_sasl(mSmtp, "CRAM-MD5", - MCUTF8(mHostname), - NULL, - NULL, - MCUTF8(mUsername), MCUTF8(mUsername), - MCUTF8(mPassword), NULL); - break; - + r = mailesmtp_auth_sasl(mSmtp, "CRAM-MD5", + MCUTF8(mHostname), + NULL, + NULL, + MCUTF8(mUsername), MCUTF8(mUsername), + MCUTF8(mPassword), NULL); + break; + case AuthTypeSASLPlain: - r = mailesmtp_auth_sasl(mSmtp, "PLAIN", - MCUTF8(mHostname), - NULL, - NULL, - MCUTF8(mUsername), MCUTF8(mUsername), - MCUTF8(mPassword), NULL); - break; - + r = mailesmtp_auth_sasl(mSmtp, "PLAIN", + MCUTF8(mHostname), + NULL, + NULL, + MCUTF8(mUsername), MCUTF8(mUsername), + MCUTF8(mPassword), NULL); + break; + case AuthTypeSASLGSSAPI: // needs to be tested - r = mailesmtp_auth_sasl(mSmtp, "GSSAPI", - MCUTF8(mHostname), - NULL, - NULL, - MCUTF8(mUsername), MCUTF8(mUsername), - MCUTF8(mPassword), NULL); - break; - + r = mailesmtp_auth_sasl(mSmtp, "GSSAPI", + MCUTF8(mHostname), + NULL, + NULL, + MCUTF8(mUsername), MCUTF8(mUsername), + MCUTF8(mPassword), NULL); + break; + case AuthTypeSASLDIGESTMD5: - r = mailesmtp_auth_sasl(mSmtp, "DIGEST-MD5", - MCUTF8(mHostname), - NULL, - NULL, - MCUTF8(mUsername), MCUTF8(mUsername), - MCUTF8(mPassword), NULL); - break; - + r = mailesmtp_auth_sasl(mSmtp, "DIGEST-MD5", + MCUTF8(mHostname), + NULL, + NULL, + MCUTF8(mUsername), MCUTF8(mUsername), + MCUTF8(mPassword), NULL); + break; + case AuthTypeSASLLogin: - r = mailesmtp_auth_sasl(mSmtp, "LOGIN", - MCUTF8(mHostname), - NULL, - NULL, - MCUTF8(mUsername), MCUTF8(mUsername), - MCUTF8(mPassword), NULL); - break; - + r = mailesmtp_auth_sasl(mSmtp, "LOGIN", + MCUTF8(mHostname), + NULL, + NULL, + MCUTF8(mUsername), MCUTF8(mUsername), + MCUTF8(mPassword), NULL); + break; + case AuthTypeSASLSRP: - r = mailesmtp_auth_sasl(mSmtp, "SRP", - MCUTF8(mHostname), - NULL, - NULL, - MCUTF8(mUsername), MCUTF8(mUsername), - MCUTF8(mPassword), NULL); - break; - + r = mailesmtp_auth_sasl(mSmtp, "SRP", + MCUTF8(mHostname), + NULL, + NULL, + MCUTF8(mUsername), MCUTF8(mUsername), + MCUTF8(mPassword), NULL); + break; + case AuthTypeSASLNTLM: - r = mailesmtp_auth_sasl(mSmtp, "NTLM", - MCUTF8(mHostname), - NULL, - NULL, - MCUTF8(mUsername), MCUTF8(mUsername), - MCUTF8(mPassword), NULL /* realm */); - break; - + r = mailesmtp_auth_sasl(mSmtp, "NTLM", + MCUTF8(mHostname), + NULL, + NULL, + MCUTF8(mUsername), MCUTF8(mUsername), + MCUTF8(mPassword), NULL /* realm */); + break; + case AuthTypeSASLKerberosV4: - r = mailesmtp_auth_sasl(mSmtp, "KERBEROS_V4", - MCUTF8(mHostname), - NULL, - NULL, - MCUTF8(mUsername), MCUTF8(mUsername), - MCUTF8(mPassword), NULL /* realm */); - break; + r = mailesmtp_auth_sasl(mSmtp, "KERBEROS_V4", + MCUTF8(mHostname), + NULL, + NULL, + MCUTF8(mUsername), MCUTF8(mUsername), + MCUTF8(mPassword), NULL /* realm */); + break; + + case AuthTypeXOAuth2: + r = mailsmtp_oauth2_authenticate(mSmtp, MCUTF8(mUsername), MCUTF8(mOAuth2Token)); + break; } if (r == MAILSMTP_ERROR_STREAM) { * pError = ErrorConnection; diff --git a/src/core/smtp/MCSMTPSession.h b/src/core/smtp/MCSMTPSession.h index 491ecb07..3d066a6c 100644 --- a/src/core/smtp/MCSMTPSession.h +++ b/src/core/smtp/MCSMTPSession.h @@ -30,6 +30,11 @@ namespace mailcore { virtual void setPassword(String * password); virtual String * password(); + // To authenticate using OAuth2, username and oauth2token should be set. + // auth type to use is AuthTypeOAuth2. + virtual void setOAuth2Token(String * token); + virtual String * OAuth2Token(); + virtual void setAuthType(AuthType authType); virtual AuthType authType(); @@ -62,6 +67,7 @@ namespace mailcore { unsigned int mPort; String * mUsername; String * mPassword; + String * mOAuth2Token; AuthType mAuthType; ConnectionType mConnectionType; time_t mTimeout; 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 43f366e6..1dff0f1f 100644 --- a/src/objc/imap/MCOIMAPSession.mm +++ b/src/objc/imap/MCOIMAPSession.mm @@ -35,7 +35,7 @@ public: mSession = session; } - virtual void log(void * context, void * sender, ConnectionLogType logType, Data * data) + virtual void log(void * sender, ConnectionLogType logType, Data * data) { [mSession _logWithSender:sender connectionType:(MCOConnectionLogType)logType data:MCO_TO_OBJC(data)]; } @@ -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/pop/MCOPOPSession.mm b/src/objc/pop/MCOPOPSession.mm index 42c76646..fb48cb1e 100644 --- a/src/objc/pop/MCOPOPSession.mm +++ b/src/objc/pop/MCOPOPSession.mm @@ -31,7 +31,7 @@ public: mSession = session; } - virtual void log(void * context, void * sender, ConnectionLogType logType, Data * data) + virtual void log(void * sender, ConnectionLogType logType, Data * data) { [mSession _logWithSender:sender connectionType:(MCOConnectionLogType)logType data:MCO_TO_OBJC(data)]; } 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 fac86b89..5a009bb7 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 7d7f9fcb..8e3f1261 100644 --- a/src/objc/rfc822/MCOMessageParser.mm +++ b/src/objc/rfc822/MCOMessageParser.mm @@ -69,4 +69,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/smtp/MCOSMTPSession.h b/src/objc/smtp/MCOSMTPSession.h index 44d37942..bb7c5f57 100644 --- a/src/objc/smtp/MCOSMTPSession.h +++ b/src/objc/smtp/MCOSMTPSession.h @@ -39,6 +39,9 @@ /** This is the password of the account. */ @property (nonatomic, copy) NSString * password; +/** This is the OAuth2 token. */ +@property (nonatomic, copy) NSString *OAuth2Token; + /** This is the authentication type to use to connect. `MCOAuthTypeSASLNone` means that it uses the clear-text is used (and is the default). diff --git a/src/objc/smtp/MCOSMTPSession.mm b/src/objc/smtp/MCOSMTPSession.mm index 1538d53a..c9f9f0fc 100644 --- a/src/objc/smtp/MCOSMTPSession.mm +++ b/src/objc/smtp/MCOSMTPSession.mm @@ -32,7 +32,7 @@ public: mSession = session; } - virtual void log(void * context, void * sender, ConnectionLogType logType, Data * data) + virtual void log(void * sender, ConnectionLogType logType, Data * data) { [mSession _logWithSender:sender connectionType:(MCOConnectionLogType)logType data:MCO_TO_OBJC(data)]; } @@ -74,6 +74,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/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 2201d6d5..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() @@ -351,7 +352,7 @@ void testAll() displayName = MCSTR("My Email"); mailcore::AutoreleasePool * pool = new mailcore::AutoreleasePool(); - mailcore::logEnabled = true; + MCLogEnabled = 1; mailstream_debug = 1; //mailcore::Data * data = testMessageBuilder(); @@ -365,7 +366,7 @@ void testAll() //testAddresses(); //testAttachments(); //testProviders(); - testObjC(); + //testObjC(); MCLog("pool release"); pool->release(); |