aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/async
diff options
context:
space:
mode:
authorGravatar Hoa V. DINH <dinh.viet.hoa@gmail.com>2013-06-22 23:04:01 -0700
committerGravatar Hoa V. DINH <dinh.viet.hoa@gmail.com>2013-06-22 23:04:01 -0700
commitb203675deaaf0049b7093587ce8fb30bb6ab3d9a (patch)
tree7c7a30059958bc5b736752a6f486fad30bc87d2a /src/async
parent9682845dd6a6985f396a93ff95adc1dcdeae8861 (diff)
POP operations retain the session. Fixed #129
Diffstat (limited to 'src/async')
-rw-r--r--src/async/pop/MCPOPAsyncSession.cc28
-rw-r--r--src/async/pop/MCPOPAsyncSession.h4
2 files changed, 30 insertions, 2 deletions
diff --git a/src/async/pop/MCPOPAsyncSession.cc b/src/async/pop/MCPOPAsyncSession.cc
index 39f356db..1269a34b 100644
--- a/src/async/pop/MCPOPAsyncSession.cc
+++ b/src/async/pop/MCPOPAsyncSession.cc
@@ -14,17 +14,44 @@
#include "MCPOPDeleteMessagesOperation.h"
#include "MCPOPFetchMessagesOperation.h"
#include "MCPOPCheckAccountOperation.h"
+#include "MCOperationQueueCallback.h"
using namespace mailcore;
+namespace mailcore {
+ class POPOperationQueueCallback : public Object, public OperationQueueCallback {
+ public:
+ POPOperationQueueCallback(POPAsyncSession * session) {
+ mSession = session;
+ }
+
+ virtual ~POPOperationQueueCallback() {
+ }
+
+ virtual void queueStartRunning() {
+ mSession->retain();
+ }
+
+ virtual void queueStoppedRunning() {
+ mSession->release();
+ }
+
+ private:
+ POPAsyncSession * mSession;
+ };
+}
+
POPAsyncSession::POPAsyncSession()
{
mSession = new POPSession();
mQueue = new OperationQueue();
+ mQueueCallback = new POPOperationQueueCallback(this);
+ mQueue->setCallback(mQueueCallback);
}
POPAsyncSession::~POPAsyncSession()
{
+ MC_SAFE_RELEASE(mQueueCallback);
MC_SAFE_RELEASE(mSession);
MC_SAFE_RELEASE(mQueue);
}
@@ -164,6 +191,5 @@ POPSession * POPAsyncSession::session()
void POPAsyncSession::runOperation(POPOperation * operation)
{
-#warning disconnect after delay
mQueue->addOperation(operation);
}
diff --git a/src/async/pop/MCPOPAsyncSession.h b/src/async/pop/MCPOPAsyncSession.h
index 166675e0..452d4d75 100644
--- a/src/async/pop/MCPOPAsyncSession.h
+++ b/src/async/pop/MCPOPAsyncSession.h
@@ -22,7 +22,8 @@ namespace mailcore {
class POPFetchMessageOperation;
class POPDeleteMessagesOperation;
class POPFetchMessagesOperation;
-
+ class POPOperationQueueCallback;
+
class POPAsyncSession : public Object {
public:
POPAsyncSession();
@@ -68,6 +69,7 @@ namespace mailcore {
private:
POPSession * mSession;
OperationQueue * mQueue;
+ POPOperationQueueCallback * mQueueCallback;
public: // private
virtual void runOperation(POPOperation * operation);