diff options
author | 2013-08-18 00:52:57 -0700 | |
---|---|---|
committer | 2013-08-18 00:52:57 -0700 | |
commit | 2620459cbc853d4bf166acf9080640953554534b (patch) | |
tree | e11f7bdbeccbc37fc1e86cc7580a19b61cbc848e /src | |
parent | 513f9bd1a0b468036e1c7e10414a40d30acbdf30 (diff) | |
parent | 381019b71729db9c398e6e5a0ce4d1190048eed6 (diff) |
Merge branch 'master' into autoconfiguration
Diffstat (limited to 'src')
-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 | ||||
-rwxr-xr-x | src/core/imap/MCIMAPSession.cc | 8 | ||||
-rwxr-xr-x | src/core/imap/MCIMAPSession.h | 1 | ||||
-rw-r--r-- | src/core/smtp/MCSMTPSession.h | 4 | ||||
-rw-r--r-- | src/objc/smtp/MCOSMTPSession.h | 18 | ||||
-rw-r--r-- | src/objc/smtp/MCOSMTPSession.mm | 13 |
9 files changed, 92 insertions, 4 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; }; } diff --git a/src/core/imap/MCIMAPSession.cc b/src/core/imap/MCIMAPSession.cc index 4384bf28..05330573 100755 --- a/src/core/imap/MCIMAPSession.cc +++ b/src/core/imap/MCIMAPSession.cc @@ -346,6 +346,7 @@ void IMAPSession::init() mModSequenceValue = 0; mFolderMsgCount = 0; mFirstUnseenUid = 0; + mYahooServer = false; mLastFetchedSequenceNumber = 0; mCurrentFolder = NULL; pthread_mutex_init(&mIdleLock, NULL); @@ -638,6 +639,7 @@ void IMAPSession::connect(ErrorCode * pError) if (mImap->imap_response != NULL) { MC_SAFE_REPLACE_RETAIN(String, mWelcomeString, String::stringWithUTF8Characters(mImap->imap_response)); + mYahooServer = (mWelcomeString->locationOfString(MCSTR("yahoo.com")) != -1); } mState = STATE_CONNECTED; @@ -2544,7 +2546,11 @@ IndexSet * IMAPSession::search(String * folder, IMAPSearchExpression * expressio clist * result_list = NULL; - int r = mailimap_uid_search(mImap, "utf-8", key, &result_list); + const char * charset = "utf-8"; + if (mYahooServer) { + charset = NULL; + } + int r = mailimap_uid_search(mImap, charset, key, &result_list); mailimap_search_key_free(key); MCLog("had error : %i", r); if (r == MAILIMAP_ERROR_STREAM) { diff --git a/src/core/imap/MCIMAPSession.h b/src/core/imap/MCIMAPSession.h index 19418323..dceab02b 100755 --- a/src/core/imap/MCIMAPSession.h +++ b/src/core/imap/MCIMAPSession.h @@ -221,6 +221,7 @@ namespace mailcore { uint64_t mModSequenceValue; unsigned int mFolderMsgCount; uint32_t mFirstUnseenUid; + bool mYahooServer; unsigned int mLastFetchedSequenceNumber; String * mCurrentFolder; diff --git a/src/core/smtp/MCSMTPSession.h b/src/core/smtp/MCSMTPSession.h index 3d066a6c..1b4c9690 100644 --- a/src/core/smtp/MCSMTPSession.h +++ b/src/core/smtp/MCSMTPSession.h @@ -58,6 +58,8 @@ namespace mailcore { virtual void checkAccount(Address * from, ErrorCode * pError); virtual void sendMessage(Data * messageData, SMTPProgressCallback * callback, ErrorCode * pError); + virtual void sendMessage(Address * from, Array * /* Address */ recipients, Data * messageData, + SMTPProgressCallback * callback, ErrorCode * pError); virtual void setConnectionLogger(ConnectionLogger * logger); virtual ConnectionLogger * connectionLogger(); @@ -93,8 +95,6 @@ namespace mailcore { void loginIfNeeded(ErrorCode * pError); bool checkCertificate(); - void sendMessage(Address * from, Array * /* Address */ recipients, Data * messageData, - SMTPProgressCallback * callback, ErrorCode * pError); void sendMessage(MessageBuilder * msg, SMTPProgressCallback * callback, ErrorCode * pError); public: // private diff --git a/src/objc/smtp/MCOSMTPSession.h b/src/objc/smtp/MCOSMTPSession.h index bb7c5f57..6716ee30 100644 --- a/src/objc/smtp/MCOSMTPSession.h +++ b/src/objc/smtp/MCOSMTPSession.h @@ -93,6 +93,24 @@ - (MCOSMTPSendOperation *) sendOperationWithData:(NSData *)messageData; /** + Returns an operation that will send the given message through SMTP. + It will use the sender and recipient set from the parameters. + It will also filter out Bcc from the content of the message. + + Generate RFC 822 data using MCOMessageBuilder + + MCOPOPOperation * op = [session sendOperationWithData:rfc822Data + from:[MCOAddress addressWithMailbox:@"hoa@etpan.org"] + recipients:[NSArray arrayWithObject:[MCOAddress addressWithMailbox:@"laura@etpan.org"]]]; + [op start:^(NSError * error) { + ... + }]; + */ +- (MCOSMTPSendOperation *) sendOperationWithData:(NSData *)messageData + from:(MCOAddress *)from + recipients:(NSArray *)recipients; + +/** Returns an operation that will check whether the SMTP account is valid. MCOPOPOperation * op = [session checkAccountOperationWithFrom:[MCOAddress addressWithMailbox:@"hoa@etpan.org"]]; diff --git a/src/objc/smtp/MCOSMTPSession.mm b/src/objc/smtp/MCOSMTPSession.mm index c9f9f0fc..0c24f66c 100644 --- a/src/objc/smtp/MCOSMTPSession.mm +++ b/src/objc/smtp/MCOSMTPSession.mm @@ -109,6 +109,19 @@ MCO_OBJC_SYNTHESIZE_BOOL(setUseHeloIPEnabled, useHeloIPEnabled) return result; } +- (MCOSMTPSendOperation *) sendOperationWithData:(NSData *)messageData + from:(MCOAddress *)from + recipients:(NSArray *)recipients +{ + mailcore::SMTPOperation * coreOp = + MCO_NATIVE_INSTANCE->sendMessageOperation(MCO_FROM_OBJC(Address, from), + MCO_FROM_OBJC(Array, recipients), + [messageData mco_mcData]); + MCOSMTPSendOperation * result = [[[MCOSMTPSendOperation alloc] initWithMCOperation:coreOp] autorelease]; + [result setSession:self]; + return result; +} + - (MCOOperation *) checkAccountOperationWithFrom:(MCOAddress *)from { mailcore::SMTPOperation *coreOp = MCO_NATIVE_INSTANCE->checkAccountOperation(MCO_FROM_OBJC(mailcore::Address, from)); |