From 7ac32a19b563bb17abe7fe9c9fbc245682e34711 Mon Sep 17 00:00:00 2001
From: Daniel Molkentin
%3")
.arg(Theme::instance()->appNameGUI(),
reply->url().toString(),
- reply->errorString()));
+ reply->errorString()), checkDowngradeAdvised(reply));
}
void OwncloudSetupWizard::slotNoOwnCloudFoundAuthTimeout(const QUrl&url)
{
- _ocWizard->displayError(tr("Failed to connect to %1 at %2:
%3")
+ _ocWizard->displayError(tr("Timeout while trying to connect to %1 at %2.")
.arg(Theme::instance()->appNameGUI(),
- url.toString(),
- "Timeout"));
+ url.toString()), false);
}
void OwncloudSetupWizard::slotConnectToOCUrl( const QString& url )
@@ -219,6 +218,28 @@ void OwncloudSetupWizard::testOwnCloudConnect()
job->start();
}
+bool OwncloudSetupWizard::checkDowngradeAdvised(QNetworkReply* reply)
+{
+ bool downgradeAdvised = (reply->url().scheme() == QLatin1String("https"));
+
+ switch (reply->error()) {
+ case QNetworkReply::NoError:
+ case QNetworkReply::ContentNotFoundError:
+ case QNetworkReply::ConnectionRefusedError:
+ case QNetworkReply::HostNotFoundError:
+ case QNetworkReply::TimeoutError:
+ downgradeAdvised = false;
+ // fall through
+ default:
+ _ocWizard->show();
+ _ocWizard->back();
+ // Adhere to HSTS, even though we do not parse it properly
+ downgradeAdvised &= !reply->hasRawHeader("Strict-Transport-Security");
+ break;
+ }
+ return downgradeAdvised;
+}
+
void OwncloudSetupWizard::slotConnectionCheck(QNetworkReply* reply)
{
switch (reply->error()) {
@@ -226,11 +247,8 @@ void OwncloudSetupWizard::slotConnectionCheck(QNetworkReply* reply)
case QNetworkReply::ContentNotFoundError:
_ocWizard->successfulStep();
break;
-
default:
- _ocWizard->show();
- _ocWizard->back();
- _ocWizard->displayError(reply->errorString());
+ _ocWizard->displayError(reply->errorString(), checkDowngradeAdvised(reply));
break;
}
}
@@ -254,7 +272,7 @@ void OwncloudSetupWizard::slotCreateLocalAndRemoteFolders(const QString& localFo
} else {
res += tr("failed.");
qDebug() << "Failed to create " << fi.path();
- _ocWizard->displayError(tr("Could not create local folder %1").arg(localFolder));
+ _ocWizard->displayError(tr("Could not create local folder %1").arg(localFolder), false);
nextStep = false;
}
_ocWizard->appendToConfigurationLog( res );
@@ -290,7 +308,7 @@ void OwncloudSetupWizard::slotAuthCheckReply(QNetworkReply *reply)
}
if( !ok ) {
- _ocWizard->displayError(error);
+ _ocWizard->displayError(error, false);
}
finalizeSetup( ok );
@@ -318,20 +336,20 @@ void OwncloudSetupWizard::slotCreateRemoteFolderFinished( QNetworkReply::Network
} 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 ));
+ _ocWizard->displayError( tr("The folder creation resulted in HTTP error code %1").arg((int)error ), false);
_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.
Remote folder creation failed probably because the provided credentials are wrong."
"
Please go back and check your credentials.
Could not connect securely:
%1
Do you want to connect unencrypted instead (not recommended)?
").arg(err); QString title = tr("Connection failed"); if (QMessageBox::question(this, title, msg, QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes) { diff --git a/src/gui/wizard/owncloudsetuppage.h b/src/gui/wizard/owncloudsetuppage.h index 2974c0d88..5385b2d09 100644 --- a/src/gui/wizard/owncloudsetuppage.h +++ b/src/gui/wizard/owncloudsetuppage.h @@ -46,7 +46,7 @@ public: void setAuthType(WizardCommon::AuthType type); public slots: - void setErrorString( const QString& ); + void setErrorString( const QString&, bool retryHTTPonly ); void setConfigExists( bool ); void startSpinner(); void stopSpinner(); diff --git a/src/gui/wizard/owncloudwizard.cpp b/src/gui/wizard/owncloudwizard.cpp index a02f802a8..24f0de242 100644 --- a/src/gui/wizard/owncloudwizard.cpp +++ b/src/gui/wizard/owncloudwizard.cpp @@ -182,11 +182,11 @@ void OwncloudWizard::slotCurrentPageChanged( int id ) setOption(QWizard::HaveCustomButton1, id == WizardCommon::Page_AdvancedSetup); } -void OwncloudWizard::displayError( const QString& msg ) +void OwncloudWizard::displayError( const QString& msg, bool retryHTTPonly ) { switch (currentId()) { case WizardCommon::Page_ServerSetup: - _setupPage->setErrorString( msg ); + _setupPage->setErrorString( msg, retryHTTPonly ); break; case WizardCommon::Page_HttpCreds: diff --git a/src/gui/wizard/owncloudwizard.h b/src/gui/wizard/owncloudwizard.h index a2f45ad6e..eb952e7e7 100644 --- a/src/gui/wizard/owncloudwizard.h +++ b/src/gui/wizard/owncloudwizard.h @@ -54,7 +54,7 @@ public: void enableFinishOnResultWidget(bool enable); - void displayError( const QString& ); + void displayError( const QString&, bool retryHTTPonly); void setMultipleFoldersExist( bool ); void setConfigExists( bool ); bool configExists();