diff options
author | 2013-07-04 13:28:54 -0600 | |
---|---|---|
committer | 2013-07-04 13:28:54 -0600 | |
commit | 82b3ca2801cc99fae8b32e162346283a63bef114 (patch) | |
tree | bfc59613257d61f4bdd93e690593f1103fb503cc | |
parent | d90bb3ec8178d5190c829d82750fea1f8ef0d5ef (diff) | |
parent | 2a36c7acd33ac51be81209d0baac67c54bbd0800 (diff) |
Merge remote-tracking branch 'upstream/master'
21 files changed, 74 insertions, 36 deletions
diff --git a/build-mac/mailcore2.xcodeproj/project.pbxproj b/build-mac/mailcore2.xcodeproj/project.pbxproj index c1b46c92..cedef738 100644 --- a/build-mac/mailcore2.xcodeproj/project.pbxproj +++ b/build-mac/mailcore2.xcodeproj/project.pbxproj @@ -125,7 +125,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 +449,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 */; }; @@ -1206,7 +1206,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>"; }; @@ -1802,7 +1802,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 */, @@ -2345,7 +2345,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 */, @@ -2527,7 +2527,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..ea109b5d 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=517a7fb7c47d925f67cc48ddf9636170c74ecd9e pushd `dirname $0` > /dev/null scriptpath=`pwd` diff --git a/scripts/prepare-libetpan-macos.sh b/scripts/prepare-libetpan-macos.sh index 81013fa6..c8eaf26b 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=517a7fb7c47d925f67cc48ddf9636170c74ecd9e 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/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..38d57756 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); } 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..de75314f 100644 --- a/src/core/basetypes/MCLog.h +++ b/src/core/basetypes/MCLog.h @@ -6,22 +6,28 @@ #ifdef __cplusplus -#define MCLog(...) mailcore::logInternal(NULL, __FILE__, __LINE__, 0, __VA_ARGS__) +#define MCLog(...) MCLogInternal(NULL, __FILE__, __LINE__, 0, __VA_ARGS__) namespace mailcore { - 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/basetypes/MCString.cc b/src/core/basetypes/MCString.cc index 766ecaab..034e3299 100644 --- a/src/core/basetypes/MCString.cc +++ b/src/core/basetypes/MCString.cc @@ -1131,7 +1131,7 @@ void String::appendBytes(const char * bytes, unsigned int length, const char * c CFStringEncoding encoding = CFStringConvertIANACharSetNameToEncoding(encodingName); CFStringRef cfStr = CFStringCreateWithBytes(NULL, (const UInt8 *) bytes, (CFIndex) length, encoding, false); if (cfStr != NULL) { - CFDataRef data = CFStringCreateExternalRepresentation(NULL, cfStr, kCFStringEncodingUTF16, '_'); + CFDataRef data = CFStringCreateExternalRepresentation(NULL, cfStr, kCFStringEncodingUTF16LE, '_'); if (data != NULL) { appendCharactersLength((const UChar *) CFDataGetBytePtr(data), (unsigned int) CFDataGetLength(data) / 2); CFRelease(data); @@ -1841,7 +1841,7 @@ Data * String::dataUsingEncoding(const char * charset) CFStringRef encodingName = CFStringCreateWithCString(NULL, charset, kCFStringEncodingUTF8); CFStringEncoding encoding = CFStringConvertIANACharSetNameToEncoding(encodingName); CFStringRef cfStr = CFStringCreateWithBytes(NULL, (const UInt8 *) mUnicodeChars, - (CFIndex) mLength * sizeof(* mUnicodeChars), kCFStringEncodingUTF16, false); + (CFIndex) mLength * sizeof(* mUnicodeChars), kCFStringEncodingUTF16LE, false); if (cfStr != NULL) { CFDataRef cfData = CFStringCreateExternalRepresentation(NULL, cfStr, encoding, '_'); if (cfData != NULL) { diff --git a/src/objc/abstract/MCOAbstractMessage.mm b/src/objc/abstract/MCOAbstractMessage.mm index 6fedcc8a..05530845 100644 --- a/src/objc/abstract/MCOAbstractMessage.mm +++ b/src/objc/abstract/MCOAbstractMessage.mm @@ -28,6 +28,12 @@ return _message; } +- (id) init +{ + MCAssert(0); + return nil; +} + - (id) initWithMCMessage:(mailcore::AbstractMessage *)message { self = [super init]; @@ -40,7 +46,7 @@ - (void) dealloc { - _message->release(); + MC_SAFE_RELEASE(_message); [super dealloc]; } diff --git a/src/objc/abstract/MCOAbstractPart.mm b/src/objc/abstract/MCOAbstractPart.mm index 8b2b008d..7a37dcaf 100644 --- a/src/objc/abstract/MCOAbstractPart.mm +++ b/src/objc/abstract/MCOAbstractPart.mm @@ -27,6 +27,12 @@ return _part; } +- (id) init +{ + MCAssert(0); + return nil; +} + - (id) initWithMCPart:(mailcore::AbstractPart *)part { self = [super init]; @@ -39,7 +45,7 @@ - (void) dealloc { - _part->release(); + MC_SAFE_RELEASE(_part); [super dealloc]; } diff --git a/src/objc/abstract/MCOConstants.h b/src/objc/abstract/MCOConstants.h index a1916ef1..5ec21422 100644 --- a/src/objc/abstract/MCOConstants.h +++ b/src/objc/abstract/MCOConstants.h @@ -33,6 +33,8 @@ typedef enum { MCOAuthTypeSASLNTLM = 1 << 6, /** Kerberos 4 authentication.*/ MCOAuthTypeSASLKerberosV4 = 1 << 7, + /** OAuth2 authentication.*/ + MCOAuthTypeXOAuth2 = 1 << 8, } MCOAuthType; /** It's the IMAP flags of the folder.*/ diff --git a/src/objc/imap/MCOIMAPSession.mm b/src/objc/imap/MCOIMAPSession.mm index 43f366e6..0c23f1e2 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)]; } 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/smtp/MCOSMTPSendOperation.mm b/src/objc/smtp/MCOSMTPSendOperation.mm index 776f7270..8a7d5b04 100644 --- a/src/objc/smtp/MCOSMTPSendOperation.mm +++ b/src/objc/smtp/MCOSMTPSendOperation.mm @@ -80,6 +80,18 @@ private: [self start]; } +// This method needs to be duplicated from MCOSMTPOperation since _completionBlock +// references the instance of this subclass and not the one from MCOSMTPOperation. +- (void)operationCompleted { + if (_completionBlock == NULL) + return; + + NSError * error = [NSError mco_errorWithErrorCode:MCO_NATIVE_INSTANCE->error()]; + _completionBlock(error); + [_completionBlock release]; + _completionBlock = NULL; +} + - (void) bodyProgress:(unsigned int)current maximum:(unsigned int)maximum { if (_progress != NULL) { diff --git a/src/objc/smtp/MCOSMTPSession.mm b/src/objc/smtp/MCOSMTPSession.mm index 1538d53a..1cadf4ad 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)]; } diff --git a/tests/test-all.mm b/tests/test-all.mm index 2201d6d5..fdb0888c 100644 --- a/tests/test-all.mm +++ b/tests/test-all.mm @@ -351,7 +351,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(); |