diff options
author | 2013-09-06 13:32:13 +1200 | |
---|---|---|
committer | 2013-09-06 13:32:13 +1200 | |
commit | 755d656cc5e5119e44d6250efbd97cf388a44433 (patch) | |
tree | d8a2c31874a432a87188d4b76c9ad56238048a89 | |
parent | 1d0cb6e92f546935d547f7be95ae36eea3547894 (diff) |
Add MCOIMAPConnectOperation, include STARTTLS and auth methods in autoconfiguration
-rwxr-xr-x | src/async/imap/MCIMAPAsyncConnection.cc | 9 | ||||
-rwxr-xr-x | src/async/imap/MCIMAPAsyncConnection.h | 1 | ||||
-rwxr-xr-x | src/async/imap/MCIMAPAsyncSession.cc | 6 | ||||
-rwxr-xr-x | src/async/imap/MCIMAPAsyncSession.h | 1 | ||||
-rw-r--r-- | src/async/imap/MCIMAPConnectOperation.cc | 21 | ||||
-rw-r--r-- | src/async/imap/MCIMAPConnectOperation.h | 26 | ||||
-rwxr-xr-x | src/core/imap/MCIMAPSession.cc | 9 | ||||
-rwxr-xr-x | src/objc/imap/MCOIMAPSession.h | 12 | ||||
-rwxr-xr-x | src/objc/imap/MCOIMAPSession.mm | 6 |
9 files changed, 91 insertions, 0 deletions
diff --git a/src/async/imap/MCIMAPAsyncConnection.cc b/src/async/imap/MCIMAPAsyncConnection.cc index d1322687..f4e6b73b 100755 --- a/src/async/imap/MCIMAPAsyncConnection.cc +++ b/src/async/imap/MCIMAPAsyncConnection.cc @@ -25,6 +25,7 @@ #include "MCIMAPStoreFlagsOperation.h" #include "MCIMAPStoreLabelsOperation.h" #include "MCIMAPSearchOperation.h" +#include "MCIMAPConnectOperation.h" #include "MCIMAPCheckAccountOperation.h" #include "MCIMAPFetchNamespaceOperation.h" #include "MCIMAPIdleOperation.h" @@ -487,6 +488,14 @@ IMAPIdentityOperation * IMAPAsyncConnection::identityOperation(IMAPIdentity * id return op; } +IMAPOperation * IMAPAsyncConnection::connectOperation() +{ + IMAPConnectOperation * op = new IMAPConnectOperation(); + op->setSession(this); + op->autorelease(); + return op; +} + IMAPOperation * IMAPAsyncConnection::checkAccountOperation() { IMAPCheckAccountOperation * op = new IMAPCheckAccountOperation(); diff --git a/src/async/imap/MCIMAPAsyncConnection.h b/src/async/imap/MCIMAPAsyncConnection.h index 9f1b9d47..934180fd 100755 --- a/src/async/imap/MCIMAPAsyncConnection.h +++ b/src/async/imap/MCIMAPAsyncConnection.h @@ -123,6 +123,7 @@ namespace mailcore { virtual IMAPIdentityOperation * identityOperation(IMAPIdentity * identity); + virtual IMAPOperation * connectOperation(); virtual IMAPOperation * checkAccountOperation(); virtual IMAPCapabilityOperation * capabilityOperation(); diff --git a/src/async/imap/MCIMAPAsyncSession.cc b/src/async/imap/MCIMAPAsyncSession.cc index 5fe9a61b..7e791ce9 100755 --- a/src/async/imap/MCIMAPAsyncSession.cc +++ b/src/async/imap/MCIMAPAsyncSession.cc @@ -448,6 +448,12 @@ IMAPIdentityOperation * IMAPAsyncSession::identityOperation(IMAPIdentity * ident return session->identityOperation(identity); } +IMAPOperation * IMAPAsyncSession::connectOperation() +{ + IMAPAsyncConnection * session = sessionForFolder(MCSTR("INBOX")); + return session->connectOperation(); +} + IMAPOperation * IMAPAsyncSession::checkAccountOperation() { IMAPAsyncConnection * session = sessionForFolder(MCSTR("INBOX")); diff --git a/src/async/imap/MCIMAPAsyncSession.h b/src/async/imap/MCIMAPAsyncSession.h index 10af928d..33362e01 100755 --- a/src/async/imap/MCIMAPAsyncSession.h +++ b/src/async/imap/MCIMAPAsyncSession.h @@ -138,6 +138,7 @@ namespace mailcore { virtual IMAPIdentityOperation * identityOperation(IMAPIdentity * identity); + virtual IMAPOperation * connectOperation(); virtual IMAPOperation * checkAccountOperation(); virtual IMAPCapabilityOperation * capabilityOperation(); diff --git a/src/async/imap/MCIMAPConnectOperation.cc b/src/async/imap/MCIMAPConnectOperation.cc new file mode 100644 index 00000000..e4f71d03 --- /dev/null +++ b/src/async/imap/MCIMAPConnectOperation.cc @@ -0,0 +1,21 @@ +// +// MCIMAPConnectOperation.cc +// mailcore2 +// +// Created by Ryan Walklin on 6/09/13. +// Copyright (c) 2013 MailCore. All rights reserved. +// + +#include "MCIMAPConnectOperation.h" + +#include "MCIMAPAsyncConnection.h" +#include "MCIMAPSession.h" + +using namespace mailcore; + +void IMAPConnectOperation::main() +{ + ErrorCode error; + session()->session()->connectIfNeeded(&error); + setError(error); +} diff --git a/src/async/imap/MCIMAPConnectOperation.h b/src/async/imap/MCIMAPConnectOperation.h new file mode 100644 index 00000000..a5d3c035 --- /dev/null +++ b/src/async/imap/MCIMAPConnectOperation.h @@ -0,0 +1,26 @@ +// +// MCIMAPConnectOperation.h +// mailcore2 +// +// Created by Ryan Walklin on 6/09/13. +// Copyright (c) 2013 MailCore. All rights reserved. +// + +#ifndef __MAILCORE_MCIMAPCONNECTOPERATION_H_ +#define __MAILCORE_MCIMAPCONNECTOPERATION_H_ + +#include <MailCore/MCIMAPOperation.h> + +#ifdef __cplusplus + +namespace mailcore { + + class IMAPConnectOperation : public IMAPOperation { + public: // subclass behavior + virtual void main(); + }; +} + +#endif + +#endif /* defined(__MAILCORE_MCIMAPCONNECTOPERATION_H_) */ diff --git a/src/core/imap/MCIMAPSession.cc b/src/core/imap/MCIMAPSession.cc index f08ff91a..31bbbc62 100755 --- a/src/core/imap/MCIMAPSession.cc +++ b/src/core/imap/MCIMAPSession.cc @@ -3189,6 +3189,15 @@ IndexSet * IMAPSession::capability(ErrorCode * pError) void IMAPSession::capabilitySetWithSessionState(IndexSet * capabilities) { + if (mailimap_has_extension(mImap, (char *)"STARTTLS")) { + capabilities->addIndex(IMAPCapabilityStartTLS); + } + if (mailimap_has_authentication(mImap, (char *)"PLAIN")) { + capabilities->addIndex(IMAPCapabilityAuthPlain); + } + if (mailimap_has_authentication(mImap, (char *)"LOGIN")) { + capabilities->addIndex(IMAPCapabilityAuthLogin); + } if (mailimap_has_idle(mImap)) { LOCK(); mCanIdle = true; diff --git a/src/objc/imap/MCOIMAPSession.h b/src/objc/imap/MCOIMAPSession.h index e63e1745..f4c6b85b 100755 --- a/src/objc/imap/MCOIMAPSession.h +++ b/src/objc/imap/MCOIMAPSession.h @@ -504,6 +504,17 @@ - (MCOIMAPIdentityOperation *) identityOperationWithClientIdentity:(MCOIMAPIdentity *)identity; /** + Returns an operation that will connect to the given IMAP server without authenticating. + Useful for checking initial server capabilities. + + MCOIMAPOperation * op = [session connectOperation]; + [op start:^(NSError * error) { + ... + }]; + */ +- (MCOIMAPOperation *)connectOperation; + +/** Returns an operation that will check whether the IMAP account is valid. MCOIMAPOperation * op = [session checkAccountOperation]; @@ -511,6 +522,7 @@ ... }]; */ + - (MCOIMAPOperation *) checkAccountOperation; /** diff --git a/src/objc/imap/MCOIMAPSession.mm b/src/objc/imap/MCOIMAPSession.mm index 8b4bb363..e7732b16 100755 --- a/src/objc/imap/MCOIMAPSession.mm +++ b/src/objc/imap/MCOIMAPSession.mm @@ -390,6 +390,12 @@ MCO_OBJC_SYNTHESIZE_SCALAR(unsigned int, unsigned int, setMaximumConnections, ma return MCO_TO_OBJC_OP(coreOp); } +- (MCOIMAPOperation *)connectOperation +{ + IMAPOperation *coreOp = MCO_NATIVE_INSTANCE->connectOperation(); + return OPAQUE_OPERATION(coreOp); +} + - (MCOIMAPOperation *)checkAccountOperation { IMAPOperation *coreOp = MCO_NATIVE_INSTANCE->checkAccountOperation(); |