void OwncloudHttpCredsPage::initializePage()
{
    WizardCommon::initErrorLabel(_ui.errorLabel);

    OwncloudWizard* ocWizard = qobject_cast< OwncloudWizard* >(wizard());
    AbstractCredentials *cred = ocWizard->account()->credentials();
    HttpCredentials *httpCreds = qobject_cast<HttpCredentials*>(cred);
    if (httpCreds) {
        const QString user = httpCreds->fetchUser();
        if (!user.isEmpty()) {
            _ui.leUsername->setText(user);
        }
    } else {
        QUrl url = ocWizard->account()->url();

        // If the final url does not have a username, check the
        // user specified url too. Sometimes redirects can lose
        // the user:pw information.
        if (url.userName().isEmpty()) {
            url = ocWizard->ocUrl();
        }

        const QString user = url.userName();
        const QString password = url.password();

        if(!user.isEmpty()) {
            _ui.leUsername->setText(user);
        }
        if(!password.isEmpty()) {
            _ui.lePassword->setText(password);
        }
    }
    _ui.leUsername->setFocus();
}
Esempio n. 2
0
void OwncloudHttpCredsPage::initializePage()
{
    WizardCommon::initErrorLabel(_ui.errorLabel);

    OwncloudWizard* ocWizard = qobject_cast< OwncloudWizard* >(wizard());
    AbstractCredentials *cred = ocWizard->account()->credentials();
    HttpCredentials *httpCreds = qobject_cast<HttpCredentials*>(cred);
    if (httpCreds) {
        const QString user = httpCreds->fetchUser(ocWizard->account());
        if (!user.isEmpty()) {
            _ui.leUsername->setText(user);
        }
    }
    _ui.leUsername->setFocus();
}