diff options
Diffstat (limited to 'src/async')
-rw-r--r-- | src/async/nntp/MCAsyncNNTP.h | 1 | ||||
-rw-r--r-- | src/async/nntp/MCNNTPAsyncSession.cc | 25 | ||||
-rw-r--r-- | src/async/nntp/MCNNTPAsyncSession.h | 8 | ||||
-rw-r--r-- | src/async/nntp/MCNNTPFetchOverviewOperation.cc | 68 | ||||
-rw-r--r-- | src/async/nntp/MCNNTPFetchOverviewOperation.h | 45 |
5 files changed, 143 insertions, 4 deletions
diff --git a/src/async/nntp/MCAsyncNNTP.h b/src/async/nntp/MCAsyncNNTP.h index 56509ff8..618cd3d0 100644 --- a/src/async/nntp/MCAsyncNNTP.h +++ b/src/async/nntp/MCAsyncNNTP.h @@ -16,6 +16,7 @@ #include <MailCore/MCNNTPFetchArticleOperation.h> #include <MailCore/MCNNTPFetchArticlesOperation.h> #include <MailCore/MCNNTPListNewsgroupsOperation.h> +#include <MailCore/MCNNTPFetchOverviewOperation.h> #include <MailCore/MCNNTPOperationCallback.h> #endif diff --git a/src/async/nntp/MCNNTPAsyncSession.cc b/src/async/nntp/MCNNTPAsyncSession.cc index a290b8d3..f250a23e 100644 --- a/src/async/nntp/MCNNTPAsyncSession.cc +++ b/src/async/nntp/MCNNTPAsyncSession.cc @@ -13,6 +13,7 @@ #include "MCNNTPFetchArticleOperation.h" #include "MCNNTPFetchArticlesOperation.h" #include "MCNNTPListNewsgroupsOperation.h" +#include "MCNNTPFetchOverviewOperation.h" #include "MCNNTPCheckAccountOperation.h" #include "MCNNTPDisconnectOperation.h" #include "MCOperationQueueCallback.h" @@ -153,9 +154,9 @@ bool NNTPAsyncSession::isCheckCertificateEnabled() return mSession->isCheckCertificateEnabled(); } -MCNNTPFetchArticlesOperation * NNTPAsyncSession::fetchAllArticlesOperation(String * group) +NNTPFetchArticlesOperation * NNTPAsyncSession::fetchAllArticlesOperation(String * group) { - MCNNTPFetchArticlesOperation * op = new MCNNTPFetchArticlesOperation(); + NNTPFetchArticlesOperation * op = new NNTPFetchArticlesOperation(); op->setSession(this); op->setGroupName(group); op->autorelease(); @@ -182,6 +183,26 @@ NNTPFetchArticleOperation * NNTPAsyncSession::fetchArticleOperation(String * gro return op; } +NNTPFetchArticleOperation * NNTPAsyncSession::fetchArticleByMessageIDOperation(String *groupName, String *messageID) +{ + NNTPFetchArticleOperation * op = new NNTPFetchArticleOperation(); + op->setSession(this); + op->setGroupName(groupName); + op->setMessageID(messageID); + op->autorelease(); + return op; +} + +NNTPFetchOverviewOperation * NNTPAsyncSession::fetchOverviewOperationWithIndexes(String * groupName, IndexSet * indexes) +{ + NNTPFetchOverviewOperation * op = new NNTPFetchOverviewOperation(); + op->setSession(this); + op->setGroupName(groupName); + op->setIndexes(indexes); + op->autorelease(); + return op; +} + NNTPListNewsgroupsOperation * NNTPAsyncSession::listAllNewsgroupsOperation() { NNTPListNewsgroupsOperation * op = new NNTPListNewsgroupsOperation(); diff --git a/src/async/nntp/MCNNTPAsyncSession.h b/src/async/nntp/MCNNTPAsyncSession.h index d0fea2d0..b0686614 100644 --- a/src/async/nntp/MCNNTPAsyncSession.h +++ b/src/async/nntp/MCNNTPAsyncSession.h @@ -12,7 +12,8 @@ namespace mailcore { class NNTPSession; class NNTPFetchHeaderOperation; class NNTPFetchArticleOperation; - class MCNNTPFetchArticlesOperation; + class NNTPFetchArticlesOperation; + class NNTPFetchOverviewOperation; class NNTPListNewsgroupsOperation; class NNTPOperationQueueCallback; class NNTPConnectionLogger; @@ -51,11 +52,14 @@ namespace mailcore { virtual dispatch_queue_t dispatchQueue(); #endif - virtual MCNNTPFetchArticlesOperation * fetchAllArticlesOperation(String * group); + virtual NNTPFetchArticlesOperation * fetchAllArticlesOperation(String * group); virtual NNTPFetchHeaderOperation * fetchHeaderOperation(String * groupName, unsigned int index); virtual NNTPFetchArticleOperation * fetchArticleOperation(String *groupName, unsigned int index); + virtual NNTPFetchArticleOperation * fetchArticleByMessageIDOperation(String * groupname, String * messageID); + + virtual NNTPFetchOverviewOperation * fetchOverviewOperationWithIndexes(String * groupName, IndexSet * indexes); virtual NNTPListNewsgroupsOperation * listAllNewsgroupsOperation(); virtual NNTPListNewsgroupsOperation * listDefaultNewsgroupsOperation(); diff --git a/src/async/nntp/MCNNTPFetchOverviewOperation.cc b/src/async/nntp/MCNNTPFetchOverviewOperation.cc new file mode 100644 index 00000000..9bd47fba --- /dev/null +++ b/src/async/nntp/MCNNTPFetchOverviewOperation.cc @@ -0,0 +1,68 @@ +// +// NNTPFetchOverviewOperation.cpp +// mailcore2 +// +// Created by Robert Widmann on 10/21/14. +// Copyright (c) 2014 MailCore. All rights reserved. +// + +#include "MCNNTPFetchOverviewOperation.h" + +#include "MCNNTPAsyncSession.h" +#include "MCNNTPSession.h" + +using namespace mailcore; + +NNTPFetchOverviewOperation::NNTPFetchOverviewOperation() +{ + mArticles = NULL; + mIndexes = NULL; + mGroupName = NULL; +} + +NNTPFetchOverviewOperation::~NNTPFetchOverviewOperation() +{ + MC_SAFE_RELEASE(mIndexes); + MC_SAFE_RELEASE(mGroupName); +} + +void NNTPFetchOverviewOperation::setIndexes(IndexSet * indexes) +{ + MC_SAFE_REPLACE_RETAIN(IndexSet, mIndexes, indexes); +} + +IndexSet * NNTPFetchOverviewOperation::indexes() +{ + return mIndexes; +} + +void NNTPFetchOverviewOperation::setGroupName(String * groupname) +{ + MC_SAFE_REPLACE_COPY(String, mGroupName, groupname); +} + +String * NNTPFetchOverviewOperation::groupName() +{ + return mGroupName; +} + +Array * NNTPFetchOverviewOperation::articles() { + return mArticles; +} + +void NNTPFetchOverviewOperation::main() +{ + ErrorCode error; + mArticles = Array::array(); + for(unsigned int i = 0 ; i < mIndexes->rangesCount() ; i ++) { + Range range = mIndexes->allRanges()[i]; + if (error != ErrorNone) { + setError(error); + mArticles->removeAllObjects(); + return; + } + mArticles->addObjectsFromArray(session()->session()->fetchOverArticlesInRange(range, mGroupName, &error)); + } + + setError(error); +} diff --git a/src/async/nntp/MCNNTPFetchOverviewOperation.h b/src/async/nntp/MCNNTPFetchOverviewOperation.h new file mode 100644 index 00000000..0582864d --- /dev/null +++ b/src/async/nntp/MCNNTPFetchOverviewOperation.h @@ -0,0 +1,45 @@ +// +// NNTPFetchOverviewOperation.h +// mailcore2 +// +// Created by Robert Widmann on 10/21/14. +// Copyright (c) 2014 MailCore. All rights reserved. +// + +#ifndef MAILCORE_MCNNTPFETCHOVERVIEWOPERATION_H + +#define MAILCORE_MCNNTPFETCHOVERVIEWOPERATION_H + +#include <MailCore/MCNNTPOperation.h> + +#ifdef __cplusplus + +namespace mailcore { + + class NNTPFetchOverviewOperation : public NNTPOperation { + public: + NNTPFetchOverviewOperation(); + virtual ~NNTPFetchOverviewOperation(); + + virtual void setIndexes(IndexSet * indexes); + virtual IndexSet * indexes(); + + virtual void setGroupName(String * groupName); + virtual String * groupName(); + + virtual Array * articles(); + + public: // subclass behavior + virtual void main(); + + private: + IndexSet * mIndexes; + String * mGroupName; + Array * /* NNTPGroupInfo */ mArticles; + }; + +} + +#endif + +#endif |