aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/async
diff options
context:
space:
mode:
Diffstat (limited to 'src/async')
-rw-r--r--src/async/nntp/MCAsyncNNTP.h1
-rw-r--r--src/async/nntp/MCNNTPAsyncSession.cpp19
-rw-r--r--src/async/nntp/MCNNTPAsyncSession.h4
-rw-r--r--src/async/nntp/MCNNTPSendOperation.cpp58
-rw-r--r--src/async/nntp/MCNNTPSendOperation.h44
5 files changed, 126 insertions, 0 deletions
diff --git a/src/async/nntp/MCAsyncNNTP.h b/src/async/nntp/MCAsyncNNTP.h
index 914cc754..57b80cb8 100644
--- a/src/async/nntp/MCAsyncNNTP.h
+++ b/src/async/nntp/MCAsyncNNTP.h
@@ -18,6 +18,7 @@
#include <MailCore/MCNNTPListNewsgroupsOperation.h>
#include <MailCore/MCNNTPFetchOverviewOperation.h>
#include <MailCore/MCNNTPFetchServerTimeOperation.h>
+#include <MailCore/MCNNTPSendOperation.h>
#include <MailCore/MCNNTPOperationCallback.h>
#endif
diff --git a/src/async/nntp/MCNNTPAsyncSession.cpp b/src/async/nntp/MCNNTPAsyncSession.cpp
index ad74f7a9..ddd4c804 100644
--- a/src/async/nntp/MCNNTPAsyncSession.cpp
+++ b/src/async/nntp/MCNNTPAsyncSession.cpp
@@ -16,6 +16,7 @@
#include "MCNNTPFetchOverviewOperation.h"
#include "MCNNTPCheckAccountOperation.h"
#include "MCNNTPFetchServerTimeOperation.h"
+#include "MCNNTPSendOperation.h"
#include "MCNNTPDisconnectOperation.h"
#include "MCOperationQueueCallback.h"
#include "MCConnectionLogger.h"
@@ -236,6 +237,24 @@ NNTPListNewsgroupsOperation * NNTPAsyncSession::listDefaultNewsgroupsOperation()
return op;
}
+NNTPSendOperation * NNTPAsyncSession::sendMessageOperation(Data * messageData)
+{
+ NNTPSendOperation * op = new NNTPSendOperation();
+ op->setSession(this);
+ op->setMessageData(messageData);
+ op->autorelease();
+ return op;
+}
+
+NNTPSendOperation * NNTPAsyncSession::sendMessageOperation(String * filename)
+{
+ NNTPSendOperation * op = new NNTPSendOperation();
+ op->setSession(this);
+ op->setMessageFilepath(filename);
+ op->autorelease();
+ return op;
+}
+
NNTPOperation * NNTPAsyncSession::disconnectOperation()
{
NNTPDisconnectOperation * op = new NNTPDisconnectOperation();
diff --git a/src/async/nntp/MCNNTPAsyncSession.h b/src/async/nntp/MCNNTPAsyncSession.h
index b3e40ea8..c41066ac 100644
--- a/src/async/nntp/MCNNTPAsyncSession.h
+++ b/src/async/nntp/MCNNTPAsyncSession.h
@@ -16,6 +16,7 @@ namespace mailcore {
class NNTPFetchOverviewOperation;
class NNTPListNewsgroupsOperation;
class NNTPFetchServerTimeOperation;
+ class NNTPSendOperation;
class NNTPOperationQueueCallback;
class NNTPConnectionLogger;
@@ -72,6 +73,9 @@ namespace mailcore {
virtual NNTPListNewsgroupsOperation * listAllNewsgroupsOperation();
virtual NNTPListNewsgroupsOperation * listDefaultNewsgroupsOperation();
+ virtual NNTPSendOperation * sendMessageOperation(Data * messageData);
+ virtual NNTPSendOperation * sendMessageOperation(String * filename);
+
virtual NNTPOperation * disconnectOperation();
virtual NNTPOperation * checkAccountOperation();
diff --git a/src/async/nntp/MCNNTPSendOperation.cpp b/src/async/nntp/MCNNTPSendOperation.cpp
new file mode 100644
index 00000000..d5f27928
--- /dev/null
+++ b/src/async/nntp/MCNNTPSendOperation.cpp
@@ -0,0 +1,58 @@
+//
+// MCNNTPSendOperation.cpp
+// mailcore2
+//
+// Created by Daryle Walker on 2/21/16.
+// Copyright © 2016 MailCore. All rights reserved.
+//
+
+#include "MCNNTPSendOperation.h"
+
+#include "MCNNTPAsyncSession.h"
+#include "MCNNTPSession.h"
+
+using namespace mailcore;
+
+NNTPSendOperation::NNTPSendOperation()
+{
+ mMessageData = NULL;
+ mMessageFilepath = NULL;
+}
+
+NNTPSendOperation::~NNTPSendOperation()
+{
+ MC_SAFE_RELEASE(mMessageFilepath);
+ MC_SAFE_RELEASE(mMessageData);
+}
+
+void NNTPSendOperation::setMessageData(Data * data)
+{
+ MC_SAFE_REPLACE_RETAIN(Data, mMessageData, data);
+}
+
+Data * NNTPSendOperation::messageData()
+{
+ return mMessageData;
+}
+
+void NNTPSendOperation::setMessageFilepath(String * path)
+{
+ MC_SAFE_REPLACE_RETAIN(String, mMessageFilepath, path);
+}
+
+String * NNTPSendOperation::messageFilepath()
+{
+ return mMessageFilepath;
+}
+
+void NNTPSendOperation::main()
+{
+ ErrorCode error;
+ if (mMessageFilepath != NULL) {
+ session()->session()->sendMessage(mMessageFilepath, this, &error);
+ }
+ else {
+ session()->session()->sendMessage(mMessageData, this, &error);
+ }
+ setError(error);
+}
diff --git a/src/async/nntp/MCNNTPSendOperation.h b/src/async/nntp/MCNNTPSendOperation.h
new file mode 100644
index 00000000..d859cd58
--- /dev/null
+++ b/src/async/nntp/MCNNTPSendOperation.h
@@ -0,0 +1,44 @@
+//
+// MCNNTPSendOperation.h
+// mailcore2
+//
+// Created by Daryle Walker on 2/21/16.
+// Copyright © 2016 MailCore. All rights reserved.
+//
+
+#ifndef MAILCORE_MCNNTPSENDOPERATION_H
+
+#define MAILCORE_MCNNTPSENDOPERATION_H
+
+#include <MailCore/MCBaseTypes.h>
+#include <MailCore/MCAbstract.h>
+#include <MailCore/MCNNTPOperation.h>
+
+#ifdef __cplusplus
+
+namespace mailcore {
+
+ class MAILCORE_EXPORT NNTPSendOperation : public NNTPOperation {
+ public:
+ NNTPSendOperation();
+ virtual ~NNTPSendOperation();
+
+ virtual void setMessageData(Data * data);
+ virtual Data * messageData();
+
+ virtual void setMessageFilepath(String * path);
+ virtual String * messageFilepath();
+
+ public: // subclass behavior
+ virtual void main();
+
+ private:
+ Data * mMessageData;
+ String * mMessageFilepath;
+ };
+
+}
+
+#endif
+
+#endif