From 3b0f9a5bebff6342ad92b2be05b984f31c565531 Mon Sep 17 00:00:00 2001 From: Matthieu Gallien Date: Wed, 23 Oct 2024 11:22:28 +0200 Subject: [PATCH 1/2] improve again state tracking with terms of service app Signed-off-by: Matthieu Gallien --- src/gui/accountstate.cpp | 13 +++++++------ src/gui/accountstate.h | 2 +- src/gui/owncloudgui.cpp | 19 +++++++++++-------- src/gui/owncloudgui.h | 3 ++- 4 files changed, 21 insertions(+), 16 deletions(-) diff --git a/src/gui/accountstate.cpp b/src/gui/accountstate.cpp index 1324fa1dd2c81..e2fb2779413bd 100644 --- a/src/gui/accountstate.cpp +++ b/src/gui/accountstate.cpp @@ -359,12 +359,7 @@ void AccountState::slotConnectionValidatorResult(ConnectionValidator::Status sta return; } - if ((_lastConnectionValidatorStatus == ConnectionValidator::NeedToSignTermsOfService && status == ConnectionValidator::Connected) || - (status == ConnectionValidator::NeedToSignTermsOfService && _lastConnectionValidatorStatus != status)) { - - emit termsOfServiceChanged(_account); - } - + const auto oldConnectionValidatorStatus = _lastConnectionValidatorStatus; _lastConnectionValidatorStatus = status; // Come online gradually from 503, captive portal(redirection) or maintenance mode @@ -449,6 +444,12 @@ void AccountState::slotConnectionValidatorResult(ConnectionValidator::Status sta setState(NeedToSignTermsOfService); break; } + + if ((oldConnectionValidatorStatus == ConnectionValidator::NeedToSignTermsOfService && status == ConnectionValidator::Connected) || + (status == ConnectionValidator::NeedToSignTermsOfService && oldConnectionValidatorStatus != status)) { + + emit termsOfServiceChanged(_account, status == ConnectionValidator::NeedToSignTermsOfService ? AccountState::NeedToSignTermsOfService : AccountState::Connected); + } } void AccountState::slotHandleRemoteWipeCheck() diff --git a/src/gui/accountstate.h b/src/gui/accountstate.h index fb306545c3674..de4311dbe6059 100644 --- a/src/gui/accountstate.h +++ b/src/gui/accountstate.h @@ -195,7 +195,7 @@ public slots: void hasFetchedNavigationApps(); void statusChanged(); void desktopNotificationsAllowedChanged(); - void termsOfServiceChanged(OCC::AccountPtr account); + void termsOfServiceChanged(OCC::AccountPtr account, AccountState::State state); protected Q_SLOTS: void slotConnectionValidatorResult(OCC::ConnectionValidator::Status status, const QStringList &errors); diff --git a/src/gui/owncloudgui.cpp b/src/gui/owncloudgui.cpp index abd1b6ec9cacc..52536d77add50 100644 --- a/src/gui/owncloudgui.cpp +++ b/src/gui/owncloudgui.cpp @@ -285,14 +285,17 @@ void ownCloudGui::slotTrayMessageIfServerUnsupported(Account *account) } } -void ownCloudGui::slotNeedToAcceptTermsOfService(OCC::AccountPtr account) -{ - slotShowTrayMessage( - tr("Terms of service"), - tr("Your account %1 requires you to accept the terms of service of your server. " - "You will be redirected to %2 to acknowledge that you have read it and agrees with it.") - .arg(account->displayName(), account->url().toString())); - QDesktopServices::openUrl(account->url()); +void ownCloudGui::slotNeedToAcceptTermsOfService(OCC::AccountPtr account, + AccountState::State state) +{ + if (state == AccountState::NeedToSignTermsOfService) { + slotShowTrayMessage( + tr("Terms of service"), + tr("Your account %1 requires you to accept the terms of service of your server. " + "You will be redirected to %2 to acknowledge that you have read it and agrees with it.") + .arg(account->displayName(), account->url().toString())); + QDesktopServices::openUrl(account->url()); + } } void ownCloudGui::slotComputeOverallSyncStatus() diff --git a/src/gui/owncloudgui.h b/src/gui/owncloudgui.h index 1cfc44876d525..2370d9d3f5614 100644 --- a/src/gui/owncloudgui.h +++ b/src/gui/owncloudgui.h @@ -94,7 +94,8 @@ public slots: void slotOpenPath(const QString &path); void slotAccountStateChanged(); void slotTrayMessageIfServerUnsupported(OCC::Account *account); - void slotNeedToAcceptTermsOfService(OCC::AccountPtr account); + void slotNeedToAcceptTermsOfService(OCC::AccountPtr account, + OCC::AccountState::State state); /** * Open a share dialog for a file or folder. From ba4b28cc00b405c66e5a0259ec3136a8fcd87a4e Mon Sep 17 00:00:00 2001 From: Matthieu Gallien Date: Wed, 23 Oct 2024 15:18:10 +0200 Subject: [PATCH 2/2] improve logs when checking terms of service status should help diagnosing a client stuck with ToS block while thinking they had been accepted Signed-off-by: Matthieu Gallien --- src/gui/connectionvalidator.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/gui/connectionvalidator.cpp b/src/gui/connectionvalidator.cpp index c5ed581db05b9..75cb21762fcb0 100644 --- a/src/gui/connectionvalidator.cpp +++ b/src/gui/connectionvalidator.cpp @@ -378,25 +378,29 @@ void TermsOfServiceChecker::start() void TermsOfServiceChecker::slotServerTermsOfServiceRecieved(const QJsonDocument &reply) { - qCDebug(lcConnectionValidator) << "Terms of service status" << reply; + qCInfo(lcConnectionValidator) << "Terms of service status" << reply; if (reply.object().contains("ocs")) { const auto needToSign = !reply.object().value("ocs").toObject().value("data").toObject().value("hasSigned").toBool(false); if (needToSign != _needToSign) { + qCInfo(lcConnectionValidator) << "_needToSign" << (_needToSign ? "need to sign" : "no need to sign"); _needToSign = needToSign; emit needToSignChanged(); } } else if (_needToSign) { _needToSign = false; + qCInfo(lcConnectionValidator) << "_needToSign" << (_needToSign ? "need to sign" : "no need to sign"); emit needToSignChanged(); } + qCInfo(lcConnectionValidator) << "done"; emit done(); } void TermsOfServiceChecker::checkServerTermsOfService() { if (!_account) { + qCInfo(lcConnectionValidator) << "done"; emit done(); }