aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rwxr-xr-xsrc/async/imap/MCIMAPAsyncSession.cc8
-rwxr-xr-xsrc/async/imap/MCIMAPAsyncSession.h2
-rw-r--r--src/core/abstract/MCMessageConstants.h3
-rwxr-xr-xsrc/core/imap/MCIMAPSession.cc28
-rwxr-xr-xsrc/core/imap/MCIMAPSession.h6
-rw-r--r--src/objc/abstract/MCOConstants.h3
-rwxr-xr-xsrc/objc/imap/MCOIMAPSession.h3
-rwxr-xr-xsrc/objc/imap/MCOIMAPSession.mm5
8 files changed, 58 insertions, 0 deletions
diff --git a/src/async/imap/MCIMAPAsyncSession.cc b/src/async/imap/MCIMAPAsyncSession.cc
index 1aa44f1d..8c3678e1 100755
--- a/src/async/imap/MCIMAPAsyncSession.cc
+++ b/src/async/imap/MCIMAPAsyncSession.cc
@@ -45,10 +45,12 @@ IMAPAsyncSession::IMAPAsyncSession()
#if __APPLE__
mDispatchQueue = dispatch_get_main_queue();
#endif
+ mGmailUserDisplayName = NULL;
}
IMAPAsyncSession::~IMAPAsyncSession()
{
+ MC_SAFE_RELEASE(mGmailUserDisplayName);
MC_SAFE_RELEASE(mServerIdentity);
MC_SAFE_RELEASE(mClientIdentity);
MC_SAFE_RELEASE(mSessions);
@@ -199,6 +201,11 @@ IMAPIdentity * IMAPAsyncSession::clientIdentity()
return mClientIdentity;
}
+String * IMAPAsyncSession::gmailUserDisplayName()
+{
+ return mGmailUserDisplayName;
+}
+
IMAPAsyncConnection * IMAPAsyncSession::session()
{
IMAPAsyncConnection * session = new IMAPAsyncConnection();
@@ -540,6 +547,7 @@ IMAPMessageRenderingOperation * IMAPAsyncSession::plainTextBodyRenderingOperatio
void IMAPAsyncSession::automaticConfigurationDone(IMAPSession * session)
{
MC_SAFE_REPLACE_COPY(IMAPIdentity, mServerIdentity, session->serverIdentity());
+ MC_SAFE_REPLACE_COPY(String, mGmailUserDisplayName, session->gmailUserDisplayName());
setDefaultNamespace(session->defaultNamespace());
mAutomaticConfigurationDone = true;
}
diff --git a/src/async/imap/MCIMAPAsyncSession.h b/src/async/imap/MCIMAPAsyncSession.h
index 3b1f2ccc..24fb6f91 100755
--- a/src/async/imap/MCIMAPAsyncSession.h
+++ b/src/async/imap/MCIMAPAsyncSession.h
@@ -100,6 +100,7 @@ namespace mailcore {
virtual IMAPIdentity * serverIdentity();
virtual IMAPIdentity * clientIdentity();
+ virtual String * gmailUserDisplayName();
virtual IMAPFolderInfoOperation * folderInfoOperation(String * folder);
virtual IMAPFolderStatusOperation * folderStatusOperation(String * folder);
@@ -186,6 +187,7 @@ namespace mailcore {
#if __APPLE__
dispatch_queue_t mDispatchQueue;
#endif
+ String * mGmailUserDisplayName;
virtual IMAPAsyncConnection * sessionForFolder(String * folder, bool urgent = false);
virtual IMAPAsyncConnection * session();
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);
diff --git a/src/objc/abstract/MCOConstants.h b/src/objc/abstract/MCOConstants.h
index 17af29eb..534d118d 100644
--- a/src/objc/abstract/MCOConstants.h
+++ b/src/objc/abstract/MCOConstants.h
@@ -72,6 +72,9 @@ typedef enum {
MCOIMAPFolderFlagJunk = MCOIMAPFolderFlagSpam,
/** \Flagged: When the folder contains all the flagged emails.*/
MCOIMAPFolderFlagFlagged = MCOIMAPFolderFlagStarred,
+ /** Mask to identify the folder */
+ MCOIMAPFolderFlagFolderTypeMask = MCOIMAPFolderFlagInbox | MCOIMAPFolderFlagSentMail | MCOIMAPFolderFlagStarred | MCOIMAPFolderFlagAllMail |
+ MCOIMAPFolderFlagTrash| MCOIMAPFolderFlagDrafts | MCOIMAPFolderFlagSpam | MCOIMAPFolderFlagImportant | MCOIMAPFolderFlagArchive,
} MCOIMAPFolderFlag;
/** It's the flags of a message.*/
diff --git a/src/objc/imap/MCOIMAPSession.h b/src/objc/imap/MCOIMAPSession.h
index abfcc8da..8ddfa8cd 100755
--- a/src/objc/imap/MCOIMAPSession.h
+++ b/src/objc/imap/MCOIMAPSession.h
@@ -89,6 +89,9 @@
/** The identity of the IMAP server. */
@property (nonatomic, strong, readonly) MCOIMAPIdentity * serverIdentity;
+/** Display name of the Gmail user. It will be nil if it's not a Gmail server. */
+@property (nonatomic, copy, readonly) NSString * gmailUserDisplayName;
+
/**
When set to YES, the session is allowed open to open several connections to the same folder.
@warning Some older IMAP servers don't like this
diff --git a/src/objc/imap/MCOIMAPSession.mm b/src/objc/imap/MCOIMAPSession.mm
index 6e788a36..762e594a 100755
--- a/src/objc/imap/MCOIMAPSession.mm
+++ b/src/objc/imap/MCOIMAPSession.mm
@@ -127,6 +127,11 @@ MCO_OBJC_SYNTHESIZE_SCALAR(dispatch_queue_t, dispatch_queue_t, setDispatchQueue,
return MCO_OBJC_BRIDGE_GET(serverIdentity);
}
+- (NSString *) gmailUserDisplayName
+{
+ return MCO_TO_OBJC(_session->gmailUserDisplayName());
+}
+
- (void) setConnectionLogger:(MCOConnectionLogger)connectionLogger
{
[_connectionLogger release];