Skip to content

Commit

Permalink
Merge pull request #32 from nemomobile-packages/test-account
Browse files Browse the repository at this point in the history
[qmf] Add enablers for credentials checking.
  • Loading branch information
VDVsx committed Apr 9, 2014
2 parents b178ca8 + 931708a commit e52d3a7
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 11 deletions.
11 changes: 11 additions & 0 deletions qmf/src/libraries/qmfclient/ssosessionmanager.cpp
Expand Up @@ -81,6 +81,7 @@ SSOSessionManager::SSOSessionManager(QObject *parent)
_waitForSso(false),
_recreatingSession(false),
_reAuthenticate(false),
_credentialsCheck(false),
_identity(0),
_session(0)
{
Expand Down Expand Up @@ -171,6 +172,8 @@ bool SSOSessionManager::createSsoIdentity(const QMailAccountId &id, const QStrin
return false;
}

_credentialsCheck = account->valueAsBool("credentialsCheck");

// Some plugins stores an identity per service.
// If there is no specific credentials for the specific service than we should check regular credentialsId.
// This allows to store different credentials for incoming and outgoing servers for example.
Expand Down Expand Up @@ -202,6 +205,14 @@ bool SSOSessionManager::createSsoIdentity(const QMailAccountId &id, const QStrin
}
}

/*!
Returns true if credentials checking is being performed for this account, otherwise returns false.
*/
bool SSOSessionManager::checkingCredentials() const
{
return _credentialsCheck;
}

/*!
Set credentials need update if the plugin supports it.
*/
Expand Down
2 changes: 2 additions & 0 deletions qmf/src/libraries/qmfclient/ssosessionmanager.h
Expand Up @@ -65,6 +65,7 @@ class QMF_EXPORT SSOSessionManager : public QObject
void cancel();
bool createSsoIdentity(const QMailAccountId &id,
const QString &serviceType, int serviceAuthentication);
bool checkingCredentials() const;
void credentialsNeedUpdate();
void deleteSsoIdentity();
void recreateSsoIdentity();
Expand Down Expand Up @@ -94,6 +95,7 @@ private slots:
bool _waitForSso;
bool _recreatingSession;
bool _reAuthenticate;
bool _credentialsCheck;
QByteArray _ssoLogin;
QString _authMethod;
QString _authMechanism;
Expand Down
5 changes: 4 additions & 1 deletion qmf/src/plugins/messageservices/imap/imapclient.cpp
Expand Up @@ -793,7 +793,10 @@ void ImapClient::checkCommandResponse(ImapCommand command, OperationStatus statu
// We try only once to recreate the sso identity and relogin,
// in order to allow user interaction if defined by the sso
// plugin.
if (!_loginFailed && _recreateIdentity) {
if (_ssoSessionManager && _ssoSessionManager->checkingCredentials()) {
operationFailed(QMailServiceAction::Status::ErrLoginFailed, _protocol.lastError());
return;
} else if (!_loginFailed && _recreateIdentity) {
_loginFailed = true;
_sendLogin = true;
ssoProcessLogin();
Expand Down
14 changes: 9 additions & 5 deletions qmf/src/plugins/messageservices/pop/popclient.cpp
Expand Up @@ -534,12 +534,16 @@ void PopClient::processResponse(const QString &response)
if (response[0] != '+') {
// Authentication failed
#ifdef USE_ACCOUNTS_QT
if (ssoSessionManager && !loginFailed) {
loginFailed = true;
ssoProcessLogin();
} else {
ssoCredentialsNeedUpdate();
if (ssoSessionManager && ssoSessionManager->checkingCredentials()) {
operationFailed(QMailServiceAction::Status::ErrLoginFailed, "");
} else {
if (ssoSessionManager && !loginFailed) {
loginFailed = true;
ssoProcessLogin();
} else {
ssoCredentialsNeedUpdate();
operationFailed(QMailServiceAction::Status::ErrLoginFailed, "");
}
}
#else
operationFailed(QMailServiceAction::Status::ErrLoginFailed, "");
Expand Down
17 changes: 12 additions & 5 deletions qmf/src/plugins/messageservices/smtp/smtpclient.cpp
Expand Up @@ -610,11 +610,16 @@ void SmtpClient::nextAction(const QString &response)
case SignOnSession:
{
if (loginFailed) {
if (ssoSessionManager) {
sendLogin = true;
ssoSessionManager->recreateSsoIdentity();
} else
if (ssoSessionManager && ssoSessionManager->checkingCredentials()) {
operationFailed(QMailServiceAction::Status::ErrLoginFailed, response);
} else {
if (ssoSessionManager) {
sendLogin = true;
ssoSessionManager->recreateSsoIdentity();
} else {
operationFailed(QMailServiceAction::Status::ErrLoginFailed, response);
}
}
} else {
if (!ssoSessionManager->waitForSso()) {
QByteArray authCmd(SmtpAuthenticator::getAuthentication(config.serviceConfiguration("smtp"), capabilities, ssoLogin));
Expand Down Expand Up @@ -661,7 +666,9 @@ void SmtpClient::nextAction(const QString &response)
operationFailed(QMailServiceAction::Status::ErrConfiguration, response);
} else {
#ifdef USE_ACCOUNTS_QT
if (!loginFailed) {
if (ssoSessionManager && ssoSessionManager->checkingCredentials()) {
operationFailed(QMailServiceAction::Status::ErrLoginFailed, response);
} else if (!loginFailed) {
loginFailed = true;
status = SignOnSession;
nextAction(QString());
Expand Down
3 changes: 3 additions & 0 deletions qmf/src/plugins/messageservices/smtp/smtpservice.cpp
Expand Up @@ -125,7 +125,10 @@ SmtpService::SmtpService(const QMailAccountId &accountId)

_client.setAccount(accountId);

// Don't try to autoconnect on account creation for SSO services
#ifndef USE_ACCOUNTS_QT
fetchCapabilities();
#endif
}

void SmtpService::fetchCapabilities()
Expand Down

0 comments on commit e52d3a7

Please sign in to comment.