Skip to content
Open
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
77 changes: 59 additions & 18 deletions src/libsync/configfile.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/*
* SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2014 ownCloud GmbH
Expand Down Expand Up @@ -59,7 +59,7 @@
static constexpr char logFlushC[] = "logFlush";
static constexpr char showExperimentalOptionsC[] = "showExperimentalOptions";
static constexpr char clientPreviousVersionC[] = "clientPreviousVersion";
static constexpr char fileProviderDomainsAppSandboxMigrationCompletedC[] = "fileProviderDomainsAppSandboxMigrationCompleted";

Check warning on line 62 in src/libsync/configfile.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this identifier to be shorter or equal to 31 characters.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ5BMJquZAE0R6ifmkNV&open=AZ5BMJquZAE0R6ifmkNV&pullRequest=10058
static constexpr char fileProviderDomainUuidsGroupC[] = "FileProviderDomainUuids";
static constexpr char fileProviderAccountIdsGroupC[] = "FileProviderAccountIds";

Expand All @@ -69,19 +69,19 @@
static constexpr char proxyUserC[] = "Proxy/user";
static constexpr char proxyPassC[] = "Proxy/pass";
static constexpr char proxyNeedsAuthC[] = "Proxy/needsAuth";
static constexpr char forceLoginV2C[] = "forceLoginV2";

Check warning on line 72 in src/libsync/configfile.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove the redundant "static" specifier.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ5BMJquZAE0R6ifmkNW&open=AZ5BMJquZAE0R6ifmkNW&pullRequest=10058

static constexpr char certPath[] = "http_certificatePath";
static constexpr char certPasswd[] = "http_certificatePasswd";

static constexpr char serverHasValidSubscriptionC[] = "serverHasValidSubscription";

Check warning on line 77 in src/libsync/configfile.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove the redundant "static" specifier.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ5BMJquZAE0R6ifmkNX&open=AZ5BMJquZAE0R6ifmkNX&pullRequest=10058
static constexpr char desktopEnterpriseChannelName[] = "desktopEnterpriseChannel";

Check warning on line 78 in src/libsync/configfile.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove the redundant "static" specifier.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ5BMJquZAE0R6ifmkNY&open=AZ5BMJquZAE0R6ifmkNY&pullRequest=10058

static constexpr char languageC[] = "language";

Check warning on line 80 in src/libsync/configfile.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove the redundant "static" specifier.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ5BMJquZAE0R6ifmkNZ&open=AZ5BMJquZAE0R6ifmkNZ&pullRequest=10058

static constexpr char lastSelectedAccountC[] = "lastSelectedAccount";

Check warning on line 82 in src/libsync/configfile.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove the redundant "static" specifier.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ5BMJquZAE0R6ifmkNa&open=AZ5BMJquZAE0R6ifmkNa&pullRequest=10058

static constexpr int deleteFilesThresholdDefaultValue = 100;

Check warning on line 84 in src/libsync/configfile.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove the redundant "static" specifier.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ5BMJquZAE0R6ifmkNc&open=AZ5BMJquZAE0R6ifmkNc&pullRequest=10058

Check warning on line 84 in src/libsync/configfile.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this identifier to be shorter or equal to 31 characters.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ5BMJquZAE0R6ifmkNb&open=AZ5BMJquZAE0R6ifmkNb&pullRequest=10058
}

namespace OCC {
Expand Down Expand Up @@ -181,7 +181,7 @@
return settings.value(showChatNotificationsC, true).toBool();
}

void ConfigFile::setShowChatNotifications(const bool show)

Check warning on line 184 in src/libsync/configfile.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

This function should be declared "const".

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ5BMJquZAE0R6ifmkNd&open=AZ5BMJquZAE0R6ifmkNd&pullRequest=10058
{
QSettings settings(configFile(), QSettings::IniFormat);
settings.setValue(showChatNotificationsC, show);
Expand All @@ -207,7 +207,7 @@
return settings.value(showQuotaWarningNotificationsC, true).toBool();
}

void ConfigFile::setShowQuotaWarningNotifications(bool show)

Check warning on line 210 in src/libsync/configfile.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

This function should be declared "const".

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ5BMJquZAE0R6ifmkNf&open=AZ5BMJquZAE0R6ifmkNf&pullRequest=10058

Check warning on line 210 in src/libsync/configfile.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unmodified variable "show" of type "_Bool" should be const-qualified.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ5BMJquZAE0R6ifmkNg&open=AZ5BMJquZAE0R6ifmkNg&pullRequest=10058

Check warning on line 210 in src/libsync/configfile.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this identifier to be shorter or equal to 31 characters.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ5BMJquZAE0R6ifmkNe&open=AZ5BMJquZAE0R6ifmkNe&pullRequest=10058
{
QSettings settings(configFile(), QSettings::IniFormat);
settings.setValue(showQuotaWarningNotificationsC, show);
Expand Down Expand Up @@ -329,14 +329,14 @@
if (Utility::isWindows()) {
const auto appName = isUnbrandedToBrandedMigrationInProgress() ? unbrandedAppName : Theme::instance()->appNameGUI();
// check for policies first and return immediately if a value is found.
QSettings userPolicy(QString::fromLatin1(R"(HKEY_CURRENT_USER\Software\Policies\%1\%2)").arg(APPLICATION_VENDOR, appName),
QSettings::NativeFormat);

Check warning on line 333 in src/libsync/configfile.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unmodified variable "userPolicy" of type "class QSettings" should be const-qualified.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ5BMJquZAE0R6ifmkNh&open=AZ5BMJquZAE0R6ifmkNh&pullRequest=10058
if (userPolicy.contains(setting)) {
return userPolicy.value(setting);
}

QSettings machinePolicy(QString::fromLatin1(R"(HKEY_LOCAL_MACHINE\Software\Policies\%1\%2)").arg(APPLICATION_VENDOR, appName),
QSettings::NativeFormat);

Check warning on line 339 in src/libsync/configfile.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unmodified variable "machinePolicy" of type "class QSettings" should be const-qualified.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ5BMJquZAE0R6ifmkNi&open=AZ5BMJquZAE0R6ifmkNi&pullRequest=10058
if (machinePolicy.contains(setting)) {
return machinePolicy.value(setting);
}
Expand Down Expand Up @@ -406,7 +406,7 @@
if (!fi.exists()) {
// Prefer to return the preferred path! Only use the fallback location
// if the other path does not exist and the fallback is valid.
QFileInfo nextToBinary(QCoreApplication::applicationDirPath(), syncExclFile);

Check warning on line 409 in src/libsync/configfile.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unmodified variable "nextToBinary" of type "class QFileInfo" should be const-qualified.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ5BMJquZAE0R6ifmkNj&open=AZ5BMJquZAE0R6ifmkNj&pullRequest=10058
if (nextToBinary.exists()) {
fi = nextToBinary;
} else {
Expand All @@ -416,7 +416,7 @@
d.cdUp(); // go out of usr
if (!d.isRoot()) { // it is really a mountpoint
if (d.cd("etc") && d.cd(Theme::instance()->appName())) {
QFileInfo inMountDir(d, syncExclFile);

Check warning on line 419 in src/libsync/configfile.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unmodified variable "inMountDir" of type "class QFileInfo" should be const-qualified.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ5BMJquZAE0R6ifmkNk&open=AZ5BMJquZAE0R6ifmkNk&pullRequest=10058
if (inMountDir.exists()) {
fi = inMountDir;
}
Expand All @@ -434,7 +434,7 @@
return fi.absoluteFilePath();
}

void OCC::ConfigFile::cleanUpdaterConfiguration()

Check warning on line 437 in src/libsync/configfile.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

This function should be declared "const".

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ5BMJquZAE0R6ifmkNl&open=AZ5BMJquZAE0R6ifmkNl&pullRequest=10058
{
QSettings settings(configFile(), QSettings::IniFormat);
settings.beginGroup("Updater");
Expand All @@ -445,7 +445,7 @@
settings.sync();
}

void OCC::ConfigFile::cleanupGlobalNetworkConfiguration()

Check warning on line 448 in src/libsync/configfile.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this identifier to be shorter or equal to 31 characters.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ5BMJquZAE0R6ifmkNm&open=AZ5BMJquZAE0R6ifmkNm&pullRequest=10058
{
QSettings settings(configFile(), QSettings::IniFormat);
settings.remove(useUploadLimitC);
Expand Down Expand Up @@ -554,7 +554,7 @@
return remoteInterval;
}

void ConfigFile::setRemotePollInterval(chrono::milliseconds interval, const QString &connectionGroupName)

Check warning on line 557 in src/libsync/configfile.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

This function should be declared "const".

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ5BMJquZAE0R6ifmkNo&open=AZ5BMJquZAE0R6ifmkNo&pullRequest=10058

Check warning on line 557 in src/libsync/configfile.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unmodified variable "interval" of type "class std::chrono::duration<long, struct std::ratio<1, 1000> >" should be const-qualified.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ5BMJquZAE0R6ifmkNp&open=AZ5BMJquZAE0R6ifmkNp&pullRequest=10058
{
const auto groupName = connectionGroupName.isEmpty() ? defaultConnectionGroupName() : connectionGroupName;
if (interval < chrono::seconds(5)) {
Expand All @@ -570,7 +570,7 @@
chrono::milliseconds ConfigFile::forceSyncInterval(const QString &connectionGroupName) const
{
const auto groupName = connectionGroupName.isEmpty() ? defaultConnectionGroupName() : connectionGroupName;
auto pollInterval = remotePollInterval(groupName);

Check warning on line 573 in src/libsync/configfile.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unmodified variable "pollInterval" of type "class std::chrono::duration<long, struct std::ratio<1, 1000> >" should be const-qualified.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ5BMJquZAE0R6ifmkNq&open=AZ5BMJquZAE0R6ifmkNq&pullRequest=10058
QSettings settings(configFile(), QSettings::IniFormat);
settings.beginGroup(groupName);
auto defaultInterval = chrono::hours(2);
Expand Down Expand Up @@ -631,7 +631,7 @@
return value.toBool();
}

void ConfigFile::setSkipUpdateCheck(bool skip, const QString &connectionGroupName)

Check warning on line 634 in src/libsync/configfile.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

This function should be declared "const".

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ5BMJquZAE0R6ifmkNr&open=AZ5BMJquZAE0R6ifmkNr&pullRequest=10058
{
const auto groupName = connectionGroupName.isEmpty() ? defaultConnectionGroupName() : connectionGroupName;
QSettings settings(configFile(), QSettings::IniFormat);
Expand All @@ -651,7 +651,7 @@
return value.toBool();
}

void ConfigFile::setAutoUpdateCheck(bool autoCheck, const QString &connectionGroupName)

Check warning on line 654 in src/libsync/configfile.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

This function should be declared "const".

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ5BMJquZAE0R6ifmkNt&open=AZ5BMJquZAE0R6ifmkNt&pullRequest=10058
{
const auto groupName = connectionGroupName.isEmpty() ? defaultConnectionGroupName() : connectionGroupName;
QSettings settings(configFile(), QSettings::IniFormat);
Expand Down Expand Up @@ -679,18 +679,19 @@
QStringList ConfigFile::validUpdateChannels() const
{
const auto isBranded = Theme::instance()->isBranded();
const QString defaultChannel = UpdateChannel::defaultUpdateChannel().toString();

if (isBranded) {
return {UpdateChannel::defaultUpdateChannel().toString()};
return {defaultChannel};
}

const QList<UpdateChannel> *channel_list = &UpdateChannel::defaultUpdateChannelList();
const QList<UpdateChannel> *channelList = &UpdateChannel::defaultUpdateChannelList();
if (serverHasValidSubscription()) {
channel_list = &UpdateChannel::enterpriseUpdateChannelsList();
channelList = &UpdateChannel::enterpriseUpdateChannelsList();
}

QStringList list;
for (const auto &channel : *channel_list) {
for (const auto &channel : *channelList) {
list.append(channel.toString());
}

Expand All @@ -700,35 +701,69 @@
QString ConfigFile::defaultUpdateChannel() const
{
const auto isBranded = Theme::instance()->isBranded();
if (serverHasValidSubscription() && !isBranded) {
if (const auto serverChannel = desktopEnterpriseChannel();
validUpdateChannels().contains(serverChannel)) {
qCInfo(lcConfigFile()) << "Default update channel is" << serverChannel << "because that is the desktop enterprise channel returned by the server.";
const QString defaultChannel = UpdateChannel::defaultUpdateChannel().toString();

if (isBranded) {
qCInfo(lcConfigFile()) << "Default update channel is" << defaultChannel
<< "because branded clients only support the default channel.";
return defaultChannel;
}

const QStringList validChannels = validUpdateChannels();
const bool hasSubscription = serverHasValidSubscription();
const bool hasServerChannel = hasDesktopEnterpriseChannel();

if (hasSubscription && hasServerChannel) {
const auto serverChannel = desktopEnterpriseChannel();
if (validChannels.contains(serverChannel)) {
qCInfo(lcConfigFile()) << "Default update channel is" << serverChannel
<< "because it was provided by the server.";
return serverChannel;
}
qCInfo(lcConfigFile()) << "Ignoring invalid server-provided update channel" << serverChannel;
}

if (const auto currentVersionSuffix = Theme::instance()->versionSuffix();
validUpdateChannels().contains(currentVersionSuffix) && !isBranded) {
qCInfo(lcConfigFile()) << "Default update channel is" << currentVersionSuffix << "because of the version suffix of the current client.";
return currentVersionSuffix;
if (hasSubscription && !hasServerChannel) {
qCDebug(lcConfigFile()) << "No desktop enterprise channel configured by server.";
}

qCInfo(lcConfigFile()) << "Default update channel is" << UpdateChannel::defaultUpdateChannel().toString();
return UpdateChannel::defaultUpdateChannel().toString();
const auto versionSuffix = Theme::instance()->versionSuffix();
if (validChannels.contains(versionSuffix)) {
qCInfo(lcConfigFile()) << "Default update channel is" << versionSuffix
<< "because of the current client build.";
return versionSuffix;
}

qCInfo(lcConfigFile()) << "Default update channel is" << defaultChannel;
return defaultChannel;
}

QString ConfigFile::currentUpdateChannel() const
{
if (const auto isBranded = Theme::instance()->isBranded(); isBranded) {
return UpdateChannel::defaultUpdateChannel().toString();
const auto isBranded = Theme::instance()->isBranded();
const QString defaultChannel = UpdateChannel::defaultUpdateChannel().toString();

if (isBranded) {
return defaultChannel;
}

const QStringList validChannels = validUpdateChannels();
QSettings settings(configFile(), QSettings::IniFormat);
const auto currentChannel = UpdateChannel::fromString(settings.value(QLatin1String(updateChannelC), defaultUpdateChannel()).toString());

auto currentChannel = UpdateChannel::fromString(
settings.value(QLatin1String(updateChannelC), defaultUpdateChannel()).toString());

if (!validChannels.contains(currentChannel.toString())) {
currentChannel = UpdateChannel::fromString(defaultUpdateChannel());
}

if (serverHasValidSubscription()) {
const auto enterpriseChannel = UpdateChannel::fromString(desktopEnterpriseChannel());
return UpdateChannel::mostStable(currentChannel, enterpriseChannel).toString();
currentChannel = UpdateChannel::mostStable(currentChannel, enterpriseChannel);

if (!validChannels.contains(currentChannel.toString())) {
currentChannel = UpdateChannel::fromString(defaultUpdateChannel());
}
}

return currentChannel.toString();
Expand Down Expand Up @@ -1028,7 +1063,7 @@
return getValue(forceLoginV2C, QString(), false).toBool();
}

void ConfigFile::setForceLoginV2(bool isChecked)

Check warning on line 1066 in src/libsync/configfile.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unmodified variable "isChecked" of type "_Bool" should be const-qualified.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ5BMJquZAE0R6ifmkNw&open=AZ5BMJquZAE0R6ifmkNw&pullRequest=10058
{
setValue(forceLoginV2C, isChecked);
}
Expand All @@ -1055,7 +1090,7 @@
return settings.value(QLatin1String(deleteFilesThresholdC), deleteFilesThresholdDefaultValue).toInt();
}

void ConfigFile::setDeleteFilesThreshold(int thresholdValue)

Check warning on line 1093 in src/libsync/configfile.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

This function should be declared "const".

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ5BMJquZAE0R6ifmkNx&open=AZ5BMJquZAE0R6ifmkNx&pullRequest=10058
{
QSettings settings(configFile(), QSettings::IniFormat);
settings.setValue(QLatin1String(deleteFilesThresholdC), thresholdValue);
Expand Down Expand Up @@ -1195,7 +1230,7 @@

bool ConfigFile::launchOnSystemStartup() const
{
QSettings settings(configFile(), QSettings::IniFormat);

Check warning on line 1233 in src/libsync/configfile.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unmodified variable "settings" of type "class QSettings" should be const-qualified.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ5BMJquZAE0R6ifmkN0&open=AZ5BMJquZAE0R6ifmkN0&pullRequest=10058
return settings.value(launchOnSystemStartupC, true).toBool();
}

Expand All @@ -1211,7 +1246,7 @@
return settings.value(QLatin1String(serverHasValidSubscriptionC), false).toBool();
}

void ConfigFile::setServerHasValidSubscription(const bool valid)

Check warning on line 1249 in src/libsync/configfile.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

This function should be declared "const".

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ5BMJquZAE0R6ifmkN3&open=AZ5BMJquZAE0R6ifmkN3&pullRequest=10058
{
QSettings settings(configFile(), QSettings::IniFormat);
settings.setValue(QLatin1String(serverHasValidSubscriptionC), valid);
Expand All @@ -1219,11 +1254,17 @@

QString ConfigFile::desktopEnterpriseChannel() const
{
QSettings settings(configFile(), QSettings::IniFormat);

Check warning on line 1257 in src/libsync/configfile.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unmodified variable "settings" of type "class QSettings" should be const-qualified.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ5BMJquZAE0R6ifmkN4&open=AZ5BMJquZAE0R6ifmkN4&pullRequest=10058
return settings.value(QLatin1String(desktopEnterpriseChannelName), UpdateChannel::defaultUpdateChannel().toString()).toString();
}

bool ConfigFile::hasDesktopEnterpriseChannel() const
{
QSettings settings(configFile(), QSettings::IniFormat);

Check warning on line 1263 in src/libsync/configfile.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unmodified variable "settings" of type "class QSettings" should be const-qualified.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ5BMJquZAE0R6ifmkN5&open=AZ5BMJquZAE0R6ifmkN5&pullRequest=10058
return settings.contains(QLatin1String(desktopEnterpriseChannelName));
}

void ConfigFile::setDesktopEnterpriseChannel(const QString &channel)

Check warning on line 1267 in src/libsync/configfile.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

This function should be declared "const".

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ5BMJquZAE0R6ifmkN6&open=AZ5BMJquZAE0R6ifmkN6&pullRequest=10058
{
QSettings settings(configFile(), QSettings::IniFormat);
settings.setValue(QLatin1String(desktopEnterpriseChannelName), UpdateChannel::fromString(channel).toString());
Expand All @@ -1235,7 +1276,7 @@
return settings.value(QLatin1String(languageC), QLatin1String("")).toString();
}

void ConfigFile::setLanguage(const QString& language)

Check warning on line 1279 in src/libsync/configfile.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

This function should be declared "const".

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ5BMJquZAE0R6ifmkN8&open=AZ5BMJquZAE0R6ifmkN8&pullRequest=10058
{
QSettings settings(configFile(), QSettings::IniFormat);
settings.setValue(QLatin1String(languageC), language);
Expand All @@ -1243,11 +1284,11 @@

uint ConfigFile::lastSelectedAccount() const
{
QSettings settings(configFile(), QSettings::IniFormat);

Check warning on line 1287 in src/libsync/configfile.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unmodified variable "settings" of type "class QSettings" should be const-qualified.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ5BMJquZAE0R6ifmkN9&open=AZ5BMJquZAE0R6ifmkN9&pullRequest=10058
return settings.value(QLatin1String(lastSelectedAccountC), QLatin1String("")).toUInt();
}

void ConfigFile::setLastSelectedAccount(const uint accountId)

Check warning on line 1291 in src/libsync/configfile.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

This function should be declared "const".

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ5BMJquZAE0R6ifmkN-&open=AZ5BMJquZAE0R6ifmkN-&pullRequest=10058
{
QSettings settings(configFile(), QSettings::IniFormat);
settings.setValue(QLatin1String(lastSelectedAccountC), accountId);
Expand Down Expand Up @@ -1315,7 +1356,7 @@
_discoveredLegacyConfigPath = discoveredLegacyConfigPath;
}

void ConfigFile::removeFileProviderDomainMapping()

Check warning on line 1359 in src/libsync/configfile.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

This function should be declared "const".

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ5BMJquZAE0R6ifmkN_&open=AZ5BMJquZAE0R6ifmkN_&pullRequest=10058
{
QSettings settings(configFile(), QSettings::IniFormat);
settings.remove(QLatin1String(fileProviderDomainUuidsGroupC));
Expand All @@ -1323,13 +1364,13 @@
settings.sync();
}

bool ConfigFile::fileProviderDomainsAppSandboxMigrationCompleted() const

Check warning on line 1367 in src/libsync/configfile.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this identifier to be shorter or equal to 31 characters.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ5BMJquZAE0R6ifmkOA&open=AZ5BMJquZAE0R6ifmkOA&pullRequest=10058
{
QSettings settings(configFile(), QSettings::IniFormat);

Check warning on line 1369 in src/libsync/configfile.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unmodified variable "settings" of type "class QSettings" should be const-qualified.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ5BMJquZAE0R6ifmkOB&open=AZ5BMJquZAE0R6ifmkOB&pullRequest=10058
return settings.value(fileProviderDomainsAppSandboxMigrationCompletedC, false).toBool();
}

void ConfigFile::setFileProviderDomainsAppSandboxMigrationCompleted(const bool completed)

Check warning on line 1373 in src/libsync/configfile.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this identifier to be shorter or equal to 31 characters.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ5BMJquZAE0R6ifmkOC&open=AZ5BMJquZAE0R6ifmkOC&pullRequest=10058

Check warning on line 1373 in src/libsync/configfile.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

This function should be declared "const".

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ5BMJquZAE0R6ifmkOD&open=AZ5BMJquZAE0R6ifmkOD&pullRequest=10058
{
QSettings settings(configFile(), QSettings::IniFormat);
settings.setValue(fileProviderDomainsAppSandboxMigrationCompletedC, completed);
Expand All @@ -1356,7 +1397,7 @@
&& !discoveredLegacyConfigPath().isEmpty();
}

bool ConfigFile::isUnbrandedToBrandedMigrationInProgress() const

Check warning on line 1400 in src/libsync/configfile.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this identifier to be shorter or equal to 31 characters.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ5BMJquZAE0R6ifmkOF&open=AZ5BMJquZAE0R6ifmkOF&pullRequest=10058
{
return isMigrationInProgress() && Theme::instance()->appName() != unbrandedAppName;
}
Expand All @@ -1378,7 +1419,7 @@
return _migrationPhase != MigrationPhase::NotStarted && _migrationPhase != MigrationPhase::Done;
}

void ConfigFile::setMigrationPhase(const MigrationPhase phase)

Check warning on line 1422 in src/libsync/configfile.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

This function should be declared "const".

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ5BMJquZAE0R6ifmkOG&open=AZ5BMJquZAE0R6ifmkOG&pullRequest=10058
{
// do not rollback
if (phase > _migrationPhase) {
Expand Down
2 changes: 2 additions & 0 deletions src/libsync/configfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#ifndef CONFIGFILE_H
#define CONFIGFILE_H

#include "owncloudlib.h"

Check failure on line 10 in src/libsync/configfile.h

View workflow job for this annotation

GitHub Actions / build

src/libsync/configfile.h:10:10 [clang-diagnostic-error]

'owncloudlib.h' file not found
#include <memory>
#include <QSharedPointer>
#include <QSettings>
Expand Down Expand Up @@ -42,7 +42,7 @@
static QString excludeFileFromSystem(); // doesn't access config dir

void cleanUpdaterConfiguration();
void cleanupGlobalNetworkConfiguration();

Check warning on line 45 in src/libsync/configfile.h

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this identifier to be shorter or equal to 31 characters.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ5BMJnPZAE0R6ifmkNL&open=AZ5BMJnPZAE0R6ifmkNL&pullRequest=10058

/**
* Creates a backup of any given fileName in the config folder
Expand Down Expand Up @@ -149,7 +149,7 @@
[[nodiscard]] bool moveToTrash() const;
void setMoveToTrash(bool);

/** If we should force loginflow v2 */

Check warning on line 152 in src/libsync/configfile.h

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Edit this comment to use the C++ format, i.e. "//".

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ5BMJnPZAE0R6ifmkNI&open=AZ5BMJnPZAE0R6ifmkNI&pullRequest=10058
[[nodiscard]] bool forceLoginV2() const;
void setForceLoginV2(bool);

Expand All @@ -167,7 +167,7 @@
void setShowCallNotifications(bool show);

[[nodiscard]] bool showQuotaWarningNotifications() const;
void setShowQuotaWarningNotifications(bool show);

Check warning on line 170 in src/libsync/configfile.h

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this identifier to be shorter or equal to 31 characters.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ5BMJnPZAE0R6ifmkNM&open=AZ5BMJnPZAE0R6ifmkNM&pullRequest=10058

[[nodiscard]] bool showInExplorerNavigationPane() const;
void setShowInExplorerNavigationPane(bool show);
Expand Down Expand Up @@ -238,6 +238,8 @@
[[nodiscard]] QString desktopEnterpriseChannel() const;
void setDesktopEnterpriseChannel(const QString &channel);

[[nodiscard]] bool hasDesktopEnterpriseChannel() const;

/// Enforce a specific language used for the UI
[[nodiscard]] QString language() const;
void setLanguage(const QString &language);
Expand All @@ -259,17 +261,17 @@

/// File Provider Domain UUID to Account ID mapping

/**
* @brief Completely removes the now obsolete "FileProviderAccountIds" and "FileProviderDomainUuids" groups from the configuration file.
*/

Check warning on line 266 in src/libsync/configfile.h

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Edit this comment to use the C++ format, i.e. "//".

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ5BMJnPZAE0R6ifmkNK&open=AZ5BMJnPZAE0R6ifmkNK&pullRequest=10058
void removeFileProviderDomainMapping();

/// File Provider app sandbox migration flag
[[nodiscard]] bool fileProviderDomainsAppSandboxMigrationCompleted() const;

Check warning on line 270 in src/libsync/configfile.h

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this identifier to be shorter or equal to 31 characters.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ5BMJnPZAE0R6ifmkNN&open=AZ5BMJnPZAE0R6ifmkNN&pullRequest=10058
void setFileProviderDomainsAppSandboxMigrationCompleted(bool completed);

Check warning on line 271 in src/libsync/configfile.h

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this identifier to be shorter or equal to 31 characters.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ5BMJnPZAE0R6ifmkNO&open=AZ5BMJnPZAE0R6ifmkNO&pullRequest=10058

/// Helper function for migration/upgrade proccess
enum MigrationPhase {

Check warning on line 274 in src/libsync/configfile.h

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace this "enum" with "enum class".

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ5BMJnPZAE0R6ifmkNP&open=AZ5BMJnPZAE0R6ifmkNP&pullRequest=10058
NotStarted,
SetupConfigFile,
SetupUsers,
Expand All @@ -278,8 +280,8 @@
};
[[nodiscard]] bool isUpgrade() const;
[[nodiscard]] bool isDowngrade() const;
[[nodiscard]] bool shouldTryUnbrandedToBrandedMigration() const;

Check warning on line 283 in src/libsync/configfile.h

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this identifier to be shorter or equal to 31 characters.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ5BMJnPZAE0R6ifmkNQ&open=AZ5BMJnPZAE0R6ifmkNQ&pullRequest=10058
[[nodiscard]] bool isUnbrandedToBrandedMigrationInProgress() const;

Check warning on line 284 in src/libsync/configfile.h

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this identifier to be shorter or equal to 31 characters.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ5BMJnPZAE0R6ifmkNR&open=AZ5BMJnPZAE0R6ifmkNR&pullRequest=10058
[[nodiscard]] bool shouldTryToMigrate() const;
/// Does the current app has a different version of the config version
[[nodiscard]] bool hasVersionChanged() const;
Expand All @@ -304,7 +306,7 @@
static constexpr char useNewBigFolderSizeLimitC[] = "useNewBigFolderSizeLimit";
static constexpr char newBigFolderSizeLimitC[] = "newBigFolderSizeLimit";
static constexpr char notifyExistingFoldersOverLimitC[] = "notifyExistingFoldersOverLimit";
static constexpr char stopSyncingExistingFoldersOverLimitC[] = "stopSyncingExistingFoldersOverLimit";

Check warning on line 309 in src/libsync/configfile.h

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this identifier to be shorter or equal to 31 characters.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ5BMJnPZAE0R6ifmkNS&open=AZ5BMJnPZAE0R6ifmkNS&pullRequest=10058
static constexpr char moveToTrashC[] = "moveToTrash";
static constexpr char updateChannelC[] = "updateChannel";
static constexpr char autoUpdateCheckC[] = "autoUpdateCheck";
Expand Down
Loading