aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/async
diff options
context:
space:
mode:
Diffstat (limited to 'src/async')
-rw-r--r--src/async/MCAsync.h2
-rw-r--r--src/async/imap/MCIMAPCopyMessagesOperation.cc4
-rw-r--r--src/async/imap/MCIMAPFetchMessagesOperation.cc8
-rw-r--r--src/async/imap/MCIMAPFetchNamespaceOperation.cc2
-rw-r--r--src/async/imap/MCIMAPFolderInfoOperation.cc1
-rw-r--r--src/async/imap/MCIMAPIdentityOperation.cc1
-rw-r--r--src/async/imap/MCIMAPSearchOperation.cc12
-rw-r--r--src/async/imap/MCIMAPSearchOperation.h3
-rw-r--r--src/async/pop/MCAsyncPOP.h19
-rw-r--r--src/async/pop/MCPOPAsyncSession.cc155
-rw-r--r--src/async/pop/MCPOPAsyncSession.h70
-rw-r--r--src/async/pop/MCPOPDeleteMessagesOperation.cc51
-rw-r--r--src/async/pop/MCPOPDeleteMessagesOperation.h33
-rw-r--r--src/async/pop/MCPOPFetchHeaderOperation.cc49
-rw-r--r--src/async/pop/MCPOPFetchHeaderOperation.h36
-rw-r--r--src/async/pop/MCPOPFetchMessageOperation.cc49
-rw-r--r--src/async/pop/MCPOPFetchMessageOperation.h33
-rw-r--r--src/async/pop/MCPOPFetchMessagesOperation.cc37
-rw-r--r--src/async/pop/MCPOPFetchMessagesOperation.h27
-rw-r--r--src/async/pop/MCPOPOperation.cc86
-rw-r--r--src/async/pop/MCPOPOperation.h46
-rw-r--r--src/async/pop/MCPOPOperationCallback.h23
22 files changed, 734 insertions, 13 deletions
diff --git a/src/async/MCAsync.h b/src/async/MCAsync.h
index 4fa1428c..245bf15b 100644
--- a/src/async/MCAsync.h
+++ b/src/async/MCAsync.h
@@ -10,5 +10,7 @@
#define mailcore2_MCAsync_h
#include <mailcore/MCAsyncSMTP.h>
+#include <mailcore/MCAsyncIMAP.h>
+#include <mailcore/MCAsyncPOP.h>
#endif
diff --git a/src/async/imap/MCIMAPCopyMessagesOperation.cc b/src/async/imap/MCIMAPCopyMessagesOperation.cc
index b7321d97..b207c71e 100644
--- a/src/async/imap/MCIMAPCopyMessagesOperation.cc
+++ b/src/async/imap/MCIMAPCopyMessagesOperation.cc
@@ -68,8 +68,6 @@ void IMAPCopyMessagesOperation::main()
{
ErrorCode error;
session()->session()->copyMessages(mFolder, mUids, mDestFolder, &mDestUids, &error);
- if (mDestUids != NULL) {
- mDestUids->retain();
- }
+ MC_SAFE_RETAIN(mDestUids);
setError(error);
}
diff --git a/src/async/imap/MCIMAPFetchMessagesOperation.cc b/src/async/imap/MCIMAPFetchMessagesOperation.cc
index c08d1c52..3c6ba49b 100644
--- a/src/async/imap/MCIMAPFetchMessagesOperation.cc
+++ b/src/async/imap/MCIMAPFetchMessagesOperation.cc
@@ -110,28 +110,22 @@ Array * IMAPFetchMessagesOperation::messages()
void IMAPFetchMessagesOperation::main()
{
ErrorCode error;
- MCLog("1");
if (mFetchByUidEnabled) {
- MCLog("2");
if (mUids != NULL) {
- MCLog("3");
mMessages = session()->session()->fetchMessagesByUID(mFolder, mKind, mUids, this, &error);
}
else {
- MCLog("4");
mMessages = session()->session()->fetchMessagesByUID(mFolder, mKind, mFirst, mLast, this, &error);
}
}
else {
- MCLog("5");
if (mNumbers != NULL) {
- MCLog("6");
mMessages = session()->session()->fetchMessagesByNumber(mFolder, mKind, mNumbers, this, &error);
}
else {
- MCLog("7");
mMessages = session()->session()->fetchMessagesByNumber(mFolder, mKind, mFirst, mLast, this, &error);
}
}
+ MC_SAFE_RETAIN(mMessages);
setError(error);
}
diff --git a/src/async/imap/MCIMAPFetchNamespaceOperation.cc b/src/async/imap/MCIMAPFetchNamespaceOperation.cc
index 5aea5237..ecd2af63 100644
--- a/src/async/imap/MCIMAPFetchNamespaceOperation.cc
+++ b/src/async/imap/MCIMAPFetchNamespaceOperation.cc
@@ -28,6 +28,6 @@ void IMAPFetchNamespaceOperation::main()
ErrorCode error;
mNamespaces = session()->session()->fetchNamespace(&error);
setError(error);
- mNamespaces->retain();
+ MC_SAFE_RETAIN(mNamespaces);
}
diff --git a/src/async/imap/MCIMAPFolderInfoOperation.cc b/src/async/imap/MCIMAPFolderInfoOperation.cc
index 3f2970e3..452b9551 100644
--- a/src/async/imap/MCIMAPFolderInfoOperation.cc
+++ b/src/async/imap/MCIMAPFolderInfoOperation.cc
@@ -55,6 +55,7 @@ void IMAPFolderInfoOperation::main()
{
ErrorCode error;
session()->session()->select(mFolder, &error);
+#warning set results
setError(error);
}
diff --git a/src/async/imap/MCIMAPIdentityOperation.cc b/src/async/imap/MCIMAPIdentityOperation.cc
index 16ffd6a4..0996970e 100644
--- a/src/async/imap/MCIMAPIdentityOperation.cc
+++ b/src/async/imap/MCIMAPIdentityOperation.cc
@@ -68,6 +68,7 @@ void IMAPIdentityOperation::main()
{
ErrorCode error;
mServerIdentity = session()->session()->identity(mVendor, mName, mVersion, &error);
+ MC_SAFE_RETAIN(mServerIdentity);
setError(error);
}
diff --git a/src/async/imap/MCIMAPSearchOperation.cc b/src/async/imap/MCIMAPSearchOperation.cc
index 395d3924..4a4cec67 100644
--- a/src/async/imap/MCIMAPSearchOperation.cc
+++ b/src/async/imap/MCIMAPSearchOperation.cc
@@ -20,6 +20,7 @@ IMAPSearchOperation::IMAPSearchOperation()
mKind = IMAPSearchKindNone;
mSearchString = NULL;
mExpression = NULL;
+ mUids = NULL;
}
IMAPSearchOperation::~IMAPSearchOperation()
@@ -27,6 +28,7 @@ IMAPSearchOperation::~IMAPSearchOperation()
MC_SAFE_RELEASE(mFolder);
MC_SAFE_RELEASE(mSearchString);
MC_SAFE_RELEASE(mExpression);
+ MC_SAFE_RELEASE(mUids);
}
void IMAPSearchOperation::setFolder(String * folder)
@@ -69,15 +71,21 @@ IMAPSearchExpression * IMAPSearchOperation::searchExpression()
return mExpression;
}
+Array * IMAPSearchOperation::uids()
+{
+ return mUids;
+}
+
void IMAPSearchOperation::main()
{
ErrorCode error;
if (mExpression != NULL) {
- session()->session()->search(mFolder, mExpression, &error);
+ mUids = session()->session()->search(mFolder, mExpression, &error);
}
else {
- session()->session()->search(mFolder, mKind, mSearchString, &error);
+ mUids = session()->session()->search(mFolder, mKind, mSearchString, &error);
}
+ MC_SAFE_RETAIN(mUids);
setError(error);
}
diff --git a/src/async/imap/MCIMAPSearchOperation.h b/src/async/imap/MCIMAPSearchOperation.h
index cf93d1a9..b039bd24 100644
--- a/src/async/imap/MCIMAPSearchOperation.h
+++ b/src/async/imap/MCIMAPSearchOperation.h
@@ -22,6 +22,7 @@ namespace mailcore {
IMAPSearchKind mKind;
String * mSearchString;
IMAPSearchExpression * mExpression;
+ Array * mUids;
public:
IMAPSearchOperation();
@@ -39,6 +40,8 @@ namespace mailcore {
virtual void setSearchExpression(IMAPSearchExpression * expression);
virtual IMAPSearchExpression * searchExpression();
+ virtual Array * uids();
+
virtual void main();
};
}
diff --git a/src/async/pop/MCAsyncPOP.h b/src/async/pop/MCAsyncPOP.h
new file mode 100644
index 00000000..d41d406d
--- /dev/null
+++ b/src/async/pop/MCAsyncPOP.h
@@ -0,0 +1,19 @@
+//
+// MCAsyncPOP.h
+// mailcore2
+//
+// Created by DINH Viêt Hoà on 1/16/13.
+// Copyright (c) 2013 MailCore. All rights reserved.
+//
+
+#ifndef mailcore2_MCAsyncPOP_h
+#define mailcore2_MCAsyncPOP_h
+
+#include <mailcore/MCPOPAsyncSession.h>
+#include <mailcore/MCPOPOperation.h>
+#include <mailcore/MCPOPFetchHeaderOperation.h>
+#include <mailcore/MCPOPFetchMessageOperation.h>
+#include <mailcore/MCPOPFetchMessagesOperation.h>
+#include <mailcore/MCPOPOperationCallback.h>
+
+#endif
diff --git a/src/async/pop/MCPOPAsyncSession.cc b/src/async/pop/MCPOPAsyncSession.cc
new file mode 100644
index 00000000..c09eb1d7
--- /dev/null
+++ b/src/async/pop/MCPOPAsyncSession.cc
@@ -0,0 +1,155 @@
+//
+// MCPopAsyncSession.cpp
+// mailcore2
+//
+// Created by DINH Viêt Hoà on 1/16/13.
+// Copyright (c) 2013 MailCore. All rights reserved.
+//
+
+#include "MCPOPAsyncSession.h"
+
+#include "MCPOP.h"
+#include "MCPOPFetchHeaderOperation.h"
+#include "MCPOPFetchMessageOperation.h"
+#include "MCPOPDeleteMessagesOperation.h"
+#include "MCPOPFetchMessagesOperation.h"
+
+using namespace mailcore;
+
+POPAsyncSession::POPAsyncSession()
+{
+ mSession = new POPSession();
+ mQueue = new OperationQueue();
+}
+
+POPAsyncSession::~POPAsyncSession()
+{
+ MC_SAFE_RELEASE(mSession);
+ MC_SAFE_RELEASE(mQueue);
+}
+
+void POPAsyncSession::setHostname(String * hostname)
+{
+ mSession->setHostname(hostname);
+}
+
+String * POPAsyncSession::hostname()
+{
+ return mSession->hostname();
+}
+
+void POPAsyncSession::setPort(unsigned int port)
+{
+ mSession->setPort(port);
+}
+
+unsigned int POPAsyncSession::port()
+{
+ return mSession->port();
+}
+
+void POPAsyncSession::setUsername(String * username)
+{
+ mSession->setUsername(username);
+}
+
+String * POPAsyncSession::username()
+{
+ return mSession->username();
+}
+
+void POPAsyncSession::setPassword(String * password)
+{
+ mSession->setPassword(password);
+}
+
+String * POPAsyncSession::password()
+{
+ return mSession->password();
+}
+
+void POPAsyncSession::setAuthType(AuthType authType)
+{
+ mSession->setAuthType(authType);
+}
+
+AuthType POPAsyncSession::authType()
+{
+ return mSession->authType();
+}
+
+void POPAsyncSession::setConnectionType(ConnectionType connectionType)
+{
+ mSession->setConnectionType(connectionType);
+}
+
+ConnectionType POPAsyncSession::connectionType()
+{
+ return mSession->connectionType();
+}
+
+void POPAsyncSession::setTimeout(time_t timeout)
+{
+ mSession->setTimeout(timeout);
+}
+
+time_t POPAsyncSession::timeout()
+{
+ return mSession->timeout();
+}
+
+void POPAsyncSession::setCheckCertificateEnabled(bool enabled)
+{
+ mSession->setCheckCertificateEnabled(enabled);
+}
+
+bool POPAsyncSession::isCheckCertificateEnabled()
+{
+ return mSession->isCheckCertificateEnabled();
+}
+
+POPFetchMessagesOperation * POPAsyncSession::fetchMessagesOperation()
+{
+ POPFetchMessagesOperation * op = new POPFetchMessagesOperation();
+ op->setSession(this);
+ op->autorelease();
+ return op;
+}
+
+POPFetchHeaderOperation * POPAsyncSession::fetchHeaderOperation(unsigned int index)
+{
+ POPFetchHeaderOperation * op = new POPFetchHeaderOperation();
+ op->setSession(this);
+ op->setMessageIndex(index);
+ op->autorelease();
+ return op;
+}
+
+POPFetchMessageOperation * POPAsyncSession::fetchMessage(unsigned int index)
+{
+ POPFetchMessageOperation * op = new POPFetchMessageOperation();
+ op->setSession(this);
+ op->setMessageIndex(index);
+ op->autorelease();
+ return op;
+}
+
+POPOperation * POPAsyncSession::deleteMessages(Array * indexes)
+{
+ POPDeleteMessagesOperation * op = new POPDeleteMessagesOperation();
+ op->setSession(this);
+ op->setMessageIndexes(indexes);
+ op->autorelease();
+ return op;
+}
+
+POPSession * POPAsyncSession::session()
+{
+ return mSession;
+}
+
+void POPAsyncSession::runOperation(POPOperation * operation)
+{
+ // TODO: disconnect after delay
+ mQueue->addOperation(operation);
+}
diff --git a/src/async/pop/MCPOPAsyncSession.h b/src/async/pop/MCPOPAsyncSession.h
new file mode 100644
index 00000000..fe713c4e
--- /dev/null
+++ b/src/async/pop/MCPOPAsyncSession.h
@@ -0,0 +1,70 @@
+//
+// MCPopAsyncSession.h
+// mailcore2
+//
+// Created by DINH Viêt Hoà on 1/16/13.
+// Copyright (c) 2013 MailCore. All rights reserved.
+//
+
+#ifndef __mailcore2__MCPopAsyncSession__
+#define __mailcore2__MCPopAsyncSession__
+
+#include <mailcore/MCBaseTypes.h>
+
+namespace mailcore {
+
+ class POPOperation;
+ class POPSession;
+ class POPFetchHeaderOperation;
+ class POPFetchMessageOperation;
+ class POPDeleteMessagesOperation;
+ class POPFetchMessagesOperation;
+
+ class POPAsyncSession : public Object {
+ private:
+ POPSession * mSession;
+ OperationQueue * mQueue;
+
+ public:
+ POPAsyncSession();
+ virtual ~POPAsyncSession();
+
+ virtual void setHostname(String * hostname);
+ virtual String * hostname();
+
+ virtual void setPort(unsigned int port);
+ virtual unsigned int port();
+
+ virtual void setUsername(String * login);
+ 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 POPFetchMessagesOperation * fetchMessagesOperation();
+
+ virtual POPFetchHeaderOperation * fetchHeaderOperation(unsigned int index);
+
+ virtual POPFetchMessageOperation * fetchMessage(unsigned int index);
+
+ virtual POPOperation * deleteMessages(Array * indexes);
+
+ // private
+ virtual void runOperation(POPOperation * operation);
+ virtual POPSession * session();
+ };
+}
+
+#endif /* defined(__mailcore2__MCPopAsyncSession__) */
diff --git a/src/async/pop/MCPOPDeleteMessagesOperation.cc b/src/async/pop/MCPOPDeleteMessagesOperation.cc
new file mode 100644
index 00000000..b655ab59
--- /dev/null
+++ b/src/async/pop/MCPOPDeleteMessagesOperation.cc
@@ -0,0 +1,51 @@
+//
+// MCPOPDeleteMessagesOperation.cc
+// mailcore2
+//
+// Created by DINH Viêt Hoà on 1/16/13.
+// Copyright (c) 2013 MailCore. All rights reserved.
+//
+
+#include "MCPOPDeleteMessagesOperation.h"
+
+#include "MCPOPAsyncSession.h"
+#include "MCPOPSession.h"
+
+using namespace mailcore;
+
+POPDeleteMessagesOperation::POPDeleteMessagesOperation()
+{
+ mMessageIndexes = NULL;
+}
+
+POPDeleteMessagesOperation::~POPDeleteMessagesOperation()
+{
+ MC_SAFE_RELEASE(mMessageIndexes);
+}
+
+void POPDeleteMessagesOperation::setMessageIndexes(Array * indexes)
+{
+ MC_SAFE_REPLACE_RETAIN(Array, mMessageIndexes, indexes);
+}
+
+Array * POPDeleteMessagesOperation::messageIndexes()
+{
+ return mMessageIndexes;
+}
+
+void POPDeleteMessagesOperation::main()
+{
+ if (mMessageIndexes == NULL)
+ return;
+
+ ErrorCode error;
+ for(unsigned int i = 0 ; i < mMessageIndexes->count() ; i ++) {
+ Value * value = (Value *) mMessageIndexes->objectAtIndex(i);
+ session()->session()->deleteMessage(value->unsignedIntValue(), &error);
+ if (error != ErrorNone) {
+ setError(error);
+ return;
+ }
+ }
+}
+
diff --git a/src/async/pop/MCPOPDeleteMessagesOperation.h b/src/async/pop/MCPOPDeleteMessagesOperation.h
new file mode 100644
index 00000000..1eca422a
--- /dev/null
+++ b/src/async/pop/MCPOPDeleteMessagesOperation.h
@@ -0,0 +1,33 @@
+//
+// MCPOPDeleteMessagesOperation.h
+// mailcore2
+//
+// Created by DINH Viêt Hoà on 1/16/13.
+// Copyright (c) 2013 MailCore. All rights reserved.
+//
+
+#ifndef __mailcore2__MCPOPDeleteMessagesOperation__
+#define __mailcore2__MCPOPDeleteMessagesOperation__
+
+#include <mailcore/MCPOPOperation.h>
+
+namespace mailcore {
+
+ class POPDeleteMessagesOperation : public POPOperation {
+ private:
+ Array * mMessageIndexes;
+
+ public:
+ POPDeleteMessagesOperation();
+ virtual ~POPDeleteMessagesOperation();
+
+ virtual void setMessageIndexes(Array * indexes);
+ virtual Array * messageIndexes();
+
+ virtual void main();
+ };
+
+}
+
+
+#endif /* defined(__mailcore2__MCPOPDeleteMessagesOperation__) */
diff --git a/src/async/pop/MCPOPFetchHeaderOperation.cc b/src/async/pop/MCPOPFetchHeaderOperation.cc
new file mode 100644
index 00000000..3c6360a8
--- /dev/null
+++ b/src/async/pop/MCPOPFetchHeaderOperation.cc
@@ -0,0 +1,49 @@
+//
+// MCPOPFetchHeaderOperation.cc
+// mailcore2
+//
+// Created by DINH Viêt Hoà on 1/16/13.
+// Copyright (c) 2013 MailCore. All rights reserved.
+//
+
+#include "MCPOPFetchHeaderOperation.h"
+
+#include "MCPOPAsyncSession.h"
+#include "MCPOPSession.h"
+#include "MCMessageHeader.h"
+
+using namespace mailcore;
+
+POPFetchHeaderOperation::POPFetchHeaderOperation()
+{
+ mMessageIndex = 0;
+ mHeader = NULL;
+}
+
+POPFetchHeaderOperation::~POPFetchHeaderOperation()
+{
+ MC_SAFE_RELEASE(mHeader);
+}
+
+void POPFetchHeaderOperation::setMessageIndex(unsigned int messageIndex)
+{
+ mMessageIndex = messageIndex;
+}
+
+unsigned int POPFetchHeaderOperation::messageIndex()
+{
+ return mMessageIndex;
+}
+
+MessageHeader * POPFetchHeaderOperation::header()
+{
+ return mHeader;
+}
+
+void POPFetchHeaderOperation::main()
+{
+ ErrorCode error;
+ mHeader = session()->session()->fetchHeader(mMessageIndex, &error);
+ mHeader->retain();
+ setError(error);
+}
diff --git a/src/async/pop/MCPOPFetchHeaderOperation.h b/src/async/pop/MCPOPFetchHeaderOperation.h
new file mode 100644
index 00000000..2b48062d
--- /dev/null
+++ b/src/async/pop/MCPOPFetchHeaderOperation.h
@@ -0,0 +1,36 @@
+//
+// MCPOPFetchHeaderOperation.h
+// mailcore2
+//
+// Created by DINH Viêt Hoà on 1/16/13.
+// Copyright (c) 2013 MailCore. All rights reserved.
+//
+
+#ifndef __mailcore2__MCPOPFetchHeaderOperation__
+#define __mailcore2__MCPOPFetchHeaderOperation__
+
+#include <mailcore/MCPOPOperation.h>
+
+namespace mailcore {
+
+ class MessageHeader;
+
+ class POPFetchHeaderOperation : public POPOperation {
+ private:
+ unsigned int mMessageIndex;
+ MessageHeader * mHeader;
+
+ public:
+ POPFetchHeaderOperation();
+ virtual ~POPFetchHeaderOperation();
+
+ virtual void setMessageIndex(unsigned int messageIndex);
+ virtual unsigned int messageIndex();
+
+ virtual MessageHeader * header();
+
+ virtual void main();
+ };
+}
+
+#endif /* defined(__mailcore2__MCPOPFetchHeaderOperation__) */
diff --git a/src/async/pop/MCPOPFetchMessageOperation.cc b/src/async/pop/MCPOPFetchMessageOperation.cc
new file mode 100644
index 00000000..4f909568
--- /dev/null
+++ b/src/async/pop/MCPOPFetchMessageOperation.cc
@@ -0,0 +1,49 @@
+//
+// MCPOPFetchMessageOperation.cc
+// mailcore2
+//
+// Created by DINH Viêt Hoà on 1/16/13.
+// Copyright (c) 2013 MailCore. All rights reserved.
+//
+
+#include "MCPOPFetchMessageOperation.h"
+
+#include "MCPOPAsyncSession.h"
+#include "MCPOPSession.h"
+
+using namespace mailcore;
+
+POPFetchMessageOperation::POPFetchMessageOperation()
+{
+ mMessageIndex = 0;
+ mData = NULL;
+}
+
+POPFetchMessageOperation::~POPFetchMessageOperation()
+{
+ MC_SAFE_RELEASE(mData);
+}
+
+void POPFetchMessageOperation::setMessageIndex(unsigned int messageIndex)
+{
+ mMessageIndex = messageIndex;
+}
+
+unsigned int POPFetchMessageOperation::messageIndex()
+{
+ return mMessageIndex;
+}
+
+Data * POPFetchMessageOperation::data()
+{
+ return mData;
+}
+
+void POPFetchMessageOperation::main()
+{
+ ErrorCode error;
+ mData = session()->session()->fetchMessage(mMessageIndex, this, &error);
+ mData->retain();
+ setError(error);
+}
+
diff --git a/src/async/pop/MCPOPFetchMessageOperation.h b/src/async/pop/MCPOPFetchMessageOperation.h
new file mode 100644
index 00000000..d60841d7
--- /dev/null
+++ b/src/async/pop/MCPOPFetchMessageOperation.h
@@ -0,0 +1,33 @@
+//
+// MCPOPFetchMessageOperation.h
+// mailcore2
+//
+// Created by DINH Viêt Hoà on 1/16/13.
+// Copyright (c) 2013 MailCore. All rights reserved.
+//
+
+#ifndef __mailcore2__MCPOPFetchMessageOperation__
+#define __mailcore2__MCPOPFetchMessageOperation__
+
+#include <mailcore/MCPOPOperation.h>
+
+namespace mailcore {
+ class POPFetchMessageOperation : public POPOperation {
+ private:
+ unsigned int mMessageIndex;
+ Data * mData;
+
+ public:
+ POPFetchMessageOperation();
+ virtual ~POPFetchMessageOperation();
+
+ virtual void setMessageIndex(unsigned int messageIndex);
+ virtual unsigned int messageIndex();
+
+ virtual Data * data();
+
+ virtual void main();
+ };
+}
+
+#endif /* defined(__mailcore2__MCPOPFetchMessageOperation__) */
diff --git a/src/async/pop/MCPOPFetchMessagesOperation.cc b/src/async/pop/MCPOPFetchMessagesOperation.cc
new file mode 100644
index 00000000..9b7627fa
--- /dev/null
+++ b/src/async/pop/MCPOPFetchMessagesOperation.cc
@@ -0,0 +1,37 @@
+//
+// MCPOPFetchMessagesOperation.cc
+// mailcore2
+//
+// Created by DINH Viêt Hoà on 1/16/13.
+// Copyright (c) 2013 MailCore. All rights reserved.
+//
+
+#include "MCPOPFetchMessagesOperation.h"
+
+#include "MCPOPAsyncSession.h"
+#include "MCPOPSession.h"
+
+using namespace mailcore;
+
+POPFetchMessagesOperation::POPFetchMessagesOperation()
+{
+ mMessages = NULL;
+}
+
+POPFetchMessagesOperation::~POPFetchMessagesOperation()
+{
+ MC_SAFE_RELEASE(mMessages);
+}
+
+Array * POPFetchMessagesOperation::messages()
+{
+ return mMessages;
+}
+
+void POPFetchMessagesOperation::main()
+{
+ ErrorCode error;
+ mMessages = session()->session()->fetchMessages(&error);
+ setError(error);
+ MC_SAFE_RETAIN(mMessages);
+}
diff --git a/src/async/pop/MCPOPFetchMessagesOperation.h b/src/async/pop/MCPOPFetchMessagesOperation.h
new file mode 100644
index 00000000..b8c3d703
--- /dev/null
+++ b/src/async/pop/MCPOPFetchMessagesOperation.h
@@ -0,0 +1,27 @@
+//
+// MCPOPFetchMessagesOperation.h
+// mailcore2
+//
+// Created by DINH Viêt Hoà on 1/16/13.
+// Copyright (c) 2013 MailCore. All rights reserved.
+//
+
+#ifndef __mailcore2__MCPOPFetchMessagesOperation__
+#define __mailcore2__MCPOPFetchMessagesOperation__
+
+#include <mailcore/MCPOPOperation.h>
+
+namespace mailcore {
+ class POPFetchMessagesOperation : public POPOperation {
+ Array * mMessages;
+ public:
+ POPFetchMessagesOperation();
+ virtual ~POPFetchMessagesOperation();
+
+ virtual Array * messages();
+
+ virtual void main();
+ };
+}
+
+#endif /* defined(__mailcore2__MCPOPFetchMessagesOperation__) */
diff --git a/src/async/pop/MCPOPOperation.cc b/src/async/pop/MCPOPOperation.cc
new file mode 100644
index 00000000..7fb279d6
--- /dev/null
+++ b/src/async/pop/MCPOPOperation.cc
@@ -0,0 +1,86 @@
+//
+// MCPOPOperation.cc
+// mailcore2
+//
+// Created by DINH Viêt Hoà on 1/16/13.
+// Copyright (c) 2013 MailCore. All rights reserved.
+//
+
+#include "MCPOPOperation.h"
+
+#include <stdlib.h>
+
+#include "MCPOPSession.h"
+#include "MCPOPAsyncSession.h"
+#include "MCPOPOperationCallback.h"
+
+using namespace mailcore;
+
+POPOperation::POPOperation()
+{
+ mSession = NULL;
+ mPopCallback = NULL;
+ mError = ErrorNone;
+}
+
+POPOperation::~POPOperation()
+{
+ MC_SAFE_RELEASE(mSession);
+}
+
+void POPOperation::setSession(POPAsyncSession * session)
+{
+ MC_SAFE_REPLACE_RETAIN(POPAsyncSession, mSession, session);
+}
+
+POPAsyncSession * POPOperation::session()
+{
+ return mSession;
+}
+
+void POPOperation::setPopCallback(POPOperationCallback * callback)
+{
+ mPopCallback = callback;
+}
+
+POPOperationCallback * POPOperation::popCallback()
+{
+ return mPopCallback;
+}
+
+void POPOperation::setError(ErrorCode error)
+{
+ mError = error;
+}
+
+ErrorCode POPOperation::error()
+{
+ return mError;
+}
+
+void POPOperation::start()
+{
+ mSession->runOperation(this);
+}
+
+struct progressContext {
+ unsigned int current;
+ unsigned int maximum;
+};
+
+void POPOperation::bodyProgress(POPSession * session, unsigned int current, unsigned int maximum)
+{
+ struct progressContext * context = (struct progressContext *) calloc(sizeof(* context), 1);
+ context->current = current;
+ context->maximum = maximum;
+ performMethodOnMainThread((Object::Method) &POPOperation::bodyProgressOnMainThread, context);
+}
+
+void POPOperation::bodyProgressOnMainThread(void * ctx)
+{
+ struct progressContext * context = (struct progressContext *) ctx;
+ if (mPopCallback != NULL) {
+ mPopCallback->bodyProgress(this, context->current, context->maximum);
+ }
+ free(context);
+}
diff --git a/src/async/pop/MCPOPOperation.h b/src/async/pop/MCPOPOperation.h
new file mode 100644
index 00000000..9fcc6af6
--- /dev/null
+++ b/src/async/pop/MCPOPOperation.h
@@ -0,0 +1,46 @@
+//
+// MCPOPOperation.h
+// mailcore2
+//
+// Created by DINH Viêt Hoà on 1/16/13.
+// Copyright (c) 2013 MailCore. All rights reserved.
+//
+
+#ifndef __mailcore2__MCPOPOperation__
+#define __mailcore2__MCPOPOperation__
+
+#include <mailcore/MCBaseTypes.h>
+#include <mailcore/MCPOPProgressCallback.h>
+
+namespace mailcore {
+
+ class POPAsyncSession;
+ class POPOperationCallback;
+
+ class POPOperation : public Operation, public POPProgressCallback {
+ POPAsyncSession * mSession;
+ POPOperationCallback * mPopCallback;
+ ErrorCode mError;
+ private:
+ virtual void bodyProgress(POPSession * session, unsigned int current, unsigned int maximum);
+ virtual void bodyProgressOnMainThread(void * context);
+
+ public:
+ POPOperation();
+ virtual ~POPOperation();
+
+ virtual void setSession(POPAsyncSession * session);
+ virtual POPAsyncSession * session();
+
+ virtual void setPopCallback(POPOperationCallback * callback);
+ virtual POPOperationCallback * popCallback();
+
+ virtual void setError(ErrorCode error);
+ virtual ErrorCode error();
+
+ virtual void start();
+ };
+
+}
+
+#endif /* defined(__mailcore2__MCPOPOperation__) */
diff --git a/src/async/pop/MCPOPOperationCallback.h b/src/async/pop/MCPOPOperationCallback.h
new file mode 100644
index 00000000..a71bd008
--- /dev/null
+++ b/src/async/pop/MCPOPOperationCallback.h
@@ -0,0 +1,23 @@
+//
+// MCPOPOperationCallback.h
+// mailcore2
+//
+// Created by DINH Viêt Hoà on 1/16/13.
+// Copyright (c) 2013 MailCore. All rights reserved.
+//
+
+#ifndef mailcore2_MCPOPOperationCallback_h
+#define mailcore2_MCPOPOperationCallback_h
+
+namespace mailcore {
+
+ class POPOperation;
+
+ class POPOperationCallback {
+ public:
+ virtual void bodyProgress(POPOperation * session, unsigned int current, unsigned int maximum) {};
+ };
+
+}
+
+#endif