From aefac083c0553f0a71f808eea1d93458496e026e Mon Sep 17 00:00:00 2001 From: Lenny Date: Fri, 28 Jun 2013 09:30:17 -0700 Subject: ignore build/ folders --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index ef1ed6b8..dd5dc7b7 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,4 @@ project.xcworkspace example/ios/iOS UI Test/DerivedData - +build/ -- cgit v1.2.3 From d2daea1a6980e6395fd62a79fd7620eee0d2a539 Mon Sep 17 00:00:00 2001 From: Pushkar Singh Date: Wed, 3 Jul 2013 15:08:28 -0700 Subject: Removed extra x --- src/async/imap/MCIMAPCheckAccountOperation.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/async/imap/MCIMAPCheckAccountOperation.h b/src/async/imap/MCIMAPCheckAccountOperation.h index 2e3ddbd9..78c95d52 100644 --- a/src/async/imap/MCIMAPCheckAccountOperation.h +++ b/src/async/imap/MCIMAPCheckAccountOperation.h @@ -1,4 +1,4 @@ -x// +// // MCIMAPCheckAccountOperation.h // mailcore2 // -- cgit v1.2.3 From 4970546ecec70e89e2baece66eccfd350c499050 Mon Sep 17 00:00:00 2001 From: "Hoa V. DINH" Date: Mon, 5 Aug 2013 16:40:50 -0700 Subject: Internal callbacks for ops, before and after running. --- src/core/basetypes/MCOperation.cc | 8 ++++++++ src/core/basetypes/MCOperation.h | 8 +++++++- src/core/basetypes/MCOperationQueue.cc | 13 ++++++++++--- src/core/basetypes/MCOperationQueue.h | 1 + 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/core/basetypes/MCOperation.cc b/src/core/basetypes/MCOperation.cc index d42a0598..73a8d7cd 100644 --- a/src/core/basetypes/MCOperation.cc +++ b/src/core/basetypes/MCOperation.cc @@ -40,10 +40,18 @@ bool Operation::isCancelled() return value; } +void Operation::beforeMain() +{ +} + void Operation::main() { } +void Operation::afterMain() +{ +} + void Operation::start() { } diff --git a/src/core/basetypes/MCOperation.h b/src/core/basetypes/MCOperation.h index 71d0b465..bb77dbb1 100644 --- a/src/core/basetypes/MCOperation.h +++ b/src/core/basetypes/MCOperation.h @@ -18,11 +18,17 @@ namespace mailcore { virtual void setCallback(OperationCallback * callback); virtual OperationCallback * callback(); - + virtual void cancel(); virtual bool isCancelled(); + // Will be called on main thread. + virtual void beforeMain(); + virtual void main(); + + // Will be called on main thread. + virtual void afterMain(); virtual void start(); diff --git a/src/core/basetypes/MCOperationQueue.cc b/src/core/basetypes/MCOperationQueue.cc index 9c30ad22..c20cb907 100644 --- a/src/core/basetypes/MCOperationQueue.cc +++ b/src/core/basetypes/MCOperationQueue.cc @@ -84,6 +84,8 @@ void OperationQueue::runOperations() break; } + performMethodOnMainThread((Object::Method) &OperationQueue::beforeMain, op, true); + op->main(); op->retain()->autorelease(); @@ -99,9 +101,7 @@ void OperationQueue::runOperations() pthread_mutex_unlock(&mLock); if (!op->isCancelled()) { - if (op->callback() != NULL) { - performMethodOnMainThread((Object::Method) &OperationQueue::callbackOnMainThread, op, true); - } + performMethodOnMainThread((Object::Method) &OperationQueue::callbackOnMainThread, op, true); } if (needsCheckRunning) { @@ -115,8 +115,15 @@ void OperationQueue::runOperations() MCLog("cleanup thread %p", this); } +void OperationQueue::beforeMain(Operation * op) +{ + op->beforeMain(); +} + void OperationQueue::callbackOnMainThread(Operation * op) { + op->afterMain(); + if (op->isCancelled()) return; diff --git a/src/core/basetypes/MCOperationQueue.h b/src/core/basetypes/MCOperationQueue.h index ddfe9de2..0518d62f 100644 --- a/src/core/basetypes/MCOperationQueue.h +++ b/src/core/basetypes/MCOperationQueue.h @@ -43,6 +43,7 @@ namespace mailcore { void startThread(); static void runOperationsOnThread(OperationQueue * queue); void runOperations(); + void beforeMain(Operation * op); void callbackOnMainThread(Operation * op); void checkRunningOnMainThread(void * context); void checkRunningAfterDelay(void * context); -- cgit v1.2.3 From f3a2c777ebe69fe2fefbebb31788757d82ce1837 Mon Sep 17 00:00:00 2001 From: "Hoa V. DINH" Date: Mon, 5 Aug 2013 16:41:50 -0700 Subject: Automatic fetch of namespace and capabilities in IMAPSession --- src/core/imap/MCIMAPSession.cc | 196 ++++++++++++++++++++++++++++++++++++++--- src/core/imap/MCIMAPSession.h | 18 ++++ 2 files changed, 200 insertions(+), 14 deletions(-) diff --git a/src/core/imap/MCIMAPSession.cc b/src/core/imap/MCIMAPSession.cc index 7ebe4354..13cff58c 100644 --- a/src/core/imap/MCIMAPSession.cc +++ b/src/core/imap/MCIMAPSession.cc @@ -36,6 +36,8 @@ String * mailcore::IMAPNamespacePersonal = NULL; String * mailcore::IMAPNamespaceOther = NULL; String * mailcore::IMAPNamespaceShared = NULL; +static Array * resultsWithError(int r, clist * list, ErrorCode * pError); + __attribute__((constructor)) static void initialize() { @@ -333,6 +335,7 @@ void IMAPSession::init() mQResyncEnabled = false; mCondstoreEnabled = false; mIdentityEnabled = false; + mNamespaceEnabled = false; mWelcomeString = NULL; mNeedsMboxMailWorkaround = false; mDefaultNamespace = NULL; @@ -351,6 +354,9 @@ void IMAPSession::init() mProgressCallback = NULL; mProgressItemsCount = 0; mConnectionLogger = NULL; + mAutomaticCapabilitiesEnabled = true; + mAutomaticNamespaceEnabled = true; + mAutomaticConfigurationDone = false; } IMAPSession::IMAPSession() @@ -634,8 +640,24 @@ void IMAPSession::connect(ErrorCode * pError) MC_SAFE_REPLACE_RETAIN(String, mWelcomeString, String::stringWithUTF8Characters(mImap->imap_response)); } - * pError = ErrorNone; mState = STATE_CONNECTED; + + if (isAutomaticCapabilitiesEnabled()) { + if ((mImap->imap_connection_info != NULL) && (mImap->imap_connection_info->imap_capability != NULL)) { + // Don't keep result. It will be kept in session state. + capabilitySetWithSessionState(IndexSet::indexSet()); + } + else { + IndexSet * capabilities = capability(pError); + if (* pError != ErrorNone) { + MCLog("capabilities failed"); + unsetup(); + return; + } + } + } + + * pError = ErrorNone; MCLog("connect ok"); LOCK(); mCanIdle = true; @@ -674,6 +696,13 @@ void IMAPSession::login(ErrorCode * pError) MCAssert(mState == STATE_CONNECTED); + if (mImap->imap_connection_info != NULL) { + if (mImap->imap_connection_info->imap_capability != NULL) { + mailimap_capability_data_free(mImap->imap_connection_info->imap_capability); + mImap->imap_connection_info->imap_capability = NULL; + } + } + const char * utf8username; const char * utf8password; utf8username = MCUTF8(mUsername); @@ -807,8 +836,73 @@ void IMAPSession::login(ErrorCode * pError) return; } - * pError = ErrorNone; mState = STATE_LOGGEDIN; + + if (isAutomaticCapabilitiesEnabled()) { + if ((mImap->imap_connection_info != NULL) && (mImap->imap_connection_info->imap_capability != NULL)) { + // Don't keep result. It will be kept in session state. + capabilitySetWithSessionState(IndexSet::indexSet()); + } + else { + IndexSet * capabilities = capability(pError); + if (* pError != ErrorNone) { + MCLog("capabilities failed"); + return; + } + } + + enableFeatures(); + } + else { + // TODO: capabilities should be shared for non automatic capabilities sessions. + enableFeatures(); + } + + if (isAutomaticNamespaceEnabled()) { + if (isNamespaceEnabled()) { + HashMap * result = fetchNamespace(pError); + if (* pError != ErrorNone) { + MCLog("fetch namespace failed"); + return; + } + IMAPNamespace * personalNamespace = (IMAPNamespace *) result->objectForKey(IMAPNamespacePersonal); + setDefaultNamespace(personalNamespace); + mDelimiter = defaultNamespace()->mainDelimiter(); + } + else { + clist * imap_folders; + IMAPFolder * folder; + Array * folders; + + r = mailimap_list(mImap, "", "", &imap_folders); + folders = resultsWithError(r, imap_folders, pError); + if (* pError != ErrorNone) + return; + + if (folders->count() > 0) { + folder = (IMAPFolder *) folders->objectAtIndex(0); + } + else { + folder = NULL; + } + if (folder == NULL) { + * pError = ErrorNonExistantFolder; + return; + } + + mDelimiter = folder->delimiter(); + IMAPNamespace * defaultNamespace = IMAPNamespace::namespaceWithPrefix(folder->path(), folder->delimiter()); + setDefaultNamespace(defaultNamespace); + } + } + else { + // TODO: namespace should be shared for non automatic namespace. + // setDefaultNamespace() + } + + mAutomaticConfigurationDone = true; + + * pError = ErrorNone; MCLog("login ok"); } @@ -1124,6 +1218,7 @@ static Array * resultsWithError(int r, clist * list, ErrorCode * pError) return result; } +// Deprecated char IMAPSession::fetchDelimiterIfNeeded(char defaultDelimiter, ErrorCode * pError) { int r; @@ -2981,7 +3076,7 @@ IndexSet * IMAPSession::capability(ErrorCode * pError) int r; struct mailimap_capability_data * cap; - loginIfNeeded(pError); + connectIfNeeded(pError); if (* pError != ErrorNone) return NULL; @@ -3002,12 +3097,21 @@ IndexSet * IMAPSession::capability(ErrorCode * pError) mailimap_capability_data_free(cap); IndexSet * result = new IndexSet(); + capabilitySetWithSessionState(result); + + * pError = ErrorNone; + result->autorelease(); + return result; +} + +void IMAPSession::capabilitySetWithSessionState(IndexSet * capabilities) +{ if (mailimap_has_id(mImap)) { - result->addIndex(IMAPCapabilityId); + capabilities->addIndex(IMAPCapabilityId); mIdentityEnabled = true; } if (mailimap_has_xlist(mImap)) { - result->addIndex(IMAPCapabilityXList); + capabilities->addIndex(IMAPCapabilityXList); mXListEnabled = true; } if (mailimap_has_extension(mImap, (char *) "X-GM-EXT-1")) { @@ -3016,25 +3120,25 @@ IndexSet * IMAPSession::capability(ErrorCode * pError) mXListEnabled = false; } if (mailimap_has_idle(mImap)) { - result->addIndex(IMAPCapabilityIdle); + capabilities->addIndex(IMAPCapabilityIdle); mIdleEnabled = true; } if (mailimap_has_condstore(mImap)) { - result->addIndex(IMAPCapabilityCondstore); + capabilities->addIndex(IMAPCapabilityCondstore); mCondstoreEnabled = true; } if (mailimap_has_condstore(mImap)) { - result->addIndex(IMAPCapabilityQResync); + capabilities->addIndex(IMAPCapabilityQResync); mQResyncEnabled = true; } if (mailimap_has_xoauth2(mImap)) { - result->addIndex(IMAPCapabilityXOAuth2); + capabilities->addIndex(IMAPCapabilityXOAuth2); mXOauth2Enabled = true; } - - * pError = ErrorNone; - result->autorelease(); - return result; + if (mailimap_has_namespace(mImap)) { + capabilities->addIndex(IMAPCapabilityNamespace); + mNamespaceEnabled = true; + } } bool IMAPSession::isIdleEnabled() @@ -3062,10 +3166,16 @@ bool IMAPSession::isIdentityEnabled() return mIdentityEnabled; } -bool IMAPSession::isXOAuthEnabled() { +bool IMAPSession::isXOAuthEnabled() +{ return mXOauth2Enabled; } +bool IMAPSession::isNamespaceEnabled() +{ + return mNamespaceEnabled; +} + bool IMAPSession::isDisconnected() { return mState == STATE_DISCONNECTED; @@ -3153,3 +3263,61 @@ String * IMAPSession::plainTextBodyRendering(IMAPMessage * message, String * fol return plainTextBodyString; } + +void IMAPSession::setAutomaticCapabilitiesEnabled(bool enabled) +{ + mAutomaticCapabilitiesEnabled = enabled; +} + +bool IMAPSession::isAutomaticCapabilitiesEnabled() +{ + return mAutomaticCapabilitiesEnabled; +} + +void IMAPSession::setAutomaticNamespaceEnabled(bool enabled) +{ + mAutomaticNamespaceEnabled = enabled; +} + +bool IMAPSession::isAutomaticNamespaceEnabled() +{ + return mAutomaticNamespaceEnabled; +} + +bool IMAPSession::enableFeature(String * feature) +{ + struct mailimap_capability_data * caps; + clist * cap_list; + struct mailimap_capability * cap; + int r; + + cap_list = clist_new(); + cap = mailimap_capability_new(MAILIMAP_CAPABILITY_NAME, NULL, strdup(MCUTF8(feature))); + clist_append(cap_list, cap); + caps = mailimap_capability_data_new(cap_list); + + struct mailimap_capability_data * result; + r = mailimap_enable(mImap, caps, &result); + if (r != MAILIMAP_NO_ERROR) + return false; + + mailimap_capability_data_free(result); + + return true; +} + +void IMAPSession::enableFeatures() +{ + if (isQResyncEnabled()) { + IMAPSession::enableFeature(MCSTR("QRESYNC")); + } + else if (isCondstoreEnabled()) { + IMAPSession::enableFeature(MCSTR("CONDSTORE")); + } +} + +bool IMAPSession::isAutomaticConfigurationDone() +{ + return mAutomaticConfigurationDone; +} + diff --git a/src/core/imap/MCIMAPSession.h b/src/core/imap/MCIMAPSession.h index 4128b516..09b2fa17 100644 --- a/src/core/imap/MCIMAPSession.h +++ b/src/core/imap/MCIMAPSession.h @@ -155,6 +155,7 @@ namespace mailcore { virtual bool isQResyncEnabled(); virtual bool isIdentityEnabled(); virtual bool isXOAuthEnabled(); + virtual bool isNamespaceEnabled(); virtual void setConnectionLogger(ConnectionLogger * logger); virtual ConnectionLogger * connectionLogger(); @@ -172,10 +173,20 @@ namespace mailcore { This method can be used to generate the summary of the message.*/ virtual String * plainTextBodyRendering(IMAPMessage * message, String * folder, ErrorCode * pError); + /** Enable automatic query of the capabilities of the IMAP server when set to true. */ + virtual void setAutomaticCapabilitiesEnabled(bool enabled); + + /** Check if the automatic query of the capabilities of the IMAP server is enabled. */ + virtual bool isAutomaticCapabilitiesEnabled(); + + virtual void setAutomaticNamespaceEnabled(bool enabled); + virtual bool isAutomaticNamespaceEnabled(); + public: // private virtual void loginIfNeeded(ErrorCode * pError); virtual void connectIfNeeded(ErrorCode * pError); virtual bool isDisconnected(); + virtual bool isAutomaticConfigurationDone(); private: String * mHostname; @@ -198,6 +209,7 @@ namespace mailcore { bool mQResyncEnabled; bool mIdentityEnabled; bool mXOauth2Enabled; + bool mNamespaceEnabled; String * mWelcomeString; bool mNeedsMboxMailWorkaround; uint32_t mUIDValidity; @@ -215,6 +227,9 @@ namespace mailcore { IMAPProgressCallback * mProgressCallback; unsigned int mProgressItemsCount; ConnectionLogger * mConnectionLogger; + bool mAutomaticCapabilitiesEnabled; + bool mAutomaticNamespaceEnabled; + bool mAutomaticConfigurationDone; void init(); void bodyProgress(unsigned int current, unsigned int maximum); @@ -230,6 +245,9 @@ namespace mailcore { bool fetchByUID, struct mailimap_set * imapset, uint64_t modseq, HashMap * mapping, uint32_t startUid, IMAPProgressCallback * progressCallback, Array * extraHeaders, ErrorCode * pError); + void capabilitySetWithSessionState(IndexSet * capabilities); + bool enableFeature(String * feature); + void enableFeatures(); }; } -- cgit v1.2.3 From 44a5e789f1e78d043f667ab2862a0097eaa2d06b Mon Sep 17 00:00:00 2001 From: "Hoa V. DINH" Date: Mon, 5 Aug 2013 16:42:22 -0700 Subject: Force capability operation to login() --- src/async/imap/MCIMAPCapabilityOperation.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/async/imap/MCIMAPCapabilityOperation.cc b/src/async/imap/MCIMAPCapabilityOperation.cc index 30bf1e3c..9edb9b1c 100644 --- a/src/async/imap/MCIMAPCapabilityOperation.cc +++ b/src/async/imap/MCIMAPCapabilityOperation.cc @@ -31,6 +31,11 @@ IndexSet * IMAPCapabilityOperation::capabilities() void IMAPCapabilityOperation::main() { ErrorCode error; + session()->session()->loginIfNeeded(&error); + if (error != ErrorNone) { + setError(error); + return; + } mCapabilities = session()->session()->capability(&error); MC_SAFE_RETAIN(mCapabilities); setError(error); -- cgit v1.2.3 From 920c43dad5d30b6892f0fccb3b6093b2571b6e70 Mon Sep 17 00:00:00 2001 From: "Hoa V. DINH" Date: Mon, 5 Aug 2013 19:42:12 -0700 Subject: work in progress on automatic configuration --- src/async/imap/MCIMAPAsyncConnection.cc | 13 +++++++++++++ src/async/imap/MCIMAPAsyncConnection.h | 4 ++++ src/async/imap/MCIMAPAsyncSession.cc | 11 ++++++++++- src/async/imap/MCIMAPAsyncSession.h | 4 ++++ src/async/imap/MCIMAPOperation.cc | 12 ++++++++++++ src/async/imap/MCIMAPOperation.h | 3 +++ 6 files changed, 46 insertions(+), 1 deletion(-) diff --git a/src/async/imap/MCIMAPAsyncConnection.cc b/src/async/imap/MCIMAPAsyncConnection.cc index 85c411a8..1d6e8fa9 100644 --- a/src/async/imap/MCIMAPAsyncConnection.cc +++ b/src/async/imap/MCIMAPAsyncConnection.cc @@ -93,6 +93,7 @@ IMAPAsyncConnection::IMAPAsyncConnection() mConnectionLogger = NULL; pthread_mutex_init(&mConnectionLoggerLock, NULL); mInternalLogger = new IMAPConnectionLogger(this); + mAutomaticConfigurationEnabled = true; } IMAPAsyncConnection::~IMAPAsyncConnection() @@ -630,3 +631,15 @@ IMAPMessageRenderingOperation * IMAPAsyncConnection::plainTextBodyRenderingOpera { return renderingOperation(message, folder, IMAPMessageRenderingTypePlainTextBody); } + +void IMAPAsyncConnection::setAutomaticConfigurationEnabled(bool enabled) +{ + mAutomaticConfigurationEnabled = enabled; + mSession->setAutomaticCapabilitiesEnabled(enabled); + mSession->setAutomaticNamespaceEnabled(enabled); +} + +bool IMAPAsyncConnection::isAutomaticConfigurationEnabled() +{ + return mAutomaticConfigurationEnabled; +} diff --git a/src/async/imap/MCIMAPAsyncConnection.h b/src/async/imap/MCIMAPAsyncConnection.h index 45acb707..9594aef2 100644 --- a/src/async/imap/MCIMAPAsyncConnection.h +++ b/src/async/imap/MCIMAPAsyncConnection.h @@ -69,6 +69,9 @@ namespace mailcore { virtual void setDelimiter(char delimiter); virtual char delimiter(); + virtual void setAutomaticConfigurationEnabled(bool enabled); + virtual bool isAutomaticConfigurationEnabled(); + virtual void setDefaultNamespace(IMAPNamespace * ns); virtual IMAPNamespace * defaultNamespace(); @@ -138,6 +141,7 @@ namespace mailcore { ConnectionLogger * mConnectionLogger; IMAPConnectionLogger * mInternalLogger; pthread_mutex_t mConnectionLoggerLock; + bool mAutomaticConfigurationEnabled; virtual void tryAutomaticDisconnectAfterDelay(void * context); virtual IMAPMessageRenderingOperation * renderingOperation(IMAPMessage * message, diff --git a/src/async/imap/MCIMAPAsyncSession.cc b/src/async/imap/MCIMAPAsyncSession.cc index 7aa37d83..93812f90 100644 --- a/src/async/imap/MCIMAPAsyncSession.cc +++ b/src/async/imap/MCIMAPAsyncSession.cc @@ -36,6 +36,7 @@ IMAPAsyncSession::IMAPAsyncSession() mDefaultNamespace = NULL; mTimeout = 30.; mConnectionLogger = NULL; + mAutomaticConfigurationDone = false; } IMAPAsyncSession::~IMAPAsyncSession() @@ -208,6 +209,9 @@ IMAPAsyncConnection * IMAPAsyncSession::session() session->setVoIPEnabled(mVoIPEnabled); session->setDelimiter(mDelimiter); session->setDefaultNamespace(mDefaultNamespace); + if (mAutomaticConfigurationDone) { + session->setAutomaticConfigurationEnabled(false); + } return session; } @@ -489,4 +493,9 @@ IMAPMessageRenderingOperation * IMAPAsyncSession::plainTextBodyRenderingOperatio { IMAPAsyncConnection * session = sessionForFolder(folder); return session->plainTextBodyRenderingOperation(message, folder); -} \ No newline at end of file +} + +void IMAPAsyncSession::automaticConfigurateDone() +{ + mAutomaticConfigurationDone = true; +} diff --git a/src/async/imap/MCIMAPAsyncSession.h b/src/async/imap/MCIMAPAsyncSession.h index 68e8899a..95c80c2f 100644 --- a/src/async/imap/MCIMAPAsyncSession.h +++ b/src/async/imap/MCIMAPAsyncSession.h @@ -138,6 +138,9 @@ namespace mailcore { virtual IMAPMessageRenderingOperation * htmlBodyRenderingOperation(IMAPMessage * message, String * folder); virtual IMAPMessageRenderingOperation * plainTextRenderingOperation(IMAPMessage * message, String * folder); virtual IMAPMessageRenderingOperation * plainTextBodyRenderingOperation(IMAPMessage * message, String * folder); + + public: // private + virtual void automaticConfigurateDone(); private: Array * mSessions; @@ -157,6 +160,7 @@ namespace mailcore { bool mAllowsFolderConcurrentAccessEnabled; unsigned int mMaximumConnections; ConnectionLogger * mConnectionLogger; + bool mAutomaticConfigurationDone; virtual IMAPAsyncConnection * sessionForFolder(String * folder, bool urgent = false); virtual IMAPAsyncConnection * session(); diff --git a/src/async/imap/MCIMAPOperation.cc b/src/async/imap/MCIMAPOperation.cc index 35eedd6c..2ceb2b55 100644 --- a/src/async/imap/MCIMAPOperation.cc +++ b/src/async/imap/MCIMAPOperation.cc @@ -10,6 +10,7 @@ #include +#include "MCIMAPAsyncSession.h" #include "MCIMAPSession.h" #include "MCIMAPAsyncConnection.h" #include "MCIMAPOperationCallback.h" @@ -133,3 +134,14 @@ void IMAPOperation::itemsProgressOnMainThread(void * ctx) free(context); release(); } + +void IMAPOperation::beforeMain() +{ +} + +void IMAPOperation::afterMain() +{ + if (mSession->session()->isAutomaticConfigurationDone()) { + mSession->owner()->automaticConfigurateDone(); + } +} diff --git a/src/async/imap/MCIMAPOperation.h b/src/async/imap/MCIMAPOperation.h index f7e937db..e7dcb9a5 100644 --- a/src/async/imap/MCIMAPOperation.h +++ b/src/async/imap/MCIMAPOperation.h @@ -34,6 +34,9 @@ namespace mailcore { virtual void setImapCallback(IMAPOperationCallback * callback); virtual IMAPOperationCallback * imapCallback(); + virtual void beforeMain(); + virtual void afterMain(); + virtual void start(); // Result. -- cgit v1.2.3 From a18210b3ff718e2872c1827abc0d50863977298a Mon Sep 17 00:00:00 2001 From: CodaFi Date: Wed, 7 Aug 2013 20:01:54 -0600 Subject: Added check for filename --- src/objc/provider/MCOMailProvidersManager.mm | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/objc/provider/MCOMailProvidersManager.mm b/src/objc/provider/MCOMailProvidersManager.mm index 8f12aa11..d8fb1aa0 100644 --- a/src/objc/provider/MCOMailProvidersManager.mm +++ b/src/objc/provider/MCOMailProvidersManager.mm @@ -18,12 +18,12 @@ + (MCOMailProvidersManager *) sharedManager { - static MCOMailProvidersManager * sharedInstance = nil; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - sharedInstance = [[self alloc] init]; \ - }); - return sharedInstance; + static MCOMailProvidersManager * sharedInstance = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + sharedInstance = [[self alloc] init]; \ + }); + return sharedInstance; } - (id) init @@ -32,27 +32,29 @@ self = [super init]; - filename = [[NSBundle bundleForClass:[self class]] pathForResource:@"providers" ofType:@"json"]; - mailcore::MailProvidersManager::sharedManager()->registerProvidersWithFilename(filename.mco_mcString); - + filename = [[NSBundle bundleForClass:[self class]] pathForResource:@"providers" ofType:@"json"]; + if (filename) { + mailcore::MailProvidersManager::sharedManager()->registerProvidersWithFilename(filename.mco_mcString); + } + return self; } - (MCOMailProvider *) providerForEmail:(NSString *)email { - mailcore::MailProvider *provider = mailcore::MailProvidersManager::sharedManager()->providerForEmail(email.mco_mcString); + mailcore::MailProvider *provider = mailcore::MailProvidersManager::sharedManager()->providerForEmail(email.mco_mcString); return MCO_TO_OBJC(provider); } - (MCOMailProvider *) providerForMX:(NSString *)hostname { - mailcore::MailProvider *provider = mailcore::MailProvidersManager::sharedManager()->providerForMX(hostname.mco_mcString); + mailcore::MailProvider *provider = mailcore::MailProvidersManager::sharedManager()->providerForMX(hostname.mco_mcString); return MCO_TO_OBJC(provider); } - (MCOMailProvider *) providerForIdentifier:(NSString *)identifier { - mailcore::MailProvider *provider = mailcore::MailProvidersManager::sharedManager()->providerForIdentifier(identifier.mco_mcString); + mailcore::MailProvider *provider = mailcore::MailProvidersManager::sharedManager()->providerForIdentifier(identifier.mco_mcString); return MCO_TO_OBJC(provider); } -- cgit v1.2.3 From 9c98ecae2bf5ce00c0ffdc68a41cc05f1c5e7eea Mon Sep 17 00:00:00 2001 From: CodaFi Date: Wed, 7 Aug 2013 20:03:19 -0600 Subject: Whitespace --- src/objc/provider/MCOMailProvidersManager.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/objc/provider/MCOMailProvidersManager.mm b/src/objc/provider/MCOMailProvidersManager.mm index d8fb1aa0..b1585166 100644 --- a/src/objc/provider/MCOMailProvidersManager.mm +++ b/src/objc/provider/MCOMailProvidersManager.mm @@ -34,7 +34,7 @@ filename = [[NSBundle bundleForClass:[self class]] pathForResource:@"providers" ofType:@"json"]; if (filename) { - mailcore::MailProvidersManager::sharedManager()->registerProvidersWithFilename(filename.mco_mcString); + mailcore::MailProvidersManager::sharedManager()->registerProvidersWithFilename(filename.mco_mcString); } return self; -- cgit v1.2.3 From e7702ed35563614e1ad8e4ff6c30ad9bbbca1c35 Mon Sep 17 00:00:00 2001 From: CodaFi Date: Wed, 7 Aug 2013 20:10:49 -0600 Subject: Fix literal to char* conversion warnings --- src/core/basetypes/MCObject.cc | 4 ++-- src/core/basetypes/MCObject.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/basetypes/MCObject.cc b/src/core/basetypes/MCObject.cc index fff2055d..8ed4fb52 100644 --- a/src/core/basetypes/MCObject.cc +++ b/src/core/basetypes/MCObject.cc @@ -272,14 +272,14 @@ void Object::initObjectConstructors() constructors = chash_new(CHASH_DEFAULTSIZE, CHASH_COPYKEY); } -void Object::registerObjectConstructor(char * className, void * (* objectConstructor)(void)) +void Object::registerObjectConstructor(const char * className, void * (* objectConstructor)(void)) { static pthread_once_t once = PTHREAD_ONCE_INIT; pthread_once(&once, initObjectConstructors); chashdatum key; chashdatum value; - key.data = className; + key.data = (void *) className; key.len = strlen(className); value.data = (void *) objectConstructor; value.len = 0; diff --git a/src/core/basetypes/MCObject.h b/src/core/basetypes/MCObject.h index 6bde74e5..77f7e06e 100644 --- a/src/core/basetypes/MCObject.h +++ b/src/core/basetypes/MCObject.h @@ -44,7 +44,7 @@ namespace mailcore { virtual void cancelDelayedPerformMethod(Method method, void * context); // serialization utils - static void registerObjectConstructor(char * className, void * (* objectConstructor)(void)); + static void registerObjectConstructor(const char * className, void * (* objectConstructor)(void)); static Object * objectWithSerializable(HashMap * serializable); public: // private -- cgit v1.2.3 From c6c9d10e66ae6a01fabd6c55c4492566372b59e5 Mon Sep 17 00:00:00 2001 From: Petro Korienev Date: Thu, 8 Aug 2013 17:40:45 +0300 Subject: added getQuota operation to get free space in mailbox --- .gitignore | 1 + build-mac/mailcore2.xcodeproj/project.pbxproj | 20 ++++++++ src/async/imap/MCAsyncIMAP.h | 1 + src/async/imap/MCIMAPAsyncConnection.cc | 9 ++++ src/async/imap/MCIMAPAsyncConnection.h | 2 + src/async/imap/MCIMAPAsyncSession.cc | 6 +++ src/async/imap/MCIMAPAsyncSession.h | 2 + src/async/imap/MCIMAPGetQuotaOperation.cc | 42 ++++++++++++++++ src/async/imap/MCIMAPGetQuotaOperation.h | 39 +++++++++++++++ src/core/imap/MCIMAPSession.cc | 36 ++++++++++++++ src/core/imap/MCIMAPSession.h | 1 + src/objc/imap/MCOIMAP.h | 1 + src/objc/imap/MCOIMAPGetQuotaOperation.h | 15 ++++++ src/objc/imap/MCOIMAPGetQuotaOperation.mm | 69 +++++++++++++++++++++++++++ src/objc/imap/MCOIMAPSession.h | 3 ++ src/objc/imap/MCOIMAPSession.mm | 6 +++ 16 files changed, 253 insertions(+) mode change 100644 => 100755 build-mac/mailcore2.xcodeproj/project.pbxproj mode change 100644 => 100755 src/async/imap/MCAsyncIMAP.h mode change 100644 => 100755 src/async/imap/MCIMAPAsyncConnection.cc mode change 100644 => 100755 src/async/imap/MCIMAPAsyncConnection.h mode change 100644 => 100755 src/async/imap/MCIMAPAsyncSession.cc mode change 100644 => 100755 src/async/imap/MCIMAPAsyncSession.h create mode 100644 src/async/imap/MCIMAPGetQuotaOperation.cc create mode 100644 src/async/imap/MCIMAPGetQuotaOperation.h mode change 100644 => 100755 src/core/imap/MCIMAPSession.cc mode change 100644 => 100755 src/core/imap/MCIMAPSession.h mode change 100644 => 100755 src/objc/imap/MCOIMAP.h create mode 100644 src/objc/imap/MCOIMAPGetQuotaOperation.h create mode 100644 src/objc/imap/MCOIMAPGetQuotaOperation.mm mode change 100644 => 100755 src/objc/imap/MCOIMAPSession.h mode change 100644 => 100755 src/objc/imap/MCOIMAPSession.mm diff --git a/.gitignore b/.gitignore index 73cdfa35..715128d3 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ xcuserdata .DS_Store .idea project.xcworkspace +.svn example/ios/iOS UI Test/DerivedData scripts/prebuilt.list diff --git a/build-mac/mailcore2.xcodeproj/project.pbxproj b/build-mac/mailcore2.xcodeproj/project.pbxproj old mode 100644 new mode 100755 index 9a1c64c3..9b9fd0e8 --- a/build-mac/mailcore2.xcodeproj/project.pbxproj +++ b/build-mac/mailcore2.xcodeproj/project.pbxproj @@ -7,6 +7,12 @@ objects = { /* Begin PBXBuildFile section */ + 4B3C1BDE17ABF309008BBF4C /* MCOIMAPGetQuotaOperation.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4B3C1BDD17ABF307008BBF4C /* MCOIMAPGetQuotaOperation.mm */; }; + 4B3C1BE117ABF4BC008BBF4C /* MCIMAPGetQuotaOperation.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4B3C1BDF17ABF4BB008BBF4C /* MCIMAPGetQuotaOperation.cc */; }; + 4B3C1BE217ABFF7C008BBF4C /* MCOIMAPGetQuotaOperation.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 4B3C1BDC17ABF306008BBF4C /* MCOIMAPGetQuotaOperation.h */; }; + 4B3C1BE317ABFF91008BBF4C /* MCOIMAPGetQuotaOperation.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4B3C1BDD17ABF307008BBF4C /* MCOIMAPGetQuotaOperation.mm */; }; + 4B3C1BE417AC0156008BBF4C /* MCIMAPGetQuotaOperation.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 4B3C1BE017ABF4BC008BBF4C /* MCIMAPGetQuotaOperation.h */; }; + 4B3C1BE517AC0176008BBF4C /* MCIMAPGetQuotaOperation.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4B3C1BDF17ABF4BB008BBF4C /* MCIMAPGetQuotaOperation.cc */; }; 84AF9E7E172DBAF600E60AA3 /* providers.json in Resources */ = {isa = PBXBuildFile; fileRef = 84AF9E7D172DBAF600E60AA3 /* providers.json */; }; 9E774D891767C7F60065EB9B /* MCIMAPFolderStatus.cc in Sources */ = {isa = PBXBuildFile; fileRef = 9E774D881767C7F60065EB9B /* MCIMAPFolderStatus.cc */; }; 9E774D8A1767C7F60065EB9B /* MCIMAPFolderStatus.cc in Sources */ = {isa = PBXBuildFile; fileRef = 9E774D881767C7F60065EB9B /* MCIMAPFolderStatus.cc */; }; @@ -922,6 +928,8 @@ dstPath = include/MailCore; dstSubfolderSpec = 16; files = ( + 4B3C1BE417AC0156008BBF4C /* MCIMAPGetQuotaOperation.h in CopyFiles */, + 4B3C1BE217ABFF7C008BBF4C /* MCOIMAPGetQuotaOperation.h in CopyFiles */, DAE42E8A178F7E2200E0DB8F /* MCOIMAPMessageRenderingOperation.h in CopyFiles */, C6E6652F1791B2530063F2CF /* MCIMAPMessageRenderingOperation.h in CopyFiles */, 9E774D8B1767CD3C0065EB9B /* MCIMAPFolderStatus.h in CopyFiles */, @@ -1099,6 +1107,10 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 4B3C1BDC17ABF306008BBF4C /* MCOIMAPGetQuotaOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MCOIMAPGetQuotaOperation.h; sourceTree = ""; }; + 4B3C1BDD17ABF307008BBF4C /* MCOIMAPGetQuotaOperation.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MCOIMAPGetQuotaOperation.mm; sourceTree = ""; }; + 4B3C1BDF17ABF4BB008BBF4C /* MCIMAPGetQuotaOperation.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MCIMAPGetQuotaOperation.cc; sourceTree = ""; }; + 4B3C1BE017ABF4BC008BBF4C /* MCIMAPGetQuotaOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MCIMAPGetQuotaOperation.h; sourceTree = ""; }; 84AF9E7D172DBAF600E60AA3 /* providers.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = providers.json; path = ../resources/providers.json; sourceTree = ""; }; 9E774D871767C54E0065EB9B /* MCIMAPFolderStatus.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MCIMAPFolderStatus.h; sourceTree = ""; }; 9E774D881767C7F60065EB9B /* MCIMAPFolderStatus.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MCIMAPFolderStatus.cc; sourceTree = ""; }; @@ -1750,6 +1762,8 @@ C62C6ED716A398FA00737497 /* MCIMAPFolderInfoOperation.h */, C64BB22916E5C0A3000DB34C /* MCIMAPCapabilityOperation.cc */, C64BB22A16E5C0A3000DB34C /* MCIMAPCapabilityOperation.h */, + 4B3C1BDF17ABF4BB008BBF4C /* MCIMAPGetQuotaOperation.cc */, + 4B3C1BE017ABF4BC008BBF4C /* MCIMAPGetQuotaOperation.h */, 9EF9AB10175F319A0027FA3B /* MCIMAPFolderStatusOperation.cc */, 9EF9AB0E175F30C20027FA3B /* MCIMAPFolderStatusOperation.h */, C6081679177635D2001F1018 /* MCIMAPDisconnectOperation.cc */, @@ -2206,6 +2220,8 @@ C6F61F9217016B250073032E /* MCOIMAPIdentityOperation.mm */, C6F61F9417016B310073032E /* MCOIMAPCapabilityOperation.h */, C6F61F9517016B310073032E /* MCOIMAPCapabilityOperation.mm */, + 4B3C1BDC17ABF306008BBF4C /* MCOIMAPGetQuotaOperation.h */, + 4B3C1BDD17ABF307008BBF4C /* MCOIMAPGetQuotaOperation.mm */, C6F61F9717016B460073032E /* MCOIMAPSearchExpression.h */, C6F61F9817016B460073032E /* MCOIMAPSearchExpression.mm */, 9EF9AB06175F2EC60027FA3B /* MCOIMAPFolderStatus.h */, @@ -2589,6 +2605,8 @@ BD63713B177DFF080094121B /* MCLibetpan.cc in Sources */, DAACAD5117886807000B4517 /* MCHTMLRendererIMAPDataCallback.cc in Sources */, DA89896D178A47D200F6D90A /* MCOIMAPMessageRenderingOperation.mm in Sources */, + 4B3C1BDE17ABF309008BBF4C /* MCOIMAPGetQuotaOperation.mm in Sources */, + 4B3C1BE117ABF4BC008BBF4C /* MCIMAPGetQuotaOperation.cc in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2780,6 +2798,8 @@ BD63713C177DFF080094121B /* MCLibetpan.cc in Sources */, DAACAD5217886807000B4517 /* MCHTMLRendererIMAPDataCallback.cc in Sources */, DA89896E178A47D200F6D90A /* MCOIMAPMessageRenderingOperation.mm in Sources */, + 4B3C1BE317ABFF91008BBF4C /* MCOIMAPGetQuotaOperation.mm in Sources */, + 4B3C1BE517AC0176008BBF4C /* MCIMAPGetQuotaOperation.cc in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/src/async/imap/MCAsyncIMAP.h b/src/async/imap/MCAsyncIMAP.h old mode 100644 new mode 100755 index a6bf40d0..511a5cf6 --- a/src/async/imap/MCAsyncIMAP.h +++ b/src/async/imap/MCAsyncIMAP.h @@ -27,6 +27,7 @@ #include #include #include +#include #include #include diff --git a/src/async/imap/MCIMAPAsyncConnection.cc b/src/async/imap/MCIMAPAsyncConnection.cc old mode 100644 new mode 100755 index 85c411a8..77800bca --- a/src/async/imap/MCIMAPAsyncConnection.cc +++ b/src/async/imap/MCIMAPAsyncConnection.cc @@ -30,6 +30,7 @@ #include "MCIMAPIdleOperation.h" #include "MCIMAPIdentityOperation.h" #include "MCIMAPCapabilityOperation.h" +#include "MCIMAPGetQuotaOperation.h" #include "MCOperationQueueCallback.h" #include "MCIMAPDisconnectOperation.h" #include "MCIMAPAsyncSession.h" @@ -494,6 +495,14 @@ IMAPCapabilityOperation * IMAPAsyncConnection::capabilityOperation() return op; } +IMAPGetQuotaOperation * IMAPAsyncConnection::getQuotaOperation() +{ + IMAPGetQuotaOperation * op = new IMAPGetQuotaOperation(); + op->setSession(this); + op->autorelease(); + return op; +} + IMAPSession * IMAPAsyncConnection::session() { return mSession; diff --git a/src/async/imap/MCIMAPAsyncConnection.h b/src/async/imap/MCIMAPAsyncConnection.h old mode 100644 new mode 100755 index 45acb707..8fe025c9 --- a/src/async/imap/MCIMAPAsyncConnection.h +++ b/src/async/imap/MCIMAPAsyncConnection.h @@ -25,6 +25,7 @@ namespace mailcore { class IMAPFetchNamespaceOperation; class IMAPIdentityOperation; class IMAPCapabilityOperation; + class IMAPGetQuotaOperation; class IMAPOperationQueueCallback; class IMAPAsyncSession; class IMAPConnectionLogger; @@ -120,6 +121,7 @@ namespace mailcore { virtual IMAPOperation * checkAccountOperation(); virtual IMAPCapabilityOperation * capabilityOperation(); + virtual IMAPGetQuotaOperation * getQuotaOperation(); virtual IMAPMessageRenderingOperation * htmlRenderingOperation(IMAPMessage * message, String * folder); virtual IMAPMessageRenderingOperation * htmlBodyRenderingOperation(IMAPMessage * message, String * folder); diff --git a/src/async/imap/MCIMAPAsyncSession.cc b/src/async/imap/MCIMAPAsyncSession.cc old mode 100644 new mode 100755 index 7aa37d83..205b57b2 --- a/src/async/imap/MCIMAPAsyncSession.cc +++ b/src/async/imap/MCIMAPAsyncSession.cc @@ -449,6 +449,12 @@ IMAPCapabilityOperation * IMAPAsyncSession::capabilityOperation() return session->capabilityOperation(); } +IMAPGetQuotaOperation * IMAPAsyncSession::getQuotaOperation() +{ + IMAPAsyncConnection * session = sessionForFolder(MCSTR("INBOX")); + return session->getQuotaOperation(); +} + void IMAPAsyncSession::setConnectionLogger(ConnectionLogger * logger) { mConnectionLogger = logger; diff --git a/src/async/imap/MCIMAPAsyncSession.h b/src/async/imap/MCIMAPAsyncSession.h old mode 100644 new mode 100755 index 68e8899a..212cdaab --- a/src/async/imap/MCIMAPAsyncSession.h +++ b/src/async/imap/MCIMAPAsyncSession.h @@ -33,6 +33,7 @@ namespace mailcore { class IMAPIdentityOperation; class IMAPAsyncConnection; class IMAPCapabilityOperation; + class IMAPGetQuotaOperation; class IMAPMessageRenderingOperation; class IMAPMessage; @@ -133,6 +134,7 @@ namespace mailcore { virtual IMAPOperation * checkAccountOperation(); virtual IMAPCapabilityOperation * capabilityOperation(); + virtual IMAPGetQuotaOperation * getQuotaOperation(); virtual IMAPMessageRenderingOperation * htmlRenderingOperation(IMAPMessage * message, String * folder); virtual IMAPMessageRenderingOperation * htmlBodyRenderingOperation(IMAPMessage * message, String * folder); diff --git a/src/async/imap/MCIMAPGetQuotaOperation.cc b/src/async/imap/MCIMAPGetQuotaOperation.cc new file mode 100644 index 00000000..572bd583 --- /dev/null +++ b/src/async/imap/MCIMAPGetQuotaOperation.cc @@ -0,0 +1,42 @@ +// +// MCIMAPGetQuotaOperation.cc +// mailcore2 +// +// Created by Petro Korenev on 8/2/13. +// Copyright (c) 2013 MailCore. All rights reserved. +// + +#include "MCIMAPGetQuotaOperation.h" + +#include "MCIMAPSession.h" +#include "MCIMAPAsyncConnection.h" + +using namespace mailcore; + +IMAPGetQuotaOperation::IMAPGetQuotaOperation() +{ + mLimit = 0; + mUsage = 0; +} + +IMAPGetQuotaOperation::~IMAPGetQuotaOperation() +{ +} + +uint32_t IMAPGetQuotaOperation::limit() +{ + return mLimit; +} + +uint32_t IMAPGetQuotaOperation::usage() +{ + return mUsage; +} + +void IMAPGetQuotaOperation::main() +{ + ErrorCode error; + session()->session()->getQuota(&mUsage, &mLimit, &error); + fprintf(stderr, "QnIQuESeqUeNcE %d %d", mUsage, mLimit); + setError(error); +} diff --git a/src/async/imap/MCIMAPGetQuotaOperation.h b/src/async/imap/MCIMAPGetQuotaOperation.h new file mode 100644 index 00000000..bea3d2f6 --- /dev/null +++ b/src/async/imap/MCIMAPGetQuotaOperation.h @@ -0,0 +1,39 @@ +// +// MCIMAPGetQuotaOperation.h +// mailcore2 +// +// Created by Petro Korenev on 8/2/13. +// Copyright (c) 2013 MailCore. All rights reserved. +// + +#ifndef __MAILCORE_MCIMAPGETQUOTAOPERATION_H_ + +#define __MAILCORE_MCIMAPGETQUOTAOPERATION_H_ + +#include "MCIMAPOperation.h" + +#ifdef __cplusplus + +namespace mailcore { + + class IMAPGetQuotaOperation : public IMAPOperation { + public: + IMAPGetQuotaOperation(); + virtual ~IMAPGetQuotaOperation(); + + // Result. + virtual uint32_t limit(); + virtual uint32_t usage(); + + public: // subclass behavior + virtual void main(); + + private: + uint32_t mLimit; + uint32_t mUsage; + }; +} + +#endif + +#endif diff --git a/src/core/imap/MCIMAPSession.cc b/src/core/imap/MCIMAPSession.cc old mode 100644 new mode 100755 index 7ebe4354..f423de1c --- a/src/core/imap/MCIMAPSession.cc +++ b/src/core/imap/MCIMAPSession.cc @@ -2445,6 +2445,7 @@ IndexSet * IMAPSession::search(String * folder, IMAPSearchExpression * expressio clist * result_list = NULL; +// int r = mailimap_uid_search(mImap, expression->shouldAvoidCharset() ? NULL : "utf-8", key, &result_list); int r = mailimap_uid_search(mImap, "utf-8", key, &result_list); mailimap_search_key_free(key); MCLog("had error : %i", r); @@ -2471,6 +2472,41 @@ IndexSet * IMAPSession::search(String * folder, IMAPSearchExpression * expressio return result; } +void IMAPSession::getQuota(uint32_t *usage, uint32_t *limit, ErrorCode * pError) +{ + static char * const inboxFolderName = "INBOX"; + mailimap_quota_complete_data *quota_data; + selectIfNeeded(MCSTR("INBOX"), pError); + + if (* pError != ErrorNone) + return; + + int r = mailimap_quota_getquotaroot(mImap, inboxFolderName, "a_data); + if (r == MAILIMAP_ERROR_STREAM) { + * pError = ErrorConnection; + return; + } + else if (r == MAILIMAP_ERROR_PARSE) { + * pError = ErrorParse; + return; + } + else if (hasError(r)) { + * pError = ErrorFetch; + return; + } + for(clistiter * cur = clist_begin(quota_data->quota_list); cur != NULL; cur = clist_next(cur)) { + mailimap_quota_quota_data *quota = (mailimap_quota_quota_data*)clist_content(cur); + for (clistiter *cur2 = clist_begin(quota->quota_list); cur2 != NULL; cur2 = clist_next(cur2)) { + mailimap_quota_quota_resource *res = (mailimap_quota_quota_resource*)clist_content(cur2); + if (!strcasecmp("STORAGE", res->resource_name)) { + *usage = res->usage; + *limit = res->limit; + } + } + } + mailimap_quota_complete_data_free(quota_data); +} + bool IMAPSession::setupIdle() { // main thread diff --git a/src/core/imap/MCIMAPSession.h b/src/core/imap/MCIMAPSession.h old mode 100644 new mode 100755 index 4128b516..97567d65 --- a/src/core/imap/MCIMAPSession.h +++ b/src/core/imap/MCIMAPSession.h @@ -126,6 +126,7 @@ namespace mailcore { virtual IndexSet * search(String * folder, IMAPSearchKind kind, String * searchString, ErrorCode * pError); virtual IndexSet * search(String * folder, IMAPSearchExpression * expression, ErrorCode * pError); + virtual void getQuota(uint32_t *usage, uint32_t *limit, ErrorCode * pError); virtual bool setupIdle(); virtual void idle(String * folder, uint32_t lastKnownUID, ErrorCode * pError); diff --git a/src/objc/imap/MCOIMAP.h b/src/objc/imap/MCOIMAP.h old mode 100644 new mode 100755 index f0994042..9e4cf6c0 --- a/src/objc/imap/MCOIMAP.h +++ b/src/objc/imap/MCOIMAP.h @@ -36,6 +36,7 @@ #import #import #import +#import #import #import diff --git a/src/objc/imap/MCOIMAPGetQuotaOperation.h b/src/objc/imap/MCOIMAPGetQuotaOperation.h new file mode 100644 index 00000000..401b5aaa --- /dev/null +++ b/src/objc/imap/MCOIMAPGetQuotaOperation.h @@ -0,0 +1,15 @@ +// +// MCOIMAPGetQuotaOperation.h +// mailcore2 +// +// Created by Petro Korenev on 8/2/13. +// Copyright (c) 2013 MailCore. All rights reserved. +// + +#import "MCOIMAPBaseOperation.h" + +@interface MCOIMAPGetQuotaOperation : MCOIMAPBaseOperation + +- (void) start:(void (^)(NSError * error, NSUInteger usage, NSUInteger limit))completionBlock; + +@end diff --git a/src/objc/imap/MCOIMAPGetQuotaOperation.mm b/src/objc/imap/MCOIMAPGetQuotaOperation.mm new file mode 100644 index 00000000..25a6dc98 --- /dev/null +++ b/src/objc/imap/MCOIMAPGetQuotaOperation.mm @@ -0,0 +1,69 @@ +// +// MCOIMAPGetQuotaOperation.m +// mailcore2 +// +// Created by Petro Korenev on 8/2/13. +// Copyright (c) 2013 MailCore. All rights reserved. +// + +#import "MCOIMAPGetQuotaOperation.h" + +#include "MCAsyncIMAP.h" + +#import "MCOOperation+Private.h" +#import "MCOUtils.h" + +typedef void (^CompletionType)(NSError *error, NSUInteger usage, NSUInteger limit); + +@implementation MCOIMAPGetQuotaOperation { + CompletionType _completionBlock; +} + +#define nativeType mailcore::IMAPGetQuotaOperation + ++ (void) load +{ + MCORegisterClass(self, &typeid(nativeType)); +} + ++ (NSObject *) mco_objectWithMCObject:(mailcore::Object *)object +{ + nativeType * op = (nativeType *) object; + return [[[self alloc] initWithMCOperation:op] autorelease]; +} + +- (void) dealloc +{ + [_completionBlock release]; + [super dealloc]; +} + +- (void) start:(void (^)(NSError *error, NSUInteger usage, NSUInteger limit))completionBlock +{ + _completionBlock = [completionBlock copy]; + [self start]; +} + +- (void) cancel +{ + [_completionBlock release]; + _completionBlock = nil; + [super cancel]; +} + +- (void) operationCompleted +{ + if (_completionBlock == NULL) + return; + + nativeType *op = MCO_NATIVE_INSTANCE; + if (op->error() == mailcore::ErrorNone) { + _completionBlock(nil, op->usage(), op->limit()); + } else { + _completionBlock([NSError mco_errorWithErrorCode:op->error()], 0, 0); + } + [_completionBlock release]; + _completionBlock = nil; +} + +@end diff --git a/src/objc/imap/MCOIMAPSession.h b/src/objc/imap/MCOIMAPSession.h old mode 100644 new mode 100755 index 5db608f7..9776ab11 --- a/src/objc/imap/MCOIMAPSession.h +++ b/src/objc/imap/MCOIMAPSession.h @@ -29,6 +29,7 @@ @class MCOIMAPSearchExpression; @class MCOIMAPIdentityOperation; @class MCOIMAPCapabilityOperation; +@class MCOIMAPGetQuotaOperation; @class MCOIMAPMessageRenderingOperation; @class MCOIMAPMessage; @@ -507,6 +508,8 @@ */ - (MCOIMAPCapabilityOperation *) capabilityOperation; +- (MCOIMAPGetQuotaOperation *) getQuotaOperation; + /** @name Search Operations */ /** diff --git a/src/objc/imap/MCOIMAPSession.mm b/src/objc/imap/MCOIMAPSession.mm old mode 100644 new mode 100755 index 2546e612..62899b37 --- a/src/objc/imap/MCOIMAPSession.mm +++ b/src/objc/imap/MCOIMAPSession.mm @@ -362,6 +362,12 @@ MCO_OBJC_SYNTHESIZE_SCALAR(unsigned int, unsigned int, setMaximumConnections, ma return MCO_TO_OBJC_OP(coreOp); } +- (MCOIMAPGetQuotaOperation *) getQuotaOperation +{ + IMAPGetQuotaOperation * coreOp = MCO_NATIVE_INSTANCE->getQuotaOperation(); + return MCO_TO_OBJC_OP((IMAPOperation*)coreOp); +} + - (void) _logWithSender:(void *)sender connectionType:(MCOConnectionLogType)logType data:(NSData *)data { _connectionLogger(sender, logType, data); -- cgit v1.2.3 From 1e05ee7ea55905b26b4b9e8545c881f63b2cdf6f Mon Sep 17 00:00:00 2001 From: Petro Korienev Date: Fri, 9 Aug 2013 19:05:18 +0300 Subject: renamed getQuotaOperation to quotaOperation, removed debug stuff --- .gitignore | 1 - build-mac/mailcore2.xcodeproj/project.pbxproj | 44 +++++++++-------- src/async/imap/MCAsyncIMAP.h | 2 +- src/async/imap/MCIMAPAsyncConnection.cc | 6 +-- src/async/imap/MCIMAPAsyncConnection.h | 4 +- src/async/imap/MCIMAPAsyncSession.cc | 4 +- src/async/imap/MCIMAPAsyncSession.h | 4 +- src/async/imap/MCIMAPGetQuotaOperation.cc | 42 ---------------- src/async/imap/MCIMAPGetQuotaOperation.h | 39 --------------- src/async/imap/MCIMAPQuotaOperation.cc | 41 ++++++++++++++++ src/async/imap/MCIMAPQuotaOperation.h | 39 +++++++++++++++ src/core/imap/MCIMAPSession.cc | 1 - src/objc/imap/MCOIMAP.h | 2 +- src/objc/imap/MCOIMAPGetQuotaOperation.h | 15 ------ src/objc/imap/MCOIMAPGetQuotaOperation.mm | 69 --------------------------- src/objc/imap/MCOIMAPQuotaOperation.h | 15 ++++++ src/objc/imap/MCOIMAPQuotaOperation.mm | 69 +++++++++++++++++++++++++++ src/objc/imap/MCOIMAPSession.h | 4 +- src/objc/imap/MCOIMAPSession.mm | 4 +- 19 files changed, 203 insertions(+), 202 deletions(-) delete mode 100644 src/async/imap/MCIMAPGetQuotaOperation.cc delete mode 100644 src/async/imap/MCIMAPGetQuotaOperation.h create mode 100644 src/async/imap/MCIMAPQuotaOperation.cc create mode 100644 src/async/imap/MCIMAPQuotaOperation.h delete mode 100644 src/objc/imap/MCOIMAPGetQuotaOperation.h delete mode 100644 src/objc/imap/MCOIMAPGetQuotaOperation.mm create mode 100644 src/objc/imap/MCOIMAPQuotaOperation.h create mode 100644 src/objc/imap/MCOIMAPQuotaOperation.mm diff --git a/.gitignore b/.gitignore index 715128d3..73cdfa35 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,6 @@ xcuserdata .DS_Store .idea project.xcworkspace -.svn example/ios/iOS UI Test/DerivedData scripts/prebuilt.list diff --git a/build-mac/mailcore2.xcodeproj/project.pbxproj b/build-mac/mailcore2.xcodeproj/project.pbxproj index 9b9fd0e8..9c9efc3c 100755 --- a/build-mac/mailcore2.xcodeproj/project.pbxproj +++ b/build-mac/mailcore2.xcodeproj/project.pbxproj @@ -7,12 +7,14 @@ objects = { /* Begin PBXBuildFile section */ - 4B3C1BDE17ABF309008BBF4C /* MCOIMAPGetQuotaOperation.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4B3C1BDD17ABF307008BBF4C /* MCOIMAPGetQuotaOperation.mm */; }; - 4B3C1BE117ABF4BC008BBF4C /* MCIMAPGetQuotaOperation.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4B3C1BDF17ABF4BB008BBF4C /* MCIMAPGetQuotaOperation.cc */; }; - 4B3C1BE217ABFF7C008BBF4C /* MCOIMAPGetQuotaOperation.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 4B3C1BDC17ABF306008BBF4C /* MCOIMAPGetQuotaOperation.h */; }; - 4B3C1BE317ABFF91008BBF4C /* MCOIMAPGetQuotaOperation.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4B3C1BDD17ABF307008BBF4C /* MCOIMAPGetQuotaOperation.mm */; }; - 4B3C1BE417AC0156008BBF4C /* MCIMAPGetQuotaOperation.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 4B3C1BE017ABF4BC008BBF4C /* MCIMAPGetQuotaOperation.h */; }; - 4B3C1BE517AC0176008BBF4C /* MCIMAPGetQuotaOperation.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4B3C1BDF17ABF4BB008BBF4C /* MCIMAPGetQuotaOperation.cc */; }; + 4B3C1BDE17ABF309008BBF4C /* MCOIMAPQuotaOperation.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4B3C1BDD17ABF307008BBF4C /* MCOIMAPQuotaOperation.mm */; }; + 4B3C1BE117ABF4BC008BBF4C /* MCIMAPQuotaOperation.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4B3C1BDF17ABF4BB008BBF4C /* MCIMAPQuotaOperation.cc */; }; + 4B3C1BE217ABFF7C008BBF4C /* MCOIMAPQuotaOperation.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 4B3C1BDC17ABF306008BBF4C /* MCOIMAPQuotaOperation.h */; }; + 4B3C1BE317ABFF91008BBF4C /* MCOIMAPQuotaOperation.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4B3C1BDD17ABF307008BBF4C /* MCOIMAPQuotaOperation.mm */; }; + 4B3C1BE417AC0156008BBF4C /* MCIMAPQuotaOperation.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 4B3C1BE017ABF4BC008BBF4C /* MCIMAPQuotaOperation.h */; }; + 4B3C1BE517AC0176008BBF4C /* MCIMAPQuotaOperation.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4B3C1BDF17ABF4BB008BBF4C /* MCIMAPQuotaOperation.cc */; }; + 4BE4029117B548B900ECC5E4 /* MCOIMAPQuotaOperation.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 4B3C1BDC17ABF306008BBF4C /* MCOIMAPQuotaOperation.h */; }; + 4BE4029217B548D900ECC5E4 /* MCIMAPQuotaOperation.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 4B3C1BE017ABF4BC008BBF4C /* MCIMAPQuotaOperation.h */; }; 84AF9E7E172DBAF600E60AA3 /* providers.json in Resources */ = {isa = PBXBuildFile; fileRef = 84AF9E7D172DBAF600E60AA3 /* providers.json */; }; 9E774D891767C7F60065EB9B /* MCIMAPFolderStatus.cc in Sources */ = {isa = PBXBuildFile; fileRef = 9E774D881767C7F60065EB9B /* MCIMAPFolderStatus.cc */; }; 9E774D8A1767C7F60065EB9B /* MCIMAPFolderStatus.cc in Sources */ = {isa = PBXBuildFile; fileRef = 9E774D881767C7F60065EB9B /* MCIMAPFolderStatus.cc */; }; @@ -739,6 +741,8 @@ dstPath = include/MailCore; dstSubfolderSpec = 16; files = ( + 4BE4029217B548D900ECC5E4 /* MCIMAPQuotaOperation.h in CopyFiles */, + 4BE4029117B548B900ECC5E4 /* MCOIMAPQuotaOperation.h in CopyFiles */, C6E665001790963E0063F2CF /* MCIMAPMessageRenderingOperation.h in CopyFiles */, DAE42E89178F7E1800E0DB8F /* MCOIMAPMessageRenderingOperation.h in CopyFiles */, 9E774D8C1767CD490065EB9B /* MCIMAPFolderStatus.h in CopyFiles */, @@ -928,8 +932,8 @@ dstPath = include/MailCore; dstSubfolderSpec = 16; files = ( - 4B3C1BE417AC0156008BBF4C /* MCIMAPGetQuotaOperation.h in CopyFiles */, - 4B3C1BE217ABFF7C008BBF4C /* MCOIMAPGetQuotaOperation.h in CopyFiles */, + 4B3C1BE417AC0156008BBF4C /* MCIMAPQuotaOperation.h in CopyFiles */, + 4B3C1BE217ABFF7C008BBF4C /* MCOIMAPQuotaOperation.h in CopyFiles */, DAE42E8A178F7E2200E0DB8F /* MCOIMAPMessageRenderingOperation.h in CopyFiles */, C6E6652F1791B2530063F2CF /* MCIMAPMessageRenderingOperation.h in CopyFiles */, 9E774D8B1767CD3C0065EB9B /* MCIMAPFolderStatus.h in CopyFiles */, @@ -1107,10 +1111,10 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ - 4B3C1BDC17ABF306008BBF4C /* MCOIMAPGetQuotaOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MCOIMAPGetQuotaOperation.h; sourceTree = ""; }; - 4B3C1BDD17ABF307008BBF4C /* MCOIMAPGetQuotaOperation.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MCOIMAPGetQuotaOperation.mm; sourceTree = ""; }; - 4B3C1BDF17ABF4BB008BBF4C /* MCIMAPGetQuotaOperation.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MCIMAPGetQuotaOperation.cc; sourceTree = ""; }; - 4B3C1BE017ABF4BC008BBF4C /* MCIMAPGetQuotaOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MCIMAPGetQuotaOperation.h; sourceTree = ""; }; + 4B3C1BDC17ABF306008BBF4C /* MCOIMAPQuotaOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MCOIMAPQuotaOperation.h; sourceTree = ""; }; + 4B3C1BDD17ABF307008BBF4C /* MCOIMAPQuotaOperation.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MCOIMAPQuotaOperation.mm; sourceTree = ""; }; + 4B3C1BDF17ABF4BB008BBF4C /* MCIMAPQuotaOperation.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MCIMAPQuotaOperation.cc; sourceTree = ""; }; + 4B3C1BE017ABF4BC008BBF4C /* MCIMAPQuotaOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MCIMAPQuotaOperation.h; sourceTree = ""; }; 84AF9E7D172DBAF600E60AA3 /* providers.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = providers.json; path = ../resources/providers.json; sourceTree = ""; }; 9E774D871767C54E0065EB9B /* MCIMAPFolderStatus.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MCIMAPFolderStatus.h; sourceTree = ""; }; 9E774D881767C7F60065EB9B /* MCIMAPFolderStatus.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MCIMAPFolderStatus.cc; sourceTree = ""; }; @@ -1762,8 +1766,8 @@ C62C6ED716A398FA00737497 /* MCIMAPFolderInfoOperation.h */, C64BB22916E5C0A3000DB34C /* MCIMAPCapabilityOperation.cc */, C64BB22A16E5C0A3000DB34C /* MCIMAPCapabilityOperation.h */, - 4B3C1BDF17ABF4BB008BBF4C /* MCIMAPGetQuotaOperation.cc */, - 4B3C1BE017ABF4BC008BBF4C /* MCIMAPGetQuotaOperation.h */, + 4B3C1BDF17ABF4BB008BBF4C /* MCIMAPQuotaOperation.cc */, + 4B3C1BE017ABF4BC008BBF4C /* MCIMAPQuotaOperation.h */, 9EF9AB10175F319A0027FA3B /* MCIMAPFolderStatusOperation.cc */, 9EF9AB0E175F30C20027FA3B /* MCIMAPFolderStatusOperation.h */, C6081679177635D2001F1018 /* MCIMAPDisconnectOperation.cc */, @@ -2220,8 +2224,8 @@ C6F61F9217016B250073032E /* MCOIMAPIdentityOperation.mm */, C6F61F9417016B310073032E /* MCOIMAPCapabilityOperation.h */, C6F61F9517016B310073032E /* MCOIMAPCapabilityOperation.mm */, - 4B3C1BDC17ABF306008BBF4C /* MCOIMAPGetQuotaOperation.h */, - 4B3C1BDD17ABF307008BBF4C /* MCOIMAPGetQuotaOperation.mm */, + 4B3C1BDC17ABF306008BBF4C /* MCOIMAPQuotaOperation.h */, + 4B3C1BDD17ABF307008BBF4C /* MCOIMAPQuotaOperation.mm */, C6F61F9717016B460073032E /* MCOIMAPSearchExpression.h */, C6F61F9817016B460073032E /* MCOIMAPSearchExpression.mm */, 9EF9AB06175F2EC60027FA3B /* MCOIMAPFolderStatus.h */, @@ -2605,8 +2609,8 @@ BD63713B177DFF080094121B /* MCLibetpan.cc in Sources */, DAACAD5117886807000B4517 /* MCHTMLRendererIMAPDataCallback.cc in Sources */, DA89896D178A47D200F6D90A /* MCOIMAPMessageRenderingOperation.mm in Sources */, - 4B3C1BDE17ABF309008BBF4C /* MCOIMAPGetQuotaOperation.mm in Sources */, - 4B3C1BE117ABF4BC008BBF4C /* MCIMAPGetQuotaOperation.cc in Sources */, + 4B3C1BDE17ABF309008BBF4C /* MCOIMAPQuotaOperation.mm in Sources */, + 4B3C1BE117ABF4BC008BBF4C /* MCIMAPQuotaOperation.cc in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2798,8 +2802,8 @@ BD63713C177DFF080094121B /* MCLibetpan.cc in Sources */, DAACAD5217886807000B4517 /* MCHTMLRendererIMAPDataCallback.cc in Sources */, DA89896E178A47D200F6D90A /* MCOIMAPMessageRenderingOperation.mm in Sources */, - 4B3C1BE317ABFF91008BBF4C /* MCOIMAPGetQuotaOperation.mm in Sources */, - 4B3C1BE517AC0176008BBF4C /* MCIMAPGetQuotaOperation.cc in Sources */, + 4B3C1BE317ABFF91008BBF4C /* MCOIMAPQuotaOperation.mm in Sources */, + 4B3C1BE517AC0176008BBF4C /* MCIMAPQuotaOperation.cc in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/src/async/imap/MCAsyncIMAP.h b/src/async/imap/MCAsyncIMAP.h index 511a5cf6..66ba6c7b 100755 --- a/src/async/imap/MCAsyncIMAP.h +++ b/src/async/imap/MCAsyncIMAP.h @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/async/imap/MCIMAPAsyncConnection.cc b/src/async/imap/MCIMAPAsyncConnection.cc index 77800bca..1472d974 100755 --- a/src/async/imap/MCIMAPAsyncConnection.cc +++ b/src/async/imap/MCIMAPAsyncConnection.cc @@ -30,7 +30,7 @@ #include "MCIMAPIdleOperation.h" #include "MCIMAPIdentityOperation.h" #include "MCIMAPCapabilityOperation.h" -#include "MCIMAPGetQuotaOperation.h" +#include "MCIMAPQuotaOperation.h" #include "MCOperationQueueCallback.h" #include "MCIMAPDisconnectOperation.h" #include "MCIMAPAsyncSession.h" @@ -495,9 +495,9 @@ IMAPCapabilityOperation * IMAPAsyncConnection::capabilityOperation() return op; } -IMAPGetQuotaOperation * IMAPAsyncConnection::getQuotaOperation() +IMAPQuotaOperation * IMAPAsyncConnection::quotaOperation() { - IMAPGetQuotaOperation * op = new IMAPGetQuotaOperation(); + IMAPQuotaOperation * op = new IMAPQuotaOperation(); op->setSession(this); op->autorelease(); return op; diff --git a/src/async/imap/MCIMAPAsyncConnection.h b/src/async/imap/MCIMAPAsyncConnection.h index 8fe025c9..13f9ff7b 100755 --- a/src/async/imap/MCIMAPAsyncConnection.h +++ b/src/async/imap/MCIMAPAsyncConnection.h @@ -25,7 +25,7 @@ namespace mailcore { class IMAPFetchNamespaceOperation; class IMAPIdentityOperation; class IMAPCapabilityOperation; - class IMAPGetQuotaOperation; + class IMAPQuotaOperation; class IMAPOperationQueueCallback; class IMAPAsyncSession; class IMAPConnectionLogger; @@ -121,7 +121,7 @@ namespace mailcore { virtual IMAPOperation * checkAccountOperation(); virtual IMAPCapabilityOperation * capabilityOperation(); - virtual IMAPGetQuotaOperation * getQuotaOperation(); + virtual IMAPQuotaOperation * quotaOperation(); virtual IMAPMessageRenderingOperation * htmlRenderingOperation(IMAPMessage * message, String * folder); virtual IMAPMessageRenderingOperation * htmlBodyRenderingOperation(IMAPMessage * message, String * folder); diff --git a/src/async/imap/MCIMAPAsyncSession.cc b/src/async/imap/MCIMAPAsyncSession.cc index 205b57b2..26c0feca 100755 --- a/src/async/imap/MCIMAPAsyncSession.cc +++ b/src/async/imap/MCIMAPAsyncSession.cc @@ -449,10 +449,10 @@ IMAPCapabilityOperation * IMAPAsyncSession::capabilityOperation() return session->capabilityOperation(); } -IMAPGetQuotaOperation * IMAPAsyncSession::getQuotaOperation() +IMAPQuotaOperation * IMAPAsyncSession::quotaOperation() { IMAPAsyncConnection * session = sessionForFolder(MCSTR("INBOX")); - return session->getQuotaOperation(); + return session->quotaOperation(); } void IMAPAsyncSession::setConnectionLogger(ConnectionLogger * logger) diff --git a/src/async/imap/MCIMAPAsyncSession.h b/src/async/imap/MCIMAPAsyncSession.h index 212cdaab..e5c17078 100755 --- a/src/async/imap/MCIMAPAsyncSession.h +++ b/src/async/imap/MCIMAPAsyncSession.h @@ -33,7 +33,7 @@ namespace mailcore { class IMAPIdentityOperation; class IMAPAsyncConnection; class IMAPCapabilityOperation; - class IMAPGetQuotaOperation; + class IMAPQuotaOperation; class IMAPMessageRenderingOperation; class IMAPMessage; @@ -134,7 +134,7 @@ namespace mailcore { virtual IMAPOperation * checkAccountOperation(); virtual IMAPCapabilityOperation * capabilityOperation(); - virtual IMAPGetQuotaOperation * getQuotaOperation(); + virtual IMAPQuotaOperation * quotaOperation(); virtual IMAPMessageRenderingOperation * htmlRenderingOperation(IMAPMessage * message, String * folder); virtual IMAPMessageRenderingOperation * htmlBodyRenderingOperation(IMAPMessage * message, String * folder); diff --git a/src/async/imap/MCIMAPGetQuotaOperation.cc b/src/async/imap/MCIMAPGetQuotaOperation.cc deleted file mode 100644 index 572bd583..00000000 --- a/src/async/imap/MCIMAPGetQuotaOperation.cc +++ /dev/null @@ -1,42 +0,0 @@ -// -// MCIMAPGetQuotaOperation.cc -// mailcore2 -// -// Created by Petro Korenev on 8/2/13. -// Copyright (c) 2013 MailCore. All rights reserved. -// - -#include "MCIMAPGetQuotaOperation.h" - -#include "MCIMAPSession.h" -#include "MCIMAPAsyncConnection.h" - -using namespace mailcore; - -IMAPGetQuotaOperation::IMAPGetQuotaOperation() -{ - mLimit = 0; - mUsage = 0; -} - -IMAPGetQuotaOperation::~IMAPGetQuotaOperation() -{ -} - -uint32_t IMAPGetQuotaOperation::limit() -{ - return mLimit; -} - -uint32_t IMAPGetQuotaOperation::usage() -{ - return mUsage; -} - -void IMAPGetQuotaOperation::main() -{ - ErrorCode error; - session()->session()->getQuota(&mUsage, &mLimit, &error); - fprintf(stderr, "QnIQuESeqUeNcE %d %d", mUsage, mLimit); - setError(error); -} diff --git a/src/async/imap/MCIMAPGetQuotaOperation.h b/src/async/imap/MCIMAPGetQuotaOperation.h deleted file mode 100644 index bea3d2f6..00000000 --- a/src/async/imap/MCIMAPGetQuotaOperation.h +++ /dev/null @@ -1,39 +0,0 @@ -// -// MCIMAPGetQuotaOperation.h -// mailcore2 -// -// Created by Petro Korenev on 8/2/13. -// Copyright (c) 2013 MailCore. All rights reserved. -// - -#ifndef __MAILCORE_MCIMAPGETQUOTAOPERATION_H_ - -#define __MAILCORE_MCIMAPGETQUOTAOPERATION_H_ - -#include "MCIMAPOperation.h" - -#ifdef __cplusplus - -namespace mailcore { - - class IMAPGetQuotaOperation : public IMAPOperation { - public: - IMAPGetQuotaOperation(); - virtual ~IMAPGetQuotaOperation(); - - // Result. - virtual uint32_t limit(); - virtual uint32_t usage(); - - public: // subclass behavior - virtual void main(); - - private: - uint32_t mLimit; - uint32_t mUsage; - }; -} - -#endif - -#endif diff --git a/src/async/imap/MCIMAPQuotaOperation.cc b/src/async/imap/MCIMAPQuotaOperation.cc new file mode 100644 index 00000000..6744ac4b --- /dev/null +++ b/src/async/imap/MCIMAPQuotaOperation.cc @@ -0,0 +1,41 @@ +// +// MCIMAPQuotaOperation.cc +// mailcore2 +// +// Created by Petro Korenev on 8/2/13. +// Copyright (c) 2013 MailCore. All rights reserved. +// + +#include "MCIMAPQuotaOperation.h" + +#include "MCIMAPSession.h" +#include "MCIMAPAsyncConnection.h" + +using namespace mailcore; + +IMAPQuotaOperation::IMAPQuotaOperation() +{ + mLimit = 0; + mUsage = 0; +} + +IMAPQuotaOperation::~IMAPQuotaOperation() +{ +} + +uint32_t IMAPQuotaOperation::limit() +{ + return mLimit; +} + +uint32_t IMAPQuotaOperation::usage() +{ + return mUsage; +} + +void IMAPQuotaOperation::main() +{ + ErrorCode error; + session()->session()->getQuota(&mUsage, &mLimit, &error); + setError(error); +} diff --git a/src/async/imap/MCIMAPQuotaOperation.h b/src/async/imap/MCIMAPQuotaOperation.h new file mode 100644 index 00000000..5cef943c --- /dev/null +++ b/src/async/imap/MCIMAPQuotaOperation.h @@ -0,0 +1,39 @@ +// +// MCIMAPQuotaOperation.h +// mailcore2 +// +// Created by Petro Korenev on 8/2/13. +// Copyright (c) 2013 MailCore. All rights reserved. +// + +#ifndef __MAILCORE_MCIMAPQuotaOperation_H_ + +#define __MAILCORE_MCIMAPQuotaOperation_H_ + +#include "MCIMAPOperation.h" + +#ifdef __cplusplus + +namespace mailcore { + + class IMAPQuotaOperation : public IMAPOperation { + public: + IMAPQuotaOperation(); + virtual ~IMAPQuotaOperation(); + + // Result. + virtual uint32_t limit(); + virtual uint32_t usage(); + + public: // subclass behavior + virtual void main(); + + private: + uint32_t mLimit; + uint32_t mUsage; + }; +} + +#endif + +#endif diff --git a/src/core/imap/MCIMAPSession.cc b/src/core/imap/MCIMAPSession.cc index f423de1c..09f78ec1 100755 --- a/src/core/imap/MCIMAPSession.cc +++ b/src/core/imap/MCIMAPSession.cc @@ -2445,7 +2445,6 @@ IndexSet * IMAPSession::search(String * folder, IMAPSearchExpression * expressio clist * result_list = NULL; -// int r = mailimap_uid_search(mImap, expression->shouldAvoidCharset() ? NULL : "utf-8", key, &result_list); int r = mailimap_uid_search(mImap, "utf-8", key, &result_list); mailimap_search_key_free(key); MCLog("had error : %i", r); diff --git a/src/objc/imap/MCOIMAP.h b/src/objc/imap/MCOIMAP.h index 9e4cf6c0..e2036291 100755 --- a/src/objc/imap/MCOIMAP.h +++ b/src/objc/imap/MCOIMAP.h @@ -36,7 +36,7 @@ #import #import #import -#import +#import #import #import diff --git a/src/objc/imap/MCOIMAPGetQuotaOperation.h b/src/objc/imap/MCOIMAPGetQuotaOperation.h deleted file mode 100644 index 401b5aaa..00000000 --- a/src/objc/imap/MCOIMAPGetQuotaOperation.h +++ /dev/null @@ -1,15 +0,0 @@ -// -// MCOIMAPGetQuotaOperation.h -// mailcore2 -// -// Created by Petro Korenev on 8/2/13. -// Copyright (c) 2013 MailCore. All rights reserved. -// - -#import "MCOIMAPBaseOperation.h" - -@interface MCOIMAPGetQuotaOperation : MCOIMAPBaseOperation - -- (void) start:(void (^)(NSError * error, NSUInteger usage, NSUInteger limit))completionBlock; - -@end diff --git a/src/objc/imap/MCOIMAPGetQuotaOperation.mm b/src/objc/imap/MCOIMAPGetQuotaOperation.mm deleted file mode 100644 index 25a6dc98..00000000 --- a/src/objc/imap/MCOIMAPGetQuotaOperation.mm +++ /dev/null @@ -1,69 +0,0 @@ -// -// MCOIMAPGetQuotaOperation.m -// mailcore2 -// -// Created by Petro Korenev on 8/2/13. -// Copyright (c) 2013 MailCore. All rights reserved. -// - -#import "MCOIMAPGetQuotaOperation.h" - -#include "MCAsyncIMAP.h" - -#import "MCOOperation+Private.h" -#import "MCOUtils.h" - -typedef void (^CompletionType)(NSError *error, NSUInteger usage, NSUInteger limit); - -@implementation MCOIMAPGetQuotaOperation { - CompletionType _completionBlock; -} - -#define nativeType mailcore::IMAPGetQuotaOperation - -+ (void) load -{ - MCORegisterClass(self, &typeid(nativeType)); -} - -+ (NSObject *) mco_objectWithMCObject:(mailcore::Object *)object -{ - nativeType * op = (nativeType *) object; - return [[[self alloc] initWithMCOperation:op] autorelease]; -} - -- (void) dealloc -{ - [_completionBlock release]; - [super dealloc]; -} - -- (void) start:(void (^)(NSError *error, NSUInteger usage, NSUInteger limit))completionBlock -{ - _completionBlock = [completionBlock copy]; - [self start]; -} - -- (void) cancel -{ - [_completionBlock release]; - _completionBlock = nil; - [super cancel]; -} - -- (void) operationCompleted -{ - if (_completionBlock == NULL) - return; - - nativeType *op = MCO_NATIVE_INSTANCE; - if (op->error() == mailcore::ErrorNone) { - _completionBlock(nil, op->usage(), op->limit()); - } else { - _completionBlock([NSError mco_errorWithErrorCode:op->error()], 0, 0); - } - [_completionBlock release]; - _completionBlock = nil; -} - -@end diff --git a/src/objc/imap/MCOIMAPQuotaOperation.h b/src/objc/imap/MCOIMAPQuotaOperation.h new file mode 100644 index 00000000..c0463bb0 --- /dev/null +++ b/src/objc/imap/MCOIMAPQuotaOperation.h @@ -0,0 +1,15 @@ +// +// MCOIMAPQuotaOperation.h +// mailcore2 +// +// Created by Petro Korenev on 8/2/13. +// Copyright (c) 2013 MailCore. All rights reserved. +// + +#import "MCOIMAPBaseOperation.h" + +@interface MCOIMAPQuotaOperation : MCOIMAPBaseOperation + +- (void) start:(void (^)(NSError * error, NSUInteger usage, NSUInteger limit))completionBlock; + +@end diff --git a/src/objc/imap/MCOIMAPQuotaOperation.mm b/src/objc/imap/MCOIMAPQuotaOperation.mm new file mode 100644 index 00000000..5be2571f --- /dev/null +++ b/src/objc/imap/MCOIMAPQuotaOperation.mm @@ -0,0 +1,69 @@ +// +// MCOIMAPQuotaOperation.m +// mailcore2 +// +// Created by Petro Korenev on 8/2/13. +// Copyright (c) 2013 MailCore. All rights reserved. +// + +#import "MCOIMAPQuotaOperation.h" + +#include "MCAsyncIMAP.h" + +#import "MCOOperation+Private.h" +#import "MCOUtils.h" + +typedef void (^CompletionType)(NSError *error, NSUInteger usage, NSUInteger limit); + +@implementation MCOIMAPQuotaOperation { + CompletionType _completionBlock; +} + +#define nativeType mailcore::IMAPQuotaOperation + ++ (void) load +{ + MCORegisterClass(self, &typeid(nativeType)); +} + ++ (NSObject *) mco_objectWithMCObject:(mailcore::Object *)object +{ + nativeType * op = (nativeType *) object; + return [[[self alloc] initWithMCOperation:op] autorelease]; +} + +- (void) dealloc +{ + [_completionBlock release]; + [super dealloc]; +} + +- (void) start:(void (^)(NSError *error, NSUInteger usage, NSUInteger limit))completionBlock +{ + _completionBlock = [completionBlock copy]; + [self start]; +} + +- (void) cancel +{ + [_completionBlock release]; + _completionBlock = nil; + [super cancel]; +} + +- (void) operationCompleted +{ + if (_completionBlock == NULL) + return; + + nativeType *op = MCO_NATIVE_INSTANCE; + if (op->error() == mailcore::ErrorNone) { + _completionBlock(nil, op->usage(), op->limit()); + } else { + _completionBlock([NSError mco_errorWithErrorCode:op->error()], 0, 0); + } + [_completionBlock release]; + _completionBlock = nil; +} + +@end diff --git a/src/objc/imap/MCOIMAPSession.h b/src/objc/imap/MCOIMAPSession.h index 9776ab11..ea920114 100755 --- a/src/objc/imap/MCOIMAPSession.h +++ b/src/objc/imap/MCOIMAPSession.h @@ -29,7 +29,7 @@ @class MCOIMAPSearchExpression; @class MCOIMAPIdentityOperation; @class MCOIMAPCapabilityOperation; -@class MCOIMAPGetQuotaOperation; +@class MCOIMAPQuotaOperation; @class MCOIMAPMessageRenderingOperation; @class MCOIMAPMessage; @@ -508,7 +508,7 @@ */ - (MCOIMAPCapabilityOperation *) capabilityOperation; -- (MCOIMAPGetQuotaOperation *) getQuotaOperation; +- (MCOIMAPQuotaOperation *) quotaOperation; /** @name Search Operations */ diff --git a/src/objc/imap/MCOIMAPSession.mm b/src/objc/imap/MCOIMAPSession.mm index 62899b37..a9bbeb5c 100755 --- a/src/objc/imap/MCOIMAPSession.mm +++ b/src/objc/imap/MCOIMAPSession.mm @@ -362,9 +362,9 @@ MCO_OBJC_SYNTHESIZE_SCALAR(unsigned int, unsigned int, setMaximumConnections, ma return MCO_TO_OBJC_OP(coreOp); } -- (MCOIMAPGetQuotaOperation *) getQuotaOperation +- (MCOIMAPQuotaOperation *) quotaOperation { - IMAPGetQuotaOperation * coreOp = MCO_NATIVE_INSTANCE->getQuotaOperation(); + IMAPQuotaOperation * coreOp = MCO_NATIVE_INSTANCE->quotaOperation(); return MCO_TO_OBJC_OP((IMAPOperation*)coreOp); } -- cgit v1.2.3 From 18116c342c4b0e917b35e13d81151baca1298e0e Mon Sep 17 00:00:00 2001 From: "Hoa V. DINH" Date: Fri, 9 Aug 2013 14:17:47 -0700 Subject: Fixed MIME type conversion --- src/core/imap/MCIMAPPart.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/imap/MCIMAPPart.cc b/src/core/imap/MCIMAPPart.cc index 76e59021..5fc39fc9 100644 --- a/src/core/imap/MCIMAPPart.cc +++ b/src/core/imap/MCIMAPPart.cc @@ -221,7 +221,7 @@ IMAPPart * IMAPPart::attachmentWithIMAPBody1PartBasic(struct mailimap_body_type_ mimeType = String::stringWithUTF8Format("video/%s", basic->bd_media_basic->med_subtype); break; case MAILIMAP_MEDIA_BASIC_OTHER: - mimeType = String::stringWithUTF8Format("other/%s", basic->bd_media_basic->med_subtype); + mimeType = String::stringWithUTF8Format("%s/%s", basic->bd_media_basic->med_basic_type, basic->bd_media_basic->med_subtype); break; } attachment->setMimeType(mimeType); -- cgit v1.2.3 From 7ceab3190caaa6f1dadf8d29bce12c4d772c48fe Mon Sep 17 00:00:00 2001 From: Pushkar Singh Date: Sat, 10 Aug 2013 13:15:46 -0700 Subject: mailimap_has_qresync should be called to check QRESYNC instead of mailimap_has_condstore --- src/core/imap/MCIMAPSession.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/imap/MCIMAPSession.cc b/src/core/imap/MCIMAPSession.cc index 09f78ec1..c54d8395 100755 --- a/src/core/imap/MCIMAPSession.cc +++ b/src/core/imap/MCIMAPSession.cc @@ -3058,7 +3058,7 @@ IndexSet * IMAPSession::capability(ErrorCode * pError) result->addIndex(IMAPCapabilityCondstore); mCondstoreEnabled = true; } - if (mailimap_has_condstore(mImap)) { + if (mailimap_has_qresync(mImap)) { result->addIndex(IMAPCapabilityQResync); mQResyncEnabled = true; } -- cgit v1.2.3 From 82c918489bfb11aee57b8a00b34305956fca3433 Mon Sep 17 00:00:00 2001 From: Pushkar Singh Date: Sat, 10 Aug 2013 14:58:41 -0700 Subject: Revert "ignore build/ folders" This reverts commit aefac083c0553f0a71f808eea1d93458496e026e. --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 03378c52..e743557b 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,4 @@ project.xcworkspace example/ios/iOS UI Test/DerivedData scripts/prebuilt.list -build/ + -- cgit v1.2.3 From 5b52b34754ecced0217fe5bb188f2d4c5103d800 Mon Sep 17 00:00:00 2001 From: "Hoa V. DINH" Date: Sun, 11 Aug 2013 17:14:01 -0700 Subject: Added capability for X-GM-EXT-1 (Gmail) --- src/core/abstract/MCMessageConstants.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/core/abstract/MCMessageConstants.h b/src/core/abstract/MCMessageConstants.h index a245eac3..097ced04 100644 --- a/src/core/abstract/MCMessageConstants.h +++ b/src/core/abstract/MCMessageConstants.h @@ -123,6 +123,7 @@ namespace mailcore { IMAPCapabilityAuthSKey, IMAPCapabilityAuthSRP, IMAPCapabilityXOAuth2, + IMAPCapabilityGmail, }; enum POPCapability { -- cgit v1.2.3 From 3a95b361831b4fe227913af04a7a7c2d53e1737d Mon Sep 17 00:00:00 2001 From: "Hoa V. Dinh" Date: Mon, 12 Aug 2013 16:42:29 -0700 Subject: Fixed build (for Cocoapods) --- src/core/abstract/MCMessageHeader.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/core/abstract/MCMessageHeader.cc b/src/core/abstract/MCMessageHeader.cc index 6dd1cdd1..34aba8f5 100644 --- a/src/core/abstract/MCMessageHeader.cc +++ b/src/core/abstract/MCMessageHeader.cc @@ -1,6 +1,7 @@ #include "MCMessageHeader.h" #include "MCAddress.h" +#include "MCIterator.h" #include #include -- cgit v1.2.3 From 9823e07d1e87ce5ff54cf92a24e8f9ea4ce20ba8 Mon Sep 17 00:00:00 2001 From: "Hoa V. Dinh" Date: Wed, 14 Aug 2013 11:45:05 -0700 Subject: Fixed state when select() fails on IMAP --- src/core/imap/MCIMAPSession.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/core/imap/MCIMAPSession.cc b/src/core/imap/MCIMAPSession.cc index c54d8395..06bfced7 100755 --- a/src/core/imap/MCIMAPSession.cc +++ b/src/core/imap/MCIMAPSession.cc @@ -884,6 +884,7 @@ void IMAPSession::select(String * folder, ErrorCode * pError) } else if (hasError(r)) { * pError = ErrorNonExistantFolder; + mState == STATE_LOGGEDIN; MC_SAFE_RELEASE(mCurrentFolder); return; } -- cgit v1.2.3 From d9045b9396b1f3ad937e3e8ac43014fa44a2c949 Mon Sep 17 00:00:00 2001 From: "Hoa V. DINH" Date: Sat, 17 Aug 2013 12:08:17 -0700 Subject: Updated to libetpan 5ee776caa2b005a13ff604bb35539832b2ad1a52 --- scripts/prepare-libetpan-ios.sh | 2 +- scripts/prepare-libetpan-macos.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/prepare-libetpan-ios.sh b/scripts/prepare-libetpan-ios.sh index fad34498..f9757286 100755 --- a/scripts/prepare-libetpan-ios.sh +++ b/scripts/prepare-libetpan-ios.sh @@ -2,7 +2,7 @@ sdkversion=6.1 url="https://github.com/dinhviethoa/libetpan.git" -rev=4b8e42fc53509a6933451e326a1a258f403162fa +rev=5ee776caa2b005a13ff604bb35539832b2ad1a52 pushd `dirname $0` > /dev/null scriptpath=`pwd` diff --git a/scripts/prepare-libetpan-macos.sh b/scripts/prepare-libetpan-macos.sh index 4283e232..31a40c40 100755 --- a/scripts/prepare-libetpan-macos.sh +++ b/scripts/prepare-libetpan-macos.sh @@ -1,7 +1,7 @@ #!/bin/sh url="https://github.com/dinhviethoa/libetpan.git" -rev=4b8e42fc53509a6933451e326a1a258f403162fa +rev=5ee776caa2b005a13ff604bb35539832b2ad1a52 pushd `dirname $0` > /dev/null scriptpath=`pwd` -- cgit v1.2.3 From 1369f83a49766b847a58d21313be82582a67b784 Mon Sep 17 00:00:00 2001 From: "Hoa V. DINH" Date: Sat, 17 Aug 2013 12:08:45 -0700 Subject: Fixed memory leak in logger --- example/mac/macExample/macExample/AppDelegate.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/mac/macExample/macExample/AppDelegate.m b/example/mac/macExample/macExample/AppDelegate.m index 5081f8a5..7be4bfc2 100644 --- a/example/mac/macExample/macExample/AppDelegate.m +++ b/example/mac/macExample/macExample/AppDelegate.m @@ -146,7 +146,7 @@ finishedRefreshWithFetcher:(GTMHTTPFetcher *)fetcher self.checkOp = [self.session checkAccountOperation]; self.session.connectionLogger = ^(void * connectionID, MCOConnectionLogType type, NSData * data) { if (type != MCOConnectionLogTypeSentPrivate) { - NSLog(@"event logged:%p %i withData: %@", connectionID, type, [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]); + NSLog(@"event logged:%p %i withData: %@", connectionID, type, [[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] autorelease]); } }; -- cgit v1.2.3 From a437fb12b6948eace575a8fc773544c2e5bc80de Mon Sep 17 00:00:00 2001 From: "Hoa V. DINH" Date: Sat, 17 Aug 2013 12:09:43 -0700 Subject: Fixed memory leak in autorelease pool --- src/core/basetypes/MCAutoreleasePool.cc | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/core/basetypes/MCAutoreleasePool.cc b/src/core/basetypes/MCAutoreleasePool.cc index 8c351bdf..67e58a78 100644 --- a/src/core/basetypes/MCAutoreleasePool.cc +++ b/src/core/basetypes/MCAutoreleasePool.cc @@ -60,13 +60,9 @@ carray * AutoreleasePool::createAutoreleasePoolStackIfNeeded() return stack; } -void AutoreleasePool::destroyAutoreleasePoolStack(void *) +void AutoreleasePool::destroyAutoreleasePoolStack(void * value) { - init(); - carray * stack = (carray *) pthread_getspecific(autoreleasePoolStackKey); - if (stack == NULL) - return; - + carray * stack = (carray *) value; if (carray_count(stack) != 0) { MCLog("some autoreleasepool have not been released\n"); } -- cgit v1.2.3 From ea47c349c9ffe5f1aaa278af58479f0871dcec3b Mon Sep 17 00:00:00 2001 From: "Hoa V. DINH" Date: Sat, 17 Aug 2013 13:06:11 -0700 Subject: Fixed several warnings --- build-mac/mailcore2.xcodeproj/project.pbxproj | 2 -- src/core/abstract/MCAbstractPart.cc | 1 - src/core/basetypes/MCObject.cc | 4 ++-- src/core/basetypes/MCRange.cc | 6 ++++++ src/core/basetypes/MCString.cc | 4 ++-- src/core/basetypes/MCValue.cc | 1 + src/core/imap/MCIMAPMessage.cc | 2 +- src/core/imap/MCIMAPSession.cc | 9 ++------- src/objc/abstract/MCOMessageHeader.mm | 8 ++++---- 9 files changed, 18 insertions(+), 19 deletions(-) diff --git a/build-mac/mailcore2.xcodeproj/project.pbxproj b/build-mac/mailcore2.xcodeproj/project.pbxproj index 9c9efc3c..acb3260a 100755 --- a/build-mac/mailcore2.xcodeproj/project.pbxproj +++ b/build-mac/mailcore2.xcodeproj/project.pbxproj @@ -2946,7 +2946,6 @@ CLANG_CXX_LIBRARY = "libc++"; COMBINE_HIDPI_IMAGES = YES; EXECUTABLE_PREFIX = lib; - GCC_WARN_INHIBIT_ALL_WARNINGS = YES; PRODUCT_NAME = MailCore; }; name = Debug; @@ -2958,7 +2957,6 @@ CLANG_CXX_LIBRARY = "libc++"; COMBINE_HIDPI_IMAGES = YES; EXECUTABLE_PREFIX = lib; - GCC_WARN_INHIBIT_ALL_WARNINGS = YES; PRODUCT_NAME = MailCore; }; name = Release; diff --git a/src/core/abstract/MCAbstractPart.cc b/src/core/abstract/MCAbstractPart.cc index d7b57544..c2646d36 100644 --- a/src/core/abstract/MCAbstractPart.cc +++ b/src/core/abstract/MCAbstractPart.cc @@ -364,5 +364,4 @@ void AbstractPart::importSerializable(HashMap * serializable) setPartType(PartTypeMultipartAlternative); } } - PartType mPartType; } diff --git a/src/core/basetypes/MCObject.cc b/src/core/basetypes/MCObject.cc index 8ed4fb52..e792a1fd 100644 --- a/src/core/basetypes/MCObject.cc +++ b/src/core/basetypes/MCObject.cc @@ -280,7 +280,7 @@ void Object::registerObjectConstructor(const char * className, void * (* objectC chashdatum key; chashdatum value; key.data = (void *) className; - key.len = strlen(className); + key.len = (unsigned int) strlen(className); value.data = (void *) objectConstructor; value.len = 0; chash_set(constructors, &key, &value, NULL); @@ -297,7 +297,7 @@ Object * Object::objectWithSerializable(HashMap * serializable) chashdatum value; const char * className = ((String *) serializable->objectForKey(MCSTR("class")))->UTF8Characters(); key.data = (void *) className; - key.len = strlen(className); + key.len = (unsigned int) strlen(className); int r = chash_get(constructors, &key, &value); if (r < 0) return NULL; diff --git a/src/core/basetypes/MCRange.cc b/src/core/basetypes/MCRange.cc index 7b7e9f41..6a5bba7d 100644 --- a/src/core/basetypes/MCRange.cc +++ b/src/core/basetypes/MCRange.cc @@ -4,6 +4,7 @@ #include "MCHashMap.h" #include "MCString.h" #include "MCUtils.h" +#include "MCArray.h" #include @@ -149,4 +150,9 @@ String * mailcore::RangeToString(Range range) Range mailcore::RangeFromString(String * rangeString) { Array * components = rangeString->componentsSeparatedByString(MCSTR("-")); + if (components->count() != 2) + return RangeEmpty; + String * locationString = (String *) components->objectAtIndex(0); + String * lengthString = (String *) components->objectAtIndex(1); + return RangeMake(locationString->unsignedLongLongValue(), lengthString->unsignedLongLongValue()); } diff --git a/src/core/basetypes/MCString.cc b/src/core/basetypes/MCString.cc index 2f8ab316..c6b4ae8d 100644 --- a/src/core/basetypes/MCString.cc +++ b/src/core/basetypes/MCString.cc @@ -2125,8 +2125,8 @@ bool String::isEqualCaseInsensitive(String * otherString) Data * String::decodedBase64Data() { const char * utf8 = UTF8Characters(); - char * decoded = MCDecodeBase64(utf8, strlen(utf8)); - Data * result = Data::dataWithBytes(decoded, strlen(decoded)); + char * decoded = MCDecodeBase64(utf8, (unsigned int) strlen(utf8)); + Data * result = Data::dataWithBytes(decoded, (unsigned int) strlen(decoded)); free(decoded); return result; } diff --git a/src/core/basetypes/MCValue.cc b/src/core/basetypes/MCValue.cc index 11dbc79f..db9e96eb 100644 --- a/src/core/basetypes/MCValue.cc +++ b/src/core/basetypes/MCValue.cc @@ -76,6 +76,7 @@ String * Value::description() return String::stringWithUTF8Format("", this); default: MCAssert(0); + return NULL; } } diff --git a/src/core/imap/MCIMAPMessage.cc b/src/core/imap/MCIMAPMessage.cc index d8a0d943..74b3459b 100644 --- a/src/core/imap/MCIMAPMessage.cc +++ b/src/core/imap/MCIMAPMessage.cc @@ -237,7 +237,7 @@ void IMAPMessage::importSerializable(HashMap * serializable) } String * uid = (String *) serializable->objectForKey(MCSTR("uid")); if (uid != NULL) { - setUid(uid->unsignedLongValue()); + setUid((uint32_t) uid->unsignedLongValue()); } String * flags = (String *) serializable->objectForKey(MCSTR("flags")); if (flags != NULL) { diff --git a/src/core/imap/MCIMAPSession.cc b/src/core/imap/MCIMAPSession.cc index 06bfced7..8f31856b 100755 --- a/src/core/imap/MCIMAPSession.cc +++ b/src/core/imap/MCIMAPSession.cc @@ -884,7 +884,7 @@ void IMAPSession::select(String * folder, ErrorCode * pError) } else if (hasError(r)) { * pError = ErrorNonExistantFolder; - mState == STATE_LOGGEDIN; + mState = STATE_LOGGEDIN; MC_SAFE_RELEASE(mCurrentFolder); return; } @@ -2474,14 +2474,9 @@ IndexSet * IMAPSession::search(String * folder, IMAPSearchExpression * expressio void IMAPSession::getQuota(uint32_t *usage, uint32_t *limit, ErrorCode * pError) { - static char * const inboxFolderName = "INBOX"; mailimap_quota_complete_data *quota_data; - selectIfNeeded(MCSTR("INBOX"), pError); - - if (* pError != ErrorNone) - return; - int r = mailimap_quota_getquotaroot(mImap, inboxFolderName, "a_data); + int r = mailimap_quota_getquotaroot(mImap, "INBOX", "a_data); if (r == MAILIMAP_ERROR_STREAM) { * pError = ErrorConnection; return; diff --git a/src/objc/abstract/MCOMessageHeader.mm b/src/objc/abstract/MCOMessageHeader.mm index 241dab88..7dee244f 100644 --- a/src/objc/abstract/MCOMessageHeader.mm +++ b/src/objc/abstract/MCOMessageHeader.mm @@ -102,18 +102,18 @@ MCO_OBJC_SYNTHESIZE_ARRAY(setReplyTo, replyTo) MCO_OBJC_SYNTHESIZE_STRING(setSubject, subject) MCO_OBJC_SYNTHESIZE_STRING(setUserAgent, userAgent) -- (void)addExtraHeaderValue:(NSString *)value forName:(NSString *)name { +- (void)addHeaderValue:(NSString *)value forName:(NSString *)name { _nativeHeader->setExtraHeader(MCO_FROM_OBJC(mailcore::String, name), MCO_FROM_OBJC(mailcore::String, value)); } -- (NSString *)extraHeaderValueForName:(NSString *)name { +- (NSString *)headerValueForName:(NSString *)name { return MCO_TO_OBJC(_nativeHeader->extraHeaderValueForName((MCO_FROM_OBJC(mailcore::String, name)))); } -- (void)removeExtraHeaderForName:(NSString *)name { +- (void)removeHeaderForName:(NSString *)name { _nativeHeader->removeExtraHeader(MCO_FROM_OBJC(mailcore::String, name)); } -- (NSArray * /* NSString */)allExtraHeadersNames { +- (NSArray * /* NSString */)allHeadersNames { return MCO_TO_OBJC(_nativeHeader->allExtraHeadersNames()); } -- cgit v1.2.3 From 4c41560313cdb4aa57ce9c15ed4285318d99f56c Mon Sep 17 00:00:00 2001 From: "Hoa V. DINH" Date: Sat, 17 Aug 2013 13:11:42 -0700 Subject: Updated settings --- build-mac/mailcore2.xcodeproj/project.pbxproj | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/build-mac/mailcore2.xcodeproj/project.pbxproj b/build-mac/mailcore2.xcodeproj/project.pbxproj index acb3260a..ef7dab58 100755 --- a/build-mac/mailcore2.xcodeproj/project.pbxproj +++ b/build-mac/mailcore2.xcodeproj/project.pbxproj @@ -2840,7 +2840,6 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - ARCHS = "$(ARCHS_STANDARD_64_BIT)"; CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_OBJC_ARC = NO; @@ -2886,7 +2885,6 @@ ONLY_ACTIVE_ARCH = YES; OSX_HEADERS_SEARCH_PATHS = "\"$(SRCROOT)/../Externals/libetpan/include\" \"$(SRCROOT)/../Externals/icu4c/include\" \"$(SRCROOT)/../Externals/ctemplate/include\" /usr/include/tidy /usr/include/libxml2"; OSX_LIBRARY_SEARCH_PATHS = "\"$(SRCROOT)/../Externals/libetpan/lib\" \"$(SRCROOT)/../Externals/icu4c/lib\" \"$(SRCROOT)/../Externals/ctemplate/lib\""; - SDKROOT = macosx; }; name = Debug; }; @@ -2894,7 +2892,6 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - ARCHS = "$(ARCHS_STANDARD_64_BIT)"; CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_OBJC_ARC = NO; @@ -2935,43 +2932,50 @@ MACOSX_DEPLOYMENT_TARGET = 10.8; OSX_HEADERS_SEARCH_PATHS = "\"$(SRCROOT)/../Externals/libetpan/include\" \"$(SRCROOT)/../Externals/icu4c/include\" \"$(SRCROOT)/../Externals/ctemplate/include\" /usr/include/tidy /usr/include/libxml2"; OSX_LIBRARY_SEARCH_PATHS = "\"$(SRCROOT)/../Externals/libetpan/lib\" \"$(SRCROOT)/../Externals/icu4c/lib\" \"$(SRCROOT)/../Externals/ctemplate/lib\""; - SDKROOT = macosx; }; name = Release; }; C64EA53C169E772200778456 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + ARCHS = "$(ARCHS_STANDARD_64_BIT)"; CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; CLANG_CXX_LIBRARY = "libc++"; COMBINE_HIDPI_IMAGES = YES; EXECUTABLE_PREFIX = lib; PRODUCT_NAME = MailCore; + SDKROOT = macosx; }; name = Debug; }; C64EA53D169E772200778456 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + ARCHS = "$(ARCHS_STANDARD_64_BIT)"; CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; CLANG_CXX_LIBRARY = "libc++"; COMBINE_HIDPI_IMAGES = YES; EXECUTABLE_PREFIX = lib; PRODUCT_NAME = MailCore; + SDKROOT = macosx; }; name = Release; }; C64EA799169F259300778456 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + ARCHS = "$(ARCHS_STANDARD_64_BIT)"; PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = macosx; }; name = Debug; }; C64EA79A169F259300778456 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + ARCHS = "$(ARCHS_STANDARD_64_BIT)"; PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = macosx; }; name = Release; }; @@ -3055,7 +3059,6 @@ CLANG_CXX_LIBRARY = "libstdc++"; DEAD_CODE_STRIPPING = NO; EXECUTABLE_PREFIX = lib; - ONLY_ACTIVE_ARCH = NO; PRODUCT_NAME = "MailCore-ios"; SDKROOT = iphoneos; SKIP_INSTALL = YES; @@ -3072,7 +3075,6 @@ CLANG_CXX_LIBRARY = "libstdc++"; DEAD_CODE_STRIPPING = NO; EXECUTABLE_PREFIX = lib; - ONLY_ACTIVE_ARCH = NO; PRODUCT_NAME = "MailCore-ios"; SDKROOT = iphoneos; SKIP_INSTALL = YES; @@ -3083,6 +3085,7 @@ C6BD289E170BD71100A91AC1 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + ARCHS = "$(ARCHS_STANDARD_64_BIT)"; CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; CLANG_CXX_LIBRARY = "libc++"; COMBINE_HIDPI_IMAGES = YES; @@ -3107,6 +3110,7 @@ "-lz", ); PRODUCT_NAME = MailCore; + SDKROOT = macosx; WRAPPER_EXTENSION = framework; }; name = Debug; @@ -3114,6 +3118,7 @@ C6BD289F170BD71100A91AC1 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + ARCHS = "$(ARCHS_STANDARD_64_BIT)"; CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; CLANG_CXX_LIBRARY = "libc++"; COMBINE_HIDPI_IMAGES = YES; @@ -3138,6 +3143,7 @@ "-lz", ); PRODUCT_NAME = MailCore; + SDKROOT = macosx; WRAPPER_EXTENSION = framework; }; name = Release; -- cgit v1.2.3 From 11b0dadce55fb4ffe9cfeb6298971066ead8cace Mon Sep 17 00:00:00 2001 From: "Hoa V. DINH" Date: Sat, 17 Aug 2013 19:17:14 -0700 Subject: Fixed #317: on yahoo servers, don't use charset when searching. --- src/core/imap/MCIMAPSession.cc | 8 +++++++- src/core/imap/MCIMAPSession.h | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/core/imap/MCIMAPSession.cc b/src/core/imap/MCIMAPSession.cc index 8f31856b..5dbe62a6 100755 --- a/src/core/imap/MCIMAPSession.cc +++ b/src/core/imap/MCIMAPSession.cc @@ -342,6 +342,7 @@ void IMAPSession::init() mModSequenceValue = 0; mFolderMsgCount = 0; mFirstUnseenUid = 0; + mYahooServer = false; mLastFetchedSequenceNumber = 0; mCurrentFolder = NULL; pthread_mutex_init(&mIdleLock, NULL); @@ -632,6 +633,7 @@ void IMAPSession::connect(ErrorCode * pError) if (mImap->imap_response != NULL) { MC_SAFE_REPLACE_RETAIN(String, mWelcomeString, String::stringWithUTF8Characters(mImap->imap_response)); + mYahooServer = (mWelcomeString->locationOfString(MCSTR("yahoo.com")) != -1); } * pError = ErrorNone; @@ -2446,7 +2448,11 @@ IndexSet * IMAPSession::search(String * folder, IMAPSearchExpression * expressio clist * result_list = NULL; - int r = mailimap_uid_search(mImap, "utf-8", key, &result_list); + const char * charset = "utf-8"; + if (mYahooServer) { + charset = NULL; + } + int r = mailimap_uid_search(mImap, charset, key, &result_list); mailimap_search_key_free(key); MCLog("had error : %i", r); if (r == MAILIMAP_ERROR_STREAM) { diff --git a/src/core/imap/MCIMAPSession.h b/src/core/imap/MCIMAPSession.h index 97567d65..0a5506ab 100755 --- a/src/core/imap/MCIMAPSession.h +++ b/src/core/imap/MCIMAPSession.h @@ -206,6 +206,7 @@ namespace mailcore { uint64_t mModSequenceValue; unsigned int mFolderMsgCount; uint32_t mFirstUnseenUid; + bool mYahooServer; unsigned int mLastFetchedSequenceNumber; String * mCurrentFolder; -- cgit v1.2.3 From 0bc9d79ada9b7a0a3f2cc2ea8c398e480be779f6 Mon Sep 17 00:00:00 2001 From: "Hoa V. DINH" Date: Sat, 17 Aug 2013 19:39:58 -0700 Subject: Fixed build --- example/ios/iOS UI Test/iOS UI Test.xcodeproj/project.pbxproj | 1 + 1 file changed, 1 insertion(+) diff --git a/example/ios/iOS UI Test/iOS UI Test.xcodeproj/project.pbxproj b/example/ios/iOS UI Test/iOS UI Test.xcodeproj/project.pbxproj index da41f157..5b53cf3b 100644 --- a/example/ios/iOS UI Test/iOS UI Test.xcodeproj/project.pbxproj +++ b/example/ios/iOS UI Test/iOS UI Test.xcodeproj/project.pbxproj @@ -552,6 +552,7 @@ AB9EAE2A170368F000D750C7 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_CXX_LIBRARY = "libstdc++"; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "iOS UI Test/iOS UI Test-Prefix.pch"; INFOPLIST_FILE = "iOS UI Test/iOS UI Test-Info.plist"; -- cgit v1.2.3 From d510c2dda500ce3955df1c377410b1d8ffc9cf6b Mon Sep 17 00:00:00 2001 From: "Hoa V. DINH" Date: Sat, 17 Aug 2013 20:09:36 -0700 Subject: Fixed #314: added -[MCOSMTPSession sendOperationWithData:from:recipients:] --- src/async/smtp/MCSMTPAsyncSession.cc | 11 ++++++++++ src/async/smtp/MCSMTPAsyncSession.h | 2 ++ src/async/smtp/MCSMTPSendWithDataOperation.cc | 31 ++++++++++++++++++++++++++- src/async/smtp/MCSMTPSendWithDataOperation.h | 8 +++++++ src/core/smtp/MCSMTPSession.h | 4 ++-- src/objc/smtp/MCOSMTPSession.h | 18 ++++++++++++++++ src/objc/smtp/MCOSMTPSession.mm | 13 +++++++++++ 7 files changed, 84 insertions(+), 3 deletions(-) diff --git a/src/async/smtp/MCSMTPAsyncSession.cc b/src/async/smtp/MCSMTPAsyncSession.cc index f670894a..4da41b5d 100644 --- a/src/async/smtp/MCSMTPAsyncSession.cc +++ b/src/async/smtp/MCSMTPAsyncSession.cc @@ -211,6 +211,17 @@ SMTPOperation * SMTPAsyncSession::sendMessageOperation(Data * messageData) return (SMTPOperation *) op->autorelease(); } +SMTPOperation * SMTPAsyncSession::sendMessageOperation(Address * from, Array * recipients, + Data * messageData) +{ + SMTPSendWithDataOperation * op = new SMTPSendWithDataOperation(); + op->setSession(this); + op->setMessageData(messageData); + op->setFrom(from); + op->setRecipients(recipients); + return (SMTPOperation *) op->autorelease(); +} + SMTPOperation * SMTPAsyncSession::checkAccountOperation(Address * from) { SMTPCheckAccountOperation * op = new SMTPCheckAccountOperation(); diff --git a/src/async/smtp/MCSMTPAsyncSession.h b/src/async/smtp/MCSMTPAsyncSession.h index bbb81737..f013dc26 100644 --- a/src/async/smtp/MCSMTPAsyncSession.h +++ b/src/async/smtp/MCSMTPAsyncSession.h @@ -55,6 +55,8 @@ namespace mailcore { virtual ConnectionLogger * connectionLogger(); virtual SMTPOperation * sendMessageOperation(Data * messageData); + virtual SMTPOperation * sendMessageOperation(Address * from, Array * recipients, + Data * messageData); virtual SMTPOperation * checkAccountOperation(Address * from); public: // private diff --git a/src/async/smtp/MCSMTPSendWithDataOperation.cc b/src/async/smtp/MCSMTPSendWithDataOperation.cc index bb2c5ea9..03f6a530 100644 --- a/src/async/smtp/MCSMTPSendWithDataOperation.cc +++ b/src/async/smtp/MCSMTPSendWithDataOperation.cc @@ -16,10 +16,14 @@ using namespace mailcore; SMTPSendWithDataOperation::SMTPSendWithDataOperation() { mMessageData = NULL; + mFrom = NULL; + mRecipients = NULL; } SMTPSendWithDataOperation::~SMTPSendWithDataOperation() { + MC_SAFE_RELEASE(mFrom); + MC_SAFE_RELEASE(mRecipients); MC_SAFE_RELEASE(mMessageData); } @@ -33,9 +37,34 @@ Data * SMTPSendWithDataOperation::messageData() return mMessageData; } +void SMTPSendWithDataOperation::setFrom(Address * from) +{ + MC_SAFE_REPLACE_COPY(Address, mFrom, from); +} + +Address * SMTPSendWithDataOperation::from() +{ + return mFrom; +} + +void SMTPSendWithDataOperation::setRecipients(Array * recipients) +{ + MC_SAFE_REPLACE_COPY(Array, mRecipients, recipients); +} + +Array * SMTPSendWithDataOperation::recipients() +{ + return mRecipients; +} + void SMTPSendWithDataOperation::main() { ErrorCode error; - session()->session()->sendMessage(mMessageData, this, &error); + if ((mFrom != NULL) && (mRecipients != NULL)) { + session()->session()->sendMessage(mFrom, mRecipients, mMessageData, this, &error); + } + else { + session()->session()->sendMessage(mMessageData, this, &error); + } setError(error); } diff --git a/src/async/smtp/MCSMTPSendWithDataOperation.h b/src/async/smtp/MCSMTPSendWithDataOperation.h index afa1a5e0..6c407bb3 100644 --- a/src/async/smtp/MCSMTPSendWithDataOperation.h +++ b/src/async/smtp/MCSMTPSendWithDataOperation.h @@ -23,6 +23,12 @@ namespace mailcore { SMTPSendWithDataOperation(); virtual ~SMTPSendWithDataOperation(); + virtual void setFrom(Address * from); + virtual Address * from(); + + virtual void setRecipients(Array * recipients); + virtual Array * recipients(); + virtual void setMessageData(Data * data); virtual Data * messageData(); @@ -31,6 +37,8 @@ namespace mailcore { private: Data * mMessageData; + Array * mRecipients; + Address * mFrom; }; } diff --git a/src/core/smtp/MCSMTPSession.h b/src/core/smtp/MCSMTPSession.h index 3d066a6c..1b4c9690 100644 --- a/src/core/smtp/MCSMTPSession.h +++ b/src/core/smtp/MCSMTPSession.h @@ -58,6 +58,8 @@ namespace mailcore { virtual void checkAccount(Address * from, ErrorCode * pError); virtual void sendMessage(Data * messageData, SMTPProgressCallback * callback, ErrorCode * pError); + virtual void sendMessage(Address * from, Array * /* Address */ recipients, Data * messageData, + SMTPProgressCallback * callback, ErrorCode * pError); virtual void setConnectionLogger(ConnectionLogger * logger); virtual ConnectionLogger * connectionLogger(); @@ -93,8 +95,6 @@ namespace mailcore { void loginIfNeeded(ErrorCode * pError); bool checkCertificate(); - void sendMessage(Address * from, Array * /* Address */ recipients, Data * messageData, - SMTPProgressCallback * callback, ErrorCode * pError); void sendMessage(MessageBuilder * msg, SMTPProgressCallback * callback, ErrorCode * pError); public: // private diff --git a/src/objc/smtp/MCOSMTPSession.h b/src/objc/smtp/MCOSMTPSession.h index bb7c5f57..6716ee30 100644 --- a/src/objc/smtp/MCOSMTPSession.h +++ b/src/objc/smtp/MCOSMTPSession.h @@ -92,6 +92,24 @@ */ - (MCOSMTPSendOperation *) sendOperationWithData:(NSData *)messageData; +/** + Returns an operation that will send the given message through SMTP. + It will use the sender and recipient set from the parameters. + It will also filter out Bcc from the content of the message. + + Generate RFC 822 data using MCOMessageBuilder + + MCOPOPOperation * op = [session sendOperationWithData:rfc822Data + from:[MCOAddress addressWithMailbox:@"hoa@etpan.org"] + recipients:[NSArray arrayWithObject:[MCOAddress addressWithMailbox:@"laura@etpan.org"]]]; + [op start:^(NSError * error) { + ... + }]; + */ +- (MCOSMTPSendOperation *) sendOperationWithData:(NSData *)messageData + from:(MCOAddress *)from + recipients:(NSArray *)recipients; + /** Returns an operation that will check whether the SMTP account is valid. diff --git a/src/objc/smtp/MCOSMTPSession.mm b/src/objc/smtp/MCOSMTPSession.mm index c9f9f0fc..0c24f66c 100644 --- a/src/objc/smtp/MCOSMTPSession.mm +++ b/src/objc/smtp/MCOSMTPSession.mm @@ -109,6 +109,19 @@ MCO_OBJC_SYNTHESIZE_BOOL(setUseHeloIPEnabled, useHeloIPEnabled) return result; } +- (MCOSMTPSendOperation *) sendOperationWithData:(NSData *)messageData + from:(MCOAddress *)from + recipients:(NSArray *)recipients +{ + mailcore::SMTPOperation * coreOp = + MCO_NATIVE_INSTANCE->sendMessageOperation(MCO_FROM_OBJC(Address, from), + MCO_FROM_OBJC(Array, recipients), + [messageData mco_mcData]); + MCOSMTPSendOperation * result = [[[MCOSMTPSendOperation alloc] initWithMCOperation:coreOp] autorelease]; + [result setSession:self]; + return result; +} + - (MCOOperation *) checkAccountOperationWithFrom:(MCOAddress *)from { mailcore::SMTPOperation *coreOp = MCO_NATIVE_INSTANCE->checkAccountOperation(MCO_FROM_OBJC(mailcore::Address, from)); -- cgit v1.2.3 From 513f9bd1a0b468036e1c7e10414a40d30acbdf30 Mon Sep 17 00:00:00 2001 From: "Hoa V. DINH" Date: Sun, 18 Aug 2013 00:45:42 -0700 Subject: Added support of compression. Work in progress on automatic configuration. --- src/async/imap/MCIMAPAsyncConnection.cc | 7 +- src/async/imap/MCIMAPAsyncConnection.h | 7 +- src/async/imap/MCIMAPAsyncSession.cc | 13 +- src/async/imap/MCIMAPAsyncSession.h | 9 +- src/async/imap/MCIMAPFetchFoldersOperation.cc | 4 + src/async/imap/MCIMAPFetchFoldersOperation.h | 2 +- src/async/imap/MCIMAPOperation.cc | 3 +- src/core/imap/MCIMAPSession.cc | 163 ++++++++++++++++++-------- src/core/imap/MCIMAPSession.h | 16 +-- src/objc/abstract/MCOConstants.h | 2 + src/objc/imap/MCOIMAPSession.h | 2 +- src/objc/imap/MCOIMAPSession.mm | 2 +- 12 files changed, 153 insertions(+), 77 deletions(-) diff --git a/src/async/imap/MCIMAPAsyncConnection.cc b/src/async/imap/MCIMAPAsyncConnection.cc index 5993302e..789147e2 100755 --- a/src/async/imap/MCIMAPAsyncConnection.cc +++ b/src/async/imap/MCIMAPAsyncConnection.cc @@ -86,7 +86,7 @@ IMAPAsyncConnection::IMAPAsyncConnection() mSession = new IMAPSession(); mQueue = new OperationQueue(); mDefaultNamespace = NULL; - mDelimiter = 0; + //mDelimiter = 0; mLastFolder = NULL; mQueueCallback = new IMAPOperationQueueCallback(this); mQueue->setCallback(mQueueCallback); @@ -209,6 +209,7 @@ bool IMAPAsyncConnection::isVoIPEnabled() return mSession->isVoIPEnabled(); } +#if 0 void IMAPAsyncConnection::setDelimiter(char delimiter) { mSession->setDelimiter(delimiter); @@ -219,6 +220,7 @@ char IMAPAsyncConnection::delimiter() { return mDelimiter; } +#endif void IMAPAsyncConnection::setDefaultNamespace(IMAPNamespace * ns) { @@ -644,8 +646,7 @@ IMAPMessageRenderingOperation * IMAPAsyncConnection::plainTextBodyRenderingOpera void IMAPAsyncConnection::setAutomaticConfigurationEnabled(bool enabled) { mAutomaticConfigurationEnabled = enabled; - mSession->setAutomaticCapabilitiesEnabled(enabled); - mSession->setAutomaticNamespaceEnabled(enabled); + mSession->setAutomaticConfigurationEnabled(enabled); } bool IMAPAsyncConnection::isAutomaticConfigurationEnabled() diff --git a/src/async/imap/MCIMAPAsyncConnection.h b/src/async/imap/MCIMAPAsyncConnection.h index d2cdbcaa..720bd9c6 100755 --- a/src/async/imap/MCIMAPAsyncConnection.h +++ b/src/async/imap/MCIMAPAsyncConnection.h @@ -67,12 +67,13 @@ namespace mailcore { virtual void setVoIPEnabled(bool enabled); virtual bool isVoIPEnabled(); - virtual void setDelimiter(char delimiter); - virtual char delimiter(); + //virtual void setDelimiter(char delimiter); + //virtual char delimiter(); virtual void setAutomaticConfigurationEnabled(bool enabled); virtual bool isAutomaticConfigurationEnabled(); + // Needs to be run before starting a connection. virtual void setDefaultNamespace(IMAPNamespace * ns); virtual IMAPNamespace * defaultNamespace(); @@ -135,7 +136,7 @@ namespace mailcore { private: IMAPSession * mSession; OperationQueue * mQueue; - char mDelimiter; + //char mDelimiter; IMAPNamespace * mDefaultNamespace; String * mLastFolder; IMAPOperationQueueCallback * mQueueCallback; diff --git a/src/async/imap/MCIMAPAsyncSession.cc b/src/async/imap/MCIMAPAsyncSession.cc index 48e96004..b9cb5615 100755 --- a/src/async/imap/MCIMAPAsyncSession.cc +++ b/src/async/imap/MCIMAPAsyncSession.cc @@ -12,6 +12,7 @@ #include "MCIMAPNamespace.h" #include "MCOperationQueueCallback.h" #include "MCConnectionLogger.h" +#include "MCIMAPSession.h" #define DEFAULT_MAX_CONNECTIONS 3 @@ -32,7 +33,7 @@ IMAPAsyncSession::IMAPAsyncSession() mConnectionType = ConnectionTypeClear; mCheckCertificateEnabled = true; mVoIPEnabled = true; - mDelimiter = 0; + //mDelimiter = 0; mDefaultNamespace = NULL; mTimeout = 30.; mConnectionLogger = NULL; @@ -149,7 +150,7 @@ bool IMAPAsyncSession::isVoIPEnabled() return mVoIPEnabled; } - +#if 0 void IMAPAsyncSession::setDelimiter(char delimiter) { mDelimiter = delimiter; @@ -159,6 +160,7 @@ char IMAPAsyncSession::delimiter() { return mDelimiter; } +#endif IMAPNamespace * IMAPAsyncSession::defaultNamespace() { @@ -207,11 +209,13 @@ IMAPAsyncConnection * IMAPAsyncSession::session() session->setTimeout(mTimeout); session->setCheckCertificateEnabled(mCheckCertificateEnabled); session->setVoIPEnabled(mVoIPEnabled); - session->setDelimiter(mDelimiter); + //session->setDelimiter(mDelimiter); session->setDefaultNamespace(mDefaultNamespace); +#if 0 // should be implemented properly if (mAutomaticConfigurationDone) { session->setAutomaticConfigurationEnabled(false); } +#endif return session; } @@ -501,7 +505,8 @@ IMAPMessageRenderingOperation * IMAPAsyncSession::plainTextBodyRenderingOperatio return session->plainTextBodyRenderingOperation(message, folder); } -void IMAPAsyncSession::automaticConfigurateDone() +void IMAPAsyncSession::automaticConfigurationDone(IMAPSession * session) { + setDefaultNamespace(session->defaultNamespace()); mAutomaticConfigurationDone = true; } diff --git a/src/async/imap/MCIMAPAsyncSession.h b/src/async/imap/MCIMAPAsyncSession.h index 1d0e3e23..920183f2 100755 --- a/src/async/imap/MCIMAPAsyncSession.h +++ b/src/async/imap/MCIMAPAsyncSession.h @@ -36,6 +36,7 @@ namespace mailcore { class IMAPQuotaOperation; class IMAPMessageRenderingOperation; class IMAPMessage; + class IMAPSession; class IMAPAsyncSession : public Object { public: @@ -74,8 +75,8 @@ namespace mailcore { virtual void setVoIPEnabled(bool enabled); virtual bool isVoIPEnabled(); - virtual void setDelimiter(char delimiter); - virtual char delimiter(); + //virtual void setDelimiter(char delimiter); + //virtual char delimiter(); virtual void setDefaultNamespace(IMAPNamespace * ns); virtual IMAPNamespace * defaultNamespace(); @@ -142,7 +143,7 @@ namespace mailcore { virtual IMAPMessageRenderingOperation * plainTextBodyRenderingOperation(IMAPMessage * message, String * folder); public: // private - virtual void automaticConfigurateDone(); + virtual void automaticConfigurationDone(IMAPSession * session); private: Array * mSessions; @@ -156,7 +157,7 @@ namespace mailcore { ConnectionType mConnectionType; bool mCheckCertificateEnabled; bool mVoIPEnabled; - char mDelimiter; + //char mDelimiter; IMAPNamespace * mDefaultNamespace; time_t mTimeout; bool mAllowsFolderConcurrentAccessEnabled; diff --git a/src/async/imap/MCIMAPFetchFoldersOperation.cc b/src/async/imap/MCIMAPFetchFoldersOperation.cc index 41a95572..637c981c 100644 --- a/src/async/imap/MCIMAPFetchFoldersOperation.cc +++ b/src/async/imap/MCIMAPFetchFoldersOperation.cc @@ -53,14 +53,18 @@ void IMAPFetchFoldersOperation::main() MC_SAFE_RETAIN(mFolders); setError(error); +#if 0 char * delimiterData = (char *) malloc(1); * delimiterData = session()->session()->delimiter(); performMethodOnMainThread((Object::Method) &IMAPFetchFoldersOperation::setDelimiterDataOnMainThread, delimiterData, true); +#endif } +#if 0 void IMAPFetchFoldersOperation::setDelimiterDataOnMainThread(char * delimiterData) { session()->setDelimiter(* delimiterData); free(delimiterData); } +#endif diff --git a/src/async/imap/MCIMAPFetchFoldersOperation.h b/src/async/imap/MCIMAPFetchFoldersOperation.h index c59bf85a..2dd01831 100644 --- a/src/async/imap/MCIMAPFetchFoldersOperation.h +++ b/src/async/imap/MCIMAPFetchFoldersOperation.h @@ -35,7 +35,7 @@ namespace mailcore { String * /* IMAPFolder */ mFolder; bool mFetchSubscribedEnabled; Array * mFolders; - void setDelimiterDataOnMainThread(char * delimiterData); + //void setDelimiterDataOnMainThread(char * delimiterData); }; } diff --git a/src/async/imap/MCIMAPOperation.cc b/src/async/imap/MCIMAPOperation.cc index 2ceb2b55..1211a73b 100644 --- a/src/async/imap/MCIMAPOperation.cc +++ b/src/async/imap/MCIMAPOperation.cc @@ -142,6 +142,7 @@ void IMAPOperation::beforeMain() void IMAPOperation::afterMain() { if (mSession->session()->isAutomaticConfigurationDone()) { - mSession->owner()->automaticConfigurateDone(); + mSession->owner()->automaticConfigurationDone(mSession->session()); + mSession->session()->resetAutomaticConfigurationDone(); } } diff --git a/src/core/imap/MCIMAPSession.cc b/src/core/imap/MCIMAPSession.cc index bc82a212..4384bf28 100755 --- a/src/core/imap/MCIMAPSession.cc +++ b/src/core/imap/MCIMAPSession.cc @@ -336,6 +336,7 @@ void IMAPSession::init() mCondstoreEnabled = false; mIdentityEnabled = false; mNamespaceEnabled = false; + mCompressionEnabled = false; mWelcomeString = NULL; mNeedsMboxMailWorkaround = false; mDefaultNamespace = NULL; @@ -354,8 +355,7 @@ void IMAPSession::init() mProgressCallback = NULL; mProgressItemsCount = 0; mConnectionLogger = NULL; - mAutomaticCapabilitiesEnabled = true; - mAutomaticNamespaceEnabled = true; + mAutomaticConfigurationEnabled = true; mAutomaticConfigurationDone = false; } @@ -642,7 +642,7 @@ void IMAPSession::connect(ErrorCode * pError) mState = STATE_CONNECTED; - if (isAutomaticCapabilitiesEnabled()) { + if (isAutomaticConfigurationEnabled()) { if ((mImap->imap_connection_info != NULL) && (mImap->imap_connection_info->imap_capability != NULL)) { // Don't keep result. It will be kept in session state. capabilitySetWithSessionState(IndexSet::indexSet()); @@ -838,7 +838,7 @@ void IMAPSession::login(ErrorCode * pError) mState = STATE_LOGGEDIN; - if (isAutomaticCapabilitiesEnabled()) { + if (isAutomaticConfigurationEnabled()) { if ((mImap->imap_connection_info != NULL) && (mImap->imap_connection_info->imap_capability != NULL)) { // Don't keep result. It will be kept in session state. capabilitySetWithSessionState(IndexSet::indexSet()); @@ -850,15 +850,13 @@ void IMAPSession::login(ErrorCode * pError) return; } } - - enableFeatures(); } else { - // TODO: capabilities should be shared for non automatic capabilities sessions. - enableFeatures(); + // TODO: capabilities should be shared with other sessions for non automatic capabilities sessions. } - - if (isAutomaticNamespaceEnabled()) { + enableFeatures(); + + if (isAutomaticConfigurationEnabled()) { if (isNamespaceEnabled()) { HashMap * result = fetchNamespace(pError); if (* pError != ErrorNone) { @@ -896,8 +894,7 @@ void IMAPSession::login(ErrorCode * pError) } } else { - // TODO: namespace should be shared for non automatic namespace. - // setDefaultNamespace() + // TODO: namespace should be shared with other sessions for non automatic namespace. } mAutomaticConfigurationDone = true; @@ -1252,18 +1249,21 @@ Array * /* IMAPFolder */ IMAPSession::fetchSubscribedFolders(ErrorCode * pError) { int r; clist * imap_folders; - char delimiter; MCLog("fetch subscribed"); loginIfNeeded(pError); if (* pError != ErrorNone) return NULL; - delimiter = fetchDelimiterIfNeeded(mDelimiter, pError); - if (* pError != ErrorNone) - return NULL; - - setDelimiter(delimiter); + if (mDelimiter == 0) { + char delimiter; + + delimiter = fetchDelimiterIfNeeded(mDelimiter, pError); + if (* pError != ErrorNone) + return NULL; + + setDelimiter(delimiter); + } String * prefix; prefix = defaultNamespace()->mainPrefix(); @@ -1271,8 +1271,8 @@ Array * /* IMAPFolder */ IMAPSession::fetchSubscribedFolders(ErrorCode * pError) prefix = MCSTR(""); } if (prefix->length() > 0) { - if (!prefix->hasSuffix(String::stringWithUTF8Format("%c", delimiter))) { - prefix = prefix->stringByAppendingUTF8Format("%c", delimiter); + if (!prefix->hasSuffix(String::stringWithUTF8Format("%c", mDelimiter))) { + prefix = prefix->stringByAppendingUTF8Format("%c", mDelimiter); } } @@ -1285,17 +1285,20 @@ Array * /* IMAPFolder */ IMAPSession::fetchAllFolders(ErrorCode * pError) { int r; clist * imap_folders; - char delimiter; loginIfNeeded(pError); if (* pError != ErrorNone) return NULL; - delimiter = fetchDelimiterIfNeeded(mDelimiter, pError); - if (* pError != ErrorNone) - return NULL; - - setDelimiter(delimiter); + if (mDelimiter == 0) { + char delimiter; + + delimiter = fetchDelimiterIfNeeded(mDelimiter, pError); + if (* pError != ErrorNone) + return NULL; + + setDelimiter(delimiter); + } String * prefix = NULL; if (defaultNamespace()) { @@ -1305,8 +1308,8 @@ Array * /* IMAPFolder */ IMAPSession::fetchAllFolders(ErrorCode * pError) prefix = MCSTR(""); } if (prefix->length() > 0) { - if (!prefix->hasSuffix(String::stringWithUTF8Format("%c", delimiter))) { - prefix = prefix->stringByAppendingUTF8Format("%c", delimiter); + if (!prefix->hasSuffix(String::stringWithUTF8Format("%c", mDelimiter))) { + prefix = prefix->stringByAppendingUTF8Format("%c", mDelimiter); } } @@ -3139,37 +3142,65 @@ void IMAPSession::capabilitySetWithSessionState(IndexSet * capabilities) { if (mailimap_has_id(mImap)) { capabilities->addIndex(IMAPCapabilityId); - mIdentityEnabled = true; } if (mailimap_has_xlist(mImap)) { capabilities->addIndex(IMAPCapabilityXList); - mXListEnabled = true; } if (mailimap_has_extension(mImap, (char *) "X-GM-EXT-1")) { // Disable use of XLIST if this is the Gmail IMAP server because it implements // RFC 6154. - mXListEnabled = false; + capabilities->addIndex(IMAPCapabilityGmail); } if (mailimap_has_idle(mImap)) { capabilities->addIndex(IMAPCapabilityIdle); - mIdleEnabled = true; } if (mailimap_has_condstore(mImap)) { capabilities->addIndex(IMAPCapabilityCondstore); - mCondstoreEnabled = true; } if (mailimap_has_qresync(mImap)) { - result->addIndex(IMAPCapabilityQResync); - mQResyncEnabled = true; + capabilities->addIndex(IMAPCapabilityQResync); } if (mailimap_has_xoauth2(mImap)) { capabilities->addIndex(IMAPCapabilityXOAuth2); - mXOauth2Enabled = true; } if (mailimap_has_namespace(mImap)) { capabilities->addIndex(IMAPCapabilityNamespace); + } + if (mailimap_has_compress_deflate(mImap)) { + capabilities->addIndex(IMAPCapabilityCompressDeflate); + } + applyCapabilities(capabilities); +} + +void IMAPSession::applyCapabilities(IndexSet * capabilities) +{ + if (capabilities->containsIndex(IMAPCapabilityId)) { + mIdentityEnabled = true; + } + if (capabilities->containsIndex(IMAPCapabilityXList)) { + mXListEnabled = true; + } + if (capabilities->containsIndex(IMAPCapabilityGmail)) { + mXListEnabled = false; + } + if (capabilities->containsIndex(IMAPCapabilityIdle)) { + mIdleEnabled = true; + } + if (capabilities->containsIndex(IMAPCapabilityCondstore)) { + mCondstoreEnabled = true; + } + if (capabilities->containsIndex(IMAPCapabilityQResync)) { + mQResyncEnabled = true; + } + if (capabilities->containsIndex(IMAPCapabilityXOAuth2)) { + mXOauth2Enabled = true; + } + if (capabilities->containsIndex(IMAPCapabilityNamespace)) { mNamespaceEnabled = true; } + if (capabilities->containsIndex(IMAPCapabilityCompressDeflate)) { + mCompressionEnabled = true; + } } bool IMAPSession::isIdleEnabled() @@ -3207,6 +3238,11 @@ bool IMAPSession::isNamespaceEnabled() return mNamespaceEnabled; } +bool IMAPSession::isCompressionEnabled() +{ + return mCompressionEnabled; +} + bool IMAPSession::isDisconnected() { return mState == STATE_DISCONNECTED; @@ -3295,24 +3331,14 @@ String * IMAPSession::plainTextBodyRendering(IMAPMessage * message, String * fol return plainTextBodyString; } -void IMAPSession::setAutomaticCapabilitiesEnabled(bool enabled) +void IMAPSession::setAutomaticConfigurationEnabled(bool enabled) { - mAutomaticCapabilitiesEnabled = enabled; + mAutomaticConfigurationEnabled = enabled; } -bool IMAPSession::isAutomaticCapabilitiesEnabled() +bool IMAPSession::isAutomaticConfigurationEnabled() { - return mAutomaticCapabilitiesEnabled; -} - -void IMAPSession::setAutomaticNamespaceEnabled(bool enabled) -{ - mAutomaticNamespaceEnabled = enabled; -} - -bool IMAPSession::isAutomaticNamespaceEnabled() -{ - return mAutomaticNamespaceEnabled; + return mAutomaticConfigurationEnabled; } bool IMAPSession::enableFeature(String * feature) @@ -3339,12 +3365,41 @@ bool IMAPSession::enableFeature(String * feature) void IMAPSession::enableFeatures() { + if (isCompressionEnabled()) { + ErrorCode error; + enableCompression(&error); + if (error != ErrorNone) { + MCLog("could not enable compression"); + } + } + if (isQResyncEnabled()) { - IMAPSession::enableFeature(MCSTR("QRESYNC")); + enableFeature(MCSTR("QRESYNC")); } else if (isCondstoreEnabled()) { - IMAPSession::enableFeature(MCSTR("CONDSTORE")); + enableFeature(MCSTR("CONDSTORE")); + } +} + +void IMAPSession::enableCompression(ErrorCode * pError) +{ + int r; + r = mailimap_compress(mImap); + if (r == MAILIMAP_ERROR_STREAM) { + * pError = ErrorConnection; + return; } + else if (r == MAILIMAP_ERROR_PARSE) { + * pError = ErrorParse; + return; + } + else if (hasError(r)) { + * pError = ErrorCompression; + return; + } + + this->mCompressionEnabled = true; + * pError = ErrorNone; } bool IMAPSession::isAutomaticConfigurationDone() @@ -3352,3 +3407,7 @@ bool IMAPSession::isAutomaticConfigurationDone() return mAutomaticConfigurationDone; } +void IMAPSession::resetAutomaticConfigurationDone() +{ + mAutomaticConfigurationDone = false; +} diff --git a/src/core/imap/MCIMAPSession.h b/src/core/imap/MCIMAPSession.h index 90e145fd..19418323 100755 --- a/src/core/imap/MCIMAPSession.h +++ b/src/core/imap/MCIMAPSession.h @@ -144,6 +144,8 @@ namespace mailcore { virtual IndexSet * capability(ErrorCode * pError); + virtual void enableCompression(ErrorCode * pError); + virtual uint32_t uidValidity(); virtual uint32_t uidNext(); virtual uint64_t modSequenceValue(); @@ -157,6 +159,7 @@ namespace mailcore { virtual bool isIdentityEnabled(); virtual bool isXOAuthEnabled(); virtual bool isNamespaceEnabled(); + virtual bool isCompressionEnabled(); virtual void setConnectionLogger(ConnectionLogger * logger); virtual ConnectionLogger * connectionLogger(); @@ -175,19 +178,18 @@ namespace mailcore { virtual String * plainTextBodyRendering(IMAPMessage * message, String * folder, ErrorCode * pError); /** Enable automatic query of the capabilities of the IMAP server when set to true. */ - virtual void setAutomaticCapabilitiesEnabled(bool enabled); + virtual void setAutomaticConfigurationEnabled(bool enabled); /** Check if the automatic query of the capabilities of the IMAP server is enabled. */ - virtual bool isAutomaticCapabilitiesEnabled(); - - virtual void setAutomaticNamespaceEnabled(bool enabled); - virtual bool isAutomaticNamespaceEnabled(); + virtual bool isAutomaticConfigurationEnabled(); public: // private virtual void loginIfNeeded(ErrorCode * pError); virtual void connectIfNeeded(ErrorCode * pError); virtual bool isDisconnected(); virtual bool isAutomaticConfigurationDone(); + virtual void resetAutomaticConfigurationDone(); + virtual void applyCapabilities(IndexSet * capabilities); private: String * mHostname; @@ -211,6 +213,7 @@ namespace mailcore { bool mIdentityEnabled; bool mXOauth2Enabled; bool mNamespaceEnabled; + bool mCompressionEnabled; String * mWelcomeString; bool mNeedsMboxMailWorkaround; uint32_t mUIDValidity; @@ -228,8 +231,7 @@ namespace mailcore { IMAPProgressCallback * mProgressCallback; unsigned int mProgressItemsCount; ConnectionLogger * mConnectionLogger; - bool mAutomaticCapabilitiesEnabled; - bool mAutomaticNamespaceEnabled; + bool mAutomaticConfigurationEnabled; bool mAutomaticConfigurationDone; void init(); diff --git a/src/objc/abstract/MCOConstants.h b/src/objc/abstract/MCOConstants.h index 427e787a..0bdf9af6 100644 --- a/src/objc/abstract/MCOConstants.h +++ b/src/objc/abstract/MCOConstants.h @@ -328,6 +328,8 @@ typedef enum { MCOErrorDeleteMessage, /** SMTP: Error while checking account.*/ MCOErrorInvalidAccount, + /** IMAP: Error when trying to enable compression.*/ + MCOErrorCompression, /** The count of all errors */ MCOErrorCodeCount, } MCOErrorCode; diff --git a/src/objc/imap/MCOIMAPSession.h b/src/objc/imap/MCOIMAPSession.h index ea920114..fa22c913 100755 --- a/src/objc/imap/MCOIMAPSession.h +++ b/src/objc/imap/MCOIMAPSession.h @@ -80,7 +80,7 @@ @property (nonatomic, assign, getter=isVoIPEnabled) BOOL voIPEnabled; /** The default delimiter for the folder paths */ -@property (nonatomic, assign) char delimiter; +//@property (nonatomic, assign) char delimiter; /** The default namespace. */ @property (nonatomic, strong) MCOIMAPNamespace * defaultNamespace; diff --git a/src/objc/imap/MCOIMAPSession.mm b/src/objc/imap/MCOIMAPSession.mm index a9bbeb5c..4c1542f3 100755 --- a/src/objc/imap/MCOIMAPSession.mm +++ b/src/objc/imap/MCOIMAPSession.mm @@ -86,7 +86,7 @@ MCO_OBJC_SYNTHESIZE_SCALAR(MCOConnectionType, mailcore::ConnectionType, setConne MCO_OBJC_SYNTHESIZE_SCALAR(NSTimeInterval, time_t, setTimeout, timeout) MCO_OBJC_SYNTHESIZE_BOOL(setCheckCertificateEnabled, isCheckCertificateEnabled) MCO_OBJC_SYNTHESIZE_BOOL(setVoIPEnabled, isVoIPEnabled) -MCO_OBJC_SYNTHESIZE_SCALAR(char, char, setDelimiter, delimiter) +//MCO_OBJC_SYNTHESIZE_SCALAR(char, char, setDelimiter, delimiter) MCO_OBJC_SYNTHESIZE_SCALAR(BOOL, BOOL, setAllowsFolderConcurrentAccessEnabled, allowsFolderConcurrentAccessEnabled) MCO_OBJC_SYNTHESIZE_SCALAR(unsigned int, unsigned int, setMaximumConnections, maximumConnections) -- cgit v1.2.3 From 381019b71729db9c398e6e5a0ce4d1190048eed6 Mon Sep 17 00:00:00 2001 From: "Hoa V. DINH" Date: Sun, 18 Aug 2013 00:47:06 -0700 Subject: Updated to libetpan - 2e016471cea776add8995124b0c58fa31a1c05dd --- scripts/prepare-libetpan-ios.sh | 2 +- scripts/prepare-libetpan-macos.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/prepare-libetpan-ios.sh b/scripts/prepare-libetpan-ios.sh index f9757286..4bb18ab0 100755 --- a/scripts/prepare-libetpan-ios.sh +++ b/scripts/prepare-libetpan-ios.sh @@ -2,7 +2,7 @@ sdkversion=6.1 url="https://github.com/dinhviethoa/libetpan.git" -rev=5ee776caa2b005a13ff604bb35539832b2ad1a52 +rev=2e016471cea776add8995124b0c58fa31a1c05dd pushd `dirname $0` > /dev/null scriptpath=`pwd` diff --git a/scripts/prepare-libetpan-macos.sh b/scripts/prepare-libetpan-macos.sh index 31a40c40..925bfc08 100755 --- a/scripts/prepare-libetpan-macos.sh +++ b/scripts/prepare-libetpan-macos.sh @@ -1,7 +1,7 @@ #!/bin/sh url="https://github.com/dinhviethoa/libetpan.git" -rev=5ee776caa2b005a13ff604bb35539832b2ad1a52 +rev=2e016471cea776add8995124b0c58fa31a1c05dd pushd `dirname $0` > /dev/null scriptpath=`pwd` -- cgit v1.2.3 From c378363b5afc43b98d62acb1a3d8186a907da915 Mon Sep 17 00:00:00 2001 From: "Hoa V. DINH" Date: Sun, 18 Aug 2013 20:21:00 -0700 Subject: IMAPMessage destructor is made virtual --- src/core/imap/MCIMAPMessage.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/imap/MCIMAPMessage.h b/src/core/imap/MCIMAPMessage.h index 2f72cd7b..435334c7 100644 --- a/src/core/imap/MCIMAPMessage.h +++ b/src/core/imap/MCIMAPMessage.h @@ -18,7 +18,7 @@ namespace mailcore { class IMAPMessage : public AbstractMessage { public: IMAPMessage(); - ~IMAPMessage(); + virtual ~IMAPMessage(); virtual uint32_t uid(); virtual void setUid(uint32_t uid); -- cgit v1.2.3 From 807b39da9aa62365f6a7494b7666c844a781f2c7 Mon Sep 17 00:00:00 2001 From: "Hoa V. DINH" Date: Sun, 18 Aug 2013 22:28:32 -0700 Subject: Removed public method setDelimiter --- src/core/abstract/MCMessageConstants.h | 1 + src/core/imap/MCIMAPSession.cc | 8 ++++++-- src/core/imap/MCIMAPSession.h | 4 ++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/core/abstract/MCMessageConstants.h b/src/core/abstract/MCMessageConstants.h index 097ced04..30ce0efc 100644 --- a/src/core/abstract/MCMessageConstants.h +++ b/src/core/abstract/MCMessageConstants.h @@ -208,6 +208,7 @@ namespace mailcore { ErrorDeleteMessage, ErrorInvalidAccount, ErrorFile, + ErrorCompression, }; enum PartType { diff --git a/src/core/imap/MCIMAPSession.cc b/src/core/imap/MCIMAPSession.cc index 05330573..86a35b2a 100755 --- a/src/core/imap/MCIMAPSession.cc +++ b/src/core/imap/MCIMAPSession.cc @@ -477,6 +477,7 @@ bool IMAPSession::isVoIPEnabled() return mVoIPEnabled; } +#if 0 void IMAPSession::setDelimiter(char delimiter) { mDelimiter = delimiter; @@ -486,6 +487,7 @@ char IMAPSession::delimiter() { return mDelimiter; } +#endif static bool hasError(int errorCode) { @@ -1264,7 +1266,8 @@ Array * /* IMAPFolder */ IMAPSession::fetchSubscribedFolders(ErrorCode * pError) if (* pError != ErrorNone) return NULL; - setDelimiter(delimiter); + //setDelimiter(delimiter); + mDelimiter = delimiter; } String * prefix; @@ -1299,7 +1302,8 @@ Array * /* IMAPFolder */ IMAPSession::fetchAllFolders(ErrorCode * pError) if (* pError != ErrorNone) return NULL; - setDelimiter(delimiter); + //setDelimiter(delimiter); + mDelimiter = delimiter; } String * prefix = NULL; diff --git a/src/core/imap/MCIMAPSession.h b/src/core/imap/MCIMAPSession.h index dceab02b..13222cd4 100755 --- a/src/core/imap/MCIMAPSession.h +++ b/src/core/imap/MCIMAPSession.h @@ -59,8 +59,8 @@ namespace mailcore { virtual bool isVoIPEnabled(); // Needed for fetchSubscribedFolders() and fetchAllFolders(). - virtual void setDelimiter(char delimiter); - virtual char delimiter(); + //virtual void setDelimiter(char delimiter); + //virtual char delimiter(); // Needed for fetchSubscribedFolders() and fetchAllFolders(). virtual void setDefaultNamespace(IMAPNamespace * ns); -- cgit v1.2.3 From d86e4a126eb37d62557f35ca7bd13d5e16ece648 Mon Sep 17 00:00:00 2001 From: "Hoa V. DINH" Date: Sun, 18 Aug 2013 22:43:48 -0700 Subject: Clean up --- src/async/imap/MCIMAPAsyncConnection.cc | 14 -------------- src/async/imap/MCIMAPAsyncConnection.h | 4 ---- src/async/imap/MCIMAPAsyncSession.cc | 14 -------------- src/async/imap/MCIMAPAsyncSession.h | 4 ---- src/async/imap/MCIMAPFetchFoldersOperation.cc | 15 --------------- src/async/imap/MCIMAPFetchFoldersOperation.h | 1 - src/core/imap/MCIMAPSession.cc | 12 ------------ src/core/imap/MCIMAPSession.h | 4 ---- src/objc/imap/MCOIMAPSession.h | 3 --- src/objc/imap/MCOIMAPSession.mm | 1 - 10 files changed, 72 deletions(-) diff --git a/src/async/imap/MCIMAPAsyncConnection.cc b/src/async/imap/MCIMAPAsyncConnection.cc index 789147e2..a5e46a58 100755 --- a/src/async/imap/MCIMAPAsyncConnection.cc +++ b/src/async/imap/MCIMAPAsyncConnection.cc @@ -86,7 +86,6 @@ IMAPAsyncConnection::IMAPAsyncConnection() mSession = new IMAPSession(); mQueue = new OperationQueue(); mDefaultNamespace = NULL; - //mDelimiter = 0; mLastFolder = NULL; mQueueCallback = new IMAPOperationQueueCallback(this); mQueue->setCallback(mQueueCallback); @@ -209,19 +208,6 @@ bool IMAPAsyncConnection::isVoIPEnabled() return mSession->isVoIPEnabled(); } -#if 0 -void IMAPAsyncConnection::setDelimiter(char delimiter) -{ - mSession->setDelimiter(delimiter); - mDelimiter = delimiter; -} - -char IMAPAsyncConnection::delimiter() -{ - return mDelimiter; -} -#endif - void IMAPAsyncConnection::setDefaultNamespace(IMAPNamespace * ns) { mSession->setDefaultNamespace(ns); diff --git a/src/async/imap/MCIMAPAsyncConnection.h b/src/async/imap/MCIMAPAsyncConnection.h index 720bd9c6..e7ceb283 100755 --- a/src/async/imap/MCIMAPAsyncConnection.h +++ b/src/async/imap/MCIMAPAsyncConnection.h @@ -67,9 +67,6 @@ namespace mailcore { virtual void setVoIPEnabled(bool enabled); virtual bool isVoIPEnabled(); - //virtual void setDelimiter(char delimiter); - //virtual char delimiter(); - virtual void setAutomaticConfigurationEnabled(bool enabled); virtual bool isAutomaticConfigurationEnabled(); @@ -136,7 +133,6 @@ namespace mailcore { private: IMAPSession * mSession; OperationQueue * mQueue; - //char mDelimiter; IMAPNamespace * mDefaultNamespace; String * mLastFolder; IMAPOperationQueueCallback * mQueueCallback; diff --git a/src/async/imap/MCIMAPAsyncSession.cc b/src/async/imap/MCIMAPAsyncSession.cc index b9cb5615..50c7dcde 100755 --- a/src/async/imap/MCIMAPAsyncSession.cc +++ b/src/async/imap/MCIMAPAsyncSession.cc @@ -33,7 +33,6 @@ IMAPAsyncSession::IMAPAsyncSession() mConnectionType = ConnectionTypeClear; mCheckCertificateEnabled = true; mVoIPEnabled = true; - //mDelimiter = 0; mDefaultNamespace = NULL; mTimeout = 30.; mConnectionLogger = NULL; @@ -150,18 +149,6 @@ bool IMAPAsyncSession::isVoIPEnabled() return mVoIPEnabled; } -#if 0 -void IMAPAsyncSession::setDelimiter(char delimiter) -{ - mDelimiter = delimiter; -} - -char IMAPAsyncSession::delimiter() -{ - return mDelimiter; -} -#endif - IMAPNamespace * IMAPAsyncSession::defaultNamespace() { return mDefaultNamespace; @@ -209,7 +196,6 @@ IMAPAsyncConnection * IMAPAsyncSession::session() session->setTimeout(mTimeout); session->setCheckCertificateEnabled(mCheckCertificateEnabled); session->setVoIPEnabled(mVoIPEnabled); - //session->setDelimiter(mDelimiter); session->setDefaultNamespace(mDefaultNamespace); #if 0 // should be implemented properly if (mAutomaticConfigurationDone) { diff --git a/src/async/imap/MCIMAPAsyncSession.h b/src/async/imap/MCIMAPAsyncSession.h index 920183f2..4360cdef 100755 --- a/src/async/imap/MCIMAPAsyncSession.h +++ b/src/async/imap/MCIMAPAsyncSession.h @@ -75,9 +75,6 @@ namespace mailcore { virtual void setVoIPEnabled(bool enabled); virtual bool isVoIPEnabled(); - //virtual void setDelimiter(char delimiter); - //virtual char delimiter(); - virtual void setDefaultNamespace(IMAPNamespace * ns); virtual IMAPNamespace * defaultNamespace(); @@ -157,7 +154,6 @@ namespace mailcore { ConnectionType mConnectionType; bool mCheckCertificateEnabled; bool mVoIPEnabled; - //char mDelimiter; IMAPNamespace * mDefaultNamespace; time_t mTimeout; bool mAllowsFolderConcurrentAccessEnabled; diff --git a/src/async/imap/MCIMAPFetchFoldersOperation.cc b/src/async/imap/MCIMAPFetchFoldersOperation.cc index 637c981c..e1f121e8 100644 --- a/src/async/imap/MCIMAPFetchFoldersOperation.cc +++ b/src/async/imap/MCIMAPFetchFoldersOperation.cc @@ -52,19 +52,4 @@ void IMAPFetchFoldersOperation::main() } MC_SAFE_RETAIN(mFolders); setError(error); - -#if 0 - char * delimiterData = (char *) malloc(1); - * delimiterData = session()->session()->delimiter(); - performMethodOnMainThread((Object::Method) &IMAPFetchFoldersOperation::setDelimiterDataOnMainThread, - delimiterData, true); -#endif } - -#if 0 -void IMAPFetchFoldersOperation::setDelimiterDataOnMainThread(char * delimiterData) -{ - session()->setDelimiter(* delimiterData); - free(delimiterData); -} -#endif diff --git a/src/async/imap/MCIMAPFetchFoldersOperation.h b/src/async/imap/MCIMAPFetchFoldersOperation.h index 2dd01831..057df493 100644 --- a/src/async/imap/MCIMAPFetchFoldersOperation.h +++ b/src/async/imap/MCIMAPFetchFoldersOperation.h @@ -35,7 +35,6 @@ namespace mailcore { String * /* IMAPFolder */ mFolder; bool mFetchSubscribedEnabled; Array * mFolders; - //void setDelimiterDataOnMainThread(char * delimiterData); }; } diff --git a/src/core/imap/MCIMAPSession.cc b/src/core/imap/MCIMAPSession.cc index 86a35b2a..3c64909f 100755 --- a/src/core/imap/MCIMAPSession.cc +++ b/src/core/imap/MCIMAPSession.cc @@ -477,18 +477,6 @@ bool IMAPSession::isVoIPEnabled() return mVoIPEnabled; } -#if 0 -void IMAPSession::setDelimiter(char delimiter) -{ - mDelimiter = delimiter; -} - -char IMAPSession::delimiter() -{ - return mDelimiter; -} -#endif - static bool hasError(int errorCode) { return ((errorCode != MAILIMAP_NO_ERROR) && (errorCode != MAILIMAP_NO_ERROR_AUTHENTICATED) && diff --git a/src/core/imap/MCIMAPSession.h b/src/core/imap/MCIMAPSession.h index 13222cd4..b2c7e25d 100755 --- a/src/core/imap/MCIMAPSession.h +++ b/src/core/imap/MCIMAPSession.h @@ -58,10 +58,6 @@ namespace mailcore { virtual void setVoIPEnabled(bool enabled); virtual bool isVoIPEnabled(); - // Needed for fetchSubscribedFolders() and fetchAllFolders(). - //virtual void setDelimiter(char delimiter); - //virtual char delimiter(); - // Needed for fetchSubscribedFolders() and fetchAllFolders(). virtual void setDefaultNamespace(IMAPNamespace * ns); virtual IMAPNamespace * defaultNamespace(); diff --git a/src/objc/imap/MCOIMAPSession.h b/src/objc/imap/MCOIMAPSession.h index fa22c913..e92a0636 100755 --- a/src/objc/imap/MCOIMAPSession.h +++ b/src/objc/imap/MCOIMAPSession.h @@ -79,9 +79,6 @@ /** When set to YES, VoIP capability will be enabled on the IMAP connection on iOS */ @property (nonatomic, assign, getter=isVoIPEnabled) BOOL voIPEnabled; -/** The default delimiter for the folder paths */ -//@property (nonatomic, assign) char delimiter; - /** The default namespace. */ @property (nonatomic, strong) MCOIMAPNamespace * defaultNamespace; diff --git a/src/objc/imap/MCOIMAPSession.mm b/src/objc/imap/MCOIMAPSession.mm index 4c1542f3..b3584f4d 100755 --- a/src/objc/imap/MCOIMAPSession.mm +++ b/src/objc/imap/MCOIMAPSession.mm @@ -86,7 +86,6 @@ MCO_OBJC_SYNTHESIZE_SCALAR(MCOConnectionType, mailcore::ConnectionType, setConne MCO_OBJC_SYNTHESIZE_SCALAR(NSTimeInterval, time_t, setTimeout, timeout) MCO_OBJC_SYNTHESIZE_BOOL(setCheckCertificateEnabled, isCheckCertificateEnabled) MCO_OBJC_SYNTHESIZE_BOOL(setVoIPEnabled, isVoIPEnabled) -//MCO_OBJC_SYNTHESIZE_SCALAR(char, char, setDelimiter, delimiter) MCO_OBJC_SYNTHESIZE_SCALAR(BOOL, BOOL, setAllowsFolderConcurrentAccessEnabled, allowsFolderConcurrentAccessEnabled) MCO_OBJC_SYNTHESIZE_SCALAR(unsigned int, unsigned int, setMaximumConnections, maximumConnections) -- cgit v1.2.3 From f508d351c0a5066a60386a17dc228e0c192ba4b3 Mon Sep 17 00:00:00 2001 From: "Hoa V. Dinh" Date: Mon, 19 Aug 2013 08:30:34 -0700 Subject: Disable compression --- src/core/imap/MCIMAPSession.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/core/imap/MCIMAPSession.cc b/src/core/imap/MCIMAPSession.cc index 3c64909f..32402231 100755 --- a/src/core/imap/MCIMAPSession.cc +++ b/src/core/imap/MCIMAPSession.cc @@ -3197,7 +3197,7 @@ void IMAPSession::applyCapabilities(IndexSet * capabilities) mNamespaceEnabled = true; } if (capabilities->containsIndex(IMAPCapabilityCompressDeflate)) { - mCompressionEnabled = true; + //mCompressionEnabled = true; } } @@ -3396,7 +3396,6 @@ void IMAPSession::enableCompression(ErrorCode * pError) return; } - this->mCompressionEnabled = true; * pError = ErrorNone; } -- cgit v1.2.3 From bf91399a0db6ddb856c556f2c8e7a52f726e66c5 Mon Sep 17 00:00:00 2001 From: "Hoa V. Dinh" Date: Tue, 20 Aug 2013 12:07:19 -0700 Subject: Build all architectures on iOS --- build-mac/mailcore2.xcodeproj/project.pbxproj | 4 ++++ example/ios/iOS UI Test/iOS UI Test.xcodeproj/project.pbxproj | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/build-mac/mailcore2.xcodeproj/project.pbxproj b/build-mac/mailcore2.xcodeproj/project.pbxproj index ef7dab58..620683bb 100755 --- a/build-mac/mailcore2.xcodeproj/project.pbxproj +++ b/build-mac/mailcore2.xcodeproj/project.pbxproj @@ -2994,6 +2994,7 @@ ); INFOPLIST_FILE = "../tests-ios/tests-ios-Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 6.1; + ONLY_ACTIVE_ARCH = NO; OTHER_LDFLAGS = ( "-lctemplate-ios", "-letpan-ios", @@ -3029,6 +3030,7 @@ ); INFOPLIST_FILE = "../tests-ios/tests-ios-Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 6.1; + ONLY_ACTIVE_ARCH = NO; OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; OTHER_LDFLAGS = ( "-lctemplate-ios", @@ -3059,6 +3061,7 @@ CLANG_CXX_LIBRARY = "libstdc++"; DEAD_CODE_STRIPPING = NO; EXECUTABLE_PREFIX = lib; + ONLY_ACTIVE_ARCH = NO; PRODUCT_NAME = "MailCore-ios"; SDKROOT = iphoneos; SKIP_INSTALL = YES; @@ -3075,6 +3078,7 @@ CLANG_CXX_LIBRARY = "libstdc++"; DEAD_CODE_STRIPPING = NO; EXECUTABLE_PREFIX = lib; + ONLY_ACTIVE_ARCH = NO; PRODUCT_NAME = "MailCore-ios"; SDKROOT = iphoneos; SKIP_INSTALL = YES; diff --git a/example/ios/iOS UI Test/iOS UI Test.xcodeproj/project.pbxproj b/example/ios/iOS UI Test/iOS UI Test.xcodeproj/project.pbxproj index 5b53cf3b..e8555f85 100644 --- a/example/ios/iOS UI Test/iOS UI Test.xcodeproj/project.pbxproj +++ b/example/ios/iOS UI Test/iOS UI Test.xcodeproj/project.pbxproj @@ -493,7 +493,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 6.1; - ONLY_ACTIVE_ARCH = YES; + ONLY_ACTIVE_ARCH = NO; SDKROOT = iphoneos; }; name = Debug; @@ -517,6 +517,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 6.1; + ONLY_ACTIVE_ARCH = NO; OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; SDKROOT = iphoneos; VALIDATE_PRODUCT = YES; -- cgit v1.2.3 From ee150fc3e1379d4af5e8d5297837cd9b206444da Mon Sep 17 00:00:00 2001 From: "Hoa V. DINH" Date: Wed, 21 Aug 2013 00:32:34 -0700 Subject: Updated to libetpan 75a2e16a23c73ab0cdabb8e5b69b941ded0632f0. Fixed build with Xcode 5. --- scripts/build-mailcore2-ios.sh | 9 ++++++++- scripts/prepare-ctemplate-ios.sh | 9 ++++++++- scripts/prepare-icu4c-ios.sh | 10 +++++++++- scripts/prepare-libetpan-ios.sh | 12 ++++++++++-- scripts/prepare-libetpan-macos.sh | 2 +- scripts/prepare-tidy-ios.sh | 9 ++++++++- 6 files changed, 44 insertions(+), 7 deletions(-) diff --git a/scripts/build-mailcore2-ios.sh b/scripts/build-mailcore2-ios.sh index 9e54dea6..a505fce0 100755 --- a/scripts/build-mailcore2-ios.sh +++ b/scripts/build-mailcore2-ios.sh @@ -1,6 +1,13 @@ #!/bin/sh -sdkversion=6.1 +if xcodebuild -showsdks|grep iphoneos6.1 >/dev/null ; then + sdkversion=6.1 +elif xcodebuild -showsdks|grep iphoneos7.0 >/dev/null ; then + sdkversion=7.0 +else + echo SDK not found + exit 1 +fi url="https://github.com/MailCore/mailcore2.git" pushd `dirname $0` > /dev/null diff --git a/scripts/prepare-ctemplate-ios.sh b/scripts/prepare-ctemplate-ios.sh index 50521f57..5185cb98 100755 --- a/scripts/prepare-ctemplate-ios.sh +++ b/scripts/prepare-ctemplate-ios.sh @@ -2,7 +2,14 @@ url="https://github.com/dinhviethoa/ctemplate" -sdkversion="6.1" +if xcodebuild -showsdks|grep iphoneos6.1 >/dev/null ; then + sdkversion=6.1 +elif xcodebuild -showsdks|grep iphoneos7.0 >/dev/null ; then + sdkversion=7.0 +else + echo SDK not found + exit 1 +fi pushd `dirname $0` > /dev/null scriptpath=`pwd` diff --git a/scripts/prepare-icu4c-ios.sh b/scripts/prepare-icu4c-ios.sh index 854802f1..b09daff7 100755 --- a/scripts/prepare-icu4c-ios.sh +++ b/scripts/prepare-icu4c-ios.sh @@ -1,6 +1,14 @@ #!/bin/sh -sdkversion=6.1 +if xcodebuild -showsdks|grep iphoneos6.1 >/dev/null ; then + sdkversion=6.1 +elif xcodebuild -showsdks|grep iphoneos7.0 >/dev/null ; then + sdkversion=7.0 +else + echo SDK not found + exit 1 +fi + versionfolder='51.1' version='51_1' build_version="$version~1" diff --git a/scripts/prepare-libetpan-ios.sh b/scripts/prepare-libetpan-ios.sh index 4bb18ab0..26824e0e 100755 --- a/scripts/prepare-libetpan-ios.sh +++ b/scripts/prepare-libetpan-ios.sh @@ -1,8 +1,16 @@ #!/bin/sh -sdkversion=6.1 +if xcodebuild -showsdks|grep iphoneos6.1 >/dev/null ; then + sdkversion=6.1 +elif xcodebuild -showsdks|grep iphoneos7.0 >/dev/null ; then + sdkversion=7.0 +else + echo SDK not found + exit 1 +fi + url="https://github.com/dinhviethoa/libetpan.git" -rev=2e016471cea776add8995124b0c58fa31a1c05dd +rev=75a2e16a23c73ab0cdabb8e5b69b941ded0632f0 pushd `dirname $0` > /dev/null scriptpath=`pwd` diff --git a/scripts/prepare-libetpan-macos.sh b/scripts/prepare-libetpan-macos.sh index 925bfc08..b7a1b0bc 100755 --- a/scripts/prepare-libetpan-macos.sh +++ b/scripts/prepare-libetpan-macos.sh @@ -1,7 +1,7 @@ #!/bin/sh url="https://github.com/dinhviethoa/libetpan.git" -rev=2e016471cea776add8995124b0c58fa31a1c05dd +rev=75a2e16a23c73ab0cdabb8e5b69b941ded0632f0 pushd `dirname $0` > /dev/null scriptpath=`pwd` diff --git a/scripts/prepare-tidy-ios.sh b/scripts/prepare-tidy-ios.sh index 53989950..f48f9726 100755 --- a/scripts/prepare-tidy-ios.sh +++ b/scripts/prepare-tidy-ios.sh @@ -1,6 +1,13 @@ #!/bin/sh -sdkversion=6.1 +if xcodebuild -showsdks|grep iphoneos6.1 >/dev/null ; then + sdkversion=6.1 +elif xcodebuild -showsdks|grep iphoneos7.0 >/dev/null ; then + sdkversion=7.0 +else + echo SDK not found + exit 1 +fi url="https://github.com/dinhviethoa/tidy-html5.git" pushd `dirname $0` > /dev/null -- cgit v1.2.3 From 4eea42266c70d3becfd15482e8654c3590dd388c Mon Sep 17 00:00:00 2001 From: "Hoa V. DINH" Date: Wed, 21 Aug 2013 00:32:50 -0700 Subject: Enable compression --- src/core/imap/MCIMAPSession.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/imap/MCIMAPSession.cc b/src/core/imap/MCIMAPSession.cc index 32402231..eaea8042 100755 --- a/src/core/imap/MCIMAPSession.cc +++ b/src/core/imap/MCIMAPSession.cc @@ -3197,7 +3197,7 @@ void IMAPSession::applyCapabilities(IndexSet * capabilities) mNamespaceEnabled = true; } if (capabilities->containsIndex(IMAPCapabilityCompressDeflate)) { - //mCompressionEnabled = true; + mCompressionEnabled = true; } } -- cgit v1.2.3 From 75810bbb5cade21363fff5096ee36ff4ead9d117 Mon Sep 17 00:00:00 2001 From: "Hoa V. DINH" Date: Wed, 21 Aug 2013 00:53:57 -0700 Subject: SMTP QUIT only if a stream is available. --- src/core/smtp/MCSMTPSession.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/core/smtp/MCSMTPSession.cc b/src/core/smtp/MCSMTPSession.cc index 4677e2d6..6421d138 100644 --- a/src/core/smtp/MCSMTPSession.cc +++ b/src/core/smtp/MCSMTPSession.cc @@ -355,7 +355,9 @@ void SMTPSession::disconnect() if (mSmtp == NULL) return; - mailsmtp_quit(mSmtp); + if (mSmtp->stream != NULL) { + mailsmtp_quit(mSmtp); + } unsetup(); -- cgit v1.2.3 From c89bf888c725d8997c76375be52d2ec1819a767a Mon Sep 17 00:00:00 2001 From: "Hoa V. DINH" Date: Wed, 21 Aug 2013 22:00:08 -0700 Subject: Check certificate can be disabled. Fixed #324: reconnect SMTP properly after it's been disconnected. --- src/core/imap/MCIMAPSession.cc | 2 + src/core/pop/MCPOPSession.cc | 2 + src/core/smtp/MCSMTPSession.cc | 165 +++++++++++++++++++++++------------------ src/core/smtp/MCSMTPSession.h | 1 + 4 files changed, 99 insertions(+), 71 deletions(-) diff --git a/src/core/imap/MCIMAPSession.cc b/src/core/imap/MCIMAPSession.cc index eaea8042..d177803a 100755 --- a/src/core/imap/MCIMAPSession.cc +++ b/src/core/imap/MCIMAPSession.cc @@ -485,6 +485,8 @@ static bool hasError(int errorCode) bool IMAPSession::checkCertificate() { + if (!isCheckCertificateEnabled()) + return true; return mailcore::checkCertificate(mImap->imap_stream, hostname()); } diff --git a/src/core/pop/MCPOPSession.cc b/src/core/pop/MCPOPSession.cc index 393ec516..86a4a0d3 100644 --- a/src/core/pop/MCPOPSession.cc +++ b/src/core/pop/MCPOPSession.cc @@ -130,6 +130,8 @@ bool POPSession::isCheckCertificateEnabled() bool POPSession::checkCertificate() { + if (!isCheckCertificateEnabled()) + return true; return mailcore::checkCertificate(mPop->pop3_stream, hostname()); } diff --git a/src/core/smtp/MCSMTPSession.cc b/src/core/smtp/MCSMTPSession.cc index 6421d138..78eb4113 100644 --- a/src/core/smtp/MCSMTPSession.cc +++ b/src/core/smtp/MCSMTPSession.cc @@ -14,9 +14,9 @@ using namespace mailcore; enum { - STATE_DISCONNECTED, - STATE_CONNECTED, - STATE_LOGGEDIN, + STATE_DISCONNECTED, + STATE_CONNECTED, + STATE_LOGGEDIN, }; void SMTPSession::init() @@ -31,6 +31,7 @@ void SMTPSession::init() mTimeout = 30; mCheckCertificateEnabled = true; mUseHeloIPEnabled = false; + mShouldDisconnect = false; mSmtp = NULL; mProgressCallback = NULL; @@ -147,6 +148,8 @@ bool SMTPSession::isCheckCertificateEnabled() bool SMTPSession::checkCertificate() { + if (!isCheckCertificateEnabled()) + return true; return mailcore::checkCertificate(mSmtp->stream, hostname()); } @@ -212,6 +215,17 @@ void SMTPSession::unsetup() void SMTPSession::connectIfNeeded(ErrorCode * pError) { + if (mSmtp != NULL) { + // In case pipelining is available, libetpan will disconnect the session. + if (mSmtp->stream == NULL) { + mShouldDisconnect = true; + } + } + if (mShouldDisconnect) { + disconnect(); + mShouldDisconnect = false; + } + if (mState == STATE_DISCONNECTED) { connect(pError); } @@ -222,114 +236,114 @@ void SMTPSession::connectIfNeeded(ErrorCode * pError) void SMTPSession::connect(ErrorCode * pError) { - int r; - + int r; + setup(); switch (mConnectionType) { - case ConnectionTypeStartTLS: - MCLog("connect %s %u", MCUTF8(hostname()), (unsigned int) port()); - r = mailsmtp_socket_connect(mSmtp, MCUTF8(hostname()), port()); - if (r != MAILSMTP_NO_ERROR) { + case ConnectionTypeStartTLS: + MCLog("connect %s %u", MCUTF8(hostname()), (unsigned int) port()); + r = mailsmtp_socket_connect(mSmtp, MCUTF8(hostname()), port()); + if (r != MAILSMTP_NO_ERROR) { * pError = ErrorConnection; - return; - } - - MCLog("init"); + goto close; + } + + MCLog("init"); if (useHeloIPEnabled()) { r = mailsmtp_init_with_ip(mSmtp, 1); } else { r = mailsmtp_init(mSmtp); } - if (r == MAILSMTP_ERROR_STREAM) { + if (r == MAILSMTP_ERROR_STREAM) { * pError = ErrorConnection; - return; - } - else if (r != MAILSMTP_NO_ERROR) { + goto close; + } + else if (r != MAILSMTP_NO_ERROR) { * pError = ErrorConnection; - return; - } - - MCLog("start TLS"); - r = mailsmtp_socket_starttls(mSmtp); - if (r != MAILSMTP_NO_ERROR) { + goto close; + } + + MCLog("start TLS"); + r = mailsmtp_socket_starttls(mSmtp); + if (r != MAILSMTP_NO_ERROR) { * pError = ErrorStartTLSNotAvailable; - return; - } - MCLog("done"); - if (!checkCertificate()) { + goto close; + } + MCLog("done"); + if (!checkCertificate()) { * pError = ErrorCertificate; - return; + goto close; } - - MCLog("init after starttls"); + + MCLog("init after starttls"); if (useHeloIPEnabled()) { r = mailsmtp_init_with_ip(mSmtp, 1); } else { r = mailsmtp_init(mSmtp); } - if (r == MAILSMTP_ERROR_STREAM) { + if (r == MAILSMTP_ERROR_STREAM) { * pError = ErrorConnection; - return; - } - else if (r != MAILSMTP_NO_ERROR) { + goto close; + } + else if (r != MAILSMTP_NO_ERROR) { * pError = ErrorConnection; - return; - } + goto close; + } + + break; - break; - - case ConnectionTypeTLS: - r = mailsmtp_ssl_connect(mSmtp, MCUTF8(mHostname), port()); - if (r != MAILSMTP_NO_ERROR) { + case ConnectionTypeTLS: + r = mailsmtp_ssl_connect(mSmtp, MCUTF8(mHostname), port()); + if (r != MAILSMTP_NO_ERROR) { * pError = ErrorConnection; - return; - } - if (!checkCertificate()) { + goto close; + } + if (!checkCertificate()) { * pError = ErrorCertificate; - return; + goto close; } - - MCLog("init"); + + MCLog("init"); if (useHeloIPEnabled()) { r = mailsmtp_init_with_ip(mSmtp, 1); } else { r = mailsmtp_init(mSmtp); } - if (r == MAILSMTP_ERROR_STREAM) { + if (r == MAILSMTP_ERROR_STREAM) { * pError = ErrorConnection; - return; - } - else if (r != MAILSMTP_NO_ERROR) { + goto close; + } + else if (r != MAILSMTP_NO_ERROR) { * pError = ErrorConnection; - return; - } - - break; - - default: - r = mailsmtp_socket_connect(mSmtp, MCUTF8(hostname()), port()); - if (r != MAILIMAP_NO_ERROR) { + goto close; + } + + break; + + default: + r = mailsmtp_socket_connect(mSmtp, MCUTF8(hostname()), port()); + if (r != MAILIMAP_NO_ERROR) { * pError = ErrorConnection; - return; - } - - MCLog("init"); + goto close; + } + + MCLog("init"); if (useHeloIPEnabled()) { r = mailsmtp_init_with_ip(mSmtp, 1); } else { r = mailsmtp_init(mSmtp); } - if (r == MAILSMTP_ERROR_STREAM) { + if (r == MAILSMTP_ERROR_STREAM) { * pError = ErrorConnection; - return; - } - else if (r != MAILSMTP_NO_ERROR) { + goto close; + } + else if (r != MAILSMTP_NO_ERROR) { * pError = ErrorConnection; - return; - } - - break; + goto close; + } + + break; } mailstream_low * low; @@ -348,6 +362,10 @@ void SMTPSession::connect(ErrorCode * pError) mState = STATE_CONNECTED; * pError = ErrorNone; + return; + +close: + unsetup(); } void SMTPSession::disconnect() @@ -510,6 +528,7 @@ void SMTPSession::login(ErrorCode * pError) } if (r == MAILSMTP_ERROR_STREAM) { * pError = ErrorConnection; + mShouldDisconnect = true; return; } else if (r != MAILSMTP_NO_ERROR) { @@ -532,6 +551,7 @@ void SMTPSession::checkAccount(Address * from, ErrorCode * pError) r = mailsmtp_mail(mSmtp, MCUTF8(from->mailbox())); if (r == MAILSMTP_ERROR_STREAM) { * pError = ErrorConnection; + mShouldDisconnect = true; return; } else if (r != MAILSMTP_NO_ERROR) { @@ -542,6 +562,7 @@ void SMTPSession::checkAccount(Address * from, ErrorCode * pError) r = mailsmtp_rcpt(mSmtp, "email@invalid.com"); if (r == MAILSMTP_ERROR_STREAM) { * pError = ErrorConnection; + mShouldDisconnect = true; return; } else if (r != MAILSMTP_NO_ERROR) { @@ -589,6 +610,7 @@ void SMTPSession::sendMessage(Address * from, Array * recipients, Data * message r = mailesmtp_send(mSmtp, MCUTF8(from->mailbox()), 0, NULL, address_list, messageData->bytes(), messageData->length()); + mailsmtp_quit(mSmtp); } esmtp_address_list_free(address_list); @@ -603,6 +625,7 @@ void SMTPSession::sendMessage(Address * from, Array * recipients, Data * message if ((r == MAILSMTP_ERROR_STREAM) || (r == MAILSMTP_ERROR_CONNECTION_REFUSED)) { * pError = ErrorConnection; + mShouldDisconnect = true; goto err; } else if (r == MAILSMTP_ERROR_EXCEED_STORAGE_ALLOCATION) { diff --git a/src/core/smtp/MCSMTPSession.h b/src/core/smtp/MCSMTPSession.h index 1b4c9690..28f94ada 100644 --- a/src/core/smtp/MCSMTPSession.h +++ b/src/core/smtp/MCSMTPSession.h @@ -75,6 +75,7 @@ namespace mailcore { time_t mTimeout; bool mCheckCertificateEnabled; bool mUseHeloIPEnabled; + bool mShouldDisconnect; mailsmtp * mSmtp; SMTPProgressCallback * mProgressCallback; -- cgit v1.2.3 From ca12f905446f72c6c3077762bbcb85b9ca755f4d Mon Sep 17 00:00:00 2001 From: "Hoa V. DINH" Date: Wed, 21 Aug 2013 22:03:10 -0700 Subject: Fixed IDLE capability detection --- src/core/imap/MCIMAPSession.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/core/imap/MCIMAPSession.cc b/src/core/imap/MCIMAPSession.cc index d177803a..d35a9980 100755 --- a/src/core/imap/MCIMAPSession.cc +++ b/src/core/imap/MCIMAPSession.cc @@ -642,7 +642,7 @@ void IMAPSession::connect(ErrorCode * pError) capabilitySetWithSessionState(IndexSet::indexSet()); } else { - IndexSet * capabilities = capability(pError); + capability(pError); if (* pError != ErrorNone) { MCLog("capabilities failed"); unsetup(); @@ -653,9 +653,6 @@ void IMAPSession::connect(ErrorCode * pError) * pError = ErrorNone; MCLog("connect ok"); - LOCK(); - mCanIdle = true; - UNLOCK(); } void IMAPSession::connectIfNeeded(ErrorCode * pError) @@ -3140,6 +3137,11 @@ IndexSet * IMAPSession::capability(ErrorCode * pError) void IMAPSession::capabilitySetWithSessionState(IndexSet * capabilities) { + if (mailimap_has_idle(mImap)) { + LOCK(); + mCanIdle = true; + UNLOCK(); + } if (mailimap_has_id(mImap)) { capabilities->addIndex(IMAPCapabilityId); } -- cgit v1.2.3 From 1d893874d362afc6f976365654887c8069508143 Mon Sep 17 00:00:00 2001 From: "Hoa V. DINH" Date: Wed, 21 Aug 2013 22:25:13 -0700 Subject: Reconnect automatically the IMAP session after a connection error (Fixed #313) --- src/core/imap/MCIMAPSession.cc | 66 +++++++++++++++++++++++++++++++++--------- src/core/imap/MCIMAPSession.h | 1 + 2 files changed, 53 insertions(+), 14 deletions(-) diff --git a/src/core/imap/MCIMAPSession.cc b/src/core/imap/MCIMAPSession.cc index d35a9980..6b112646 100755 --- a/src/core/imap/MCIMAPSession.cc +++ b/src/core/imap/MCIMAPSession.cc @@ -358,6 +358,7 @@ void IMAPSession::init() mConnectionLogger = NULL; mAutomaticConfigurationEnabled = true; mAutomaticConfigurationDone = false; + mShouldDisconnect = false; } IMAPSession::IMAPSession() @@ -575,17 +576,15 @@ void IMAPSession::connect(ErrorCode * pError) MCLog("STARTTLS connect"); r = mailimap_socket_connect_voip(mImap, MCUTF8(mHostname), mPort, isVoIPEnabled()); if (hasError(r)) { - unsetup(); * pError = ErrorConnection; - return; + goto close; } r = mailimap_socket_starttls(mImap); if (hasError(r)) { - unsetup(); MCLog("no TLS %i", r); * pError = ErrorTLSNotAvailable; - return; + goto close; } break; @@ -593,16 +592,14 @@ void IMAPSession::connect(ErrorCode * pError) r = mailimap_ssl_connect_voip(mImap, MCUTF8(mHostname), mPort, isVoIPEnabled()); MCLog("ssl connect %s %u %u", MCUTF8(mHostname), mPort, r); if (hasError(r)) { - unsetup(); MCLog("connect error %i", r); * pError = ErrorConnection; - return; + goto close; } if (!checkCertificate()) { - unsetup(); MCLog("ssl connect certificate ERROR %d", r); * pError = ErrorCertificate; - return; + goto close; } break; @@ -612,10 +609,9 @@ void IMAPSession::connect(ErrorCode * pError) r = mailimap_socket_connect_voip(mImap, MCUTF8(mHostname), mPort, isVoIPEnabled()); MCLog("socket connect %i", r); if (hasError(r)) { - unsetup(); MCLog("connect error %i", r); * pError = ErrorConnection; - return; + goto close; } break; } @@ -645,18 +641,26 @@ void IMAPSession::connect(ErrorCode * pError) capability(pError); if (* pError != ErrorNone) { MCLog("capabilities failed"); - unsetup(); - return; + goto close; } } } * pError = ErrorNone; MCLog("connect ok"); + return; + +close: + unsetup(); } void IMAPSession::connectIfNeeded(ErrorCode * pError) { + if (mShouldDisconnect) { + disconnect(); + mShouldDisconnect = false; + } + if (mState == STATE_DISCONNECTED) { connect(pError); } @@ -789,6 +793,7 @@ void IMAPSession::login(ErrorCode * pError) break; } if (r == MAILIMAP_ERROR_STREAM) { + mShouldDisconnect = true; * pError = ErrorConnection; return; } @@ -956,6 +961,7 @@ void IMAPSession::select(String * folder, ErrorCode * pError) r = mailimap_select(mImap, MCUTF8(folder)); MCLog("select error : %i", r); if (r == MAILIMAP_ERROR_STREAM) { + mShouldDisconnect = true; * pError = ErrorConnection; MCLog("select error : %s %i", MCUTF8DESC(this), * pError); return; @@ -1030,6 +1036,7 @@ IMAPFolderStatus * IMAPSession::folderStatus(String * folder, ErrorCode * pError MCLog("status error : %i", r); if (r == MAILIMAP_ERROR_STREAM) { + mShouldDisconnect = true; * pError = ErrorConnection; MCLog("status error : %s %i", MCUTF8DESC(this), * pError); return fs; @@ -1220,6 +1227,8 @@ char IMAPSession::fetchDelimiterIfNeeded(char defaultDelimiter, ErrorCode * pErr r = mailimap_list(mImap, "", "", &imap_folders); folders = resultsWithError(r, imap_folders, pError); + if (* pError == ErrorConnection) + mShouldDisconnect = true; if (* pError != ErrorNone) return 0; @@ -1270,7 +1279,10 @@ Array * /* IMAPFolder */ IMAPSession::fetchSubscribedFolders(ErrorCode * pError) r = mailimap_lsub(mImap, MCUTF8(prefix), "*", &imap_folders); MCLog("fetch subscribed %u", r); - return resultsWithError(r, imap_folders, pError); + Array * result = resultsWithError(r, imap_folders, pError); + if (* pError == ErrorConnection) + mShouldDisconnect = true; + return result; } Array * /* IMAPFolder */ IMAPSession::fetchAllFolders(ErrorCode * pError) @@ -1312,7 +1324,10 @@ Array * /* IMAPFolder */ IMAPSession::fetchAllFolders(ErrorCode * pError) else { r = mailimap_list(mImap, MCUTF8(prefix), "*", &imap_folders); } - return resultsWithError(r, imap_folders, pError); + Array * result = resultsWithError(r, imap_folders, pError); + if (* pError == ErrorConnection) + mShouldDisconnect = true; + return result; } void IMAPSession::renameFolder(String * folder, String * otherName, ErrorCode * pError) @@ -1325,6 +1340,7 @@ void IMAPSession::renameFolder(String * folder, String * otherName, ErrorCode * r = mailimap_rename(mImap, MCUTF8(folder), MCUTF8(otherName)); if (r == MAILIMAP_ERROR_STREAM) { + mShouldDisconnect = true; * pError = ErrorConnection; return; } @@ -1349,6 +1365,7 @@ void IMAPSession::deleteFolder(String * folder, ErrorCode * pError) r = mailimap_delete(mImap, MCUTF8(folder)); if (r == MAILIMAP_ERROR_STREAM) { + mShouldDisconnect = true; * pError = ErrorConnection; return; } @@ -1373,6 +1390,7 @@ void IMAPSession::createFolder(String * folder, ErrorCode * pError) r = mailimap_create(mImap, MCUTF8(folder)); if (r == MAILIMAP_ERROR_STREAM) { + mShouldDisconnect = true; * pError = ErrorConnection; return; } @@ -1399,6 +1417,7 @@ void IMAPSession::subscribeFolder(String * folder, ErrorCode * pError) r = mailimap_subscribe(mImap, MCUTF8(folder)); if (r == MAILIMAP_ERROR_STREAM) { + mShouldDisconnect = true; * pError = ErrorConnection; return; } @@ -1423,6 +1442,7 @@ void IMAPSession::unsubscribeFolder(String * folder, ErrorCode * pError) r = mailimap_unsubscribe(mImap, MCUTF8(folder)); if (r == MAILIMAP_ERROR_STREAM) { + mShouldDisconnect = true; * pError = ErrorConnection; return; } @@ -1462,6 +1482,7 @@ void IMAPSession::appendMessage(String * folder, Data * messageData, MessageFlag mProgressCallback = NULL; if (r == MAILIMAP_ERROR_STREAM) { + mShouldDisconnect = true; * pError = ErrorConnection; return; } @@ -1509,6 +1530,7 @@ void IMAPSession::copyMessages(String * folder, IndexSet * uidSet, String * dest r = mailimap_uidplus_uid_copy(mImap, current_set, MCUTF8(destFolder), &uidvalidity, &src_uid, &dest_uid); if (r == MAILIMAP_ERROR_STREAM) { + mShouldDisconnect = true; * pError = ErrorConnection; goto release; } @@ -1555,6 +1577,7 @@ void IMAPSession::expunge(String * folder, ErrorCode * pError) r = mailimap_expunge(mImap); if (r == MAILIMAP_ERROR_STREAM) { + mShouldDisconnect = true; * pError = ErrorConnection; return; } @@ -1660,6 +1683,7 @@ HashMap * IMAPSession::fetchMessageNumberUIDMapping(String * folder, uint32_t fr if (r == MAILIMAP_ERROR_STREAM) { MCLog("error stream"); + mShouldDisconnect = true; * pError = ErrorConnection; return NULL; } @@ -2174,6 +2198,7 @@ IMAPSyncResult * IMAPSession::fetchMessages(String * folder, IMAPMessagesRequest if (r == MAILIMAP_ERROR_STREAM) { MCLog("error stream"); + mShouldDisconnect = true; * pError = ErrorConnection; return NULL; } @@ -2356,6 +2381,7 @@ Data * IMAPSession::fetchMessageByUID(String * folder, uint32_t uid, mProgressCallback = NULL; if (r == MAILIMAP_ERROR_STREAM) { + mShouldDisconnect = true; * pError = ErrorConnection; return NULL; } @@ -2426,6 +2452,7 @@ Data * IMAPSession::fetchMessageAttachmentByUID(String * folder, uint32_t uid, S MCLog("had error : %i", r); if (r == MAILIMAP_ERROR_STREAM) { + mShouldDisconnect = true; * pError = ErrorConnection; return NULL; } @@ -2545,6 +2572,7 @@ IndexSet * IMAPSession::search(String * folder, IMAPSearchExpression * expressio mailimap_search_key_free(key); MCLog("had error : %i", r); if (r == MAILIMAP_ERROR_STREAM) { + mShouldDisconnect = true; * pError = ErrorConnection; return NULL; } @@ -2573,6 +2601,7 @@ void IMAPSession::getQuota(uint32_t *usage, uint32_t *limit, ErrorCode * pError) int r = mailimap_quota_getquotaroot(mImap, "INBOX", "a_data); if (r == MAILIMAP_ERROR_STREAM) { + mShouldDisconnect = true; * pError = ErrorConnection; return; } @@ -2638,6 +2667,7 @@ void IMAPSession::idle(String * folder, uint32_t lastKnownUID, ErrorCode * pErro r = mailimap_idle(mImap); if (r == MAILIMAP_ERROR_STREAM) { + mShouldDisconnect = true; * pError = ErrorConnection; return; } @@ -2657,6 +2687,7 @@ void IMAPSession::idle(String * folder, uint32_t lastKnownUID, ErrorCode * pErro case MAILSTREAM_IDLE_ERROR: case MAILSTREAM_IDLE_CANCELLED: { + mShouldDisconnect = true; * pError = ErrorConnection; MCLog("error or cancelled"); return; @@ -2678,6 +2709,7 @@ void IMAPSession::idle(String * folder, uint32_t lastKnownUID, ErrorCode * pErro r = mailimap_idle_done(mImap); if (r == MAILIMAP_ERROR_STREAM) { + mShouldDisconnect = true; * pError = ErrorConnection; return; } @@ -2750,6 +2782,7 @@ HashMap * IMAPSession::identity(String * vendor, String * name, String * version r = mailimap_id(mImap, client_identification, &server_identification); mailimap_id_params_list_free(client_identification); if (r == MAILIMAP_ERROR_STREAM) { + mShouldDisconnect = true; * pError = ErrorConnection; return NULL; } @@ -2824,6 +2857,7 @@ HashMap * IMAPSession::fetchNamespace(ErrorCode * pError) result = HashMap::hashMap(); r = mailimap_namespace(mImap, &namespace_data); if (r == MAILIMAP_ERROR_STREAM) { + mShouldDisconnect = true; * pError = ErrorConnection; return NULL; } @@ -2960,6 +2994,7 @@ void IMAPSession::storeFlags(String * folder, IndexSet * uids, IMAPStoreFlagsReq r = mailimap_uid_store(mImap, current_set, store_att_flags); if (r == MAILIMAP_ERROR_STREAM) { + mShouldDisconnect = true; * pError = ErrorConnection; goto release; } @@ -3029,6 +3064,7 @@ void IMAPSession::storeLabels(String * folder, IndexSet * uids, IMAPStoreFlagsRe } r = mailimap_uid_store_xgmlabels(mImap, current_set, fl_sign, 1, xgmlabels); if (r == MAILIMAP_ERROR_STREAM) { + mShouldDisconnect = true; * pError = ErrorConnection; goto release; } @@ -3113,6 +3149,7 @@ IndexSet * IMAPSession::capability(ErrorCode * pError) r = mailimap_capability(mImap, &cap); if (r == MAILIMAP_ERROR_STREAM) { + mShouldDisconnect = true; * pError = ErrorConnection; return NULL; } @@ -3388,6 +3425,7 @@ void IMAPSession::enableCompression(ErrorCode * pError) int r; r = mailimap_compress(mImap); if (r == MAILIMAP_ERROR_STREAM) { + mShouldDisconnect = true; * pError = ErrorConnection; return; } diff --git a/src/core/imap/MCIMAPSession.h b/src/core/imap/MCIMAPSession.h index b2c7e25d..842d0866 100755 --- a/src/core/imap/MCIMAPSession.h +++ b/src/core/imap/MCIMAPSession.h @@ -230,6 +230,7 @@ namespace mailcore { ConnectionLogger * mConnectionLogger; bool mAutomaticConfigurationEnabled; bool mAutomaticConfigurationDone; + bool mShouldDisconnect; void init(); void bodyProgress(unsigned int current, unsigned int maximum); -- cgit v1.2.3 From e44cdd8f9ce460d30703ca3c9cc3ef9450191f28 Mon Sep 17 00:00:00 2001 From: "Hoa V. DINH" Date: Fri, 23 Aug 2013 22:27:13 -0700 Subject: Fixed #319: [[MCOIMAPMessage alloc] init] can now be called. --- src/objc/imap/MCOIMAPMessage.mm | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/objc/imap/MCOIMAPMessage.mm b/src/objc/imap/MCOIMAPMessage.mm index 325f2b09..99c45505 100644 --- a/src/objc/imap/MCOIMAPMessage.mm +++ b/src/objc/imap/MCOIMAPMessage.mm @@ -25,6 +25,14 @@ MCORegisterClass(self, &typeid(nativeType)); } +- (id) init +{ + mailcore::IMAPMessage * msg = new mailcore::IMAPMessage(); + self = [self initWithMCMessage:msg]; + msg->release(); + return self; +} + + (NSObject *) mco_objectWithMCObject:(mailcore::Object *)object { mailcore::IMAPMessage * msg = (mailcore::IMAPMessage *) object; -- cgit v1.2.3 From 88c28fa7b259a27648f7306afeebe2497ddb1507 Mon Sep 17 00:00:00 2001 From: "Hoa V. DINH" Date: Fri, 23 Aug 2013 22:28:17 -0700 Subject: Fixed warning --- src/core/imap/MCIMAPSession.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/imap/MCIMAPSession.cc b/src/core/imap/MCIMAPSession.cc index 6b112646..510f5eda 100755 --- a/src/core/imap/MCIMAPSession.cc +++ b/src/core/imap/MCIMAPSession.cc @@ -840,7 +840,7 @@ void IMAPSession::login(ErrorCode * pError) capabilitySetWithSessionState(IndexSet::indexSet()); } else { - IndexSet * capabilities = capability(pError); + capability(pError); if (* pError != ErrorNone) { MCLog("capabilities failed"); return; -- cgit v1.2.3 From b7febcf978c5faf6d70a132b88394d074df9c790 Mon Sep 17 00:00:00 2001 From: "Hoa V. DINH" Date: Sat, 24 Aug 2013 18:46:54 -0700 Subject: Fixed #277: automatic ID. Cleaner API for identity API and also allows to specify custom fields. --- build-mac/mailcore2.xcodeproj/project.pbxproj | 24 +++++++ src/async/imap/MCAsyncIMAP.h | 1 + src/async/imap/MCIMAPAsyncConnection.cc | 22 ++++-- src/async/imap/MCIMAPAsyncConnection.h | 7 +- src/async/imap/MCIMAPAsyncSession.cc | 21 +++++- src/async/imap/MCIMAPAsyncSession.h | 8 ++- src/async/imap/MCIMAPIdentityOperation.cc | 41 +++-------- src/async/imap/MCIMAPIdentityOperation.h | 20 ++---- src/core/imap/MCIMAP.h | 1 + src/core/imap/MCIMAPIdentity.cc | 97 +++++++++++++++++++++++++++ src/core/imap/MCIMAPIdentity.h | 54 +++++++++++++++ src/core/imap/MCIMAPSession.cc | 51 +++++++++----- src/core/imap/MCIMAPSession.h | 8 ++- src/objc/imap/MCOIMAP.h | 1 + src/objc/imap/MCOIMAPIdentity.h | 42 ++++++++++++ src/objc/imap/MCOIMAPIdentity.mm | 96 ++++++++++++++++++++++++++ src/objc/imap/MCOIMAPSession.h | 19 +++--- src/objc/imap/MCOIMAPSession.mm | 19 ++++-- 18 files changed, 446 insertions(+), 86 deletions(-) create mode 100644 src/core/imap/MCIMAPIdentity.cc create mode 100644 src/core/imap/MCIMAPIdentity.h create mode 100644 src/objc/imap/MCOIMAPIdentity.h create mode 100644 src/objc/imap/MCOIMAPIdentity.mm diff --git a/build-mac/mailcore2.xcodeproj/project.pbxproj b/build-mac/mailcore2.xcodeproj/project.pbxproj index 620683bb..002d1128 100755 --- a/build-mac/mailcore2.xcodeproj/project.pbxproj +++ b/build-mac/mailcore2.xcodeproj/project.pbxproj @@ -92,6 +92,14 @@ C63CD68D16BE1BCA00DB18F1 /* MCRenderer.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = C63CD68716BE1AB600DB18F1 /* MCRenderer.h */; }; C63CD68E16BE324100DB18F1 /* MCOIMAPFetchFoldersOperation.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = F87F190816BB62690012652F /* MCOIMAPFetchFoldersOperation.h */; }; C63CD69116BE566E00DB18F1 /* MCHTMLCleaner.cc in Sources */ = {isa = PBXBuildFile; fileRef = C63CD68F16BE566D00DB18F1 /* MCHTMLCleaner.cc */; }; + C63D315C17C9155C00A4D993 /* MCIMAPIdentity.cc in Sources */ = {isa = PBXBuildFile; fileRef = C63D315A17C9155C00A4D993 /* MCIMAPIdentity.cc */; }; + C63D315D17C9155C00A4D993 /* MCIMAPIdentity.cc in Sources */ = {isa = PBXBuildFile; fileRef = C63D315A17C9155C00A4D993 /* MCIMAPIdentity.cc */; }; + C63D315E17C9279700A4D993 /* MCIMAPIdentity.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = C63D315B17C9155C00A4D993 /* MCIMAPIdentity.h */; }; + C63D315F17C9279D00A4D993 /* MCIMAPIdentity.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = C63D315B17C9155C00A4D993 /* MCIMAPIdentity.h */; }; + C63D316217C92D8300A4D993 /* MCOIMAPIdentity.mm in Sources */ = {isa = PBXBuildFile; fileRef = C63D316117C92D8300A4D993 /* MCOIMAPIdentity.mm */; }; + C63D316317C92D8300A4D993 /* MCOIMAPIdentity.mm in Sources */ = {isa = PBXBuildFile; fileRef = C63D316117C92D8300A4D993 /* MCOIMAPIdentity.mm */; }; + C63D316617C997B400A4D993 /* MCOIMAPIdentity.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = C63D316017C92D8300A4D993 /* MCOIMAPIdentity.h */; }; + C63D316717C997BA00A4D993 /* MCOIMAPIdentity.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = C63D316017C92D8300A4D993 /* MCOIMAPIdentity.h */; }; C64BB22116E34DCB000DB34C /* MCIMAPSyncResult.cc in Sources */ = {isa = PBXBuildFile; fileRef = C64BB21F16E34DCA000DB34C /* MCIMAPSyncResult.cc */; }; C64BB22B16E5C0A4000DB34C /* MCIMAPCapabilityOperation.cc in Sources */ = {isa = PBXBuildFile; fileRef = C64BB22916E5C0A3000DB34C /* MCIMAPCapabilityOperation.cc */; }; C64BB22E16E5C1EE000DB34C /* MCIndexSet.cc in Sources */ = {isa = PBXBuildFile; fileRef = C64BB22C16E5C1EE000DB34C /* MCIndexSet.cc */; }; @@ -745,6 +753,8 @@ 4BE4029117B548B900ECC5E4 /* MCOIMAPQuotaOperation.h in CopyFiles */, C6E665001790963E0063F2CF /* MCIMAPMessageRenderingOperation.h in CopyFiles */, DAE42E89178F7E1800E0DB8F /* MCOIMAPMessageRenderingOperation.h in CopyFiles */, + C63D316617C997B400A4D993 /* MCOIMAPIdentity.h in CopyFiles */, + C63D315E17C9279700A4D993 /* MCIMAPIdentity.h in CopyFiles */, 9E774D8C1767CD490065EB9B /* MCIMAPFolderStatus.h in CopyFiles */, 9EF9AB24175F409D0027FA3B /* MCIMAPFolderStatusOperation.h in CopyFiles */, 9EF9AB22175F406D0027FA3B /* MCOIMAPFolderStatus.h in CopyFiles */, @@ -934,6 +944,7 @@ files = ( 4B3C1BE417AC0156008BBF4C /* MCIMAPQuotaOperation.h in CopyFiles */, 4B3C1BE217ABFF7C008BBF4C /* MCOIMAPQuotaOperation.h in CopyFiles */, + C63D316717C997BA00A4D993 /* MCOIMAPIdentity.h in CopyFiles */, DAE42E8A178F7E2200E0DB8F /* MCOIMAPMessageRenderingOperation.h in CopyFiles */, C6E6652F1791B2530063F2CF /* MCIMAPMessageRenderingOperation.h in CopyFiles */, 9E774D8B1767CD3C0065EB9B /* MCIMAPFolderStatus.h in CopyFiles */, @@ -942,6 +953,7 @@ 9EF9AB21175F3FD10027FA3B /* MCOIMAPFolderStatusOperation.h in CopyFiles */, C6CF62D5175325BB006398B9 /* MCOMailProvider.h in CopyFiles */, C6CF62D6175325BD006398B9 /* MCOMailProvidersManager.h in CopyFiles */, + C63D315F17C9279D00A4D993 /* MCIMAPIdentity.h in CopyFiles */, C6CF62D7175325BF006398B9 /* MCONetService.h in CopyFiles */, C6CF62D8175325C5006398B9 /* MCOProvider.h in CopyFiles */, C68B2AEF1778A869005E61EF /* MCConnectionLogger.h in CopyFiles */, @@ -1176,6 +1188,10 @@ C63CD68716BE1AB600DB18F1 /* MCRenderer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MCRenderer.h; sourceTree = ""; }; C63CD68F16BE566D00DB18F1 /* MCHTMLCleaner.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MCHTMLCleaner.cc; sourceTree = ""; }; C63CD69016BE566E00DB18F1 /* MCHTMLCleaner.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MCHTMLCleaner.h; sourceTree = ""; }; + C63D315A17C9155C00A4D993 /* MCIMAPIdentity.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MCIMAPIdentity.cc; sourceTree = ""; }; + C63D315B17C9155C00A4D993 /* MCIMAPIdentity.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MCIMAPIdentity.h; sourceTree = ""; }; + C63D316017C92D8300A4D993 /* MCOIMAPIdentity.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MCOIMAPIdentity.h; sourceTree = ""; }; + C63D316117C92D8300A4D993 /* MCOIMAPIdentity.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MCOIMAPIdentity.mm; sourceTree = ""; }; C64BB21F16E34DCA000DB34C /* MCIMAPSyncResult.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MCIMAPSyncResult.cc; sourceTree = ""; }; C64BB22016E34DCB000DB34C /* MCIMAPSyncResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MCIMAPSyncResult.h; sourceTree = ""; }; C64BB22916E5C0A3000DB34C /* MCIMAPCapabilityOperation.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MCIMAPCapabilityOperation.cc; sourceTree = ""; }; @@ -1952,6 +1968,8 @@ C64BB22016E34DCB000DB34C /* MCIMAPSyncResult.h */, 9E774D871767C54E0065EB9B /* MCIMAPFolderStatus.h */, 9E774D881767C7F60065EB9B /* MCIMAPFolderStatus.cc */, + C63D315B17C9155C00A4D993 /* MCIMAPIdentity.h */, + C63D315A17C9155C00A4D993 /* MCIMAPIdentity.cc */, ); path = imap; sourceTree = ""; @@ -2234,6 +2252,8 @@ 9EF9AB18175F36600027FA3B /* MCOIMAPFolderStatusOperation.mm */, DA89896B178A47D200F6D90A /* MCOIMAPMessageRenderingOperation.h */, DA89896C178A47D200F6D90A /* MCOIMAPMessageRenderingOperation.mm */, + C63D316017C92D8300A4D993 /* MCOIMAPIdentity.h */, + C63D316117C92D8300A4D993 /* MCOIMAPIdentity.mm */, ); path = imap; sourceTree = ""; @@ -2494,6 +2514,7 @@ C64EA7FC16A2959800778456 /* MCIMAPFetchFoldersOperation.cc in Sources */, C64EA80216A295E400778456 /* MCIMAPRenameFolderOperation.cc in Sources */, C64EA80516A2997E00778456 /* MCIMAPDeleteFolderOperation.cc in Sources */, + C63D315C17C9155C00A4D993 /* MCIMAPIdentity.cc in Sources */, C64EA80816A2999A00778456 /* MCIMAPCreateFolderOperation.cc in Sources */, C64EA80B16A299B700778456 /* MCIMAPSubscribeFolderOperation.cc in Sources */, C64EA81116A299ED00778456 /* MCIMAPAppendMessageOperation.cc in Sources */, @@ -2562,6 +2583,7 @@ C6F5B9F416FEAC6C00D9DABD /* MCOIndexSet.mm in Sources */, C6F5B9FE16FED18600D9DABD /* MCOAbstractMessageRendererCallback.mm in Sources */, C6CCC5C716FFE5190077A5FC /* MCORange.mm in Sources */, + C63D316217C92D8300A4D993 /* MCOIMAPIdentity.mm in Sources */, C6F61F7B170169EE0073032E /* MCOIMAPFolderInfoOperation.mm in Sources */, C6F61F7E170169FB0073032E /* MCOIMAPAppendMessageOperation.mm in Sources */, C6F61F8117016A0D0073032E /* MCOIMAPCopyMessagesOperation.mm in Sources */, @@ -2687,6 +2709,7 @@ C6BA2BC51705F4E6003F0E9E /* MCIMAPFetchFoldersOperation.cc in Sources */, C6BA2BC61705F4E6003F0E9E /* MCIMAPRenameFolderOperation.cc in Sources */, C6BA2BC71705F4E6003F0E9E /* MCIMAPDeleteFolderOperation.cc in Sources */, + C63D315D17C9155C00A4D993 /* MCIMAPIdentity.cc in Sources */, C6BA2BC81705F4E6003F0E9E /* MCIMAPCreateFolderOperation.cc in Sources */, C6BA2BC91705F4E6003F0E9E /* MCIMAPSubscribeFolderOperation.cc in Sources */, C6BA2BCA1705F4E6003F0E9E /* MCIMAPAppendMessageOperation.cc in Sources */, @@ -2755,6 +2778,7 @@ C6BA2C051705F4E6003F0E9E /* MCOIndexSet.mm in Sources */, C6BA2C061705F4E6003F0E9E /* MCOAbstractMessageRendererCallback.mm in Sources */, C6BA2C071705F4E6003F0E9E /* MCORange.mm in Sources */, + C63D316317C92D8300A4D993 /* MCOIMAPIdentity.mm in Sources */, C6BA2C081705F4E6003F0E9E /* MCOIMAPFolderInfoOperation.mm in Sources */, C6BA2C091705F4E6003F0E9E /* MCOIMAPAppendMessageOperation.mm in Sources */, C6BA2C0A1705F4E6003F0E9E /* MCOIMAPCopyMessagesOperation.mm in Sources */, diff --git a/src/async/imap/MCAsyncIMAP.h b/src/async/imap/MCAsyncIMAP.h index 66ba6c7b..b1184fe7 100755 --- a/src/async/imap/MCAsyncIMAP.h +++ b/src/async/imap/MCAsyncIMAP.h @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include diff --git a/src/async/imap/MCIMAPAsyncConnection.cc b/src/async/imap/MCIMAPAsyncConnection.cc index a5e46a58..8fddd237 100755 --- a/src/async/imap/MCIMAPAsyncConnection.cc +++ b/src/async/imap/MCIMAPAsyncConnection.cc @@ -36,6 +36,7 @@ #include "MCIMAPAsyncSession.h" #include "MCConnectionLogger.h" #include "MCIMAPMessageRenderingOperation.h" +#include "MCIMAPIdentity.h" using namespace mailcore; @@ -86,6 +87,7 @@ IMAPAsyncConnection::IMAPAsyncConnection() mSession = new IMAPSession(); mQueue = new OperationQueue(); mDefaultNamespace = NULL; + mClientIdentity = new IMAPIdentity(); mLastFolder = NULL; mQueueCallback = new IMAPOperationQueueCallback(this); mQueue->setCallback(mQueueCallback); @@ -103,6 +105,7 @@ IMAPAsyncConnection::~IMAPAsyncConnection() MC_SAFE_RELEASE(mInternalLogger); MC_SAFE_RELEASE(mQueueCallback); MC_SAFE_RELEASE(mLastFolder); + MC_SAFE_RELEASE(mClientIdentity); MC_SAFE_RELEASE(mDefaultNamespace); MC_SAFE_RELEASE(mQueue); MC_SAFE_RELEASE(mSession); @@ -219,6 +222,19 @@ IMAPNamespace * IMAPAsyncConnection::defaultNamespace() return mDefaultNamespace; } +void IMAPAsyncConnection::setClientIdentity(IMAPIdentity * identity) +{ + MC_SAFE_REPLACE_COPY(IMAPIdentity, mClientIdentity, identity); + mc_foreacharray(String, key, identity->allInfoKeys()) { + mSession->clientIdentity()->setInfoForKey(key, identity->infoForKey(key)); + } +} + +IMAPIdentity * IMAPAsyncConnection::clientIdentity() +{ + return mClientIdentity; +} + IMAPFolderInfoOperation * IMAPAsyncConnection::folderInfoOperation(String * folder) { IMAPFolderInfoOperation * op = new IMAPFolderInfoOperation(); @@ -457,13 +473,11 @@ IMAPFetchNamespaceOperation * IMAPAsyncConnection::fetchNamespaceOperation() return op; } -IMAPIdentityOperation * IMAPAsyncConnection::identityOperation(String * vendor, String * name, String * version) +IMAPIdentityOperation * IMAPAsyncConnection::identityOperation(IMAPIdentity * identity) { IMAPIdentityOperation * op = new IMAPIdentityOperation(); op->setSession(this); - op->setVendor(vendor); - op->setName(name); - op->setVersion(version); + op->setClientIdentity(identity); op->autorelease(); return op; } diff --git a/src/async/imap/MCIMAPAsyncConnection.h b/src/async/imap/MCIMAPAsyncConnection.h index e7ceb283..16f9721e 100755 --- a/src/async/imap/MCIMAPAsyncConnection.h +++ b/src/async/imap/MCIMAPAsyncConnection.h @@ -31,6 +31,7 @@ namespace mailcore { class IMAPConnectionLogger; class IMAPMessageRenderingOperation; class IMAPMessage; + class IMAPIdentity; class IMAPAsyncConnection : public Object { public: @@ -74,6 +75,9 @@ namespace mailcore { virtual void setDefaultNamespace(IMAPNamespace * ns); virtual IMAPNamespace * defaultNamespace(); + virtual void setClientIdentity(IMAPIdentity * identity); + virtual IMAPIdentity * clientIdentity(); + virtual void setConnectionLogger(ConnectionLogger * logger); virtual ConnectionLogger * connectionLogger(); @@ -117,7 +121,7 @@ namespace mailcore { virtual IMAPFetchNamespaceOperation * fetchNamespaceOperation(); - virtual IMAPIdentityOperation * identityOperation(String * vendor, String * name, String * version); + virtual IMAPIdentityOperation * identityOperation(IMAPIdentity * identity); virtual IMAPOperation * checkAccountOperation(); @@ -134,6 +138,7 @@ namespace mailcore { IMAPSession * mSession; OperationQueue * mQueue; IMAPNamespace * mDefaultNamespace; + IMAPIdentity * mClientIdentity; String * mLastFolder; IMAPOperationQueueCallback * mQueueCallback; IMAPAsyncSession * mOwner; diff --git a/src/async/imap/MCIMAPAsyncSession.cc b/src/async/imap/MCIMAPAsyncSession.cc index 50c7dcde..7986cb0b 100755 --- a/src/async/imap/MCIMAPAsyncSession.cc +++ b/src/async/imap/MCIMAPAsyncSession.cc @@ -13,6 +13,7 @@ #include "MCOperationQueueCallback.h" #include "MCConnectionLogger.h" #include "MCIMAPSession.h" +#include "MCIMAPIdentity.h" #define DEFAULT_MAX_CONNECTIONS 3 @@ -37,10 +38,14 @@ IMAPAsyncSession::IMAPAsyncSession() mTimeout = 30.; mConnectionLogger = NULL; mAutomaticConfigurationDone = false; + mServerIdentity = new IMAPIdentity(); + mClientIdentity = new IMAPIdentity(); } IMAPAsyncSession::~IMAPAsyncSession() { + MC_SAFE_RELEASE(mServerIdentity); + MC_SAFE_RELEASE(mClientIdentity); MC_SAFE_RELEASE(mSessions); MC_SAFE_RELEASE(mHostname); MC_SAFE_RELEASE(mUsername); @@ -179,6 +184,16 @@ unsigned int IMAPAsyncSession::maximumConnections() return mMaximumConnections; } +IMAPIdentity * IMAPAsyncSession::serverIdentity() +{ + return mServerIdentity; +} + +IMAPIdentity * IMAPAsyncSession::clientIdentity() +{ + return mClientIdentity; +} + IMAPAsyncConnection * IMAPAsyncSession::session() { IMAPAsyncConnection * session = new IMAPAsyncConnection(); @@ -197,6 +212,7 @@ IMAPAsyncConnection * IMAPAsyncSession::session() session->setCheckCertificateEnabled(mCheckCertificateEnabled); session->setVoIPEnabled(mVoIPEnabled); session->setDefaultNamespace(mDefaultNamespace); + session->setClientIdentity(mClientIdentity); #if 0 // should be implemented properly if (mAutomaticConfigurationDone) { session->setAutomaticConfigurationEnabled(false); @@ -425,10 +441,10 @@ IMAPFetchNamespaceOperation * IMAPAsyncSession::fetchNamespaceOperation() return session->fetchNamespaceOperation(); } -IMAPIdentityOperation * IMAPAsyncSession::identityOperation(String * vendor, String * name, String * version) +IMAPIdentityOperation * IMAPAsyncSession::identityOperation(IMAPIdentity * identity) { IMAPAsyncConnection * session = sessionForFolder(MCSTR("INBOX")); - return session->identityOperation(vendor, name, version); + return session->identityOperation(identity); } IMAPOperation * IMAPAsyncSession::checkAccountOperation() @@ -493,6 +509,7 @@ IMAPMessageRenderingOperation * IMAPAsyncSession::plainTextBodyRenderingOperatio void IMAPAsyncSession::automaticConfigurationDone(IMAPSession * session) { + MC_SAFE_REPLACE_COPY(IMAPIdentity, mServerIdentity, session->serverIdentity()); setDefaultNamespace(session->defaultNamespace()); mAutomaticConfigurationDone = true; } diff --git a/src/async/imap/MCIMAPAsyncSession.h b/src/async/imap/MCIMAPAsyncSession.h index 4360cdef..c5ea5fb5 100755 --- a/src/async/imap/MCIMAPAsyncSession.h +++ b/src/async/imap/MCIMAPAsyncSession.h @@ -37,6 +37,7 @@ namespace mailcore { class IMAPMessageRenderingOperation; class IMAPMessage; class IMAPSession; + class IMAPIdentity; class IMAPAsyncSession : public Object { public: @@ -87,6 +88,9 @@ namespace mailcore { virtual void setConnectionLogger(ConnectionLogger * logger); virtual ConnectionLogger * connectionLogger(); + virtual IMAPIdentity * serverIdentity(); + virtual IMAPIdentity * clientIdentity(); + virtual IMAPFolderInfoOperation * folderInfoOperation(String * folder); virtual IMAPFolderStatusOperation * folderStatusOperation(String * folder); @@ -127,7 +131,7 @@ namespace mailcore { virtual IMAPFetchNamespaceOperation * fetchNamespaceOperation(); - virtual IMAPIdentityOperation * identityOperation(String * vendor, String * name, String * version); + virtual IMAPIdentityOperation * identityOperation(IMAPIdentity * identity); virtual IMAPOperation * checkAccountOperation(); @@ -160,6 +164,8 @@ namespace mailcore { unsigned int mMaximumConnections; ConnectionLogger * mConnectionLogger; bool mAutomaticConfigurationDone; + IMAPIdentity * mServerIdentity; + IMAPIdentity * mClientIdentity; virtual IMAPAsyncConnection * sessionForFolder(String * folder, bool urgent = false); virtual IMAPAsyncConnection * session(); diff --git a/src/async/imap/MCIMAPIdentityOperation.cc b/src/async/imap/MCIMAPIdentityOperation.cc index 469163d7..0dc035e5 100644 --- a/src/async/imap/MCIMAPIdentityOperation.cc +++ b/src/async/imap/MCIMAPIdentityOperation.cc @@ -10,56 +10,33 @@ #include "MCIMAPSession.h" #include "MCIMAPAsyncConnection.h" +#include "MCIMAPIdentity.h" using namespace mailcore; IMAPIdentityOperation::IMAPIdentityOperation() { - mVendor = NULL; - mName = NULL; - mVersion = NULL; + mClientIdentity = NULL; mServerIdentity = NULL; } IMAPIdentityOperation::~IMAPIdentityOperation() { - MC_SAFE_RELEASE(mVendor); - MC_SAFE_RELEASE(mName); - MC_SAFE_RELEASE(mVersion); + MC_SAFE_RELEASE(mClientIdentity); MC_SAFE_RELEASE(mServerIdentity); } -void IMAPIdentityOperation::setVendor(String * vendor) +void IMAPIdentityOperation::setClientIdentity(IMAPIdentity * identity) { - MC_SAFE_REPLACE_COPY(String, mVendor, vendor); + MC_SAFE_REPLACE_COPY(IMAPIdentity, mClientIdentity, identity); } -String * IMAPIdentityOperation::vendor() +IMAPIdentity * IMAPIdentityOperation::clientIdentity() { - return mVendor; + return mClientIdentity; } -void IMAPIdentityOperation::setName(String * name) -{ - MC_SAFE_REPLACE_COPY(String, mName, name); -} - -String * IMAPIdentityOperation::name() -{ - return mName; -} - -void IMAPIdentityOperation::setVersion(String * version) -{ - MC_SAFE_REPLACE_COPY(String, mVersion, version); -} - -String * IMAPIdentityOperation::version() -{ - return mVersion; -} - -HashMap * IMAPIdentityOperation::serverIdentity() +IMAPIdentity * IMAPIdentityOperation::serverIdentity() { return mServerIdentity; } @@ -67,7 +44,7 @@ HashMap * IMAPIdentityOperation::serverIdentity() void IMAPIdentityOperation::main() { ErrorCode error; - mServerIdentity = session()->session()->identity(mVendor, mName, mVersion, &error); + mServerIdentity = session()->session()->identity(mClientIdentity, &error); MC_SAFE_RETAIN(mServerIdentity); setError(error); } diff --git a/src/async/imap/MCIMAPIdentityOperation.h b/src/async/imap/MCIMAPIdentityOperation.h index 069918cf..16f592a5 100644 --- a/src/async/imap/MCIMAPIdentityOperation.h +++ b/src/async/imap/MCIMAPIdentityOperation.h @@ -16,31 +16,25 @@ namespace mailcore { + class IMAPIdentity; + class IMAPIdentityOperation : public IMAPOperation { public: IMAPIdentityOperation(); virtual ~IMAPIdentityOperation(); - virtual void setVendor(String * vendor); - virtual String * vendor(); - - virtual void setName(String * name); - virtual String * name(); - - virtual void setVersion(String * version); - virtual String * version(); + virtual void setClientIdentity(IMAPIdentity * identity); + virtual IMAPIdentity * clientIdentity(); // Result. - virtual HashMap * serverIdentity(); + virtual IMAPIdentity * serverIdentity(); public: // subclass behavior virtual void main(); private: - String * mVendor; - String * mName; - String * mVersion; - HashMap * mServerIdentity; + IMAPIdentity * mClientIdentity; + IMAPIdentity * mServerIdentity; }; } diff --git a/src/core/imap/MCIMAP.h b/src/core/imap/MCIMAP.h index 0248882a..3faddea1 100644 --- a/src/core/imap/MCIMAP.h +++ b/src/core/imap/MCIMAP.h @@ -14,5 +14,6 @@ #include #include #include +#include #endif diff --git a/src/core/imap/MCIMAPIdentity.cc b/src/core/imap/MCIMAPIdentity.cc new file mode 100644 index 00000000..2e22d539 --- /dev/null +++ b/src/core/imap/MCIMAPIdentity.cc @@ -0,0 +1,97 @@ +// +// MCIMAPIdentity.cpp +// mailcore2 +// +// Created by Hoa V. DINH on 8/24/13. +// Copyright (c) 2013 MailCore. All rights reserved. +// + +#include "MCIMAPIdentity.h" + +using namespace mailcore; + +IMAPIdentity::IMAPIdentity() +{ + init(); +} + +IMAPIdentity::IMAPIdentity(IMAPIdentity * identity) +{ + init(); + mc_foreachhashmapKeyAndValue(String, key, String, value, identity->mValues) { + mValues->setObjectForKey(key, value); + } +} + +void IMAPIdentity::init() +{ + mValues = new HashMap(); +} + +IMAPIdentity::~IMAPIdentity() +{ + MC_SAFE_RELEASE(mValues); +} + +void IMAPIdentity::setVendor(String * vendor) +{ + setInfoForKey(MCSTR("vendor"), vendor); +} + +String * IMAPIdentity::vendor() +{ + return infoForKey(MCSTR("vendor")); +} + +void IMAPIdentity::setName(String * name) +{ + setInfoForKey(MCSTR("name"), name); +} + +String * IMAPIdentity::name() +{ + return infoForKey(MCSTR("name")); +} + +void IMAPIdentity::setVersion(String * version) +{ + setInfoForKey(MCSTR("version"), version); +} + +String * IMAPIdentity::version() +{ + return infoForKey(MCSTR("version")); +} + +Array * IMAPIdentity::allInfoKeys() +{ + return mValues->allKeys(); +} + +String * IMAPIdentity::infoForKey(String * key) +{ + return (String *) mValues->objectForKey(key); +} + +void IMAPIdentity::setInfoForKey(String * key, String * value) +{ + if (value != NULL) { + mValues->setObjectForKey(key, value->copy()->autorelease()); + } + else { + mValues->removeObjectForKey(key); + } +} + +Object * IMAPIdentity::copy() +{ + return new IMAPIdentity(this); +} + +String * IMAPIdentity::description() +{ + return String::stringWithUTF8Format("<%s:%p %s>", className()->UTF8Characters(), this, MCUTF8DESC(mValues)); +} + + + diff --git a/src/core/imap/MCIMAPIdentity.h b/src/core/imap/MCIMAPIdentity.h new file mode 100644 index 00000000..c2565955 --- /dev/null +++ b/src/core/imap/MCIMAPIdentity.h @@ -0,0 +1,54 @@ +// +// MCIMAPIdentity.h +// mailcore2 +// +// Created by Hoa V. DINH on 8/24/13. +// Copyright (c) 2013 MailCore. All rights reserved. +// + +#ifndef __MAILCORE_MCIMAPIDENTITY_H + +#define __MAILCORE_MCIMAPIDENTITY_H + +#include + +#ifdef __cplusplus + +namespace mailcore { + + class IMAPIdentity : public Object { + public: + + IMAPIdentity(); + virtual ~IMAPIdentity(); + + virtual void setVendor(String * vendor); + virtual String * vendor(); + + virtual void setName(String * name); + virtual String * name(); + + virtual void setVersion(String * version); + virtual String * version(); + + virtual Array * allInfoKeys(); + virtual String * infoForKey(String * key); + virtual void setInfoForKey(String * key, String * value); + + public: // subclass behavior + IMAPIdentity(IMAPIdentity * identity); + virtual Object * copy(); + virtual String * description(); + + private: + HashMap * mValues; + + void init(); + }; + +} + +#endif + +#endif + diff --git a/src/core/imap/MCIMAPSession.cc b/src/core/imap/MCIMAPSession.cc index 510f5eda..f08ff91a 100755 --- a/src/core/imap/MCIMAPSession.cc +++ b/src/core/imap/MCIMAPSession.cc @@ -22,6 +22,7 @@ #include "MCHTMLRendererIMAPDataCallback.h" #include "MCHTMLBodyRendererTemplateCallback.h" #include "MCCertificateUtils.h" +#include "MCIMAPIdentity.h" using namespace mailcore; @@ -340,6 +341,8 @@ void IMAPSession::init() mWelcomeString = NULL; mNeedsMboxMailWorkaround = false; mDefaultNamespace = NULL; + mServerIdentity = new IMAPIdentity(); + mClientIdentity = new IMAPIdentity(); mTimeout = 30; mUIDValidity = 0; mUIDNext = 0; @@ -368,6 +371,7 @@ IMAPSession::IMAPSession() IMAPSession::~IMAPSession() { + MC_SAFE_RELEASE(mServerIdentity); MC_SAFE_RELEASE(mHostname); MC_SAFE_RELEASE(mUsername); MC_SAFE_RELEASE(mPassword); @@ -888,6 +892,15 @@ void IMAPSession::login(ErrorCode * pError) IMAPNamespace * defaultNamespace = IMAPNamespace::namespaceWithPrefix(folder->path(), folder->delimiter()); setDefaultNamespace(defaultNamespace); } + + if (isIdentityEnabled()) { + IMAPIdentity * serverIdentity = identity(clientIdentity(), pError); + if (* pError != ErrorNone) { + MCLog("fetch identity failed"); + return; + } + MC_SAFE_REPLACE_RETAIN(IMAPIdentity, mServerIdentity, serverIdentity); + } } else { // TODO: namespace should be shared with other sessions for non automatic namespace. @@ -2749,31 +2762,22 @@ void IMAPSession::disconnect() unsetup(); } -HashMap * IMAPSession::identity(String * vendor, String * name, String * version, ErrorCode * pError) +IMAPIdentity * IMAPSession::identity(IMAPIdentity * clientIdentity, ErrorCode * pError) { connectIfNeeded(pError); if (* pError != ErrorNone) return NULL; struct mailimap_id_params_list * client_identification; - char * dup_name; - char * dup_value; client_identification = mailimap_id_params_list_new_empty(); - if (name != NULL) { - dup_name = strdup("name"); - dup_value = strdup(name->UTF8Characters()); - mailimap_id_params_list_add_name_value(client_identification, dup_name, dup_value); - } - if (version != NULL) { - dup_name = strdup("version"); - dup_value = strdup(version->UTF8Characters()); - mailimap_id_params_list_add_name_value(client_identification, dup_name, dup_value); - } - if (vendor != NULL) { - dup_name = strdup("vendor"); - dup_value = strdup(vendor->UTF8Characters()); + mc_foreacharray(String, key, clientIdentity->allInfoKeys()) { + char * dup_name; + char * dup_value; + + dup_name = strdup(key->UTF8Characters()); + dup_value = strdup(clientIdentity->name()->UTF8Characters()); mailimap_id_params_list_add_name_value(client_identification, dup_name, dup_value); } @@ -2795,7 +2799,7 @@ HashMap * IMAPSession::identity(String * vendor, String * name, String * version return NULL; } - HashMap * result = HashMap::hashMap(); + IMAPIdentity * result = new IMAPIdentity(); clistiter * cur; for(cur = clist_begin(server_identification->idpa_list) ; cur != NULL ; cur = clist_next(cur)) { @@ -2807,12 +2811,13 @@ HashMap * IMAPSession::identity(String * vendor, String * name, String * version String * responseValue; responseKey = String::stringWithUTF8Characters(param->idpa_name); responseValue = String::stringWithUTF8Characters(param->idpa_value); - result->setObjectForKey(responseKey, responseValue); + result->setInfoForKey(responseKey, responseValue); } mailimap_id_params_list_free(server_identification); * pError = ErrorNone; + result->autorelease(); return result; } @@ -2844,6 +2849,16 @@ void IMAPSession::setDefaultNamespace(IMAPNamespace * ns) MC_SAFE_REPLACE_RETAIN(IMAPNamespace, mDefaultNamespace, ns); } +IMAPIdentity * IMAPSession::serverIdentity() +{ + return mServerIdentity; +} + +IMAPIdentity * IMAPSession::clientIdentity() +{ + return mClientIdentity; +} + HashMap * IMAPSession::fetchNamespace(ErrorCode * pError) { HashMap * result; diff --git a/src/core/imap/MCIMAPSession.h b/src/core/imap/MCIMAPSession.h index 842d0866..f4f83e72 100755 --- a/src/core/imap/MCIMAPSession.h +++ b/src/core/imap/MCIMAPSession.h @@ -20,6 +20,7 @@ namespace mailcore { class IMAPProgressCallback; class IMAPSyncResult; class IMAPFolderStatus; + class IMAPIdentity; class IMAPSession : public Object { public: @@ -62,6 +63,9 @@ namespace mailcore { virtual void setDefaultNamespace(IMAPNamespace * ns); virtual IMAPNamespace * defaultNamespace(); + virtual IMAPIdentity * serverIdentity(); + virtual IMAPIdentity * clientIdentity(); + virtual void select(String * folder, ErrorCode * pError); virtual IMAPFolderStatus * folderStatus(String * folder, ErrorCode * pError); @@ -136,7 +140,7 @@ namespace mailcore { virtual void login(ErrorCode * pError); - virtual HashMap * identity(String * vendor, String * name, String * version, ErrorCode * pError); + IMAPIdentity * identity(IMAPIdentity * clientIdentity, ErrorCode * pError); virtual IndexSet * capability(ErrorCode * pError); @@ -199,6 +203,8 @@ namespace mailcore { bool mVoIPEnabled; char mDelimiter; IMAPNamespace * mDefaultNamespace; + IMAPIdentity * mServerIdentity; + IMAPIdentity * mClientIdentity; time_t mTimeout; bool mBodyProgressEnabled; diff --git a/src/objc/imap/MCOIMAP.h b/src/objc/imap/MCOIMAP.h index e2036291..538c3492 100755 --- a/src/objc/imap/MCOIMAP.h +++ b/src/objc/imap/MCOIMAP.h @@ -19,6 +19,7 @@ #import #import #import +#import #import #import #import diff --git a/src/objc/imap/MCOIMAPIdentity.h b/src/objc/imap/MCOIMAPIdentity.h new file mode 100644 index 00000000..32ce8b5c --- /dev/null +++ b/src/objc/imap/MCOIMAPIdentity.h @@ -0,0 +1,42 @@ +// +// MCOIMAPIdentity.h +// mailcore2 +// +// Created by Hoa V. DINH on 8/24/13. +// Copyright (c) 2013 MailCore. All rights reserved. +// + +#ifndef __MAILCORE_MCOIMAPIDENTITY_H_ + +#define __MAILCORE_MCOIMAPIDENTITY_H_ + +#import + +@interface MCOIMAPIdentity : NSObject + +/** Returns a simple identity */ ++ (MCOIMAPIdentity *) identityWithVendor:(NSString *)vendor + name:(NSString *)name + version:(NSString *)version; + +/** Vendor of the IMAP client */ +@property (nonatomic, copy) NSString * vendor; + +/** Name of the IMAP client */ +@property (nonatomic, copy) NSString * name; + +/** Version of the IMAP client */ +@property (nonatomic, copy) NSString * version; + +/** All fields names of the identity of the client */ +- (NSArray *) allInfoKeys; + +/** Set a custom field in the identity */ +- (NSString *) infoForKey:(NSString *)key; + +/** Retrieve a custom field in the identity */ +- (void) setInfo:(NSString *)value forKey:(NSString *)key; + +@end + +#endif diff --git a/src/objc/imap/MCOIMAPIdentity.mm b/src/objc/imap/MCOIMAPIdentity.mm new file mode 100644 index 00000000..0beb092b --- /dev/null +++ b/src/objc/imap/MCOIMAPIdentity.mm @@ -0,0 +1,96 @@ +// +// MCOIMAPIdentity.m +// mailcore2 +// +// Created by Hoa V. DINH on 8/24/13. +// Copyright (c) 2013 MailCore. All rights reserved. +// + +#import "MCOIMAPIdentity.h" +#import "NSObject+MCO.h" +#import "NSString+MCO.h" + +#include "MCIMAPIdentity.h" + +#define nativeType mailcore::IMAPIdentity + +@implementation MCOIMAPIdentity { + mailcore::IMAPIdentity * _nativeIdentity; +} + ++ (void) load +{ + MCORegisterClass(self, &typeid(nativeType)); +} + +- (id) initWithMCIdentity:(mailcore::IMAPIdentity *)identity +{ + self = [super init]; + + identity->retain(); + _nativeIdentity = identity; + + return self; +} + +- (void) dealloc +{ + MC_SAFE_RELEASE(_nativeIdentity); + [super dealloc]; +} + ++ (NSObject *) mco_objectWithMCObject:(mailcore::Object *)object +{ + mailcore::IMAPIdentity * identity = (mailcore::IMAPIdentity *) object; + return [[[self alloc] initWithMCIdentity:identity] autorelease]; +} + +- (mailcore::Object *) mco_mcObject +{ + return _nativeIdentity; +} + +- (id) copyWithZone:(NSZone *)zone +{ + nativeType * nativeObject = (nativeType *) [self mco_mcObject]->copy(); + id result = [[self class] mco_objectWithMCObject:nativeObject]; + MC_SAFE_RELEASE(nativeObject); + return [result retain]; +} + +- (NSString *) description +{ + return MCO_OBJC_BRIDGE_GET(description); +} + +MCO_OBJC_SYNTHESIZE_STRING(setVendor, vendor) +MCO_OBJC_SYNTHESIZE_STRING(setName, name) +MCO_OBJC_SYNTHESIZE_STRING(setVersion, version) + +- (NSArray *) allInfoKeys +{ + return MCO_OBJC_BRIDGE_GET(allInfoKeys); +} + +- (NSString *) infoForKey:(NSString *)key +{ + return MCO_TO_OBJC(MCO_NATIVE_INSTANCE->infoForKey([key mco_mcString])); +} + +- (void) setInfo:(NSString *)value forKey:(NSString *)key +{ + MCO_NATIVE_INSTANCE->setInfoForKey([key mco_mcString], [value mco_mcString]); +} + ++ (MCOIMAPIdentity *) identityWithVendor:(NSString *)vendor + name:(NSString *)name + version:(NSString *)version +{ + MCOIMAPIdentity * identity = [[[MCOIMAPIdentity alloc] init] autorelease]; + [identity setVendor:vendor]; + [identity setName:name]; + [identity setVersion:version]; + return identity; +} + +@end diff --git a/src/objc/imap/MCOIMAPSession.h b/src/objc/imap/MCOIMAPSession.h index e92a0636..66b76276 100755 --- a/src/objc/imap/MCOIMAPSession.h +++ b/src/objc/imap/MCOIMAPSession.h @@ -32,6 +32,7 @@ @class MCOIMAPQuotaOperation; @class MCOIMAPMessageRenderingOperation; @class MCOIMAPMessage; +@class MCOIMAPIdentity; /** This is the main IMAP class from which all operations are created @@ -82,6 +83,12 @@ /** The default namespace. */ @property (nonatomic, strong) MCOIMAPNamespace * defaultNamespace; +/** The identity of the IMAP client. */ +@property (nonatomic, strong, readonly) MCOIMAPIdentity * clientIdentity; + +/** The identity of the IMAP server. */ +@property (nonatomic, strong, readonly) MCOIMAPIdentity * serverIdentity; + /** 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 @@ -469,17 +476,13 @@ /** Returns an operation to send the client or get the server identity. - MCOIMAPIdentityOperation * op = [session identityOperationWithVendor:@"Mozilla" - name:@"Thunderbird" - version:@"17.0.5"]; - [op start:^(NSError * error, NSDictionary * serverIdentity) { + MCOIMAPIdentity * identity = [MCOIMAPIdentity identityWithVendor:@"Mozilla" name:@"Thunderbird" version:@"17.0.5"]; + MCOIMAPIdentityOperation * op = [session identityOperationWithClientIdentity:identity]; + [op start:^(NSError * error, MCOIMAPIdentity * serverIdentity) { ... }]; */ -- (MCOIMAPIdentityOperation *) identityOperationWithVendor:(NSString *)vendor - name:(NSString *)name - version:(NSString *)version; - +- (MCOIMAPIdentityOperation *) identityOperationWithClientIdentity:(MCOIMAPIdentity *)identity; /** Returns an operation that will check whether the IMAP account is valid. diff --git a/src/objc/imap/MCOIMAPSession.mm b/src/objc/imap/MCOIMAPSession.mm index b3584f4d..ce814435 100755 --- a/src/objc/imap/MCOIMAPSession.mm +++ b/src/objc/imap/MCOIMAPSession.mm @@ -15,6 +15,7 @@ #import "MCOIMAPFetchFoldersOperation.h" #import "MCOIMAPBaseOperation+Private.h" #import "MCOIMAPMessageRenderingOperation.h" +#import "MCOIMAPIdentity.h" #import "MCOUtils.h" @@ -99,6 +100,16 @@ MCO_OBJC_SYNTHESIZE_SCALAR(unsigned int, unsigned int, setMaximumConnections, ma return MCO_TO_OBJC(_session->defaultNamespace()); } +- (MCOIMAPIdentity *) clientIdentity +{ + return MCO_OBJC_BRIDGE_GET(clientIdentity); +} + +- (MCOIMAPIdentity *) serverIdentity +{ + return MCO_OBJC_BRIDGE_GET(serverIdentity); +} + - (void) setConnectionLogger:(MCOConnectionLogger)connectionLogger { [_connectionLogger release]; @@ -339,13 +350,9 @@ MCO_OBJC_SYNTHESIZE_SCALAR(unsigned int, unsigned int, setMaximumConnections, ma return MCO_TO_OBJC_OP(coreOp); } -- (MCOIMAPIdentityOperation *) identityOperationWithVendor:(NSString *)vendor - name:(NSString *)name - version:(NSString *)version +- (MCOIMAPIdentityOperation *) identityOperationWithClientIdentity:(MCOIMAPIdentity *)identity { - IMAPIdentityOperation * coreOp = MCO_NATIVE_INSTANCE->identityOperation([vendor mco_mcString], - [name mco_mcString], - [version mco_mcString]); + IMAPIdentityOperation * coreOp = MCO_NATIVE_INSTANCE->identityOperation(MCO_FROM_OBJC(IMAPIdentity, identity)); return MCO_TO_OBJC_OP(coreOp); } -- cgit v1.2.3 From f8ab0cc697223156e7136d85ecf9f02f1889cb6d Mon Sep 17 00:00:00 2001 From: "Hoa V. DINH" Date: Sat, 24 Aug 2013 22:38:07 -0700 Subject: Fixed #196: callback to notify when operations are running or not --- src/async/imap/MCIMAPAsyncConnection.cc | 19 ++++++++- src/async/imap/MCIMAPAsyncConnection.h | 4 ++ src/async/imap/MCIMAPAsyncSession.cc | 40 ++++++++++++++++++ src/async/imap/MCIMAPAsyncSession.h | 10 ++++- src/async/pop/MCPOPAsyncSession.cc | 4 +- src/async/smtp/MCSMTPAsyncSession.cc | 4 +- src/core/basetypes/MCOperationQueue.cc | 4 +- src/core/basetypes/MCOperationQueueCallback.h | 4 +- src/objc/abstract/MCOConstants.h | 5 +++ src/objc/imap/MCOIMAPSession.h | 19 +++++++++ src/objc/imap/MCOIMAPSession.mm | 61 ++++++++++++++++++++++++--- 11 files changed, 156 insertions(+), 18 deletions(-) diff --git a/src/async/imap/MCIMAPAsyncConnection.cc b/src/async/imap/MCIMAPAsyncConnection.cc index 8fddd237..d1322687 100755 --- a/src/async/imap/MCIMAPAsyncConnection.cc +++ b/src/async/imap/MCIMAPAsyncConnection.cc @@ -50,12 +50,16 @@ namespace mailcore { virtual ~IMAPOperationQueueCallback() { } - virtual void queueStartRunning(OperationQueue * queue) { + virtual void queueStartRunning() { + mConnection->setQueueRunning(true); + mConnection->owner()->operationRunningStateChanged(); mConnection->queueStartRunning(); } - virtual void queueStoppedRunning(OperationQueue * queue) { + virtual void queueStoppedRunning() { + mConnection->setQueueRunning(false); mConnection->tryAutomaticDisconnect(); + mConnection->owner()->operationRunningStateChanged(); mConnection->queueStoppedRunning(); } @@ -96,6 +100,7 @@ IMAPAsyncConnection::IMAPAsyncConnection() pthread_mutex_init(&mConnectionLoggerLock, NULL); mInternalLogger = new IMAPConnectionLogger(this); mAutomaticConfigurationEnabled = true; + mQueueRunning = false; } IMAPAsyncConnection::~IMAPAsyncConnection() @@ -653,3 +658,13 @@ bool IMAPAsyncConnection::isAutomaticConfigurationEnabled() { return mAutomaticConfigurationEnabled; } + +bool IMAPAsyncConnection::isQueueRunning() +{ + return mQueueRunning; +} + +void IMAPAsyncConnection::setQueueRunning(bool running) +{ + mQueueRunning = running; +} diff --git a/src/async/imap/MCIMAPAsyncConnection.h b/src/async/imap/MCIMAPAsyncConnection.h index 16f9721e..9f1b9d47 100755 --- a/src/async/imap/MCIMAPAsyncConnection.h +++ b/src/async/imap/MCIMAPAsyncConnection.h @@ -146,6 +146,7 @@ namespace mailcore { IMAPConnectionLogger * mInternalLogger; pthread_mutex_t mConnectionLoggerLock; bool mAutomaticConfigurationEnabled; + bool mQueueRunning; virtual void tryAutomaticDisconnectAfterDelay(void * context); virtual IMAPMessageRenderingOperation * renderingOperation(IMAPMessage * message, @@ -169,6 +170,9 @@ namespace mailcore { virtual IMAPAsyncSession * owner(); virtual void logConnection(ConnectionLogType logType, Data * buffer); + + virtual bool isQueueRunning(); + virtual void setQueueRunning(bool running); }; } diff --git a/src/async/imap/MCIMAPAsyncSession.cc b/src/async/imap/MCIMAPAsyncSession.cc index 7986cb0b..5fe9a61b 100755 --- a/src/async/imap/MCIMAPAsyncSession.cc +++ b/src/async/imap/MCIMAPAsyncSession.cc @@ -40,6 +40,7 @@ IMAPAsyncSession::IMAPAsyncSession() mAutomaticConfigurationDone = false; mServerIdentity = new IMAPIdentity(); mClientIdentity = new IMAPIdentity(); + mOperationQueueCallback = NULL; } IMAPAsyncSession::~IMAPAsyncSession() @@ -513,3 +514,42 @@ void IMAPAsyncSession::automaticConfigurationDone(IMAPSession * session) setDefaultNamespace(session->defaultNamespace()); mAutomaticConfigurationDone = true; } + +void IMAPAsyncSession::setOperationQueueCallback(OperationQueueCallback * callback) +{ + mOperationQueueCallback = callback; +} + +OperationQueueCallback * IMAPAsyncSession::operationQueueCallback() +{ + return mOperationQueueCallback; +} + +bool IMAPAsyncSession::isOperationQueueRunning() +{ + return mQueueRunning; +} + +void IMAPAsyncSession::operationRunningStateChanged() +{ + bool isRunning = false; + for(unsigned int i = 0 ; i < mSessions->count() ; i ++) { + IMAPAsyncConnection * currentSession = (IMAPAsyncConnection *) mSessions->objectAtIndex(i); + if (currentSession->isQueueRunning()){ + isRunning = true; + break; + } + } + if (mQueueRunning == isRunning) { + return; + } + mQueueRunning = isRunning; + if (mOperationQueueCallback != NULL) { + if (isRunning) { + mOperationQueueCallback->queueStartRunning(); + } + else { + mOperationQueueCallback->queueStoppedRunning(); + } + } +} \ No newline at end of file diff --git a/src/async/imap/MCIMAPAsyncSession.h b/src/async/imap/MCIMAPAsyncSession.h index c5ea5fb5..10af928d 100755 --- a/src/async/imap/MCIMAPAsyncSession.h +++ b/src/async/imap/MCIMAPAsyncSession.h @@ -38,6 +38,7 @@ namespace mailcore { class IMAPMessage; class IMAPSession; class IMAPIdentity; + class OperationQueueCallback; class IMAPAsyncSession : public Object { public: @@ -88,6 +89,10 @@ namespace mailcore { virtual void setConnectionLogger(ConnectionLogger * logger); virtual ConnectionLogger * connectionLogger(); + virtual void setOperationQueueCallback(OperationQueueCallback * callback); + virtual OperationQueueCallback * operationQueueCallback(); + virtual bool isOperationQueueRunning(); + virtual IMAPIdentity * serverIdentity(); virtual IMAPIdentity * clientIdentity(); @@ -145,7 +150,8 @@ namespace mailcore { public: // private virtual void automaticConfigurationDone(IMAPSession * session); - + virtual void operationRunningStateChanged(); + private: Array * mSessions; @@ -166,6 +172,8 @@ namespace mailcore { bool mAutomaticConfigurationDone; IMAPIdentity * mServerIdentity; IMAPIdentity * mClientIdentity; + bool mQueueRunning; + OperationQueueCallback * mOperationQueueCallback; virtual IMAPAsyncConnection * sessionForFolder(String * folder, bool urgent = false); virtual IMAPAsyncConnection * session(); diff --git a/src/async/pop/MCPOPAsyncSession.cc b/src/async/pop/MCPOPAsyncSession.cc index bfabc847..f5334542 100644 --- a/src/async/pop/MCPOPAsyncSession.cc +++ b/src/async/pop/MCPOPAsyncSession.cc @@ -29,11 +29,11 @@ namespace mailcore { virtual ~POPOperationQueueCallback() { } - virtual void queueStartRunning(OperationQueue * queue) { + virtual void queueStartRunning() { mSession->retain(); } - virtual void queueStoppedRunning(OperationQueue * queue) { + virtual void queueStoppedRunning() { mSession->release(); } diff --git a/src/async/smtp/MCSMTPAsyncSession.cc b/src/async/smtp/MCSMTPAsyncSession.cc index 4da41b5d..605f267a 100644 --- a/src/async/smtp/MCSMTPAsyncSession.cc +++ b/src/async/smtp/MCSMTPAsyncSession.cc @@ -19,11 +19,11 @@ namespace mailcore { virtual ~SMTPOperationQueueCallback() { } - virtual void queueStartRunning(OperationQueue * queue) { + virtual void queueStartRunning() { mSession->retain(); } - virtual void queueStoppedRunning(OperationQueue * queue) { + virtual void queueStoppedRunning() { mSession->tryAutomaticDisconnect(); mSession->release(); } diff --git a/src/core/basetypes/MCOperationQueue.cc b/src/core/basetypes/MCOperationQueue.cc index c20cb907..2c00f930 100644 --- a/src/core/basetypes/MCOperationQueue.cc +++ b/src/core/basetypes/MCOperationQueue.cc @@ -166,7 +166,7 @@ void OperationQueue::stoppedOnMainThread(void * context) mStarted = false; if (mCallback) { - mCallback->queueStoppedRunning(this); + mCallback->queueStoppedRunning(); } release(); // (2) @@ -180,7 +180,7 @@ void OperationQueue::startThread() return; if (mCallback) { - mCallback->queueStartRunning(this); + mCallback->queueStartRunning(); } retain(); // (3) diff --git a/src/core/basetypes/MCOperationQueueCallback.h b/src/core/basetypes/MCOperationQueueCallback.h index 605de030..367888bb 100644 --- a/src/core/basetypes/MCOperationQueueCallback.h +++ b/src/core/basetypes/MCOperationQueueCallback.h @@ -15,8 +15,8 @@ namespace mailcore { class OperationQueueCallback { public: - virtual void queueStartRunning(OperationQueue * queue) {} - virtual void queueStoppedRunning(OperationQueue * queue) {} + virtual void queueStartRunning() {} + virtual void queueStoppedRunning() {} }; } diff --git a/src/objc/abstract/MCOConstants.h b/src/objc/abstract/MCOConstants.h index 0bdf9af6..0e13f986 100644 --- a/src/objc/abstract/MCOConstants.h +++ b/src/objc/abstract/MCOConstants.h @@ -358,4 +358,9 @@ typedef enum { */ typedef void (^MCOConnectionLogger)(void * connectionID, MCOConnectionLogType type, NSData * data); +/** + It's called when asynchronous operations stop/start running. + */ +typedef void (^MCOOperationQueueRunningChangeBlock)(void); + #endif diff --git a/src/objc/imap/MCOIMAPSession.h b/src/objc/imap/MCOIMAPSession.h index 66b76276..e63e1745 100755 --- a/src/objc/imap/MCOIMAPSession.h +++ b/src/objc/imap/MCOIMAPSession.h @@ -109,6 +109,25 @@ */ @property (nonatomic, copy) MCOConnectionLogger connectionLogger; +/** + The value will be YES when asynchronous operations are running, else it will return NO. +*/ +@property (nonatomic, assign, readonly, getter=isOperationQueueRunning) BOOL operationQueueRunning; + +/** + Sets operation running callback. It will be called when operations start or stop running. + + [session setOperationQueueRunningChangeBlock:^{ + if ([session isOperationQueueRunning]) { + ... + } + else { + ... + } + }]; +*/ +@property (nonatomic, copy) MCOOperationQueueRunningChangeBlock operationQueueRunningChangeBlock; + /** @name Folder Operations */ /** diff --git a/src/objc/imap/MCOIMAPSession.mm b/src/objc/imap/MCOIMAPSession.mm index ce814435..8b4bb363 100755 --- a/src/objc/imap/MCOIMAPSession.mm +++ b/src/objc/imap/MCOIMAPSession.mm @@ -22,19 +22,20 @@ #import #include "MCIMAPMessageRenderingOperation.h" - +#include "MCOperationQueueCallback.h" using namespace mailcore; @interface MCOIMAPSession () - (void) _logWithSender:(void *)sender connectionType:(MCOConnectionLogType)logType data:(NSData *)data; +- (void) _queueRunningChanged; @end -class MCOIMAPConnectionLoggerBridge : public Object, public ConnectionLogger { +class MCOIMAPCallbackBridge : public Object, public ConnectionLogger, public OperationQueueCallback { public: - MCOIMAPConnectionLoggerBridge(MCOIMAPSession * session) + MCOIMAPCallbackBridge(MCOIMAPSession * session) { mSession = session; } @@ -44,6 +45,16 @@ public: [mSession _logWithSender:sender connectionType:(MCOConnectionLogType)logType data:MCO_TO_OBJC(data)]; } + virtual void queueStartRunning() + { + [mSession _queueRunningChanged]; + } + + virtual void queueStoppedRunning() + { + [mSession _queueRunningChanged]; + } + private: MCOIMAPSession * mSession; }; @@ -51,7 +62,8 @@ private: @implementation MCOIMAPSession { IMAPAsyncSession * _session; MCOConnectionLogger _connectionLogger; - MCOIMAPConnectionLoggerBridge * _loggerBridge; + MCOIMAPCallbackBridge * _callbackBridge; + MCOOperationQueueRunningChangeBlock _operationQueueRunningChangeBlock; } #define nativeType mailcore::IMAPAsyncSession @@ -65,13 +77,17 @@ private: self = [super init]; _session = new IMAPAsyncSession(); - _loggerBridge = new MCOIMAPConnectionLoggerBridge(self); + _callbackBridge = new MCOIMAPCallbackBridge(self); + _session->setOperationQueueCallback(_callbackBridge); return self; } - (void)dealloc { - MC_SAFE_RELEASE(_loggerBridge); + _session->setConnectionLogger(NULL); + _session->setOperationQueueCallback(NULL); + MC_SAFE_RELEASE(_callbackBridge); + [_operationQueueRunningChangeBlock release]; [_connectionLogger release]; _session->release(); [super dealloc]; @@ -116,7 +132,7 @@ MCO_OBJC_SYNTHESIZE_SCALAR(unsigned int, unsigned int, setMaximumConnections, ma _connectionLogger = [connectionLogger copy]; if (_connectionLogger != nil) { - _session->setConnectionLogger(_loggerBridge); + _session->setConnectionLogger(_callbackBridge); } else { _session->setConnectionLogger(NULL); @@ -128,6 +144,24 @@ MCO_OBJC_SYNTHESIZE_SCALAR(unsigned int, unsigned int, setMaximumConnections, ma return _connectionLogger; } +- (void) setOperationQueueRunningChangeBlock:(MCOOperationQueueRunningChangeBlock)operationQueueRunningChangeBlock +{ + [_operationQueueRunningChangeBlock release]; + _operationQueueRunningChangeBlock = [operationQueueRunningChangeBlock copy]; + + if (_operationQueueRunningChangeBlock != nil) { + _session->setOperationQueueCallback(_callbackBridge); + } + else { + _session->setOperationQueueCallback(NULL); + } +} + +- (MCOOperationQueueRunningChangeBlock) operationQueueRunningChangeBlock +{ + return _operationQueueRunningChangeBlock; +} + #pragma mark - Operations #define MCO_TO_OBJC_OP(op) [self _objcOperationFromNativeOp:op]; @@ -407,4 +441,17 @@ MCO_OBJC_SYNTHESIZE_SCALAR(unsigned int, unsigned int, setMaximumConnections, ma return MCO_TO_OBJC_OP(coreOp); } +- (void) _queueRunningChanged +{ + if (_operationQueueRunningChangeBlock == NULL) + return; + + _operationQueueRunningChangeBlock(); +} + +- (BOOL) isOperationQueueRunning +{ + return _session->isOperationQueueRunning(); +} + @end -- cgit v1.2.3 From 8c339bb4bd58f21063b41ba797bf513e13f4f576 Mon Sep 17 00:00:00 2001 From: "Hoa V. DINH" Date: Sat, 24 Aug 2013 23:27:18 -0700 Subject: Removed references to ICU --- tests/test-all.mm | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/tests/test-all.mm b/tests/test-all.mm index 255e518a..2d6fe30b 100644 --- a/tests/test-all.mm +++ b/tests/test-all.mm @@ -8,9 +8,6 @@ #include "test-all.h" -#include -#include -#include #include extern "C" { @@ -347,8 +344,8 @@ void testObjC() void testAll() { - u_setDataDirectory("/usr/local/share/icu"); - + mailcore::setICUDataDirectory(MCSTR("/usr/local/share/icu")); + email = MCSTR("email@gmail.com"); password = MCSTR("MyP4ssw0rd"); displayName = MCSTR("My Email"); -- cgit v1.2.3 From 4b7c5e2455c9312a11a6f93678e99b774df00c31 Mon Sep 17 00:00:00 2001 From: "Hoa V. DINH" Date: Sat, 24 Aug 2013 23:28:52 -0700 Subject: Fixed CMake build --- CMakeLists.txt | 6 ++++++ src/cmake/async.cmake | 1 + src/cmake/core.cmake | 8 ++++++++ src/cmake/objc.cmake | 32 +++++++++++++++++--------------- src/cmake/public-headers.cmake | 4 ++++ 5 files changed, 36 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a70ccf5d..bbdf85dd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,10 @@ cmake_minimum_required (VERSION 2.6) project (mailcore2) +IF(APPLE) + set(CMAKE_CXX__FLAGS "-std=c++11 -stdlib=libc++") + set(CMAKE_EXE_LINKER_FLAGS "-lc++ -stdlib=libc++") +ENDIF() + add_subdirectory (src) +add_subdirectory (tests) diff --git a/src/cmake/async.cmake b/src/cmake/async.cmake index 8b4857ea..a002d7c5 100644 --- a/src/cmake/async.cmake +++ b/src/cmake/async.cmake @@ -21,6 +21,7 @@ set(async_imap_files async/imap/MCIMAPIdleOperation.cc async/imap/MCIMAPMessageRenderingOperation.cc async/imap/MCIMAPOperation.cc + async/imap/MCIMAPQuotaOperation.cc async/imap/MCIMAPRenameFolderOperation.cc async/imap/MCIMAPSearchOperation.cc async/imap/MCIMAPStoreFlagsOperation.cc diff --git a/src/cmake/core.cmake b/src/cmake/core.cmake index f2678ad1..a7ba18c9 100644 --- a/src/cmake/core.cmake +++ b/src/cmake/core.cmake @@ -21,6 +21,7 @@ set(basetypes_files core/basetypes/MCArray.cc core/basetypes/MCAssert.c core/basetypes/MCAutoreleasePool.cc + core/basetypes/MCBase64.c core/basetypes/MCConnectionLoggerUtils.cc core/basetypes/MCData.cc core/basetypes/MCHash.cc @@ -46,6 +47,7 @@ set(basetypes_files set(imap_files core/imap/MCIMAPFolder.cc core/imap/MCIMAPFolderStatus.cc + core/imap/MCIMAPIdentity.cc core/imap/MCIMAPMessage.cc core/imap/MCIMAPMessagePart.cc core/imap/MCIMAPMultipart.cc @@ -99,6 +101,10 @@ set(zip_files core/zip/MiniZip/zip.c ) +set(security_files + core/security/MCCertificateUtils.cc +) + set(core_files ${basetypes_files} ${abstract_files} @@ -106,6 +112,7 @@ set(core_files ${pop_files} ${renderer_files} ${rfc822_files} + ${security_files} ${smtp_files} ${zip_files} ) @@ -121,6 +128,7 @@ set(core_includes ${CMAKE_CURRENT_SOURCE_DIR}/core/provider ${CMAKE_CURRENT_SOURCE_DIR}/core/renderer ${CMAKE_CURRENT_SOURCE_DIR}/core/rfc822 + ${CMAKE_CURRENT_SOURCE_DIR}/core/security ${CMAKE_CURRENT_SOURCE_DIR}/core/smtp ${CMAKE_CURRENT_SOURCE_DIR}/core/zip ${CMAKE_CURRENT_SOURCE_DIR}/core/zip/MiniZip diff --git a/src/cmake/objc.cmake b/src/cmake/objc.cmake index 57a8c317..e3e461c9 100644 --- a/src/cmake/objc.cmake +++ b/src/cmake/objc.cmake @@ -1,6 +1,6 @@ # Files to build -set(async_objc_abstract +set(objc_abstract_files objc/abstract/MCOAbstractMessage.mm objc/abstract/MCOAbstractMessagePart.mm objc/abstract/MCOAbstractMessageRendererCallback.mm @@ -10,7 +10,7 @@ set(async_objc_abstract objc/abstract/MCOMessageHeader.mm ) -set(async_objc_imap +set(objc_imap_files objc/imap/MCOIMAPAppendMessageOperation.mm objc/imap/MCOIMAPBaseOperation.mm objc/imap/MCOIMAPCapabilityOperation.mm @@ -22,8 +22,9 @@ set(async_objc_imap objc/imap/MCOIMAPFolder.mm objc/imap/MCOIMAPFolderInfo.m objc/imap/MCOIMAPFolderInfoOperation.mm - objc/imap/MCOIMAPFolderStatus.m + objc/imap/MCOIMAPFolderStatus.mm objc/imap/MCOIMAPFolderStatusOperation.mm + objc/imap/MCOIMAPIdentity.mm objc/imap/MCOIMAPIdentityOperation.mm objc/imap/MCOIMAPIdleOperation.mm objc/imap/MCOIMAPMessage.mm @@ -34,12 +35,13 @@ set(async_objc_imap objc/imap/MCOIMAPNamespaceItem.mm objc/imap/MCOIMAPOperation.mm objc/imap/MCOIMAPPart.mm + objc/imap/MCOIMAPQuotaOperation.mm objc/imap/MCOIMAPSearchExpression.mm objc/imap/MCOIMAPSearchOperation.mm objc/imap/MCOIMAPSession.mm ) -set(async_objc_pop +set(objc_pop_files objc/pop/MCOPOPFetchHeaderOperation.mm objc/pop/MCOPOPFetchMessageOperation.mm objc/pop/MCOPOPFetchMessagesOperation.mm @@ -48,13 +50,13 @@ set(async_objc_pop objc/pop/MCOPOPSession.mm ) -set(async_objc_provider +set(objc_provider_files objc/provider/MCOMailProvider.mm objc/provider/MCOMailProvidersManager.mm objc/provider/MCONetService.mm ) -set(async_objc_rfc822 +set(objc_rfc822_files objc/rfc822/MCOAttachment.mm objc/rfc822/MCOMessageBuilder.mm objc/rfc822/MCOMessageParser.mm @@ -62,13 +64,13 @@ set(async_objc_rfc822 objc/rfc822/MCOMultipart.mm ) -set(async_objc_smtp +set(objc_smtp_files objc/smtp/MCOSMTPOperation.mm objc/smtp/MCOSMTPSendOperation.mm objc/smtp/MCOSMTPSession.mm ) -set(async_objc_utils +set(objc_utils_files objc/utils/MCOIndexSet.mm objc/utils/MCOObjectWrapper.mm objc/utils/MCOOperation.mm @@ -83,13 +85,13 @@ set(async_objc_utils ) IF(APPLE) -set(async_objc - ${async_objc_abstract} - ${async_objc_imap} - ${async_objc_pop} - ${async_objc_rfc822} - ${async_objc_smtp} - ${async_objc_utils} +set(objc_files + ${objc_abstract_files} + ${objc_imap_files} + ${objc_pop_files} + ${objc_rfc822_files} + ${objc_smtp_files} + ${objc_utils_files} ) ENDIF() diff --git a/src/cmake/public-headers.cmake b/src/cmake/public-headers.cmake index 41409f59..8395072a 100644 --- a/src/cmake/public-headers.cmake +++ b/src/cmake/public-headers.cmake @@ -47,6 +47,7 @@ core/imap/MCIMAPSearchExpression.h core/imap/MCIMAPSession.h core/imap/MCIMAPSyncResult.h core/imap/MCIMAPFolderStatus.h +core/imap/MCIMAPIdentity.h core/pop/MCPOP.h core/pop/MCPOPMessageInfo.h core/pop/MCPOPProgressCallback.h @@ -88,6 +89,7 @@ async/imap/MCIMAPSearchOperation.h async/imap/MCIMAPFetchNamespaceOperation.h async/imap/MCIMAPIdentityOperation.h async/imap/MCIMAPCapabilityOperation.h +async/imap/MCIMAPQuotaOperation.h async/imap/MCIMAPOperationCallback.h async/imap/MCIMAPMessageRenderingOperation.h async/pop/MCAsyncPOP.h @@ -131,6 +133,7 @@ objc/imap/MCOIMAPMessagePart.h objc/imap/MCOIMAPMultipart.h objc/imap/MCOIMAPNamespace.h objc/imap/MCOIMAPNamespaceItem.h +objc/imap/MCOIMAPIdentity.h objc/imap/MCOIMAPPart.h objc/imap/MCOIMAPFolderInfoOperation.h objc/imap/MCOIMAPFolderInfo.h @@ -145,6 +148,7 @@ objc/imap/MCOIMAPIdleOperation.h objc/imap/MCOIMAPFetchNamespaceOperation.h objc/imap/MCOIMAPIdentityOperation.h objc/imap/MCOIMAPCapabilityOperation.h +objc/imap/MCOIMAPQuotaOperation.h objc/imap/MCOIMAPSearchExpression.h objc/imap/MCOIMAPMessageRenderingOperation.h objc/rfc822/MCORFC822.h -- cgit v1.2.3 From 53ed88f0431bf85abcbe314b88165fe38904ba55 Mon Sep 17 00:00:00 2001 From: "Hoa V. DINH" Date: Sat, 24 Aug 2013 23:29:55 -0700 Subject: Added CMake build to travis --- scripts/travis/before-script.sh | 3 ++- scripts/travis/script.sh | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/scripts/travis/before-script.sh b/scripts/travis/before-script.sh index 45b429fa..b8753159 100755 --- a/scripts/travis/before-script.sh +++ b/scripts/travis/before-script.sh @@ -2,4 +2,5 @@ set -e brew update -brew install xctool +#brew install xctool +brew install cmake diff --git a/scripts/travis/script.sh b/scripts/travis/script.sh index d9dfa28b..a786e960 100755 --- a/scripts/travis/script.sh +++ b/scripts/travis/script.sh @@ -16,3 +16,9 @@ echo Building framework for Mac xcodebuild -project build-mac/mailcore2.xcodeproj -sdk macosx10.8 -target "mailcore osx" build > /dev/null echo Link test for Mac xcodebuild -project build-mac/mailcore2.xcodeproj -sdk macosx10.8 -target "tests" build > /dev/null + +echo Testing CMake build +mkdir -p build-cmake +cd build-cmake +cmake .. +make -- cgit v1.2.3 From f01a97df69225b8c185d343b441af7cf06fd0951 Mon Sep 17 00:00:00 2001 From: "Hoa V. DINH" Date: Sat, 24 Aug 2013 23:37:30 -0700 Subject: Added missing CMakeLists.txt --- tests/CMakeLists.txt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 tests/CMakeLists.txt diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 00000000..61fa7120 --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,14 @@ +include_directories(${CMAKE_CURRENT_BINARY_DIR}/../src/include) +link_directories( + ${CMAKE_CURRENT_SOURCE_DIR}/../Externals/ctemplate/lib + ${CMAKE_CURRENT_SOURCE_DIR}/../Externals/icu4c/lib + ${CMAKE_CURRENT_SOURCE_DIR}/../Externals/libetpan/lib +) + +find_library(FOUNDATIONFRAMEWORK NAMES Foundation) +find_library(SECURITYFRAMEWORK NAMES Security) +find_library(CORESERVICESFRAMEWORK NAMES CoreServices) + +add_executable (tests main.mm test-all.mm) +target_link_libraries (tests MailCore z etpan xml2 icudata icui18n icuuc sasl2 iconv tidy ctemplate ssl crypto + ${FOUNDATIONFRAMEWORK} ${SECURITYFRAMEWORK} ${CORESERVICESFRAMEWORK}) -- cgit v1.2.3 From c289501d2631b181f3098540807e97cd93137232 Mon Sep 17 00:00:00 2001 From: "Hoa V. DINH" Date: Sun, 25 Aug 2013 00:58:38 -0700 Subject: Switch to xctool for build. --- .../xcshareddata/xcschemes/mailcore osx.xcscheme | 59 +++++++++++++++ .../xcschemes/static mailcore2 ios.xcscheme | 59 +++++++++++++++ .../xcschemes/static mailcore2 osx.xcscheme | 59 +++++++++++++++ .../xcshareddata/xcschemes/test-ios.xcscheme | 86 ++++++++++++++++++++++ .../xcshareddata/xcschemes/tests.xcscheme | 86 ++++++++++++++++++++++ scripts/travis/script.sh | 12 +-- 6 files changed, 355 insertions(+), 6 deletions(-) create mode 100644 build-mac/mailcore2.xcodeproj/xcshareddata/xcschemes/mailcore osx.xcscheme create mode 100644 build-mac/mailcore2.xcodeproj/xcshareddata/xcschemes/static mailcore2 ios.xcscheme create mode 100644 build-mac/mailcore2.xcodeproj/xcshareddata/xcschemes/static mailcore2 osx.xcscheme create mode 100644 build-mac/mailcore2.xcodeproj/xcshareddata/xcschemes/test-ios.xcscheme create mode 100644 build-mac/mailcore2.xcodeproj/xcshareddata/xcschemes/tests.xcscheme diff --git a/build-mac/mailcore2.xcodeproj/xcshareddata/xcschemes/mailcore osx.xcscheme b/build-mac/mailcore2.xcodeproj/xcshareddata/xcschemes/mailcore osx.xcscheme new file mode 100644 index 00000000..da69f296 --- /dev/null +++ b/build-mac/mailcore2.xcodeproj/xcshareddata/xcschemes/mailcore osx.xcscheme @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/build-mac/mailcore2.xcodeproj/xcshareddata/xcschemes/static mailcore2 ios.xcscheme b/build-mac/mailcore2.xcodeproj/xcshareddata/xcschemes/static mailcore2 ios.xcscheme new file mode 100644 index 00000000..71bb1afe --- /dev/null +++ b/build-mac/mailcore2.xcodeproj/xcshareddata/xcschemes/static mailcore2 ios.xcscheme @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/build-mac/mailcore2.xcodeproj/xcshareddata/xcschemes/static mailcore2 osx.xcscheme b/build-mac/mailcore2.xcodeproj/xcshareddata/xcschemes/static mailcore2 osx.xcscheme new file mode 100644 index 00000000..414b66d8 --- /dev/null +++ b/build-mac/mailcore2.xcodeproj/xcshareddata/xcschemes/static mailcore2 osx.xcscheme @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/build-mac/mailcore2.xcodeproj/xcshareddata/xcschemes/test-ios.xcscheme b/build-mac/mailcore2.xcodeproj/xcshareddata/xcschemes/test-ios.xcscheme new file mode 100644 index 00000000..100c2da6 --- /dev/null +++ b/build-mac/mailcore2.xcodeproj/xcshareddata/xcschemes/test-ios.xcscheme @@ -0,0 +1,86 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/build-mac/mailcore2.xcodeproj/xcshareddata/xcschemes/tests.xcscheme b/build-mac/mailcore2.xcodeproj/xcshareddata/xcschemes/tests.xcscheme new file mode 100644 index 00000000..0cf7361a --- /dev/null +++ b/build-mac/mailcore2.xcodeproj/xcshareddata/xcschemes/tests.xcscheme @@ -0,0 +1,86 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/scripts/travis/script.sh b/scripts/travis/script.sh index a786e960..5d0813ea 100755 --- a/scripts/travis/script.sh +++ b/scripts/travis/script.sh @@ -2,20 +2,20 @@ set -e echo Building library for iPhoneOS -xcodebuild -project build-mac/mailcore2.xcodeproj -sdk iphoneos6.1 -target "static mailcore2 ios" build > /dev/null +xctool -project build-mac/mailcore2.xcodeproj -sdk iphoneos6.1 -scheme "static mailcore2 ios" build echo Building library for iPhoneSimulator -xcodebuild -project build-mac/mailcore2.xcodeproj -sdk iphonesimulator6.1 -target "static mailcore2 ios" build > /dev/null +xctool -project build-mac/mailcore2.xcodeproj -sdk iphonesimulator6.1 -scheme "static mailcore2 ios" build #echo Link test for iPhoneOS #xcodebuild -project build-mac/mailcore2.xcodeproj -sdk iphoneos6.1 -target "test-ios" CODE_SIGN_IDENTITY="" build echo Link test for iPhoneSimulator -xcodebuild -project build-mac/mailcore2.xcodeproj -sdk iphonesimulator6.1 -target "test-ios" build > /dev/null +xctool -project build-mac/mailcore2.xcodeproj -sdk iphonesimulator6.1 -scheme "test-ios" build echo Building library for Mac -xcodebuild -project build-mac/mailcore2.xcodeproj -sdk macosx10.8 -target "static mailcore2 osx" build > /dev/null +xctool -project build-mac/mailcore2.xcodeproj -sdk macosx10.8 -scheme "static mailcore2 osx" build echo Building framework for Mac -xcodebuild -project build-mac/mailcore2.xcodeproj -sdk macosx10.8 -target "mailcore osx" build > /dev/null +xctool -project build-mac/mailcore2.xcodeproj -sdk macosx10.8 -scheme "mailcore osx" build echo Link test for Mac -xcodebuild -project build-mac/mailcore2.xcodeproj -sdk macosx10.8 -target "tests" build > /dev/null +xctool -project build-mac/mailcore2.xcodeproj -sdk macosx10.8 -scheme "tests" build echo Testing CMake build mkdir -p build-cmake -- cgit v1.2.3 From 7166f2e8ba30962af74233fdce2be737fbf62e62 Mon Sep 17 00:00:00 2001 From: "Hoa V. DINH" Date: Sun, 25 Aug 2013 00:59:00 -0700 Subject: Make sure to install xctool before building. --- scripts/travis/before-script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/travis/before-script.sh b/scripts/travis/before-script.sh index b8753159..9799bf0c 100755 --- a/scripts/travis/before-script.sh +++ b/scripts/travis/before-script.sh @@ -2,5 +2,5 @@ set -e brew update -#brew install xctool +brew install xctool brew install cmake -- cgit v1.2.3 From 0d601d61738d482d50653198f0966b866419e9a5 Mon Sep 17 00:00:00 2001 From: "Hoa V. DINH" Date: Sun, 25 Aug 2013 17:30:44 -0700 Subject: Disabled Identity because libetpan support is broken. --- src/core/imap/MCIMAPSession.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/core/imap/MCIMAPSession.cc b/src/core/imap/MCIMAPSession.cc index f08ff91a..7a69b50a 100755 --- a/src/core/imap/MCIMAPSession.cc +++ b/src/core/imap/MCIMAPSession.cc @@ -894,12 +894,14 @@ void IMAPSession::login(ErrorCode * pError) } if (isIdentityEnabled()) { +#if 0 // Disabled while ID is not working. IMAPIdentity * serverIdentity = identity(clientIdentity(), pError); if (* pError != ErrorNone) { MCLog("fetch identity failed"); return; } MC_SAFE_REPLACE_RETAIN(IMAPIdentity, mServerIdentity, serverIdentity); +#endif } } else { -- cgit v1.2.3 From 796decd6f785a5b8eb23f6b229c7109f91c7cf52 Mon Sep 17 00:00:00 2001 From: "Hoa V. DINH" Date: Sun, 25 Aug 2013 18:30:34 -0700 Subject: Update to libetpan df052805726c7825ea7dce127b5df501cbf62238 --- scripts/prepare-libetpan-ios.sh | 2 +- scripts/prepare-libetpan-macos.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/prepare-libetpan-ios.sh b/scripts/prepare-libetpan-ios.sh index 26824e0e..e8b9494c 100755 --- a/scripts/prepare-libetpan-ios.sh +++ b/scripts/prepare-libetpan-ios.sh @@ -10,7 +10,7 @@ else fi url="https://github.com/dinhviethoa/libetpan.git" -rev=75a2e16a23c73ab0cdabb8e5b69b941ded0632f0 +rev=df052805726c7825ea7dce127b5df501cbf62238 pushd `dirname $0` > /dev/null scriptpath=`pwd` diff --git a/scripts/prepare-libetpan-macos.sh b/scripts/prepare-libetpan-macos.sh index b7a1b0bc..071b8fef 100755 --- a/scripts/prepare-libetpan-macos.sh +++ b/scripts/prepare-libetpan-macos.sh @@ -1,7 +1,7 @@ #!/bin/sh url="https://github.com/dinhviethoa/libetpan.git" -rev=75a2e16a23c73ab0cdabb8e5b69b941ded0632f0 +rev=df052805726c7825ea7dce127b5df501cbf62238 pushd `dirname $0` > /dev/null scriptpath=`pwd` -- cgit v1.2.3 From 12d1dd0a938d98b9d21a39a58fcd36f79c6d74c8 Mon Sep 17 00:00:00 2001 From: "Hoa V. DINH" Date: Sun, 25 Aug 2013 18:31:10 -0700 Subject: Enabled back IMAP ID support --- src/core/imap/MCIMAPSession.cc | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/core/imap/MCIMAPSession.cc b/src/core/imap/MCIMAPSession.cc index 7a69b50a..f08ff91a 100755 --- a/src/core/imap/MCIMAPSession.cc +++ b/src/core/imap/MCIMAPSession.cc @@ -894,14 +894,12 @@ void IMAPSession::login(ErrorCode * pError) } if (isIdentityEnabled()) { -#if 0 // Disabled while ID is not working. IMAPIdentity * serverIdentity = identity(clientIdentity(), pError); if (* pError != ErrorNone) { MCLog("fetch identity failed"); return; } MC_SAFE_REPLACE_RETAIN(IMAPIdentity, mServerIdentity, serverIdentity); -#endif } } else { -- cgit v1.2.3 From 4d7da7ed73f51a4cf4525a93801c5adb9af9ebbd Mon Sep 17 00:00:00 2001 From: "Hoa V. DINH" Date: Sun, 25 Aug 2013 19:25:42 -0700 Subject: Fixed #321: fixed -pathForComponents: --- src/core/basetypes/MCArray.cc | 2 +- src/core/basetypes/MCString.cc | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/core/basetypes/MCArray.cc b/src/core/basetypes/MCArray.cc index a59e3648..c4c0fee1 100644 --- a/src/core/basetypes/MCArray.cc +++ b/src/core/basetypes/MCArray.cc @@ -229,7 +229,7 @@ String * Array::componentsJoinedByString(String * delimiter) String * result = String::string(); for(unsigned int i = 0 ; i < count() ; i ++) { Object * obj = objectAtIndex(i); - if (result != 0) { + if (i != 0) { result->appendString(delimiter); } result->appendString(obj->description()); diff --git a/src/core/basetypes/MCString.cc b/src/core/basetypes/MCString.cc index c6b4ae8d..cc3b6e91 100644 --- a/src/core/basetypes/MCString.cc +++ b/src/core/basetypes/MCString.cc @@ -1850,8 +1850,15 @@ Data * String::dataUsingEncoding(const char * charset) Data * data; data = NULL; - CFStringRef encodingName = CFStringCreateWithCString(NULL, charset, kCFStringEncodingUTF8); - CFStringEncoding encoding = CFStringConvertIANACharSetNameToEncoding(encodingName); + CFStringEncoding encoding; + if (strcasecmp(charset, "mutf-7") == 0) { + encoding = kCFStringEncodingUTF7_IMAP; + } + else { + CFStringRef encodingName = CFStringCreateWithCString(NULL, charset, kCFStringEncodingUTF8); + encoding = CFStringConvertIANACharSetNameToEncoding(encodingName); + CFRelease(encodingName); + } CFStringRef cfStr = CFStringCreateWithBytes(NULL, (const UInt8 *) mUnicodeChars, (CFIndex) mLength * sizeof(* mUnicodeChars), kCFStringEncodingUTF16LE, false); if (cfStr != NULL) { @@ -1863,7 +1870,6 @@ Data * String::dataUsingEncoding(const char * charset) } CFRelease(cfStr); } - CFRelease(encodingName); return data; #else -- cgit v1.2.3 From f829b51d1a2c049c24c2bb349b1c13edef12fd42 Mon Sep 17 00:00:00 2001 From: "Hoa V. DINH" Date: Tue, 27 Aug 2013 23:47:46 -0700 Subject: Fixed #271: change attachment name to avoid caching side effect --- src/ui/ios/MCOMessageView.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ui/ios/MCOMessageView.mm b/src/ui/ios/MCOMessageView.mm index e3786bb5..1c541548 100755 --- a/src/ui/ios/MCOMessageView.mm +++ b/src/ui/ios/MCOMessageView.mm @@ -173,7 +173,7 @@ pre {\ void (^replaceImages)(NSError *error) = ^(NSError *error) { NSData * downloadedData = [[self delegate] MCOMessageView:self dataForPartWithUniqueID:partUniqueID]; NSData * previewData = [[self delegate] MCOMessageView:self previewForData:downloadedData isHTMLInlineImage:[MCOCIDURLProtocol isCID:url]]; - NSString * filename = [NSString stringWithFormat:@"%lu", (unsigned long)urlString.hash]; + NSString * filename = [NSString stringWithFormat:@"%u", downloadedData.hash]; NSURL * cacheURL = [self _cacheJPEGImageData:previewData withFilename:filename]; NSDictionary * args = @{ @"URLKey": urlString, @"LocalPathKey": cacheURL.absoluteString }; -- cgit v1.2.3 From f74f96d18d729ddcc9274e028d385e36ac90322e Mon Sep 17 00:00:00 2001 From: "Hoa V. DINH" Date: Wed, 28 Aug 2013 07:40:48 -0700 Subject: Don't install tools before build --- scripts/travis/before-script.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/travis/before-script.sh b/scripts/travis/before-script.sh index 9799bf0c..32b34589 100755 --- a/scripts/travis/before-script.sh +++ b/scripts/travis/before-script.sh @@ -1,6 +1,6 @@ #!/bin/sh set -e -brew update -brew install xctool -brew install cmake +#brew update +#brew install xctool +#brew install cmake -- cgit v1.2.3 From 47a10e080f8746f0aa447b95535011ea38c5341e Mon Sep 17 00:00:00 2001 From: "Hoa V. DINH" Date: Wed, 28 Aug 2013 07:47:45 -0700 Subject: Install CMake anyway --- scripts/travis/before-script.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/travis/before-script.sh b/scripts/travis/before-script.sh index 32b34589..b8753159 100755 --- a/scripts/travis/before-script.sh +++ b/scripts/travis/before-script.sh @@ -1,6 +1,6 @@ #!/bin/sh set -e -#brew update +brew update #brew install xctool -#brew install cmake +brew install cmake -- cgit v1.2.3