diff options
author | 2013-06-29 14:42:19 -0700 | |
---|---|---|
committer | 2013-06-29 14:42:19 -0700 | |
commit | 934f99cf96ae362b898528ef357f9af148ed01c6 (patch) | |
tree | 176e9599f8dcc4d9ce4770f3def1b7f41fdc2e95 /src/core/imap | |
parent | d5848cbbb862ffa0b3e44e978acf042eeed63ce7 (diff) |
Support of OAuth2 on C++ layer. Also reindent code.
Diffstat (limited to 'src/core/imap')
-rw-r--r-- | src/core/imap/MCIMAPSession.cc | 16 | ||||
-rw-r--r-- | src/core/imap/MCIMAPSession.h | 6 |
2 files changed, 22 insertions, 0 deletions
diff --git a/src/core/imap/MCIMAPSession.cc b/src/core/imap/MCIMAPSession.cc index 2dc970c5..8437cded 100644 --- a/src/core/imap/MCIMAPSession.cc +++ b/src/core/imap/MCIMAPSession.cc @@ -313,6 +313,7 @@ void IMAPSession::init() mPort = 0; mUsername = NULL; mPassword = NULL; + mOAuth2Token = NULL; mAuthType = AuthTypeSASLNone; mConnectionType = ConnectionTypeClear; mCheckCertificateEnabled = true; @@ -355,6 +356,7 @@ IMAPSession::~IMAPSession() MC_SAFE_RELEASE(mHostname); MC_SAFE_RELEASE(mUsername); MC_SAFE_RELEASE(mPassword); + MC_SAFE_RELEASE(mOAuth2Token); MC_SAFE_RELEASE(mWelcomeString); MC_SAFE_RELEASE(mDefaultNamespace); MC_SAFE_RELEASE(mCurrentFolder); @@ -401,6 +403,16 @@ String * IMAPSession::password() return mPassword; } +void IMAPSession::setOAuth2Token(String * token) +{ + MC_SAFE_REPLACE_COPY(String, mOAuth2Token, token); +} + +String * IMAPSession::OAuth2Token() +{ + return mOAuth2Token; +} + void IMAPSession::setAuthType(AuthType authType) { mAuthType = authType; @@ -746,6 +758,10 @@ void IMAPSession::login(ErrorCode * pError) utf8username, utf8username, utf8password, NULL/* realm */); break; + + case AuthTypeXOAuth2: + r = mailimap_oauth2_authenticate(mImap, MCUTF8(mUsername), MCUTF8(mOAuth2Token)); + break; } if (r == MAILIMAP_ERROR_STREAM) { * pError = ErrorConnection; diff --git a/src/core/imap/MCIMAPSession.h b/src/core/imap/MCIMAPSession.h index ac282072..212f0876 100644 --- a/src/core/imap/MCIMAPSession.h +++ b/src/core/imap/MCIMAPSession.h @@ -37,6 +37,11 @@ namespace mailcore { virtual void setPassword(String * password); virtual String * password(); + // To authenticate using OAuth2, username and oauth2token should be set. + // auth type to use is AuthTypeOAuth2. + virtual void setOAuth2Token(String * token); + virtual String * OAuth2Token(); + virtual void setAuthType(AuthType authType); virtual AuthType authType(); @@ -145,6 +150,7 @@ namespace mailcore { unsigned int mPort; String * mUsername; String * mPassword; + String * mOAuth2Token; AuthType mAuthType; ConnectionType mConnectionType; bool mCheckCertificateEnabled; |