From 19e01865ca8877a0bc2730b5db222b5c42510c6e Mon Sep 17 00:00:00 2001 From: Matthieu Gallien Date: Tue, 22 Oct 2024 14:49:51 +0200 Subject: [PATCH 1/2] content access denied error during discovery: verify server access will trigger a check of the server connectivity in case of content access denied reporting when listing folders during discovery should allow discovering early that terms of service need to be signed Signed-off-by: Matthieu Gallien --- src/gui/accountstate.h | 1 + src/gui/connectionvalidator.cpp | 8 ++++++++ src/gui/connectionvalidator.h | 34 +++++++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+) diff --git a/src/gui/accountstate.h b/src/gui/accountstate.h index 77caa1b4051ca..e71d12e6710d2 100644 --- a/src/gui/accountstate.h +++ b/src/gui/accountstate.h @@ -223,6 +223,7 @@ private Q_SLOTS: bool _waitingForNewCredentials = false; QDateTime _timeOfLastETagCheck; QPointer _connectionValidator; + TermsOfServiceChecker _termsOfServiceChecker; QByteArray _notificationsEtagResponseHeader; QByteArray _navigationAppsEtagResponseHeader; diff --git a/src/gui/connectionvalidator.cpp b/src/gui/connectionvalidator.cpp index 9cc24de4a7521..d75d2155db4cc 100644 --- a/src/gui/connectionvalidator.cpp +++ b/src/gui/connectionvalidator.cpp @@ -42,7 +42,10 @@ ConnectionValidator::ConnectionValidator(AccountStatePtr accountState, const QSt , _previousErrors(previousErrors) , _accountState(accountState) , _account(accountState->account()) + , _termsOfServiceChecker(_account) { + connect(&_termsOfServiceChecker, &TermsOfServiceChecker::done, + this, &ConnectionValidator::termsOfServiceCheckDone); } void ConnectionValidator::checkServerAndAuth() @@ -306,6 +309,11 @@ bool ConnectionValidator::setAndCheckServerVersion(const QString &version) return true; } +void ConnectionValidator::checkServerTermsOfService() +{ + _termsOfServiceChecker.start(); +} + void ConnectionValidator::slotUserFetched(UserInfo *userInfo) { if(userInfo) { diff --git a/src/gui/connectionvalidator.h b/src/gui/connectionvalidator.h index 4b7193b0c8004..929c15d1b7b76 100644 --- a/src/gui/connectionvalidator.h +++ b/src/gui/connectionvalidator.h @@ -75,6 +75,37 @@ namespace OCC { class UserInfo; +class TermsOfServiceChecker : public QObject +{ + Q_OBJECT + + Q_PROPERTY(bool needToSign READ needToSign NOTIFY needToSignChanged FINAL) +public: + explicit TermsOfServiceChecker(AccountPtr account, + QObject *parent = nullptr); + + explicit TermsOfServiceChecker(QObject *parent = nullptr); + + [[nodiscard]] bool needToSign() const; + +public slots: + void start(); + +signals: + void needToSignChanged(); + + void done(); + +private slots: + void slotServerTermsOfServiceRecieved(const QJsonDocument &reply); + +private: + void checkServerTermsOfService(); + + AccountPtr _account; + bool _needToSign = false; +}; + class ConnectionValidator : public QObject { Q_OBJECT @@ -144,10 +175,13 @@ protected slots: */ bool setAndCheckServerVersion(const QString &version); + void checkServerTermsOfService(); + const QStringList _previousErrors; QStringList _errors; AccountStatePtr _accountState; AccountPtr _account; + TermsOfServiceChecker _termsOfServiceChecker; bool _isCheckingServerAndAuth = false; void showSystrayErrorMessage(); From fe255d99861a5c032da2b354d34f9b872921ae8e Mon Sep 17 00:00:00 2001 From: Matthieu Gallien Date: Tue, 22 Oct 2024 17:13:31 +0200 Subject: [PATCH 2/2] notify user once when terms of service need to be signed Signed-off-by: Matthieu Gallien