From 5f82321bf14e8836da9d9a9f9caf9f12d021eef8 Mon Sep 17 00:00:00 2001 From: CodaFi Date: Wed, 13 Aug 2014 19:11:10 -0600 Subject: cpp -> cc --- src/async/nntp/MCAsyncNNTP.h | 4 +- src/async/nntp/MCNNTPAsyncSession.cc | 283 +++++++++++++++++++++++ src/async/nntp/MCNNTPAsyncSession.cpp | 282 ---------------------- src/async/nntp/MCNNTPAsyncSession.h | 14 +- src/async/nntp/MCNNTPCheckAccountOperation.cc | 30 +++ src/async/nntp/MCNNTPCheckAccountOperation.cpp | 30 --- src/async/nntp/MCNNTPDisconnectOperation.cc | 30 +++ src/async/nntp/MCNNTPDisconnectOperation.cpp | 30 --- src/async/nntp/MCNNTPFetchArticleOperation.cc | 57 +++++ src/async/nntp/MCNNTPFetchArticleOperation.h | 45 ++++ src/async/nntp/MCNNTPFetchArticlesOperation.cc | 49 ++++ src/async/nntp/MCNNTPFetchArticlesOperation.h | 41 ++++ src/async/nntp/MCNNTPFetchHeaderOperation.cc | 59 +++++ src/async/nntp/MCNNTPFetchHeaderOperation.cpp | 51 ---- src/async/nntp/MCNNTPFetchHeaderOperation.h | 4 + src/async/nntp/MCNNTPFetchMessageOperation.cpp | 57 ----- src/async/nntp/MCNNTPFetchMessageOperation.h | 45 ---- src/async/nntp/MCNNTPFetchMessagesOperation.cpp | 49 ---- src/async/nntp/MCNNTPFetchMessagesOperation.h | 41 ---- src/async/nntp/MCNNTPListNewsgroupsOperation.cc | 48 ++++ src/async/nntp/MCNNTPListNewsgroupsOperation.cpp | 48 ---- src/async/nntp/MCNNTPOperation.cc | 104 +++++++++ src/async/nntp/MCNNTPOperation.cpp | 104 --------- 23 files changed, 759 insertions(+), 746 deletions(-) create mode 100644 src/async/nntp/MCNNTPAsyncSession.cc delete mode 100644 src/async/nntp/MCNNTPAsyncSession.cpp create mode 100644 src/async/nntp/MCNNTPCheckAccountOperation.cc delete mode 100644 src/async/nntp/MCNNTPCheckAccountOperation.cpp create mode 100644 src/async/nntp/MCNNTPDisconnectOperation.cc delete mode 100644 src/async/nntp/MCNNTPDisconnectOperation.cpp create mode 100644 src/async/nntp/MCNNTPFetchArticleOperation.cc create mode 100644 src/async/nntp/MCNNTPFetchArticleOperation.h create mode 100644 src/async/nntp/MCNNTPFetchArticlesOperation.cc create mode 100644 src/async/nntp/MCNNTPFetchArticlesOperation.h create mode 100644 src/async/nntp/MCNNTPFetchHeaderOperation.cc delete mode 100644 src/async/nntp/MCNNTPFetchHeaderOperation.cpp delete mode 100644 src/async/nntp/MCNNTPFetchMessageOperation.cpp delete mode 100644 src/async/nntp/MCNNTPFetchMessageOperation.h delete mode 100644 src/async/nntp/MCNNTPFetchMessagesOperation.cpp delete mode 100644 src/async/nntp/MCNNTPFetchMessagesOperation.h create mode 100644 src/async/nntp/MCNNTPListNewsgroupsOperation.cc delete mode 100644 src/async/nntp/MCNNTPListNewsgroupsOperation.cpp create mode 100644 src/async/nntp/MCNNTPOperation.cc delete mode 100644 src/async/nntp/MCNNTPOperation.cpp (limited to 'src/async') diff --git a/src/async/nntp/MCAsyncNNTP.h b/src/async/nntp/MCAsyncNNTP.h index e96788ca..56509ff8 100644 --- a/src/async/nntp/MCAsyncNNTP.h +++ b/src/async/nntp/MCAsyncNNTP.h @@ -13,8 +13,8 @@ #include #include #include -#include -#include +#include +#include #include #include diff --git a/src/async/nntp/MCNNTPAsyncSession.cc b/src/async/nntp/MCNNTPAsyncSession.cc new file mode 100644 index 00000000..84b5f318 --- /dev/null +++ b/src/async/nntp/MCNNTPAsyncSession.cc @@ -0,0 +1,283 @@ +// +// MCNNTPAsyncSession.cpp +// mailcore2 +// +// Created by Robert Widmann on 8/13/14. +// Copyright (c) 2014 MailCore. All rights reserved. +// + +#include "MCNNTPAsyncSession.h" + +#include "MCNNTP.h" +#include "MCNNTPFetchHeaderOperation.h" +#include "MCNNTPFetchArticleOperation.h" +#include "MCNNTPFetchArticlesOperation.h" +#include "MCNNTPListNewsgroupsOperation.h" +#include "MCNNTPCheckAccountOperation.h" +#include "MCNNTPDisconnectOperation.h" +#include "MCOperationQueueCallback.h" +#include "MCConnectionLogger.h" + +using namespace mailcore; + +namespace mailcore { + class NNTPOperationQueueCallback : public Object, public OperationQueueCallback { + public: + NNTPOperationQueueCallback(NNTPAsyncSession * session) { + mSession = session; + } + + virtual ~NNTPOperationQueueCallback() { + } + + virtual void queueStartRunning() { + mSession->retain(); + } + + virtual void queueStoppedRunning() { + mSession->release(); + } + + private: + NNTPAsyncSession * mSession; + }; + + class NNTPConnectionLogger : public Object, public ConnectionLogger { + public: + NNTPConnectionLogger(NNTPAsyncSession * session) { + mSession = session; + } + + virtual ~NNTPConnectionLogger() { + } + + virtual void log(void * sender, ConnectionLogType logType, Data * buffer) + { + mSession->logConnection(logType, buffer); + } + + private: + NNTPAsyncSession * mSession; + }; + +} + +NNTPAsyncSession::NNTPAsyncSession() +{ + mSession = new NNTPSession(); + mQueue = new OperationQueue(); + mQueueCallback = new NNTPOperationQueueCallback(this); + mQueue->setCallback(mQueueCallback); + mConnectionLogger = NULL; + pthread_mutex_init(&mConnectionLoggerLock, NULL); + mInternalLogger = new NNTPConnectionLogger(this); + mSession->setConnectionLogger(mInternalLogger); +} + +NNTPAsyncSession::~NNTPAsyncSession() +{ + MC_SAFE_RELEASE(mInternalLogger); + pthread_mutex_destroy(&mConnectionLoggerLock); + MC_SAFE_RELEASE(mQueueCallback); + MC_SAFE_RELEASE(mSession); + MC_SAFE_RELEASE(mQueue); +} + +void NNTPAsyncSession::setHostname(String * hostname) +{ + mSession->setHostname(hostname); +} + +String * NNTPAsyncSession::hostname() +{ + return mSession->hostname(); +} + +void NNTPAsyncSession::setPort(unsigned int port) +{ + mSession->setPort(port); +} + +unsigned int NNTPAsyncSession::port() +{ + return mSession->port(); +} + +void NNTPAsyncSession::setUsername(String * username) +{ + mSession->setUsername(username); +} + +String * NNTPAsyncSession::username() +{ + return mSession->username(); +} + +void NNTPAsyncSession::setPassword(String * password) +{ + mSession->setPassword(password); +} + +String * NNTPAsyncSession::password() +{ + return mSession->password(); +} + +void NNTPAsyncSession::setConnectionType(ConnectionType connectionType) +{ + mSession->setConnectionType(connectionType); +} + +ConnectionType NNTPAsyncSession::connectionType() +{ + return mSession->connectionType(); +} + +void NNTPAsyncSession::setTimeout(time_t timeout) +{ + mSession->setTimeout(timeout); +} + +time_t NNTPAsyncSession::timeout() +{ + return mSession->timeout(); +} + +void NNTPAsyncSession::setCheckCertificateEnabled(bool enabled) +{ + mSession->setCheckCertificateEnabled(enabled); +} + +bool NNTPAsyncSession::isCheckCertificateEnabled() +{ + return mSession->isCheckCertificateEnabled(); +} + +MCNNTPFetchArticlesOperation * NNTPAsyncSession::fetchArticlesOperation(String * group) +{ + MCNNTPFetchArticlesOperation * op = new MCNNTPFetchArticlesOperation(); + op->setSession(this); + op->setGroupName(group); + op->autorelease(); + return op; +} + +NNTPFetchHeaderOperation * NNTPAsyncSession::fetchHeaderOperation(String * groupName, unsigned int index) +{ + NNTPFetchHeaderOperation * op = new NNTPFetchHeaderOperation(); + op->setSession(this); + op->setGroupName(groupName); + op->setMessageIndex(index); + op->autorelease(); + return op; +} + +NNTPFetchHeaderOperation * NNTPAsyncSession::fetchHeaderOperation(String * groupName, NNTPMessageInfo * msg) +{ + return fetchHeaderOperation(groupName, msg->index()); +} + +NNTPFetchArticleOperation * NNTPAsyncSession::fetchArticleOperation(String * groupName, unsigned int index) +{ + NNTPFetchArticleOperation * op = new NNTPFetchArticleOperation(); + op->setSession(this); + op->setGroupName(groupName); + op->setMessageIndex(index); + op->autorelease(); + return op; +} + +NNTPFetchArticleOperation * NNTPAsyncSession::fetchArticleOperation(String *groupName, NNTPMessageInfo * msg) +{ + return fetchArticleOperation(groupName, msg->index()); +} + + +NNTPListNewsgroupsOperation * NNTPAsyncSession::listAllNewsgroupsOperation() +{ + NNTPListNewsgroupsOperation * op = new NNTPListNewsgroupsOperation(); + op->setSession(this); + op->setListsSubscribed(false); + op->autorelease(); + return op; +} + +NNTPListNewsgroupsOperation * NNTPAsyncSession::listSubscribedNewsgroupsOperation() +{ + NNTPListNewsgroupsOperation * op = new NNTPListNewsgroupsOperation(); + op->setSession(this); + op->setListsSubscribed(true); + op->autorelease(); + return op; +} + +NNTPOperation * NNTPAsyncSession::disconnectOperation() +{ + NNTPDisconnectOperation * op = new NNTPDisconnectOperation(); + op->setSession(this); + op->autorelease(); + return op; +} + +NNTPOperation * NNTPAsyncSession::checkAccountOperation() +{ + NNTPCheckAccountOperation * op = new NNTPCheckAccountOperation(); + op->setSession(this); + op->autorelease(); + return op; +} + +NNTPSession * NNTPAsyncSession::session() +{ + return mSession; +} + +void NNTPAsyncSession::runOperation(NNTPOperation * operation) +{ + mQueue->addOperation(operation); +} + +void NNTPAsyncSession::setConnectionLogger(ConnectionLogger * logger) +{ + pthread_mutex_lock(&mConnectionLoggerLock); + mConnectionLogger = logger; + if (mConnectionLogger != NULL) { + mSession->setConnectionLogger(mInternalLogger); + } + else { + mSession->setConnectionLogger(NULL); + } + pthread_mutex_unlock(&mConnectionLoggerLock); +} + +ConnectionLogger * NNTPAsyncSession::connectionLogger() +{ + ConnectionLogger * result; + + pthread_mutex_lock(&mConnectionLoggerLock); + result = mConnectionLogger; + pthread_mutex_unlock(&mConnectionLoggerLock); + + return result; +} + +void NNTPAsyncSession::logConnection(ConnectionLogType logType, Data * buffer) +{ + pthread_mutex_lock(&mConnectionLoggerLock); + if (mConnectionLogger != NULL) { + mConnectionLogger->log(this, logType, buffer); + } + pthread_mutex_unlock(&mConnectionLoggerLock); +} + +#if __APPLE__ +void NNTPAsyncSession::setDispatchQueue(dispatch_queue_t dispatchQueue) +{ + mQueue->setDispatchQueue(dispatchQueue); +} + +dispatch_queue_t NNTPAsyncSession::dispatchQueue() +{ + return mQueue->dispatchQueue(); +} +#endif diff --git a/src/async/nntp/MCNNTPAsyncSession.cpp b/src/async/nntp/MCNNTPAsyncSession.cpp deleted file mode 100644 index ba3b630b..00000000 --- a/src/async/nntp/MCNNTPAsyncSession.cpp +++ /dev/null @@ -1,282 +0,0 @@ -// -// MCNNTPAsyncSession.cpp -// mailcore2 -// -// Created by Robert Widmann on 8/13/14. -// Copyright (c) 2014 MailCore. All rights reserved. -// - -#include "MCNNTPAsyncSession.h" - -#include "MCNNTP.h" -#include "MCNNTPFetchHeaderOperation.h" -#include "MCNNTPFetchMessageOperation.h" -#include "MCNNTPFetchMessagesOperation.h" -#include "MCNNTPListNewsgroupsOperation.h" -#include "MCNNTPCheckAccountOperation.h" -#include "MCNNTPDisconnectOperation.h" -#include "MCOperationQueueCallback.h" -#include "MCConnectionLogger.h" - -using namespace mailcore; - -namespace mailcore { - class NNTPOperationQueueCallback : public Object, public OperationQueueCallback { - public: - NNTPOperationQueueCallback(NNTPAsyncSession * session) { - mSession = session; - } - - virtual ~NNTPOperationQueueCallback() { - } - - virtual void queueStartRunning() { - mSession->retain(); - } - - virtual void queueStoppedRunning() { - mSession->release(); - } - - private: - NNTPAsyncSession * mSession; - }; - - class NNTPConnectionLogger : public Object, public ConnectionLogger { - public: - NNTPConnectionLogger(NNTPAsyncSession * session) { - mSession = session; - } - - virtual ~NNTPConnectionLogger() { - } - - virtual void log(void * sender, ConnectionLogType logType, Data * buffer) - { - mSession->logConnection(logType, buffer); - } - - private: - NNTPAsyncSession * mSession; - }; - -} - -NNTPAsyncSession::NNTPAsyncSession() -{ - mSession = new NNTPSession(); - mQueue = new OperationQueue(); - mQueueCallback = new NNTPOperationQueueCallback(this); - mQueue->setCallback(mQueueCallback); - mConnectionLogger = NULL; - pthread_mutex_init(&mConnectionLoggerLock, NULL); - mInternalLogger = new NNTPConnectionLogger(this); - mSession->setConnectionLogger(mInternalLogger); -} - -NNTPAsyncSession::~NNTPAsyncSession() -{ - MC_SAFE_RELEASE(mInternalLogger); - pthread_mutex_destroy(&mConnectionLoggerLock); - MC_SAFE_RELEASE(mQueueCallback); - MC_SAFE_RELEASE(mSession); - MC_SAFE_RELEASE(mQueue); -} - -void NNTPAsyncSession::setHostname(String * hostname) -{ - mSession->setHostname(hostname); -} - -String * NNTPAsyncSession::hostname() -{ - return mSession->hostname(); -} - -void NNTPAsyncSession::setPort(unsigned int port) -{ - mSession->setPort(port); -} - -unsigned int NNTPAsyncSession::port() -{ - return mSession->port(); -} - -void NNTPAsyncSession::setUsername(String * username) -{ - mSession->setUsername(username); -} - -String * NNTPAsyncSession::username() -{ - return mSession->username(); -} - -void NNTPAsyncSession::setPassword(String * password) -{ - mSession->setPassword(password); -} - -String * NNTPAsyncSession::password() -{ - return mSession->password(); -} - -void NNTPAsyncSession::setConnectionType(ConnectionType connectionType) -{ - mSession->setConnectionType(connectionType); -} - -ConnectionType NNTPAsyncSession::connectionType() -{ - return mSession->connectionType(); -} - -void NNTPAsyncSession::setTimeout(time_t timeout) -{ - mSession->setTimeout(timeout); -} - -time_t NNTPAsyncSession::timeout() -{ - return mSession->timeout(); -} - -void NNTPAsyncSession::setCheckCertificateEnabled(bool enabled) -{ - mSession->setCheckCertificateEnabled(enabled); -} - -bool NNTPAsyncSession::isCheckCertificateEnabled() -{ - return mSession->isCheckCertificateEnabled(); -} - -NNTPFetchMessagesOperation * NNTPAsyncSession::fetchMessagesOperation(String * group) -{ - NNTPFetchMessagesOperation * op = new NNTPFetchMessagesOperation(); - op->setSession(this); - op->setGroupName(group); - op->autorelease(); - return op; -} - -NNTPFetchHeaderOperation * NNTPAsyncSession::fetchHeaderOperation(unsigned int index) -{ - NNTPFetchHeaderOperation * op = new NNTPFetchHeaderOperation(); - op->setSession(this); - op->setMessageIndex(index); - op->autorelease(); - return op; -} - -NNTPFetchHeaderOperation * NNTPAsyncSession::fetchHeaderOperation(NNTPMessageInfo * msg) -{ - return fetchHeaderOperation(msg->index()); -} - -NNTPFetchMessageOperation * NNTPAsyncSession::fetchArticleOperation(String * groupName, unsigned int index) -{ - NNTPFetchMessageOperation * op = new NNTPFetchMessageOperation(); - op->setSession(this); - op->setGroupName(groupName); - op->setMessageIndex(index); - op->autorelease(); - return op; -} - -NNTPFetchMessageOperation * NNTPAsyncSession::fetchArticleOperation(String *groupName, NNTPMessageInfo * msg) -{ - return fetchArticleOperation(groupName, msg->index()); -} - - -NNTPListNewsgroupsOperation * NNTPAsyncSession::listAllNewsgroupsOperation() -{ - NNTPListNewsgroupsOperation * op = new NNTPListNewsgroupsOperation(); - op->setSession(this); - op->setListsSubscribed(false); - op->autorelease(); - return op; -} - -NNTPListNewsgroupsOperation * NNTPAsyncSession::listSubscribedNewsgroupsOperation() -{ - NNTPListNewsgroupsOperation * op = new NNTPListNewsgroupsOperation(); - op->setSession(this); - op->setListsSubscribed(true); - op->autorelease(); - return op; -} - -NNTPOperation * NNTPAsyncSession::disconnectOperation() -{ - NNTPDisconnectOperation * op = new NNTPDisconnectOperation(); - op->setSession(this); - op->autorelease(); - return op; -} - -NNTPOperation * NNTPAsyncSession::checkAccountOperation() -{ - NNTPCheckAccountOperation * op = new NNTPCheckAccountOperation(); - op->setSession(this); - op->autorelease(); - return op; -} - -NNTPSession * NNTPAsyncSession::session() -{ - return mSession; -} - -void NNTPAsyncSession::runOperation(NNTPOperation * operation) -{ - mQueue->addOperation(operation); -} - -void NNTPAsyncSession::setConnectionLogger(ConnectionLogger * logger) -{ - pthread_mutex_lock(&mConnectionLoggerLock); - mConnectionLogger = logger; - if (mConnectionLogger != NULL) { - mSession->setConnectionLogger(mInternalLogger); - } - else { - mSession->setConnectionLogger(NULL); - } - pthread_mutex_unlock(&mConnectionLoggerLock); -} - -ConnectionLogger * NNTPAsyncSession::connectionLogger() -{ - ConnectionLogger * result; - - pthread_mutex_lock(&mConnectionLoggerLock); - result = mConnectionLogger; - pthread_mutex_unlock(&mConnectionLoggerLock); - - return result; -} - -void NNTPAsyncSession::logConnection(ConnectionLogType logType, Data * buffer) -{ - pthread_mutex_lock(&mConnectionLoggerLock); - if (mConnectionLogger != NULL) { - mConnectionLogger->log(this, logType, buffer); - } - pthread_mutex_unlock(&mConnectionLoggerLock); -} - -#if __APPLE__ -void NNTPAsyncSession::setDispatchQueue(dispatch_queue_t dispatchQueue) -{ - mQueue->setDispatchQueue(dispatchQueue); -} - -dispatch_queue_t NNTPAsyncSession::dispatchQueue() -{ - return mQueue->dispatchQueue(); -} -#endif diff --git a/src/async/nntp/MCNNTPAsyncSession.h b/src/async/nntp/MCNNTPAsyncSession.h index 9c214b93..501985bc 100644 --- a/src/async/nntp/MCNNTPAsyncSession.h +++ b/src/async/nntp/MCNNTPAsyncSession.h @@ -12,8 +12,8 @@ namespace mailcore { class NNTPMessageInfo; class NNTPSession; class NNTPFetchHeaderOperation; - class NNTPFetchMessageOperation; - class NNTPFetchMessagesOperation; + class NNTPFetchArticleOperation; + class MCNNTPFetchArticlesOperation; class NNTPListNewsgroupsOperation; class NNTPOperationQueueCallback; class NNTPConnectionLogger; @@ -52,13 +52,13 @@ namespace mailcore { virtual dispatch_queue_t dispatchQueue(); #endif - virtual NNTPFetchMessagesOperation * fetchMessagesOperation(String * group); + virtual MCNNTPFetchArticlesOperation * fetchArticlesOperation(String * group); - virtual NNTPFetchHeaderOperation * fetchHeaderOperation(unsigned int index); - virtual NNTPFetchHeaderOperation * fetchHeaderOperation(NNTPMessageInfo * msg); + virtual NNTPFetchHeaderOperation * fetchHeaderOperation(String * groupName, unsigned int index); + virtual NNTPFetchHeaderOperation * fetchHeaderOperation(String * groupName, NNTPMessageInfo * msg); - virtual NNTPFetchMessageOperation * fetchArticleOperation(String *groupName, unsigned int index); - virtual NNTPFetchMessageOperation * fetchArticleOperation(String *groupName, NNTPMessageInfo * msg); + virtual NNTPFetchArticleOperation * fetchArticleOperation(String *groupName, unsigned int index); + virtual NNTPFetchArticleOperation * fetchArticleOperation(String *groupName, NNTPMessageInfo * msg); virtual NNTPListNewsgroupsOperation * listAllNewsgroupsOperation(); virtual NNTPListNewsgroupsOperation * listSubscribedNewsgroupsOperation(); diff --git a/src/async/nntp/MCNNTPCheckAccountOperation.cc b/src/async/nntp/MCNNTPCheckAccountOperation.cc new file mode 100644 index 00000000..29b050f0 --- /dev/null +++ b/src/async/nntp/MCNNTPCheckAccountOperation.cc @@ -0,0 +1,30 @@ +// +// MCNNTPCheckAccountOperation.cpp +// mailcore2 +// +// Created by Robert Widmann on 8/13/14. +// Copyright (c) 2014 MailCore. All rights reserved. +// + +#include "MCNNTPCheckAccountOperation.h" + +#include "MCNNTPAsyncSession.h" +#include "MCNNTPSession.h" + +using namespace mailcore; + +NNTPCheckAccountOperation::NNTPCheckAccountOperation() +{ +} + +NNTPCheckAccountOperation::~NNTPCheckAccountOperation() +{ +} + +void NNTPCheckAccountOperation::main() +{ + ErrorCode error; + + session()->session()->checkAccount(&error); + setError(error); +} diff --git a/src/async/nntp/MCNNTPCheckAccountOperation.cpp b/src/async/nntp/MCNNTPCheckAccountOperation.cpp deleted file mode 100644 index 29b050f0..00000000 --- a/src/async/nntp/MCNNTPCheckAccountOperation.cpp +++ /dev/null @@ -1,30 +0,0 @@ -// -// MCNNTPCheckAccountOperation.cpp -// mailcore2 -// -// Created by Robert Widmann on 8/13/14. -// Copyright (c) 2014 MailCore. All rights reserved. -// - -#include "MCNNTPCheckAccountOperation.h" - -#include "MCNNTPAsyncSession.h" -#include "MCNNTPSession.h" - -using namespace mailcore; - -NNTPCheckAccountOperation::NNTPCheckAccountOperation() -{ -} - -NNTPCheckAccountOperation::~NNTPCheckAccountOperation() -{ -} - -void NNTPCheckAccountOperation::main() -{ - ErrorCode error; - - session()->session()->checkAccount(&error); - setError(error); -} diff --git a/src/async/nntp/MCNNTPDisconnectOperation.cc b/src/async/nntp/MCNNTPDisconnectOperation.cc new file mode 100644 index 00000000..d269904a --- /dev/null +++ b/src/async/nntp/MCNNTPDisconnectOperation.cc @@ -0,0 +1,30 @@ +// +// MCNNTPDisconnectOperation.cpp +// mailcore2 +// +// Created by Robert Widmann on 8/13/14. +// Copyright (c) 2014 MailCore. All rights reserved. +// + +#include "MCNNTPDisconnectOperation.h" + +#include "MCNNTPAsyncSession.h" +#include "MCNNTPSession.h" + +using namespace mailcore; + +NNTPDisconnectOperation::NNTPDisconnectOperation() +{ +} + +NNTPDisconnectOperation::~NNTPDisconnectOperation() +{ +} + +void NNTPDisconnectOperation::main() +{ + ErrorCode error; + + session()->session()->checkAccount(&error); + setError(error); +} diff --git a/src/async/nntp/MCNNTPDisconnectOperation.cpp b/src/async/nntp/MCNNTPDisconnectOperation.cpp deleted file mode 100644 index d269904a..00000000 --- a/src/async/nntp/MCNNTPDisconnectOperation.cpp +++ /dev/null @@ -1,30 +0,0 @@ -// -// MCNNTPDisconnectOperation.cpp -// mailcore2 -// -// Created by Robert Widmann on 8/13/14. -// Copyright (c) 2014 MailCore. All rights reserved. -// - -#include "MCNNTPDisconnectOperation.h" - -#include "MCNNTPAsyncSession.h" -#include "MCNNTPSession.h" - -using namespace mailcore; - -NNTPDisconnectOperation::NNTPDisconnectOperation() -{ -} - -NNTPDisconnectOperation::~NNTPDisconnectOperation() -{ -} - -void NNTPDisconnectOperation::main() -{ - ErrorCode error; - - session()->session()->checkAccount(&error); - setError(error); -} diff --git a/src/async/nntp/MCNNTPFetchArticleOperation.cc b/src/async/nntp/MCNNTPFetchArticleOperation.cc new file mode 100644 index 00000000..a12f346f --- /dev/null +++ b/src/async/nntp/MCNNTPFetchArticleOperation.cc @@ -0,0 +1,57 @@ +// +// MCMCNNTPFetchArticlesOperation.cpp +// mailcore2 +// +// Created by Robert Widmann on 8/13/14. +// Copyright (c) 2014 MailCore. All rights reserved. +// + +#include "MCNNTPFetchArticleOperation.h" + +#include "MCNNTPAsyncSession.h" +#include "MCNNTPSession.h" + +using namespace mailcore; + +NNTPFetchArticleOperation::NNTPFetchArticleOperation() +{ + mMessageIndex = 0; + mData = NULL; +} + +NNTPFetchArticleOperation::~NNTPFetchArticleOperation() +{ + MC_SAFE_RELEASE(mData); +} + +void NNTPFetchArticleOperation::setGroupName(String * groupName) { + MC_SAFE_REPLACE_COPY(String, mGroupName, groupName); +} + +String * NNTPFetchArticleOperation::groupName() { + return mGroupName; +} + +void NNTPFetchArticleOperation::setMessageIndex(unsigned int messageIndex) +{ + mMessageIndex = messageIndex; +} + +unsigned int NNTPFetchArticleOperation::messageIndex() +{ + return mMessageIndex; +} + +Data * NNTPFetchArticleOperation::data() +{ + return mData; +} + +void NNTPFetchArticleOperation::main() +{ + ErrorCode error; + mData = session()->session()->fetchArticle(mGroupName, mMessageIndex, this, &error); + MC_SAFE_RETAIN(mData); + setError(error); +} + diff --git a/src/async/nntp/MCNNTPFetchArticleOperation.h b/src/async/nntp/MCNNTPFetchArticleOperation.h new file mode 100644 index 00000000..f43799a9 --- /dev/null +++ b/src/async/nntp/MCNNTPFetchArticleOperation.h @@ -0,0 +1,45 @@ +// +// MCMCNNTPFetchArticlesOperation.h +// mailcore2 +// +// Created by Robert Widmann on 8/13/14. +// Copyright (c) 2014 MailCore. All rights reserved. +// + +#ifndef MAILCORE_MCNNTPFETCHMESSAGEOPERATION_H + +#define MAILCORE_MCNNTPFETCHMESSAGEOPERATION_H + +#include + +#ifdef __cplusplus + +namespace mailcore { + class NNTPFetchArticleOperation : public NNTPOperation { + public: + NNTPFetchArticleOperation(); + virtual ~NNTPFetchArticleOperation(); + + virtual void setGroupName(String * groupName); + virtual String * groupName(); + + virtual void setMessageIndex(unsigned int messageIndex); + virtual unsigned int messageIndex(); + + virtual Data * data(); + + public: // subclass behavior + virtual void main(); + + private: + String * mGroupName; + unsigned int mMessageIndex; + Data * mData; + + }; + +} + +#endif + +#endif diff --git a/src/async/nntp/MCNNTPFetchArticlesOperation.cc b/src/async/nntp/MCNNTPFetchArticlesOperation.cc new file mode 100644 index 00000000..41e3281f --- /dev/null +++ b/src/async/nntp/MCNNTPFetchArticlesOperation.cc @@ -0,0 +1,49 @@ +// +// MCMCNNTPFetchArticlesOperation.cpp +// mailcore2 +// +// Created by Robert Widmann on 8/13/14. +// Copyright (c) 2014 MailCore. All rights reserved. +// + +#include "MCNNTPFetchArticlesOperation.h" + +#include "MCNNTPAsyncSession.h" +#include "MCNNTPSession.h" + +using namespace mailcore; + +MCNNTPFetchArticlesOperation::MCNNTPFetchArticlesOperation() +{ + mGroupName = NULL; + mMessages = NULL; +} + +MCNNTPFetchArticlesOperation::~MCNNTPFetchArticlesOperation() +{ + MC_SAFE_RELEASE(mGroupName); + MC_SAFE_RELEASE(mMessages); +} + +void MCNNTPFetchArticlesOperation::setGroupName(String * groupname) +{ + MC_SAFE_REPLACE_COPY(String, mGroupName, groupname); +} + +String * MCNNTPFetchArticlesOperation::groupName() +{ + return mGroupName; +} + +Array * MCNNTPFetchArticlesOperation::messages() +{ + return mMessages; +} + +void MCNNTPFetchArticlesOperation::main() +{ + ErrorCode error; + mMessages = session()->session()->fetchArticles(mGroupName, &error); + setError(error); + MC_SAFE_RETAIN(mMessages); +} diff --git a/src/async/nntp/MCNNTPFetchArticlesOperation.h b/src/async/nntp/MCNNTPFetchArticlesOperation.h new file mode 100644 index 00000000..9fe6fd1b --- /dev/null +++ b/src/async/nntp/MCNNTPFetchArticlesOperation.h @@ -0,0 +1,41 @@ +// +// MCMCNNTPFetchArticlesOperation.h +// mailcore2 +// +// Created by Robert Widmann on 8/13/14. +// Copyright (c) 2014 MailCore. All rights reserved. +// + +#ifndef MAILCORE_MCNNTPFETCHMESSAGESOPERATION_H + +#define MAILCORE_MCNNTPFETCHMESSAGESOPERATION_H + +#include + +#ifdef __cplusplus + +namespace mailcore { + + class MCNNTPFetchArticlesOperation : public NNTPOperation { + public: + MCNNTPFetchArticlesOperation(); + virtual ~MCNNTPFetchArticlesOperation(); + + virtual void setGroupName(String * groupName); + virtual String * groupName(); + + virtual Array * /* NNTPMessageInfo */ messages(); + + public: // subclass behavior + virtual void main(); + + private: + String * mGroupName; + Array * /* NNTPMessageInfo */ mMessages; + }; + +} + +#endif + +#endif diff --git a/src/async/nntp/MCNNTPFetchHeaderOperation.cc b/src/async/nntp/MCNNTPFetchHeaderOperation.cc new file mode 100644 index 00000000..386dc142 --- /dev/null +++ b/src/async/nntp/MCNNTPFetchHeaderOperation.cc @@ -0,0 +1,59 @@ +// +// MCNNTPFetchHeaderOperation.cpp +// mailcore2 +// +// Created by Robert Widmann on 8/13/14. +// Copyright (c) 2014 MailCore. All rights reserved. +// + +#include "MCNNTPFetchHeaderOperation.h" + +#include "MCNNTPAsyncSession.h" +#include "MCNNTPSession.h" +#include "MCMessageHeader.h" + +using namespace mailcore; + +NNTPFetchHeaderOperation::NNTPFetchHeaderOperation() +{ + mMessageIndex = 0; + mHeader = NULL; +} + +NNTPFetchHeaderOperation::~NNTPFetchHeaderOperation() +{ + MC_SAFE_RELEASE(mHeader); +} + +void NNTPFetchHeaderOperation::setGroupName(String * groupName) { + MC_SAFE_REPLACE_COPY(String, mGroupName, groupName); +} + +String * NNTPFetchHeaderOperation::groupName() { + return mGroupName; +} + +void NNTPFetchHeaderOperation::setMessageIndex(unsigned int messageIndex) +{ + mMessageIndex = messageIndex; +} + +unsigned int NNTPFetchHeaderOperation::messageIndex() +{ + return mMessageIndex; +} + +MessageHeader * NNTPFetchHeaderOperation::header() +{ + return mHeader; +} + +void NNTPFetchHeaderOperation::main() +{ + ErrorCode error; + mHeader = session()->session()->fetchHeader(mGroupName, mMessageIndex, &error); + if (mHeader != NULL) { + mHeader->retain(); + } + setError(error); +} diff --git a/src/async/nntp/MCNNTPFetchHeaderOperation.cpp b/src/async/nntp/MCNNTPFetchHeaderOperation.cpp deleted file mode 100644 index ea374527..00000000 --- a/src/async/nntp/MCNNTPFetchHeaderOperation.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// -// MCNNTPFetchHeaderOperation.cpp -// mailcore2 -// -// Created by Robert Widmann on 8/13/14. -// Copyright (c) 2014 MailCore. All rights reserved. -// - -#include "MCNNTPFetchHeaderOperation.h" - -#include "MCNNTPAsyncSession.h" -#include "MCNNTPSession.h" -#include "MCMessageHeader.h" - -using namespace mailcore; - -NNTPFetchHeaderOperation::NNTPFetchHeaderOperation() -{ - mMessageIndex = 0; - mHeader = NULL; -} - -NNTPFetchHeaderOperation::~NNTPFetchHeaderOperation() -{ - MC_SAFE_RELEASE(mHeader); -} - -void NNTPFetchHeaderOperation::setMessageIndex(unsigned int messageIndex) -{ - mMessageIndex = messageIndex; -} - -unsigned int NNTPFetchHeaderOperation::messageIndex() -{ - return mMessageIndex; -} - -MessageHeader * NNTPFetchHeaderOperation::header() -{ - return mHeader; -} - -void NNTPFetchHeaderOperation::main() -{ - ErrorCode error; - mHeader = session()->session()->fetchHeader(mMessageIndex, &error); - if (mHeader != NULL) { - mHeader->retain(); - } - setError(error); -} diff --git a/src/async/nntp/MCNNTPFetchHeaderOperation.h b/src/async/nntp/MCNNTPFetchHeaderOperation.h index 91ded8ee..97b12b05 100644 --- a/src/async/nntp/MCNNTPFetchHeaderOperation.h +++ b/src/async/nntp/MCNNTPFetchHeaderOperation.h @@ -23,6 +23,9 @@ namespace mailcore { NNTPFetchHeaderOperation(); virtual ~NNTPFetchHeaderOperation(); + virtual void setGroupName(String * groupName); + virtual String * groupName(); + virtual void setMessageIndex(unsigned int messageIndex); virtual unsigned int messageIndex(); @@ -32,6 +35,7 @@ namespace mailcore { virtual void main(); private: + String * mGroupName; unsigned int mMessageIndex; MessageHeader * mHeader; diff --git a/src/async/nntp/MCNNTPFetchMessageOperation.cpp b/src/async/nntp/MCNNTPFetchMessageOperation.cpp deleted file mode 100644 index 2fe02f37..00000000 --- a/src/async/nntp/MCNNTPFetchMessageOperation.cpp +++ /dev/null @@ -1,57 +0,0 @@ -// -// MCNNTPFetchMessagesOperation.cpp -// mailcore2 -// -// Created by Robert Widmann on 8/13/14. -// Copyright (c) 2014 MailCore. All rights reserved. -// - -#include "MCNNTPFetchMessageOperation.h" - -#include "MCNNTPAsyncSession.h" -#include "MCNNTPSession.h" - -using namespace mailcore; - -NNTPFetchMessageOperation::NNTPFetchMessageOperation() -{ - mMessageIndex = 0; - mData = NULL; -} - -NNTPFetchMessageOperation::~NNTPFetchMessageOperation() -{ - MC_SAFE_RELEASE(mData); -} - -void NNTPFetchMessageOperation::setGroupName(String * groupName) { - MC_SAFE_REPLACE_COPY(String, mGroupName, groupName); -} - -String * NNTPFetchMessageOperation::groupName() { - return mGroupName; -} - -void NNTPFetchMessageOperation::setMessageIndex(unsigned int messageIndex) -{ - mMessageIndex = messageIndex; -} - -unsigned int NNTPFetchMessageOperation::messageIndex() -{ - return mMessageIndex; -} - -Data * NNTPFetchMessageOperation::data() -{ - return mData; -} - -void NNTPFetchMessageOperation::main() -{ - ErrorCode error; - mData = session()->session()->fetchArticle(mGroupName, mMessageIndex, this, &error); - MC_SAFE_RETAIN(mData); - setError(error); -} - diff --git a/src/async/nntp/MCNNTPFetchMessageOperation.h b/src/async/nntp/MCNNTPFetchMessageOperation.h deleted file mode 100644 index d038a62f..00000000 --- a/src/async/nntp/MCNNTPFetchMessageOperation.h +++ /dev/null @@ -1,45 +0,0 @@ -// -// MCNNTPFetchMessagesOperation.h -// mailcore2 -// -// Created by Robert Widmann on 8/13/14. -// Copyright (c) 2014 MailCore. All rights reserved. -// - -#ifndef MAILCORE_MCNNTPFETCHMESSAGEOPERATION_H - -#define MAILCORE_MCNNTPFETCHMESSAGEOPERATION_H - -#include - -#ifdef __cplusplus - -namespace mailcore { - class NNTPFetchMessageOperation : public NNTPOperation { - public: - NNTPFetchMessageOperation(); - virtual ~NNTPFetchMessageOperation(); - - virtual void setGroupName(String * groupName); - virtual String * groupName(); - - virtual void setMessageIndex(unsigned int messageIndex); - virtual unsigned int messageIndex(); - - virtual Data * data(); - - public: // subclass behavior - virtual void main(); - - private: - String * mGroupName; - unsigned int mMessageIndex; - Data * mData; - - }; - -} - -#endif - -#endif diff --git a/src/async/nntp/MCNNTPFetchMessagesOperation.cpp b/src/async/nntp/MCNNTPFetchMessagesOperation.cpp deleted file mode 100644 index 0e0fc239..00000000 --- a/src/async/nntp/MCNNTPFetchMessagesOperation.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// -// MCNNTPFetchMessagesOperation.cpp -// mailcore2 -// -// Created by Robert Widmann on 8/13/14. -// Copyright (c) 2014 MailCore. All rights reserved. -// - -#include "MCNNTPFetchMessagesOperation.h" - -#include "MCNNTPAsyncSession.h" -#include "MCNNTPSession.h" - -using namespace mailcore; - -NNTPFetchMessagesOperation::NNTPFetchMessagesOperation() -{ - mGroupName = NULL; - mMessages = NULL; -} - -NNTPFetchMessagesOperation::~NNTPFetchMessagesOperation() -{ - MC_SAFE_RELEASE(mGroupName); - MC_SAFE_RELEASE(mMessages); -} - -void NNTPFetchMessagesOperation::setGroupName(String * groupname) -{ - MC_SAFE_REPLACE_COPY(String, mGroupName, groupname); -} - -String * NNTPFetchMessagesOperation::groupName() -{ - return mGroupName; -} - -Array * NNTPFetchMessagesOperation::messages() -{ - return mMessages; -} - -void NNTPFetchMessagesOperation::main() -{ - ErrorCode error; - mMessages = session()->session()->fetchArticles(mGroupName, &error); - setError(error); - MC_SAFE_RETAIN(mMessages); -} diff --git a/src/async/nntp/MCNNTPFetchMessagesOperation.h b/src/async/nntp/MCNNTPFetchMessagesOperation.h deleted file mode 100644 index 91390c1f..00000000 --- a/src/async/nntp/MCNNTPFetchMessagesOperation.h +++ /dev/null @@ -1,41 +0,0 @@ -// -// MCNNTPFetchMessagesOperation.h -// mailcore2 -// -// Created by Robert Widmann on 8/13/14. -// Copyright (c) 2014 MailCore. All rights reserved. -// - -#ifndef MAILCORE_MCNNTPFETCHMESSAGESOPERATION_H - -#define MAILCORE_MCNNTPFETCHMESSAGESOPERATION_H - -#include - -#ifdef __cplusplus - -namespace mailcore { - - class NNTPFetchMessagesOperation : public NNTPOperation { - public: - NNTPFetchMessagesOperation(); - virtual ~NNTPFetchMessagesOperation(); - - virtual void setGroupName(String * groupName); - virtual String * groupName(); - - virtual Array * /* NNTPMessageInfo */ messages(); - - public: // subclass behavior - virtual void main(); - - private: - String * mGroupName; - Array * /* NNTPMessageInfo */ mMessages; - }; - -} - -#endif - -#endif diff --git a/src/async/nntp/MCNNTPListNewsgroupsOperation.cc b/src/async/nntp/MCNNTPListNewsgroupsOperation.cc new file mode 100644 index 00000000..253b38d0 --- /dev/null +++ b/src/async/nntp/MCNNTPListNewsgroupsOperation.cc @@ -0,0 +1,48 @@ +// +// MCNNTPListNewsgroupsMessagesOperation.cpp +// mailcore2 +// +// Created by Robert Widmann on 8/13/14. +// Copyright (c) 2014 MailCore. All rights reserved. +// + +#include "MCNNTPListNewsgroupsOperation.h" + +#include "MCNNTPAsyncSession.h" +#include "MCNNTPSession.h" + +using namespace mailcore; + +NNTPListNewsgroupsOperation::NNTPListNewsgroupsOperation() +{ +} + +NNTPListNewsgroupsOperation::~NNTPListNewsgroupsOperation() +{ +} + +void NNTPListNewsgroupsOperation::setListsSubscribed(bool listsSubscribed) +{ + mListsSuscribed = listsSubscribed; +} + +bool NNTPListNewsgroupsOperation::listsSubscribed() +{ + return mListsSuscribed; +} + +Array * NNTPListNewsgroupsOperation::groups() { + return mGroups; +} + +void NNTPListNewsgroupsOperation::main() +{ + ErrorCode error; + + if (mListsSuscribed) { + mGroups = session()->session()->listSubscribedNewsgroups(&error); + } else { + mGroups = session()->session()->listAllNewsgroups(&error); + } + setError(error); +} diff --git a/src/async/nntp/MCNNTPListNewsgroupsOperation.cpp b/src/async/nntp/MCNNTPListNewsgroupsOperation.cpp deleted file mode 100644 index 253b38d0..00000000 --- a/src/async/nntp/MCNNTPListNewsgroupsOperation.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// -// MCNNTPListNewsgroupsMessagesOperation.cpp -// mailcore2 -// -// Created by Robert Widmann on 8/13/14. -// Copyright (c) 2014 MailCore. All rights reserved. -// - -#include "MCNNTPListNewsgroupsOperation.h" - -#include "MCNNTPAsyncSession.h" -#include "MCNNTPSession.h" - -using namespace mailcore; - -NNTPListNewsgroupsOperation::NNTPListNewsgroupsOperation() -{ -} - -NNTPListNewsgroupsOperation::~NNTPListNewsgroupsOperation() -{ -} - -void NNTPListNewsgroupsOperation::setListsSubscribed(bool listsSubscribed) -{ - mListsSuscribed = listsSubscribed; -} - -bool NNTPListNewsgroupsOperation::listsSubscribed() -{ - return mListsSuscribed; -} - -Array * NNTPListNewsgroupsOperation::groups() { - return mGroups; -} - -void NNTPListNewsgroupsOperation::main() -{ - ErrorCode error; - - if (mListsSuscribed) { - mGroups = session()->session()->listSubscribedNewsgroups(&error); - } else { - mGroups = session()->session()->listAllNewsgroups(&error); - } - setError(error); -} diff --git a/src/async/nntp/MCNNTPOperation.cc b/src/async/nntp/MCNNTPOperation.cc new file mode 100644 index 00000000..3368ba0e --- /dev/null +++ b/src/async/nntp/MCNNTPOperation.cc @@ -0,0 +1,104 @@ +// +// MCNNTPOperation.cpp +// mailcore2 +// +// Created by Robert Widmann on 8/13/14. +// Copyright (c) 2014 MailCore. All rights reserved. +// + +#include "MCNNTPOperation.h" + +#include + +#include "MCNNTPSession.h" +#include "MCNNTPAsyncSession.h" +#include "MCNNTPOperationCallback.h" + +using namespace mailcore; + +NNTPOperation::NNTPOperation() +{ + mSession = NULL; + mPopCallback = NULL; + mError = ErrorNone; +} + +NNTPOperation::~NNTPOperation() +{ + MC_SAFE_RELEASE(mSession); +} + +void NNTPOperation::setSession(NNTPAsyncSession * session) +{ + MC_SAFE_REPLACE_RETAIN(NNTPAsyncSession, mSession, session); +#if __APPLE__ + dispatch_queue_t queue; + if (session != NULL) { + queue = session->dispatchQueue(); + } + else { + queue = dispatch_get_main_queue(); + } + setCallbackDispatchQueue(queue); +#endif +} + +NNTPAsyncSession * NNTPOperation::session() +{ + return mSession; +} + +void NNTPOperation::setNNTPCallback(NNTPOperationCallback * callback) +{ + mPopCallback = callback; +} + +NNTPOperationCallback * NNTPOperation::nntpCallback() +{ + return mPopCallback; +} + +void NNTPOperation::setError(ErrorCode error) +{ + mError = error; +} + +ErrorCode NNTPOperation::error() +{ + return mError; +} + +void NNTPOperation::start() +{ + mSession->runOperation(this); +} + +struct progressContext { + unsigned int current; + unsigned int maximum; +}; + +void NNTPOperation::bodyProgress(NNTPSession * session, unsigned int current, unsigned int maximum) +{ + struct progressContext * context = (struct progressContext *) calloc(sizeof(* context), 1); + context->current = current; + context->maximum = maximum; + + retain(); + performMethodOnCallbackThread((Object::Method) &NNTPOperation::bodyProgressOnMainThread, context); +} + +void NNTPOperation::bodyProgressOnMainThread(void * ctx) +{ + if (isCancelled()) { + release(); + return; + } + + struct progressContext * context = (struct progressContext *) ctx; + if (mPopCallback != NULL) { + mPopCallback->bodyProgress(this, context->current, context->maximum); + } + free(context); + release(); +} diff --git a/src/async/nntp/MCNNTPOperation.cpp b/src/async/nntp/MCNNTPOperation.cpp deleted file mode 100644 index 3368ba0e..00000000 --- a/src/async/nntp/MCNNTPOperation.cpp +++ /dev/null @@ -1,104 +0,0 @@ -// -// MCNNTPOperation.cpp -// mailcore2 -// -// Created by Robert Widmann on 8/13/14. -// Copyright (c) 2014 MailCore. All rights reserved. -// - -#include "MCNNTPOperation.h" - -#include - -#include "MCNNTPSession.h" -#include "MCNNTPAsyncSession.h" -#include "MCNNTPOperationCallback.h" - -using namespace mailcore; - -NNTPOperation::NNTPOperation() -{ - mSession = NULL; - mPopCallback = NULL; - mError = ErrorNone; -} - -NNTPOperation::~NNTPOperation() -{ - MC_SAFE_RELEASE(mSession); -} - -void NNTPOperation::setSession(NNTPAsyncSession * session) -{ - MC_SAFE_REPLACE_RETAIN(NNTPAsyncSession, mSession, session); -#if __APPLE__ - dispatch_queue_t queue; - if (session != NULL) { - queue = session->dispatchQueue(); - } - else { - queue = dispatch_get_main_queue(); - } - setCallbackDispatchQueue(queue); -#endif -} - -NNTPAsyncSession * NNTPOperation::session() -{ - return mSession; -} - -void NNTPOperation::setNNTPCallback(NNTPOperationCallback * callback) -{ - mPopCallback = callback; -} - -NNTPOperationCallback * NNTPOperation::nntpCallback() -{ - return mPopCallback; -} - -void NNTPOperation::setError(ErrorCode error) -{ - mError = error; -} - -ErrorCode NNTPOperation::error() -{ - return mError; -} - -void NNTPOperation::start() -{ - mSession->runOperation(this); -} - -struct progressContext { - unsigned int current; - unsigned int maximum; -}; - -void NNTPOperation::bodyProgress(NNTPSession * session, unsigned int current, unsigned int maximum) -{ - struct progressContext * context = (struct progressContext *) calloc(sizeof(* context), 1); - context->current = current; - context->maximum = maximum; - - retain(); - performMethodOnCallbackThread((Object::Method) &NNTPOperation::bodyProgressOnMainThread, context); -} - -void NNTPOperation::bodyProgressOnMainThread(void * ctx) -{ - if (isCancelled()) { - release(); - return; - } - - struct progressContext * context = (struct progressContext *) ctx; - if (mPopCallback != NULL) { - mPopCallback->bodyProgress(this, context->current, context->maximum); - } - free(context); - release(); -} -- cgit v1.2.3