From 38cae4a0a329da2618c212f545d3d8e10417af72 Mon Sep 17 00:00:00 2001 From: Daryle Walker Date: Thu, 25 Feb 2016 15:10:40 -0500 Subject: Replace NNTP "send" with "post". --- build-mac/mailcore2.xcodeproj/project.pbxproj | 48 ++++----- build-windows/build_headers.list | 4 +- .../mailcore2/mailcore2/mailcore2.vcxproj | 4 +- .../mailcore2/mailcore2/mailcore2.vcxproj.filters | 4 +- src/async/nntp/MCAsyncNNTP.h | 2 +- src/async/nntp/MCNNTPAsyncSession.cpp | 10 +- src/async/nntp/MCNNTPAsyncSession.h | 6 +- src/async/nntp/MCNNTPPostOperation.cpp | 58 +++++++++++ src/async/nntp/MCNNTPPostOperation.h | 44 ++++++++ src/async/nntp/MCNNTPSendOperation.cpp | 58 ----------- src/async/nntp/MCNNTPSendOperation.h | 44 -------- src/cmake/async.cmake | 2 +- src/cmake/objc.cmake | 2 +- src/cmake/public-headers.cmake | 4 +- src/core/nntp/MCNNTPSession.cpp | 6 +- src/core/nntp/MCNNTPSession.h | 4 +- src/objc/nntp/MCONNTP.h | 2 +- src/objc/nntp/MCONNTPPostOperation.h | 37 +++++++ src/objc/nntp/MCONNTPPostOperation.mm | 116 +++++++++++++++++++++ src/objc/nntp/MCONNTPSendOperation.h | 37 ------- src/objc/nntp/MCONNTPSendOperation.mm | 116 --------------------- src/objc/nntp/MCONNTPSession.h | 14 +-- src/objc/nntp/MCONNTPSession.mm | 10 +- 23 files changed, 316 insertions(+), 316 deletions(-) create mode 100644 src/async/nntp/MCNNTPPostOperation.cpp create mode 100644 src/async/nntp/MCNNTPPostOperation.h delete mode 100644 src/async/nntp/MCNNTPSendOperation.cpp delete mode 100644 src/async/nntp/MCNNTPSendOperation.h create mode 100644 src/objc/nntp/MCONNTPPostOperation.h create mode 100644 src/objc/nntp/MCONNTPPostOperation.mm delete mode 100644 src/objc/nntp/MCONNTPSendOperation.h delete mode 100644 src/objc/nntp/MCONNTPSendOperation.mm diff --git a/build-mac/mailcore2.xcodeproj/project.pbxproj b/build-mac/mailcore2.xcodeproj/project.pbxproj index 64058b61..51f4e1ee 100755 --- a/build-mac/mailcore2.xcodeproj/project.pbxproj +++ b/build-mac/mailcore2.xcodeproj/project.pbxproj @@ -962,14 +962,14 @@ DAD28C8C1783CFFC00F2BB8F /* MCHTMLBodyRendererTemplateCallback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DAD28C891783CFFC00F2BB8F /* MCHTMLBodyRendererTemplateCallback.cpp */; }; DAE42E89178F7E1800E0DB8F /* MCOIMAPMessageRenderingOperation.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DA89896B178A47D200F6D90A /* MCOIMAPMessageRenderingOperation.h */; }; DAE42E8A178F7E2200E0DB8F /* MCOIMAPMessageRenderingOperation.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DA89896B178A47D200F6D90A /* MCOIMAPMessageRenderingOperation.h */; }; - F382219F1C7A626700E00721 /* MCNNTPSendOperation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F382219E1C7A626700E00721 /* MCNNTPSendOperation.cpp */; }; - F38221A01C7A626700E00721 /* MCNNTPSendOperation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F382219E1C7A626700E00721 /* MCNNTPSendOperation.cpp */; }; - F38221A31C7AAD8100E00721 /* MCONNTPSendOperation.mm in Sources */ = {isa = PBXBuildFile; fileRef = F38221A21C7AAD8100E00721 /* MCONNTPSendOperation.mm */; }; - F38221A41C7AAD8100E00721 /* MCONNTPSendOperation.mm in Sources */ = {isa = PBXBuildFile; fileRef = F38221A21C7AAD8100E00721 /* MCONNTPSendOperation.mm */; }; - F38221A51C7B629B00E00721 /* MCNNTPSendOperation.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = F382219D1C7A60A800E00721 /* MCNNTPSendOperation.h */; }; - F38221A61C7B62E900E00721 /* MCONNTPSendOperation.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = F38221A11C7AAD8100E00721 /* MCONNTPSendOperation.h */; }; - F38221A71C7B638200E00721 /* MCNNTPSendOperation.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = F382219D1C7A60A800E00721 /* MCNNTPSendOperation.h */; }; - F38221A81C7B63E500E00721 /* MCONNTPSendOperation.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = F38221A11C7AAD8100E00721 /* MCONNTPSendOperation.h */; }; + F382219F1C7A626700E00721 /* MCNNTPPostOperation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F382219E1C7A626700E00721 /* MCNNTPPostOperation.cpp */; }; + F38221A01C7A626700E00721 /* MCNNTPPostOperation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F382219E1C7A626700E00721 /* MCNNTPPostOperation.cpp */; }; + F38221A31C7AAD8100E00721 /* MCONNTPPostOperation.mm in Sources */ = {isa = PBXBuildFile; fileRef = F38221A21C7AAD8100E00721 /* MCONNTPPostOperation.mm */; }; + F38221A41C7AAD8100E00721 /* MCONNTPPostOperation.mm in Sources */ = {isa = PBXBuildFile; fileRef = F38221A21C7AAD8100E00721 /* MCONNTPPostOperation.mm */; }; + F38221A51C7B629B00E00721 /* MCNNTPPostOperation.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = F382219D1C7A60A800E00721 /* MCNNTPPostOperation.h */; }; + F38221A61C7B62E900E00721 /* MCONNTPPostOperation.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = F38221A11C7AAD8100E00721 /* MCONNTPPostOperation.h */; }; + F38221A71C7B638200E00721 /* MCNNTPPostOperation.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = F382219D1C7A60A800E00721 /* MCNNTPPostOperation.h */; }; + F38221A81C7B63E500E00721 /* MCONNTPPostOperation.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = F38221A11C7AAD8100E00721 /* MCONNTPPostOperation.h */; }; F87F190C16BB62B00012652F /* MCOIMAPFetchFoldersOperation.mm in Sources */ = {isa = PBXBuildFile; fileRef = F87F190B16BB62B00012652F /* MCOIMAPFetchFoldersOperation.mm */; }; F8EA941716BB1C9D0011AC6F /* MCOIMAPSession.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = F8EA941416BAED6E0011AC6F /* MCOIMAPSession.h */; }; /* End PBXBuildFile section */ @@ -1035,8 +1035,8 @@ dstPath = include/MailCore; dstSubfolderSpec = 16; files = ( - F38221A81C7B63E500E00721 /* MCONNTPSendOperation.h in CopyFiles */, - F38221A71C7B638200E00721 /* MCNNTPSendOperation.h in CopyFiles */, + F38221A81C7B63E500E00721 /* MCONNTPPostOperation.h in CopyFiles */, + F38221A71C7B638200E00721 /* MCNNTPPostOperation.h in CopyFiles */, C6BEC1AB1B1256C100546519 /* MCHTMLCleaner.h in CopyFiles */, 27E91D601A80D3F4005A3244 /* MCMXRecordResolverOperation.h in CopyFiles */, 27478E861A76475F004AE621 /* MCOAccountValidator.h in CopyFiles */, @@ -1274,8 +1274,8 @@ dstPath = include/MailCore; dstSubfolderSpec = 16; files = ( - F38221A61C7B62E900E00721 /* MCONNTPSendOperation.h in CopyFiles */, - F38221A51C7B629B00E00721 /* MCNNTPSendOperation.h in CopyFiles */, + F38221A61C7B62E900E00721 /* MCONNTPPostOperation.h in CopyFiles */, + F38221A51C7B629B00E00721 /* MCNNTPPostOperation.h in CopyFiles */, C6BEC1AA1B1256BA00546519 /* MCHTMLCleaner.h in CopyFiles */, 276A65D01A7B7E7D008722C2 /* MCMXRecordResolverOperation.h in CopyFiles */, 27478E881A7647AC004AE621 /* MCOAccountValidator.h in CopyFiles */, @@ -2119,10 +2119,10 @@ DAACAD5017886807000B4517 /* MCHTMLRendererIMAPDataCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MCHTMLRendererIMAPDataCallback.h; sourceTree = ""; }; DAD28C891783CFFC00F2BB8F /* MCHTMLBodyRendererTemplateCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MCHTMLBodyRendererTemplateCallback.cpp; sourceTree = ""; }; DAD28C8A1783CFFC00F2BB8F /* MCHTMLBodyRendererTemplateCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MCHTMLBodyRendererTemplateCallback.h; sourceTree = ""; }; - F382219D1C7A60A800E00721 /* MCNNTPSendOperation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MCNNTPSendOperation.h; sourceTree = ""; }; - F382219E1C7A626700E00721 /* MCNNTPSendOperation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MCNNTPSendOperation.cpp; sourceTree = ""; }; - F38221A11C7AAD8100E00721 /* MCONNTPSendOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MCONNTPSendOperation.h; sourceTree = ""; }; - F38221A21C7AAD8100E00721 /* MCONNTPSendOperation.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MCONNTPSendOperation.mm; sourceTree = ""; }; + F382219D1C7A60A800E00721 /* MCNNTPPostOperation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MCNNTPPostOperation.h; sourceTree = ""; }; + F382219E1C7A626700E00721 /* MCNNTPPostOperation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MCNNTPPostOperation.cpp; sourceTree = ""; }; + F38221A11C7AAD8100E00721 /* MCONNTPPostOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MCONNTPPostOperation.h; sourceTree = ""; }; + F38221A21C7AAD8100E00721 /* MCONNTPPostOperation.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MCONNTPPostOperation.mm; sourceTree = ""; }; F87F190816BB62690012652F /* MCOIMAPFetchFoldersOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MCOIMAPFetchFoldersOperation.h; sourceTree = ""; }; F87F190B16BB62B00012652F /* MCOIMAPFetchFoldersOperation.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MCOIMAPFetchFoldersOperation.mm; sourceTree = ""; }; F8EA941416BAED6E0011AC6F /* MCOIMAPSession.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MCOIMAPSession.h; sourceTree = ""; }; @@ -2281,8 +2281,8 @@ 84D7372E199BF704005124E5 /* MCNNTPOperation.cpp */, 84D7372F199BF704005124E5 /* MCNNTPOperation.h */, 84D7373F199BF887005124E5 /* MCNNTPOperationCallback.h */, - F382219D1C7A60A800E00721 /* MCNNTPSendOperation.h */, - F382219E1C7A626700E00721 /* MCNNTPSendOperation.cpp */, + F382219D1C7A60A800E00721 /* MCNNTPPostOperation.h */, + F382219E1C7A626700E00721 /* MCNNTPPostOperation.cpp */, ); path = nntp; sourceTree = ""; @@ -2312,8 +2312,8 @@ 84D7378E199C02A8005124E5 /* MCONNTPDisconnectOperation.mm */, 84D73791199C0511005124E5 /* MCONNTPGroupInfo.h */, 84D73792199C0511005124E5 /* MCONNTPGroupInfo.mm */, - F38221A11C7AAD8100E00721 /* MCONNTPSendOperation.h */, - F38221A21C7AAD8100E00721 /* MCONNTPSendOperation.mm */, + F38221A11C7AAD8100E00721 /* MCONNTPPostOperation.h */, + F38221A21C7AAD8100E00721 /* MCONNTPPostOperation.mm */, ); path = nntp; sourceTree = ""; @@ -3684,7 +3684,7 @@ C6F61F9917016B460073032E /* MCOIMAPSearchExpression.mm in Sources */, C6F61F9F17016EA10073032E /* MCOIMAPFolderInfo.mm in Sources */, C6D4FD3F19FB7534001F7E01 /* MCMessageParserMac.mm in Sources */, - F38221A31C7AAD8100E00721 /* MCONNTPSendOperation.mm in Sources */, + F38221A31C7AAD8100E00721 /* MCONNTPPostOperation.mm in Sources */, C6F61FB51702AB340073032E /* MCOIMAPBaseOperation.mm in Sources */, C608167517759967001F1018 /* MCSMTPDisconnectOperation.cpp in Sources */, C6A81BBF17068E5E00882C15 /* MCOSMTPSession.mm in Sources */, @@ -3728,7 +3728,7 @@ 9EF9AB09175F2EC60027FA3B /* MCOIMAPFolderStatus.mm in Sources */, 9EF9AB11175F319A0027FA3B /* MCIMAPFolderStatusOperation.cpp in Sources */, 9EF9AB19175F36600027FA3B /* MCOIMAPFolderStatusOperation.mm in Sources */, - F382219F1C7A626700E00721 /* MCNNTPSendOperation.cpp in Sources */, + F382219F1C7A626700E00721 /* MCNNTPPostOperation.cpp in Sources */, 9E774D891767C7F60065EB9B /* MCIMAPFolderStatus.cpp in Sources */, DAD28C8B1783CFFC00F2BB8F /* MCHTMLBodyRendererTemplateCallback.cpp in Sources */, BD63713B177DFF080094121B /* MCLibetpan.cpp in Sources */, @@ -3962,7 +3962,7 @@ C6E665BC1796500C0063F2CF /* unzip.c in Sources */, C6BA2C121705F4E6003F0E9E /* MCOIMAPSearchExpression.mm in Sources */, C6D4FD4019FB7786001F7E01 /* MCMessageParserMac.mm in Sources */, - F38221A41C7AAD8100E00721 /* MCONNTPSendOperation.mm in Sources */, + F38221A41C7AAD8100E00721 /* MCONNTPPostOperation.mm in Sources */, C6BA2C131705F4E6003F0E9E /* MCOIMAPFolderInfo.mm in Sources */, C6BA2C141705F4E6003F0E9E /* MCOIMAPBaseOperation.mm in Sources */, C608167617759968001F1018 /* MCSMTPDisconnectOperation.cpp in Sources */, @@ -4006,7 +4006,7 @@ C6CF62CB175324F0006398B9 /* MCNetService.cpp in Sources */, 9EF9AB0A175F2EC60027FA3B /* MCOIMAPFolderStatus.mm in Sources */, 9EF9AB12175F319A0027FA3B /* MCIMAPFolderStatusOperation.cpp in Sources */, - F38221A01C7A626700E00721 /* MCNNTPSendOperation.cpp in Sources */, + F38221A01C7A626700E00721 /* MCNNTPPostOperation.cpp in Sources */, 9EF9AB1A175F36600027FA3B /* MCOIMAPFolderStatusOperation.mm in Sources */, 9E774D8A1767C7F60065EB9B /* MCIMAPFolderStatus.cpp in Sources */, DAD28C8C1783CFFC00F2BB8F /* MCHTMLBodyRendererTemplateCallback.cpp in Sources */, diff --git a/build-windows/build_headers.list b/build-windows/build_headers.list index c21923f6..3d5a92e2 100644 --- a/build-windows/build_headers.list +++ b/build-windows/build_headers.list @@ -116,7 +116,7 @@ src\async\nntp\MCNNTPFetchAllArticlesOperation.h src\async\nntp\MCNNTPListNewsgroupsOperation.h src\async\nntp\MCNNTPFetchOverviewOperation.h src\async\nntp\MCNNTPFetchServerTimeOperation.h -src\async\nntp\MCNNTPSendOperation.h +src\async\nntp\MCNNTPPostOperation.h src\async\nntp\MCNNTPOperationCallback.h src\objc\MCObjC.h src\objc\utils\MCOUtils.h @@ -199,7 +199,7 @@ src\objc\nntp\MCONNTPFetchAllArticlesOperation.h src\objc\nntp\MCONNTPListNewsgroupsOperation.h src\objc\nntp\MCONNTPFetchOverviewOperation.h src\objc\nntp\MCONNTPFetchServerTimeOperation.h -src\objc\nntp\MCONNTPSendOperation.h +src\objc\nntp\MCONNTPPostOperation.h src\objc\nntp\MCONNTPGroupInfo.h src\objc\provider\MCOProvider.h src\objc\provider\MCONetService.h diff --git a/build-windows/mailcore2/mailcore2/mailcore2.vcxproj b/build-windows/mailcore2/mailcore2/mailcore2.vcxproj index a5100e61..7fd762c2 100644 --- a/build-windows/mailcore2/mailcore2/mailcore2.vcxproj +++ b/build-windows/mailcore2/mailcore2/mailcore2.vcxproj @@ -63,7 +63,7 @@ - + @@ -224,7 +224,7 @@ - + diff --git a/build-windows/mailcore2/mailcore2/mailcore2.vcxproj.filters b/build-windows/mailcore2/mailcore2/mailcore2.vcxproj.filters index e5653303..77e0f971 100644 --- a/build-windows/mailcore2/mailcore2/mailcore2.vcxproj.filters +++ b/build-windows/mailcore2/mailcore2/mailcore2.vcxproj.filters @@ -537,7 +537,7 @@ Source Files\async\nntp - + Source Files\async\nntp @@ -932,7 +932,7 @@ Source Files\async\nntp - + Source Files\async\nntp diff --git a/src/async/nntp/MCAsyncNNTP.h b/src/async/nntp/MCAsyncNNTP.h index 57b80cb8..326138dc 100644 --- a/src/async/nntp/MCAsyncNNTP.h +++ b/src/async/nntp/MCAsyncNNTP.h @@ -18,7 +18,7 @@ #include #include #include -#include +#include #include #endif diff --git a/src/async/nntp/MCNNTPAsyncSession.cpp b/src/async/nntp/MCNNTPAsyncSession.cpp index ddd4c804..eeed1244 100644 --- a/src/async/nntp/MCNNTPAsyncSession.cpp +++ b/src/async/nntp/MCNNTPAsyncSession.cpp @@ -16,7 +16,7 @@ #include "MCNNTPFetchOverviewOperation.h" #include "MCNNTPCheckAccountOperation.h" #include "MCNNTPFetchServerTimeOperation.h" -#include "MCNNTPSendOperation.h" +#include "MCNNTPPostOperation.h" #include "MCNNTPDisconnectOperation.h" #include "MCOperationQueueCallback.h" #include "MCConnectionLogger.h" @@ -237,18 +237,18 @@ NNTPListNewsgroupsOperation * NNTPAsyncSession::listDefaultNewsgroupsOperation() return op; } -NNTPSendOperation * NNTPAsyncSession::sendMessageOperation(Data * messageData) +NNTPPostOperation * NNTPAsyncSession::postMessageOperation(Data * messageData) { - NNTPSendOperation * op = new NNTPSendOperation(); + NNTPPostOperation * op = new NNTPPostOperation(); op->setSession(this); op->setMessageData(messageData); op->autorelease(); return op; } -NNTPSendOperation * NNTPAsyncSession::sendMessageOperation(String * filename) +NNTPPostOperation * NNTPAsyncSession::postMessageOperation(String * filename) { - NNTPSendOperation * op = new NNTPSendOperation(); + NNTPPostOperation * op = new NNTPPostOperation(); op->setSession(this); op->setMessageFilepath(filename); op->autorelease(); diff --git a/src/async/nntp/MCNNTPAsyncSession.h b/src/async/nntp/MCNNTPAsyncSession.h index c41066ac..eb2531a4 100644 --- a/src/async/nntp/MCNNTPAsyncSession.h +++ b/src/async/nntp/MCNNTPAsyncSession.h @@ -16,7 +16,7 @@ namespace mailcore { class NNTPFetchOverviewOperation; class NNTPListNewsgroupsOperation; class NNTPFetchServerTimeOperation; - class NNTPSendOperation; + class NNTPPostOperation; class NNTPOperationQueueCallback; class NNTPConnectionLogger; @@ -73,8 +73,8 @@ namespace mailcore { virtual NNTPListNewsgroupsOperation * listAllNewsgroupsOperation(); virtual NNTPListNewsgroupsOperation * listDefaultNewsgroupsOperation(); - virtual NNTPSendOperation * sendMessageOperation(Data * messageData); - virtual NNTPSendOperation * sendMessageOperation(String * filename); + virtual NNTPPostOperation * postMessageOperation(Data * messageData); + virtual NNTPPostOperation * postMessageOperation(String * filename); virtual NNTPOperation * disconnectOperation(); diff --git a/src/async/nntp/MCNNTPPostOperation.cpp b/src/async/nntp/MCNNTPPostOperation.cpp new file mode 100644 index 00000000..c5b586f5 --- /dev/null +++ b/src/async/nntp/MCNNTPPostOperation.cpp @@ -0,0 +1,58 @@ +// +// MCNNTPPostOperation.cpp +// mailcore2 +// +// Created by Daryle Walker on 2/21/16. +// Copyright © 2016 MailCore. All rights reserved. +// + +#include "MCNNTPPostOperation.h" + +#include "MCNNTPAsyncSession.h" +#include "MCNNTPSession.h" + +using namespace mailcore; + +NNTPPostOperation::NNTPPostOperation() +{ + mMessageData = NULL; + mMessageFilepath = NULL; +} + +NNTPPostOperation::~NNTPPostOperation() +{ + MC_SAFE_RELEASE(mMessageFilepath); + MC_SAFE_RELEASE(mMessageData); +} + +void NNTPPostOperation::setMessageData(Data * data) +{ + MC_SAFE_REPLACE_RETAIN(Data, mMessageData, data); +} + +Data * NNTPPostOperation::messageData() +{ + return mMessageData; +} + +void NNTPPostOperation::setMessageFilepath(String * path) +{ + MC_SAFE_REPLACE_RETAIN(String, mMessageFilepath, path); +} + +String * NNTPPostOperation::messageFilepath() +{ + return mMessageFilepath; +} + +void NNTPPostOperation::main() +{ + ErrorCode error; + if (mMessageFilepath != NULL) { + session()->session()->postMessage(mMessageFilepath, this, &error); + } + else { + session()->session()->postMessage(mMessageData, this, &error); + } + setError(error); +} diff --git a/src/async/nntp/MCNNTPPostOperation.h b/src/async/nntp/MCNNTPPostOperation.h new file mode 100644 index 00000000..9255dafd --- /dev/null +++ b/src/async/nntp/MCNNTPPostOperation.h @@ -0,0 +1,44 @@ +// +// MCNNTPPostOperation.h +// mailcore2 +// +// Created by Daryle Walker on 2/21/16. +// Copyright © 2016 MailCore. All rights reserved. +// + +#ifndef MAILCORE_MCNNTPPOSTOPERATION_H + +#define MAILCORE_MCNNTPPOSTOPERATION_H + +#include +#include +#include + +#ifdef __cplusplus + +namespace mailcore { + + class MAILCORE_EXPORT NNTPPostOperation : public NNTPOperation { + public: + NNTPPostOperation(); + virtual ~NNTPPostOperation(); + + 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 diff --git a/src/async/nntp/MCNNTPSendOperation.cpp b/src/async/nntp/MCNNTPSendOperation.cpp deleted file mode 100644 index d5f27928..00000000 --- a/src/async/nntp/MCNNTPSendOperation.cpp +++ /dev/null @@ -1,58 +0,0 @@ -// -// 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 deleted file mode 100644 index d859cd58..00000000 --- a/src/async/nntp/MCNNTPSendOperation.h +++ /dev/null @@ -1,44 +0,0 @@ -// -// 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 -#include -#include - -#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 diff --git a/src/cmake/async.cmake b/src/cmake/async.cmake index a7cab6b0..1c213a33 100644 --- a/src/cmake/async.cmake +++ b/src/cmake/async.cmake @@ -67,7 +67,7 @@ set(async_nntp_files async/nntp/MCNNTPListNewsgroupsOperation.cpp async/nntp/MCNNTPFetchOverviewOperation.cpp async/nntp/MCNNTPFetchServerTimeOperation.cpp - async/nntp/MCNNTPSendOperation.cpp + async/nntp/MCNNTPPostOperation.cpp async/nntp/MCNNTPOperation.cpp ) diff --git a/src/cmake/objc.cmake b/src/cmake/objc.cmake index b784bf9d..aeb01d3b 100644 --- a/src/cmake/objc.cmake +++ b/src/cmake/objc.cmake @@ -88,7 +88,7 @@ set(objc_nntp_files objc/nntp/MCONNTPListNewsgroupsOperation.mm objc/nntp/MCONNTPFetchOverviewOperation.mm objc/nntp/MCONNTPFetchServerTimeOperation.mm - objc/nntp/MCONNTPSendOperation.mm + objc/nntp/MCONNTPPostOperation.mm objc/nntp/MCONNTPOperation.mm objc/nntp/MCONNTPSession.mm ) diff --git a/src/cmake/public-headers.cmake b/src/cmake/public-headers.cmake index bca47e2c..bcbdb0b6 100644 --- a/src/cmake/public-headers.cmake +++ b/src/cmake/public-headers.cmake @@ -118,7 +118,7 @@ async/nntp/MCNNTPFetchAllArticlesOperation.h async/nntp/MCNNTPListNewsgroupsOperation.h async/nntp/MCNNTPFetchOverviewOperation.h async/nntp/MCNNTPFetchServerTimeOperation.h -async/nntp/MCNNTPSendOperation.h +async/nntp/MCNNTPPostOperation.h async/nntp/MCNNTPOperationCallback.h objc/MCObjC.h objc/utils/MCOUtils.h @@ -202,7 +202,7 @@ objc/nntp/MCONNTPFetchAllArticlesOperation.h objc/nntp/MCONNTPListNewsgroupsOperation.h objc/nntp/MCONNTPFetchOverviewOperation.h objc/nntp/MCONNTPFetchServerTimeOperation.h -objc/nntp/MCONNTPSendOperation.h +objc/nntp/MCONNTPPostOperation.h objc/nntp/MCONNTPGroupInfo.h objc/provider/MCOProvider.h objc/provider/MCONetService.h diff --git a/src/core/nntp/MCNNTPSession.cpp b/src/core/nntp/MCNNTPSession.cpp index c40301a4..e5004432 100644 --- a/src/core/nntp/MCNNTPSession.cpp +++ b/src/core/nntp/MCNNTPSession.cpp @@ -622,7 +622,7 @@ Array * NNTPSession::fetchOverArticlesInRange(Range range, String * groupName, E return result; } -void NNTPSession::sendMessage(Data * messageData, NNTPProgressCallback * callback, ErrorCode * pError) +void NNTPSession::postMessage(Data * messageData, NNTPProgressCallback * callback, ErrorCode * pError) { int r; @@ -665,7 +665,7 @@ err: mProgressCallback = NULL; } -void NNTPSession::sendMessage(String * messagePath, NNTPProgressCallback * callback, ErrorCode * pError) +void NNTPSession::postMessage(String * messagePath, NNTPProgressCallback * callback, ErrorCode * pError) { Data * messageData = Data::dataWithContentsOfFile(messagePath); if (!messageData) { @@ -673,7 +673,7 @@ void NNTPSession::sendMessage(String * messagePath, NNTPProgressCallback * callb return; } - return sendMessage(messageData, callback, pError); + return postMessage(messageData, callback, pError); } static void mmapStringDeallocator(char * bytes, unsigned int length) { diff --git a/src/core/nntp/MCNNTPSession.h b/src/core/nntp/MCNNTPSession.h index 94669edd..22734f2d 100644 --- a/src/core/nntp/MCNNTPSession.h +++ b/src/core/nntp/MCNNTPSession.h @@ -57,8 +57,8 @@ namespace mailcore { virtual time_t fetchServerDate(ErrorCode * pError); - virtual void sendMessage(Data * messageData, NNTPProgressCallback * callback, ErrorCode * pError); - virtual void sendMessage(String * messagePath, NNTPProgressCallback * callback, ErrorCode * pError); + virtual void postMessage(Data * messageData, NNTPProgressCallback * callback, ErrorCode * pError); + virtual void postMessage(String * messagePath, NNTPProgressCallback * callback, ErrorCode * pError); virtual void setConnectionLogger(ConnectionLogger * logger); virtual ConnectionLogger * connectionLogger(); diff --git a/src/objc/nntp/MCONNTP.h b/src/objc/nntp/MCONNTP.h index 213384c4..62442c2a 100644 --- a/src/objc/nntp/MCONNTP.h +++ b/src/objc/nntp/MCONNTP.h @@ -18,7 +18,7 @@ #include #include #include -#include +#include #include #endif diff --git a/src/objc/nntp/MCONNTPPostOperation.h b/src/objc/nntp/MCONNTPPostOperation.h new file mode 100644 index 00000000..a2447e70 --- /dev/null +++ b/src/objc/nntp/MCONNTPPostOperation.h @@ -0,0 +1,37 @@ +// +// MCONNTPPostOperation.h +// mailcore2 +// +// Created by Daryle Walker on 2/21/16. +// Copyright © 2016 MailCore. All rights reserved. +// + +#ifndef MAILCORE_MCONNTPPOSTOPERATION_H + +#define MAILCORE_MCONNTPPOSTOPERATION_H + +#import +#import + +NS_ASSUME_NONNULL_BEGIN +@interface MCONNTPPostOperation : MCONNTPOperation + +/** This block will be called as data is downloaded from the network */ +@property (nonatomic, copy) MCONNTPOperationProgressBlock progress; + +/** + Starts the asynchronous send operation. + + @param completionBlock Called when the operation is finished. + + - On success `error` will be nil + + - On failure, `error` will be set with `MCOErrorDomain` as domain and an + error code available in MCOConstants.h + */ +- (void) start:(void (^)(NSError * __nullable error))completionBlock; + +@end +NS_ASSUME_NONNULL_END + +#endif diff --git a/src/objc/nntp/MCONNTPPostOperation.mm b/src/objc/nntp/MCONNTPPostOperation.mm new file mode 100644 index 00000000..f5009afa --- /dev/null +++ b/src/objc/nntp/MCONNTPPostOperation.mm @@ -0,0 +1,116 @@ +// +// MCONNTPPostOperation.mm +// mailcore2 +// +// Created by Daryle Walker on 2/21/16. +// Copyright © 2016 MailCore. All rights reserved. +// + +#import "MCONNTPPostOperation.h" + +#import "MCAsyncNNTP.h" + +#import "MCOUtils.h" +#import "MCOOperation+Private.h" + +#define nativeType mailcore::NNTPPostOperation + +typedef void (^CompletionType)(NSError *error); + +@interface MCONNTPPostOperation () + +- (void) bodyProgress:(unsigned int)current maximum:(unsigned int)maximum; + +@end + +class MCONNTPPostOperationCallback : public mailcore::NNTPOperationCallback { +public: + MCONNTPPostOperationCallback(MCONNTPPostOperation * op) + { + mOperation = op; + } + virtual ~MCONNTPPostOperationCallback() + { + } + + virtual void bodyProgress(mailcore::NNTPOperation * session, unsigned int current, unsigned int maximum) { + [mOperation bodyProgress:current maximum:maximum]; + } + +private: + MCONNTPPostOperation * mOperation; +}; + +@implementation MCONNTPPostOperation { + CompletionType _completionBlock; + MCONNTPPostOperationCallback * _popCallback; + MCONNTPOperationProgressBlock _progress; +} + +@synthesize progress = _progress; + ++ (void) load +{ + MCORegisterClass(self, &typeid(nativeType)); +} + ++ (NSObject *) mco_objectWithMCObject:(mailcore::Object *)object +{ + nativeType * op = (nativeType *) object; + return [[[self alloc] initWithMCOperation:op] autorelease]; +} + +- (instancetype) initWithMCOperation:(mailcore::Operation *)op +{ + self = [super initWithMCOperation:op]; + + _popCallback = new MCONNTPPostOperationCallback(self); + ((mailcore::NNTPOperation *) op)->setNNTPCallback(_popCallback); + + return self; +} + +- (void) dealloc +{ + [_progress release]; + [_completionBlock release]; + delete _popCallback; + [super dealloc]; +} + +- (void) start:(void (^)(NSError *error))completionBlock +{ + _completionBlock = [completionBlock copy]; + [self start]; +} + +- (void) cancel +{ + [_completionBlock release]; + _completionBlock = nil; + [super cancel]; +} + +- (void) operationCompleted +{ + if (_completionBlock == NULL) + return; + + nativeType *op = MCO_NATIVE_INSTANCE; + if (op->error() == mailcore::ErrorNone) { + _completionBlock(nil); + } else { + _completionBlock([NSError mco_errorWithErrorCode:op->error()]); + } + [_completionBlock release]; + _completionBlock = nil; +} + +- (void) bodyProgress:(unsigned int)current maximum:(unsigned int)maximum +{ + if (_progress != NULL) { + _progress(current, maximum); + } +} + +@end diff --git a/src/objc/nntp/MCONNTPSendOperation.h b/src/objc/nntp/MCONNTPSendOperation.h deleted file mode 100644 index 711e44a5..00000000 --- a/src/objc/nntp/MCONNTPSendOperation.h +++ /dev/null @@ -1,37 +0,0 @@ -// -// MCONNTPSendOperation.h -// mailcore2 -// -// Created by Daryle Walker on 2/21/16. -// Copyright © 2016 MailCore. All rights reserved. -// - -#ifndef MAILCORE_MCONNTPSENDOPERATION_H - -#define MAILCORE_MCONNTPSENDOPERATION_H - -#import -#import - -NS_ASSUME_NONNULL_BEGIN -@interface MCONNTPSendOperation : MCONNTPOperation - -/** This block will be called as data is downloaded from the network */ -@property (nonatomic, copy) MCONNTPOperationProgressBlock progress; - -/** - Starts the asynchronous send operation. - - @param completionBlock Called when the operation is finished. - - - On success `error` will be nil - - - On failure, `error` will be set with `MCOErrorDomain` as domain and an - error code available in MCOConstants.h - */ -- (void) start:(void (^)(NSError * __nullable error))completionBlock; - -@end -NS_ASSUME_NONNULL_END - -#endif diff --git a/src/objc/nntp/MCONNTPSendOperation.mm b/src/objc/nntp/MCONNTPSendOperation.mm deleted file mode 100644 index db1277af..00000000 --- a/src/objc/nntp/MCONNTPSendOperation.mm +++ /dev/null @@ -1,116 +0,0 @@ -// -// MCONNTPSendOperation.mm -// mailcore2 -// -// Created by Daryle Walker on 2/21/16. -// Copyright © 2016 MailCore. All rights reserved. -// - -#import "MCONNTPSendOperation.h" - -#import "MCAsyncNNTP.h" - -#import "MCOUtils.h" -#import "MCOOperation+Private.h" - -#define nativeType mailcore::NNTPSendOperation - -typedef void (^CompletionType)(NSError *error); - -@interface MCONNTPSendOperation () - -- (void) bodyProgress:(unsigned int)current maximum:(unsigned int)maximum; - -@end - -class MCONNTPSendOperationCallback : public mailcore::NNTPOperationCallback { -public: - MCONNTPSendOperationCallback(MCONNTPSendOperation * op) - { - mOperation = op; - } - virtual ~MCONNTPSendOperationCallback() - { - } - - virtual void bodyProgress(mailcore::NNTPOperation * session, unsigned int current, unsigned int maximum) { - [mOperation bodyProgress:current maximum:maximum]; - } - -private: - MCONNTPSendOperation * mOperation; -}; - -@implementation MCONNTPSendOperation { - CompletionType _completionBlock; - MCONNTPSendOperationCallback * _popCallback; - MCONNTPOperationProgressBlock _progress; -} - -@synthesize progress = _progress; - -+ (void) load -{ - MCORegisterClass(self, &typeid(nativeType)); -} - -+ (NSObject *) mco_objectWithMCObject:(mailcore::Object *)object -{ - nativeType * op = (nativeType *) object; - return [[[self alloc] initWithMCOperation:op] autorelease]; -} - -- (instancetype) initWithMCOperation:(mailcore::Operation *)op -{ - self = [super initWithMCOperation:op]; - - _popCallback = new MCONNTPSendOperationCallback(self); - ((mailcore::NNTPOperation *) op)->setNNTPCallback(_popCallback); - - return self; -} - -- (void) dealloc -{ - [_progress release]; - [_completionBlock release]; - delete _popCallback; - [super dealloc]; -} - -- (void) start:(void (^)(NSError *error))completionBlock -{ - _completionBlock = [completionBlock copy]; - [self start]; -} - -- (void) cancel -{ - [_completionBlock release]; - _completionBlock = nil; - [super cancel]; -} - -- (void) operationCompleted -{ - if (_completionBlock == NULL) - return; - - nativeType *op = MCO_NATIVE_INSTANCE; - if (op->error() == mailcore::ErrorNone) { - _completionBlock(nil); - } else { - _completionBlock([NSError mco_errorWithErrorCode:op->error()]); - } - [_completionBlock release]; - _completionBlock = nil; -} - -- (void) bodyProgress:(unsigned int)current maximum:(unsigned int)maximum -{ - if (_progress != NULL) { - _progress(current, maximum); - } -} - -@end diff --git a/src/objc/nntp/MCONNTPSession.h b/src/objc/nntp/MCONNTPSession.h index 84b1c5e7..19fe5ff4 100644 --- a/src/objc/nntp/MCONNTPSession.h +++ b/src/objc/nntp/MCONNTPSession.h @@ -20,7 +20,7 @@ @class MCONNTPListNewsgroupsOperation; @class MCONNTPFetchOverviewOperation; @class MCONNTPFetchServerTimeOperation; -@class MCONNTPSendOperation; +@class MCONNTPPostOperation; @class MCONNTPOperation; @class MCOIndexSet; @@ -183,30 +183,30 @@ NS_ASSUME_NONNULL_BEGIN - (MCONNTPListNewsgroupsOperation *) listDefaultNewsgroupsOperation; /** - Returns an operation that will send the given message through NNTP. + Returns an operation that will post the given message through NNTP. It will use the newsgroups set in the message data. It will also filter out Bcc from the content of the message. Generate RFC 822 data using MCOMessageBuilder - MCONNTPOperation * op = [session sendOperationWithData:rfc822Data]; + MCONNTPOperation * op = [session postOperationWithData:rfc822Data]; [op start:^(NSError * __nullable error) { ... }]; */ -- (MCONNTPSendOperation *) sendOperationWithData:(NSData *)messageData; +- (MCONNTPPostOperation *) postOperationWithData:(NSData *)messageData; /** - Returns an operation that will send the message from the given file through NNTP. + Returns an operation that will post the message from the given file through NNTP. It will use the newsgroups set in the message data. It will also filter out Bcc from the content of the message. - MCONNTPOperation * op = [session sendOperationWithContentsOfFile:rfc822DataFilename]; + MCONNTPOperation * op = [session postOperationWithContentsOfFile:rfc822DataFilename]; [op start:^(NSError * __nullable error) { ... }]; */ -- (MCONNTPSendOperation *) sendOperationWithContentsOfFile:(NSString *)path; +- (MCONNTPPostOperation *) postOperationWithContentsOfFile:(NSString *)path; /** Returns an operation that will disconnect the session. diff --git a/src/objc/nntp/MCONNTPSession.mm b/src/objc/nntp/MCONNTPSession.mm index 4a6e0c9a..f873cff9 100644 --- a/src/objc/nntp/MCONNTPSession.mm +++ b/src/objc/nntp/MCONNTPSession.mm @@ -14,7 +14,7 @@ #import "MCONNTPOperation.h" #import "MCOOperation+Private.h" #import "MCONNTPFetchAllArticlesOperation.h" -#import "MCONNTPSendOperation.h" +#import "MCONNTPPostOperation.h" #import "MCONNTPOperation+Private.h" #include "MCOperationQueueCallback.h" @@ -206,14 +206,14 @@ MCO_OBJC_SYNTHESIZE_SCALAR(dispatch_queue_t, dispatch_queue_t, setDispatchQueue, return MCO_TO_OBJC_OP(coreOp); } -- (MCONNTPSendOperation *) sendOperationWithData:(NSData *)messageData { - mailcore::NNTPSendOperation * coreOp = MCO_NATIVE_INSTANCE->sendMessageOperation(MCO_FROM_OBJC(mailcore::Data, messageData)); +- (MCONNTPPostOperation *) postOperationWithData:(NSData *)messageData { + mailcore::NNTPPostOperation * coreOp = MCO_NATIVE_INSTANCE->postMessageOperation(MCO_FROM_OBJC(mailcore::Data, messageData)); return MCO_TO_OBJC_OP(coreOp); } -- (MCONNTPSendOperation *) sendOperationWithContentsOfFile:(NSString *)path +- (MCONNTPPostOperation *) postOperationWithContentsOfFile:(NSString *)path { - mailcore::NNTPSendOperation * coreOp = MCO_NATIVE_INSTANCE->sendMessageOperation(MCO_FROM_OBJC(mailcore::String, path)); + mailcore::NNTPPostOperation * coreOp = MCO_NATIVE_INSTANCE->postMessageOperation(MCO_FROM_OBJC(mailcore::String, path)); return MCO_TO_OBJC_OP(coreOp); } -- cgit v1.2.3