Skip to content

Commit

Permalink
Save serverHasValidsubcription in the account.
Browse files Browse the repository at this point in the history
Signed-off-by: Camila Ayres <[email protected]>
  • Loading branch information
camilasan committed Oct 31, 2024
1 parent 5368110 commit 59094a7
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/gui/accountmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ void AccountManager::saveAccountHelper(Account *acc, QSettings &settings, bool s
settings.setValue(QLatin1String(serverVersionC), acc->_serverVersion);
settings.setValue(QLatin1String(serverColorC), acc->_serverColor);
settings.setValue(QLatin1String(serverTextColorC), acc->_serverTextColor);
settings.setValue(QLatin1String(serverHasValidSubscriptionC), acc->capabilities().serverHasValidSubscription());
settings.setValue(QLatin1String(serverHasValidSubscriptionC), acc->serverHasValidSubscription());

if (!acc->_skipE2eeMetadataChecksumValidation) {
settings.remove(QLatin1String(skipE2eeMetadataChecksumValidationC));
Expand Down
21 changes: 18 additions & 3 deletions src/libsync/account.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1076,13 +1076,28 @@ void Account::setAskUserForMnemonic(const bool ask)
emit askUserForMnemonicChanged();
}

bool Account::serverHasValidSubscription() const
{
return _serverHasValidSubscription;
}

void Account::setServerHasValidSubscription(bool valid)
{
if (_serverHasValidSubscription != valid) {
_serverHasValidSubscription = valid;
}
}

void Account::updateServerSubcription()
{
ConfigFile currentConfig;
if (const auto serverHasValidSubscription = _capabilities.serverHasValidSubscription();
serverHasValidSubscription != currentConfig.serverHasValidSubscription() && !serverHasValidSubscription) {
currentConfig.setServerHasValidSubscription(serverHasValidSubscription);
const auto capabilityValidSubscription = _capabilities.serverHasValidSubscription();
const auto configValidSubscription = currentConfig.serverHasValidSubscription();
if (capabilityValidSubscription != configValidSubscription && !configValidSubscription) {
currentConfig.setServerHasValidSubscription(capabilityValidSubscription);
}

setServerHasValidSubscription(capabilityValidSubscription);
}

void Account::updateDesktopEnterpriseChannel()
Expand Down
5 changes: 5 additions & 0 deletions src/libsync/account.h
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,9 @@ class OWNCLOUDSYNC_EXPORT Account : public QObject
[[nodiscard]] unsigned int downloadLimit() const;
void setDownloadLimit(unsigned int kbytes);

[[nodiscard]] bool serverHasValidSubscription() const;
void setServerHasValidSubscription(bool valid);

public slots:
/// Used when forgetting credentials
void clearQNAMCache();
Expand Down Expand Up @@ -553,6 +556,8 @@ private slots:
unsigned int _uploadLimit = 0;
unsigned int _downloadLimit = 0;

bool _serverHasValidSubscription = false;

/* IMPORTANT - remove later - FIXME MS@2019-12-07 -->
* TODO: For "Log out" & "Remove account": Remove client CA certs and KEY!
*
Expand Down

0 comments on commit 59094a7

Please sign in to comment.