Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve again state tracking with terms of service app #7404

Merged
merged 2 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/gui/accountstate.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*

Check notice on line 1 in src/gui/accountstate.cpp

View workflow job for this annotation

GitHub Actions / build

Run clang-format on src/gui/accountstate.cpp

File src/gui/accountstate.cpp does not conform to Custom style guidelines. (lines 448, 449, 451)
* Copyright (C) by Daniel Molkentin <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -359,12 +359,7 @@
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
Expand Down Expand Up @@ -449,6 +444,12 @@
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);

Check warning on line 451 in src/gui/accountstate.cpp

View workflow job for this annotation

GitHub Actions / build

src/gui/accountstate.cpp:451:14 [cppcoreguidelines-init-variables]

variable 'termsOfServiceChanged' is not initialized
}
}

void AccountState::slotHandleRemoteWipeCheck()
Expand Down
2 changes: 1 addition & 1 deletion src/gui/accountstate.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 5 additions & 1 deletion src/gui/connectionvalidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* for more details.
*/

#include <QJsonDocument>

Check failure on line 15 in src/gui/connectionvalidator.cpp

View workflow job for this annotation

GitHub Actions / build

src/gui/connectionvalidator.cpp:15:10 [clang-diagnostic-error]

'QJsonDocument' file not found
#include <QJsonObject>
#include <QJsonArray>
#include <QLoggingCategory>
Expand Down Expand Up @@ -378,26 +378,30 @@

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();

Check warning on line 393 in src/gui/connectionvalidator.cpp

View workflow job for this annotation

GitHub Actions / build

src/gui/connectionvalidator.cpp:393:14 [modernize-use-trailing-return-type]

use a trailing return type for this function
}

qCInfo(lcConnectionValidator) << "done";
emit done();

Check warning on line 397 in src/gui/connectionvalidator.cpp

View workflow job for this annotation

GitHub Actions / build

src/gui/connectionvalidator.cpp:397:10 [modernize-use-trailing-return-type]

use a trailing return type for this function
}

void TermsOfServiceChecker::checkServerTermsOfService()
{
if (!_account) {
qCInfo(lcConnectionValidator) << "done";
emit done();

Check warning on line 404 in src/gui/connectionvalidator.cpp

View workflow job for this annotation

GitHub Actions / build

src/gui/connectionvalidator.cpp:404:14 [modernize-use-trailing-return-type]

use a trailing return type for this function
}

// The main flow now needs the capabilities
Expand Down
19 changes: 11 additions & 8 deletions src/gui/owncloudgui.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*

Check notice on line 1 in src/gui/owncloudgui.cpp

View workflow job for this annotation

GitHub Actions / build

Run clang-format on src/gui/owncloudgui.cpp

File src/gui/owncloudgui.cpp does not conform to Custom style guidelines. (lines 288, 292, 293, 294, 295)
* Copyright (C) by Klaas Freitag <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -285,14 +285,17 @@
}
}

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,

Check warning on line 288 in src/gui/owncloudgui.cpp

View workflow job for this annotation

GitHub Actions / build

src/gui/owncloudgui.cpp:288:19 [readability-convert-member-functions-to-static]

method 'slotNeedToAcceptTermsOfService' can be made static

Check warning on line 288 in src/gui/owncloudgui.cpp

View workflow job for this annotation

GitHub Actions / build

src/gui/owncloudgui.cpp:288:50 [bugprone-easily-swappable-parameters]

2 adjacent parameters of 'slotNeedToAcceptTermsOfService' of similar type ('int') are easily swapped by mistake
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()
Expand Down
3 changes: 2 additions & 1 deletion src/gui/owncloudgui.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*

Check notice on line 1 in src/gui/owncloudgui.h

View workflow job for this annotation

GitHub Actions / build

Run clang-format on src/gui/owncloudgui.h

File src/gui/owncloudgui.h does not conform to Custom style guidelines. (lines 97)
* Copyright (C) by Klaas Freitag <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -94,7 +94,8 @@
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.
Expand Down
Loading