aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rwxr-xr-xbuild-mac/mailcore2.xcodeproj/project.pbxproj12
-rw-r--r--src/async/nntp/MCNNTPAsyncSession.cpp13
-rw-r--r--src/async/nntp/MCNNTPAsyncSession.h5
-rw-r--r--src/async/nntp/MCNNTPFetchMessageOperation.cpp10
-rw-r--r--src/async/nntp/MCNNTPFetchMessageOperation.h4
-rw-r--r--src/async/nntp/MCNNTPFetchMessagesOperation.cpp2
-rw-r--r--src/core/nntp/MCNNTPSession.cpp22
-rw-r--r--src/core/nntp/MCNNTPSession.h8
-rw-r--r--src/objc/nntp/MCONNTP.h2
-rw-r--r--src/objc/nntp/MCONNTPSession.h12
-rw-r--r--src/objc/nntp/MCONNTPSession.mm4
11 files changed, 68 insertions, 26 deletions
diff --git a/build-mac/mailcore2.xcodeproj/project.pbxproj b/build-mac/mailcore2.xcodeproj/project.pbxproj
index 62cd28c6..5cb37d9d 100755
--- a/build-mac/mailcore2.xcodeproj/project.pbxproj
+++ b/build-mac/mailcore2.xcodeproj/project.pbxproj
@@ -19,6 +19,12 @@
8416A99E17F284F400B3C7DA /* MCOSMTPNoopOperation.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8416A99C17F284F400B3C7DA /* MCOSMTPNoopOperation.mm */; };
8416A9A117F2871D00B3C7DA /* MCOIMAPNoopOperation.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8416A9A017F2871D00B3C7DA /* MCOIMAPNoopOperation.mm */; };
8416A9A217F2871D00B3C7DA /* MCOIMAPNoopOperation.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8416A9A017F2871D00B3C7DA /* MCOIMAPNoopOperation.mm */; };
+ 84391342199C3AA800FEFCDD /* MCONNTPListNewsgroupsOperation.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 84D73789199C0260005124E5 /* MCONNTPListNewsgroupsOperation.h */; };
+ 84391343199C3AAA00FEFCDD /* MCONNTPListNewsgroupsOperation.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 84D73789199C0260005124E5 /* MCONNTPListNewsgroupsOperation.h */; };
+ 84391344199C3AB200FEFCDD /* MCONNTPDisconnectOperation.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 84D7378D199C02A8005124E5 /* MCONNTPDisconnectOperation.h */; };
+ 84391345199C3AB400FEFCDD /* MCONNTPDisconnectOperation.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 84D7378D199C02A8005124E5 /* MCONNTPDisconnectOperation.h */; };
+ 84391346199C3ABB00FEFCDD /* MCONNTPGroupInfo.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 84D73791199C0511005124E5 /* MCONNTPGroupInfo.h */; };
+ 84391347199C3ABD00FEFCDD /* MCONNTPGroupInfo.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 84D73791199C0511005124E5 /* MCONNTPGroupInfo.h */; };
849189A118C93FB7002063A3 /* MCNNTPSession.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8491899F18C93FB7002063A3 /* MCNNTPSession.cpp */; };
849189A218C93FB7002063A3 /* MCNNTPSession.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8491899F18C93FB7002063A3 /* MCNNTPSession.cpp */; };
849189A318C94023002063A3 /* MCNNTP.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 8491899C18C93F92002063A3 /* MCNNTP.h */; };
@@ -877,9 +883,12 @@
84E65535199BE2C300EC8CC4 /* MCNNTPGroupInfo.h in CopyFiles */,
943F1AA017D9736100F0C798 /* MCIMAPConnectOperation.h in CopyFiles */,
4BE4029217B548D900ECC5E4 /* MCIMAPQuotaOperation.h in CopyFiles */,
+ 84391342199C3AA800FEFCDD /* MCONNTPListNewsgroupsOperation.h in CopyFiles */,
4BE4029117B548B900ECC5E4 /* MCOIMAPQuotaOperation.h in CopyFiles */,
84D7374C199BFB9C005124E5 /* MCNNTPFetchHeaderOperation.h in CopyFiles */,
+ 84391345199C3AB400FEFCDD /* MCONNTPDisconnectOperation.h in CopyFiles */,
C69BA85E17DEFD9F00D601B7 /* NSIndexSet+MCO.h in CopyFiles */,
+ 84391346199C3ABB00FEFCDD /* MCONNTPGroupInfo.h in CopyFiles */,
84D7373A199BF81D005124E5 /* MCNNTPOperation.h in CopyFiles */,
84D73753199BFBE6005124E5 /* MCNNTPCheckAccountOperation.h in CopyFiles */,
84D73748199BFACA005124E5 /* MCNNTPAsyncSession.h in CopyFiles */,
@@ -1099,8 +1108,11 @@
84D73785199C0117005124E5 /* MCONNTPFetchHeaderOperation.h in CopyFiles */,
84D73739199BF81A005124E5 /* MCNNTPOperation.h in CopyFiles */,
84D73787199C011A005124E5 /* MCONNTPFetchMessagesOperation.h in CopyFiles */,
+ 84391344199C3AB200FEFCDD /* MCONNTPDisconnectOperation.h in CopyFiles */,
+ 84391343199C3AAA00FEFCDD /* MCONNTPListNewsgroupsOperation.h in CopyFiles */,
84D73788199C011C005124E5 /* MCONNTPMessageInfo.h in CopyFiles */,
84D73786199C0118005124E5 /* MCONNTPFetchMessageOperation.h in CopyFiles */,
+ 84391347199C3ABD00FEFCDD /* MCONNTPGroupInfo.h in CopyFiles */,
84D73749199BFACF005124E5 /* MCNNTPAsyncSession.h in CopyFiles */,
84D73752199BFBE3005124E5 /* MCNNTPCheckAccountOperation.h in CopyFiles */,
4B3C1BE217ABFF7C008BBF4C /* MCOIMAPQuotaOperation.h in CopyFiles */,
diff --git a/src/async/nntp/MCNNTPAsyncSession.cpp b/src/async/nntp/MCNNTPAsyncSession.cpp
index 4aa9b906..ba3b630b 100644
--- a/src/async/nntp/MCNNTPAsyncSession.cpp
+++ b/src/async/nntp/MCNNTPAsyncSession.cpp
@@ -171,15 +171,26 @@ NNTPFetchHeaderOperation * NNTPAsyncSession::fetchHeaderOperation(unsigned int i
return op;
}
-NNTPFetchMessageOperation * NNTPAsyncSession::fetchMessageOperation(unsigned int index)
+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()
{
diff --git a/src/async/nntp/MCNNTPAsyncSession.h b/src/async/nntp/MCNNTPAsyncSession.h
index ad2ee699..9c214b93 100644
--- a/src/async/nntp/MCNNTPAsyncSession.h
+++ b/src/async/nntp/MCNNTPAsyncSession.h
@@ -9,6 +9,7 @@
namespace mailcore {
class NNTPOperation;
+ class NNTPMessageInfo;
class NNTPSession;
class NNTPFetchHeaderOperation;
class NNTPFetchMessageOperation;
@@ -54,8 +55,10 @@ namespace mailcore {
virtual NNTPFetchMessagesOperation * fetchMessagesOperation(String * group);
virtual NNTPFetchHeaderOperation * fetchHeaderOperation(unsigned int index);
+ virtual NNTPFetchHeaderOperation * fetchHeaderOperation(NNTPMessageInfo * msg);
- virtual NNTPFetchMessageOperation * fetchMessageOperation(unsigned int index);
+ virtual NNTPFetchMessageOperation * fetchArticleOperation(String *groupName, unsigned int index);
+ virtual NNTPFetchMessageOperation * fetchArticleOperation(String *groupName, NNTPMessageInfo * msg);
virtual NNTPListNewsgroupsOperation * listAllNewsgroupsOperation();
virtual NNTPListNewsgroupsOperation * listSubscribedNewsgroupsOperation();
diff --git a/src/async/nntp/MCNNTPFetchMessageOperation.cpp b/src/async/nntp/MCNNTPFetchMessageOperation.cpp
index 3610a51e..2fe02f37 100644
--- a/src/async/nntp/MCNNTPFetchMessageOperation.cpp
+++ b/src/async/nntp/MCNNTPFetchMessageOperation.cpp
@@ -24,6 +24,14 @@ 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;
@@ -42,7 +50,7 @@ Data * NNTPFetchMessageOperation::data()
void NNTPFetchMessageOperation::main()
{
ErrorCode error;
- mData = session()->session()->fetchMessage(mMessageIndex, this, &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
index f1bb0a65..d038a62f 100644
--- a/src/async/nntp/MCNNTPFetchMessageOperation.h
+++ b/src/async/nntp/MCNNTPFetchMessageOperation.h
@@ -20,6 +20,9 @@ namespace mailcore {
NNTPFetchMessageOperation();
virtual ~NNTPFetchMessageOperation();
+ virtual void setGroupName(String * groupName);
+ virtual String * groupName();
+
virtual void setMessageIndex(unsigned int messageIndex);
virtual unsigned int messageIndex();
@@ -29,6 +32,7 @@ namespace mailcore {
virtual void main();
private:
+ String * mGroupName;
unsigned int mMessageIndex;
Data * mData;
diff --git a/src/async/nntp/MCNNTPFetchMessagesOperation.cpp b/src/async/nntp/MCNNTPFetchMessagesOperation.cpp
index 03a91510..0e0fc239 100644
--- a/src/async/nntp/MCNNTPFetchMessagesOperation.cpp
+++ b/src/async/nntp/MCNNTPFetchMessagesOperation.cpp
@@ -43,7 +43,7 @@ Array * NNTPFetchMessagesOperation::messages()
void NNTPFetchMessagesOperation::main()
{
ErrorCode error;
- mMessages = session()->session()->fetchMessages(mGroupName, &error);
+ mMessages = session()->session()->fetchArticles(mGroupName, &error);
setError(error);
MC_SAFE_RETAIN(mMessages);
}
diff --git a/src/core/nntp/MCNNTPSession.cpp b/src/core/nntp/MCNNTPSession.cpp
index b8a0cf38..bad1ebb4 100644
--- a/src/core/nntp/MCNNTPSession.cpp
+++ b/src/core/nntp/MCNNTPSession.cpp
@@ -436,7 +436,7 @@ MessageHeader * NNTPSession::fetchHeader(NNTPMessageInfo * msg, ErrorCode * pErr
return fetchHeader(msg->index(), pError);
}
-Data * NNTPSession::fetchMessage(unsigned int index, NNTPProgressCallback * callback, ErrorCode * pError)
+Data * NNTPSession::fetchArticle(String *groupName, unsigned int index, NNTPProgressCallback * callback, ErrorCode * pError)
{
int r;
char * content;
@@ -445,8 +445,14 @@ Data * NNTPSession::fetchMessage(unsigned int index, NNTPProgressCallback * call
MCLog("fetch article at index %u", index);
loginIfNeeded(pError);
- if (* pError != ErrorNone)
+ if (* pError != ErrorNone) {
return NULL;
+ }
+
+ selectGroup(groupName, pError);
+ if (* pError != ErrorNone) {
+ return NULL;
+ }
r = newsnntp_article(mNNTP, index, &content, &content_len);
if (r == NEWSNNTP_ERROR_STREAM) {
@@ -466,22 +472,22 @@ Data * NNTPSession::fetchMessage(unsigned int index, NNTPProgressCallback * call
return result;
}
-Data * NNTPSession::fetchMessage(NNTPMessageInfo * msg, NNTPProgressCallback * callback, ErrorCode * pError)
+Data * NNTPSession::fetchArticle(String *groupName, NNTPMessageInfo * msg, NNTPProgressCallback * callback, ErrorCode * pError)
{
- return fetchMessage(msg->index(), callback, pError);
+ return fetchArticle(groupName, msg->index(), callback, pError);
}
-Array * NNTPSession::fetchMessages(String * groupname, ErrorCode * pError)
+Array * NNTPSession::fetchArticles(String * groupName, ErrorCode * pError)
{
int r;
clist * msg_list;
- select(groupname, pError);
+ selectGroup(groupName, pError);
if (* pError != ErrorNone) {
return NULL;
}
- r = newsnntp_listgroup(mNNTP, groupname->UTF8Characters(), &msg_list);
+ r = newsnntp_listgroup(mNNTP, groupName->UTF8Characters(), &msg_list);
if (r == MAILPOP3_ERROR_STREAM) {
* pError = ErrorConnection;
return NULL;
@@ -514,7 +520,7 @@ Array * NNTPSession::fetchMessages(String * groupname, ErrorCode * pError)
return result;
}
-void NNTPSession::select(String * folder, ErrorCode * pError)
+void NNTPSession::selectGroup(String * folder, ErrorCode * pError)
{
int r;
struct newsnntp_group_info * info;
diff --git a/src/core/nntp/MCNNTPSession.h b/src/core/nntp/MCNNTPSession.h
index ac290679..6f8bf73a 100644
--- a/src/core/nntp/MCNNTPSession.h
+++ b/src/core/nntp/MCNNTPSession.h
@@ -51,15 +51,14 @@ namespace mailcore {
virtual MessageHeader * fetchHeader(unsigned int index, ErrorCode * pError);
virtual MessageHeader * fetchHeader(NNTPMessageInfo * msg, ErrorCode * pError);
- virtual Array * /* NNTPMessageInfo */ fetchMessages(String * groupname, ErrorCode * pError);
+ virtual Array * /* NNTPMessageInfo */ fetchArticles(String * groupname, ErrorCode * pError);
- Data * fetchMessage(unsigned int index, NNTPProgressCallback * callback, ErrorCode * pError);
- Data * fetchMessage(NNTPMessageInfo * msg, NNTPProgressCallback * callback, ErrorCode * pError);
+ Data * fetchArticle(String *groupName, unsigned int index, NNTPProgressCallback * callback, ErrorCode * pError);
+ Data * fetchArticle(String *groupName, NNTPMessageInfo * msg, NNTPProgressCallback * callback, ErrorCode * pError);
virtual void setConnectionLogger(ConnectionLogger * logger);
virtual ConnectionLogger * connectionLogger();
- virtual void select(String * folder, ErrorCode * pError);
private:
String * mHostname;
unsigned int mPort;
@@ -82,6 +81,7 @@ namespace mailcore {
void loginIfNeeded(ErrorCode * pError);
void readerIfNeeded(ErrorCode * pError);
void listIfNeeded(ErrorCode * pError);
+ void selectGroup(String * folder, ErrorCode * pError);
};
}
diff --git a/src/objc/nntp/MCONNTP.h b/src/objc/nntp/MCONNTP.h
index d81e8f26..f96f296c 100644
--- a/src/objc/nntp/MCONNTP.h
+++ b/src/objc/nntp/MCONNTP.h
@@ -10,7 +10,7 @@
#define MAILCORE_MCONNTP_H
-#include <MailCore/MCONNTPAsyncSession.h>
+#include <MailCore/MCONNTPSession.h>
#include <MailCore/MCONNTPOperation.h>
#include <MailCore/MCONNTPFetchHeaderOperation.h>
#include <MailCore/MCONNTPFetchMessageOperation.h>
diff --git a/src/objc/nntp/MCONNTPSession.h b/src/objc/nntp/MCONNTPSession.h
index 7f9f78cd..214e9d9d 100644
--- a/src/objc/nntp/MCONNTPSession.h
+++ b/src/objc/nntp/MCONNTPSession.h
@@ -89,19 +89,18 @@
/**
Returns an operation that will fetch the content of the given message.
- MCONNTPFetchMessageOperation * op = [session fetchMessageOperationWithIndex:idx];
+ MCONNTPFetchMessageOperation * op = [session fetchMessageOperationWithIndex:idx inGroup:@"Group"];
[op start:^(NSError * error, NSData * messageData) {
// messageData is the RFC 822 formatted message data.
}];
*/
-- (MCONNTPFetchMessageOperation *) fetchMessageOperationWithIndex:(unsigned int)index;
+- (MCONNTPFetchMessageOperation *) fetchArticleOperationWithIndex:(unsigned int)index inGroup:(NSString *)group;
/**
Returns an operation that will list all available newsgroups.
MCONNTPListNewsgroupsOperation * op = [session listAllNewsgroupsOperation];
- [op start:^(NSError * error, NSData * messageData) {
- // messageData is the RFC 822 formatted message data.
+ [op start:^(NSError * error, NSArray * subscribedGroups) {
}];
*/
- (MCONNTPListNewsgroupsOperation *) listAllNewsgroupsOperation;
@@ -109,9 +108,8 @@
/**
Returns an operation that will list all newsgroups subscribed to by the user.
- MCONNTPListNewsgroupsOperation * op = [session listAllNewsgroupsOperation];
- [op start:^(NSError * error, NSData * messageData) {
- // messageData is the RFC 822 formatted message data.
+ MCONNTPListNewsgroupsOperation * op = [session listSubscribedNewsgroupsOperation];
+ [op start:^(NSError * error, NSArray * subscribedGroups) {
}];
*/
- (MCONNTPListNewsgroupsOperation *) listSubscribedNewsgroupsOperation;
diff --git a/src/objc/nntp/MCONNTPSession.mm b/src/objc/nntp/MCONNTPSession.mm
index f300d97c..eb7ce4ab 100644
--- a/src/objc/nntp/MCONNTPSession.mm
+++ b/src/objc/nntp/MCONNTPSession.mm
@@ -133,9 +133,9 @@ MCO_OBJC_SYNTHESIZE_SCALAR(dispatch_queue_t, dispatch_queue_t, setDispatchQueue,
return MCO_TO_OBJC_OP(coreOp);
}
-- (MCONNTPFetchMessageOperation *) fetchMessageOperationWithIndex:(unsigned int)index;
+- (MCONNTPFetchMessageOperation *) fetchArticleOperationWithIndex:(unsigned int)index inGroup:(NSString *)group
{
- mailcore::NNTPFetchMessageOperation * coreOp = MCO_NATIVE_INSTANCE->fetchMessageOperation(index);
+ mailcore::NNTPFetchMessageOperation * coreOp = MCO_NATIVE_INSTANCE->fetchArticleOperation(MCO_FROM_OBJC(mailcore::String, group), index);
return MCO_TO_OBJC_OP(coreOp);
}