From: alex-z Date: Thu, 16 Dec 2021 16:23:03 +0000 (+0200) Subject: Try to sign-in after being signed-out due to SslHandshakeFailedError X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~17^2~217^2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=62b0a9b9f17d6d531f9bd005de6a87c92f7ff8e1;p=nextcloud-desktop.git Try to sign-in after being signed-out due to SslHandshakeFailedError Signed-off-by: alex-z --- diff --git a/src/gui/accountstate.cpp b/src/gui/accountstate.cpp index 7521dac79..6100f70fc 100644 --- a/src/gui/accountstate.cpp +++ b/src/gui/accountstate.cpp @@ -221,6 +221,19 @@ void AccountState::setDesktopNotificationsAllowed(bool isAllowed) emit desktopNotificationsAllowedChanged(); } +AccountState::ConnectionStatus AccountState::lastConnectionStatus() const +{ + return _lastConnectionValidatorStatus; +} + +void AccountState::trySignIn() +{ + if (isSignedOut() && account()) { + account()->resetRejectedCertificates(); + signIn(); + } +} + void AccountState::checkConnectivity() { if (isSignedOut() || _waitingForNewCredentials) { @@ -285,6 +298,8 @@ void AccountState::slotConnectionValidatorResult(ConnectionValidator::Status sta return; } + _lastConnectionValidatorStatus = status; + // Come online gradually from 503 or maintenance mode if (status == ConnectionValidator::Connected && (_connectionStatus == ConnectionValidator::ServiceUnavailable diff --git a/src/gui/accountstate.h b/src/gui/accountstate.h index 7946e2f96..e2b0a927d 100644 --- a/src/gui/accountstate.h +++ b/src/gui/accountstate.h @@ -171,6 +171,10 @@ public: */ void setDesktopNotificationsAllowed(bool isAllowed); + ConnectionStatus lastConnectionStatus() const; + + void trySignIn(); + public slots: /// Triggers a ping to the server to update state and /// connection status and errors. @@ -205,6 +209,7 @@ private: AccountPtr _account; State _state; ConnectionStatus _connectionStatus; + ConnectionStatus _lastConnectionValidatorStatus = ConnectionStatus::Undefined; QStringList _connectionErrors; bool _waitingForNewCredentials; QDateTime _timeOfLastETagCheck; diff --git a/src/gui/application.cpp b/src/gui/application.cpp index f153224b2..a7137743f 100644 --- a/src/gui/application.cpp +++ b/src/gui/application.cpp @@ -465,6 +465,9 @@ void Application::slotCheckConnection() if (state != AccountState::SignedOut && state != AccountState::ConfigurationError && state != AccountState::AskingCredentials && !pushNotificationsAvailable) { accountState->checkConnectivity(); + } else if (state == AccountState::SignedOut && accountState->lastConnectionStatus() == AccountState::ConnectionStatus::SslError) { + qCWarning(lcApplication) << "Account is signed out due to SSL Handshake error. Going to perform a sign-in attempt..."; + accountState->trySignIn(); } } diff --git a/src/gui/connectionvalidator.cpp b/src/gui/connectionvalidator.cpp index 159333544..14bc2617c 100644 --- a/src/gui/connectionvalidator.cpp +++ b/src/gui/connectionvalidator.cpp @@ -136,7 +136,7 @@ void ConnectionValidator::slotStatusFound(const QUrl &url, const QJsonObject &in void ConnectionValidator::slotNoStatusFound(QNetworkReply *reply) { auto job = qobject_cast(sender()); - qCWarning(lcConnectionValidator) << reply->error() << job->errorString() << reply->peek(1024); + qCWarning(lcConnectionValidator) << reply->error() << reply->errorString() << job->errorString() << reply->peek(1024); if (reply->error() == QNetworkReply::SslHandshakeFailedError) { reportResult(SslError); return;