diff options
author | Dmitry Isaikin <isaikin@corp.mail.ru> | 2016-02-02 19:23:58 +0300 |
---|---|---|
committer | Dmitry Isaikin <isaikin@corp.mail.ru> | 2016-02-09 15:53:40 +0300 |
commit | f9cdd2e6193cddfa405723eb70dda9261b26848d (patch) | |
tree | 0448dfc39864b9d52b55d5ad7a91d16d15bb2c71 /src/async/smtp | |
parent | 908b7d4b8fdd7be43687450a36d56a6fb905ca25 (diff) |
Add file-based interface for sending messages via SMTP (reduce memory usage)
Diffstat (limited to 'src/async/smtp')
-rw-r--r-- | src/async/smtp/MCSMTPAsyncSession.cpp | 11 | ||||
-rw-r--r-- | src/async/smtp/MCSMTPAsyncSession.h | 2 | ||||
-rw-r--r-- | src/async/smtp/MCSMTPSendWithDataOperation.cpp | 16 | ||||
-rw-r--r-- | src/async/smtp/MCSMTPSendWithDataOperation.h | 7 |
4 files changed, 34 insertions, 2 deletions
diff --git a/src/async/smtp/MCSMTPAsyncSession.cpp b/src/async/smtp/MCSMTPAsyncSession.cpp index d2f645da..46b25184 100644 --- a/src/async/smtp/MCSMTPAsyncSession.cpp +++ b/src/async/smtp/MCSMTPAsyncSession.cpp @@ -240,6 +240,17 @@ SMTPOperation * SMTPAsyncSession::sendMessageOperation(Address * from, Array * r return (SMTPOperation *) op->autorelease(); } +SMTPOperation * SMTPAsyncSession::sendMessageOperation(Address * from, Array * recipients, + String * filename) +{ + SMTPSendWithDataOperation * op = new SMTPSendWithDataOperation(); + op->setSession(this); + op->setMessageFilepath(filename); + op->setFrom(from); + op->setRecipients(recipients); + return (SMTPOperation *) op->autorelease(); +} + SMTPOperation * SMTPAsyncSession::checkAccountOperation(Address * from) { SMTPCheckAccountOperation * op = new SMTPCheckAccountOperation(); diff --git a/src/async/smtp/MCSMTPAsyncSession.h b/src/async/smtp/MCSMTPAsyncSession.h index 90849797..961df6ef 100644 --- a/src/async/smtp/MCSMTPAsyncSession.h +++ b/src/async/smtp/MCSMTPAsyncSession.h @@ -68,6 +68,8 @@ namespace mailcore { virtual SMTPOperation * sendMessageOperation(Data * messageData); virtual SMTPOperation * sendMessageOperation(Address * from, Array * recipients, Data * messageData); + virtual SMTPOperation * sendMessageOperation(Address * from, Array * recipients, + String * filename); virtual SMTPOperation * checkAccountOperation(Address * from); virtual SMTPOperation * noopOperation(); diff --git a/src/async/smtp/MCSMTPSendWithDataOperation.cpp b/src/async/smtp/MCSMTPSendWithDataOperation.cpp index 03f6a530..4561b5d8 100644 --- a/src/async/smtp/MCSMTPSendWithDataOperation.cpp +++ b/src/async/smtp/MCSMTPSendWithDataOperation.cpp @@ -16,6 +16,7 @@ using namespace mailcore; SMTPSendWithDataOperation::SMTPSendWithDataOperation() { mMessageData = NULL; + mMessageFilepath = NULL; mFrom = NULL; mRecipients = NULL; } @@ -24,6 +25,7 @@ SMTPSendWithDataOperation::~SMTPSendWithDataOperation() { MC_SAFE_RELEASE(mFrom); MC_SAFE_RELEASE(mRecipients); + MC_SAFE_RELEASE(mMessageFilepath); MC_SAFE_RELEASE(mMessageData); } @@ -37,6 +39,16 @@ Data * SMTPSendWithDataOperation::messageData() return mMessageData; } +void SMTPSendWithDataOperation::setMessageFilepath(String * path) +{ + MC_SAFE_REPLACE_RETAIN(String, mMessageFilepath, path); +} + +String * SMTPSendWithDataOperation::messageFilepath() +{ + return mMessageFilepath; +} + void SMTPSendWithDataOperation::setFrom(Address * from) { MC_SAFE_REPLACE_COPY(Address, mFrom, from); @@ -60,6 +72,10 @@ Array * SMTPSendWithDataOperation::recipients() void SMTPSendWithDataOperation::main() { ErrorCode error; + if (mMessageFilepath != NULL) { + session()->session()->sendMessage(mFrom, mRecipients, mMessageFilepath, this, &error); + } + else if ((mFrom != NULL) && (mRecipients != NULL)) { session()->session()->sendMessage(mFrom, mRecipients, mMessageData, this, &error); } diff --git a/src/async/smtp/MCSMTPSendWithDataOperation.h b/src/async/smtp/MCSMTPSendWithDataOperation.h index a8ee2515..768adda9 100644 --- a/src/async/smtp/MCSMTPSendWithDataOperation.h +++ b/src/async/smtp/MCSMTPSendWithDataOperation.h @@ -31,15 +31,18 @@ namespace mailcore { 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; Array * mRecipients; Address * mFrom; - }; } |