diff options
Diffstat (limited to 'src/core/provider/MCAccountValidator.cpp')
-rw-r--r-- | src/core/provider/MCAccountValidator.cpp | 70 |
1 files changed, 65 insertions, 5 deletions
diff --git a/src/core/provider/MCAccountValidator.cpp b/src/core/provider/MCAccountValidator.cpp index 15c3a041..753a0236 100644 --- a/src/core/provider/MCAccountValidator.cpp +++ b/src/core/provider/MCAccountValidator.cpp @@ -60,6 +60,10 @@ void AccountValidator::init() mImapSession = NULL; mPopSession = NULL; mSmtpSession = NULL; + + mImapEnabled = false; + mPopEnabled = false; + mSmtpEnabled = false; } AccountValidator::AccountValidator() @@ -170,9 +174,11 @@ void AccountValidator::resolveMXDone() Array * mxRecords = mResolveMX->mxRecords(); mc_foreacharray(String, mxRecord, mxRecords) { - MailProvider *provider = MailProvidersManager::sharedManager()->providerForMX(mxRecord); - if (provider){ + MailProvider * provider = MailProvidersManager::sharedManager()->providerForMX(mxRecord); + if (provider != NULL){ mProvider = provider; + MC_SAFE_RETAIN(mProvider); + setupServices(); break; } } @@ -180,6 +186,16 @@ void AccountValidator::resolveMXDone() startCheckingHosts(); } +void AccountValidator::setupServices() +{ + mImapServices = mProvider->imapServices(); + MC_SAFE_RETAIN(mImapServices); + mPopServices = mProvider->popServices(); + MC_SAFE_RETAIN(mPopServices); + mSmtpServices = mProvider->smtpServices(); + MC_SAFE_RETAIN(mSmtpServices); +} + void AccountValidator::startCheckingHosts() { if (mProvider != NULL) { @@ -217,7 +233,7 @@ void AccountValidator::startCheckingHosts() void AccountValidator::checkNextHost() { if (mCurrentServiceTested == SERVICE_IMAP) { - if (mCurrentServiceIndex < mImapServices->count()) { + if (mImapEnabled && (mCurrentServiceIndex < mImapServices->count())) { mImapSession = new IMAPAsyncSession(); mImapSession->setUsername(mUsername); mImapSession->setPassword(mPassword); @@ -236,6 +252,10 @@ void AccountValidator::checkNextHost() mOperation->setCallback(this); mOperation->start(); } + else if (mImapEnabled && (mImapServices->count() > 0)) { + mImapServer = NULL; + callback()->operationFinished(this); + } else { mCurrentServiceTested ++; mCurrentServiceIndex = 0; @@ -243,7 +263,7 @@ void AccountValidator::checkNextHost() } } else if (mCurrentServiceTested == SERVICE_POP){ - if (mCurrentServiceIndex < mPopServices->count()) { + if (mPopEnabled && (mCurrentServiceIndex < mPopServices->count())) { mPopSession = new POPAsyncSession(); mPopSession->setUsername(mUsername); mPopSession->setPassword(mPassword); @@ -258,6 +278,10 @@ void AccountValidator::checkNextHost() mOperation->setCallback(this); mOperation->start(); } + else if (mPopEnabled && (mPopServices->count() > 0)) { + mPopServer = NULL; + callback()->operationFinished(this); + } else { mCurrentServiceTested ++; mCurrentServiceIndex = 0; @@ -265,7 +289,7 @@ void AccountValidator::checkNextHost() } } else if (mCurrentServiceTested == SERVICE_SMTP){ - if (mCurrentServiceIndex < mSmtpServices->count()) { + if (mPopEnabled && (mCurrentServiceIndex < mSmtpServices->count())) { mSmtpSession = new SMTPAsyncSession(); mSmtpSession->setUsername(mUsername); mSmtpSession->setPassword(mPassword); @@ -284,6 +308,10 @@ void AccountValidator::checkNextHost() mOperation->setCallback(this); mOperation->start(); } + else if (mPopEnabled && (mSmtpServices->count() > 0)) { + mSmtpServer = NULL; + callback()->operationFinished(this); + } else { mCurrentServiceTested ++; mCurrentServiceIndex = 0; @@ -318,6 +346,7 @@ void AccountValidator::checkNextHostDone() MC_SAFE_RELEASE(mOperation); if (error == ErrorNone) { + mCurrentServiceIndex = 0; mCurrentServiceTested ++; } else { @@ -367,6 +396,37 @@ String * AccountValidator::OAuth2Token() return mOAuth2Token; } +void AccountValidator::setImapEnabled(bool enabled) +{ + mImapEnabled = enabled; +} + +bool AccountValidator::isImapEnabled() +{ + return mImapEnabled; +} + +void AccountValidator::setPopEnabled(bool enabled) +{ + mPopEnabled = enabled; +} + +bool AccountValidator::isPopEnabled() +{ + return mPopEnabled; +} + + +void AccountValidator::setSmtpEnabled(bool enabled) +{ + mSmtpEnabled = enabled; +} + +bool AccountValidator::isSmtpEnabled() +{ + return mSmtpEnabled; +} + void AccountValidator::setImapServices(Array * imapServices) { MC_SAFE_REPLACE_COPY(Array, mImapServices, imapServices); |