diff options
author | Hoa V. DINH <dinh.viet.hoa@gmail.com> | 2013-08-17 20:09:36 -0700 |
---|---|---|
committer | Hoa V. DINH <dinh.viet.hoa@gmail.com> | 2013-08-17 20:09:36 -0700 |
commit | d510c2dda500ce3955df1c377410b1d8ffc9cf6b (patch) | |
tree | 48533e29001e31f4577dc1e312d075a1db7cd4f3 /src/async/smtp | |
parent | 0bc9d79ada9b7a0a3f2cc2ea8c398e480be779f6 (diff) |
Fixed #314: added -[MCOSMTPSession sendOperationWithData:from:recipients:]
Diffstat (limited to 'src/async/smtp')
-rw-r--r-- | src/async/smtp/MCSMTPAsyncSession.cc | 11 | ||||
-rw-r--r-- | src/async/smtp/MCSMTPAsyncSession.h | 2 | ||||
-rw-r--r-- | src/async/smtp/MCSMTPSendWithDataOperation.cc | 31 | ||||
-rw-r--r-- | src/async/smtp/MCSMTPSendWithDataOperation.h | 8 |
4 files changed, 51 insertions, 1 deletions
diff --git a/src/async/smtp/MCSMTPAsyncSession.cc b/src/async/smtp/MCSMTPAsyncSession.cc index f670894a..4da41b5d 100644 --- a/src/async/smtp/MCSMTPAsyncSession.cc +++ b/src/async/smtp/MCSMTPAsyncSession.cc @@ -211,6 +211,17 @@ SMTPOperation * SMTPAsyncSession::sendMessageOperation(Data * messageData) return (SMTPOperation *) op->autorelease(); } +SMTPOperation * SMTPAsyncSession::sendMessageOperation(Address * from, Array * recipients, + Data * messageData) +{ + SMTPSendWithDataOperation * op = new SMTPSendWithDataOperation(); + op->setSession(this); + op->setMessageData(messageData); + 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 bbb81737..f013dc26 100644 --- a/src/async/smtp/MCSMTPAsyncSession.h +++ b/src/async/smtp/MCSMTPAsyncSession.h @@ -55,6 +55,8 @@ namespace mailcore { virtual ConnectionLogger * connectionLogger(); virtual SMTPOperation * sendMessageOperation(Data * messageData); + virtual SMTPOperation * sendMessageOperation(Address * from, Array * recipients, + Data * messageData); virtual SMTPOperation * checkAccountOperation(Address * from); public: // private diff --git a/src/async/smtp/MCSMTPSendWithDataOperation.cc b/src/async/smtp/MCSMTPSendWithDataOperation.cc index bb2c5ea9..03f6a530 100644 --- a/src/async/smtp/MCSMTPSendWithDataOperation.cc +++ b/src/async/smtp/MCSMTPSendWithDataOperation.cc @@ -16,10 +16,14 @@ using namespace mailcore; SMTPSendWithDataOperation::SMTPSendWithDataOperation() { mMessageData = NULL; + mFrom = NULL; + mRecipients = NULL; } SMTPSendWithDataOperation::~SMTPSendWithDataOperation() { + MC_SAFE_RELEASE(mFrom); + MC_SAFE_RELEASE(mRecipients); MC_SAFE_RELEASE(mMessageData); } @@ -33,9 +37,34 @@ Data * SMTPSendWithDataOperation::messageData() return mMessageData; } +void SMTPSendWithDataOperation::setFrom(Address * from) +{ + MC_SAFE_REPLACE_COPY(Address, mFrom, from); +} + +Address * SMTPSendWithDataOperation::from() +{ + return mFrom; +} + +void SMTPSendWithDataOperation::setRecipients(Array * recipients) +{ + MC_SAFE_REPLACE_COPY(Array, mRecipients, recipients); +} + +Array * SMTPSendWithDataOperation::recipients() +{ + return mRecipients; +} + void SMTPSendWithDataOperation::main() { ErrorCode error; - session()->session()->sendMessage(mMessageData, this, &error); + if ((mFrom != NULL) && (mRecipients != NULL)) { + session()->session()->sendMessage(mFrom, mRecipients, mMessageData, this, &error); + } + else { + session()->session()->sendMessage(mMessageData, this, &error); + } setError(error); } diff --git a/src/async/smtp/MCSMTPSendWithDataOperation.h b/src/async/smtp/MCSMTPSendWithDataOperation.h index afa1a5e0..6c407bb3 100644 --- a/src/async/smtp/MCSMTPSendWithDataOperation.h +++ b/src/async/smtp/MCSMTPSendWithDataOperation.h @@ -23,6 +23,12 @@ namespace mailcore { SMTPSendWithDataOperation(); virtual ~SMTPSendWithDataOperation(); + virtual void setFrom(Address * from); + virtual Address * from(); + + virtual void setRecipients(Array * recipients); + virtual Array * recipients(); + virtual void setMessageData(Data * data); virtual Data * messageData(); @@ -31,6 +37,8 @@ namespace mailcore { private: Data * mMessageData; + Array * mRecipients; + Address * mFrom; }; } |