コード例 #1
0
ファイル: application.cpp プロジェクト: Gnostech/mirall
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;
        }

        AbstractCredentials* credentials(account->credentials());

        if (! credentials->ready()) {
            connect( credentials, SIGNAL(fetched()),
                     this, SLOT(slotCredentialsFetched()), Qt::UniqueConnection);
            credentials->fetch(account);
        } else {
            slotCredentialsFetched();
        }
    } else {
        // let gui open the setup wizard
        _gui->slotOpenSettingsDialog( true );
    }
}
コード例 #2
0
ファイル: account.cpp プロジェクト: ronynksoft/client
void Account::setCredentials(AbstractCredentials *cred)
{
    // set active credential manager
    QNetworkCookieJar *jar = 0;
    if (_am) {
        jar = _am->cookieJar();
        jar->setParent(0);

        _am->deleteLater();
    }

    if (_credentials) {
        credentials()->deleteLater();
    }

    // The order for these two is important! Reading the credential's
    // settings accesses the account as well as account->_credentials
    _credentials = cred;
    cred->setAccount(this);

    _am = _credentials->getQNAM();
    if (jar) {
        _am->setCookieJar(jar);
    }
    connect(_am, SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>)),
            SLOT(slotHandleErrors(QNetworkReply*,QList<QSslError>)));
    connect(_credentials, SIGNAL(fetched()),
            SLOT(slotCredentialsFetched()));
}
コード例 #3
0
ファイル: application.cpp プロジェクト: queer1/mirall
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);
    }
    slotCheckConnection();
}
コード例 #4
0
ファイル: application.cpp プロジェクト: prodigeni/mirall
void Application::slotFetchCredentials()
{
    QString trayMessage;

    if( CredentialStore::instance()->state() == CredentialStore::Ok ) {
        // the credentials are still valid and ok.
        slotCredentialsFetched( true );
    } else {
        if( CredentialStore::instance()->canTryAgain() ) {
            connect( CredentialStore::instance(), SIGNAL(fetchCredentialsFinished(bool)),
                     this, SLOT(slotCredentialsFetched(bool)) );
            CredentialStore::instance()->fetchCredentials();
            if( CredentialStore::instance()->state() == CredentialStore::TooManyAttempts ) {
                trayMessage = tr("Too many incorrect password attempts.");
            }
        } else {
コード例 #5
0
ファイル: networkjobs.cpp プロジェクト: Gallaecio/vaiven
void AbstractNetworkJob::slotFinished()
{
    _timer.stop();

    if( _reply->error() != QNetworkReply::NoError ) {
        qDebug() << Q_FUNC_INFO << _reply->error() << _reply->errorString();
        if (_reply->error() == QNetworkReply::ProxyAuthenticationRequiredError) {
            qDebug() << Q_FUNC_INFO << _reply->rawHeader("Proxy-Authenticate");
        }
        emit networkError(_reply);
    }

    // get the Date timestamp from reply
    _responseTimestamp = QString::fromAscii(_reply->rawHeader("Date"));
    _duration = _durationTimer.elapsed();

    bool discard = finished();
    AbstractCredentials *creds = _account->credentials();
    if (!creds->stillValid(_reply) &&! _ignoreCredentialFailure
            && _account->state() != Account::InvalidCredidential) {
        _account->setState(Account::InvalidCredidential);

        // invalidate & forget token/password
        // but try to re-sign in.
        connect( creds, SIGNAL(fetched()),
                 qApp, SLOT(slotCredentialsFetched()), Qt::UniqueConnection);
        if (creds->ready()) {
            creds->invalidateAndFetch(_account);
        } else {
            creds->fetch(_account);
        }
    }
    if (discard) {
        deleteLater();
    }
}