aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
authorGravatar Hoa V. DINH <dinh.viet.hoa@gmail.com>2014-01-21 20:56:53 -0800
committerGravatar Hoa V. DINH <dinh.viet.hoa@gmail.com>2014-01-21 20:57:27 -0800
commitd6899960904a0713b193855d4f1b81afc3473097 (patch)
tree16ae7d24706d3d6dcbc6a866c883dda897a2eb34 /src/core
parent606b4da3e35efa6633b0c02bc7f77e3b3789c8ab (diff)
Retrieve Gmail user display name
Diffstat (limited to 'src/core')
-rw-r--r--src/core/abstract/MCMessageConstants.h3
-rwxr-xr-xsrc/core/imap/MCIMAPSession.cc28
-rwxr-xr-xsrc/core/imap/MCIMAPSession.h6
3 files changed, 37 insertions, 0 deletions
diff --git a/src/core/abstract/MCMessageConstants.h b/src/core/abstract/MCMessageConstants.h
index f5d7f259..95bf1201 100644
--- a/src/core/abstract/MCMessageConstants.h
+++ b/src/core/abstract/MCMessageConstants.h
@@ -42,6 +42,9 @@ namespace mailcore {
IMAPFolderFlagAll = IMAPFolderFlagAllMail,
IMAPFolderFlagJunk = IMAPFolderFlagSpam,
IMAPFolderFlagFlagged = IMAPFolderFlagStarred,
+ IMAPFolderFlagFolderTypeMask = IMAPFolderFlagInbox | IMAPFolderFlagSentMail | IMAPFolderFlagStarred | IMAPFolderFlagAllMail |
+ IMAPFolderFlagTrash| IMAPFolderFlagDrafts | IMAPFolderFlagSpam | IMAPFolderFlagImportant | IMAPFolderFlagArchive;
+
};
enum MessageFlag {
diff --git a/src/core/imap/MCIMAPSession.cc b/src/core/imap/MCIMAPSession.cc
index 32cd4ebd..50ab4f70 100755
--- a/src/core/imap/MCIMAPSession.cc
+++ b/src/core/imap/MCIMAPSession.cc
@@ -320,6 +320,7 @@ void IMAPSession::init()
mIdentityEnabled = false;
mNamespaceEnabled = false;
mCompressionEnabled = false;
+ mIsGmail = false;
mWelcomeString = NULL;
mNeedsMboxMailWorkaround = false;
mDefaultNamespace = NULL;
@@ -344,6 +345,8 @@ void IMAPSession::init()
mAutomaticConfigurationEnabled = true;
mAutomaticConfigurationDone = false;
mShouldDisconnect = false;
+ mLoginResponse = NULL;
+ mGmailUserDisplayName = NULL;
}
IMAPSession::IMAPSession()
@@ -353,6 +356,8 @@ IMAPSession::IMAPSession()
IMAPSession::~IMAPSession()
{
+ MC_SAFE_RELEASE(mGmailUserDisplayName);
+ MC_SAFE_RELEASE(mLoginResponse);
MC_SAFE_RELEASE(mClientIdentity);
MC_SAFE_RELEASE(mServerIdentity);
MC_SAFE_RELEASE(mHostname);
@@ -819,6 +824,23 @@ void IMAPSession::login(ErrorCode * pError)
return;
}
+ String * loginResponse = MCSTR("");
+ if (mIsGmail) {
+ if (mImap->imap_response != NULL) {
+ loginResponse = String::stringWithUTF8Characters(mImap->imap_response);
+
+ int location = loginResponse->locationOfString(MCSTR(" authenticated (Success)"));
+ if (location != -1) {
+ String * emailAndName = loginResponse->substringToIndex(location);
+ location = emailAndName->locationOfString(MCSTR(" "));
+ MC_SAFE_RELEASE(mGmailUserDisplayName);
+ mGmailUserDisplayName = emailAndName->substringFromIndex(location + 1);
+ mGmailUserDisplayName->retain();
+ }
+ }
+ }
+ MC_SAFE_REPLACE_COPY(String, mLoginResponse, loginResponse);
+
mState = STATE_LOGGEDIN;
if (isAutomaticConfigurationEnabled()) {
@@ -3494,6 +3516,7 @@ void IMAPSession::applyCapabilities(IndexSet * capabilities)
}
if (capabilities->containsIndex(IMAPCapabilityGmail)) {
mXListEnabled = false;
+ mIsGmail = true;
}
if (capabilities->containsIndex(IMAPCapabilityIdle)) {
mIdleEnabled = true;
@@ -3726,3 +3749,8 @@ void IMAPSession::resetAutomaticConfigurationDone()
{
mAutomaticConfigurationDone = false;
}
+
+String * IMAPSession::gmailUserDisplayName()
+{
+ return mGmailUserDisplayName;
+}
diff --git a/src/core/imap/MCIMAPSession.h b/src/core/imap/MCIMAPSession.h
index 0cd91fcb..f185483f 100755
--- a/src/core/imap/MCIMAPSession.h
+++ b/src/core/imap/MCIMAPSession.h
@@ -163,6 +163,8 @@ namespace mailcore {
virtual bool isNamespaceEnabled();
virtual bool isCompressionEnabled();
+ virtual String * gmailUserDisplayName();
+
virtual void setConnectionLogger(ConnectionLogger * logger);
virtual ConnectionLogger * connectionLogger();
@@ -219,6 +221,7 @@ namespace mailcore {
bool mXOauth2Enabled;
bool mNamespaceEnabled;
bool mCompressionEnabled;
+ bool mIsGmail;
String * mWelcomeString;
bool mNeedsMboxMailWorkaround;
uint32_t mUIDValidity;
@@ -241,6 +244,9 @@ namespace mailcore {
bool mAutomaticConfigurationDone;
bool mShouldDisconnect;
+ String * mLoginResponse;
+ String * mGmailUserDisplayName;
+
void init();
void bodyProgress(unsigned int current, unsigned int maximum);
void itemsProgress(unsigned int current, unsigned int maximum);