diff options
24 files changed, 342 insertions, 166 deletions
diff --git a/build-android/jni/Android.mk b/build-android/jni/Android.mk index d3eddf13..3f1087f8 100644 --- a/build-android/jni/Android.mk +++ b/build-android/jni/Android.mk @@ -14,7 +14,9 @@ subdirs = \ core/security \ core/smtp \ core/zip \ - core/zip/MiniZip + core/zip/MiniZip \ + async/imap \ + java java/native includes = \ $(CURRENT_DIR)/../include \ $(CTEMPLATE_PATH)/include \ @@ -49,6 +51,7 @@ async_imap_src_files := $(wildcard $(src_dir)/async/imap/*.cpp) async_nntp_src_files := $(wildcard $(src_dir)/async/nntp/*.cpp) async_pop_src_files := $(wildcard $(src_dir)/async/pop/*.cpp) async_smtp_src_files := $(wildcard $(src_dir)/async/smtp/*.cpp) +jni_src_files := $(wildcard $(src_dir)/java/native/*.cpp) $(wildcard $(src_dir)/java/*.cpp) # include $(CLEAR_VARS) # LOCAL_MODULE := MailCore @@ -109,7 +112,9 @@ include $(PREBUILT_STATIC_LIBRARY) include $(CLEAR_VARS) LOCAL_MODULE := MailCore LOCAL_C_INCLUDES := $(includes) -LOCAL_SRC_FILES := $(core_src_files) $(abstract_src_files) $(imap_src_files) $(nntp_src_files) \ +LOCAL_SRC_FILES := \ + $(jni_src_files) \ + $(core_src_files) $(abstract_src_files) $(imap_src_files) $(nntp_src_files) \ $(pop_src_files) $(provider_src_files) $(renderer_src_files) $(rfc822_src_files) \ $(security_src_files) $(smtp_src_files) $(zip_src_files) $(minizip_src_files) \ $(async_imap_src_files) $(async_nntp_src_files) $(async_pop_src_files) $(async_smtp_src_files) diff --git a/build-mac/mailcore2.xcodeproj/project.pbxproj b/build-mac/mailcore2.xcodeproj/project.pbxproj index b380a8bc..eb47b08d 100755 --- a/build-mac/mailcore2.xcodeproj/project.pbxproj +++ b/build-mac/mailcore2.xcodeproj/project.pbxproj @@ -394,6 +394,10 @@ C668E2CC1735CB8900A2BB47 /* MCAutoreleasePoolMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = C668E2CA1735CB8900A2BB47 /* MCAutoreleasePoolMac.mm */; }; C668E2CD1735CB8900A2BB47 /* MCAutoreleasePoolMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = C668E2CA1735CB8900A2BB47 /* MCAutoreleasePoolMac.mm */; }; C668E2DD1736333900A2BB47 /* providers.json in Resources */ = {isa = PBXBuildFile; fileRef = 84AF9E7D172DBAF600E60AA3 /* providers.json */; }; + C673EBED1A46B41000A53F7F /* MCIMAPFolderInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C673EBEB1A46B41000A53F7F /* MCIMAPFolderInfo.cpp */; }; + C673EBEE1A46B41000A53F7F /* MCIMAPFolderInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C673EBEB1A46B41000A53F7F /* MCIMAPFolderInfo.cpp */; }; + C673EBEF1A46B44E00A53F7F /* MCIMAPFolderInfo.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = C673EBEC1A46B41000A53F7F /* MCIMAPFolderInfo.h */; }; + C673EBF01A46B45300A53F7F /* MCIMAPFolderInfo.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = C673EBEC1A46B41000A53F7F /* MCIMAPFolderInfo.h */; }; C67597C217A8D65000DA69DF /* MCBase64.c in Sources */ = {isa = PBXBuildFile; fileRef = C67597C117A8D65000DA69DF /* MCBase64.c */; }; C67597C317A8D65000DA69DF /* MCBase64.c in Sources */ = {isa = PBXBuildFile; fileRef = C67597C117A8D65000DA69DF /* MCBase64.c */; }; C68B2AEE1778A865005E61EF /* MCConnectionLogger.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = C68B2AEB1778A589005E61EF /* MCConnectionLogger.h */; }; @@ -722,7 +726,7 @@ C6BA2C101705F4E6003F0E9E /* MCOIMAPIdentityOperation.mm in Sources */ = {isa = PBXBuildFile; fileRef = C6F61F9217016B250073032E /* MCOIMAPIdentityOperation.mm */; }; C6BA2C111705F4E6003F0E9E /* MCOIMAPCapabilityOperation.mm in Sources */ = {isa = PBXBuildFile; fileRef = C6F61F9517016B310073032E /* MCOIMAPCapabilityOperation.mm */; }; C6BA2C121705F4E6003F0E9E /* MCOIMAPSearchExpression.mm in Sources */ = {isa = PBXBuildFile; fileRef = C6F61F9817016B460073032E /* MCOIMAPSearchExpression.mm */; }; - C6BA2C131705F4E6003F0E9E /* MCOIMAPFolderInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = C6F61F9E17016EA00073032E /* MCOIMAPFolderInfo.m */; }; + C6BA2C131705F4E6003F0E9E /* MCOIMAPFolderInfo.mm in Sources */ = {isa = PBXBuildFile; fileRef = C6F61F9E17016EA00073032E /* MCOIMAPFolderInfo.mm */; }; C6BA2C141705F4E6003F0E9E /* MCOIMAPBaseOperation.mm in Sources */ = {isa = PBXBuildFile; fileRef = C6F61FB41702AB2F0073032E /* MCOIMAPBaseOperation.mm */; }; C6BD288F170BD71100A91AC1 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C6BD288E170BD71100A91AC1 /* Cocoa.framework */; }; C6BD28A3170BD84F00A91AC1 /* libMailCore.a in Frameworks */ = {isa = PBXBuildFile; fileRef = C64EA537169E772200778456 /* libMailCore.a */; }; @@ -844,7 +848,7 @@ C6F61F9317016B250073032E /* MCOIMAPIdentityOperation.mm in Sources */ = {isa = PBXBuildFile; fileRef = C6F61F9217016B250073032E /* MCOIMAPIdentityOperation.mm */; }; C6F61F9617016B310073032E /* MCOIMAPCapabilityOperation.mm in Sources */ = {isa = PBXBuildFile; fileRef = C6F61F9517016B310073032E /* MCOIMAPCapabilityOperation.mm */; }; C6F61F9917016B460073032E /* MCOIMAPSearchExpression.mm in Sources */ = {isa = PBXBuildFile; fileRef = C6F61F9817016B460073032E /* MCOIMAPSearchExpression.mm */; }; - C6F61F9F17016EA10073032E /* MCOIMAPFolderInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = C6F61F9E17016EA00073032E /* MCOIMAPFolderInfo.m */; }; + C6F61F9F17016EA10073032E /* MCOIMAPFolderInfo.mm in Sources */ = {isa = PBXBuildFile; fileRef = C6F61F9E17016EA00073032E /* MCOIMAPFolderInfo.mm */; }; C6F61FA0170187B80073032E /* MCOIMAPFolderInfoOperation.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = C6F61F79170169EE0073032E /* MCOIMAPFolderInfoOperation.h */; }; C6F61FA1170187BA0073032E /* MCOIMAPFolderInfo.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = C6F61F9D17016EA00073032E /* MCOIMAPFolderInfo.h */; }; C6F61FA2170187BC0073032E /* MCOIMAPAppendMessageOperation.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = C6F61F7C170169FB0073032E /* MCOIMAPAppendMessageOperation.h */; }; @@ -942,6 +946,7 @@ dstPath = include/MailCore; dstSubfolderSpec = 16; files = ( + C673EBF01A46B45300A53F7F /* MCIMAPFolderInfo.h in CopyFiles */, C6181D3319FE0F8D0088FBBC /* MCIMAPFetchParsedContentOperation.h in CopyFiles */, C6181D3219FE0F8A0088FBBC /* MCOIMAPFetchParsedContentOperation.h in CopyFiles */, C6D4FD3819FA9F57001F7E01 /* MCONNTPFetchServerTimeOperation.h in CopyFiles */, @@ -1170,6 +1175,7 @@ dstPath = include/MailCore; dstSubfolderSpec = 16; files = ( + C673EBEF1A46B44E00A53F7F /* MCIMAPFolderInfo.h in CopyFiles */, 8199FBF719FAF3AF0040BBC3 /* MCOIMAPFetchParsedContentOperation.h in CopyFiles */, 8199FBF819FAF3AF0040BBC3 /* MCIMAPFetchParsedContentOperation.h in CopyFiles */, C6D4FD3619FA9F4F001F7E01 /* MCNNTPFetchServerTimeOperation.h in CopyFiles */, @@ -1732,6 +1738,8 @@ C64FF39016B3C13000F8C162 /* MCOObjectWrapper.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MCOObjectWrapper.mm; sourceTree = "<group>"; }; C668E2C51735C8D500A2BB47 /* MCObjectMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MCObjectMac.mm; sourceTree = "<group>"; }; C668E2CA1735CB8900A2BB47 /* MCAutoreleasePoolMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MCAutoreleasePoolMac.mm; sourceTree = "<group>"; }; + C673EBEB1A46B41000A53F7F /* MCIMAPFolderInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MCIMAPFolderInfo.cpp; sourceTree = "<group>"; }; + C673EBEC1A46B41000A53F7F /* MCIMAPFolderInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MCIMAPFolderInfo.h; sourceTree = "<group>"; }; C67597C117A8D65000DA69DF /* MCBase64.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = MCBase64.c; sourceTree = "<group>"; }; C67597C417A8D66000DA69DF /* MCBase64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MCBase64.h; sourceTree = "<group>"; }; C68B2AEB1778A589005E61EF /* MCConnectionLogger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MCConnectionLogger.h; sourceTree = "<group>"; }; @@ -1881,7 +1889,7 @@ C6F61F9717016B460073032E /* MCOIMAPSearchExpression.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MCOIMAPSearchExpression.h; sourceTree = "<group>"; }; C6F61F9817016B460073032E /* MCOIMAPSearchExpression.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MCOIMAPSearchExpression.mm; sourceTree = "<group>"; }; C6F61F9D17016EA00073032E /* MCOIMAPFolderInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MCOIMAPFolderInfo.h; sourceTree = "<group>"; }; - C6F61F9E17016EA00073032E /* MCOIMAPFolderInfo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MCOIMAPFolderInfo.m; sourceTree = "<group>"; }; + C6F61F9E17016EA00073032E /* MCOIMAPFolderInfo.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MCOIMAPFolderInfo.mm; sourceTree = "<group>"; }; C6F61FB31702AB2A0073032E /* MCOIMAPBaseOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MCOIMAPBaseOperation.h; sourceTree = "<group>"; }; C6F61FB41702AB2F0073032E /* MCOIMAPBaseOperation.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MCOIMAPBaseOperation.mm; sourceTree = "<group>"; }; C6F7B19D17A1C15200BE78BB /* MCCertificateUtils.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MCCertificateUtils.cpp; sourceTree = "<group>"; }; @@ -2251,6 +2259,8 @@ C62C6ED316A2A0E600737497 /* MCIMAPIdentityOperation.h */, C62C6ED616A398FA00737497 /* MCIMAPFolderInfoOperation.cpp */, C62C6ED716A398FA00737497 /* MCIMAPFolderInfoOperation.h */, + C673EBEB1A46B41000A53F7F /* MCIMAPFolderInfo.cpp */, + C673EBEC1A46B41000A53F7F /* MCIMAPFolderInfo.h */, C64BB22916E5C0A3000DB34C /* MCIMAPCapabilityOperation.cpp */, C64BB22A16E5C0A3000DB34C /* MCIMAPCapabilityOperation.h */, 4B3C1BDF17ABF4BB008BBF4C /* MCIMAPQuotaOperation.cpp */, @@ -2739,7 +2749,7 @@ C6F5B9EF16FEA3D700D9DABD /* MCOIMAPPart.h */, C6F5B9F016FEA3D700D9DABD /* MCOIMAPPart.mm */, C6F61F9D17016EA00073032E /* MCOIMAPFolderInfo.h */, - C6F61F9E17016EA00073032E /* MCOIMAPFolderInfo.m */, + C6F61F9E17016EA00073032E /* MCOIMAPFolderInfo.mm */, F87F190816BB62690012652F /* MCOIMAPFetchFoldersOperation.h */, F87F190B16BB62B00012652F /* MCOIMAPFetchFoldersOperation.mm */, C623C58D16FE6B45001BBEFC /* MCOIMAPOperation.h */, @@ -3287,11 +3297,12 @@ C6F61F9617016B310073032E /* MCOIMAPCapabilityOperation.mm in Sources */, C6E665BB1796500C0063F2CF /* unzip.c in Sources */, C6F61F9917016B460073032E /* MCOIMAPSearchExpression.mm in Sources */, - C6F61F9F17016EA10073032E /* MCOIMAPFolderInfo.m in Sources */, + C6F61F9F17016EA10073032E /* MCOIMAPFolderInfo.mm in Sources */, C6D4FD3F19FB7534001F7E01 /* MCMessageParserMac.mm in Sources */, C6F61FB51702AB340073032E /* MCOIMAPBaseOperation.mm in Sources */, C608167517759967001F1018 /* MCSMTPDisconnectOperation.cpp in Sources */, C6A81BBF17068E5E00882C15 /* MCOSMTPSession.mm in Sources */, + C673EBED1A46B41000A53F7F /* MCIMAPFolderInfo.cpp in Sources */, 8B0095CC1A00DDE700F84BC0 /* MCOSMTPLoginOperation.mm in Sources */, C6A81BC317068E9500882C15 /* MCOSMTPSendOperation.mm in Sources */, C6A81BC717068EB000882C15 /* MCOSMTPOperation.mm in Sources */, @@ -3533,9 +3544,10 @@ C6E665BC1796500C0063F2CF /* unzip.c in Sources */, C6BA2C121705F4E6003F0E9E /* MCOIMAPSearchExpression.mm in Sources */, C6D4FD4019FB7786001F7E01 /* MCMessageParserMac.mm in Sources */, - C6BA2C131705F4E6003F0E9E /* MCOIMAPFolderInfo.m in Sources */, + C6BA2C131705F4E6003F0E9E /* MCOIMAPFolderInfo.mm in Sources */, C6BA2C141705F4E6003F0E9E /* MCOIMAPBaseOperation.mm in Sources */, C608167617759968001F1018 /* MCSMTPDisconnectOperation.cpp in Sources */, + C673EBEE1A46B41000A53F7F /* MCIMAPFolderInfo.cpp in Sources */, C6A81BC017068E5E00882C15 /* MCOSMTPSession.mm in Sources */, 8B0095CE1A00DE7700F84BC0 /* MCOSMTPLoginOperation.mm in Sources */, C6A81BC417068E9500882C15 /* MCOSMTPSendOperation.mm in Sources */, diff --git a/scripts/include.sh/build-dep.sh b/scripts/include.sh/build-dep.sh index c167c548..ad66be7e 100755 --- a/scripts/include.sh/build-dep.sh +++ b/scripts/include.sh/build-dep.sh @@ -331,7 +331,12 @@ get_prebuilt_dep() curl -O "$url/$name/$name-$version.zip" unzip -q "$name-$version.zip" rm -rf "$scriptpath/../Externals/$name" - mv "$name-$version"/* "$scriptpath/../Externals" + cd "$name-$version" + for folder in * ; do + rm -rf "$scriptpath/../Externals/$folder" + mv "$folder" "$scriptpath/../Externals" + done + cd .. rm -f "$scriptpath/../Externals/git-rev" rm -rf "$tempbuilddir" diff --git a/src/async/imap/MCAsyncIMAP.h b/src/async/imap/MCAsyncIMAP.h index 15c9e482..8a490aa8 100755 --- a/src/async/imap/MCAsyncIMAP.h +++ b/src/async/imap/MCAsyncIMAP.h @@ -19,6 +19,7 @@ #include <MailCore/MCIMAPFetchContentOperation.h> #include <MailCore/MCIMAPFetchParsedContentOperation.h> #include <MailCore/MCIMAPIdleOperation.h> +#include <MailCore/MCIMAPFolderInfo.h> #include <MailCore/MCIMAPFolderInfoOperation.h> #include <MailCore/MCIMAPFolderStatusOperation.h> #include <MailCore/MCIMAPSession.h> diff --git a/src/async/imap/MCIMAPAsyncSession.cpp b/src/async/imap/MCIMAPAsyncSession.cpp index f3a55a5e..d9fb38d5 100755 --- a/src/async/imap/MCIMAPAsyncSession.cpp +++ b/src/async/imap/MCIMAPAsyncSession.cpp @@ -485,8 +485,8 @@ IMAPFetchMessagesOperation * IMAPAsyncSession::fetchMessagesByNumberOperation(St return op; } -IMAPFetchMessagesOperation * IMAPAsyncSession::syncMessagesByUID(String * folder, IMAPMessagesRequestKind requestKind, - IndexSet * uids, uint64_t modSeq) +IMAPFetchMessagesOperation * IMAPAsyncSession::syncMessagesByUIDOperation(String * folder, IMAPMessagesRequestKind requestKind, + IndexSet * uids, uint64_t modSeq) { IMAPFetchMessagesOperation * op = new IMAPFetchMessagesOperation(); op->setMainSession(this); diff --git a/src/async/imap/MCIMAPAsyncSession.h b/src/async/imap/MCIMAPAsyncSession.h index 4a61393f..64258674 100755 --- a/src/async/imap/MCIMAPAsyncSession.h +++ b/src/async/imap/MCIMAPAsyncSession.h @@ -127,8 +127,8 @@ namespace mailcore { IndexSet * indexes); virtual IMAPFetchMessagesOperation * fetchMessagesByNumberOperation(String * folder, IMAPMessagesRequestKind requestKind, IndexSet * indexes); - virtual IMAPFetchMessagesOperation * syncMessagesByUID(String * folder, IMAPMessagesRequestKind requestKind, - IndexSet * indexes, uint64_t modSeq); + virtual IMAPFetchMessagesOperation * syncMessagesByUIDOperation(String * folder, IMAPMessagesRequestKind requestKind, + IndexSet * indexes, uint64_t modSeq); virtual IMAPFetchContentOperation * fetchMessageByUIDOperation(String * folder, uint32_t uid, bool urgent = false); virtual IMAPFetchContentOperation * fetchMessageAttachmentByUIDOperation(String * folder, uint32_t uid, String * partID, diff --git a/src/async/imap/MCIMAPFolderInfo.cpp b/src/async/imap/MCIMAPFolderInfo.cpp new file mode 100644 index 00000000..2f790ca4 --- /dev/null +++ b/src/async/imap/MCIMAPFolderInfo.cpp @@ -0,0 +1,106 @@ +// +// MCIMAPFolderInfo.cpp +// mailcore2 +// +// Created by DINH Viêt Hoà on 12/6/14. +// Copyright (c) 2014 MailCore. All rights reserved. +// + +#include "MCIMAPFolderInfo.h" + +using namespace mailcore; + +void IMAPFolderInfo::init() +{ + mUidNext = 0; + mUidValidity = 0; + mMessageCount = 0; + mModSequenceValue = 0; + mFirstUnseenUid = 0; + mAllowsNewPermanentFlags = false; +} + +IMAPFolderInfo::IMAPFolderInfo() +{ + init(); +} + +IMAPFolderInfo::IMAPFolderInfo(IMAPFolderInfo * other) +{ + init(); + setUidNext(other->uidNext()); + setUidValidity(other->uidValidity()); + setModSequenceValue(other->modSequenceValue()); + setMessageCount(other->messageCount()); + setFirstUnseenUid(other->firstUnseenUid()); + setAllowsNewPermanentFlags(other->allowsNewPermanentFlags()); +} + +IMAPFolderInfo::~IMAPFolderInfo() +{ +} + +Object * IMAPFolderInfo::copy() +{ + return new IMAPFolderInfo(this); +} + +void IMAPFolderInfo::setUidNext(uint32_t uidNext) +{ + mUidNext = uidNext; +} + +uint32_t IMAPFolderInfo::uidNext() +{ + return mUidNext; +} + +void IMAPFolderInfo::setUidValidity(uint32_t uidValidity) +{ + mUidValidity = uidValidity; +} + +uint32_t IMAPFolderInfo::uidValidity() +{ + return mUidValidity; +} + +void IMAPFolderInfo::setModSequenceValue(uint64_t modSequenceValue) +{ + mModSequenceValue = modSequenceValue; +} + +uint64_t IMAPFolderInfo::modSequenceValue() +{ + return mModSequenceValue; +} + +void IMAPFolderInfo::setMessageCount(int messageCount) +{ + mMessageCount = messageCount; +} + +int IMAPFolderInfo::messageCount() +{ + return mMessageCount; +} + +void IMAPFolderInfo::setFirstUnseenUid(uint32_t firstUnseenUid) +{ + mFirstUnseenUid = firstUnseenUid; +} + +uint32_t IMAPFolderInfo::firstUnseenUid() +{ + return mFirstUnseenUid; +} + +void IMAPFolderInfo::setAllowsNewPermanentFlags(bool allowsNewPermanentFlags) +{ + mAllowsNewPermanentFlags = allowsNewPermanentFlags; +} + +bool IMAPFolderInfo::allowsNewPermanentFlags() +{ + return mAllowsNewPermanentFlags; +} diff --git a/src/async/imap/MCIMAPFolderInfo.h b/src/async/imap/MCIMAPFolderInfo.h new file mode 100644 index 00000000..c0fa7c35 --- /dev/null +++ b/src/async/imap/MCIMAPFolderInfo.h @@ -0,0 +1,63 @@ +// +// MCIMAPFolderInfo.h +// mailcore2 +// +// Created by DINH Viêt Hoà on 12/6/14. +// Copyright (c) 2014 MailCore. All rights reserved. +// + +#ifndef MAILCORE_MCIMAPFolderInfo_H + +#define MAILCORE_MCIMAPFolderInfo_H + +#include <MailCore/MCBaseTypes.h> +#include <MailCore/MCMessageConstants.h> + +#ifdef __cplusplus + +namespace mailcore { + + class MAILCORE_EXPORT IMAPFolderInfo : public Object { + public: + IMAPFolderInfo(); + virtual ~IMAPFolderInfo(); + + virtual void setUidNext(uint32_t uidNext); + virtual uint32_t uidNext(); + + virtual void setUidValidity(uint32_t uidValidity); + virtual uint32_t uidValidity(); + + virtual void setModSequenceValue(uint64_t modSequenceValue); + virtual uint64_t modSequenceValue(); + + virtual void setMessageCount(int messageCount); + virtual int messageCount(); + + virtual void setFirstUnseenUid(uint32_t firstUnseenUid); + virtual uint32_t firstUnseenUid(); + + virtual void setAllowsNewPermanentFlags(bool allowsNewPermanentFlags); + virtual bool allowsNewPermanentFlags(); + + public: // subclass behavior + IMAPFolderInfo(IMAPFolderInfo * other); + virtual Object * copy(); + + private: + uint32_t mUidNext; + uint32_t mUidValidity; + uint64_t mModSequenceValue; + int mMessageCount; + uint32_t mFirstUnseenUid; + bool mAllowsNewPermanentFlags; + + void init(); + }; + +} + +#endif + +#endif + diff --git a/src/async/imap/MCIMAPFolderInfoOperation.cpp b/src/async/imap/MCIMAPFolderInfoOperation.cpp index 0ea0d005..fc4e4462 100644 --- a/src/async/imap/MCIMAPFolderInfoOperation.cpp +++ b/src/async/imap/MCIMAPFolderInfoOperation.cpp @@ -10,51 +10,23 @@ #include "MCIMAPSession.h" #include "MCIMAPAsyncConnection.h" +#include "MCIMAPFolderInfo.h" using namespace mailcore; IMAPFolderInfoOperation::IMAPFolderInfoOperation() { - mUidNext = 0; - mUidValidity = 0; - mMessageCount = 0; - mModSequenceValue = 0; - mFirstUnseenUid = 0; - mAllowsNewPermanentFlags = false; + mInfo = NULL; } IMAPFolderInfoOperation::~IMAPFolderInfoOperation() { + MC_SAFE_RELEASE(mInfo); } -uint32_t IMAPFolderInfoOperation::uidNext() +IMAPFolderInfo * IMAPFolderInfoOperation::info() { - return mUidNext; -} - -uint32_t IMAPFolderInfoOperation::uidValidity() -{ - return mUidValidity; -} - -uint64_t IMAPFolderInfoOperation::modSequenceValue() -{ - return mModSequenceValue; -} - -int IMAPFolderInfoOperation::messageCount() -{ - return mMessageCount; -} - -uint32_t IMAPFolderInfoOperation::firstUnseenUid() -{ - return mFirstUnseenUid; -} - -bool IMAPFolderInfoOperation::allowsNewPermanentFlags() -{ - return mAllowsNewPermanentFlags; + return mInfo; } void IMAPFolderInfoOperation::main() @@ -73,14 +45,14 @@ void IMAPFolderInfoOperation::main() return; } - - mUidNext = session()->session()->uidNext(); - mUidValidity = session()->session()->uidValidity(); - mModSequenceValue = session()->session()->modSequenceValue(); - mMessageCount = session()->session()->lastFolderMessageCount(); - mFirstUnseenUid = session()->session()->firstUnseenUid(); - mAllowsNewPermanentFlags = session()->session()->allowsNewPermanentFlags(); - + mInfo = new IMAPFolderInfo(); + mInfo->setUidNext(session()->session()->uidNext()); + mInfo->setUidValidity(session()->session()->uidValidity()); + mInfo->setModSequenceValue(session()->session()->modSequenceValue()); + mInfo->setMessageCount(session()->session()->lastFolderMessageCount()); + mInfo->setFirstUnseenUid(session()->session()->firstUnseenUid()); + mInfo->setAllowsNewPermanentFlags(session()->session()->allowsNewPermanentFlags()); + setError(error); } diff --git a/src/async/imap/MCIMAPFolderInfoOperation.h b/src/async/imap/MCIMAPFolderInfoOperation.h index b29f40a2..e0b5128c 100644 --- a/src/async/imap/MCIMAPFolderInfoOperation.h +++ b/src/async/imap/MCIMAPFolderInfoOperation.h @@ -15,31 +15,23 @@ #ifdef __cplusplus namespace mailcore { + + class IMAPFolderInfo; class MAILCORE_EXPORT IMAPFolderInfoOperation : public IMAPOperation { public: IMAPFolderInfoOperation(); virtual ~IMAPFolderInfoOperation(); - - virtual uint32_t uidNext(); - virtual uint32_t uidValidity(); - virtual uint64_t modSequenceValue(); - virtual int messageCount(); - virtual uint32_t firstUnseenUid(); - virtual bool allowsNewPermanentFlags(); - + + IMAPFolderInfo * info(); + public: // subclass behavior virtual void main(); private: - - uint32_t mUidNext; - uint32_t mUidValidity; - uint64_t mModSequenceValue; - int mMessageCount; - uint32_t mFirstUnseenUid; - bool mAllowsNewPermanentFlags; - + + IMAPFolderInfo * mInfo; + }; } diff --git a/src/cmake/async.cmake b/src/cmake/async.cmake index 2f6910f2..c1eb3faf 100644 --- a/src/cmake/async.cmake +++ b/src/cmake/async.cmake @@ -17,6 +17,7 @@ set(async_imap_files async/imap/MCIMAPFetchFoldersOperation.cpp async/imap/MCIMAPFetchMessagesOperation.cpp async/imap/MCIMAPFetchNamespaceOperation.cpp + async/imap/MCIMAPFolderInfo.cpp async/imap/MCIMAPFolderInfoOperation.cpp async/imap/MCIMAPFolderStatusOperation.cpp async/imap/MCIMAPIdentityOperation.cpp diff --git a/src/cmake/objc.cmake b/src/cmake/objc.cmake index 0de041e7..f67d76e4 100644 --- a/src/cmake/objc.cmake +++ b/src/cmake/objc.cmake @@ -21,7 +21,7 @@ set(objc_imap_files objc/imap/MCOIMAPFetchMessagesOperation.mm objc/imap/MCOIMAPFetchNamespaceOperation.mm objc/imap/MCOIMAPFolder.mm - objc/imap/MCOIMAPFolderInfo.m + objc/imap/MCOIMAPFolderInfo.mm objc/imap/MCOIMAPFolderInfoOperation.mm objc/imap/MCOIMAPFolderStatus.mm objc/imap/MCOIMAPFolderStatusOperation.mm diff --git a/src/core/basetypes/MCIndexSet.h b/src/core/basetypes/MCIndexSet.h index e76517db..2e2f4892 100644 --- a/src/core/basetypes/MCIndexSet.h +++ b/src/core/basetypes/MCIndexSet.h @@ -21,7 +21,7 @@ namespace mailcore { class MAILCORE_EXPORT IndexSet : public Object { public: IndexSet(); - IndexSet(IndexSet * o); + virtual ~IndexSet(); static IndexSet * indexSet(); static IndexSet * indexSetWithRange(Range range); @@ -45,7 +45,7 @@ namespace mailcore { virtual void removeAllIndexes(); public: // subclass behavior - virtual ~IndexSet(); + IndexSet(IndexSet * o); virtual String * description(); virtual Object * copy(); virtual HashMap * serializable(); diff --git a/src/core/basetypes/MCMainThreadAndroid.cpp b/src/core/basetypes/MCMainThreadAndroid.cpp index 36792cb1..cc41bb88 100644 --- a/src/core/basetypes/MCMainThreadAndroid.cpp +++ b/src/core/basetypes/MCMainThreadAndroid.cpp @@ -18,6 +18,7 @@ #include "MCAssert.h" #include "MCLog.h" #include "MCAutoreleasePool.h" +#include "TypesUtils.h" using namespace mailcore; @@ -53,6 +54,7 @@ JNIEXPORT void JNICALL Java_com_libmailcore_MainThreadUtils_setupNative(JNIEnv * jclass localClass = env->FindClass("com/libmailcore/MainThreadUtils"); s_mainThreadUtilsClass = reinterpret_cast<jclass>(env->NewGlobalRef(localClass)); MCAssert(s_mainThreadUtilsClass != NULL); + MCTypesUtilsInit(); pool->release(); } @@ -101,10 +103,10 @@ void mailcore::callOnMainThreadAndWait(void (* function)(void *), void * context jmethodID mid = env->GetMethodID(s_mainThreadUtilsClass, "runOnMainThreadAndWait", "(J)V"); MCAssert(mid != NULL); env->CallVoidMethod(s_mainThreadUtils, mid, (jlong) data); - + // Wait. mailsem_down(data->sem); - + mailsem_free(data->sem); free(data); } diff --git a/src/core/basetypes/com_libmailcore_MainThreadUtils.h b/src/core/basetypes/com_libmailcore_MainThreadUtils.h deleted file mode 100644 index 327d9910..00000000 --- a/src/core/basetypes/com_libmailcore_MainThreadUtils.h +++ /dev/null @@ -1,37 +0,0 @@ -/* DO NOT EDIT THIS FILE - it is machine generated */ -#include <jni.h> -/* Header for class com_libmailcore_MainThreadUtils */ - -#ifndef _Included_com_libmailcore_MainThreadUtils -#define _Included_com_libmailcore_MainThreadUtils -#ifdef __cplusplus -extern "C" { -#endif -/* - * Class: com_libmailcore_MainThreadUtils - * Method: setupNative - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_com_libmailcore_MainThreadUtils_setupNative - (JNIEnv *, jobject); - -/* - * Class: com_libmailcore_MainThreadUtils - * Method: runIdentifier - * Signature: (J)V - */ -JNIEXPORT void JNICALL Java_com_libmailcore_MainThreadUtils_runIdentifier - (JNIEnv *, jobject, jlong); - -/* - * Class: com_libmailcore_MainThreadUtils - * Method: runIdentifierAndNotify - * Signature: (J)V - */ -JNIEXPORT void JNICALL Java_com_libmailcore_MainThreadUtils_runIdentifierAndNotify - (JNIEnv *, jobject, jlong); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/src/core/renderer/MCHTMLRendererCallback.cpp b/src/core/renderer/MCHTMLRendererCallback.cpp index edaf7e92..fb492c9e 100644 --- a/src/core/renderer/MCHTMLRendererCallback.cpp +++ b/src/core/renderer/MCHTMLRendererCallback.cpp @@ -15,6 +15,14 @@ using namespace mailcore; +HTMLRendererTemplateCallback::HTMLRendererTemplateCallback() +{ +} + +HTMLRendererTemplateCallback::~HTMLRendererTemplateCallback() +{ +} + mailcore::HashMap * HTMLRendererTemplateCallback::templateValuesForHeader(mailcore::MessageHeader * header) { mailcore::HashMap * result = mailcore::HashMap::hashMap(); diff --git a/src/core/renderer/MCHTMLRendererCallback.h b/src/core/renderer/MCHTMLRendererCallback.h index 7c20f18a..a12a3e45 100644 --- a/src/core/renderer/MCHTMLRendererCallback.h +++ b/src/core/renderer/MCHTMLRendererCallback.h @@ -24,14 +24,17 @@ namespace mailcore { public: HTMLRendererIMAPCallback() {} virtual ~HTMLRendererIMAPCallback() {} - + virtual Data * dataForIMAPPart(String * folder, IMAPPart * part) { return NULL; } virtual void prefetchAttachmentIMAPPart(String * folder, IMAPPart * part) {} virtual void prefetchImageIMAPPart(String * folder, IMAPPart * part) {} }; - + class MAILCORE_EXPORT HTMLRendererTemplateCallback { public: + HTMLRendererTemplateCallback(); + virtual ~HTMLRendererTemplateCallback(); + virtual bool canPreviewPart(AbstractPart * part); virtual bool shouldShowPart(AbstractPart * part); diff --git a/src/core/rfc822/MCMessageParser.cpp b/src/core/rfc822/MCMessageParser.cpp index 404bc862..71071c02 100644 --- a/src/core/rfc822/MCMessageParser.cpp +++ b/src/core/rfc822/MCMessageParser.cpp @@ -72,6 +72,11 @@ void MessageParser::setBytes(char * dataBytes, unsigned int dataLength) mailmessage_free(msg); } +MessageParser::MessageParser() +{ + init(); +} + MessageParser::MessageParser(Data * data) { init(); @@ -118,7 +123,9 @@ String * MessageParser::description() String * result = String::string(); result->appendUTF8Format("<%s:%p ", MCUTF8(className()), this); result->appendUTF8Format("<%p>", mMainPart); - result->appendString(mMainPart->description()); + if (mMainPart != NULL) { + result->appendString(mMainPart->description()); + } result->appendUTF8Characters(">"); return result; @@ -140,11 +147,17 @@ Object * MessageParser::copy() AbstractPart * MessageParser::partForContentID(String * contentID) { + if (mainPart() == NULL) { + return NULL; + } return mainPart()->partForContentID(contentID); } AbstractPart * MessageParser::partForUniqueID(String * uniqueID) { + if (mainPart() == NULL) { + return NULL; + } return mainPart()->partForUniqueID(uniqueID); } diff --git a/src/core/rfc822/MCMessageParser.h b/src/core/rfc822/MCMessageParser.h index 8d2fe4a6..048cee60 100644 --- a/src/core/rfc822/MCMessageParser.h +++ b/src/core/rfc822/MCMessageParser.h @@ -20,6 +20,7 @@ namespace mailcore { static MessageParser * messageParserWithData(Data * data); static MessageParser * messageParserWithContentsOfFile(String * filename); + MessageParser(); MessageParser(Data * data); virtual ~MessageParser(); diff --git a/src/objc/imap/MCOIMAPFolderInfo.h b/src/objc/imap/MCOIMAPFolderInfo.h index 53ad35b8..1397e841 100644 --- a/src/objc/imap/MCOIMAPFolderInfo.h +++ b/src/objc/imap/MCOIMAPFolderInfo.h @@ -14,10 +14,7 @@ /* This class holds IMAP folder metadata */ -@interface MCOIMAPFolderInfo : NSObject - -/** Create an empty instance */ -+ (MCOIMAPFolderInfo *) info; +@interface MCOIMAPFolderInfo : NSObject <NSCopying> /** The folder's IMAP UIDNEXT value. Used to determine the uid for the next received message. */ @property (nonatomic, assign) uint32_t uidNext; diff --git a/src/objc/imap/MCOIMAPFolderInfo.m b/src/objc/imap/MCOIMAPFolderInfo.m deleted file mode 100644 index be1d2c3e..00000000 --- a/src/objc/imap/MCOIMAPFolderInfo.m +++ /dev/null @@ -1,32 +0,0 @@ -// -// MCOIMAPFolderInfo.m -// mailcore2 -// -// Created by DINH Viêt Hoà on 3/25/13. -// Copyright (c) 2013 MailCore. All rights reserved. -// - -#import "MCOIMAPFolderInfo.h" - -@implementation MCOIMAPFolderInfo { - uint32_t _uidNext; - uint32_t _uidValidity; - uint64_t _modSequenceValue; - int _messageCount; - uint32_t _firstUnseenUid; - BOOL _allowsNewPermanentFlags; -} - -@synthesize uidNext = _uidNext; -@synthesize uidValidity = _uidValidity; -@synthesize modSequenceValue = _modSequenceValue; -@synthesize messageCount = _messageCount; -@synthesize firstUnseenUid = _firstUnseenUid; -@synthesize allowsNewPermanentFlags = _allowsNewPermanentFlags; - -+ (MCOIMAPFolderInfo *) info -{ - return [[[MCOIMAPFolderInfo alloc] init] autorelease]; -} - -@end diff --git a/src/objc/imap/MCOIMAPFolderInfo.mm b/src/objc/imap/MCOIMAPFolderInfo.mm new file mode 100644 index 00000000..50c7f995 --- /dev/null +++ b/src/objc/imap/MCOIMAPFolderInfo.mm @@ -0,0 +1,72 @@ +// +// MCOIMAPFolderInfo.m +// mailcore2 +// +// Created by DINH Viêt Hoà on 3/25/13. +// Copyright (c) 2013 MailCore. All rights reserved. +// + +#import "MCOIMAPFolderInfo.h" +#import "NSObject+MCO.h" + +#include "MCIMAPFolderInfo.h" + +#define nativeType mailcore::IMAPFolderInfo + +@implementation MCOIMAPFolderInfo { + mailcore::IMAPFolderInfo * _nativeInfo; +} + ++ (void) load +{ + MCORegisterClass(self, &typeid(nativeType)); +} + +- (id) initWithMCFolderInfo:(mailcore::IMAPFolderInfo *)info +{ + self = [super init]; + + info->retain(); + _nativeInfo = info; + + return self; +} + +- (void) dealloc +{ + MC_SAFE_RELEASE(_nativeInfo); + [super dealloc]; +} + ++ (NSObject *) mco_objectWithMCObject:(mailcore::Object *)object +{ + mailcore::IMAPFolderInfo * info = (mailcore::IMAPFolderInfo *) object; + return [[[self alloc] initWithMCFolderInfo:info] autorelease]; +} + +- (mailcore::Object *) mco_mcObject +{ + return _nativeInfo; +} + +- (id) copyWithZone:(NSZone *)zone +{ + nativeType * nativeObject = (nativeType *) [self mco_mcObject]->copy(); + id result = [[self class] mco_objectWithMCObject:nativeObject]; + MC_SAFE_RELEASE(nativeObject); + return [result retain]; +} + +- (NSString *) description +{ + return MCO_OBJC_BRIDGE_GET(description); +} + +MCO_OBJC_SYNTHESIZE_SCALAR(uint32_t, uint32_t, setUidNext, uidNext) +MCO_OBJC_SYNTHESIZE_SCALAR(uint32_t, uint32_t, setUidValidity, uidValidity) +MCO_OBJC_SYNTHESIZE_SCALAR(uint64_t, uint64_t, setModSequenceValue, modSequenceValue) +MCO_OBJC_SYNTHESIZE_SCALAR(int, int, setMessageCount, messageCount) +MCO_OBJC_SYNTHESIZE_SCALAR(uint32_t, uint32_t, setFirstUnseenUid, firstUnseenUid) +MCO_OBJC_SYNTHESIZE_SCALAR(BOOL, bool, setAllowsNewPermanentFlags, allowsNewPermanentFlags) + +@end diff --git a/src/objc/imap/MCOIMAPFolderInfoOperation.mm b/src/objc/imap/MCOIMAPFolderInfoOperation.mm index f4d322af..10c22462 100644 --- a/src/objc/imap/MCOIMAPFolderInfoOperation.mm +++ b/src/objc/imap/MCOIMAPFolderInfoOperation.mm @@ -56,20 +56,12 @@ typedef void (^CompletionType)(NSError *error, MCOIMAPFolderInfo *info); { if (_completionBlock == NULL) return; - + nativeType *op = MCO_NATIVE_INSTANCE; if (op->error() == mailcore::ErrorNone) { - MCOIMAPFolderInfo * info = [MCOIMAPFolderInfo info]; - [info setUidNext:MCO_NATIVE_INSTANCE->uidNext()]; - [info setUidValidity:MCO_NATIVE_INSTANCE->uidValidity()]; - [info setModSequenceValue:MCO_NATIVE_INSTANCE->modSequenceValue()]; - [info setMessageCount:MCO_NATIVE_INSTANCE->messageCount()]; - [info setFirstUnseenUid:MCO_NATIVE_INSTANCE->firstUnseenUid()]; - [info setAllowsNewPermanentFlags:MCO_NATIVE_INSTANCE->allowsNewPermanentFlags()]; - + MCOIMAPFolderInfo * info = MCO_TO_OBJC(op->info()); _completionBlock(nil, info); - } - else { + } else { _completionBlock([NSError mco_errorWithErrorCode:op->error()], nil); } [_completionBlock release]; diff --git a/src/objc/imap/MCOIMAPSession.mm b/src/objc/imap/MCOIMAPSession.mm index 325beda7..97673518 100755 --- a/src/objc/imap/MCOIMAPSession.mm +++ b/src/objc/imap/MCOIMAPSession.mm @@ -321,10 +321,10 @@ MCO_OBJC_SYNTHESIZE_SCALAR(dispatch_queue_t, dispatch_queue_t, setDispatchQueue, uids:(MCOIndexSet *)uids modSeq:(uint64_t)modSeq { - IMAPFetchMessagesOperation * coreOp = MCO_NATIVE_INSTANCE->syncMessagesByUID([folder mco_mcString], - (IMAPMessagesRequestKind) requestKind, - MCO_FROM_OBJC(IndexSet, uids), - modSeq); + IMAPFetchMessagesOperation * coreOp = MCO_NATIVE_INSTANCE->syncMessagesByUIDOperation([folder mco_mcString], + (IMAPMessagesRequestKind) requestKind, + MCO_FROM_OBJC(IndexSet, uids), + modSeq); return MCO_TO_OBJC_OP(coreOp); } |