Skip to content

Commit

Permalink
improve again state tracking with terms of service app
Browse files Browse the repository at this point in the history
Signed-off-by: Matthieu Gallien <[email protected]>
  • Loading branch information
mgallien authored and backportbot[bot] committed Oct 23, 2024
1 parent bfd4f2c commit f44fa29
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 16 deletions.
13 changes: 7 additions & 6 deletions src/gui/accountstate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
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
19 changes: 11 additions & 8 deletions src/gui/owncloudgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion src/gui/owncloudgui.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit f44fa29

Please sign in to comment.