diff --git a/changelog/unreleased/8231 b/changelog/unreleased/8231 new file mode 100644 index 00000000000..44b4c198f9f --- /dev/null +++ b/changelog/unreleased/8231 @@ -0,0 +1,6 @@ +Change: Don't ask the user to switch to http + +We no longer recommend to use a http connection if a https url +was not found. + +https://github.com/owncloud/client/issues/8231 diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 6c619d39975..87885d55bd3 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -26,10 +26,9 @@ set(client_UI_SRCS notificationwidget.ui logbrowser.ui wizard/owncloudadvancedsetuppage.ui - wizard/owncloudconnectionmethoddialog.ui wizard/owncloudhttpcredspage.ui wizard/owncloudoauthcredspage.ui - wizard/owncloudsetupnocredspage.ui + wizard/owncloudsetuppage.ui wizard/owncloudwizardresultpage.ui ) @@ -92,7 +91,6 @@ set(client_SRCS wizard/postfixlineedit.cpp wizard/abstractcredswizardpage.cpp wizard/owncloudadvancedsetuppage.cpp - wizard/owncloudconnectionmethoddialog.cpp wizard/owncloudhttpcredspage.cpp wizard/owncloudoauthcredspage.cpp wizard/owncloudsetuppage.cpp diff --git a/src/gui/owncloudsetupwizard.cpp b/src/gui/owncloudsetupwizard.cpp index bcb124403b0..6e3b49401d4 100644 --- a/src/gui/owncloudsetupwizard.cpp +++ b/src/gui/owncloudsetupwizard.cpp @@ -256,10 +256,9 @@ void OwncloudSetupWizard::slotNoServerFound(QNetworkReply *reply) Utility::escape(_ocWizard->account()->url().toString()), Utility::escape(job->errorString())); } - bool isDowngradeAdvised = checkDowngradeAdvised(reply); // Displays message inside wizard and possibly also another message box - _ocWizard->displayError(msg, isDowngradeAdvised); + _ocWizard->displayError(msg); // Allow the credentials dialog to pop up again for the same URL. // Maybe the user just clicked 'Cancel' by accident or changed his mind. @@ -270,8 +269,7 @@ void OwncloudSetupWizard::slotNoServerFoundTimeout(const QUrl &url) { _ocWizard->displayError( tr("Timeout while trying to connect to %1 at %2.") - .arg(Utility::escape(Theme::instance()->appNameGUI()), Utility::escape(url.toString())), - false); + .arg(Utility::escape(Theme::instance()->appNameGUI()), Utility::escape(url.toString()))); } void OwncloudSetupWizard::slotDetermineAuthType() @@ -378,30 +376,7 @@ void OwncloudSetupWizard::slotAuthError() if (_ocWizard->currentId() == WizardCommon::Page_OAuthCreds) { _ocWizard->back(); } - _ocWizard->displayError(errorMsg, _ocWizard->currentId() == WizardCommon::Page_ServerSetup && checkDowngradeAdvised(reply)); -} - -bool OwncloudSetupWizard::checkDowngradeAdvised(QNetworkReply *reply) -{ - if (reply->url().scheme() != QLatin1String("https")) { - return false; - } - - switch (reply->error()) { - case QNetworkReply::NoError: - case QNetworkReply::ContentNotFoundError: - case QNetworkReply::AuthenticationRequiredError: - case QNetworkReply::HostNotFoundError: - return false; - default: - break; - } - - // Adhere to HSTS, even though we do not parse it properly - if (reply->hasRawHeader("Strict-Transport-Security")) { - return false; - } - return true; + _ocWizard->displayError(errorMsg); } void OwncloudSetupWizard::slotCreateLocalAndRemoteFolders(const QString &localFolder, const QString &remoteFolder) @@ -427,7 +402,7 @@ void OwncloudSetupWizard::slotCreateLocalAndRemoteFolders(const QString &localFo } else { res += tr("failed."); qCWarning(lcWizard) << "Failed to create " << fi.path(); - _ocWizard->displayError(tr("Could not create local folder %1").arg(Utility::escape(localFolder)), false); + _ocWizard->displayError(tr("Could not create local folder %1").arg(Utility::escape(localFolder))); nextStep = false; } _ocWizard->appendToConfigurationLog(res); @@ -464,7 +439,7 @@ void OwncloudSetupWizard::slotRemoteFolderExists(QNetworkReply *reply) } if (!ok) { - _ocWizard->displayError(Utility::escape(error), false); + _ocWizard->displayError(Utility::escape(error)); } finalizeSetup(ok); @@ -492,21 +467,20 @@ void OwncloudSetupWizard::slotCreateRemoteFolderFinished(QNetworkReply::NetworkE } else if (error == 202) { _ocWizard->appendToConfigurationLog(tr("The remote folder %1 already exists. Connecting it for syncing.").arg(_remoteFolder)); } else if (error > 202 && error < 300) { - _ocWizard->displayError(tr("The folder creation resulted in HTTP error code %1").arg((int)error), false); + _ocWizard->displayError(tr("The folder creation resulted in HTTP error code %1").arg((int)error)); _ocWizard->appendToConfigurationLog(tr("The folder creation resulted in HTTP error code %1").arg((int)error)); } else if (error == QNetworkReply::OperationCanceledError) { _ocWizard->displayError(tr("The remote folder creation failed because the provided credentials " "are wrong!" - "
Please go back and check your credentials.

"), - false); + "
Please go back and check your credentials.

")); _ocWizard->appendToConfigurationLog(tr("

Remote folder creation failed probably because the provided credentials are wrong." "
Please go back and check your credentials.

")); _remoteFolder.clear(); success = false; } else { _ocWizard->appendToConfigurationLog(tr("Remote folder %1 creation failed with error %2.").arg(Utility::escape(_remoteFolder)).arg(error)); - _ocWizard->displayError(tr("Remote folder %1 creation failed with error %2.").arg(Utility::escape(_remoteFolder)).arg(error), false); + _ocWizard->displayError(tr("Remote folder %1 creation failed with error %2.").arg(Utility::escape(_remoteFolder)).arg(error)); _remoteFolder.clear(); success = false; } diff --git a/src/gui/owncloudsetupwizard.h b/src/gui/owncloudsetupwizard.h index a78907ede82..182141df536 100644 --- a/src/gui/owncloudsetupwizard.h +++ b/src/gui/owncloudsetupwizard.h @@ -74,7 +74,6 @@ private slots: void finalizeSetup(bool); bool ensureStartFromScratch(const QString &localFolder); AccountState *applyAccountChanges(); - bool checkDowngradeAdvised(QNetworkReply *reply); OwncloudWizard *_ocWizard; QString _initLocalFolder; diff --git a/src/gui/wizard/owncloudconnectionmethoddialog.cpp b/src/gui/wizard/owncloudconnectionmethoddialog.cpp deleted file mode 100644 index 2c4bd12a510..00000000000 --- a/src/gui/wizard/owncloudconnectionmethoddialog.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (C) 2015 by Jeroen Hoek - * Copyright (C) 2015 by Olivier Goffart - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - */ - -#include "wizard/owncloudconnectionmethoddialog.h" -#include - -namespace OCC { - -OwncloudConnectionMethodDialog::OwncloudConnectionMethodDialog(QWidget *parent) - : QDialog(parent, Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint | Qt::MSWindowsFixedSizeDialogHint) - , ui(new Ui::OwncloudConnectionMethodDialog) -{ - ui->setupUi(this); - - connect(ui->btnNoTLS, &QAbstractButton::clicked, this, &OwncloudConnectionMethodDialog::returnNoTLS); - connect(ui->btnClientSideTLS, &QAbstractButton::clicked, this, &OwncloudConnectionMethodDialog::returnClientSideTLS); - connect(ui->btnBack, &QAbstractButton::clicked, this, &OwncloudConnectionMethodDialog::returnBack); -} - -void OwncloudConnectionMethodDialog::setUrl(const QUrl &url) -{ - ui->label->setText(tr("

Failed to connect to the secure server address %1. How do you wish to proceed?

").arg(url.toDisplayString().toHtmlEscaped())); -} - - -void OwncloudConnectionMethodDialog::returnNoTLS() -{ - done(No_TLS); -} - -void OwncloudConnectionMethodDialog::returnClientSideTLS() -{ - done(Client_Side_TLS); -} - -void OwncloudConnectionMethodDialog::returnBack() -{ - done(Back); -} - -OwncloudConnectionMethodDialog::~OwncloudConnectionMethodDialog() -{ - delete ui; -} -} diff --git a/src/gui/wizard/owncloudconnectionmethoddialog.h b/src/gui/wizard/owncloudconnectionmethoddialog.h deleted file mode 100644 index d82d52e45b9..00000000000 --- a/src/gui/wizard/owncloudconnectionmethoddialog.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2015 by Jeroen Hoek - * Copyright (C) 2015 by Olivier Goffart - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - */ - -#ifndef OWNCLOUDCONNECTIONMETHODDIALOG_H -#define OWNCLOUDCONNECTIONMETHODDIALOG_H - -#include - -#include "ui_owncloudconnectionmethoddialog.h" - -namespace OCC { - -namespace Ui { - class OwncloudConnectionMethodDialog; -} - -/** - * @brief The OwncloudConnectionMethodDialog class - * @ingroup gui - */ -class OwncloudConnectionMethodDialog : public QDialog -{ - Q_OBJECT - -public: - explicit OwncloudConnectionMethodDialog(QWidget *parent = nullptr); - ~OwncloudConnectionMethodDialog() override; - enum { - Closed = 0, - No_TLS, - Client_Side_TLS, - Back - }; - - // The URL that was tried - void setUrl(const QUrl &); - -public slots: - void returnNoTLS(); - void returnClientSideTLS(); - void returnBack(); - -private: - Ui::OwncloudConnectionMethodDialog *ui; -}; -} - -#endif // OWNCLOUDCONNECTIONMETHODDIALOG_H diff --git a/src/gui/wizard/owncloudconnectionmethoddialog.ui b/src/gui/wizard/owncloudconnectionmethoddialog.ui deleted file mode 100644 index 6792ca00e57..00000000000 --- a/src/gui/wizard/owncloudconnectionmethoddialog.ui +++ /dev/null @@ -1,65 +0,0 @@ - - - OCC::OwncloudConnectionMethodDialog - - - - 0 - 0 - 367 - 208 - - - - Connection failed - - - true - - - - - - - - - 0 - 0 - - - - <html><head/><body><p>Failed to connect to the secure server address specified. How do you wish to proceed?</p></body></html> - - - true - - - - - - - Select a different URL - - - - - - - Retry unencrypted over HTTP (insecure) - - - - - - - Configure client-side TLS certificate - - - - - - - - - - diff --git a/src/gui/wizard/owncloudsetuppage.cpp b/src/gui/wizard/owncloudsetuppage.cpp index 87844e590e6..4666d54d7a1 100644 --- a/src/gui/wizard/owncloudsetuppage.cpp +++ b/src/gui/wizard/owncloudsetuppage.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -29,22 +30,23 @@ #include "guiutility.h" #include "wizard/owncloudwizardcommon.h" #include "wizard/owncloudsetuppage.h" -#include "wizard/owncloudconnectionmethoddialog.h" #include "theme.h" #include "account.h" +#include "ui_owncloudsetuppage.h" + namespace OCC { OwncloudSetupPage::OwncloudSetupPage(QWidget *parent) : QWizardPage() - , _ui() + , _ui(new Ui_OwncloudSetupPage) , _oCUrl() , _ocUser() , _authTypeKnown(false) , _checking(false) , _progressIndi(new QProgressIndicator(this)) { - _ui.setupUi(this); + _ui->setupUi(this); _ocWizard = qobject_cast(parent); Theme *theme = Theme::instance(); @@ -52,53 +54,63 @@ OwncloudSetupPage::OwncloudSetupPage(QWidget *parent) setSubTitle(WizardCommon::subTitleTemplate().arg(tr("Setup %1 server").arg(theme->appNameGUI()))); if (theme->overrideServerUrl().isEmpty()) { - _ui.leUrl->setPostfix(theme->wizardUrlPostfix()); - _ui.leUrl->setPlaceholderText(theme->wizardUrlHint()); + _ui->leUrl->setPostfix(theme->wizardUrlPostfix()); + _ui->leUrl->setPlaceholderText(theme->wizardUrlHint()); } else { - _ui.leUrl->setEnabled(false); + _ui->leUrl->setEnabled(false); } - registerField(QLatin1String("OCUrl*"), _ui.leUrl); + registerField(QLatin1String("OCUrl*"), _ui->leUrl); - _ui.resultLayout->addWidget(_progressIndi); + _ui->resultLayout->addWidget(_progressIndi); stopSpinner(); setupCustomization(); slotUrlChanged(QLatin1String("")); // don't jitter UI - connect(_ui.leUrl, &QLineEdit::textChanged, this, &OwncloudSetupPage::slotUrlChanged); - connect(_ui.leUrl, &QLineEdit::editingFinished, this, &OwncloudSetupPage::slotUrlEditFinished); + connect(_ui->leUrl, &QLineEdit::textChanged, this, &OwncloudSetupPage::slotUrlChanged); + connect(_ui->leUrl, &QLineEdit::editingFinished, this, &OwncloudSetupPage::slotUrlEditFinished); addCertDial = new AddCertificateDialog(this); connect(addCertDial, &QDialog::accepted, this, &OwncloudSetupPage::slotCertificateAccepted); + + _ui->more_toolButton->setIcon(Utility::getCoreIcon(QStringLiteral("more"))); + connect(_ui->more_toolButton, &QToolButton::clicked, this, [this] { + auto menu = new QMenu(this); + menu->setAttribute(Qt::WA_DeleteOnClose); + menu->addAction(tr("Configure client-side cerificate"), [this] { + addCertDial->open(); + }); + menu->popup(QCursor::pos()); + }); } void OwncloudSetupPage::setServerUrl(const QString &newUrl) { _oCUrl = newUrl; if (_oCUrl.isEmpty()) { - _ui.leUrl->clear(); + _ui->leUrl->clear(); return; } - _ui.leUrl->setText(_oCUrl); + _ui->leUrl->setText(_oCUrl); } void OwncloudSetupPage::setupCustomization() { // set defaults for the customize labels. - _ui.topLabel->hide(); - _ui.bottomLabel->hide(); + _ui->topLabel->hide(); + _ui->bottomLabel->hide(); Theme *theme = Theme::instance(); QVariant variant = theme->customMedia(Theme::oCSetupTop); if (!variant.isNull()) { - WizardCommon::setupCustomMedia(variant, _ui.topLabel); + WizardCommon::setupCustomMedia(variant, _ui->topLabel); } variant = theme->customMedia(Theme::oCSetupBottom); - WizardCommon::setupCustomMedia(variant, _ui.bottomLabel); + WizardCommon::setupCustomMedia(variant, _ui->bottomLabel); } // slot hit from textChanged of the url entry field. @@ -123,37 +135,37 @@ void OwncloudSetupPage::slotUrlChanged(const QString &url) } } if (newUrl != url) { - _ui.leUrl->setText(newUrl); + _ui->leUrl->setText(newUrl); } if (!url.startsWith(QLatin1String("https://"))) { - _ui.urlLabel->setPixmap(Utility::getCoreIcon(QStringLiteral("lock-http")).pixmap(_ui.urlLabel->size())); - _ui.urlLabel->setToolTip(tr("This url is NOT secure as it is not encrypted.\n" - "It is not advisable to use it.")); + _ui->urlLabel->setPixmap(Utility::getCoreIcon(QStringLiteral("lock-http")).pixmap(_ui->urlLabel->size())); + _ui->urlLabel->setToolTip(tr("This url is NOT secure as it is not encrypted.\n" + "It is not advisable to use it.")); } else { - _ui.urlLabel->setPixmap(Utility::getCoreIcon(QStringLiteral("lock-https")).pixmap(_ui.urlLabel->size())); - _ui.urlLabel->setToolTip(tr("This url is secure. You can use it.")); + _ui->urlLabel->setPixmap(Utility::getCoreIcon(QStringLiteral("lock-https")).pixmap(_ui->urlLabel->size())); + _ui->urlLabel->setToolTip(tr("This url is secure. You can use it.")); } } void OwncloudSetupPage::slotUrlEditFinished() { - QString url = _ui.leUrl->fullText(); + QString url = _ui->leUrl->fullText(); if (QUrl(url).isRelative() && !url.isEmpty()) { // no scheme defined, set one url.prepend("https://"); - _ui.leUrl->setFullText(url); + _ui->leUrl->setFullText(url); } } bool OwncloudSetupPage::isComplete() const { - return !_ui.leUrl->text().isEmpty() && !_checking; + return !_ui->leUrl->text().isEmpty() && !_checking; } void OwncloudSetupPage::initializePage() { - WizardCommon::initErrorLabel(_ui.errorLabel); + WizardCommon::initErrorLabel(_ui->errorLabel); _authTypeKnown = false; _checking = false; @@ -167,7 +179,7 @@ void OwncloudSetupPage::initializePage() // we just check the server type and switch to second page // immediately. if (Theme::instance()->overrideServerUrl().isEmpty()) { - _ui.leUrl->setFocus(); + _ui->leUrl->setFocus(); } else { setCommitPage(true); // Hack: setCommitPage() changes caption, but after an error this page could still be visible @@ -191,7 +203,7 @@ int OwncloudSetupPage::nextId() const QString OwncloudSetupPage::url() const { - QString url = _ui.leUrl->fullText().simplified(); + QString url = _ui->leUrl->fullText().simplified(); return url; } @@ -202,11 +214,11 @@ bool OwncloudSetupPage::validatePage() QString u = url(); QUrl qurl(u); if (!qurl.isValid() || qurl.host().isEmpty()) { - setErrorString(tr("Invalid URL"), false); + setErrorString(tr("Invalid URL")); return false; } - setErrorString(QString(), false); + setErrorString(QString()); _checking = true; startSpinner(); emit completeChanged(); @@ -228,44 +240,13 @@ void OwncloudSetupPage::setAuthType(DetermineAuthTypeJob::AuthType type) stopSpinner(); } -void OwncloudSetupPage::setErrorString(const QString &err, bool retryHTTPonly) +void OwncloudSetupPage::setErrorString(const QString &err) { if (err.isEmpty()) { - _ui.errorLabel->setVisible(false); + _ui->errorLabel->setVisible(false); } else { - if (retryHTTPonly) { - QUrl url(_ui.leUrl->fullText()); - if (url.scheme() == "https") { - // Ask the user how to proceed when connecting to a https:// URL fails. - // It is possible that the server is secured with client-side TLS certificates, - // but that it has no way of informing the owncloud client that this is the case. - - OwncloudConnectionMethodDialog dialog; - dialog.setUrl(url); - // FIXME: Synchronous dialogs are not so nice because of event loop recursion - int retVal = dialog.exec(); - - switch (retVal) { - case OwncloudConnectionMethodDialog::No_TLS: { - url.setScheme("http"); - _ui.leUrl->setFullText(url.toString()); - // skip ahead to next page, since the user would expect us to retry automatically - wizard()->next(); - } break; - case OwncloudConnectionMethodDialog::Client_Side_TLS: - addCertDial->show(); - break; - case OwncloudConnectionMethodDialog::Closed: - case OwncloudConnectionMethodDialog::Back: - default: - // No-op. - break; - } - } - } - - _ui.errorLabel->setVisible(true); - _ui.errorLabel->setText(err); + _ui->errorLabel->setVisible(true); + _ui->errorLabel->setText(err); } _checking = false; emit completeChanged(); @@ -274,14 +255,14 @@ void OwncloudSetupPage::setErrorString(const QString &err, bool retryHTTPonly) void OwncloudSetupPage::startSpinner() { - _ui.resultLayout->setEnabled(true); + _ui->resultLayout->setEnabled(true); _progressIndi->setVisible(true); _progressIndi->startAnimation(); } void OwncloudSetupPage::stopSpinner() { - _ui.resultLayout->setEnabled(false); + _ui->resultLayout->setEnabled(false); _progressIndi->setVisible(false); _progressIndi->stopAnimation(); } diff --git a/src/gui/wizard/owncloudsetuppage.h b/src/gui/wizard/owncloudsetuppage.h index 485fc7fce82..913e9f9d6e1 100644 --- a/src/gui/wizard/owncloudsetuppage.h +++ b/src/gui/wizard/owncloudsetuppage.h @@ -16,19 +16,19 @@ #ifndef MIRALL_OWNCLOUD_SETUP_PAGE_H #define MIRALL_OWNCLOUD_SETUP_PAGE_H +#include #include #include "wizard/owncloudwizardcommon.h" #include "wizard/owncloudwizard.h" #include "../addcertificatedialog.h" -#include "wizard/owncloudconnectionmethoddialog.h" - -#include "ui_owncloudsetupnocredspage.h" class QLabel; class QVariant; class QProgressIndicator; +class QButtonGroup; +class Ui_OwncloudSetupPage; namespace OCC { @@ -56,7 +56,7 @@ class OwncloudSetupPage : public QWizardPage void setAuthType(DetermineAuthTypeJob::AuthType type); public slots: - void setErrorString(const QString &, bool retryHTTPonly); + void setErrorString(const QString &); void startSpinner(); void stopSpinner(); void slotCertificateAccepted(); @@ -71,7 +71,7 @@ protected slots: void determineAuthType(const QString &); private: - Ui_OwncloudSetupPage _ui; + QScopedPointer _ui; QString _oCUrl; QString _ocUser; diff --git a/src/gui/wizard/owncloudsetupnocredspage.ui b/src/gui/wizard/owncloudsetuppage.ui similarity index 93% rename from src/gui/wizard/owncloudsetupnocredspage.ui rename to src/gui/wizard/owncloudsetuppage.ui index f9c2c8107bb..fb286cd3136 100644 --- a/src/gui/wizard/owncloudsetupnocredspage.ui +++ b/src/gui/wizard/owncloudsetuppage.ui @@ -103,6 +103,17 @@ + + + + ... + + + + :/client/resources/light/more.svg:/client/resources/light/more.svg + + + diff --git a/src/gui/wizard/owncloudwizard.cpp b/src/gui/wizard/owncloudwizard.cpp index 9d3458a176d..a5141a2b7e5 100644 --- a/src/gui/wizard/owncloudwizard.cpp +++ b/src/gui/wizard/owncloudwizard.cpp @@ -205,11 +205,11 @@ void OwncloudWizard::slotCurrentPageChanged(int id) } } -void OwncloudWizard::displayError(const QString &msg, bool retryHTTPonly) +void OwncloudWizard::displayError(const QString &msg) { switch (currentId()) { case WizardCommon::Page_ServerSetup: - _setupPage->setErrorString(msg, retryHTTPonly); + _setupPage->setErrorString(msg); break; case WizardCommon::Page_HttpCreds: diff --git a/src/gui/wizard/owncloudwizard.h b/src/gui/wizard/owncloudwizard.h index bad9a75ca85..25609fdfdd6 100644 --- a/src/gui/wizard/owncloudwizard.h +++ b/src/gui/wizard/owncloudwizard.h @@ -66,7 +66,7 @@ class OwncloudWizard : public QWizard void enableFinishOnResultWidget(bool enable); - void displayError(const QString &, bool retryHTTPonly); + void displayError(const QString &); AbstractCredentials *getCredentials() const; /**