aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rwxr-xr-xbuild-mac/mailcore2.xcodeproj/project.pbxproj28
-rwxr-xr-xsrc/async/imap/MCAsyncIMAP.h1
-rwxr-xr-xsrc/async/imap/MCIMAPAsyncConnection.cc36
-rwxr-xr-xsrc/async/imap/MCIMAPAsyncConnection.h1
-rwxr-xr-xsrc/async/imap/MCIMAPAsyncSession.cc32
-rwxr-xr-xsrc/async/imap/MCIMAPAsyncSession.h4
-rw-r--r--src/async/imap/MCIMAPFetchParsedContentOperation.cc79
-rw-r--r--src/async/imap/MCIMAPFetchParsedContentOperation.h53
-rw-r--r--src/cmake/async.cmake1
-rw-r--r--src/cmake/objc.cmake3
-rw-r--r--src/cmake/public-headers.cmake2
-rw-r--r--src/core/basetypes/MCData.cc36
-rw-r--r--src/core/basetypes/MCData.h4
-rw-r--r--src/core/basetypes/MCString.cc34
-rw-r--r--src/core/basetypes/MCString.h2
-rwxr-xr-xsrc/objc/imap/MCOIMAP.h1
-rw-r--r--src/objc/imap/MCOIMAPFetchParsedContentOperation.h44
-rw-r--r--src/objc/imap/MCOIMAPFetchParsedContentOperation.mm84
-rwxr-xr-xsrc/objc/imap/MCOIMAPSession.h119
-rwxr-xr-xsrc/objc/imap/MCOIMAPSession.mm28
20 files changed, 510 insertions, 82 deletions
diff --git a/build-mac/mailcore2.xcodeproj/project.pbxproj b/build-mac/mailcore2.xcodeproj/project.pbxproj
index 4e80d715..8005804b 100755
--- a/build-mac/mailcore2.xcodeproj/project.pbxproj
+++ b/build-mac/mailcore2.xcodeproj/project.pbxproj
@@ -524,6 +524,16 @@
4B3C1BE517AC0176008BBF4C /* MCIMAPQuotaOperation.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4B3C1BDF17ABF4BB008BBF4C /* MCIMAPQuotaOperation.cc */; };
4BE4029117B548B900ECC5E4 /* MCOIMAPQuotaOperation.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 4B3C1BDC17ABF306008BBF4C /* MCOIMAPQuotaOperation.h */; };
4BE4029217B548D900ECC5E4 /* MCIMAPQuotaOperation.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 4B3C1BE017ABF4BC008BBF4C /* MCIMAPQuotaOperation.h */; };
+ 8199FBE919FAEA440040BBC3 /* MCOIMAPFetchParsedContentOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = 8199FBE719FAEA440040BBC3 /* MCOIMAPFetchParsedContentOperation.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 8199FBEA19FAEA440040BBC3 /* MCOIMAPFetchParsedContentOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = 8199FBE719FAEA440040BBC3 /* MCOIMAPFetchParsedContentOperation.h */; settings = {ATTRIBUTES = (Public, ); }; };
+ 8199FBEB19FAEA440040BBC3 /* MCOIMAPFetchParsedContentOperation.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8199FBE819FAEA440040BBC3 /* MCOIMAPFetchParsedContentOperation.mm */; };
+ 8199FBEC19FAEA440040BBC3 /* MCOIMAPFetchParsedContentOperation.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8199FBE819FAEA440040BBC3 /* MCOIMAPFetchParsedContentOperation.mm */; };
+ 8199FBF119FAF1270040BBC3 /* MCIMAPFetchParsedContentOperation.cc in Sources */ = {isa = PBXBuildFile; fileRef = 8199FBEF19FAF1270040BBC3 /* MCIMAPFetchParsedContentOperation.cc */; };
+ 8199FBF219FAF1270040BBC3 /* MCIMAPFetchParsedContentOperation.cc in Sources */ = {isa = PBXBuildFile; fileRef = 8199FBEF19FAF1270040BBC3 /* MCIMAPFetchParsedContentOperation.cc */; };
+ 8199FBF519FAF1270040BBC3 /* MCIMAPFetchParsedContentOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = 8199FBF019FAF1270040BBC3 /* MCIMAPFetchParsedContentOperation.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 8199FBF619FAF1270040BBC3 /* MCIMAPFetchParsedContentOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = 8199FBF019FAF1270040BBC3 /* MCIMAPFetchParsedContentOperation.h */; settings = {ATTRIBUTES = (Public, ); }; };
+ 8199FBF719FAF3AF0040BBC3 /* MCOIMAPFetchParsedContentOperation.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 8199FBE719FAEA440040BBC3 /* MCOIMAPFetchParsedContentOperation.h */; };
+ 8199FBF819FAF3AF0040BBC3 /* MCIMAPFetchParsedContentOperation.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 8199FBF019FAF1270040BBC3 /* MCIMAPFetchParsedContentOperation.h */; };
8416A99D17F284F400B3C7DA /* MCOSMTPNoopOperation.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8416A99C17F284F400B3C7DA /* MCOSMTPNoopOperation.mm */; };
8416A99E17F284F400B3C7DA /* MCOSMTPNoopOperation.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8416A99C17F284F400B3C7DA /* MCOSMTPNoopOperation.mm */; };
8416A9A117F2871D00B3C7DA /* MCOIMAPNoopOperation.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8416A9A017F2871D00B3C7DA /* MCOIMAPNoopOperation.mm */; };
@@ -1642,6 +1652,8 @@
dstPath = include/MailCore;
dstSubfolderSpec = 16;
files = (
+ 8199FBF719FAF3AF0040BBC3 /* MCOIMAPFetchParsedContentOperation.h in CopyFiles */,
+ 8199FBF819FAF3AF0040BBC3 /* MCIMAPFetchParsedContentOperation.h in CopyFiles */,
C6D4FD3619FA9F4F001F7E01 /* MCNNTPFetchServerTimeOperation.h in CopyFiles */,
C6D4FD3519FA9F4D001F7E01 /* MCONNTPFetchServerTimeOperation.h in CopyFiles */,
C6D4FD3319FA9EB3001F7E01 /* MCONNTPFetchOverviewOperation.h in CopyFiles */,
@@ -1862,6 +1874,10 @@
4B3C1BDD17ABF307008BBF4C /* MCOIMAPQuotaOperation.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MCOIMAPQuotaOperation.mm; sourceTree = "<group>"; };
4B3C1BDF17ABF4BB008BBF4C /* MCIMAPQuotaOperation.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MCIMAPQuotaOperation.cc; sourceTree = "<group>"; };
4B3C1BE017ABF4BC008BBF4C /* MCIMAPQuotaOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MCIMAPQuotaOperation.h; sourceTree = "<group>"; };
+ 8199FBE719FAEA440040BBC3 /* MCOIMAPFetchParsedContentOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MCOIMAPFetchParsedContentOperation.h; sourceTree = "<group>"; };
+ 8199FBE819FAEA440040BBC3 /* MCOIMAPFetchParsedContentOperation.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MCOIMAPFetchParsedContentOperation.mm; sourceTree = "<group>"; };
+ 8199FBEF19FAF1270040BBC3 /* MCIMAPFetchParsedContentOperation.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MCIMAPFetchParsedContentOperation.cc; sourceTree = "<group>"; };
+ 8199FBF019FAF1270040BBC3 /* MCIMAPFetchParsedContentOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MCIMAPFetchParsedContentOperation.h; sourceTree = "<group>"; };
8416A99B17F284F400B3C7DA /* MCOSMTPNoopOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MCOSMTPNoopOperation.h; sourceTree = "<group>"; };
8416A99C17F284F400B3C7DA /* MCOSMTPNoopOperation.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MCOSMTPNoopOperation.mm; sourceTree = "<group>"; };
8416A99F17F2871D00B3C7DA /* MCOIMAPNoopOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MCOIMAPNoopOperation.h; sourceTree = "<group>"; };
@@ -2676,6 +2692,8 @@
C64EA81916A29ADB00778456 /* MCIMAPFetchMessagesOperation.h */,
C64EA81B16A29DC100778456 /* MCIMAPFetchContentOperation.cc */,
C64EA81C16A29DC400778456 /* MCIMAPFetchContentOperation.h */,
+ 8199FBEF19FAF1270040BBC3 /* MCIMAPFetchParsedContentOperation.cc */,
+ 8199FBF019FAF1270040BBC3 /* MCIMAPFetchParsedContentOperation.h */,
C64EA81E16A29E3D00778456 /* MCIMAPStoreFlagsOperation.cc */,
C64EA81F16A29E3F00778456 /* MCIMAPStoreFlagsOperation.h */,
C64EA82116A29E4F00778456 /* MCIMAPStoreLabelsOperation.cc */,
@@ -3185,6 +3203,8 @@
C6F61F8317016A200073032E /* MCOIMAPFetchMessagesOperation.mm */,
C6F61F8517016AD60073032E /* MCOIMAPFetchContentOperation.h */,
C6F61F8617016AD60073032E /* MCOIMAPFetchContentOperation.mm */,
+ 8199FBE719FAEA440040BBC3 /* MCOIMAPFetchParsedContentOperation.h */,
+ 8199FBE819FAEA440040BBC3 /* MCOIMAPFetchParsedContentOperation.mm */,
C6F61F8817016AE60073032E /* MCOIMAPSearchOperation.h */,
C6F61F8917016AE60073032E /* MCOIMAPSearchOperation.mm */,
C6F61F8B17016AFA0073032E /* MCOIMAPIdleOperation.h */,
@@ -3227,6 +3247,7 @@
27780E4519CFA3F500C77E44 /* MCONNTPOperation+Private.h in Headers */,
27780E4E19CFA3F500C77E44 /* MCOAbstractMessage+Private.h in Headers */,
27780E5219CFA3F600C77E44 /* MCOAbstractPart+Private.h in Headers */,
+ 8199FBF519FAF1270040BBC3 /* MCIMAPFetchParsedContentOperation.h in Headers */,
27780E5419CFA3F600C77E44 /* MCOAddress+Private.h in Headers */,
27780F2419CFA52800C77E44 /* MCOAttachment.h in Headers */,
27780F2519CFA52800C77E44 /* MCOMessageBuilder.h in Headers */,
@@ -3398,6 +3419,7 @@
27780ED519CFA40500C77E44 /* MCAbstractMultipart.h in Headers */,
27780ED619CFA40600C77E44 /* MCAbstractPart.h in Headers */,
27780ED719CFA40600C77E44 /* MCAddress.h in Headers */,
+ 8199FBE919FAEA440040BBC3 /* MCOIMAPFetchParsedContentOperation.h in Headers */,
27780ED819CFA40600C77E44 /* MCMessageConstants.h in Headers */,
27780ED919CFA40600C77E44 /* MCMessageHeader.h in Headers */,
27780EDA19CFA40600C77E44 /* MCArray.h in Headers */,
@@ -3490,6 +3512,7 @@
27780E2C19CFA39900C77E44 /* MCSMTPSendWithDataOperation.h in Headers */,
27780E2D19CFA39900C77E44 /* MCSMTPDisconnectOperation.h in Headers */,
27780E2E19CFA39900C77E44 /* MCSMTPNoopOperation.h in Headers */,
+ 8199FBF619FAF1270040BBC3 /* MCIMAPFetchParsedContentOperation.h in Headers */,
27780E2F19CFA39900C77E44 /* MCSMTPOperation.h in Headers */,
27780E3019CFA39900C77E44 /* MCSMTPOperationCallback.h in Headers */,
27780E3119CFA39900C77E44 /* MCSMTPCheckAccountOperation.h in Headers */,
@@ -3661,6 +3684,7 @@
27780DE119CFA33B00C77E44 /* MCConnectionLogger.h in Headers */,
27780DE219CFA33B00C77E44 /* MCConnectionLoggerUtils.h in Headers */,
27780DE319CFA33B00C77E44 /* MCData.h in Headers */,
+ 8199FBEA19FAEA440040BBC3 /* MCOIMAPFetchParsedContentOperation.h in Headers */,
27780DE419CFA33C00C77E44 /* MCHash.h in Headers */,
27780DE519CFA33C00C77E44 /* MCHashMap.h in Headers */,
27780DE619CFA33C00C77E44 /* MCHTMLCleaner.h in Headers */,
@@ -4046,6 +4070,7 @@
C6E665B51796500B0063F2CF /* MCZip.cc in Sources */,
84B639E317F279BB003B5BA2 /* MCSMTPNoopOperation.cc in Sources */,
84CFA98319F7153B00FE35D2 /* MCONNTPFetchOverviewOperation.mm in Sources */,
+ 8199FBEB19FAEA440040BBC3 /* MCOIMAPFetchParsedContentOperation.mm in Sources */,
C64EA706169E847800778456 /* MCAssert.c in Sources */,
84D73793199C0511005124E5 /* MCONNTPGroupInfo.mm in Sources */,
C64EA708169E847800778456 /* MCData.cc in Sources */,
@@ -4138,6 +4163,7 @@
F87F190C16BB62B00012652F /* MCOIMAPFetchFoldersOperation.mm in Sources */,
84B639F117F282B4003B5BA2 /* MCOPOPNoopOperation.mm in Sources */,
C6EB30F716B8C9480091F4F1 /* NSDictionary+MCO.mm in Sources */,
+ 8199FBF119FAF1270040BBC3 /* MCIMAPFetchParsedContentOperation.cc in Sources */,
C6EB30FE16B8E50F0091F4F1 /* NSArray+MCO.mm in Sources */,
C6EB310116B8E6E60091F4F1 /* NSObject+MCO.mm in Sources */,
C63CD67F16BDCDD400DB18F1 /* MCAddressDisplay.cc in Sources */,
@@ -4284,6 +4310,7 @@
C6E665B61796500B0063F2CF /* MCZip.cc in Sources */,
84B639E417F279BB003B5BA2 /* MCSMTPNoopOperation.cc in Sources */,
84CFA98419F7153B00FE35D2 /* MCONNTPFetchOverviewOperation.mm in Sources */,
+ 8199FBEC19FAEA440040BBC3 /* MCOIMAPFetchParsedContentOperation.mm in Sources */,
C6BA2BA11705F4E6003F0E9E /* MCAssert.c in Sources */,
84D73794199C0511005124E5 /* MCONNTPGroupInfo.mm in Sources */,
C6BA2BA21705F4E6003F0E9E /* MCData.cc in Sources */,
@@ -4376,6 +4403,7 @@
C6BA2BE21705F4E6003F0E9E /* NSError+MCO.mm in Sources */,
C6BA2BE31705F4E6003F0E9E /* MCOIMAPFetchFoldersOperation.mm in Sources */,
84B639F217F282B4003B5BA2 /* MCOPOPNoopOperation.mm in Sources */,
+ 8199FBF219FAF1270040BBC3 /* MCIMAPFetchParsedContentOperation.cc in Sources */,
C6BA2BE41705F4E6003F0E9E /* NSDictionary+MCO.mm in Sources */,
C6BA2BE51705F4E6003F0E9E /* NSArray+MCO.mm in Sources */,
C6BA2BE61705F4E6003F0E9E /* NSObject+MCO.mm in Sources */,
diff --git a/src/async/imap/MCAsyncIMAP.h b/src/async/imap/MCAsyncIMAP.h
index da032c73..15c9e482 100755
--- a/src/async/imap/MCAsyncIMAP.h
+++ b/src/async/imap/MCAsyncIMAP.h
@@ -17,6 +17,7 @@
#include <MailCore/MCIMAPCopyMessagesOperation.h>
#include <MailCore/MCIMAPFetchMessagesOperation.h>
#include <MailCore/MCIMAPFetchContentOperation.h>
+#include <MailCore/MCIMAPFetchParsedContentOperation.h>
#include <MailCore/MCIMAPIdleOperation.h>
#include <MailCore/MCIMAPFolderInfoOperation.h>
#include <MailCore/MCIMAPFolderStatusOperation.h>
diff --git a/src/async/imap/MCIMAPAsyncConnection.cc b/src/async/imap/MCIMAPAsyncConnection.cc
index 3a6508d6..b2fc24c3 100755
--- a/src/async/imap/MCIMAPAsyncConnection.cc
+++ b/src/async/imap/MCIMAPAsyncConnection.cc
@@ -21,7 +21,7 @@
#include "MCIMAPCopyMessagesOperation.h"
#include "MCIMAPFetchMessagesOperation.h"
#include "MCIMAPFetchContentOperation.h"
-#include "MCIMAPFetchContentOperation.h"
+#include "MCIMAPFetchParsedContentOperation.h"
#include "MCIMAPStoreFlagsOperation.h"
#include "MCIMAPStoreLabelsOperation.h"
#include "MCIMAPSearchOperation.h"
@@ -43,51 +43,51 @@
using namespace mailcore;
namespace mailcore {
-
+
class IMAPOperationQueueCallback : public Object, public OperationQueueCallback {
public:
IMAPOperationQueueCallback(IMAPAsyncConnection * connection) {
mConnection = connection;
}
-
+
virtual ~IMAPOperationQueueCallback() {
}
-
+
virtual void queueStartRunning() {
mConnection->setQueueRunning(true);
mConnection->owner()->operationRunningStateChanged();
mConnection->queueStartRunning();
}
-
+
virtual void queueStoppedRunning() {
mConnection->setQueueRunning(false);
mConnection->tryAutomaticDisconnect();
mConnection->owner()->operationRunningStateChanged();
mConnection->queueStoppedRunning();
}
-
+
private:
IMAPAsyncConnection * mConnection;
};
-
+
class IMAPConnectionLogger : public Object, public ConnectionLogger {
public:
IMAPConnectionLogger(IMAPAsyncConnection * connection) {
mConnection = connection;
}
-
+
virtual ~IMAPConnectionLogger() {
}
-
+
virtual void log(void * sender, ConnectionLogType logType, Data * buffer)
{
mConnection->logConnection(logType, buffer);
}
-
+
private:
IMAPAsyncConnection * mConnection;
};
-
+
}
IMAPAsyncConnection::IMAPAsyncConnection()
@@ -292,7 +292,7 @@ void IMAPAsyncConnection::tryAutomaticDisconnect()
if (mSession->isDisconnected()) {
return;
}
-
+
bool scheduledAutomaticDisconnect = mScheduledAutomaticDisconnect;
if (scheduledAutomaticDisconnect) {
#if __APPLE__
@@ -301,7 +301,7 @@ void IMAPAsyncConnection::tryAutomaticDisconnect()
cancelDelayedPerformMethod((Object::Method) &IMAPAsyncConnection::tryAutomaticDisconnectAfterDelay, NULL);
#endif
}
-
+
mOwner->retain();
mScheduledAutomaticDisconnect = true;
#if __APPLE__
@@ -309,7 +309,7 @@ void IMAPAsyncConnection::tryAutomaticDisconnect()
#else
performMethodAfterDelay((Object::Method) &IMAPAsyncConnection::tryAutomaticDisconnectAfterDelay, NULL, 30);
#endif
-
+
if (scheduledAutomaticDisconnect) {
mOwner->release();
}
@@ -318,10 +318,10 @@ void IMAPAsyncConnection::tryAutomaticDisconnect()
void IMAPAsyncConnection::tryAutomaticDisconnectAfterDelay(void * context)
{
mScheduledAutomaticDisconnect = false;
-
+
IMAPOperation * op = disconnectOperation();
op->start();
-
+
mOwner->release();
}
@@ -373,11 +373,11 @@ void IMAPAsyncConnection::setConnectionLogger(ConnectionLogger * logger)
ConnectionLogger * IMAPAsyncConnection::connectionLogger()
{
ConnectionLogger * result;
-
+
pthread_mutex_lock(&mConnectionLoggerLock);
result = mConnectionLogger;
pthread_mutex_unlock(&mConnectionLoggerLock);
-
+
return result;
}
diff --git a/src/async/imap/MCIMAPAsyncConnection.h b/src/async/imap/MCIMAPAsyncConnection.h
index 50d1409a..b267f7c7 100755
--- a/src/async/imap/MCIMAPAsyncConnection.h
+++ b/src/async/imap/MCIMAPAsyncConnection.h
@@ -15,6 +15,7 @@ namespace mailcore {
class IMAPCopyMessagesOperation;
class IMAPFetchMessagesOperation;
class IMAPFetchContentOperation;
+ class IMAPFetchParsedContentOperation;
class IMAPIdleOperation;
class IMAPFolderInfoOperation;
class IMAPFolderStatusOperation;
diff --git a/src/async/imap/MCIMAPAsyncSession.cc b/src/async/imap/MCIMAPAsyncSession.cc
index ef3bb621..f3a55a5e 100755
--- a/src/async/imap/MCIMAPAsyncSession.cc
+++ b/src/async/imap/MCIMAPAsyncSession.cc
@@ -28,7 +28,7 @@
#include "MCIMAPCopyMessagesOperation.h"
#include "MCIMAPFetchMessagesOperation.h"
#include "MCIMAPFetchContentOperation.h"
-#include "MCIMAPFetchContentOperation.h"
+#include "MCIMAPFetchParsedContentOperation.h"
#include "MCIMAPStoreFlagsOperation.h"
#include "MCIMAPStoreLabelsOperation.h"
#include "MCIMAPSearchOperation.h"
@@ -52,7 +52,7 @@ IMAPAsyncSession::IMAPAsyncSession()
mSessions = new Array();
mMaximumConnections = DEFAULT_MAX_CONNECTIONS;
mAllowsFolderConcurrentAccessEnabled = true;
-
+
mHostname = NULL;
mPort = 0;
mUsername = NULL;
@@ -244,7 +244,7 @@ IMAPAsyncConnection * IMAPAsyncSession::session()
session->setConnectionLogger(mConnectionLogger);
session->setOwner(this);
session->autorelease();
-
+
session->setHostname(mHostname);
session->setPort(mPort);
session->setUsername(mUsername);
@@ -265,7 +265,7 @@ IMAPAsyncConnection * IMAPAsyncSession::session()
session->setAutomaticConfigurationEnabled(false);
}
#endif
-
+
return session;
}
@@ -283,7 +283,7 @@ IMAPAsyncConnection * IMAPAsyncSession::sessionForFolder(String * folder, bool u
return s;
}
}
-
+
s = matchingSessionForFolder(folder);
s->setLastFolder(folder);
return s;
@@ -549,6 +549,28 @@ IMAPFetchContentOperation * IMAPAsyncSession::fetchMessageAttachmentByNumberOper
return op;
}
+IMAPFetchParsedContentOperation * IMAPAsyncSession::fetchParsedMessageByUIDOperation(String * folder, uint32_t uid, bool urgent)
+{
+ IMAPFetchParsedContentOperation * op = new IMAPFetchParsedContentOperation();
+ op->setMainSession(this);
+ op->setFolder(folder);
+ op->setUid(uid);
+ op->setUrgent(urgent);
+ op->autorelease();
+ return op;
+}
+
+IMAPFetchParsedContentOperation * IMAPAsyncSession::fetchParsedMessageByNumberOperation(String * folder, uint32_t number, bool urgent)
+{
+ IMAPFetchParsedContentOperation * op = new IMAPFetchParsedContentOperation();
+ op->setMainSession(this);
+ op->setFolder(folder);
+ op->setNumber(number);
+ op->setUrgent(urgent);
+ op->autorelease();
+ return op;
+}
+
IMAPOperation * IMAPAsyncSession::storeFlagsByUIDOperation(String * folder, IndexSet * uids, IMAPStoreFlagsRequestKind kind, MessageFlag flags, Array * customFlags)
{
IMAPStoreFlagsOperation * op = new IMAPStoreFlagsOperation();
diff --git a/src/async/imap/MCIMAPAsyncSession.h b/src/async/imap/MCIMAPAsyncSession.h
index a7ec90a0..05b1967c 100755
--- a/src/async/imap/MCIMAPAsyncSession.h
+++ b/src/async/imap/MCIMAPAsyncSession.h
@@ -23,6 +23,7 @@ namespace mailcore {
class IMAPCopyMessagesOperation;
class IMAPFetchMessagesOperation;
class IMAPFetchContentOperation;
+ class IMAPFetchParsedContentOperation;
class IMAPIdleOperation;
class IMAPFolderInfoOperation;
class IMAPFolderStatusOperation;
@@ -137,6 +138,9 @@ namespace mailcore {
virtual IMAPFetchContentOperation * fetchMessageAttachmentByNumberOperation(String * folder, uint32_t number, String * partID,
Encoding encoding, bool urgent = false);
+ virtual IMAPFetchParsedContentOperation * fetchParsedMessageByUIDOperation(String * folder, uint32_t uid, bool urgent = false);
+ virtual IMAPFetchParsedContentOperation * fetchParsedMessageByNumberOperation(String * folder, uint32_t number, bool urgent = false);
+
virtual IMAPOperation * storeFlagsByUIDOperation(String * folder, IndexSet * uids, IMAPStoreFlagsRequestKind kind, MessageFlag flags, Array * customFlags = NULL);
virtual IMAPOperation * storeFlagsByNumberOperation(String * folder, IndexSet * numbers, IMAPStoreFlagsRequestKind kind, MessageFlag flags, Array * customFlags = NULL);
virtual IMAPOperation * storeLabelsByUIDOperation(String * folder, IndexSet * uids, IMAPStoreFlagsRequestKind kind, Array * labels);
diff --git a/src/async/imap/MCIMAPFetchParsedContentOperation.cc b/src/async/imap/MCIMAPFetchParsedContentOperation.cc
new file mode 100644
index 00000000..e32112e6
--- /dev/null
+++ b/src/async/imap/MCIMAPFetchParsedContentOperation.cc
@@ -0,0 +1,79 @@
+//
+// IMAPFetchParsedContentOperation.cc
+// mailcore2
+//
+// Created by DINH Viêt Hoà on 1/12/13.
+// Copyright (c) 2013 MailCore. All rights reserved.
+//
+
+#include "MCIMAPFetchParsedContentOperation.h"
+
+#include "MCIMAPSession.h"
+#include "MCIMAPAsyncConnection.h"
+
+using namespace mailcore;
+
+IMAPFetchParsedContentOperation::IMAPFetchParsedContentOperation()
+{
+ mUid = 0;
+ mNumber = 0;
+ mEncoding = Encoding7Bit;
+ mParser = NULL;
+}
+
+IMAPFetchParsedContentOperation::~IMAPFetchParsedContentOperation()
+{
+ MC_SAFE_RELEASE(mParser);
+}
+
+void IMAPFetchParsedContentOperation::setUid(uint32_t uid)
+{
+ mUid = uid;
+}
+
+uint32_t IMAPFetchParsedContentOperation::uid()
+{
+ return mUid;
+}
+
+void IMAPFetchParsedContentOperation::setNumber(uint32_t value)
+{
+ mNumber = value;
+}
+
+uint32_t IMAPFetchParsedContentOperation::number()
+{
+ return mNumber;
+}
+
+void IMAPFetchParsedContentOperation::setEncoding(Encoding encoding)
+{
+ mEncoding = encoding;
+}
+
+Encoding IMAPFetchParsedContentOperation::encoding()
+{
+ return mEncoding;
+}
+
+MessageParser * IMAPFetchParsedContentOperation::parser()
+{
+ return mParser;
+}
+
+void IMAPFetchParsedContentOperation::main()
+{
+ ErrorCode error;
+ Data * data;
+ if (mUid != 0) {
+ data = session()->session()->fetchMessageByUID(folder(), mUid, this, &error);
+ }
+ else {
+ data = session()->session()->fetchMessageByNumber(folder(), mNumber, this, &error);
+ }
+ if (data) {
+ mParser = new mailcore::MessageParser(data);
+ }
+ setError(error);
+}
+
diff --git a/src/async/imap/MCIMAPFetchParsedContentOperation.h b/src/async/imap/MCIMAPFetchParsedContentOperation.h
new file mode 100644
index 00000000..0262a35b
--- /dev/null
+++ b/src/async/imap/MCIMAPFetchParsedContentOperation.h
@@ -0,0 +1,53 @@
+//
+// IMAPFetchParsedContentOperation.h
+// mailcore2
+//
+// Created by DINH Viêt Hoà on 1/12/13.
+// Copyright (c) 2013 MailCore. All rights reserved.
+//
+
+#ifndef MAILCORE_IMAPFETCHPARSEDCONTENTOPERATION_H
+
+#define MAILCORE_IMAPFETCHPARSEDCONTENTOPERATION_H
+
+#include <MailCore/MCIMAPOperation.h>
+
+#include <MailCore/MCRFC822.h>
+
+#ifdef __cplusplus
+
+namespace mailcore {
+
+ class IMAPFetchParsedContentOperation : public IMAPOperation {
+ public:
+ IMAPFetchParsedContentOperation();
+ virtual ~IMAPFetchParsedContentOperation();
+
+ virtual void setUid(uint32_t uid);
+ virtual uint32_t uid();
+
+ virtual void setNumber(uint32_t value);
+ virtual uint32_t number();
+
+ virtual void setEncoding(Encoding encoding);
+ virtual Encoding encoding();
+
+ // Result.
+ virtual MessageParser * parser();
+
+ public: // subclass behavior
+ virtual void main();
+
+ private:
+ uint32_t mUid;
+ uint32_t mNumber;
+ Encoding mEncoding;
+ MessageParser * mParser;
+
+ };
+
+}
+
+#endif
+
+#endif
diff --git a/src/cmake/async.cmake b/src/cmake/async.cmake
index 58f410d4..947a69ee 100644
--- a/src/cmake/async.cmake
+++ b/src/cmake/async.cmake
@@ -13,6 +13,7 @@ set(async_imap_files
async/imap/MCIMAPDisconnectOperation.cc
async/imap/MCIMAPExpungeOperation.cc
async/imap/MCIMAPFetchContentOperation.cc
+ async/imap/MCIMAPFetchParsedContentOperation.cc
async/imap/MCIMAPFetchFoldersOperation.cc
async/imap/MCIMAPFetchMessagesOperation.cc
async/imap/MCIMAPFetchNamespaceOperation.cc
diff --git a/src/cmake/objc.cmake b/src/cmake/objc.cmake
index de4d8d06..cdf09dd6 100644
--- a/src/cmake/objc.cmake
+++ b/src/cmake/objc.cmake
@@ -16,6 +16,7 @@ set(objc_imap_files
objc/imap/MCOIMAPCapabilityOperation.mm
objc/imap/MCOIMAPCopyMessagesOperation.mm
objc/imap/MCOIMAPFetchContentOperation.mm
+ objc/imap/MCOIMAPFetchParsedContentOperation.mm
objc/imap/MCOIMAPFetchFoldersOperation.mm
objc/imap/MCOIMAPFetchMessagesOperation.mm
objc/imap/MCOIMAPFetchNamespaceOperation.mm
@@ -84,7 +85,7 @@ set(objc_nntp_files
objc/nntp/MCONNTPFetchOverviewOperation.mm
objc/nntp/MCONNTPFetchServerTimeOperation.mm
objc/nntp/MCONNTPOperation.mm
- objc/nntp/MCONNTPSession.mm
+ objc/nntp/MCONNTPSession.mm
)
set(objc_utils_files
diff --git a/src/cmake/public-headers.cmake b/src/cmake/public-headers.cmake
index 8b55c15e..65be3be7 100644
--- a/src/cmake/public-headers.cmake
+++ b/src/cmake/public-headers.cmake
@@ -86,6 +86,7 @@ async/imap/MCIMAPAppendMessageOperation.h
async/imap/MCIMAPCopyMessagesOperation.h
async/imap/MCIMAPFetchMessagesOperation.h
async/imap/MCIMAPFetchContentOperation.h
+async/imap/MCIMAPFetchParsedContentOperation.h
async/imap/MCIMAPIdleOperation.h
async/imap/MCIMAPFolderInfoOperation.h
async/imap/MCIMAPFolderStatusOperation.h
@@ -160,6 +161,7 @@ objc/imap/MCOIMAPAppendMessageOperation.h
objc/imap/MCOIMAPCopyMessagesOperation.h
objc/imap/MCOIMAPFetchMessagesOperation.h
objc/imap/MCOIMAPFetchContentOperation.h
+objc/imap/MCOIMAPFetchParsedContentOperation.h
objc/imap/MCOIMAPSearchOperation.h
objc/imap/MCOIMAPIdleOperation.h
objc/imap/MCOIMAPFetchNamespaceOperation.h
diff --git a/src/core/basetypes/MCData.cc b/src/core/basetypes/MCData.cc
index 5f2282d9..9845d77a 100644
--- a/src/core/basetypes/MCData.cc
+++ b/src/core/basetypes/MCData.cc
@@ -27,17 +27,29 @@
using namespace mailcore;
-void Data::allocate(unsigned int length)
+static int isPowerOfTwo (unsigned int x)
{
- length ++;
- if (length < mAllocated)
+ return ((x != 0) && !(x & (x - 1)));
+}
+
+void Data::allocate(unsigned int length, bool force)
+{
+ if (length <= mAllocated)
return;
-
- if (mAllocated == 0) {
- mAllocated = 4;
+
+ if (force) {
+ mAllocated = length;
}
- while (length > mAllocated) {
- mAllocated *= 2;
+ else {
+ if (!isPowerOfTwo(mAllocated)) {
+ mAllocated = 0;
+ }
+ if (mAllocated == 0) {
+ mAllocated = 4;
+ }
+ while (length > mAllocated) {
+ mAllocated *= 2;
+ }
}
mBytes = (char *) realloc(mBytes, mAllocated);
@@ -68,7 +80,7 @@ Data::Data(const char * bytes, unsigned int length)
{
mBytes = NULL;
reset();
- allocate(length);
+ allocate(length, true);
appendBytes(bytes, length);
}
@@ -76,7 +88,7 @@ Data::Data(int capacity)
{
mBytes = NULL;
reset();
- allocate(capacity);
+ allocate(capacity, true);
}
Data::~Data()
@@ -483,7 +495,7 @@ String * Data::charsetWithFilteredHTML(bool filterHTML, String * hintCharset)
#endif
}
-void Data::replaceWithAllocatedBytes(char * bytes, unsigned int length)
+void Data::takeBytesOwnership(char * bytes, unsigned int length)
{
free(mBytes);
mBytes = (char *) bytes;
@@ -520,7 +532,7 @@ Data * Data::dataWithContentsOfFile(String * filename)
}
data = Data::data();
- data->replaceWithAllocatedBytes(buf, (unsigned int) stat_buf.st_size);
+ data->takeBytesOwnership(buf, (unsigned int) stat_buf.st_size);
fclose(f);
diff --git a/src/core/basetypes/MCData.h b/src/core/basetypes/MCData.h
index 131cb722..43ffb30f 100644
--- a/src/core/basetypes/MCData.h
+++ b/src/core/basetypes/MCData.h
@@ -62,10 +62,10 @@ namespace mailcore {
char * mBytes;
unsigned int mLength;
unsigned int mAllocated;
- void allocate(unsigned int length);
+ void allocate(unsigned int length, bool force = false);
void reset();
String * charsetWithFilteredHTMLWithoutHint(bool filterHTML);
- void replaceWithAllocatedBytes(char * bytes, unsigned int length);
+ void takeBytesOwnership(char * bytes, unsigned int length);
};
diff --git a/src/core/basetypes/MCString.cc b/src/core/basetypes/MCString.cc
index a122c1e6..88c61a99 100644
--- a/src/core/basetypes/MCString.cc
+++ b/src/core/basetypes/MCString.cc
@@ -754,7 +754,7 @@ String::String(const UChar * unicodeChars)
mUnicodeChars = NULL;
reset();
if (unicodeChars != NULL) {
- allocate(u_strlen(unicodeChars));
+ allocate(u_strlen(unicodeChars), true);
}
appendCharacters(unicodeChars);
}
@@ -763,7 +763,7 @@ String::String(const UChar * unicodeChars, unsigned int length)
{
mUnicodeChars = NULL;
reset();
- allocate(length);
+ allocate(length, true);
appendCharactersLength(unicodeChars, length);
}
@@ -771,6 +771,7 @@ String::String(const char * UTF8Characters)
{
mUnicodeChars = NULL;
reset();
+ allocate((unsigned int) strlen(UTF8Characters), true);
appendUTF8Characters(UTF8Characters);
}
@@ -792,7 +793,7 @@ String::String(const char * bytes, unsigned int length, const char * charset)
{
mUnicodeChars = NULL;
reset();
- allocate(length);
+ allocate(length, true);
if (charset == NULL) {
appendUTF8CharactersLength(bytes, length);
}
@@ -806,17 +807,30 @@ String::~String()
reset();
}
-void String::allocate(unsigned int length)
+static int isPowerOfTwo (unsigned int x)
+{
+ return ((x != 0) && !(x & (x - 1)));
+}
+
+void String::allocate(unsigned int length, bool force)
{
length ++;
- if (length < mAllocated)
+ if (length <= mAllocated)
return;
-
- if (mAllocated == 0) {
- mAllocated = 4;
+
+ if (force) {
+ mAllocated = length;
}
- while (length > mAllocated) {
- mAllocated *= 2;
+ else {
+ if (!isPowerOfTwo(mAllocated)) {
+ mAllocated = 0;
+ }
+ if (mAllocated == 0) {
+ mAllocated = 4;
+ }
+ while (length > mAllocated) {
+ mAllocated *= 2;
+ }
}
mUnicodeChars = (UChar *) realloc(mUnicodeChars, mAllocated * sizeof(* mUnicodeChars));
diff --git a/src/core/basetypes/MCString.h b/src/core/basetypes/MCString.h
index 25439cf2..cad79c21 100644
--- a/src/core/basetypes/MCString.h
+++ b/src/core/basetypes/MCString.h
@@ -130,7 +130,7 @@ namespace mailcore {
UChar * mUnicodeChars;
unsigned int mLength;
unsigned int mAllocated;
- void allocate(unsigned int length);
+ void allocate(unsigned int length, bool force = false);
void reset();
int compareWithCaseSensitive(String * otherString, bool caseSensitive);
void appendBytes(const char * bytes, unsigned int length, const char * charset);
diff --git a/src/objc/imap/MCOIMAP.h b/src/objc/imap/MCOIMAP.h
index 7acffcef..1957afd8 100755
--- a/src/objc/imap/MCOIMAP.h
+++ b/src/objc/imap/MCOIMAP.h
@@ -29,6 +29,7 @@
#import <MailCore/MCOIMAPCopyMessagesOperation.h>
#import <MailCore/MCOIMAPFetchMessagesOperation.h>
#import <MailCore/MCOIMAPFetchContentOperation.h>
+#import <MailCore/MCOIMAPFetchParsedContentOperation.h>
#import <MailCore/MCOIMAPSearchOperation.h>
#import <MailCore/MCOIMAPIdleOperation.h>
#import <MailCore/MCOIMAPFetchNamespaceOperation.h>
diff --git a/src/objc/imap/MCOIMAPFetchParsedContentOperation.h b/src/objc/imap/MCOIMAPFetchParsedContentOperation.h
new file mode 100644
index 00000000..de2b1663
--- /dev/null
+++ b/src/objc/imap/MCOIMAPFetchParsedContentOperation.h
@@ -0,0 +1,44 @@
+//
+// MCOIMAPFetchParsedContentOperation.h
+// mailcore2
+//
+// Created by DINH Viêt Hoà on 3/25/13.
+// Copyright (c) 2013 MailCore. All rights reserved.
+//
+
+#ifndef MAILCORE_MCOIMAPFETCHPARSEDCONTENTOPERATION_H
+
+#define MAILCORE_MCOIMAPFETCHPARSEDCONTENTOPERATION_H
+
+/**
+ This class implements an operation to fetch the parsed content of a message.
+*/
+
+#import <MailCore/MCOIMAPBaseOperation.h>
+#import <MailCore/MCOConstants.h>
+
+@class MCOMessageParser;
+
+@interface MCOIMAPFetchParsedContentOperation : MCOIMAPBaseOperation
+
+/**
+ This block will be called as bytes are received from the network
+*/
+@property (nonatomic, copy) MCOIMAPBaseOperationProgressBlock progress;
+
+/**
+ Starts the asynchronous fetch operation.
+
+ @param completionBlock Called when the operation is finished.
+
+ - On success `error` will be nil and `parser` will contain the requested message
+
+ - On failure, `error` will be set with `MCOErrorDomain` as domain and an
+ error code available in `MCOConstants.h`, `data` will be nil
+*/
+
+- (void) start:(void (^)(NSError * error, MCOMessageParser * parser))completionBlock;
+
+@end
+
+#endif
diff --git a/src/objc/imap/MCOIMAPFetchParsedContentOperation.mm b/src/objc/imap/MCOIMAPFetchParsedContentOperation.mm
new file mode 100644
index 00000000..5c1ebde3
--- /dev/null
+++ b/src/objc/imap/MCOIMAPFetchParsedContentOperation.mm
@@ -0,0 +1,84 @@
+//
+// MCOIMAPFetchParsedContentOperation.m
+// mailcore2
+//
+// Created by DINH Viêt Hoà on 3/25/13.
+// Copyright (c) 2013 MailCore. All rights reserved.
+//
+
+#import "MCOIMAPFetchParsedContentOperation.h"
+
+#include "MCAsyncIMAP.h"
+
+#import "MCOMessageParser.h"
+#import "MCOOperation+Private.h"
+#import "MCOUtils.h"
+
+typedef void (^CompletionType)(NSError *error, NSData * data);
+
+@implementation MCOIMAPFetchParsedContentOperation {
+ CompletionType _completionBlock;
+ MCOIMAPBaseOperationProgressBlock _progress;
+}
+
+@synthesize progress = _progress;
+
+#define nativeType mailcore::IMAPFetchParsedContentOperation
+
++ (void) load
+{
+ MCORegisterClass(self, &typeid(nativeType));
+}
+
++ (NSObject *) mco_objectWithMCObject:(mailcore::Object *)object
+{
+ nativeType * op = (nativeType *) object;
+ return [[[self alloc] initWithMCOperation:op] autorelease];
+}
+
+- (void) dealloc
+{
+ [_progress release];
+ [_completionBlock release];
+ [super dealloc];
+}
+
+- (void) start:(void (^)(NSError *error, MCOMessageParser * parser))completionBlock {
+ _completionBlock = [completionBlock copy];
+ [self start];
+}
+
+- (void) cancel
+{
+ [_completionBlock release];
+ _completionBlock = nil;
+ [super cancel];
+}
+
+- (void) operationCompleted
+{
+ if (_completionBlock == NULL)
+ return;
+
+ nativeType *op = MCO_NATIVE_INSTANCE;
+ if (op->error() == mailcore::ErrorNone) {
+ if (op->parser()) {
+ _completionBlock(nil, MCO_TO_OBJC(op->parser()));
+ } else {
+ _completionBlock(nil, nil);
+ }
+ } else {
+ _completionBlock([NSError mco_errorWithErrorCode:op->error()], nil);
+ }
+ [_completionBlock release];
+ _completionBlock = nil;
+}
+
+- (void) bodyProgress:(unsigned int)current maximum:(unsigned int)maximum
+{
+ if (_progress != NULL) {
+ _progress(current, maximum);
+ }
+}
+
+@end
diff --git a/src/objc/imap/MCOIMAPSession.h b/src/objc/imap/MCOIMAPSession.h
index a6034e9a..660c896d 100755
--- a/src/objc/imap/MCOIMAPSession.h
+++ b/src/objc/imap/MCOIMAPSession.h
@@ -23,6 +23,7 @@
@class MCOIndexSet;
@class MCOIMAPFetchMessagesOperation;
@class MCOIMAPFetchContentOperation;
+@class MCOIMAPFetchParsedContentOperation;
@class MCOIMAPSearchOperation;
@class MCOIMAPIdleOperation;
@class MCOIMAPFetchNamespaceOperation;
@@ -35,7 +36,7 @@
@class MCOIMAPIdentity;
/**
- This is the main IMAP class from which all operations are created
+ This is the main IMAP class from which all operations are created
After calling a method that returns an operation you must call start: on the instance
to begin the operation.
@@ -58,7 +59,7 @@
/** This is the OAuth2 token. */
@property (nonatomic, copy) NSString *OAuth2Token;
-/**
+/**
This is the authentication type to use to connect.
`MCOAuthTypeSASLNone` means that it uses the clear-text is used (and is the default).
@warning *Important*: Over an encrypted connection like TLS, the password will still be secure
@@ -105,7 +106,7 @@
/**
Sets logger callback. The network traffic will be sent to this block.
-
+
[session setConnectionLogger:^(void * connectionID, MCOConnectionLogType type, NSData * data) {
NSLog(@"%@", [[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] autorelease]);
// ...
@@ -130,7 +131,7 @@
/**
Sets operation running callback. It will be called when operations start or stop running.
-
+
[session setOperationQueueRunningChangeBlock:^{
if ([session isOperationQueueRunning]) {
...
@@ -165,7 +166,7 @@
/**
Returns an operation that retrieves folder status (like UIDNext - Unseen -)
-
+
MCOIMAPFolderStatusOperation * op = [session folderStatusOperation:@"INBOX"];
[op start:^(NSError *error, MCOIMAPFolderStatus * info) {
NSLog(@"UIDNEXT: %lu", (unsigned long) [info uidNext]);
@@ -178,7 +179,7 @@
/**
Returns an operation that gets the list of subscribed folders.
-
+
MCOIMAPFetchFoldersOperation * op = [session fetchSubscribedFoldersOperation];
[op start:^(NSError * error, NSArray * folders) {
...
@@ -225,7 +226,7 @@
[op start:^(NSError * error) {
...
}];
-*/
+*/
- (MCOIMAPOperation *) createFolderOperation:(NSString *)folder;
/**
@@ -282,7 +283,7 @@
/**
Returns an operation to add a message with custom flags to a folder.
-
+
MCOIMAPOperation * op = [session appendMessageOperationWithFolder:@"Sent Mail" messageData:rfc822Data flags:MCOMessageFlagNone customFlags:@[@"$CNS-Greeting-On"]];
[op start:^(NSError * error, uint32_t createdUID) {
if (error == nil) {
@@ -329,9 +330,9 @@
/**
Returns an operation to change flags of messages, using IMAP sequence number.
-
+
For example: Adds the seen flag to the message with the sequence number number 42.
-
+
MCOIMAPOperation * op = [session storeFlagsOperationWithFolder:@"INBOX"
numbers:[MCOIndexSet indexSetWithIndex:42]
kind:MCOIMAPStoreFlagsRequestKindAdd
@@ -347,9 +348,9 @@
/**
Returns an operation to change flags and custom flags of messages.
-
+
For example: Adds the seen flag and $CNS-Greeting-On flag to the message with UID 456.
-
+
MCOIMAPOperation * op = [session storeFlagsOperationWithFolder:@"INBOX"
uids:[MCOIndexSet indexSetWithIndex:456]
kind:MCOIMAPStoreFlagsRequestKindAdd
@@ -368,9 +369,9 @@
/**
Returns an operation to change flags and custom flags of messages, using IMAP sequence number.
-
+
For example: Adds the seen flag and $CNS-Greeting-On flag to the message with the sequence number 42.
-
+
MCOIMAPOperation * op = [session storeFlagsOperationWithFolder:@"INBOX"
numbers:[MCOIndexSet indexSetWithIndex:42]
kind:MCOIMAPStoreFlagsRequestKindAdd
@@ -461,16 +462,16 @@
For example: show 50 most recent uids.
NSString *folder = @"INBOX";
MCOIMAPFolderInfoOperation *folderInfo = [session folderInfoOperation:folder];
-
+
[folderInfo start:^(NSError *error, MCOIMAPFolderInfo *info) {
int numberOfMessages = 50;
numberOfMessages -= 1;
MCOIndexSet *numbers = [MCOIndexSet indexSetWithRange:MCORangeMake([info messageCount] - numberOfMessages, numberOfMessages)];
-
+
MCOIMAPFetchMessagesOperation *fetchOperation = [session fetchMessagesByNumberOperationWithFolder:folder
requestKind:MCOIMAPMessagesRequestKindUid
numbers:numbers];
-
+
[fetchOperation start:^(NSError *error, NSArray *messages, MCOIndexSet *vanishedMessages) {
for (MCOIMAPMessage * message in messages) {
NSLog(@"%u", [message uid]);
@@ -600,6 +601,58 @@ vanishedMessages will be set only for servers that support QRESYNC. See [RFC5162
- (MCOIMAPFetchContentOperation *) fetchMessageOperationWithFolder:(NSString *)folder
number:(uint32_t)number;
+/**
+ Returns an operation to fetch the parsed content of a message.
+ @param urgent is set to YES, an additional connection to the same folder might be opened to fetch the content.
+
+ MCOIMAPFetchParsedContentOperation * op = [session fetchParsedMessageOperationWithFolder:@"INBOX" uid:456 urgent:NO];
+ [op start:^(NSError * error, MCOMessageParser * parser) {
+
+ ...
+ }];
+ */
+- (MCOIMAPFetchParsedContentOperation *) fetchParsedMessageOperationWithFolder:(NSString *)folder
+ uid:(uint32_t)uid
+ urgent:(BOOL)urgent;
+
+/**
+ Returns an operation to fetch the parsed content of a message.
+
+ MCOIMAPFetchParsedContentOperation * op = [session fetchParsedMessageOperationWithFolder:@"INBOX" uid:456];
+ [op start:^(NSError * error, MCOMessageParser * parser) {
+
+ ...
+ }];
+ */
+- (MCOIMAPFetchParsedContentOperation *) fetchParsedMessageOperationWithFolder:(NSString *)folder
+ uid:(uint32_t)uid;
+
+/**
+ Returns an operation to fetch the parsed content of a message, using IMAP sequence number.
+ @param urgent is set to YES, an additional connection to the same folder might be opened to fetch the content.
+
+ MCOIMAPFetchParsedContentOperation * op = [session fetchParsedMessageOperationWithFolder:@"INBOX" number:42 urgent:NO];
+ [op start:^(NSError * error, MCOMessageParser * parser) {
+
+ ...
+ }];
+ */
+- (MCOIMAPFetchParsedContentOperation *) fetchParsedMessageOperationWithFolder:(NSString *)folder
+ number:(uint32_t)number
+ urgent:(BOOL)urgent;
+
+/**
+ Returns an operation to fetch the parsed content of a message, using IMAP sequence number.
+
+ MCOIMAPFetchParsedContentOperation * op = [session fetchParsedMessageOperationWithFolder:@"INBOX" number:42];
+ [op start:^(NSError * error, MCOMessageParser * parser) {
+
+ ...
+ }];
+ */
+- (MCOIMAPFetchParsedContentOperation *) fetchParsedMessageOperationWithFolder:(NSString *)folder
+ number:(uint32_t)number;
+
/** @name Fetching Attachment Operations */
/**
@@ -633,7 +686,7 @@ vanishedMessages will be set only for servers that support QRESYNC. See [RFC5162
[op start:^(NSError * error, NSData * partData) {
...
}];
-
+
Example 2:
MCOIMAPFetchContentOperation * op = [session fetchMessageAttachmentByUIDOperationWithFolder:@"INBOX"
@@ -680,7 +733,7 @@ vanishedMessages will be set only for servers that support QRESYNC. See [RFC5162
[op start:^(NSError * error, NSData * partData) {
...
}];
-
+
Example 2:
MCOIMAPFetchContentOperation * op = [session fetchMessageAttachmentOperationWithFolder:@"INBOX"
@@ -727,7 +780,7 @@ vanishedMessages will be set only for servers that support QRESYNC. See [RFC5162
[op start:^(NSError * error, NSData * partData) {
...
}];
-
+
Example 2:
MCOIMAPFetchContentOperation * op = [session fetchMessageAttachmentOperationWithFolder:@"INBOX"
@@ -758,7 +811,7 @@ vanishedMessages will be set only for servers that support QRESYNC. See [RFC5162
- (MCOIMAPIdleOperation *) idleOperationWithFolder:(NSString *)folder
lastKnownUID:(uint32_t)lastKnownUID;
-/**
+/**
Returns an operation to fetch the list of namespaces.
MCOIMAPFetchNamespaceOperation * op = [session fetchNamespaceOperation];
@@ -789,7 +842,7 @@ vanishedMessages will be set only for servers that support QRESYNC. See [RFC5162
/**
Returns an operation that will connect to the given IMAP server without authenticating.
Useful for checking initial server capabilities.
-
+
MCOIMAPOperation * op = [session connectOperation];
[op start:^(NSError * error) {
...
@@ -799,7 +852,7 @@ vanishedMessages will be set only for servers that support QRESYNC. See [RFC5162
/**
Returns an operation that will perform a No-Op operation on the given IMAP server.
-
+
MCOIMAPOperation * op = [session noopOperation];
[op start:^(NSError * error) {
...
@@ -867,10 +920,10 @@ vanishedMessages will be set only for servers that support QRESYNC. See [RFC5162
/**
Returns an operation to render the HTML version of a message to be displayed in a web view.
-
+
MCOIMAPMessageRenderingOperation * op = [session htmlRenderingOperationWithMessage:msg
folder:@"INBOX"];
-
+
[op start:^(NSString * htmlString, NSError * error) {
...
}];
@@ -880,10 +933,10 @@ vanishedMessages will be set only for servers that support QRESYNC. See [RFC5162
/**
Returns an operation to render the HTML body of a message to be displayed in a web view.
-
+
MCOIMAPMessageRenderingOperation * op = [session htmlBodyRenderingOperationWithMessage:msg
folder:@"INBOX"];
-
+
[op start:^(NSString * htmlString, NSError * error) {
...
}];
@@ -893,7 +946,7 @@ vanishedMessages will be set only for servers that support QRESYNC. See [RFC5162
/**
Returns an operation to render the plain text version of a message.
-
+
MCOIMAPMessageRenderingOperation * op = [session plainTextRenderingOperationWithMessage:msg
folder:@"INBOX"];
@@ -908,11 +961,11 @@ vanishedMessages will be set only for servers that support QRESYNC. See [RFC5162
Returns an operation to render the plain text body of a message.
All end of line will be removed and white spaces cleaned up if requested.
This method can be used to generate the summary of the message.
-
+
MCOIMAPMessageRenderingOperation * op = [session plainTextBodyRenderingOperationWithMessage:msg
folder:@"INBOX"
stripWhitespace:YES];
-
+
[op start:^(NSString * htmlString, NSError * error) {
...
}];
@@ -925,10 +978,10 @@ vanishedMessages will be set only for servers that support QRESYNC. See [RFC5162
Returns an operation to render the plain text body of a message.
All end of line will be removed and white spaces cleaned up.
This method can be used to generate the summary of the message.
-
+
MCOIMAPMessageRenderingOperation * op = [session plainTextBodyRenderingOperationWithMessage:msg
folder:@"INBOX"];
-
+
[op start:^(NSString * htmlString, NSError * error) {
...
}];
@@ -939,7 +992,7 @@ vanishedMessages will be set only for servers that support QRESYNC. See [RFC5162
/**
Returns an operation to disconnect the session.
It will disconnect all the sockets created by the session.
-
+
MCOIMAPOperation * op = [session disconnectOperation];
[op start:^(NSError * error) {
...
diff --git a/src/objc/imap/MCOIMAPSession.mm b/src/objc/imap/MCOIMAPSession.mm
index c7c389a4..d22efbc9 100755
--- a/src/objc/imap/MCOIMAPSession.mm
+++ b/src/objc/imap/MCOIMAPSession.mm
@@ -369,6 +369,34 @@ MCO_OBJC_SYNTHESIZE_SCALAR(dispatch_queue_t, dispatch_queue_t, setDispatchQueue,
return [self fetchMessageOperationWithFolder:folder number:number urgent:NO];
}
+- (MCOIMAPFetchParsedContentOperation *) fetchParsedMessageOperationWithFolder:(NSString *)folder
+ uid:(uint32_t)uid
+ urgent:(BOOL)urgent
+{
+ IMAPFetchParsedContentOperation * coreOp = MCO_NATIVE_INSTANCE->fetchParsedMessageByUIDOperation([folder mco_mcString], uid, urgent);
+ return MCO_TO_OBJC_OP(coreOp);
+}
+
+- (MCOIMAPFetchParsedContentOperation *) fetchParsedMessageOperationWithFolder:(NSString *)folder
+ uid:(uint32_t)uid
+{
+ return [self fetchParsedMessageOperationWithFolder:folder uid:uid urgent:NO];
+}
+
+- (MCOIMAPFetchParsedContentOperation *) fetchParsedMessageOperationWithFolder:(NSString *)folder
+ number:(uint32_t)number
+ urgent:(BOOL)urgent
+{
+ IMAPFetchParsedContentOperation * coreOp = MCO_NATIVE_INSTANCE->fetchParsedMessageByNumberOperation([folder mco_mcString], number, urgent);
+ return MCO_TO_OBJC_OP(coreOp);
+}
+
+- (MCOIMAPFetchParsedContentOperation *) fetchParsedMessageOperationWithFolder:(NSString *)folder
+ number:(uint32_t)number
+{
+ return [self fetchParsedMessageOperationWithFolder:folder number:number urgent:NO];
+}
+
- (MCOIMAPFetchContentOperation *) fetchMessageAttachmentByUIDOperationWithFolder:(NSString *)folder
uid:(uint32_t)uid
partID:(NSString *)partID