diff options
author | Maksim Bauer <m.bauer@zertificon.com> | 2014-08-01 13:02:10 +0200 |
---|---|---|
committer | Maksim Bauer <m.bauer@zertificon.com> | 2014-08-01 13:02:10 +0200 |
commit | 19e87b40bd40b6fc6cf7607763bf22500122765c (patch) | |
tree | 6328cde6e3902609eac6dca2b0504b3db5c06807 | |
parent | a54b838b7f14055716b4da64ea18c5652136d052 (diff) | |
parent | 6f5f44ff92337b6f34e6f6d10d9135661b164b0c (diff) |
Merge remote-tracking branch 'upstream/master'
Conflicts:
src/objc/abstract/MCOAbstractPart.h
23 files changed, 377 insertions, 538 deletions
@@ -33,8 +33,8 @@ MailCore 2 provides a simple and asynchronous Objective-C API to work with the e * Add `libMailCore-ios.a` * Add `CFNetwork.framework` * Add `Security.framework` - * Set 'Other Linker Flags': `-lctemplate-ios -letpan-ios -licudata -licui18n -licuuc -lxml2 -lsasl2 -liconv -ltidy -lz` `-licucore -lstdc++ -stdlib=libstdc++ -ObjC` - * Make sure to use GNU C++ standard library. In Build Settings, locate 'C++ Standard Library', and select `libstdc++`. + * Set 'Other Linker Flags': `-lctemplate-ios -letpan-ios -licudata -licui18n -licuuc -lxml2 -lsasl2 -liconv -ltidy -lz` `-licucore -lc++ -stdlib=libc++ -ObjC` + * Make sure to use LLVM C++ standard library. Open Build Settings, scroll down to 'C++ Standard Library', and select `libc++`. * In Build Phases, add a Target Dependency of `static mailcore2 ios`. 6. Profit. diff --git a/build-mac/mailcore2.xcodeproj/project.pbxproj b/build-mac/mailcore2.xcodeproj/project.pbxproj index 4ce9c632..1755556c 100755 --- a/build-mac/mailcore2.xcodeproj/project.pbxproj +++ b/build-mac/mailcore2.xcodeproj/project.pbxproj @@ -3074,8 +3074,6 @@ C64EA53C169E772200778456 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; - CLANG_CXX_LIBRARY = "libc++"; COMBINE_HIDPI_IMAGES = YES; EXECUTABLE_PREFIX = lib; PRODUCT_NAME = MailCore; @@ -3086,8 +3084,6 @@ C64EA53D169E772200778456 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; - CLANG_CXX_LIBRARY = "libc++"; COMBINE_HIDPI_IMAGES = YES; EXECUTABLE_PREFIX = lib; PRODUCT_NAME = MailCore; @@ -3114,8 +3110,6 @@ C6A81BAA1706840C00882C15 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libstdc++"; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INT_CONVERSION = YES; @@ -3150,8 +3144,6 @@ C6A81BAB1706840C00882C15 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libstdc++"; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INT_CONVERSION = YES; @@ -3188,8 +3180,6 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libstdc++"; DEAD_CODE_STRIPPING = NO; EXECUTABLE_PREFIX = lib; ONLY_ACTIVE_ARCH = NO; @@ -3203,8 +3193,6 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libstdc++"; DEAD_CODE_STRIPPING = NO; EXECUTABLE_PREFIX = lib; ONLY_ACTIVE_ARCH = NO; @@ -3217,8 +3205,6 @@ C6BD289E170BD71100A91AC1 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; - CLANG_CXX_LIBRARY = "libc++"; COMBINE_HIDPI_IMAGES = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; @@ -3250,8 +3236,6 @@ C6BD289F170BD71100A91AC1 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; - CLANG_CXX_LIBRARY = "libc++"; COMBINE_HIDPI_IMAGES = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; diff --git a/example/ios/iOS UI Test/iOS UI Test.xcodeproj/project.pbxproj b/example/ios/iOS UI Test/iOS UI Test.xcodeproj/project.pbxproj index 491161bd..bb9f0ea1 100644 --- a/example/ios/iOS UI Test/iOS UI Test.xcodeproj/project.pbxproj +++ b/example/ios/iOS UI Test/iOS UI Test.xcodeproj/project.pbxproj @@ -471,7 +471,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_OBJC_ARC = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; @@ -501,7 +501,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_OBJC_ARC = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; @@ -525,7 +525,7 @@ AB9EAE29170368F000D750C7 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - CLANG_CXX_LIBRARY = "libstdc++"; + CLANG_CXX_LIBRARY = "libc++"; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "iOS UI Test/iOS UI Test-Prefix.pch"; INFOPLIST_FILE = "iOS UI Test/iOS UI Test-Info.plist"; @@ -540,7 +540,7 @@ "-liconv", "-all_load", "-ltidy", - "-lstdc++", + "-lc++", "-lz", "-licucore", ); @@ -552,7 +552,7 @@ AB9EAE2A170368F000D750C7 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - CLANG_CXX_LIBRARY = "libstdc++"; + CLANG_CXX_LIBRARY = "libc++"; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "iOS UI Test/iOS UI Test-Prefix.pch"; INFOPLIST_FILE = "iOS UI Test/iOS UI Test-Info.plist"; @@ -567,7 +567,7 @@ "-liconv", "-all_load", "-ltidy", - "-lstdc++", + "-lc++", "-lz", "-licucore", ); diff --git a/example/ios/iOS UI Test/iOS UI Test/MCTMsgViewController.mm b/example/ios/iOS UI Test/iOS UI Test/MCTMsgViewController.mm index ca3aecfc..ed41fd87 100755 --- a/example/ios/iOS UI Test/iOS UI Test/MCTMsgViewController.mm +++ b/example/ios/iOS UI Test/iOS UI Test/MCTMsgViewController.mm @@ -249,9 +249,9 @@ typedef void (^DownloadCallback)(NSError * error); return nil; info = [[NSMutableDictionary alloc] init]; - [info setObject:(id) kCFBooleanTrue forKey:(id) kCGImageSourceCreateThumbnailWithTransform]; - [info setObject:(id) kCFBooleanTrue forKey:(id) kCGImageSourceCreateThumbnailFromImageAlways]; - [info setObject:(id) [NSNumber numberWithFloat:(float) IMAGE_PREVIEW_WIDTH] forKey:(id) kCGImageSourceThumbnailMaxPixelSize]; + [info setObject:(id) kCFBooleanTrue forKey:(__bridge id) kCGImageSourceCreateThumbnailWithTransform]; + [info setObject:(id) kCFBooleanTrue forKey:(__bridge id) kCGImageSourceCreateThumbnailFromImageAlways]; + [info setObject:(id) [NSNumber numberWithFloat:(float) IMAGE_PREVIEW_WIDTH] forKey:(__bridge id) kCGImageSourceThumbnailMaxPixelSize]; thumbnail = CGImageSourceCreateThumbnailAtIndex(imageSource, 0, (__bridge CFDictionaryRef) info); CGImageDestinationRef destination; diff --git a/scripts/build-mailcore2-ios.sh b/scripts/build-mailcore2-ios.sh index 77b2bf46..b6d3bfe7 100755 --- a/scripts/build-mailcore2-ios.sh +++ b/scripts/build-mailcore2-ios.sh @@ -2,16 +2,16 @@ if xcodebuild -showsdks|grep iphoneos6.1 >/dev/null ; then sdkversion=6.1 - devicearchs="armv7 armv7s" + devicearchs="armv7 armv7s" elif xcodebuild -showsdks|grep iphoneos7.0 >/dev/null ; then sdkversion=7.0 - devicearchs="armv7 armv7s arm64" + devicearchs="armv7 armv7s arm64" elif xcodebuild -showsdks|grep iphoneos7.1 >/dev/null ; then - sdkversion=7.1 - devicearchs="armv7 armv7s arm64" + sdkversion=7.1 + devicearchs="armv7 armv7s arm64" elif xcodebuild -showsdks|grep iphoneos8.0 >/dev/null ; then - sdkversion=8.0 - devicearchs="armv7 armv7s arm64" + sdkversion=8.0 + devicearchs="armv7 armv7s arm64" else echo SDK not found exit 1 diff --git a/scripts/prepare-ctemplate-ios.sh b/scripts/prepare-ctemplate-ios.sh index 3b6c0e0b..d23c10fd 100755 --- a/scripts/prepare-ctemplate-ios.sh +++ b/scripts/prepare-ctemplate-ios.sh @@ -49,7 +49,7 @@ else cd ctemplate fi version=`git rev-parse HEAD | cut -c1-10` -build_version="$version~1" +build_version="$version~2" if test -f "$resultdir/ctemplate-ios-$build_version.zip" ; then echo install from cache @@ -71,12 +71,12 @@ cp -R "$builddir/downloads/ctemplate" "$srcdir/ctemplate" echo building ctemplate cd "$srcdir/ctemplate" -TOOLCHAIN=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin +TOOLCHAIN=`xcode-select -p`/Toolchains/XcodeDefault.xctoolchain/usr/bin export CC=$TOOLCHAIN/clang export CXX=$TOOLCHAIN/clang++ sdk="iphoneos$sdkversion" -sysroot="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS$sdkversion.sdk" +sysroot="`xcode-select -p`/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS$sdkversion.sdk" ARCH=arm for MARCH in $MARCHS; do @@ -84,8 +84,8 @@ for MARCH in $MARCHS; do echo "$logdir/ctemplate-build.log" export CPPFLAGS="-arch ${MARCH} -isysroot $sysroot -miphoneos-version-min=$sdkversion" export CFLAGS="$CPPFLAGS" - export CXXFLAGS="$CFLAGS -stdlib=libstdc++ -std=gnu++11" - export LDFLAGS="-lstdc++ -stdlib=libstdc++" + export CXXFLAGS="$CFLAGS -stdlib=libc++" + export LDFLAGS="-lstdc++ -stdlib=libc++" ./configure --host=${ARCH} --disable-shared --disable-dependency-tracking >> "$logdir/ctemplate-build.log" make >> "$logdir/ctemplate-build.log" @@ -105,7 +105,7 @@ for MARCH in $MARCHS; do done sdk="iphonesimulator$sdkversion" -sysroot="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator$sdkversion.sdk" +sysroot="`xcode-select -p`/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator$sdkversion.sdk" ARCH=i386 MARCHS="i386 x86_64" @@ -115,8 +115,8 @@ for MARCH in $MARCHS; do echo "$logdir/ctemplate-build.log" export CPPFLAGS="-arch ${MARCH} -isysroot $sysroot -miphoneos-version-min=$sdkversion" export CFLAGS="$CPPFLAGS" - export CXXFLAGS="$CFLAGS -stdlib=libstdc++ -std=gnu++11" - export LDFLAGS="-lstdc++ -stdlib=libstdc++" + export CXXFLAGS="$CFLAGS -stdlib=libc++" + export LDFLAGS="-lstdc++ -stdlib=libc++" ./configure --host=${MARCH} --disable-shared --disable-dependency-tracking >> "$logdir/ctemplate-build.log" make >> "$logdir/ctemplate-build.log" diff --git a/scripts/prepare-icu4c-ios.sh b/scripts/prepare-icu4c-ios.sh index f214399b..1e84686a 100755 --- a/scripts/prepare-icu4c-ios.sh +++ b/scripts/prepare-icu4c-ios.sh @@ -19,10 +19,10 @@ fi versionfolder='51.1' version='51_1' -build_version="$version~2" +build_version="$version~3" url="http://download.icu-project.org/files/icu4c/$versionfolder/icu4c-$version-src.tgz" package_filename="icu4c-$version-src.tgz" -sysrootpath="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk" +sysrootpath="`xcode-select -p`/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk" enable_icu_data=0 pushd `dirname $0` > /dev/null @@ -77,10 +77,10 @@ cd icu patch -p1 < "$scriptpath/icu4c-ios.patch" cd .. -TOOLCHAIN=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin +TOOLCHAIN=`xcode-select -p`/Toolchains/XcodeDefault.xctoolchain/usr/bin export CC=$TOOLCHAIN/clang export CXX=$TOOLCHAIN/clang++ -export SYSROOTPATH="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk" +export SYSROOTPATH="`xcode-select -p`/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk" export CPPFLAGS="-isysroot $SYSROOTPATH" export CFLAGS="$CPPFLAGS" export LDLAGS="-lc++ -isysroot $SYSROOTPATH" @@ -100,20 +100,22 @@ if xcodebuild -showsdks|grep iphoneos7.0 >/dev/null ; then MARCHS="armv7 armv7s arm64" elif xcodebuild -showsdks|grep iphoneos6.1 >/dev/null ; then MARCHS="armv7 armv7s" +elif xcodebuild -showsdks|grep iphoneos8.0 >/dev/null ; then + MARCHS="armv7 armv7s arm64" else echo SDK not found exit 1 fi iphonesdk="iphoneos$sdkversion" -sysroot="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS$sdkversion.sdk" +sysroot="`xcode-select -p`/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS$sdkversion.sdk" cd "$srcdir/icu/source" for MARCH in $MARCHS; do export CPPFLAGS="-arch ${MARCH} -isysroot ${sysroot} -DUCONFIG_NO_FILE_IO=1 -miphoneos-version-min=$sdkversion" export CFLAGS="$CPPFLAGS" - export CXXFLAGS="$CFLAGS -stdlib=libstdc++ -std=gnu++11" - export LDFLAGS="-lstdc++ -stdlib=libstdc++ -isysroot ${sysroot}" + export CXXFLAGS="$CFLAGS -stdlib=libc++ -std=gnu++11" + export LDFLAGS="-lstdc++ -stdlib=libc++ -isysroot ${sysroot}" echo building $MARCH @@ -129,7 +131,7 @@ for MARCH in $MARCHS; do done sdk="iphonesimulator$sdkversion" -sysroot="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator$sdkversion.sdk" +sysroot="`xcode-select -p`/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator$sdkversion.sdk" ARCH=i386 MARCHS="x86_64 i386" @@ -138,8 +140,8 @@ cd "$srcdir/icu/source" for MARCH in $MARCHS; do export CPPFLAGS="-arch ${MARCH} -isysroot ${sysroot} -DUCONFIG_NO_FILE_IO=1 -miphoneos-version-min=$sdkversion" export CFLAGS="$CPPFLAGS" - export CXXFLAGS="$CFLAGS -stdlib=libstdc++ -std=gnu++11" - export LDFLAGS="-lstdc++ -stdlib=libstdc++" + export CXXFLAGS="$CFLAGS -stdlib=libc++ -std=gnu++11" + export LDFLAGS="-lstdc++ -stdlib=libc++" echo building $MARCH diff --git a/scripts/prepare-libetpan-ios.sh b/scripts/prepare-libetpan-ios.sh index 180e3721..2e5caf40 100755 --- a/scripts/prepare-libetpan-ios.sh +++ b/scripts/prepare-libetpan-ios.sh @@ -18,7 +18,7 @@ else fi url="https://github.com/dinhviethoa/libetpan.git" -rev=01b3b3b83d2b8651c0279018d4e48061509494eb +rev=35c5c939fe4d5d7072b1629638ee96f2e6a4bbd1 pushd `dirname $0` > /dev/null scriptpath=`pwd` diff --git a/scripts/prepare-libetpan-macos.sh b/scripts/prepare-libetpan-macos.sh index 37405416..e2cb217d 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=01b3b3b83d2b8651c0279018d4e48061509494eb +rev=35c5c939fe4d5d7072b1629638ee96f2e6a4bbd1 pushd `dirname $0` > /dev/null scriptpath=`pwd` diff --git a/src/async/imap/MCIMAPAsyncConnection.cc b/src/async/imap/MCIMAPAsyncConnection.cc index 2f685ca3..3a6508d6 100755 --- a/src/async/imap/MCIMAPAsyncConnection.cc +++ b/src/async/imap/MCIMAPAsyncConnection.cc @@ -249,295 +249,6 @@ IMAPIdentity * IMAPAsyncConnection::clientIdentity() return mClientIdentity; } -IMAPFolderInfoOperation * IMAPAsyncConnection::folderInfoOperation(String * folder) -{ - IMAPFolderInfoOperation * op = new IMAPFolderInfoOperation(); - op->setSession(this); - op->setFolder(folder); - op->autorelease(); - return op; -} - -IMAPFolderStatusOperation * IMAPAsyncConnection::folderStatusOperation(String * folder) -{ - IMAPFolderStatusOperation * op = new IMAPFolderStatusOperation(); - op->setSession(this); - op->setFolder(folder); - op->autorelease(); - return op; -} - -IMAPFetchFoldersOperation * IMAPAsyncConnection::fetchSubscribedFoldersOperation() -{ - IMAPFetchFoldersOperation * op = new IMAPFetchFoldersOperation(); - op->setSession(this); - op->setFetchSubscribedEnabled(true); - op->autorelease(); - return op; -} - -IMAPFetchFoldersOperation * IMAPAsyncConnection::fetchAllFoldersOperation() -{ - IMAPFetchFoldersOperation * op = new IMAPFetchFoldersOperation(); - op->setSession(this); - op->autorelease(); - return op; -} - -IMAPOperation * IMAPAsyncConnection::renameFolderOperation(String * folder, String * otherName) -{ - IMAPRenameFolderOperation * op = new IMAPRenameFolderOperation(); - op->setSession(this); - op->setFolder(folder); - op->setOtherName(otherName); - op->autorelease(); - return op; -} - -IMAPOperation * IMAPAsyncConnection::deleteFolderOperation(String * folder) -{ - IMAPDeleteFolderOperation * op = new IMAPDeleteFolderOperation(); - op->setSession(this); - op->setFolder(folder); - op->autorelease(); - return op; -} - -IMAPOperation * IMAPAsyncConnection::createFolderOperation(String * folder) -{ - IMAPCreateFolderOperation * op = new IMAPCreateFolderOperation(); - op->setSession(this); - op->setFolder(folder); - op->autorelease(); - return op; -} - -IMAPOperation * IMAPAsyncConnection::subscribeFolderOperation(String * folder) -{ - IMAPSubscribeFolderOperation * op = new IMAPSubscribeFolderOperation(); - op->setSession(this); - op->setFolder(folder); - op->autorelease(); - return op; -} - -IMAPOperation * IMAPAsyncConnection::unsubscribeFolderOperation(String * folder) -{ - IMAPSubscribeFolderOperation * op = new IMAPSubscribeFolderOperation(); - op->setSession(this); - op->setUnsubscribeEnabled(true); - op->setFolder(folder); - op->autorelease(); - return op; -} - -IMAPAppendMessageOperation * IMAPAsyncConnection::appendMessageOperation(String * folder, Data * messageData, MessageFlag flags, Array * customFlags) -{ - IMAPAppendMessageOperation * op = new IMAPAppendMessageOperation(); - op->setSession(this); - op->setFolder(folder); - op->setMessageData(messageData); - op->setFlags(flags); - op->setCustomFlags(customFlags); - op->autorelease(); - return op; -} - -IMAPCopyMessagesOperation * IMAPAsyncConnection::copyMessagesOperation(String * folder, IndexSet * uids, String * destFolder) -{ - IMAPCopyMessagesOperation * op = new IMAPCopyMessagesOperation(); - op->setSession(this); - op->setFolder(folder); - op->setUids(uids); - op->setDestFolder(destFolder); - op->autorelease(); - return op; -} - -IMAPOperation * IMAPAsyncConnection::expungeOperation(String * folder) -{ - IMAPExpungeOperation * op = new IMAPExpungeOperation(); - op->setSession(this); - op->setFolder(folder); - op->autorelease(); - return op; -} - -IMAPFetchMessagesOperation * IMAPAsyncConnection::fetchMessagesByUIDOperation(String * folder, IMAPMessagesRequestKind requestKind, - IndexSet * uids) -{ - IMAPFetchMessagesOperation * op = new IMAPFetchMessagesOperation(); - op->setSession(this); - op->setFolder(folder); - op->setKind(requestKind); - op->setFetchByUidEnabled(true); - op->setIndexes(uids); - op->autorelease(); - return op; -} - -IMAPFetchMessagesOperation * IMAPAsyncConnection::fetchMessagesByNumberOperation(String * folder, IMAPMessagesRequestKind requestKind, - IndexSet * numbers) -{ - IMAPFetchMessagesOperation * op = new IMAPFetchMessagesOperation(); - op->setSession(this); - op->setFolder(folder); - op->setKind(requestKind); - op->setIndexes(numbers); - op->autorelease(); - return op; -} - -IMAPFetchMessagesOperation * IMAPAsyncConnection::syncMessagesByUID(String * folder, IMAPMessagesRequestKind requestKind, - IndexSet * uids, uint64_t modSeq) -{ - IMAPFetchMessagesOperation * op = new IMAPFetchMessagesOperation(); - op->setSession(this); - op->setFolder(folder); - op->setKind(requestKind); - op->setFetchByUidEnabled(true); - op->setIndexes(uids); - op->setModSequenceValue(modSeq); - op->autorelease(); - return op; -} - -IMAPFetchContentOperation * IMAPAsyncConnection::fetchMessageByUIDOperation(String * folder, uint32_t uid) -{ - IMAPFetchContentOperation * op = new IMAPFetchContentOperation(); - op->setSession(this); - op->setFolder(folder); - op->setUid(uid); - op->autorelease(); - return op; -} - -IMAPFetchContentOperation * IMAPAsyncConnection::fetchMessageAttachmentByUIDOperation(String * folder, uint32_t uid, String * partID, - Encoding encoding) -{ - IMAPFetchContentOperation * op = new IMAPFetchContentOperation(); - op->setSession(this); - op->setFolder(folder); - op->setUid(uid); - op->setPartID(partID); - op->setEncoding(encoding); - op->autorelease(); - return op; -} - -IMAPOperation * IMAPAsyncConnection::storeFlagsOperation(String * folder, IndexSet * uids, IMAPStoreFlagsRequestKind kind, MessageFlag flags, Array * customFlags) -{ - IMAPStoreFlagsOperation * op = new IMAPStoreFlagsOperation(); - op->setSession(this); - op->setFolder(folder); - op->setUids(uids); - op->setKind(kind); - op->setFlags(flags); - op->setCustomFlags(customFlags); - op->autorelease(); - return op; -} - -IMAPOperation * IMAPAsyncConnection::storeLabelsOperation(String * folder, IndexSet * uids, IMAPStoreFlagsRequestKind kind, Array * labels) -{ - IMAPStoreLabelsOperation * op = new IMAPStoreLabelsOperation(); - op->setSession(this); - op->setFolder(folder); - op->setUids(uids); - op->setKind(kind); - op->setLabels(labels); - op->autorelease(); - return op; -} - -IMAPSearchOperation * IMAPAsyncConnection::searchOperation(String * folder, IMAPSearchKind kind, String * searchString) -{ - IMAPSearchOperation * op = new IMAPSearchOperation(); - op->setSession(this); - op->setFolder(folder); - op->setSearchKind(kind); - op->setSearchString(searchString); - op->autorelease(); - return op; -} - -IMAPSearchOperation * IMAPAsyncConnection::searchOperation(String * folder, IMAPSearchExpression * expression) -{ - IMAPSearchOperation * op = new IMAPSearchOperation(); - op->setSession(this); - op->setFolder(folder); - op->setSearchExpression(expression); - op->autorelease(); - return op; -} - -IMAPIdleOperation * IMAPAsyncConnection::idleOperation(String * folder, uint32_t lastKnownUID) -{ - IMAPIdleOperation * op = new IMAPIdleOperation(); - op->setSession(this); - op->setFolder(folder); - op->setLastKnownUID(lastKnownUID); - op->autorelease(); - return op; -} - -IMAPFetchNamespaceOperation * IMAPAsyncConnection::fetchNamespaceOperation() -{ - IMAPFetchNamespaceOperation * op = new IMAPFetchNamespaceOperation(); - op->setSession(this); - op->autorelease(); - return op; -} - -IMAPIdentityOperation * IMAPAsyncConnection::identityOperation(IMAPIdentity * identity) -{ - IMAPIdentityOperation * op = new IMAPIdentityOperation(); - op->setSession(this); - op->setClientIdentity(identity); - op->autorelease(); - return op; -} - -IMAPOperation * IMAPAsyncConnection::connectOperation() -{ - IMAPConnectOperation * op = new IMAPConnectOperation(); - op->setSession(this); - op->autorelease(); - return op; -} - -IMAPOperation * IMAPAsyncConnection::checkAccountOperation() -{ - IMAPCheckAccountOperation * op = new IMAPCheckAccountOperation(); - op->setSession(this); - op->autorelease(); - return op; -} - -IMAPOperation * IMAPAsyncConnection::noopOperation() -{ - IMAPNoopOperation * op = new IMAPNoopOperation(); - op->setSession(this); - op->autorelease(); - return op; -} - -IMAPCapabilityOperation * IMAPAsyncConnection::capabilityOperation() -{ - IMAPCapabilityOperation * op = new IMAPCapabilityOperation(); - op->setSession(this); - op->autorelease(); - return op; -} - -IMAPQuotaOperation * IMAPAsyncConnection::quotaOperation() -{ - IMAPQuotaOperation * op = new IMAPQuotaOperation(); - op->setSession(this); - op->autorelease(); - return op; -} - IMAPOperation * IMAPAsyncConnection::disconnectOperation() { IMAPDisconnectOperation * op = new IMAPDisconnectOperation(); @@ -679,46 +390,6 @@ void IMAPAsyncConnection::logConnection(ConnectionLogType logType, Data * buffer pthread_mutex_unlock(&mConnectionLoggerLock); } -IMAPMessageRenderingOperation * IMAPAsyncConnection::renderingOperation(IMAPMessage * message, - String * folder, - IMAPMessageRenderingType type) -{ - IMAPMessageRenderingOperation * op = new IMAPMessageRenderingOperation(); - op->setSession(this); - op->setMessage(message); - op->setFolder(folder); - op->setRenderingType(type); - op->autorelease(); - return op; -} - -IMAPMessageRenderingOperation * IMAPAsyncConnection::htmlRenderingOperation(IMAPMessage * message, - String * folder) -{ - return renderingOperation(message, folder, IMAPMessageRenderingTypeHTML); -} - -IMAPMessageRenderingOperation * IMAPAsyncConnection::htmlBodyRenderingOperation(IMAPMessage * message, - String * folder) -{ - return renderingOperation(message, folder, IMAPMessageRenderingTypeHTMLBody); -} - -IMAPMessageRenderingOperation * IMAPAsyncConnection::plainTextRenderingOperation(IMAPMessage * message, - String * folder) -{ - return renderingOperation(message, folder, IMAPMessageRenderingTypePlainText); -} - -IMAPMessageRenderingOperation * IMAPAsyncConnection::plainTextBodyRenderingOperation(IMAPMessage * message, - String * folder, - bool stripWhitespace) -{ - return renderingOperation(message, folder, - stripWhitespace ? IMAPMessageRenderingTypePlainTextBodyAndStripWhitespace : - IMAPMessageRenderingTypePlainTextBody); -} - void IMAPAsyncConnection::setAutomaticConfigurationEnabled(bool enabled) { mAutomaticConfigurationEnabled = enabled; diff --git a/src/async/imap/MCIMAPAsyncConnection.h b/src/async/imap/MCIMAPAsyncConnection.h index 6af22b50..50d1409a 100755 --- a/src/async/imap/MCIMAPAsyncConnection.h +++ b/src/async/imap/MCIMAPAsyncConnection.h @@ -86,63 +86,8 @@ namespace mailcore { virtual dispatch_queue_t dispatchQueue(); #endif - virtual IMAPFolderInfoOperation * folderInfoOperation(String * folder); - virtual IMAPFolderStatusOperation * folderStatusOperation(String * folder); - - virtual IMAPFetchFoldersOperation * fetchSubscribedFoldersOperation(); - virtual IMAPFetchFoldersOperation * fetchAllFoldersOperation(); - - virtual IMAPOperation * renameFolderOperation(String * folder, String * otherName); - virtual IMAPOperation * deleteFolderOperation(String * folder); - virtual IMAPOperation * createFolderOperation(String * folder); - - virtual IMAPOperation * subscribeFolderOperation(String * folder); - virtual IMAPOperation * unsubscribeFolderOperation(String * folder); - - virtual IMAPAppendMessageOperation * appendMessageOperation(String * folder, Data * messageData, MessageFlag flags, Array * customFlags); - - virtual IMAPCopyMessagesOperation * copyMessagesOperation(String * folder, IndexSet * uids, String * destFolder); - - virtual IMAPOperation * expungeOperation(String * folder); - - virtual IMAPFetchMessagesOperation * fetchMessagesByUIDOperation(String * folder, IMAPMessagesRequestKind requestKind, - IndexSet * uids); - virtual IMAPFetchMessagesOperation * fetchMessagesByNumberOperation(String * folder, IMAPMessagesRequestKind requestKind, - IndexSet * numbers); - virtual IMAPFetchMessagesOperation * syncMessagesByUID(String * folder, IMAPMessagesRequestKind requestKind, - IndexSet * uids, uint64_t modSeq); - - virtual IMAPFetchContentOperation * fetchMessageByUIDOperation(String * folder, uint32_t uid); - virtual IMAPFetchContentOperation * fetchMessageAttachmentByUIDOperation(String * folder, uint32_t uid, String * partID, - Encoding encoding); - - virtual IMAPOperation * storeFlagsOperation(String * folder, IndexSet * uids, IMAPStoreFlagsRequestKind kind, MessageFlag flags, Array * customFlags); - virtual IMAPOperation * storeLabelsOperation(String * folder, IndexSet * uids, IMAPStoreFlagsRequestKind kind, Array * labels); - - virtual IMAPSearchOperation * searchOperation(String * folder, IMAPSearchKind kind, String * searchString); - virtual IMAPSearchOperation * searchOperation(String * folder, IMAPSearchExpression * expression); - - virtual IMAPIdleOperation * idleOperation(String * folder, uint32_t lastKnownUID); - - virtual IMAPFetchNamespaceOperation * fetchNamespaceOperation(); - - virtual IMAPIdentityOperation * identityOperation(IMAPIdentity * identity); - - virtual IMAPOperation * connectOperation(); - virtual IMAPOperation * checkAccountOperation(); virtual IMAPOperation * disconnectOperation(); - - virtual IMAPOperation * noopOperation(); - - virtual IMAPCapabilityOperation * capabilityOperation(); - virtual IMAPQuotaOperation * quotaOperation(); - - virtual IMAPMessageRenderingOperation * htmlRenderingOperation(IMAPMessage * message, String * folder); - virtual IMAPMessageRenderingOperation * htmlBodyRenderingOperation(IMAPMessage * message, String * folder); - virtual IMAPMessageRenderingOperation * plainTextRenderingOperation(IMAPMessage * message, String * folder); - virtual IMAPMessageRenderingOperation * plainTextBodyRenderingOperation(IMAPMessage * message, String * folder, bool stripWhitespace); - - + private: IMAPSession * mSession; OperationQueue * mQueue; @@ -159,10 +104,7 @@ namespace mailcore { bool mScheduledAutomaticDisconnect; virtual void tryAutomaticDisconnectAfterDelay(void * context); - virtual IMAPMessageRenderingOperation * renderingOperation(IMAPMessage * message, - String * folder, - IMAPMessageRenderingType type); - + public: // private virtual void runOperation(IMAPOperation * operation); virtual IMAPSession * session(); diff --git a/src/async/imap/MCIMAPAsyncSession.cc b/src/async/imap/MCIMAPAsyncSession.cc index 1f1808df..68625746 100755 --- a/src/async/imap/MCIMAPAsyncSession.cc +++ b/src/async/imap/MCIMAPAsyncSession.cc @@ -16,6 +16,33 @@ #include "MCIMAPIdentity.h" #include "MCIMAPMultiDisconnectOperation.h" +#include "MCIMAPFolderInfoOperation.h" +#include "MCIMAPFolderStatusOperation.h" +#include "MCIMAPFetchFoldersOperation.h" +#include "MCIMAPRenameFolderOperation.h" +#include "MCIMAPDeleteFolderOperation.h" +#include "MCIMAPCreateFolderOperation.h" +#include "MCIMAPSubscribeFolderOperation.h" +#include "MCIMAPExpungeOperation.h" +#include "MCIMAPAppendMessageOperation.h" +#include "MCIMAPCopyMessagesOperation.h" +#include "MCIMAPFetchMessagesOperation.h" +#include "MCIMAPFetchContentOperation.h" +#include "MCIMAPFetchContentOperation.h" +#include "MCIMAPStoreFlagsOperation.h" +#include "MCIMAPStoreLabelsOperation.h" +#include "MCIMAPSearchOperation.h" +#include "MCIMAPConnectOperation.h" +#include "MCIMAPCheckAccountOperation.h" +#include "MCIMAPFetchNamespaceOperation.h" +#include "MCIMAPIdleOperation.h" +#include "MCIMAPIdentityOperation.h" +#include "MCIMAPCapabilityOperation.h" +#include "MCIMAPQuotaOperation.h" +#include "MCIMAPDisconnectOperation.h" +#include "MCIMAPNoopOperation.h" +#include "MCIMAPMessageRenderingOperation.h" + #define DEFAULT_MAX_CONNECTIONS 3 using namespace mailcore; @@ -321,180 +348,293 @@ IMAPAsyncConnection * IMAPAsyncSession::matchingSessionForFolder(String * folder IMAPFolderInfoOperation * IMAPAsyncSession::folderInfoOperation(String * folder) { - IMAPAsyncConnection * session = sessionForFolder(folder); - return session->folderInfoOperation(folder); + IMAPFolderInfoOperation * op = new IMAPFolderInfoOperation(); + op->setMainSession(this); + op->setFolder(folder); + op->autorelease(); + return op; } IMAPFolderStatusOperation * IMAPAsyncSession::folderStatusOperation(String * folder) { - IMAPAsyncConnection * session = sessionForFolder(folder); - return session->folderStatusOperation(folder); + IMAPFolderStatusOperation * op = new IMAPFolderStatusOperation(); + op->setMainSession(this); + op->setFolder(folder); + op->autorelease(); + return op; } IMAPFetchFoldersOperation * IMAPAsyncSession::fetchSubscribedFoldersOperation() { - IMAPAsyncConnection * session = sessionForFolder(NULL); - return session->fetchSubscribedFoldersOperation(); + IMAPFetchFoldersOperation * op = new IMAPFetchFoldersOperation(); + op->setMainSession(this); + op->setFetchSubscribedEnabled(true); + op->autorelease(); + return op; } IMAPFetchFoldersOperation * IMAPAsyncSession::fetchAllFoldersOperation() { - IMAPAsyncConnection * session = sessionForFolder(NULL); - return session->fetchAllFoldersOperation(); + IMAPFetchFoldersOperation * op = new IMAPFetchFoldersOperation(); + op->setMainSession(this); + op->autorelease(); + return op; } IMAPOperation * IMAPAsyncSession::renameFolderOperation(String * folder, String * otherName) { - IMAPAsyncConnection * session = sessionForFolder(NULL); - return session->renameFolderOperation(folder, otherName); + IMAPRenameFolderOperation * op = new IMAPRenameFolderOperation(); + op->setMainSession(this); + op->setFolder(folder); + op->setOtherName(otherName); + op->autorelease(); + return op; } IMAPOperation * IMAPAsyncSession::deleteFolderOperation(String * folder) { - IMAPAsyncConnection * session = sessionForFolder(NULL); - return session->deleteFolderOperation(folder); + IMAPDeleteFolderOperation * op = new IMAPDeleteFolderOperation(); + op->setMainSession(this); + op->setFolder(folder); + op->autorelease(); + return op; } IMAPOperation * IMAPAsyncSession::createFolderOperation(String * folder) { - IMAPAsyncConnection * session = sessionForFolder(NULL); - return session->createFolderOperation(folder); + IMAPCreateFolderOperation * op = new IMAPCreateFolderOperation(); + op->setMainSession(this); + op->setFolder(folder); + op->autorelease(); + return op; } IMAPOperation * IMAPAsyncSession::subscribeFolderOperation(String * folder) { - IMAPAsyncConnection * session = sessionForFolder(NULL); - return session->subscribeFolderOperation(folder); + IMAPSubscribeFolderOperation * op = new IMAPSubscribeFolderOperation(); + op->setMainSession(this); + op->setFolder(folder); + op->autorelease(); + return op; } IMAPOperation * IMAPAsyncSession::unsubscribeFolderOperation(String * folder) { - IMAPAsyncConnection * session = sessionForFolder(NULL); - return session->unsubscribeFolderOperation(folder); + IMAPSubscribeFolderOperation * op = new IMAPSubscribeFolderOperation(); + op->setMainSession(this); + op->setUnsubscribeEnabled(true); + op->setFolder(folder); + op->autorelease(); + return op; } IMAPAppendMessageOperation * IMAPAsyncSession::appendMessageOperation(String * folder, Data * messageData, MessageFlag flags, Array * customFlags) { - IMAPAsyncConnection * session = sessionForFolder(folder); - return session->appendMessageOperation(folder, messageData, flags, customFlags); + IMAPAppendMessageOperation * op = new IMAPAppendMessageOperation(); + op->setMainSession(this); + op->setFolder(folder); + op->setMessageData(messageData); + op->setFlags(flags); + op->setCustomFlags(customFlags); + op->autorelease(); + return op; } IMAPCopyMessagesOperation * IMAPAsyncSession::copyMessagesOperation(String * folder, IndexSet * uids, String * destFolder) { - IMAPAsyncConnection * session = sessionForFolder(folder); - return session->copyMessagesOperation(folder, uids, destFolder); + IMAPCopyMessagesOperation * op = new IMAPCopyMessagesOperation(); + op->setMainSession(this); + op->setFolder(folder); + op->setUids(uids); + op->setDestFolder(destFolder); + op->autorelease(); + return op; } IMAPOperation * IMAPAsyncSession::expungeOperation(String * folder) { - IMAPAsyncConnection * session = sessionForFolder(folder); - return session->expungeOperation(folder); + IMAPExpungeOperation * op = new IMAPExpungeOperation(); + op->setMainSession(this); + op->setFolder(folder); + op->autorelease(); + return op; } IMAPFetchMessagesOperation * IMAPAsyncSession::fetchMessagesByUIDOperation(String * folder, IMAPMessagesRequestKind requestKind, IndexSet * uids) { - IMAPAsyncConnection * session = sessionForFolder(folder); - return session->fetchMessagesByUIDOperation(folder, requestKind, uids); + IMAPFetchMessagesOperation * op = new IMAPFetchMessagesOperation(); + op->setMainSession(this); + op->setFolder(folder); + op->setKind(requestKind); + op->setFetchByUidEnabled(true); + op->setIndexes(uids); + op->autorelease(); + return op; } IMAPFetchMessagesOperation * IMAPAsyncSession::fetchMessagesByNumberOperation(String * folder, IMAPMessagesRequestKind requestKind, IndexSet * numbers) { - IMAPAsyncConnection * session = sessionForFolder(folder); - return session->fetchMessagesByNumberOperation(folder, requestKind, numbers); + IMAPFetchMessagesOperation * op = new IMAPFetchMessagesOperation(); + op->setMainSession(this); + op->setFolder(folder); + op->setKind(requestKind); + op->setIndexes(numbers); + op->autorelease(); + return op; } IMAPFetchMessagesOperation * IMAPAsyncSession::syncMessagesByUID(String * folder, IMAPMessagesRequestKind requestKind, IndexSet * uids, uint64_t modSeq) { - IMAPAsyncConnection * session = sessionForFolder(folder); - return session->syncMessagesByUID(folder, requestKind, uids, modSeq); + IMAPFetchMessagesOperation * op = new IMAPFetchMessagesOperation(); + op->setMainSession(this); + op->setFolder(folder); + op->setKind(requestKind); + op->setFetchByUidEnabled(true); + op->setIndexes(uids); + op->setModSequenceValue(modSeq); + op->autorelease(); + return op; } IMAPFetchContentOperation * IMAPAsyncSession::fetchMessageByUIDOperation(String * folder, uint32_t uid, bool urgent) { - IMAPAsyncConnection * session = sessionForFolder(folder, urgent); - return session->fetchMessageByUIDOperation(folder, uid); + IMAPFetchContentOperation * op = new IMAPFetchContentOperation(); + op->setMainSession(this); + op->setFolder(folder); + op->setUid(uid); + op->setUrgent(urgent); + op->autorelease(); + return op; } IMAPFetchContentOperation * IMAPAsyncSession::fetchMessageAttachmentByUIDOperation(String * folder, uint32_t uid, String * partID, Encoding encoding, bool urgent) { - IMAPAsyncConnection * session = sessionForFolder(folder, urgent); - return session->fetchMessageAttachmentByUIDOperation(folder, uid, partID, encoding); + IMAPFetchContentOperation * op = new IMAPFetchContentOperation(); + op->setMainSession(this); + op->setFolder(folder); + op->setUid(uid); + op->setPartID(partID); + op->setEncoding(encoding); + op->setUrgent(urgent); + op->autorelease(); + return op; } IMAPOperation * IMAPAsyncSession::storeFlagsOperation(String * folder, IndexSet * uids, IMAPStoreFlagsRequestKind kind, MessageFlag flags, Array * customFlags) { - IMAPAsyncConnection * session = sessionForFolder(folder); - return session->storeFlagsOperation(folder, uids, kind, flags, customFlags); + IMAPStoreFlagsOperation * op = new IMAPStoreFlagsOperation(); + op->setMainSession(this); + op->setFolder(folder); + op->setUids(uids); + op->setKind(kind); + op->setFlags(flags); + op->setCustomFlags(customFlags); + op->autorelease(); + return op; } IMAPOperation * IMAPAsyncSession::storeLabelsOperation(String * folder, IndexSet * uids, IMAPStoreFlagsRequestKind kind, Array * labels) { - IMAPAsyncConnection * session = sessionForFolder(folder); - return session->storeLabelsOperation(folder, uids, kind, labels); + IMAPStoreLabelsOperation * op = new IMAPStoreLabelsOperation(); + op->setMainSession(this); + op->setFolder(folder); + op->setUids(uids); + op->setKind(kind); + op->setLabels(labels); + op->autorelease(); + return op; } IMAPSearchOperation * IMAPAsyncSession::searchOperation(String * folder, IMAPSearchKind kind, String * searchString) { - IMAPAsyncConnection * session = sessionForFolder(folder); - return session->searchOperation(folder, kind, searchString); + IMAPSearchOperation * op = new IMAPSearchOperation(); + op->setMainSession(this); + op->setFolder(folder); + op->setSearchKind(kind); + op->setSearchString(searchString); + op->autorelease(); + return op; } IMAPSearchOperation * IMAPAsyncSession::searchOperation(String * folder, IMAPSearchExpression * expression) { - IMAPAsyncConnection * session = sessionForFolder(folder); - return session->searchOperation(folder, expression); + IMAPSearchOperation * op = new IMAPSearchOperation(); + op->setMainSession(this); + op->setFolder(folder); + op->setSearchExpression(expression); + op->autorelease(); + return op; } IMAPIdleOperation * IMAPAsyncSession::idleOperation(String * folder, uint32_t lastKnownUID) { - IMAPAsyncConnection * session = sessionForFolder(folder); - return session->idleOperation(folder, lastKnownUID); + IMAPIdleOperation * op = new IMAPIdleOperation(); + op->setMainSession(this); + op->setFolder(folder); + op->setLastKnownUID(lastKnownUID); + op->autorelease(); + return op; } IMAPFetchNamespaceOperation * IMAPAsyncSession::fetchNamespaceOperation() { - IMAPAsyncConnection * session = sessionForFolder(NULL); - return session->fetchNamespaceOperation(); + IMAPFetchNamespaceOperation * op = new IMAPFetchNamespaceOperation(); + op->setMainSession(this); + op->autorelease(); + return op; } IMAPIdentityOperation * IMAPAsyncSession::identityOperation(IMAPIdentity * identity) { - IMAPAsyncConnection * session = sessionForFolder(NULL); - return session->identityOperation(identity); + IMAPIdentityOperation * op = new IMAPIdentityOperation(); + op->setMainSession(this); + op->setClientIdentity(identity); + op->autorelease(); + return op; } IMAPOperation * IMAPAsyncSession::connectOperation() { - IMAPAsyncConnection * session = sessionForFolder(NULL); - return session->connectOperation(); + IMAPConnectOperation * op = new IMAPConnectOperation(); + op->setMainSession(this); + op->autorelease(); + return op; } IMAPOperation * IMAPAsyncSession::checkAccountOperation() { - IMAPAsyncConnection * session = sessionForFolder(NULL); - return session->checkAccountOperation(); + IMAPCheckAccountOperation * op = new IMAPCheckAccountOperation(); + op->setMainSession(this); + op->autorelease(); + return op; } IMAPCapabilityOperation * IMAPAsyncSession::capabilityOperation() { - IMAPAsyncConnection * session = sessionForFolder(NULL); - return session->capabilityOperation(); + IMAPCapabilityOperation * op = new IMAPCapabilityOperation(); + op->setMainSession(this); + op->autorelease(); + return op; } IMAPQuotaOperation * IMAPAsyncSession::quotaOperation() { - IMAPAsyncConnection * session = sessionForFolder(NULL); - return session->quotaOperation(); + IMAPQuotaOperation * op = new IMAPQuotaOperation(); + op->setMainSession(this); + op->autorelease(); + return op; } IMAPOperation * IMAPAsyncSession::noopOperation() { - IMAPAsyncConnection * session = sessionForFolder(NULL); - return session->noopOperation(); + IMAPNoopOperation * op = new IMAPNoopOperation(); + op->setMainSession(this); + op->autorelease(); + return op; } IMAPOperation * IMAPAsyncSession::disconnectOperation() @@ -522,33 +662,44 @@ ConnectionLogger * IMAPAsyncSession::connectionLogger() return mConnectionLogger; } +IMAPMessageRenderingOperation * IMAPAsyncSession::renderingOperation(IMAPMessage * message, + String * folder, + IMAPMessageRenderingType type) +{ + IMAPMessageRenderingOperation * op = new IMAPMessageRenderingOperation(); + op->setMainSession(this); + op->setMessage(message); + op->setFolder(folder); + op->setRenderingType(type); + op->autorelease(); + return op; +} + IMAPMessageRenderingOperation * IMAPAsyncSession::htmlRenderingOperation(IMAPMessage * message, String * folder) { - IMAPAsyncConnection * session = sessionForFolder(folder); - return session->htmlRenderingOperation(message, folder); + return renderingOperation(message, folder, IMAPMessageRenderingTypeHTML); } IMAPMessageRenderingOperation * IMAPAsyncSession::htmlBodyRenderingOperation(IMAPMessage * message, String * folder) { - IMAPAsyncConnection * session = sessionForFolder(folder); - return session->htmlBodyRenderingOperation(message, folder); + return renderingOperation(message, folder, IMAPMessageRenderingTypeHTMLBody); } IMAPMessageRenderingOperation * IMAPAsyncSession::plainTextRenderingOperation(IMAPMessage * message, String * folder) { - IMAPAsyncConnection * session = sessionForFolder(folder); - return session->plainTextRenderingOperation(message, folder); + return renderingOperation(message, folder, IMAPMessageRenderingTypePlainText); } IMAPMessageRenderingOperation * IMAPAsyncSession::plainTextBodyRenderingOperation(IMAPMessage * message, String * folder, bool stripWhitespace) { - IMAPAsyncConnection * session = sessionForFolder(folder); - return session->plainTextBodyRenderingOperation(message, folder, stripWhitespace); + return renderingOperation(message, folder, + stripWhitespace ? IMAPMessageRenderingTypePlainTextBodyAndStripWhitespace : + IMAPMessageRenderingTypePlainTextBody); } void IMAPAsyncSession::automaticConfigurationDone(IMAPSession * session) diff --git a/src/async/imap/MCIMAPAsyncSession.h b/src/async/imap/MCIMAPAsyncSession.h index b00af1d3..333783b2 100755 --- a/src/async/imap/MCIMAPAsyncSession.h +++ b/src/async/imap/MCIMAPAsyncSession.h @@ -162,6 +162,7 @@ namespace mailcore { public: // private virtual void automaticConfigurationDone(IMAPSession * session); virtual void operationRunningStateChanged(); + virtual IMAPAsyncConnection * sessionForFolder(String * folder, bool urgent = false); private: Array * mSessions; @@ -190,10 +191,12 @@ namespace mailcore { #endif String * mGmailUserDisplayName; - virtual IMAPAsyncConnection * sessionForFolder(String * folder, bool urgent = false); virtual IMAPAsyncConnection * session(); virtual IMAPAsyncConnection * matchingSessionForFolder(String * folder); virtual IMAPAsyncConnection * availableSession(); + virtual IMAPMessageRenderingOperation * renderingOperation(IMAPMessage * message, + String * folder, + IMAPMessageRenderingType type); }; } diff --git a/src/async/imap/MCIMAPOperation.cc b/src/async/imap/MCIMAPOperation.cc index e4b3529b..9ab30ab0 100644 --- a/src/async/imap/MCIMAPOperation.cc +++ b/src/async/imap/MCIMAPOperation.cc @@ -20,13 +20,16 @@ using namespace mailcore; IMAPOperation::IMAPOperation() { mSession = NULL; + mMainSession = NULL; mImapCallback = NULL; mError = ErrorNone; mFolder = NULL; + mUrgent = false; } IMAPOperation::~IMAPOperation() { + MC_SAFE_RELEASE(mMainSession); MC_SAFE_RELEASE(mFolder); MC_SAFE_RELEASE(mSession); } @@ -51,6 +54,16 @@ IMAPAsyncConnection * IMAPOperation::session() return mSession; } +void IMAPOperation::setMainSession(IMAPAsyncSession * session) +{ + MC_SAFE_REPLACE_RETAIN(IMAPAsyncSession, mMainSession, session); +} + +IMAPAsyncSession * IMAPOperation::mainSession() +{ + return mMainSession; +} + void IMAPOperation::setFolder(String * folder) { MC_SAFE_REPLACE_COPY(String, mFolder, folder); @@ -61,6 +74,16 @@ String * IMAPOperation::folder() return mFolder; } +void IMAPOperation::setUrgent(bool urgent) +{ + mUrgent = urgent; +} + +bool IMAPOperation::isUrgent() +{ + return mUrgent; +} + void IMAPOperation::setImapCallback(IMAPOperationCallback * callback) { mImapCallback = callback; @@ -83,6 +106,10 @@ ErrorCode IMAPOperation::error() void IMAPOperation::start() { + if (session() == NULL) { + IMAPAsyncConnection * connection = mMainSession->sessionForFolder(mFolder, mUrgent); + setSession(connection); + } mSession->runOperation(this); } diff --git a/src/async/imap/MCIMAPOperation.h b/src/async/imap/MCIMAPOperation.h index 7455fdeb..ed5bc560 100644 --- a/src/async/imap/MCIMAPOperation.h +++ b/src/async/imap/MCIMAPOperation.h @@ -18,6 +18,7 @@ namespace mailcore { class IMAPAsyncConnection; + class IMAPAsyncSession; class IMAPOperationCallback; class IMAPOperation : public Operation, public IMAPProgressCallback { @@ -25,12 +26,18 @@ namespace mailcore { IMAPOperation(); virtual ~IMAPOperation(); + virtual void setMainSession(IMAPAsyncSession * session); + virtual IMAPAsyncSession * mainSession(); + virtual void setSession(IMAPAsyncConnection * session); virtual IMAPAsyncConnection * session(); virtual void setFolder(String * folder); virtual String * folder(); + virtual void setUrgent(bool urgent); + virtual bool isUrgent(); + virtual void setImapCallback(IMAPOperationCallback * callback); virtual IMAPOperationCallback * imapCallback(); @@ -44,10 +51,12 @@ namespace mailcore { virtual ErrorCode error(); private: + IMAPAsyncSession * mMainSession; IMAPAsyncConnection * mSession; String * mFolder; IMAPOperationCallback * mImapCallback; ErrorCode mError; + bool mUrgent; private: virtual void bodyProgress(IMAPSession * session, unsigned int current, unsigned int maximum); diff --git a/src/core/basetypes/MCString.cc b/src/core/basetypes/MCString.cc index 64ec81cc..5c2da323 100644 --- a/src/core/basetypes/MCString.cc +++ b/src/core/basetypes/MCString.cc @@ -761,6 +761,9 @@ String * String::string() String * String::stringWithData(Data * data, const char * charset) { + if (data == NULL) { + return String::string(); + } String * result = NULL; result = new String(data->bytes(), data->length(), charset); result->autorelease(); @@ -807,6 +810,9 @@ String * String::stringWithCharacters(const UChar * characters, unsigned int len void String::appendCharactersLength(const UChar * unicodeCharacters, unsigned int length) { + if (unicodeCharacters == NULL) { + return; + } allocate(mLength + length); u_strncpy(&mUnicodeChars[mLength], unicodeCharacters, length); mLength += length; @@ -815,6 +821,9 @@ void String::appendCharactersLength(const UChar * unicodeCharacters, unsigned in void String::appendString(String * otherString) { + if (otherString == NULL) { + return; + } appendCharactersLength(otherString->unicodeCharacters(), otherString->length()); } @@ -831,8 +840,9 @@ void String::appendUTF8Format(const char * format, ...) void String::appendUTF8CharactersLength(const char * UTF8Characters, unsigned int length) { - if (UTF8Characters == NULL) + if (UTF8Characters == NULL) { return; + } UChar * dest; int32_t destLength; @@ -1124,6 +1134,10 @@ String * String::uppercaseString() void String::appendBytes(const char * bytes, unsigned int length, const char * charset) { + if (bytes == NULL) { + return; + } + #if __APPLE__ CFStringEncoding encoding; if (strcasecmp(charset, "mutf-7") == 0) { diff --git a/src/core/basetypes/MCUtils.h b/src/core/basetypes/MCUtils.h index e1bef841..ad9c4db5 100644 --- a/src/core/basetypes/MCUtils.h +++ b/src/core/basetypes/MCUtils.h @@ -29,7 +29,7 @@ #define MCSTR(str) mailcore::String::uniquedStringWithUTF8Characters("" str "") -#define MCUTF8(str) ((str) != NULL ? (str)->UTF8Characters() : NULL ) +#define MCUTF8(str) MCUTF8DESC(str) #define MCUTF8DESC(obj) ((obj) != NULL ? (obj)->description()->UTF8Characters() : NULL ) #define MCLOCALIZEDSTRING(key) key diff --git a/src/core/renderer/MCHTMLRenderer.cc b/src/core/renderer/MCHTMLRenderer.cc index 15f6ade3..8b561e71 100644 --- a/src/core/renderer/MCHTMLRenderer.cc +++ b/src/core/renderer/MCHTMLRenderer.cc @@ -407,8 +407,22 @@ String * htmlForAbstractMultipartAlternative(AbstractMultipart * part, htmlRende AbstractPart * preferredAlternative = preferredPartInMultipartAlternative(part); if (preferredAlternative == NULL) return MCSTR(""); - - return htmlForAbstractPart(preferredAlternative, context); + + // Exchange sends calendar invitation as alternative part. We need to extract it. + AbstractPart * calendar = NULL; + for(unsigned int i = 0 ; i < part->parts()->count() ; i ++) { + AbstractPart * subpart = (AbstractPart *) part->parts()->objectAtIndex(i); + if (partContainsMimeType(subpart, MCSTR("text/calendar"))) { + calendar = subpart; + } + } + + String * result = String::string(); + result->appendString(htmlForAbstractPart(preferredAlternative, context)); + if (calendar != NULL) { + result->appendString(htmlForAbstractPart(calendar, context)); + } + return result; } static String * htmlForAbstractMultipartMixed(AbstractMultipart * part, htmlRendererContext * context) diff --git a/src/objc/abstract/MCOAbstractPart.h b/src/objc/abstract/MCOAbstractPart.h index 54c30e31..e30f09bf 100644 --- a/src/objc/abstract/MCOAbstractPart.h +++ b/src/objc/abstract/MCOAbstractPart.h @@ -14,7 +14,7 @@ @class MCOAbstractMessage; -typedef enum { +typedef NS_ENUM(NSInteger, MCOPartType) { // Used for a single part. // The part will be a MCOAbstractPart. MCOPartTypeSingle, @@ -39,8 +39,7 @@ typedef enum { // Used for a signed message, multipart/signed. // The part will be a MCOAbstractMultipart. MCOPartTypeMultipartSigned, - -} MCOPartType; +}; @interface MCOAbstractPart : NSObject <NSCopying> diff --git a/src/objc/abstract/MCOAddress.mm b/src/objc/abstract/MCOAddress.mm index 679df967..b03b6aa7 100644 --- a/src/objc/abstract/MCOAddress.mm +++ b/src/objc/abstract/MCOAddress.mm @@ -159,6 +159,22 @@ MCO_OBJC_SYNTHESIZE_STRING(setMailbox, mailbox) return MCO_OBJC_BRIDGE_GET(nonEncodedRFC822String); } +- (NSUInteger) hash +{ + return [[self displayName] hash] ^ [[self mailbox] hash]; +} + +- (BOOL) isEqual:(id)object +{ + if (![object isKindOfClass:[MCOAddress class]]) { + return NO; + } + + MCOAddress * other = object; + return [[self displayName] isEqualToString:[other displayName]] && + [[self mailbox] isEqualToString:[other mailbox]]; +} + @end @implementation NSArray (MCOAddress) diff --git a/src/objc/abstract/MCOConstants.h b/src/objc/abstract/MCOConstants.h index eb276e0f..32a1b1bb 100644 --- a/src/objc/abstract/MCOConstants.h +++ b/src/objc/abstract/MCOConstants.h @@ -3,7 +3,7 @@ #define MAILCORE_MCOCONSTANTS_H /** It's the connection type.*/ -typedef enum { +typedef NS_OPTIONS(NSInteger, MCOConnectionType) { /** Clear-text connection for the protocol.*/ MCOConnectionTypeClear = 1 << 0, /** Clear-text connection at the beginning, then switch to encrypted connection using TLS/SSL*/ @@ -11,10 +11,10 @@ typedef enum { MCOConnectionTypeStartTLS = 1 << 1, /** Encrypted connection using TLS/SSL.*/ MCOConnectionTypeTLS = 1 << 2, -} MCOConnectionType; +}; /** It's the authentication type.*/ -typedef enum { +typedef NS_OPTIONS(NSInteger, MCOAuthType) { /** Default authentication scheme of the protocol.*/ MCOAuthTypeSASLNone = 0, /** CRAM-MD5 authentication RFC 2195.*/ @@ -37,10 +37,10 @@ typedef enum { MCOAuthTypeXOAuth2 = 1 << 8, /** OAuth2 authentication on outlook.com.*/ MCOAuthTypeXOAuth2Outlook = 1 << 9, -} MCOAuthType; +}; /** It's the IMAP flags of the folder.*/ -typedef enum { +typedef NS_OPTIONS(NSInteger, MCOIMAPFolderFlag) { MCOIMAPFolderFlagNone = 0, /** \Marked*/ MCOIMAPFolderFlagMarked = 1 << 0, @@ -77,10 +77,10 @@ typedef enum { /** Mask to identify the folder */ MCOIMAPFolderFlagFolderTypeMask = MCOIMAPFolderFlagInbox | MCOIMAPFolderFlagSentMail | MCOIMAPFolderFlagStarred | MCOIMAPFolderFlagAllMail | MCOIMAPFolderFlagTrash| MCOIMAPFolderFlagDrafts | MCOIMAPFolderFlagSpam | MCOIMAPFolderFlagImportant | MCOIMAPFolderFlagArchive, -} MCOIMAPFolderFlag; +}; /** It's the flags of a message.*/ -typedef enum { +typedef NS_OPTIONS(NSInteger, MCOMessageFlag) { MCOMessageFlagNone = 0, /** Seen/Read flag.*/ MCOMessageFlagSeen = 1 << 0, @@ -100,10 +100,10 @@ typedef enum { MCOMessageFlagSubmitPending = 1 << 7, /** $Submitted flag.*/ MCOMessageFlagSubmitted = 1 << 8, -} MCOMessageFlag; +}; /** It's the encoding of a part.*/ -typedef enum { +typedef NS_ENUM(NSInteger, MCOEncoding) { /** 7bit encoding.*/ MCOEncoding7Bit = 0, /** should match MAILIMAP_BODY_FLD_ENC_7BIT*/ /** 8bit encoding.*/ @@ -121,10 +121,10 @@ typedef enum { /** UUEncode encoding.*/ MCOEncodingUUEncode = -1 -} MCOEncoding; +}; /** It's the information to fetch for a given message in the IMAP FETCH request.*/ -typedef enum { +typedef NS_OPTIONS(NSInteger, MCOIMAPMessagesRequestKind) { /** UID of the message.*/ MCOIMAPMessagesRequestKindUid = 0, /** This is the default and it's always fetched*/ /** Flags of the message.*/ @@ -150,20 +150,20 @@ typedef enum { /* Request size of message */ MCOIMAPMessagesRequestKindSize = 1 << 10, -} MCOIMAPMessagesRequestKind; +}; /** It defines the behavior of the STORE flags request.*/ -typedef enum { +typedef NS_ENUM(NSInteger, MCOIMAPStoreFlagsRequestKind) { /** Add the given flags.*/ MCOIMAPStoreFlagsRequestKindAdd, /** Remove the given flags.*/ MCOIMAPStoreFlagsRequestKindRemove, /** Set the given flags.*/ MCOIMAPStoreFlagsRequestKindSet, -} MCOIMAPStoreFlagsRequestKind; +}; /** It's the search type.*/ -typedef enum { +typedef NS_ENUM(NSInteger, MCOIMAPSearchKind) { /** Search All */ MCOIMAPSearchKindAll, /** No search.*/ @@ -234,7 +234,7 @@ typedef enum { MCOIMAPSearchKindAnd, /** Not expression.*/ MCOIMAPSearchKindNot, -} MCOIMAPSearchKind; +}; /** Keys for the namespace dictionary.*/ #define MCOIMAPNamespacePersonal @"IMAPNamespacePersonal" @@ -243,7 +243,7 @@ typedef enum { /** This is the constants for the IMAP capabilities.*/ /** See corresponding RFC for more information.*/ -typedef enum { +typedef NS_ENUM(NSInteger, MCOIMAPCapability) { /** ACL Capability.*/ MCOIMAPCapabilityACL, /** BINARY Capability.*/ @@ -314,13 +314,13 @@ typedef enum { MCOIMAPCapabilityXOAuth2, /** X-GM-EXT-1 Capability.*/ MCOIMAPCapabilityGmail -} MCOIMAPCapability; +}; /** Error domain for mailcore.*/ #define MCOErrorDomain @"MCOErrorDomain" /** Here's the list of errors.*/ -typedef enum { +typedef NS_ENUM(NSInteger, MCOErrorCode) { /** No error occurred.*/ MCOErrorNone, /** An error related to the connection occurred.*/ @@ -402,10 +402,10 @@ typedef enum { MCOErrorNoop, /** The count of all errors */ MCOErrorCodeCount, -} MCOErrorCode; +}; /** Here's the list of connection log types.*/ -typedef enum { +typedef NS_ENUM(NSInteger, MCOConnectionLogType) { /** Received data.*/ MCOConnectionLogTypeReceived, /** Sent data.*/ @@ -418,7 +418,7 @@ typedef enum { MCOConnectionLogTypeErrorReceived, /** Error while sending dataThe data passed to the log will be nil.*/ MCOConnectionLogTypeErrorSent, -} MCOConnectionLogType; +}; /** It's a network traffic logger. diff --git a/src/objc/imap/MCOIMAPBaseOperation.h b/src/objc/imap/MCOIMAPBaseOperation.h index 31686f04..82a34378 100644 --- a/src/objc/imap/MCOIMAPBaseOperation.h +++ b/src/objc/imap/MCOIMAPBaseOperation.h @@ -19,6 +19,8 @@ typedef void (^MCOIMAPBaseOperationItemProgressBlock)(unsigned int current); @interface MCOIMAPBaseOperation : MCOOperation +@property (nonatomic, assign, getter=isUrgent) BOOL urgent; + /* Can be overriden by subclasses */ /* diff --git a/src/objc/imap/MCOIMAPBaseOperation.mm b/src/objc/imap/MCOIMAPBaseOperation.mm index fe20da53..70f0d5ff 100644 --- a/src/objc/imap/MCOIMAPBaseOperation.mm +++ b/src/objc/imap/MCOIMAPBaseOperation.mm @@ -13,6 +13,7 @@ #import "MCAsyncIMAP.h" #import "MCOIMAPSession.h" +#import "NSObject+MCO.h" class MCOIMAPBaseOperationIMAPCallback : public mailcore::IMAPOperationCallback { public: @@ -42,6 +43,10 @@ private: MCOIMAPSession * _session; } +#define nativeType mailcore::IMAPOperation + +MCO_OBJC_SYNTHESIZE_SCALAR(BOOL, bool, setUrgent, isUrgent) + - (id) initWithMCOperation:(mailcore::Operation *)op { self = [super initWithMCOperation:op]; |