aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar DINH Viet Hoa <hoa@sprw.me>2013-01-17 23:58:24 -0800
committerGravatar DINH Viet Hoa <hoa@sprw.me>2013-01-17 23:58:24 -0800
commita56ff2c85bf8572e42912ce92a0ecb356f5bcd23 (patch)
tree27fc3fae4b10ae2d2319608b6d0d62ed98d12fed
parentada1598162092e9affc9337dedeb6c805ae72121 (diff)
IMAP Account with multiple IMAP connections
-rw-r--r--build-mac/mailcore2.xcodeproj/project.pbxproj8
-rw-r--r--src/async/imap/MCAsyncIMAP.h1
-rw-r--r--src/async/imap/MCIMAPAccount.cpp411
-rw-r--r--src/async/imap/MCIMAPAccount.h146
-rw-r--r--src/async/imap/MCIMAPAppendMessageOperation.cc14
-rw-r--r--src/async/imap/MCIMAPAppendMessageOperation.h4
-rw-r--r--src/async/imap/MCIMAPAsyncSession.cc20
-rw-r--r--src/async/imap/MCIMAPAsyncSession.h10
-rw-r--r--src/async/imap/MCIMAPCopyMessagesOperation.cc14
-rw-r--r--src/async/imap/MCIMAPCopyMessagesOperation.h4
-rw-r--r--src/async/imap/MCIMAPCreateFolderOperation.cc14
-rw-r--r--src/async/imap/MCIMAPCreateFolderOperation.h4
-rw-r--r--src/async/imap/MCIMAPDeleteFolderOperation.cc14
-rw-r--r--src/async/imap/MCIMAPDeleteFolderOperation.h4
-rw-r--r--src/async/imap/MCIMAPExpungeOperation.cc14
-rw-r--r--src/async/imap/MCIMAPExpungeOperation.h4
-rw-r--r--src/async/imap/MCIMAPFetchContentOperation.cc16
-rw-r--r--src/async/imap/MCIMAPFetchContentOperation.h4
-rw-r--r--src/async/imap/MCIMAPFetchFoldersOperation.cc13
-rw-r--r--src/async/imap/MCIMAPFetchFoldersOperation.h3
-rw-r--r--src/async/imap/MCIMAPFetchMessagesOperation.cc20
-rw-r--r--src/async/imap/MCIMAPFetchMessagesOperation.h4
-rw-r--r--src/async/imap/MCIMAPFolderInfoOperation.cc18
-rw-r--r--src/async/imap/MCIMAPFolderInfoOperation.h4
-rw-r--r--src/async/imap/MCIMAPIdleOperation.cc14
-rw-r--r--src/async/imap/MCIMAPIdleOperation.h4
-rw-r--r--src/async/imap/MCIMAPOperation.cc12
-rw-r--r--src/async/imap/MCIMAPOperation.h4
-rw-r--r--src/async/imap/MCIMAPRenameFolderOperation.cc14
-rw-r--r--src/async/imap/MCIMAPRenameFolderOperation.h4
-rw-r--r--src/async/imap/MCIMAPSearchOperation.cc16
-rw-r--r--src/async/imap/MCIMAPSearchOperation.h4
-rw-r--r--src/async/imap/MCIMAPStoreFlagsOperation.cc14
-rw-r--r--src/async/imap/MCIMAPStoreFlagsOperation.h4
-rw-r--r--src/async/imap/MCIMAPStoreLabelsOperation.cc14
-rw-r--r--src/async/imap/MCIMAPStoreLabelsOperation.h4
-rw-r--r--src/async/imap/MCIMAPSubscribeFolderOperation.cc16
-rw-r--r--src/async/imap/MCIMAPSubscribeFolderOperation.h4
-rw-r--r--src/async/pop/MCPOPAsyncSession.cc2
-rw-r--r--src/async/smtp/MCSMTPAsyncSession.cc2
-rw-r--r--src/core/basetypes/MCOperationQueue.cc20
-rw-r--r--src/core/basetypes/MCOperationQueue.h2
-rw-r--r--src/core/imap/MCIMAPSession.cc17
-rw-r--r--src/core/imap/MCIMAPSession.h6
-rw-r--r--src/core/pop/MCPOPSession.cc2
-rw-r--r--src/core/rfc822/MCAttachment.cc2
-rw-r--r--src/core/smtp/MCSMTPSession.cc2
-rw-r--r--tests/main.mm8
48 files changed, 680 insertions, 279 deletions
diff --git a/build-mac/mailcore2.xcodeproj/project.pbxproj b/build-mac/mailcore2.xcodeproj/project.pbxproj
index 3607fcb3..37f50990 100644
--- a/build-mac/mailcore2.xcodeproj/project.pbxproj
+++ b/build-mac/mailcore2.xcodeproj/project.pbxproj
@@ -36,6 +36,8 @@
C62C6F0316A7E3B000737497 /* MCPOPOperationCallback.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = C62C6EFC16A7CA1500737497 /* MCPOPOperationCallback.h */; };
C62C6F0616A7E54500737497 /* MCPOPFetchMessagesOperation.cc in Sources */ = {isa = PBXBuildFile; fileRef = C62C6F0416A7E54200737497 /* MCPOPFetchMessagesOperation.cc */; };
C62C6F0716A7E7CC00737497 /* MCPOPFetchMessagesOperation.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = C62C6F0516A7E54400737497 /* MCPOPFetchMessagesOperation.h */; };
+ C62C6F0A16A8F58000737497 /* MCIMAPAccount.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C62C6F0816A8F57000737497 /* MCIMAPAccount.cpp */; };
+ C62C6F0B16A936CA00737497 /* MCIMAPAccount.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = C62C6F0916A8F57700737497 /* MCIMAPAccount.h */; };
C64EA6F4169E847800778456 /* MCAbstractMessage.cc in Sources */ = {isa = PBXBuildFile; fileRef = C64EA694169E847800778456 /* MCAbstractMessage.cc */; };
C64EA6F6169E847800778456 /* MCAbstractMessagePart.cc in Sources */ = {isa = PBXBuildFile; fileRef = C64EA696169E847800778456 /* MCAbstractMessagePart.cc */; };
C64EA6F8169E847800778456 /* MCAbstractMultipart.cc in Sources */ = {isa = PBXBuildFile; fileRef = C64EA698169E847800778456 /* MCAbstractMultipart.cc */; };
@@ -237,6 +239,7 @@
C62C6F0216A7E3A700737497 /* MCAsyncPOP.h in CopyFiles */,
C62C6F0316A7E3B000737497 /* MCPOPOperationCallback.h in CopyFiles */,
C62C6F0116A7E32F00737497 /* MCPOPFetchMessageOperation.h in CopyFiles */,
+ C62C6F0B16A936CA00737497 /* MCIMAPAccount.h in CopyFiles */,
C64EA772169E859600778456 /* MCIMAPSession.h in CopyFiles */,
C64EA773169E859600778456 /* MCPOP.h in CopyFiles */,
C64EA774169E859600778456 /* MCPOPMessageInfo.h in CopyFiles */,
@@ -287,6 +290,8 @@
C62C6EFD16A7DD0300737497 /* MCAsyncPOP.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MCAsyncPOP.h; sourceTree = "<group>"; };
C62C6F0416A7E54200737497 /* MCPOPFetchMessagesOperation.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MCPOPFetchMessagesOperation.cc; sourceTree = "<group>"; };
C62C6F0516A7E54400737497 /* MCPOPFetchMessagesOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MCPOPFetchMessagesOperation.h; sourceTree = "<group>"; };
+ C62C6F0816A8F57000737497 /* MCIMAPAccount.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MCIMAPAccount.cpp; sourceTree = "<group>"; };
+ C62C6F0916A8F57700737497 /* MCIMAPAccount.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MCIMAPAccount.h; sourceTree = "<group>"; };
C64EA537169E772200778456 /* libmailcore2.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libmailcore2.a; sourceTree = BUILT_PRODUCTS_DIR; };
C64EA68C169E847800778456 /* MCIMAPAsyncSession.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MCIMAPAsyncSession.h; sourceTree = "<group>"; };
C64EA68F169E847800778456 /* MCSMTPAsyncSession.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MCSMTPAsyncSession.cc; sourceTree = "<group>"; };
@@ -517,6 +522,8 @@
C64EA7F916A15A9200778456 /* MCAsyncIMAP.h */,
C64EA7FD16A295B500778456 /* MCIMAPAsyncSession.cc */,
C64EA68C169E847800778456 /* MCIMAPAsyncSession.h */,
+ C62C6F0816A8F57000737497 /* MCIMAPAccount.cpp */,
+ C62C6F0916A8F57700737497 /* MCIMAPAccount.h */,
C64EA7EF16A15A4D00778456 /* MCIMAPOperation.cc */,
C64EA7F016A15A4D00778456 /* MCIMAPOperation.h */,
C64EA7F416A15A6300778456 /* MCIMAPOperationCallback.h */,
@@ -915,6 +922,7 @@
C62C6EF816A7C6F500737497 /* MCPOPDeleteMessagesOperation.cc in Sources */,
C62C6EFB16A7C94000737497 /* MCPOPOperation.cc in Sources */,
C62C6F0616A7E54500737497 /* MCPOPFetchMessagesOperation.cc in Sources */,
+ C62C6F0A16A8F58000737497 /* MCIMAPAccount.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
diff --git a/src/async/imap/MCAsyncIMAP.h b/src/async/imap/MCAsyncIMAP.h
index 1391439b..96c0345f 100644
--- a/src/async/imap/MCAsyncIMAP.h
+++ b/src/async/imap/MCAsyncIMAP.h
@@ -9,6 +9,7 @@
#ifndef mailcore2_MCAsyncIMAP_h
#define mailcore2_MCAsyncIMAP_h
+#include <mailcore/MCIMAPAccount.h>
#include <mailcore/MCIMAPAsyncSession.h>
#include <mailcore/MCIMAPOperation.h>
#include <mailcore/MCIMAPFetchFoldersOperation.h>
diff --git a/src/async/imap/MCIMAPAccount.cpp b/src/async/imap/MCIMAPAccount.cpp
new file mode 100644
index 00000000..beea3381
--- /dev/null
+++ b/src/async/imap/MCIMAPAccount.cpp
@@ -0,0 +1,411 @@
+//
+// MCIMAPAccount.cpp
+// mailcore2
+//
+// Created by DINH Viêt Hoà on 1/17/13.
+// Copyright (c) 2013 MailCore. All rights reserved.
+//
+
+#include "MCIMAPAccount.h"
+
+#include "MCIMAPAsyncSession.h"
+#include "MCIMAPNamespace.h"
+
+#define DEFAULT_MAX_CONNECTIONS 3
+
+using namespace mailcore;
+
+IMAPAccount::IMAPAccount()
+{
+ mSessions = new Array();
+ mMaximumConnections = DEFAULT_MAX_CONNECTIONS;
+ mAllowsFolderConcurrentAccessEnabled = true;
+}
+
+IMAPAccount::~IMAPAccount()
+{
+ MC_SAFE_RELEASE(mSessions);
+}
+
+void IMAPAccount::setHostname(String * hostname)
+{
+ MC_SAFE_REPLACE_COPY(String, mHostname, hostname);
+}
+
+String * IMAPAccount::hostname()
+{
+ return mHostname;
+}
+
+void IMAPAccount::setPort(unsigned int port)
+{
+ mPort = port;
+}
+
+unsigned int IMAPAccount::port()
+{
+ return mPort;
+}
+
+void IMAPAccount::setUsername(String * username)
+{
+ MC_SAFE_REPLACE_COPY(String, mUsername, username);
+}
+
+String * IMAPAccount::username()
+{
+ return mUsername;
+}
+
+void IMAPAccount::setPassword(String * password)
+{
+ MC_SAFE_REPLACE_COPY(String, mPassword, password);
+}
+
+String * IMAPAccount::password()
+{
+ return mPassword;
+}
+
+void IMAPAccount::setAuthType(AuthType authType)
+{
+ mAuthType = authType;
+}
+
+AuthType IMAPAccount::authType()
+{
+ return mAuthType;
+}
+
+void IMAPAccount::setConnectionType(ConnectionType connectionType)
+{
+ mConnectionType = connectionType;
+}
+
+ConnectionType IMAPAccount::connectionType()
+{
+ return mConnectionType;
+}
+
+void IMAPAccount::setTimeout(time_t timeout)
+{
+ mTimeout = timeout;
+}
+
+time_t IMAPAccount::timeout()
+{
+ return mTimeout;
+}
+
+void IMAPAccount::setCheckCertificateEnabled(bool enabled)
+{
+ mCheckCertificateEnabled = enabled;
+}
+
+bool IMAPAccount::isCheckCertificateEnabled()
+{
+ return mCheckCertificateEnabled;
+}
+
+void IMAPAccount::setVoIPEnabled(bool enabled)
+{
+ mVoIPEnabled = enabled;
+}
+
+bool IMAPAccount::isVoIPEnabled()
+{
+ return mVoIPEnabled;
+}
+
+
+void IMAPAccount::setDelimiter(char delimiter)
+{
+ mDelimiter = delimiter;
+}
+
+char IMAPAccount::delimiter()
+{
+ return mDelimiter;
+}
+
+IMAPNamespace * IMAPAccount::defaultNamespace()
+{
+ return mDefaultNamespace;
+}
+
+void IMAPAccount::setDefaultNamespace(IMAPNamespace * ns)
+{
+ MC_SAFE_REPLACE_RETAIN(IMAPNamespace, mDefaultNamespace, ns);
+}
+
+void IMAPAccount::setAllowsFolderConcurrentAccessEnabled(bool enabled)
+{
+ mAllowsFolderConcurrentAccessEnabled = enabled;
+}
+
+bool IMAPAccount::allowsFolderConcurrentAccessEnabled()
+{
+ return mAllowsFolderConcurrentAccessEnabled;
+}
+
+void IMAPAccount::setMaximumConnections(unsigned int maxConnections)
+{
+ mMaximumConnections = maxConnections;
+}
+
+unsigned int IMAPAccount::maximumConnections()
+{
+ return mMaximumConnections;
+}
+
+IMAPAsyncSession * IMAPAccount::session()
+{
+ IMAPAsyncSession * session = new IMAPAsyncSession();
+ session->autorelease();
+
+ session->setHostname(mHostname);
+ session->setPort(mPort);
+ session->setUsername(mUsername);
+ session->setPassword(mPassword);
+ session->setAuthType(mAuthType);
+ session->setConnectionType(mConnectionType);
+ session->setTimeout(mTimeout);
+ session->setCheckCertificateEnabled(mCheckCertificateEnabled);
+ session->setVoIPEnabled(mVoIPEnabled);
+ session->setDelimiter(mDelimiter);
+ session->setDefaultNamespace(mDefaultNamespace);
+
+ return session;
+}
+
+IMAPAsyncSession * IMAPAccount::sessionForFolder(String * folder, bool urgent)
+{
+ if (folder == NULL) {
+ return availableSession();
+ }
+ else {
+ IMAPAsyncSession * s = NULL;
+ if (urgent && mAllowsFolderConcurrentAccessEnabled) {
+ s = availableSession();
+ if (s->operationsCount() == 0) {
+ s->setLastFolder(folder);
+ return s;
+ }
+ }
+
+ s = matchingSessionForFolder(folder);
+ s->setLastFolder(folder);
+ return s;
+ }
+}
+
+IMAPAsyncSession * IMAPAccount::availableSession()
+{
+ if (mMaximumConnections == 0) {
+ for(unsigned int i = 0 ; i < mSessions->count() ; i ++) {
+ IMAPAsyncSession * s = (IMAPAsyncSession *) mSessions->objectAtIndex(i);
+ if (s->operationsCount() == 0)
+ return s;
+ }
+ IMAPAsyncSession * chosenSession = session();
+ mSessions->addObject(chosenSession);
+ return chosenSession;
+ }
+ else {
+ IMAPAsyncSession * chosenSession = NULL;
+ unsigned int minOperationsCount = 0;
+ for(unsigned int i = 0 ; i < mSessions->count() ; i ++) {
+ IMAPAsyncSession * s = (IMAPAsyncSession *) mSessions->objectAtIndex(i);
+ if (chosenSession == NULL) {
+ chosenSession = s;
+ minOperationsCount = s->operationsCount();
+ }
+ else if (s->operationsCount() < minOperationsCount) {
+ chosenSession = s;
+ minOperationsCount = s->operationsCount();
+ }
+ }
+ if (mSessions->count() < mMaximumConnections) {
+ if ((chosenSession != NULL) && (minOperationsCount == 0)) {
+ return chosenSession;
+ }
+ chosenSession = session();
+ mSessions->addObject(chosenSession);
+ return chosenSession;
+ }
+ else {
+ return chosenSession;
+ }
+ }
+}
+
+IMAPAsyncSession * IMAPAccount::matchingSessionForFolder(String * folder)
+{
+ for(unsigned int i = 0 ; i < mSessions->count() ; i ++) {
+ IMAPAsyncSession * currentSession = (IMAPAsyncSession *) mSessions->objectAtIndex(i);
+ if (currentSession->lastFolder() != NULL) {
+ if (currentSession->lastFolder()->compare(folder)) {
+ return currentSession;
+ }
+ }
+ else {
+ return currentSession;
+ }
+ }
+ return availableSession();
+}
+
+IMAPFolderInfoOperation * IMAPAccount::folderInfoOperation(String * folder)
+{
+ IMAPAsyncSession * session = sessionForFolder(folder);
+ return session->folderInfoOperation(folder);
+}
+
+IMAPFetchFoldersOperation * IMAPAccount::fetchSubscribedFoldersOperation()
+{
+ IMAPAsyncSession * session = sessionForFolder(MCSTR("INBOX"));
+ return session->fetchSubscribedFoldersOperation();
+}
+
+IMAPFetchFoldersOperation * IMAPAccount::fetchAllFoldersOperation()
+{
+ IMAPAsyncSession * session = sessionForFolder(MCSTR("INBOX"));
+ return session->fetchAllFoldersOperation();
+}
+
+IMAPOperation * IMAPAccount::renameFolderOperation(String * folder, String * otherName)
+{
+ IMAPAsyncSession * session = sessionForFolder(MCSTR("INBOX"));
+ return session->renameFolderOperation(folder, otherName);
+}
+
+IMAPOperation * IMAPAccount::deleteFolderOperation(String * folder)
+{
+ IMAPAsyncSession * session = sessionForFolder(MCSTR("INBOX"));
+ return session->deleteFolderOperation(folder);
+}
+
+IMAPOperation * IMAPAccount::createFolderOperation(String * folder)
+{
+ IMAPAsyncSession * session = sessionForFolder(MCSTR("INBOX"));
+ return session->createFolderOperation(folder);
+}
+
+IMAPOperation * IMAPAccount::subscribeFolderOperation(String * folder)
+{
+ IMAPAsyncSession * session = sessionForFolder(MCSTR("INBOX"));
+ return session->subscribeFolderOperation(folder);
+}
+
+IMAPOperation * IMAPAccount::unsubscribeFolderOperation(String * folder)
+{
+ IMAPAsyncSession * session = sessionForFolder(MCSTR("INBOX"));
+ return session->unsubscribeFolderOperation(folder);
+}
+
+IMAPAppendMessageOperation * IMAPAccount::appendMessageOperation(String * folder, Data * messageData, MessageFlag flags)
+{
+ IMAPAsyncSession * session = sessionForFolder(folder);
+ return session->appendMessageOperation(folder, messageData, flags);
+}
+
+IMAPCopyMessagesOperation * IMAPAccount::copyMessagesOperation(String * folder, Array * uids, String * destFolder)
+{
+ IMAPAsyncSession * session = sessionForFolder(folder);
+ return session->copyMessagesOperation(folder, uids, destFolder);
+}
+
+IMAPOperation * IMAPAccount::expungeOperation(String * folder)
+{
+ IMAPAsyncSession * session = sessionForFolder(folder);
+ return session->expungeOperation(folder);
+}
+
+IMAPFetchMessagesOperation * IMAPAccount::fetchMessagesByUIDOperation(String * folder, IMAPMessagesRequestKind requestKind,
+ uint32_t firstUID, uint32_t lastUID)
+{
+ IMAPAsyncSession * session = sessionForFolder(folder);
+ return session->fetchMessagesByUIDOperation(folder, requestKind, firstUID, lastUID);
+}
+
+IMAPFetchMessagesOperation * IMAPAccount::fetchMessagesByNumberOperation(String * folder, IMAPMessagesRequestKind requestKind,
+ uint32_t firstNumber, uint32_t lastNumber)
+{
+ IMAPAsyncSession * session = sessionForFolder(folder);
+ return session->fetchMessagesByNumberOperation(folder, requestKind, firstNumber, lastNumber);
+}
+
+IMAPFetchMessagesOperation * IMAPAccount::fetchMessagesByUIDOperation(String * folder, IMAPMessagesRequestKind requestKind,
+ Array * uids)
+{
+ IMAPAsyncSession * session = sessionForFolder(folder);
+ return session->fetchMessagesByUIDOperation(folder, requestKind, uids);
+}
+
+IMAPFetchMessagesOperation * IMAPAccount::fetchMessagesByNumberOperation(String * folder, IMAPMessagesRequestKind requestKind,
+ Array * numbers)
+{
+ IMAPAsyncSession * session = sessionForFolder(folder);
+ return session->fetchMessagesByNumberOperation(folder, requestKind, numbers);
+}
+
+IMAPFetchContentOperation * IMAPAccount::fetchMessageByUIDOperation(String * folder, uint32_t uid, bool urgent)
+{
+ IMAPAsyncSession * session = sessionForFolder(folder, urgent);
+ return session->fetchMessageByUIDOperation(folder, uid);
+}
+
+IMAPFetchContentOperation * IMAPAccount::fetchMessageAttachmentByUIDOperation(String * folder, uint32_t uid, String * partID,
+ Encoding encoding, bool urgent)
+{
+ IMAPAsyncSession * session = sessionForFolder(folder, urgent);
+ return session->fetchMessageAttachmentByUIDOperation(folder, uid, partID, encoding);
+}
+
+IMAPOperation * IMAPAccount::storeFlagsOperation(String * folder, Array * uids, IMAPStoreFlagsRequestKind kind, MessageFlag flags)
+{
+ IMAPAsyncSession * session = sessionForFolder(folder);
+ return session->storeFlagsOperation(folder, uids, kind, flags);
+}
+
+IMAPOperation * IMAPAccount::storeLabelsOperation(String * folder, Array * uids, IMAPStoreFlagsRequestKind kind, Array * labels)
+{
+ IMAPAsyncSession * session = sessionForFolder(folder);
+ return session->storeLabelsOperation(folder, uids, kind, labels);
+}
+
+IMAPSearchOperation * IMAPAccount::searchOperation(String * folder, IMAPSearchKind kind, String * searchString)
+{
+ IMAPAsyncSession * session = sessionForFolder(folder);
+ return session->searchOperation(folder, kind, searchString);
+}
+
+IMAPSearchOperation * IMAPAccount::searchOperation(String * folder, IMAPSearchExpression * expression)
+{
+ IMAPAsyncSession * session = sessionForFolder(folder);
+ return session->searchOperation(folder, expression);
+}
+
+IMAPIdleOperation * IMAPAccount::idleOperation(String * folder, uint32_t lastKnownUID)
+{
+ IMAPAsyncSession * session = sessionForFolder(folder);
+ return session->idleOperation(folder, lastKnownUID);
+}
+
+IMAPFetchNamespaceOperation * IMAPAccount::fetchNamespaceOperation()
+{
+ IMAPAsyncSession * session = sessionForFolder(MCSTR("INBOX"));
+ return session->fetchNamespaceOperation();
+}
+
+IMAPIdentityOperation * IMAPAccount::identityOperation(String * vendor, String * name, String * version)
+{
+ IMAPAsyncSession * session = sessionForFolder(MCSTR("INBOX"));
+ return session->identityOperation(vendor, name, version);
+}
+
+IMAPOperation * IMAPAccount::checkAccountOperation()
+{
+ IMAPAsyncSession * session = sessionForFolder(MCSTR("INBOX"));
+ return session->checkAccountOperation();
+}
diff --git a/src/async/imap/MCIMAPAccount.h b/src/async/imap/MCIMAPAccount.h
new file mode 100644
index 00000000..848f7c01
--- /dev/null
+++ b/src/async/imap/MCIMAPAccount.h
@@ -0,0 +1,146 @@
+//
+// MCIMAPAccount.h
+// mailcore2
+//
+// Created by DINH Viêt Hoà on 1/17/13.
+// Copyright (c) 2013 MailCore. All rights reserved.
+//
+
+#ifndef __mailcore2__MCIMAPAccount__
+#define __mailcore2__MCIMAPAccount__
+
+#include <mailcore/MCBaseTypes.h>
+#include <mailcore/MCMessageConstants.h>
+
+namespace mailcore {
+
+ class IMAPOperation;
+ class IMAPFetchFoldersOperation;
+ class IMAPAppendMessageOperation;
+ class IMAPCopyMessagesOperation;
+ class IMAPFetchMessagesOperation;
+ class IMAPFetchContentOperation;
+ class IMAPIdleOperation;
+ class IMAPFolderInfoOperation;
+ class IMAPNamespace;
+ class IMAPSearchOperation;
+ class IMAPSearchExpression;
+ class IMAPFetchNamespaceOperation;
+ class IMAPIdentityOperation;
+ class IMAPAsyncSession;
+
+ class IMAPAccount : public Object {
+ private:
+ Array * mSessions;
+
+ String * mHostname;
+ unsigned int mPort;
+ String * mUsername;
+ String * mPassword;
+ AuthType mAuthType;
+ ConnectionType mConnectionType;
+ bool mCheckCertificateEnabled;
+ bool mVoIPEnabled;
+ char mDelimiter;
+ IMAPNamespace * mDefaultNamespace;
+ time_t mTimeout;
+ bool mAllowsFolderConcurrentAccessEnabled;
+ unsigned int mMaximumConnections;
+
+ IMAPAsyncSession * sessionForFolder(String * folder, bool urgent = false);
+ IMAPAsyncSession * session();
+ IMAPAsyncSession * matchingSessionForFolder(String * folder);
+ IMAPAsyncSession * availableSession();
+
+ public:
+ IMAPAccount();
+ virtual ~IMAPAccount();
+
+ virtual void setHostname(String * hostname);
+ virtual String * hostname();
+
+ virtual void setPort(unsigned int port);
+ virtual unsigned int port();
+
+ virtual void setUsername(String * username);
+ virtual String * username();
+
+ virtual void setPassword(String * password);
+ virtual String * password();
+
+ virtual void setAuthType(AuthType authType);
+ virtual AuthType authType();
+
+ virtual void setConnectionType(ConnectionType connectionType);
+ virtual ConnectionType connectionType();
+
+ virtual void setTimeout(time_t timeout);
+ virtual time_t timeout();
+
+ virtual void setCheckCertificateEnabled(bool enabled);
+ virtual bool isCheckCertificateEnabled();
+
+ virtual void setVoIPEnabled(bool enabled);
+ virtual bool isVoIPEnabled();
+
+ virtual void setDelimiter(char delimiter);
+ virtual char delimiter();
+
+ virtual void setDefaultNamespace(IMAPNamespace * ns);
+ virtual IMAPNamespace * defaultNamespace();
+
+ virtual void setAllowsFolderConcurrentAccessEnabled(bool enabled);
+ virtual bool allowsFolderConcurrentAccessEnabled();
+
+ virtual void setMaximumConnections(unsigned int maxConnections);
+ virtual unsigned int maximumConnections();
+
+ virtual IMAPFolderInfoOperation * folderInfoOperation(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);
+
+ virtual IMAPCopyMessagesOperation * copyMessagesOperation(String * folder, Array * uids, String * destFolder);
+
+ virtual IMAPOperation * expungeOperation(String * folder);
+
+ virtual IMAPFetchMessagesOperation * fetchMessagesByUIDOperation(String * folder, IMAPMessagesRequestKind requestKind,
+ uint32_t firstUID, uint32_t lastUID);
+ virtual IMAPFetchMessagesOperation * fetchMessagesByNumberOperation(String * folder, IMAPMessagesRequestKind requestKind,
+ uint32_t firstNumber, uint32_t lastNumber);
+ virtual IMAPFetchMessagesOperation * fetchMessagesByUIDOperation(String * folder, IMAPMessagesRequestKind requestKind,
+ Array * numbers);
+ virtual IMAPFetchMessagesOperation * fetchMessagesByNumberOperation(String * folder, IMAPMessagesRequestKind requestKind,
+ Array * numbers);
+
+ virtual IMAPFetchContentOperation * fetchMessageByUIDOperation(String * folder, uint32_t uid, bool urgent = false);
+ virtual IMAPFetchContentOperation * fetchMessageAttachmentByUIDOperation(String * folder, uint32_t uid, String * partID,
+ Encoding encoding,
+ bool urgent = false);
+
+ virtual IMAPOperation * storeFlagsOperation(String * folder, Array * uids, IMAPStoreFlagsRequestKind kind, MessageFlag flags);
+ virtual IMAPOperation * storeLabelsOperation(String * folder, Array * 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(String * vendor, String * name, String * version);
+
+ virtual IMAPOperation * checkAccountOperation();
+ };
+}
+
+#endif /* defined(__mailcore2__MCIMAPAccount__) */
diff --git a/src/async/imap/MCIMAPAppendMessageOperation.cc b/src/async/imap/MCIMAPAppendMessageOperation.cc
index 4026d2d8..af9f3f4b 100644
--- a/src/async/imap/MCIMAPAppendMessageOperation.cc
+++ b/src/async/imap/MCIMAPAppendMessageOperation.cc
@@ -15,7 +15,6 @@ using namespace mailcore;
IMAPAppendMessageOperation::IMAPAppendMessageOperation()
{
- mFolder = NULL;
mMessageData = NULL;
mFlags = MessageFlagNone;
mCreatedUID = 0;
@@ -23,20 +22,9 @@ IMAPAppendMessageOperation::IMAPAppendMessageOperation()
IMAPAppendMessageOperation::~IMAPAppendMessageOperation()
{
- MC_SAFE_RELEASE(mFolder);
MC_SAFE_RELEASE(mMessageData);
}
-void IMAPAppendMessageOperation::setFolder(String * folder)
-{
- MC_SAFE_REPLACE_COPY(String, mFolder, folder);
-}
-
-String * IMAPAppendMessageOperation::folder()
-{
- return mFolder;
-}
-
void IMAPAppendMessageOperation::setMessageData(Data * messageData)
{
MC_SAFE_REPLACE_RETAIN(Data, mMessageData, messageData);
@@ -65,7 +53,7 @@ uint32_t IMAPAppendMessageOperation::createdUID()
void IMAPAppendMessageOperation::main()
{
ErrorCode error;
- session()->session()->appendMessage(mFolder, mMessageData, mFlags, this, &mCreatedUID, &error);
+ session()->session()->appendMessage(folder(), mMessageData, mFlags, this, &mCreatedUID, &error);
setError(error);
}
diff --git a/src/async/imap/MCIMAPAppendMessageOperation.h b/src/async/imap/MCIMAPAppendMessageOperation.h
index bf8238e5..36217d2a 100644
--- a/src/async/imap/MCIMAPAppendMessageOperation.h
+++ b/src/async/imap/MCIMAPAppendMessageOperation.h
@@ -16,7 +16,6 @@ namespace mailcore {
class IMAPAppendMessageOperation : public IMAPOperation {
private:
- String * mFolder;
Data * mMessageData;
MessageFlag mFlags;
uint32_t mCreatedUID;
@@ -25,9 +24,6 @@ namespace mailcore {
IMAPAppendMessageOperation();
virtual ~IMAPAppendMessageOperation();
- virtual void setFolder(String * folder);
- virtual String * folder();
-
virtual void setMessageData(Data * messageData);
virtual Data * messageData();
diff --git a/src/async/imap/MCIMAPAsyncSession.cc b/src/async/imap/MCIMAPAsyncSession.cc
index 6dfaaa22..5d958d61 100644
--- a/src/async/imap/MCIMAPAsyncSession.cc
+++ b/src/async/imap/MCIMAPAsyncSession.cc
@@ -323,7 +323,7 @@ IMAPFetchContentOperation * IMAPAsyncSession::fetchMessageByUIDOperation(String
}
IMAPFetchContentOperation * IMAPAsyncSession::fetchMessageAttachmentByUIDOperation(String * folder, uint32_t uid, String * partID,
- Encoding encoding, unsigned int expectedSize)
+ Encoding encoding)
{
IMAPFetchContentOperation * op = new IMAPFetchContentOperation();
op->setSession(this);
@@ -422,8 +422,24 @@ IMAPSession * IMAPAsyncSession::session()
return mSession;
}
+unsigned int IMAPAsyncSession::operationsCount()
+{
+ return mQueue->count();
+}
+
void IMAPAsyncSession::runOperation(IMAPOperation * operation)
{
- // TODO: disconnect after delay
+#warning disconnect after delay
mQueue->addOperation(operation);
}
+
+void IMAPAsyncSession::setLastFolder(String * folder)
+{
+ MC_SAFE_REPLACE_COPY(String, mLastFolder, folder);
+}
+
+String * IMAPAsyncSession::lastFolder()
+{
+ return mLastFolder;
+}
+
diff --git a/src/async/imap/MCIMAPAsyncSession.h b/src/async/imap/MCIMAPAsyncSession.h
index 6628e80a..77c06b1e 100644
--- a/src/async/imap/MCIMAPAsyncSession.h
+++ b/src/async/imap/MCIMAPAsyncSession.h
@@ -28,6 +28,7 @@ namespace mailcore {
OperationQueue * mQueue;
char mDelimiter;
IMAPNamespace * mDefaultNamespace;
+ String * mLastFolder;
void queue(IMAPOperation * op);
@@ -91,12 +92,12 @@ namespace mailcore {
virtual IMAPFetchMessagesOperation * fetchMessagesByNumberOperation(String * folder, IMAPMessagesRequestKind requestKind,
uint32_t firstNumber, uint32_t lastNumber);
virtual IMAPFetchMessagesOperation * fetchMessagesByUIDOperation(String * folder, IMAPMessagesRequestKind requestKind,
- Array * numbers);
+ Array * uids);
virtual IMAPFetchMessagesOperation * fetchMessagesByNumberOperation(String * folder, IMAPMessagesRequestKind requestKind,
Array * numbers);
virtual IMAPFetchContentOperation * fetchMessageByUIDOperation(String * folder, uint32_t uid);
virtual IMAPFetchContentOperation * fetchMessageAttachmentByUIDOperation(String * folder, uint32_t uid, String * partID,
- Encoding encoding, unsigned int expectedSize);
+ Encoding encoding);
virtual IMAPOperation * storeFlagsOperation(String * folder, Array * uids, IMAPStoreFlagsRequestKind kind, MessageFlag flags);
virtual IMAPOperation * storeLabelsOperation(String * folder, Array * uids, IMAPStoreFlagsRequestKind kind, Array * labels);
@@ -115,6 +116,11 @@ namespace mailcore {
// private
virtual void runOperation(IMAPOperation * operation);
virtual IMAPSession * session();
+
+ virtual unsigned int operationsCount();
+
+ virtual void setLastFolder(String * folder);
+ virtual String * lastFolder();
};
}
diff --git a/src/async/imap/MCIMAPCopyMessagesOperation.cc b/src/async/imap/MCIMAPCopyMessagesOperation.cc
index b207c71e..b4ec068d 100644
--- a/src/async/imap/MCIMAPCopyMessagesOperation.cc
+++ b/src/async/imap/MCIMAPCopyMessagesOperation.cc
@@ -15,7 +15,6 @@ using namespace mailcore;
IMAPCopyMessagesOperation::IMAPCopyMessagesOperation()
{
- mFolder = NULL;
mUids = NULL;
mDestFolder = NULL;
mDestUids = NULL;
@@ -24,21 +23,10 @@ IMAPCopyMessagesOperation::IMAPCopyMessagesOperation()
IMAPCopyMessagesOperation::~IMAPCopyMessagesOperation()
{
MC_SAFE_RELEASE(mDestUids);
- MC_SAFE_RELEASE(mFolder);
MC_SAFE_RELEASE(mUids);
MC_SAFE_RELEASE(mDestFolder);
}
-void IMAPCopyMessagesOperation::setFolder(String * folder)
-{
- MC_SAFE_REPLACE_COPY(String, mFolder, folder);
-}
-
-String * IMAPCopyMessagesOperation::folder()
-{
- return mFolder;
-}
-
void IMAPCopyMessagesOperation::setUids(Array * uids)
{
MC_SAFE_REPLACE_RETAIN(Array, mUids, uids);
@@ -67,7 +55,7 @@ String * IMAPCopyMessagesOperation::destFolder()
void IMAPCopyMessagesOperation::main()
{
ErrorCode error;
- session()->session()->copyMessages(mFolder, mUids, mDestFolder, &mDestUids, &error);
+ session()->session()->copyMessages(folder(), mUids, mDestFolder, &mDestUids, &error);
MC_SAFE_RETAIN(mDestUids);
setError(error);
}
diff --git a/src/async/imap/MCIMAPCopyMessagesOperation.h b/src/async/imap/MCIMAPCopyMessagesOperation.h
index 4dd279dd..e3f2bf55 100644
--- a/src/async/imap/MCIMAPCopyMessagesOperation.h
+++ b/src/async/imap/MCIMAPCopyMessagesOperation.h
@@ -15,7 +15,6 @@ namespace mailcore {
class IMAPCopyMessagesOperation : public IMAPOperation {
private:
- String * mFolder;
Array * mUids;
String * mDestFolder;
Array * mDestUids;
@@ -24,9 +23,6 @@ namespace mailcore {
IMAPCopyMessagesOperation();
virtual ~IMAPCopyMessagesOperation();
- virtual void setFolder(String * folder);
- virtual String * folder();
-
virtual void setDestFolder(String * destFolder);
virtual String * destFolder();
diff --git a/src/async/imap/MCIMAPCreateFolderOperation.cc b/src/async/imap/MCIMAPCreateFolderOperation.cc
index bdf76c91..e33888a2 100644
--- a/src/async/imap/MCIMAPCreateFolderOperation.cc
+++ b/src/async/imap/MCIMAPCreateFolderOperation.cc
@@ -15,27 +15,15 @@ using namespace mailcore;
IMAPCreateFolderOperation::IMAPCreateFolderOperation()
{
- mFolder = NULL;
}
IMAPCreateFolderOperation::~IMAPCreateFolderOperation()
{
- MC_SAFE_RELEASE(mFolder);
-}
-
-void IMAPCreateFolderOperation::setFolder(String * folder)
-{
- MC_SAFE_REPLACE_COPY(String, mFolder, folder);
-}
-
-String * IMAPCreateFolderOperation::folder()
-{
- return mFolder;
}
void IMAPCreateFolderOperation::main()
{
ErrorCode error;
- session()->session()->createFolder(mFolder, &error);
+ session()->session()->createFolder(folder(), &error);
setError(error);
}
diff --git a/src/async/imap/MCIMAPCreateFolderOperation.h b/src/async/imap/MCIMAPCreateFolderOperation.h
index 4b242696..f2394297 100644
--- a/src/async/imap/MCIMAPCreateFolderOperation.h
+++ b/src/async/imap/MCIMAPCreateFolderOperation.h
@@ -15,15 +15,11 @@ namespace mailcore {
class IMAPCreateFolderOperation : public IMAPOperation {
private:
- String * mFolder;
public:
IMAPCreateFolderOperation();
virtual ~IMAPCreateFolderOperation();
- virtual void setFolder(String * folder);
- virtual String * folder();
-
virtual void main();
};
}
diff --git a/src/async/imap/MCIMAPDeleteFolderOperation.cc b/src/async/imap/MCIMAPDeleteFolderOperation.cc
index e3541480..13f11557 100644
--- a/src/async/imap/MCIMAPDeleteFolderOperation.cc
+++ b/src/async/imap/MCIMAPDeleteFolderOperation.cc
@@ -15,27 +15,15 @@ using namespace mailcore;
IMAPDeleteFolderOperation::IMAPDeleteFolderOperation()
{
- mFolder = NULL;
}
IMAPDeleteFolderOperation::~IMAPDeleteFolderOperation()
{
- MC_SAFE_RELEASE(mFolder);
-}
-
-void IMAPDeleteFolderOperation::setFolder(String * folder)
-{
- MC_SAFE_REPLACE_COPY(String, mFolder, folder);
-}
-
-String * IMAPDeleteFolderOperation::folder()
-{
- return mFolder;
}
void IMAPDeleteFolderOperation::main()
{
ErrorCode error;
- session()->session()->deleteFolder(mFolder, &error);
+ session()->session()->deleteFolder(folder(), &error);
setError(error);
}
diff --git a/src/async/imap/MCIMAPDeleteFolderOperation.h b/src/async/imap/MCIMAPDeleteFolderOperation.h
index 96d0873c..521f1d30 100644
--- a/src/async/imap/MCIMAPDeleteFolderOperation.h
+++ b/src/async/imap/MCIMAPDeleteFolderOperation.h
@@ -15,15 +15,11 @@ namespace mailcore {
class IMAPDeleteFolderOperation : public IMAPOperation {
private:
- String * mFolder;
public:
IMAPDeleteFolderOperation();
virtual ~IMAPDeleteFolderOperation();
- virtual void setFolder(String * folder);
- virtual String * folder();
-
virtual void main();
};
}
diff --git a/src/async/imap/MCIMAPExpungeOperation.cc b/src/async/imap/MCIMAPExpungeOperation.cc
index c0abee70..c1e0eea3 100644
--- a/src/async/imap/MCIMAPExpungeOperation.cc
+++ b/src/async/imap/MCIMAPExpungeOperation.cc
@@ -15,27 +15,15 @@ using namespace mailcore;
IMAPExpungeOperation::IMAPExpungeOperation()
{
- mFolder = NULL;
}
IMAPExpungeOperation::~IMAPExpungeOperation()
{
- MC_SAFE_RELEASE(mFolder);
-}
-
-void IMAPExpungeOperation::setFolder(String * folder)
-{
- MC_SAFE_REPLACE_COPY(String, mFolder, folder);
-}
-
-String * IMAPExpungeOperation::folder()
-{
- return mFolder;
}
void IMAPExpungeOperation::main()
{
ErrorCode error;
- session()->session()->expunge(mFolder, &error);
+ session()->session()->expunge(folder(), &error);
setError(error);
}
diff --git a/src/async/imap/MCIMAPExpungeOperation.h b/src/async/imap/MCIMAPExpungeOperation.h
index 4f3bde19..68ca0776 100644
--- a/src/async/imap/MCIMAPExpungeOperation.h
+++ b/src/async/imap/MCIMAPExpungeOperation.h
@@ -15,15 +15,11 @@ namespace mailcore {
class IMAPExpungeOperation : public IMAPOperation {
private:
- String * mFolder;
public:
IMAPExpungeOperation();
virtual ~IMAPExpungeOperation();
- virtual void setFolder(String * folder);
- virtual String * folder();
-
virtual void main();
};
}
diff --git a/src/async/imap/MCIMAPFetchContentOperation.cc b/src/async/imap/MCIMAPFetchContentOperation.cc
index ed0d1375..802b536f 100644
--- a/src/async/imap/MCIMAPFetchContentOperation.cc
+++ b/src/async/imap/MCIMAPFetchContentOperation.cc
@@ -15,7 +15,6 @@ using namespace mailcore;
IMAPFetchContentOperation::IMAPFetchContentOperation()
{
- mFolder = NULL;
mUid = 0;
mPartID = NULL;
mEncoding = Encoding7Bit;
@@ -24,21 +23,10 @@ IMAPFetchContentOperation::IMAPFetchContentOperation()
IMAPFetchContentOperation::~IMAPFetchContentOperation()
{
- MC_SAFE_RELEASE(mFolder);
MC_SAFE_RELEASE(mPartID);
MC_SAFE_RELEASE(mData);
}
-void IMAPFetchContentOperation::setFolder(String * folder)
-{
- MC_SAFE_REPLACE_COPY(String, mFolder, folder);
-}
-
-String * IMAPFetchContentOperation::folder()
-{
- return mFolder;
-}
-
void IMAPFetchContentOperation::setUid(uint32_t uid)
{
mUid = uid;
@@ -78,10 +66,10 @@ void IMAPFetchContentOperation::main()
{
ErrorCode error;
if (mPartID != NULL) {
- mData = session()->session()->fetchMessageAttachmentByUID(mFolder, mUid, mPartID, mEncoding, this, &error);
+ mData = session()->session()->fetchMessageAttachmentByUID(folder(), mUid, mPartID, mEncoding, this, &error);
}
else {
- mData = session()->session()->fetchMessageByUID(mFolder, mUid, this, &error);
+ mData = session()->session()->fetchMessageByUID(folder(), mUid, this, &error);
}
MC_SAFE_RETAIN(mData);
setError(error);
diff --git a/src/async/imap/MCIMAPFetchContentOperation.h b/src/async/imap/MCIMAPFetchContentOperation.h
index 732bcdf4..6c685e2b 100644
--- a/src/async/imap/MCIMAPFetchContentOperation.h
+++ b/src/async/imap/MCIMAPFetchContentOperation.h
@@ -15,7 +15,6 @@ namespace mailcore {
class IMAPFetchContentOperation : public IMAPOperation {
private:
- String * mFolder;
uint32_t mUid;
String * mPartID;
Encoding mEncoding;
@@ -25,9 +24,6 @@ namespace mailcore {
IMAPFetchContentOperation();
virtual ~IMAPFetchContentOperation();
- virtual void setFolder(String * folder);
- virtual String * folder();
-
virtual void setUid(uint32_t uid);
virtual uint32_t uid();
diff --git a/src/async/imap/MCIMAPFetchFoldersOperation.cc b/src/async/imap/MCIMAPFetchFoldersOperation.cc
index 55d3ae4e..146195b5 100644
--- a/src/async/imap/MCIMAPFetchFoldersOperation.cc
+++ b/src/async/imap/MCIMAPFetchFoldersOperation.cc
@@ -17,24 +17,13 @@ using namespace mailcore;
IMAPFetchFoldersOperation::IMAPFetchFoldersOperation()
{
- mFolder = NULL;
mFetchSubscribedEnabled = false;
mFolders = NULL;
}
IMAPFetchFoldersOperation::~IMAPFetchFoldersOperation()
{
- MC_SAFE_RELEASE(mFolder);
-}
-
-void IMAPFetchFoldersOperation::setFolder(String * folder)
-{
- MC_SAFE_REPLACE_COPY(String, mFolder, folder);
-}
-
-String * IMAPFetchFoldersOperation::folder()
-{
- return mFolder;
+ MC_SAFE_RELEASE(mFolders);
}
void IMAPFetchFoldersOperation::setFetchSubscribedEnabled(bool enabled)
diff --git a/src/async/imap/MCIMAPFetchFoldersOperation.h b/src/async/imap/MCIMAPFetchFoldersOperation.h
index 8d31e370..8eb0f798 100644
--- a/src/async/imap/MCIMAPFetchFoldersOperation.h
+++ b/src/async/imap/MCIMAPFetchFoldersOperation.h
@@ -25,9 +25,6 @@ namespace mailcore {
IMAPFetchFoldersOperation();
virtual ~IMAPFetchFoldersOperation();
- virtual void setFolder(String * folder);
- virtual String * folder();
-
virtual void setFetchSubscribedEnabled(bool enabled);
virtual bool isFetchSubscribedEnabled();
diff --git a/src/async/imap/MCIMAPFetchMessagesOperation.cc b/src/async/imap/MCIMAPFetchMessagesOperation.cc
index 3c6ba49b..af1eec30 100644
--- a/src/async/imap/MCIMAPFetchMessagesOperation.cc
+++ b/src/async/imap/MCIMAPFetchMessagesOperation.cc
@@ -15,7 +15,6 @@ using namespace mailcore;
IMAPFetchMessagesOperation::IMAPFetchMessagesOperation()
{
- mFolder = NULL;
mFetchByUidEnabled = false;
mFirst = 0;
mLast = 0;
@@ -26,22 +25,11 @@ IMAPFetchMessagesOperation::IMAPFetchMessagesOperation()
IMAPFetchMessagesOperation::~IMAPFetchMessagesOperation()
{
- MC_SAFE_RELEASE(mFolder);
MC_SAFE_RELEASE(mNumbers);
MC_SAFE_RELEASE(mUids);
MC_SAFE_RELEASE(mMessages);
}
-void IMAPFetchMessagesOperation::setFolder(String * folder)
-{
- MC_SAFE_REPLACE_COPY(String, mFolder, folder);
-}
-
-String * IMAPFetchMessagesOperation::folder()
-{
- return mFolder;
-}
-
void IMAPFetchMessagesOperation::setFetchByUidEnabled(bool enabled)
{
mFetchByUidEnabled = enabled;
@@ -112,18 +100,18 @@ void IMAPFetchMessagesOperation::main()
ErrorCode error;
if (mFetchByUidEnabled) {
if (mUids != NULL) {
- mMessages = session()->session()->fetchMessagesByUID(mFolder, mKind, mUids, this, &error);
+ mMessages = session()->session()->fetchMessagesByUID(folder(), mKind, mUids, this, &error);
}
else {
- mMessages = session()->session()->fetchMessagesByUID(mFolder, mKind, mFirst, mLast, this, &error);
+ mMessages = session()->session()->fetchMessagesByUID(folder(), mKind, mFirst, mLast, this, &error);
}
}
else {
if (mNumbers != NULL) {
- mMessages = session()->session()->fetchMessagesByNumber(mFolder, mKind, mNumbers, this, &error);
+ mMessages = session()->session()->fetchMessagesByNumber(folder(), mKind, mNumbers, this, &error);
}
else {
- mMessages = session()->session()->fetchMessagesByNumber(mFolder, mKind, mFirst, mLast, this, &error);
+ mMessages = session()->session()->fetchMessagesByNumber(folder(), mKind, mFirst, mLast, this, &error);
}
}
MC_SAFE_RETAIN(mMessages);
diff --git a/src/async/imap/MCIMAPFetchMessagesOperation.h b/src/async/imap/MCIMAPFetchMessagesOperation.h
index 03abbf2a..2e955655 100644
--- a/src/async/imap/MCIMAPFetchMessagesOperation.h
+++ b/src/async/imap/MCIMAPFetchMessagesOperation.h
@@ -15,7 +15,6 @@ namespace mailcore {
class IMAPFetchMessagesOperation : public IMAPOperation {
private:
- String * mFolder;
bool mFetchByUidEnabled;
uint32_t mFirst;
uint32_t mLast;
@@ -28,9 +27,6 @@ namespace mailcore {
IMAPFetchMessagesOperation();
virtual ~IMAPFetchMessagesOperation();
- virtual void setFolder(String * folder);
- virtual String * folder();
-
virtual void setFetchByUidEnabled(bool enabled);
virtual bool isFetchByUidEnabled();
diff --git a/src/async/imap/MCIMAPFolderInfoOperation.cc b/src/async/imap/MCIMAPFolderInfoOperation.cc
index 452b9551..18a6f3ef 100644
--- a/src/async/imap/MCIMAPFolderInfoOperation.cc
+++ b/src/async/imap/MCIMAPFolderInfoOperation.cc
@@ -15,7 +15,6 @@ using namespace mailcore;
IMAPFolderInfoOperation::IMAPFolderInfoOperation()
{
- mFolder = NULL;
mUidNext = 0;
mUidValidity = 0;
mMessageCount = 0;
@@ -23,17 +22,6 @@ IMAPFolderInfoOperation::IMAPFolderInfoOperation()
IMAPFolderInfoOperation::~IMAPFolderInfoOperation()
{
- MC_SAFE_RELEASE(mFolder);
-}
-
-void IMAPFolderInfoOperation::setFolder(String * folder)
-{
- MC_SAFE_REPLACE_COPY(String, mFolder, folder);
-}
-
-String * IMAPFolderInfoOperation::folder()
-{
- return mFolder;
}
uint32_t IMAPFolderInfoOperation::uidNext()
@@ -54,8 +42,10 @@ int IMAPFolderInfoOperation::messageCount()
void IMAPFolderInfoOperation::main()
{
ErrorCode error;
- session()->session()->select(mFolder, &error);
-#warning set results
+ session()->session()->select(folder(), &error);
+ mUidNext = session()->session()->uidNext();
+ mUidValidity = session()->session()->uidValidity();
+ mMessageCount = session()->session()->lastFolderMessageCount();
setError(error);
}
diff --git a/src/async/imap/MCIMAPFolderInfoOperation.h b/src/async/imap/MCIMAPFolderInfoOperation.h
index 0f6e1224..78aa4db0 100644
--- a/src/async/imap/MCIMAPFolderInfoOperation.h
+++ b/src/async/imap/MCIMAPFolderInfoOperation.h
@@ -15,7 +15,6 @@ namespace mailcore {
class IMAPFolderInfoOperation : public IMAPOperation {
private:
- String * mFolder;
uint32_t mUidNext;
uint32_t mUidValidity;
int mMessageCount;
@@ -24,9 +23,6 @@ namespace mailcore {
IMAPFolderInfoOperation();
virtual ~IMAPFolderInfoOperation();
- virtual void setFolder(String * folder);
- virtual String * folder();
-
virtual uint32_t uidNext();
virtual uint32_t uidValidity();
virtual int messageCount();
diff --git a/src/async/imap/MCIMAPIdleOperation.cc b/src/async/imap/MCIMAPIdleOperation.cc
index 16c9461a..41a06466 100644
--- a/src/async/imap/MCIMAPIdleOperation.cc
+++ b/src/async/imap/MCIMAPIdleOperation.cc
@@ -15,23 +15,11 @@ using namespace mailcore;
IMAPIdleOperation::IMAPIdleOperation()
{
- mFolder = NULL;
mLastKnownUid = 0;
}
IMAPIdleOperation::~IMAPIdleOperation()
{
- MC_SAFE_RELEASE(mFolder);
-}
-
-void IMAPIdleOperation::setFolder(String * folder)
-{
- MC_SAFE_REPLACE_COPY(String, mFolder, folder);
-}
-
-String * IMAPIdleOperation::folder()
-{
- return mFolder;
}
void IMAPIdleOperation::setLastKnownUID(uint32_t uid)
@@ -59,7 +47,7 @@ void IMAPIdleOperation::main()
performMethodOnMainThread((Object::Method) &IMAPIdleOperation::prepare, NULL);
ErrorCode error;
- session()->session()->idle(mFolder, mLastKnownUid, &error);
+ session()->session()->idle(folder(), mLastKnownUid, &error);
setError(error);
performMethodOnMainThread((Object::Method) &IMAPIdleOperation::unprepare, NULL);
diff --git a/src/async/imap/MCIMAPIdleOperation.h b/src/async/imap/MCIMAPIdleOperation.h
index b369cda2..bbd72285 100644
--- a/src/async/imap/MCIMAPIdleOperation.h
+++ b/src/async/imap/MCIMAPIdleOperation.h
@@ -15,7 +15,6 @@ namespace mailcore {
class IMAPIdleOperation : public IMAPOperation {
private:
- String * mFolder;
uint32_t mLastKnownUid;
void prepare();
void unprepare();
@@ -24,9 +23,6 @@ namespace mailcore {
IMAPIdleOperation();
virtual ~IMAPIdleOperation();
- virtual void setFolder(String * folder);
- virtual String * folder();
-
virtual void setLastKnownUID(uint32_t uid);
virtual uint32_t lastKnownUID();
diff --git a/src/async/imap/MCIMAPOperation.cc b/src/async/imap/MCIMAPOperation.cc
index 8dfb7a1a..f9187ee8 100644
--- a/src/async/imap/MCIMAPOperation.cc
+++ b/src/async/imap/MCIMAPOperation.cc
@@ -21,10 +21,12 @@ IMAPOperation::IMAPOperation()
mSession = NULL;
mImapCallback = NULL;
mError = ErrorNone;
+ mFolder = NULL;
}
IMAPOperation::~IMAPOperation()
{
+ MC_SAFE_RELEASE(mFolder);
MC_SAFE_RELEASE(mSession);
}
@@ -38,6 +40,16 @@ IMAPAsyncSession * IMAPOperation::session()
return mSession;
}
+void IMAPOperation::setFolder(String * folder)
+{
+ MC_SAFE_REPLACE_COPY(String, mFolder, folder);
+}
+
+String * IMAPOperation::folder()
+{
+ return mFolder;
+}
+
void IMAPOperation::setImapCallback(IMAPOperationCallback * callback)
{
mImapCallback = callback;
diff --git a/src/async/imap/MCIMAPOperation.h b/src/async/imap/MCIMAPOperation.h
index 3d9d06eb..f3ab9c7e 100644
--- a/src/async/imap/MCIMAPOperation.h
+++ b/src/async/imap/MCIMAPOperation.h
@@ -19,6 +19,7 @@ namespace mailcore {
class IMAPOperation : public Operation, public IMAPProgressCallback {
IMAPAsyncSession * mSession;
+ String * mFolder;
IMAPOperationCallback * mImapCallback;
ErrorCode mError;
private:
@@ -34,6 +35,9 @@ namespace mailcore {
virtual void setSession(IMAPAsyncSession * session);
virtual IMAPAsyncSession * session();
+ virtual void setFolder(String * folder);
+ virtual String * folder();
+
virtual void setImapCallback(IMAPOperationCallback * callback);
virtual IMAPOperationCallback * imapCallback();
diff --git a/src/async/imap/MCIMAPRenameFolderOperation.cc b/src/async/imap/MCIMAPRenameFolderOperation.cc
index 891cd571..e247aee7 100644
--- a/src/async/imap/MCIMAPRenameFolderOperation.cc
+++ b/src/async/imap/MCIMAPRenameFolderOperation.cc
@@ -15,26 +15,14 @@ using namespace mailcore;
IMAPRenameFolderOperation::IMAPRenameFolderOperation()
{
- mFolder = NULL;
mOtherName = NULL;
}
IMAPRenameFolderOperation::~IMAPRenameFolderOperation()
{
- MC_SAFE_RELEASE(mFolder);
MC_SAFE_RELEASE(mOtherName);
}
-void IMAPRenameFolderOperation::setFolder(String * folder)
-{
- MC_SAFE_REPLACE_COPY(String, mFolder, folder);
-}
-
-String * IMAPRenameFolderOperation::folder()
-{
- return mFolder;
-}
-
void IMAPRenameFolderOperation::setOtherName(String * otherName)
{
MC_SAFE_REPLACE_COPY(String, mOtherName, otherName);
@@ -48,7 +36,7 @@ String * IMAPRenameFolderOperation::otherName()
void IMAPRenameFolderOperation::main()
{
ErrorCode error;
- session()->session()->renameFolder(mFolder, mOtherName, &error);
+ session()->session()->renameFolder(folder(), mOtherName, &error);
setError(error);
}
diff --git a/src/async/imap/MCIMAPRenameFolderOperation.h b/src/async/imap/MCIMAPRenameFolderOperation.h
index ddd07432..e1bc5967 100644
--- a/src/async/imap/MCIMAPRenameFolderOperation.h
+++ b/src/async/imap/MCIMAPRenameFolderOperation.h
@@ -15,16 +15,12 @@ namespace mailcore {
class IMAPRenameFolderOperation : public IMAPOperation {
private:
- String * mFolder;
String * mOtherName;
public:
IMAPRenameFolderOperation();
~IMAPRenameFolderOperation();
- virtual void setFolder(String * folder);
- virtual String * folder();
-
virtual void setOtherName(String * otherName);
virtual String * otherName();
diff --git a/src/async/imap/MCIMAPSearchOperation.cc b/src/async/imap/MCIMAPSearchOperation.cc
index 4a4cec67..8be80f19 100644
--- a/src/async/imap/MCIMAPSearchOperation.cc
+++ b/src/async/imap/MCIMAPSearchOperation.cc
@@ -16,7 +16,6 @@ using namespace mailcore;
IMAPSearchOperation::IMAPSearchOperation()
{
- mFolder = NULL;
mKind = IMAPSearchKindNone;
mSearchString = NULL;
mExpression = NULL;
@@ -25,22 +24,11 @@ IMAPSearchOperation::IMAPSearchOperation()
IMAPSearchOperation::~IMAPSearchOperation()
{
- MC_SAFE_RELEASE(mFolder);
MC_SAFE_RELEASE(mSearchString);
MC_SAFE_RELEASE(mExpression);
MC_SAFE_RELEASE(mUids);
}
-void IMAPSearchOperation::setFolder(String * folder)
-{
- MC_SAFE_REPLACE_COPY(String, mFolder, folder);
-}
-
-String * IMAPSearchOperation::folder()
-{
- return mFolder;
-}
-
void IMAPSearchOperation::setSearchKind(IMAPSearchKind kind)
{
mKind = kind;
@@ -80,10 +68,10 @@ void IMAPSearchOperation::main()
{
ErrorCode error;
if (mExpression != NULL) {
- mUids = session()->session()->search(mFolder, mExpression, &error);
+ mUids = session()->session()->search(folder(), mExpression, &error);
}
else {
- mUids = session()->session()->search(mFolder, mKind, mSearchString, &error);
+ mUids = session()->session()->search(folder(), mKind, mSearchString, &error);
}
MC_SAFE_RETAIN(mUids);
setError(error);
diff --git a/src/async/imap/MCIMAPSearchOperation.h b/src/async/imap/MCIMAPSearchOperation.h
index b039bd24..ecbc72c5 100644
--- a/src/async/imap/MCIMAPSearchOperation.h
+++ b/src/async/imap/MCIMAPSearchOperation.h
@@ -18,7 +18,6 @@ namespace mailcore {
class IMAPSearchOperation : public IMAPOperation {
private:
- String * mFolder;
IMAPSearchKind mKind;
String * mSearchString;
IMAPSearchExpression * mExpression;
@@ -28,9 +27,6 @@ namespace mailcore {
IMAPSearchOperation();
virtual ~IMAPSearchOperation();
- virtual void setFolder(String * folder);
- virtual String * folder();
-
virtual void setSearchKind(IMAPSearchKind kind);
virtual IMAPSearchKind searchKind();
diff --git a/src/async/imap/MCIMAPStoreFlagsOperation.cc b/src/async/imap/MCIMAPStoreFlagsOperation.cc
index 82123631..79ab7100 100644
--- a/src/async/imap/MCIMAPStoreFlagsOperation.cc
+++ b/src/async/imap/MCIMAPStoreFlagsOperation.cc
@@ -15,7 +15,6 @@ using namespace mailcore;
IMAPStoreFlagsOperation::IMAPStoreFlagsOperation()
{
- mFolder = NULL;
mUids = NULL;
mKind = IMAPStoreFlagsRequestKindAdd;
mFlags = MessageFlagNone;
@@ -23,20 +22,9 @@ IMAPStoreFlagsOperation::IMAPStoreFlagsOperation()
IMAPStoreFlagsOperation::~IMAPStoreFlagsOperation()
{
- MC_SAFE_RELEASE(mFolder);
MC_SAFE_RELEASE(mUids);
}
-void IMAPStoreFlagsOperation::setFolder(String * folder)
-{
- MC_SAFE_REPLACE_COPY(String, mFolder, folder);
-}
-
-String * IMAPStoreFlagsOperation::folder()
-{
- return mFolder;
-}
-
void IMAPStoreFlagsOperation::setUids(Array * uids)
{
MC_SAFE_REPLACE_RETAIN(Array, mUids, uids);
@@ -70,6 +58,6 @@ MessageFlag IMAPStoreFlagsOperation::flags()
void IMAPStoreFlagsOperation::main()
{
ErrorCode error;
- session()->session()->storeFlags(mFolder, mUids, mKind, mFlags, &error);
+ session()->session()->storeFlags(folder(), mUids, mKind, mFlags, &error);
setError(error);
}
diff --git a/src/async/imap/MCIMAPStoreFlagsOperation.h b/src/async/imap/MCIMAPStoreFlagsOperation.h
index b087db9e..232a5a02 100644
--- a/src/async/imap/MCIMAPStoreFlagsOperation.h
+++ b/src/async/imap/MCIMAPStoreFlagsOperation.h
@@ -15,7 +15,6 @@ namespace mailcore {
class IMAPStoreFlagsOperation : public IMAPOperation {
private:
- String * mFolder;
Array * mUids;
IMAPStoreFlagsRequestKind mKind;
MessageFlag mFlags;
@@ -24,9 +23,6 @@ namespace mailcore {
IMAPStoreFlagsOperation();
virtual ~IMAPStoreFlagsOperation();
- virtual void setFolder(String * folder);
- virtual String * folder();
-
virtual void setUids(Array * uids);
virtual Array * uids();
diff --git a/src/async/imap/MCIMAPStoreLabelsOperation.cc b/src/async/imap/MCIMAPStoreLabelsOperation.cc
index dcafc175..4085a7b1 100644
--- a/src/async/imap/MCIMAPStoreLabelsOperation.cc
+++ b/src/async/imap/MCIMAPStoreLabelsOperation.cc
@@ -15,7 +15,6 @@ using namespace mailcore;
IMAPStoreLabelsOperation::IMAPStoreLabelsOperation()
{
- mFolder = NULL;
mUids = NULL;
mKind = IMAPStoreFlagsRequestKindAdd;
mLabels = NULL;
@@ -23,21 +22,10 @@ IMAPStoreLabelsOperation::IMAPStoreLabelsOperation()
IMAPStoreLabelsOperation::~IMAPStoreLabelsOperation()
{
- MC_SAFE_RELEASE(mFolder);
MC_SAFE_RELEASE(mUids);
MC_SAFE_RELEASE(mLabels);
}
-void IMAPStoreLabelsOperation::setFolder(String * folder)
-{
- MC_SAFE_REPLACE_COPY(String, mFolder, folder);
-}
-
-String * IMAPStoreLabelsOperation::folder()
-{
- return mFolder;
-}
-
void IMAPStoreLabelsOperation::setUids(Array * uids)
{
MC_SAFE_REPLACE_RETAIN(Array, mUids, uids);
@@ -71,7 +59,7 @@ Array * IMAPStoreLabelsOperation::labels()
void IMAPStoreLabelsOperation::main()
{
ErrorCode error;
- session()->session()->storeLabels(mFolder, mUids, mKind, mLabels, &error);
+ session()->session()->storeLabels(folder(), mUids, mKind, mLabels, &error);
setError(error);
}
diff --git a/src/async/imap/MCIMAPStoreLabelsOperation.h b/src/async/imap/MCIMAPStoreLabelsOperation.h
index fcfc7f95..b87b650a 100644
--- a/src/async/imap/MCIMAPStoreLabelsOperation.h
+++ b/src/async/imap/MCIMAPStoreLabelsOperation.h
@@ -15,7 +15,6 @@ namespace mailcore {
class IMAPStoreLabelsOperation : public IMAPOperation {
private:
- String * mFolder;
Array * mUids;
IMAPStoreFlagsRequestKind mKind;
Array * mLabels;
@@ -24,9 +23,6 @@ namespace mailcore {
IMAPStoreLabelsOperation();
virtual ~IMAPStoreLabelsOperation();
- virtual void setFolder(String * folder);
- virtual String * folder();
-
virtual void setUids(Array * uids);
virtual Array * uids();
diff --git a/src/async/imap/MCIMAPSubscribeFolderOperation.cc b/src/async/imap/MCIMAPSubscribeFolderOperation.cc
index d7449fba..1c461b63 100644
--- a/src/async/imap/MCIMAPSubscribeFolderOperation.cc
+++ b/src/async/imap/MCIMAPSubscribeFolderOperation.cc
@@ -15,23 +15,11 @@ using namespace mailcore;
IMAPSubscribeFolderOperation::IMAPSubscribeFolderOperation()
{
- mFolder = NULL;
mUnsubscribeEnabled = false;
}
IMAPSubscribeFolderOperation::~IMAPSubscribeFolderOperation()
{
- MC_SAFE_RELEASE(mFolder);
-}
-
-void IMAPSubscribeFolderOperation::setFolder(String * folder)
-{
- MC_SAFE_REPLACE_COPY(String, mFolder, folder);
-}
-
-String * IMAPSubscribeFolderOperation::folder()
-{
- return mFolder;
}
void IMAPSubscribeFolderOperation::setUnsubscribeEnabled(bool enabled)
@@ -48,10 +36,10 @@ void IMAPSubscribeFolderOperation::main()
{
ErrorCode error;
if (mUnsubscribeEnabled) {
- session()->session()->unsubscribeFolder(mFolder, &error);
+ session()->session()->unsubscribeFolder(folder(), &error);
}
else {
- session()->session()->subscribeFolder(mFolder, &error);
+ session()->session()->subscribeFolder(folder(), &error);
}
setError(error);
}
diff --git a/src/async/imap/MCIMAPSubscribeFolderOperation.h b/src/async/imap/MCIMAPSubscribeFolderOperation.h
index 92b97d15..cc335362 100644
--- a/src/async/imap/MCIMAPSubscribeFolderOperation.h
+++ b/src/async/imap/MCIMAPSubscribeFolderOperation.h
@@ -15,16 +15,12 @@ namespace mailcore {
class IMAPSubscribeFolderOperation : public IMAPOperation {
private:
- String * mFolder;
bool mUnsubscribeEnabled;
public:
IMAPSubscribeFolderOperation();
virtual ~IMAPSubscribeFolderOperation();
- virtual void setFolder(String * folder);
- virtual String * folder();
-
virtual void setUnsubscribeEnabled(bool enabled);
virtual bool isUnsubscribeEnabled();
diff --git a/src/async/pop/MCPOPAsyncSession.cc b/src/async/pop/MCPOPAsyncSession.cc
index c09eb1d7..624fa6c2 100644
--- a/src/async/pop/MCPOPAsyncSession.cc
+++ b/src/async/pop/MCPOPAsyncSession.cc
@@ -150,6 +150,6 @@ POPSession * POPAsyncSession::session()
void POPAsyncSession::runOperation(POPOperation * operation)
{
- // TODO: disconnect after delay
+#warning disconnect after delay
mQueue->addOperation(operation);
}
diff --git a/src/async/smtp/MCSMTPAsyncSession.cc b/src/async/smtp/MCSMTPAsyncSession.cc
index 95aa0907..95101a50 100644
--- a/src/async/smtp/MCSMTPAsyncSession.cc
+++ b/src/async/smtp/MCSMTPAsyncSession.cc
@@ -113,7 +113,7 @@ bool SMTPAsyncSession::useHeloIPEnabled()
void SMTPAsyncSession::runOperation(SMTPOperation * operation)
{
- // TODO: disconnect after delay
+#warning disconnect after delay
mQueue->addOperation(operation);
}
diff --git a/src/core/basetypes/MCOperationQueue.cc b/src/core/basetypes/MCOperationQueue.cc
index aa2e0193..52c58385 100644
--- a/src/core/basetypes/MCOperationQueue.cc
+++ b/src/core/basetypes/MCOperationQueue.cc
@@ -93,21 +93,22 @@ void OperationQueue::runOperations()
op->main();
- if (op->callback() != NULL) {
- performMethodOnMainThread((Object::Method) &OperationQueue::callbackOnMainThread, op, true);
- }
+ op->retain()->autorelease();
pthread_mutex_lock(&mLock);
mOperations->removeObjectAtIndex(0);
if (mOperations->count() == 0) {
if (mWaiting) {
- //sem_post(&mWaitingFinishedSem);
mailsem_up(mWaitingFinishedSem);
}
needsCheckRunning = true;
}
pthread_mutex_unlock(&mLock);
+ if (op->callback() != NULL) {
+ performMethodOnMainThread((Object::Method) &OperationQueue::callbackOnMainThread, op, true);
+ }
+
if (needsCheckRunning) {
retain(); // (1)
performMethodOnMainThread((Object::Method) &OperationQueue::checkRunningOnMainThread, this);
@@ -165,6 +166,17 @@ void OperationQueue::startThread()
mailsem_down(mStartSem);
}
+unsigned int OperationQueue::count()
+{
+ unsigned int count;
+
+ pthread_mutex_lock(&mLock);
+ count = mOperations->count();
+ pthread_mutex_unlock(&mLock);
+
+ return count;
+}
+
#if 0
void OperationQueue::waitUntilAllOperationsAreFinished()
{
diff --git a/src/core/basetypes/MCOperationQueue.h b/src/core/basetypes/MCOperationQueue.h
index b858aebc..c584f33a 100644
--- a/src/core/basetypes/MCOperationQueue.h
+++ b/src/core/basetypes/MCOperationQueue.h
@@ -37,6 +37,8 @@ namespace mailcore {
virtual void addOperation(Operation * op);
+ virtual unsigned int count();
+
//virtual void waitUntilAllOperationsAreFinished();
};
diff --git a/src/core/imap/MCIMAPSession.cc b/src/core/imap/MCIMAPSession.cc
index 4e9dc3b8..634c1ca6 100644
--- a/src/core/imap/MCIMAPSession.cc
+++ b/src/core/imap/MCIMAPSession.cc
@@ -432,7 +432,7 @@ static bool hasError(int errorCode)
bool IMAPSession::checkCertificate()
{
- // XXX
+#warning check certificate
return true;
}
@@ -2564,3 +2564,18 @@ void IMAPSession::storeLabels(String * folder, Array * uids, IMAPStoreFlagsReque
mailimap_set_free(imap_set);
* pError = ErrorNone;
}
+
+uint32_t IMAPSession::uidValidity()
+{
+ return mUIDValidity;
+}
+
+uint32_t IMAPSession::uidNext()
+{
+ return mUIDNext;
+}
+
+unsigned int IMAPSession::lastFolderMessageCount()
+{
+ return mFolderMsgCount;
+}
diff --git a/src/core/imap/MCIMAPSession.h b/src/core/imap/MCIMAPSession.h
index 5581aca0..798e7c01 100644
--- a/src/core/imap/MCIMAPSession.h
+++ b/src/core/imap/MCIMAPSession.h
@@ -29,13 +29,13 @@ namespace mailcore {
bool mVoIPEnabled;
char mDelimiter;
IMAPNamespace * mDefaultNamespace;
+ time_t mTimeout;
bool mBodyProgressEnabled;
bool mIdleEnabled;
bool mXListEnabled;
String * mWelcomeString;
bool mNeedsMboxMailWorkaround;
- time_t mTimeout;
uint32_t mUIDValidity;
uint32_t mUIDNext;
unsigned int mFolderMsgCount;
@@ -156,6 +156,10 @@ namespace mailcore {
virtual void login(ErrorCode * pError);
virtual HashMap * identity(String * vendor, String * name, String * version, ErrorCode * pError);
+
+ virtual uint32_t uidValidity();
+ virtual uint32_t uidNext();
+ virtual unsigned int lastFolderMessageCount();
};
}
diff --git a/src/core/pop/MCPOPSession.cc b/src/core/pop/MCPOPSession.cc
index eea5af90..0ae28a9d 100644
--- a/src/core/pop/MCPOPSession.cc
+++ b/src/core/pop/MCPOPSession.cc
@@ -133,7 +133,7 @@ bool POPSession::isCheckCertificateEnabled()
bool POPSession::checkCertificate()
{
- // XXX
+#warning check certificate
return true;
}
diff --git a/src/core/rfc822/MCAttachment.cc b/src/core/rfc822/MCAttachment.cc
index 856a756f..e41339a8 100644
--- a/src/core/rfc822/MCAttachment.cc
+++ b/src/core/rfc822/MCAttachment.cc
@@ -12,7 +12,7 @@ using namespace mailcore;
String * Attachment::mimeTypeForFilename(String * filename)
{
- // TODO: read from a file
+#warning read from a file
String * ext;
ext = filename->pathExtension()->lowercaseString();
diff --git a/src/core/smtp/MCSMTPSession.cc b/src/core/smtp/MCSMTPSession.cc
index 6d723cb4..12066146 100644
--- a/src/core/smtp/MCSMTPSession.cc
+++ b/src/core/smtp/MCSMTPSession.cc
@@ -140,7 +140,7 @@ bool SMTPSession::isCheckCertificateEnabled()
bool SMTPSession::checkCertificate()
{
- // XXX
+#warning check certificate
return true;
}
diff --git a/tests/main.mm b/tests/main.mm
index 622c35b1..93bb81d5 100644
--- a/tests/main.mm
+++ b/tests/main.mm
@@ -210,10 +210,10 @@ class TestIMAPCallback : public mailcore::Object, public mailcore::OperationCall
static void testAsyncIMAP()
{
- mailcore::IMAPAsyncSession * session;
+ mailcore::IMAPAccount * session;
TestIMAPCallback * callback = new TestIMAPCallback();
- session = new mailcore::IMAPAsyncSession();
+ session = new mailcore::IMAPAccount();
session->setHostname(MCSTR("imap.gmail.com"));
session->setPort(993);
session->setUsername(email);
@@ -284,8 +284,8 @@ void testAll()
//testIMAP();
//testPOP();
//testAsyncSMTP(data);
- //testAsyncIMAP();
- testAsyncPOP();
+ testAsyncIMAP();
+ //testAsyncPOP();
MCLog("pool release");
pool->release();