aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/imap
diff options
context:
space:
mode:
authorGravatar Hoa V. DINH <dinh.viet.hoa@gmail.com>2013-06-29 14:42:19 -0700
committerGravatar Hoa V. DINH <dinh.viet.hoa@gmail.com>2013-06-29 14:42:19 -0700
commit934f99cf96ae362b898528ef357f9af148ed01c6 (patch)
tree176e9599f8dcc4d9ce4770f3def1b7f41fdc2e95 /src/core/imap
parentd5848cbbb862ffa0b3e44e978acf042eeed63ce7 (diff)
Support of OAuth2 on C++ layer. Also reindent code.
Diffstat (limited to 'src/core/imap')
-rw-r--r--src/core/imap/MCIMAPSession.cc16
-rw-r--r--src/core/imap/MCIMAPSession.h6
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;