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
12 changes: 12 additions & 0 deletions resources.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,18 @@
<file>src/gui/ResolveConflictsDialog.qml</file>
<file>src/gui/ConflictDelegate.qml</file>
<file>src/gui/ConflictItemFileInfo.qml</file>
<file>src/gui/wizard/qml/AccountWizardWindow.qml</file>
<file>src/gui/wizard/qml/AdvancedOptionsDialog.qml</file>
<file>src/gui/wizard/qml/BasicAuthPage.qml</file>
<file>src/gui/wizard/qml/BrowserAuthPage.qml</file>
<file>src/gui/wizard/qml/ClientCertificateDialog.qml</file>
<file>src/gui/wizard/qml/OptionRow.qml</file>
<file>src/gui/wizard/qml/ProxySettingsDialog.qml</file>
<file>src/gui/wizard/qml/ServerPage.qml</file>
<file>src/gui/wizard/qml/SyncOptionsPage.qml</file>
<file>src/gui/wizard/qml/WizardButton.qml</file>
<file>src/gui/wizard/qml/WizardDialogFrame.qml</file>
<file>src/gui/wizard/qml/WizardTextField.qml</file>
<file>src/gui/macOS/ui/FileProviderSettings.qml</file>
<file>src/gui/macOS/ui/FileProviderFileDelegate.qml</file>
<file>src/gui/integration/FileActionsWindow.qml</file>
Expand Down
40 changes: 2 additions & 38 deletions src/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,12 @@ set(client_UI_SRCS
ignorelisttablewidget.ui
networksettings.ui
sslerrordialog.ui
addcertificatedialog.ui
passwordinputdialog.ui
proxyauthdialog.ui
mnemonicdialog.ui
vfsdownloaderrordialog.ui
wizard/flow2authwidget.ui
wizard/owncloudadvancedsetuppage.ui
wizard/owncloudconnectionmethoddialog.ui
wizard/owncloudhttpcredspage.ui
wizard/owncloudsetupnocredspage.ui
wizard/termsofservicecheckwidget.ui
wizard/webview.ui
wizard/welcomepage.ui
wizard/proxysettings.ui
)

qt_add_resources(client_UI_SRCS ../../resources.qrc ${CMAKE_SOURCE_DIR}/theme.qrc)
Expand Down Expand Up @@ -156,8 +148,6 @@ set(client_SRCS
vfsdownloaderrordialog.cpp
accountstate.h
accountstate.cpp
addcertificatedialog.h
addcertificatedialog.cpp
authenticationdialog.h
authenticationdialog.cpp
proxyauthhandler.h
Expand Down Expand Up @@ -225,36 +215,12 @@ set(client_SRCS
creds/webflowcredentials.cpp
creds/webflowcredentialsdialog.h
creds/webflowcredentialsdialog.cpp
wizard/abstractcredswizardpage.h
wizard/abstractcredswizardpage.cpp
wizard/owncloudadvancedsetuppage.h
wizard/owncloudadvancedsetuppage.cpp
wizard/owncloudconnectionmethoddialog.h
wizard/owncloudconnectionmethoddialog.cpp
wizard/owncloudhttpcredspage.h
wizard/owncloudhttpcredspage.cpp
wizard/flow2authcredspage.h
wizard/flow2authcredspage.cpp
wizard/accountwizardcontroller.h
wizard/accountwizardcontroller.cpp
wizard/flow2authwidget.h
wizard/flow2authwidget.cpp
wizard/owncloudsetuppage.h
wizard/owncloudsetuppage.cpp
wizard/termsofservicecheckwidget.h
wizard/termsofservicecheckwidget.cpp
wizard/termsofservicewizardpage.h
wizard/termsofservicewizardpage.cpp
wizard/owncloudwizardcommon.h
wizard/owncloudwizardcommon.cpp
wizard/owncloudwizard.h
wizard/owncloudwizard.cpp
wizard/slideshow.h
wizard/slideshow.cpp
wizard/welcomepage.h
wizard/welcomepage.cpp
wizard/linklabel.h
wizard/linklabel.cpp
wizard/wizardproxysettingsdialog.h
wizard/wizardproxysettingsdialog.cpp
integration/fileactionsmodel.h
integration/fileactionsmodel.cpp
)
Expand All @@ -268,8 +234,6 @@ endif()

if (WITH_WEBENGINE)
list(APPEND client_SRCS
wizard/webviewpage.h
wizard/webviewpage.cpp
wizard/webview.h
wizard/webview.cpp
)
Expand Down
26 changes: 20 additions & 6 deletions src/gui/accountmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@
qCDebug(lcAccountManager) << "Saved account state settings, status:" << settings->status();
}

void AccountManager::saveAccountHelper(const AccountPtr &account, QSettings &settings, bool saveCredentials)

Check failure on line 420 in src/gui/accountmanager.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Refactor this function to reduce its Cognitive Complexity from 34 to the 25 allowed.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ6N8Kkf_Beasad6n7dn&open=AZ6N8Kkf_Beasad6n7dn&pullRequest=10030
{
qCDebug(lcAccountManager) << "Saving settings to" << settings.fileName();
settings.setValue(QLatin1String(versionC), maxAccountVersion);
Expand Down Expand Up @@ -765,26 +765,40 @@
return newAccountState;
}

void AccountManager::deleteAccount(OCC::AccountState *account)

Check warning on line 768 in src/gui/accountmanager.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unmodified variable "account" of type "class OCC::AccountState *" should be const-qualified.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ6N8Kkf_Beasad6n7du&open=AZ6N8Kkf_Beasad6n7du&pullRequest=10030
{
removeAccountState(account, AccountRemovalMode::ForgetSensitiveData);
}

void AccountManager::removeAccountState(OCC::AccountState *account)
{
removeAccountState(account, AccountRemovalMode::KeepSensitiveData);
}

void AccountManager::removeAccountState(OCC::AccountState *account, AccountRemovalMode removalMode)

Check warning on line 778 in src/gui/accountmanager.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unmodified variable "account" of type "class OCC::AccountState *" should be const-qualified.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ6N8Kkf_Beasad6n7dw&open=AZ6N8Kkf_Beasad6n7dw&pullRequest=10030
{
const auto it = std::find(_accounts.begin(), _accounts.end(), account);

Check warning on line 780 in src/gui/accountmanager.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace with the version of "std::ranges::find" that takes a range.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ6N8Kkf_Beasad6n7dy&open=AZ6N8Kkf_Beasad6n7dy&pullRequest=10030
if (it == _accounts.end()) {
return;
}
const auto copy = *it; // keep a reference to the shared pointer so it does not delete it just yet
_accounts.erase(it);

// Forget account credentials, cookies
account->account()->credentials()->forgetSensitiveData();
QFile::remove(account->account()->cookieJarPath());
if (removalMode == AccountRemovalMode::ForgetSensitiveData) {
// Forget account credentials, cookies
account->account()->credentials()->forgetSensitiveData();
QFile::remove(account->account()->cookieJarPath());
}

const auto settings = ConfigFile::settingsWithGroup(QLatin1String(accountsC));
settings->remove(account->account()->id());

// Forget E2E keys
account->account()->e2e()->forgetSensitiveData();
if (removalMode == AccountRemovalMode::ForgetSensitiveData) {
// Forget E2E keys
account->account()->e2e()->forgetSensitiveData();

account->account()->deleteAppToken();
account->account()->deleteAppToken();
}

// clean up config from subscriptions and enterprise channel
updateServerHasValidSubscriptionConfig();
Expand Down
9 changes: 9 additions & 0 deletions src/gui/accountmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#pragma once

#include "account.h"

Check failure on line 9 in src/gui/accountmanager.h

View workflow job for this annotation

GitHub Actions / build

src/gui/accountmanager.h:9:10 [clang-diagnostic-error]

'account.h' file not found
#include "accountstate.h"

namespace OCC {
Expand Down Expand Up @@ -96,6 +96,9 @@
/// Delete the AccountState
void deleteAccount(OCC::AccountState *account);

/// Remove the AccountState without clearing credentials from the shared account
void removeAccountState(OCC::AccountState *account);

/// Remove all accounts
void shutdown();

Expand All @@ -116,10 +119,16 @@
void accountListInitialized();

private:
enum class AccountRemovalMode {
KeepSensitiveData,
ForgetSensitiveData,
};

// saving and loading Account to settings
void saveAccountHelper(const AccountPtr &account, QSettings &settings, bool saveCredentials = true);
AccountPtr loadAccountHelper(QSettings &settings);
void migrateNetworkSettings(const AccountPtr &account, const QSettings &settings);
void removeAccountState(OCC::AccountState *account, AccountRemovalMode removalMode);

bool restoreFromLegacySettings();

Expand All @@ -131,7 +140,7 @@

// update config serverHasValidSubscription when accounts list changes
void updateServerHasValidSubscriptionConfig();
void updateServerDesktopEnterpriseUpdateChannel();

Check warning on line 143 in src/gui/accountmanager.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=AZ6N8Krc_Beasad6n7d4&open=AZ6N8Krc_Beasad6n7d4&pullRequest=10030

AccountManager() = default;
QList<AccountStatePtr> _accounts;
Expand Down
3 changes: 1 addition & 2 deletions src/gui/accountsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
#include "encryptfolderjob.h"
#include "syncresult.h"
#include "ignorelisttablewidget.h"
#include "wizard/owncloudwizard.h"
#include "networksettings.h"
#include "ui_mnemonicdialog.h"

Expand Down Expand Up @@ -70,7 +69,7 @@
#include "common/macsandboxpersistentaccess.h"
#endif

#include "account.h"

Check warning on line 72 in src/gui/accountsettings.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Move this #include directive to the top of the file.

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

namespace {
constexpr auto propertyFolder = "folder";
Expand Down Expand Up @@ -171,7 +170,7 @@
AccountSettings::AccountSettings(AccountState *accountState, QWidget *parent)
: QWidget(parent)
, _ui(new Ui::AccountSettings)
, _model(new FolderStatusModel)

Check failure on line 173 in src/gui/accountsettings.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace the use of "new" with an operation that automatically manages the memory.

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

Check warning on line 173 in src/gui/accountsettings.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Do not use the constructor's initializer list for data member "_model". Use the in-class initializer instead.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ6IlsqdbP66BePx4vtM&open=AZ6IlsqdbP66BePx4vtM&pullRequest=10030
, _accountState(accountState)
, _userInfo(accountState, false, true)
{
Expand Down Expand Up @@ -471,7 +470,7 @@
return true;
}

void AccountSettings::slotMarkSubfolderEncrypted(FolderStatusModel::SubFolderInfo* folderInfo)

Check warning on line 473 in src/gui/accountsettings.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make the type of this parameter a pointer-to-const. The current type of "folderInfo" is "struct OCC::FolderStatusModel::SubFolderInfo *".

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ6IlsqdbP66BePx4vtP&open=AZ6IlsqdbP66BePx4vtP&pullRequest=10030
{
if (!canEncryptOrDecrypt(folderInfo)) {
return;
Expand All @@ -482,7 +481,7 @@

const auto folderAlias = folder->alias();
const auto path = folderInfo->_path;
const auto fileId = folderInfo->_fileId;

Check warning on line 484 in src/gui/accountsettings.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Avoid this unnecessary copy by using a "const" reference.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ6IlsqdbP66BePx4vtR&open=AZ6IlsqdbP66BePx4vtR&pullRequest=10030
const auto encryptFolder = [this, fileId, path, folderAlias] {
const auto folder = FolderMan::instance()->folder(folderAlias);
if (!folder) {
Expand All @@ -495,7 +494,7 @@
Q_ASSERT(!path.startsWith('/') && path.endsWith('/'));
// But EncryptFolderJob expects directory path Foo/Bar convention
const auto choppedPath = path.chopped(1);
auto job = new OCC::EncryptFolderJob(accountsState()->account(), folder->journalDb(), choppedPath, choppedPath, folder->remotePath(), fileId);

Check warning on line 497 in src/gui/accountsettings.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unmodified variable "job" of type "class OCC::EncryptFolderJob *" should be const-qualified.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ6IlsqdbP66BePx4vtS&open=AZ6IlsqdbP66BePx4vtS&pullRequest=10030
job->setParent(this);
job->setProperty(propertyFolder, QVariant::fromValue(folder));
job->setProperty(propertyPath, QVariant::fromValue(path));
Expand Down Expand Up @@ -752,7 +751,7 @@
if (const auto mode = bestAvailableVfsMode();
!Theme::instance()->disableVirtualFilesSyncFolder() &&
Theme::instance()->showVirtualFilesOption() && !folder->virtualFilesEnabled() && Vfs::checkAvailability(folder->path(), mode)) {
if (mode == Vfs::WindowsCfApi || ConfigFile().showExperimentalOptions()) {

Check warning on line 754 in src/gui/accountsettings.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Merge this "if" statement with the enclosing one.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ6IlsqdbP66BePx4vtT&open=AZ6IlsqdbP66BePx4vtT&pullRequest=10030
ac = menu->addAction(tr("Enable virtual file support %1 …").arg(mode == Vfs::WindowsCfApi ? QString() : tr("(experimental)")));
// TODO: remove when UX decision is made
ac->setEnabled(!Utility::isPathWindowsDrivePartitionRoot(folder->path()));
Expand Down Expand Up @@ -1031,7 +1030,7 @@
return;
}

OwncloudWizard::askExperimentalVirtualFilesFeature(this, [folder, this](bool enable) {
Utility::askExperimentalVirtualFilesFeature(this, [folder, this](bool enable) {

Check warning on line 1033 in src/gui/accountsettings.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

This lambda has 39 lines, which is greater than the 20 lines authorized. Split it into several lambdas or functions, or make it a named function.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ6IlsqdbP66BePx4vtU&open=AZ6IlsqdbP66BePx4vtU&pullRequest=10030
if (!enable || !folder) {
return;
}
Expand Down Expand Up @@ -1822,9 +1821,9 @@

void AccountSettings::removeActionFromEncryptionMessage(const QString &actionId)
{
const auto foundEnableEncryptionActionIt = std::find_if(std::cbegin(_ui->encryptionMessage->actions()), std::cend(_ui->encryptionMessage->actions()), [&actionId](const QAction *action) {
return action->property(e2eUiActionIdKey).toString() == actionId;
});

Check warning on line 1826 in src/gui/accountsettings.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace with the version of "std::ranges::find_if" that takes a range.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ6IlsqdbP66BePx4vta&open=AZ6IlsqdbP66BePx4vta&pullRequest=10030
if (foundEnableEncryptionActionIt != std::cend(_ui->encryptionMessage->actions())) {
_ui->encryptionMessage->removeAction(*foundEnableEncryptionActionIt);
(*foundEnableEncryptionActionIt)->deleteLater();
Expand Down Expand Up @@ -1900,8 +1899,8 @@
stretchIndex = layout->count() - 1;
}

for (QAction *action : actions) {

Check warning on line 1902 in src/gui/accountsettings.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unmodified variable "action" of type "class QAction *" should be const-qualified.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ6IlsqdbP66BePx4vtd&open=AZ6IlsqdbP66BePx4vtd&pullRequest=10030
auto *button = new QPushButton(_ui->encryptionMessage);

Check warning on line 1903 in src/gui/accountsettings.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unmodified variable "button" of type "class QPushButton *" should be const-qualified.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ6IlsqdbP66BePx4vte&open=AZ6IlsqdbP66BePx4vte&pullRequest=10030
button->setText(action->text());
button->setIcon(action->icon());
button->setEnabled(action->isEnabled());
Expand Down
73 changes: 0 additions & 73 deletions src/gui/addcertificatedialog.cpp

This file was deleted.

43 changes: 0 additions & 43 deletions src/gui/addcertificatedialog.h

This file was deleted.

Loading
Loading