Пример #1
0
void AccountState::checkConnectivity()
{
    if (isSignedOut() || _waitingForNewCredentials) {
        return;
    }

    ConnectionValidator * conValidator = new ConnectionValidator(account());
    connect(conValidator, SIGNAL(connectionResult(ConnectionValidator::Status,QStringList)),
            SLOT(slotConnectionValidatorResult(ConnectionValidator::Status,QStringList)));
    if (isConnected()) {
        // Use a small authed propfind as a minimal ping when we're
        // already connected.
        conValidator->checkAuthentication();
    } else {
        // Check the server and then the auth.

#ifdef Q_OS_WIN
        // There seems to be a bug in Qt on Windows where QNAM sometimes stops
        // working correctly after the computer woke up from sleep. See #2895 #2899
        // and #2973.
        // As an attempted workaround, reset the QNAM regularly if the account is
        // disconnected.
        account()->resetNetworkAccessManager();
#endif
        conValidator->checkServerAndAuth();
    }
}
Пример #2
0
void Application::slotCheckConnection()
{
    Account *account = AccountManager::instance()->account();

    if( account ) {
        if (account->state() == Account::InvalidCredidential
                || account->state() == Account::SignedOut) {
            //Do not try to connect if we are logged out
            if (!_userTriggeredConnect) {
                return;
            }
        }

        if (_conValidator)
            _conValidator->deleteLater();
        _conValidator = new ConnectionValidator(account);
        connect( _conValidator, SIGNAL(connectionResult(ConnectionValidator::Status)),
                 this, SLOT(slotConnectionValidatorResult(ConnectionValidator::Status)) );
        _conValidator->checkConnection();

    } else {
        // let gui open the setup wizard
        _gui->slotOpenSettingsDialog( true );

        _checkConnectionTimer.stop(); // don't popup the wizard on interval;
    }
}
Пример #3
0
void DiscoveryConnection::routine() {
  std::vector<core::ServerDiscoveryClusterInfoSPtr> inf;

  if (!connection_) {
    emit connectionResult(false, common::time::current_mstime() - start_time_, "Invalid connection settings", inf);
    return;
  }

  common::Error err = proxy::ServersManager::GetInstance().DiscoveryClusterConnection(connection_, &inf);
  if (err) {
    QString qdesc;
    common::ConvertFromString(err->GetDescription(), &qdesc);
    emit connectionResult(false, common::time::current_mstime() - start_time_, qdesc, inf);
  } else {
    emit connectionResult(true, common::time::current_mstime() - start_time_, translations::trSuccess, inf);
  }
}
Пример #4
0
// status.php could not be loaded.
void ConnectionValidator::slotNoStatusFound(QNetworkReply *reply)
{
    _account->setState(Account::Disconnected);

    // ### TODO
    _errors.append(tr("Unable to connect to %1").arg(_account->url().toString()));
    _errors.append( reply->errorString() );
    _networkError = (reply->error() != QNetworkReply::NoError);
    emit connectionResult( StatusNotFound );

}
Пример #5
0
// status.php could not be loaded.
void ConnectionValidator::slotNoStatusFound(QNetworkReply *reply)
{
    // disconnect from ownCloudInfo
    disconnect( ownCloudInfo::instance(),SIGNAL(ownCloudInfoFound(QString,QString,QString,QString)),
                this, SLOT(slotStatusFound(QString,QString,QString,QString)));

    disconnect( ownCloudInfo::instance(),SIGNAL(noOwncloudFound(QNetworkReply*)),
                this, SLOT(slotNoStatusFound(QNetworkReply*)));

    _errors.append( reply->errorString() );
    emit connectionResult( StatusNotFound );

}
Пример #6
0
void ConnectionValidator::checkConnection()
{
    if( _account ) {
        CheckServerJob *checkJob = new CheckServerJob(_account, false, this);
        checkJob->setIgnoreCredentialFailure(true);
        connect(checkJob, SIGNAL(instanceFound(QUrl,QVariantMap)), SLOT(slotStatusFound(QUrl,QVariantMap)));
        connect(checkJob, SIGNAL(networkError(QNetworkReply*)), SLOT(slotNoStatusFound(QNetworkReply*)));
        checkJob->start();
    } else {
        _errors << tr("No ownCloud account configured");
        emit connectionResult( NotConfigured );
    }
}
Пример #7
0
void ConnectionValidator::checkConnection()
{
    if( ownCloudInfo::instance()->isConfigured() ) {
        connect( ownCloudInfo::instance(),SIGNAL(ownCloudInfoFound(QString,QString,QString,QString)),
                 SLOT(slotStatusFound(QString,QString,QString,QString)));

        connect( ownCloudInfo::instance(),SIGNAL(noOwncloudFound(QNetworkReply*)),
                 SLOT(slotNoStatusFound(QNetworkReply*)));

        // checks for status.php
        ownCloudInfo::instance()->checkInstallation();
    } else {
        emit connectionResult( NotConfigured );
    }
}
Пример #8
0
void ConnectionValidator::slotStatusFound(const QUrl&url, const QVariantMap &info)
{
    // status.php was found.
    qDebug() << "** Application: ownCloud found: "
             << url << " with version "
             << CheckServerJob::versionString(info)
             << "(" << CheckServerJob::version(info) << ")";
    // now check the authentication

    if( CheckServerJob::version(info).startsWith("4.0") ) {
        _errors.append( tr("The configured server for this client is too old") );
        _errors.append( tr("Please update to the latest server and restart the client.") );
        emit connectionResult( ServerVersionMismatch );
        return;
    }

    QTimer::singleShot( 0, this, SLOT( slotCheckAuthentication() ));
}
Пример #9
0
void Application::slotCredentialsFetched()
{
    Account *account = AccountManager::instance()->account();
    Q_ASSERT(account);
    disconnect(account->credentials(), SIGNAL(fetched()), this, SLOT(slotCredentialsFetched()));
    if (!account->credentials()->ready()) {
        // User canceled the connection or did not give a password
        account->setState(Account::SignedOut);
        return;
    }
    if (account->state() == Account::InvalidCredidential) {
        // Then we ask again for the credidentials if they are wrong again
        account->setState(Account::Disconnected);
    }

    if (_conValidator)
        _conValidator->deleteLater();
    _conValidator = new ConnectionValidator(account);
    connect( _conValidator, SIGNAL(connectionResult(ConnectionValidator::Status)),
             this, SLOT(slotConnectionValidatorResult(ConnectionValidator::Status)) );
    _conValidator->checkConnection();
}
Пример #10
0
void ConnectionValidator::slotStatusFound( const QString& url, const QString& versionStr, const QString& version, const QString& edition)
{
    // status.php was found.
    qDebug() << "** Application: ownCloud found: " << url << " with version " << versionStr << "(" << version << ")";
    // now check the authentication
    MirallConfigFile cfgFile(_connection);

    cfgFile.setOwnCloudVersion( version );
    // disconnect from ownCloudInfo
    disconnect( ownCloudInfo::instance(),SIGNAL(ownCloudInfoFound(QString,QString,QString,QString)),
                this, SLOT(slotStatusFound(QString,QString,QString,QString)));

    disconnect( ownCloudInfo::instance(),SIGNAL(noOwncloudFound(QNetworkReply*)),
                this, SLOT(slotNoStatusFound(QNetworkReply*)));

    if( version.startsWith("4.0") ) {
        _errors.append( tr("<p>The configured server for this client is too old.</p>"
                           "<p>Please update to the latest server and restart the client.</p>"));
        emit connectionResult( ServerVersionMismatch );
        return;
    }

    QTimer::singleShot( 0, this, SLOT( slotFetchCredentials() ));
}
Пример #11
0
void ConnectionValidator::slotAuthFailed(QNetworkReply *reply)
{
    Status stat = StatusNotFound;

    if( reply->error() == QNetworkReply::AuthenticationRequiredError ||
            reply->error() == QNetworkReply::OperationCanceledError ) { // returned if the user/pwd is wrong.
        qDebug() <<  reply->error() << reply->errorString();
        qDebug() << "******** Password is wrong!";
        _errors << tr("The provided credentials are not correct");
        stat = CredentialsWrong;
        switch (_account->state()) {
        case Account::SignedOut:
            _account->setState(Account::SignedOut);
            break;
        default:
            _account->setState(Account::Disconnected);
        }

    } else if( reply->error() != QNetworkReply::NoError ) {
        _errors << reply->errorString();
    }

    emit connectionResult( stat );
}
Пример #12
0
void ConnectionValidator::reportResult(Status status)
{
    emit connectionResult(status, _errors);
    deleteLater();
}
Пример #13
0
void ConnectionValidator::slotAuthSuccess()
{
    _account->setState(Account::Connected);
    emit connectionResult(Connected);
}