diff options
-rw-r--r-- | src/async/nntp/MCNNTPAsyncSession.cc | 2 | ||||
-rw-r--r-- | src/async/nntp/MCNNTPAsyncSession.h | 2 | ||||
-rw-r--r-- | src/async/nntp/MCNNTPFetchArticlesOperation.cc | 2 | ||||
-rw-r--r-- | src/core/nntp/MCNNTPSession.cc | 34 | ||||
-rw-r--r-- | src/core/nntp/MCNNTPSession.h | 6 | ||||
-rw-r--r-- | src/objc/nntp/MCONNTPSession.h | 4 | ||||
-rw-r--r-- | src/objc/nntp/MCONNTPSession.mm | 4 |
7 files changed, 44 insertions, 10 deletions
diff --git a/src/async/nntp/MCNNTPAsyncSession.cc b/src/async/nntp/MCNNTPAsyncSession.cc index 833bf4d5..40993567 100644 --- a/src/async/nntp/MCNNTPAsyncSession.cc +++ b/src/async/nntp/MCNNTPAsyncSession.cc @@ -153,7 +153,7 @@ bool NNTPAsyncSession::isCheckCertificateEnabled() return mSession->isCheckCertificateEnabled(); } -MCNNTPFetchArticlesOperation * NNTPAsyncSession::fetchArticlesOperation(String * group) +MCNNTPFetchArticlesOperation * NNTPAsyncSession::fetchAllArticlesOperation(String * group) { MCNNTPFetchArticlesOperation * op = new MCNNTPFetchArticlesOperation(); op->setSession(this); diff --git a/src/async/nntp/MCNNTPAsyncSession.h b/src/async/nntp/MCNNTPAsyncSession.h index 66f0cc0d..c0d93fb2 100644 --- a/src/async/nntp/MCNNTPAsyncSession.h +++ b/src/async/nntp/MCNNTPAsyncSession.h @@ -51,7 +51,7 @@ namespace mailcore { virtual dispatch_queue_t dispatchQueue(); #endif - virtual MCNNTPFetchArticlesOperation * fetchArticlesOperation(String * group); + virtual MCNNTPFetchArticlesOperation * fetchAllArticlesOperation(String * group); virtual NNTPFetchHeaderOperation * fetchHeaderOperation(String * groupName, unsigned int index); diff --git a/src/async/nntp/MCNNTPFetchArticlesOperation.cc b/src/async/nntp/MCNNTPFetchArticlesOperation.cc index 39446f35..ddca9f13 100644 --- a/src/async/nntp/MCNNTPFetchArticlesOperation.cc +++ b/src/async/nntp/MCNNTPFetchArticlesOperation.cc @@ -43,7 +43,7 @@ IndexSet * MCNNTPFetchArticlesOperation::articles() void MCNNTPFetchArticlesOperation::main() { ErrorCode error; - mArticles = session()->session()->fetchArticles(mGroupName, &error); + mArticles = session()->session()->fetchAllArticles(mGroupName, &error); setError(error); MC_SAFE_RETAIN(mArticles); } diff --git a/src/core/nntp/MCNNTPSession.cc b/src/core/nntp/MCNNTPSession.cc index 02db197e..66b8dadc 100644 --- a/src/core/nntp/MCNNTPSession.cc +++ b/src/core/nntp/MCNNTPSession.cc @@ -466,7 +466,7 @@ Data * NNTPSession::fetchArticle(String *groupName, unsigned int index, NNTPProg return result; } -IndexSet * NNTPSession::fetchArticles(String * groupName, ErrorCode * pError) +IndexSet * NNTPSession::fetchAllArticles(String * groupName, ErrorCode * pError) { int r; clist * msg_list; @@ -506,6 +506,38 @@ IndexSet * NNTPSession::fetchArticles(String * groupName, ErrorCode * pError) return result; } +Array * NNTPSession::fetchOverArticlesInRange(Range range, String * groupName, ErrorCode * pError) +{ + int r; + clist * msg_list; + + selectGroup(groupName, pError); + if (* pError != ErrorNone) { + return NULL; + } + r = newsnntp_xover_range(mNNTP, range.location, range.location + range.length, &msg_list); + if (r == NEWSNNTP_ERROR_STREAM) { + * pError = ErrorConnection; + return NULL; + } + else if (r != NEWSNNTP_NO_ERROR) { + * pError = ErrorFetchMessageList; + return NULL; + } + + clistiter * iter; + for(iter = clist_begin(msg_list) ;iter != NULL ; iter = clist_next(iter)) { + struct newsnntp_xover_resp_item * item; + + item = clist_content(cur); + if (!msg_info) { + continue; + } + + result->addIndex(*msg_info); + } +} + void NNTPSession::selectGroup(String * folder, ErrorCode * pError) { int r; diff --git a/src/core/nntp/MCNNTPSession.h b/src/core/nntp/MCNNTPSession.h index a6fb511c..47d78a46 100644 --- a/src/core/nntp/MCNNTPSession.h +++ b/src/core/nntp/MCNNTPSession.h @@ -48,8 +48,10 @@ namespace mailcore { virtual Array * listSubscribedNewsgroups(ErrorCode * pError); virtual MessageHeader * fetchHeader(String *groupName, unsigned int index, ErrorCode * pError); - - virtual IndexSet * fetchArticles(String * groupname, ErrorCode * pError); + + virtual IndexSet * fetchAllArticles(String * groupname, ErrorCode * pError); + + virtual Array * fetchOverArticlesInRange(Range range, String * groupname, ErrorCode * pError); Data * fetchArticle(String *groupName, unsigned int index, NNTPProgressCallback * callback, ErrorCode * pError); diff --git a/src/objc/nntp/MCONNTPSession.h b/src/objc/nntp/MCONNTPSession.h index 6712d9e4..8d12608b 100644 --- a/src/objc/nntp/MCONNTPSession.h +++ b/src/objc/nntp/MCONNTPSession.h @@ -68,11 +68,11 @@ /** Returns an operation that will fetch the list of article numbers. - MCONNTPFetchArticlesOperation * op = [session fetchArticlesOperation]; + MCONNTPFetchArticlesOperation * op = [session fetchAllArticlesOperation]; [op start:^(NSError * error, MCOIndexSet * articles) { }]; */ -- (MCONNTPFetchArticlesOperation *) fetchArticlesOperation:(NSString *)group; +- (MCONNTPFetchArticlesOperation *) fetchAllArticlesOperation:(NSString *)group; /** Returns an operation that will fetch the header of the given message. diff --git a/src/objc/nntp/MCONNTPSession.mm b/src/objc/nntp/MCONNTPSession.mm index e661eb65..d7db82b2 100644 --- a/src/objc/nntp/MCONNTPSession.mm +++ b/src/objc/nntp/MCONNTPSession.mm @@ -121,9 +121,9 @@ MCO_OBJC_SYNTHESIZE_SCALAR(dispatch_queue_t, dispatch_queue_t, setDispatchQueue, return result; } -- (MCONNTPFetchArticlesOperation *) fetchArticlesOperation:(NSString *)group +- (MCONNTPFetchArticlesOperation *) fetchAllArticlesOperation:(NSString *)group { - mailcore::MCNNTPFetchArticlesOperation * coreOp = MCO_NATIVE_INSTANCE->fetchArticlesOperation(MCO_FROM_OBJC(mailcore::String, group)); + mailcore::MCNNTPFetchArticlesOperation * coreOp = MCO_NATIVE_INSTANCE->fetchAllArticlesOperation(MCO_FROM_OBJC(mailcore::String, group)); return MCO_TO_OBJC_OP(coreOp); } |