Skip to content
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
34 changes: 20 additions & 14 deletions src/gui/accountsettings.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/*
* SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2014 ownCloud GmbH
Expand Down Expand Up @@ -216,21 +216,27 @@
new ToolTipUpdater(_ui->_folderList);

#if defined(BUILD_FILE_PROVIDER_MODULE)
const auto fileProviderPanelContents = _ui->fileProviderPanelContents;
const auto fpSettingsLayout = new QVBoxLayout(fileProviderPanelContents);
const auto fpAccountUserIdAtHost = _accountState->account()->userIdAtHostWithPort();
const auto fpSettingsController = Mac::FileProviderSettingsController::instance();
const auto fpSettingsWidget = fpSettingsController->settingsViewWidget(fpAccountUserIdAtHost, fileProviderPanelContents,
QQuickWidget::SizeRootObjectToView);
fpSettingsLayout->setContentsMargins(0, 0, 0, 0);
fpSettingsLayout->setSpacing(0);

fpSettingsWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
if (const auto fpSettingsWidgetLayout = fpSettingsWidget->layout()) {
fpSettingsWidgetLayout->setContentsMargins(0, 0, 0, 0);
if (Mac::FileProvider::available()) {
const auto fileProviderPanelContents = _ui->fileProviderPanelContents;
const auto fpSettingsLayout = new QVBoxLayout(fileProviderPanelContents);
const auto fpAccountUserIdAtHost = _accountState->account()->userIdAtHostWithPort();
const auto fpSettingsController = Mac::FileProviderSettingsController::instance();
const auto fpSettingsWidget = fpSettingsController->settingsViewWidget(fpAccountUserIdAtHost, fileProviderPanelContents,
QQuickWidget::SizeRootObjectToView);
fpSettingsLayout->setContentsMargins(0, 0, 0, 0);
fpSettingsLayout->setSpacing(0);

fpSettingsWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
if (const auto fpSettingsWidgetLayout = fpSettingsWidget->layout()) {
fpSettingsWidgetLayout->setContentsMargins(0, 0, 0, 0);
}
fpSettingsLayout->addWidget(fpSettingsWidget, 1);
fileProviderPanelContents->setLayout(fpSettingsLayout);
} else {
// macOS 13 Ventura: the file provider feature is unsupported there.
// This branch can be removed once Ventura is no longer supported.
_ui->fileProviderPanel->setVisible(false);
}
fpSettingsLayout->addWidget(fpSettingsWidget, 1);
fileProviderPanelContents->setLayout(fpSettingsLayout);
#else
_ui->fileProviderPanel->setVisible(false);
#endif
Expand Down
9 changes: 9 additions & 0 deletions src/gui/macOS/fileprovider.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#pragma once

#include <QObject>

Check failure on line 8 in src/gui/macOS/fileprovider.h

View workflow job for this annotation

GitHub Actions / build

src/gui/macOS/fileprovider.h:8:10 [clang-diagnostic-error]

'QObject' file not found

#include "fileproviderdomainmanager.h"
#include "fileproviderservice.h"
Expand All @@ -29,6 +29,15 @@
static FileProvider *instance();
~FileProvider() override;

/**
* @brief Whether the macOS file provider feature is usable on the current OS.
*
* Returns false on macOS 13 Ventura, where the extension is incompatible
* (see nextcloud/desktop#9927). This runtime check can be removed once
* macOS 13 Ventura is no longer supported.
*/
[[nodiscard]] static bool available();

void configureXPC();
[[nodiscard]] FileProviderXPC *xpc() const;
[[nodiscard]] FileProviderDomainManager *domainManager() const;
Expand Down
11 changes: 11 additions & 0 deletions src/gui/macOS/fileprovider_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "fileprovider.h"

#include <QLoggingCategory>
#include <QOperatingSystemVersion>

#include "libsync/configfile.h"
#include "gui/macOS/fileproviderxpc.h"
Expand Down Expand Up @@ -54,13 +55,23 @@
return _instance;
}

bool FileProvider::available()
{
return QOperatingSystemVersion::current() >= QOperatingSystemVersion::MacOSSonoma;
}

FileProvider::~FileProvider()
{
_instance = nullptr;
}

void FileProvider::configureXPC()
{
if (!available()) {
qCInfo(lcMacFileProvider) << "Skipping file provider XPC configuration on unsupported macOS version.";
return;
}

_xpc = std::make_unique<FileProviderXPC>(new FileProviderXPC(this));

if (_xpc) {
Expand Down
37 changes: 34 additions & 3 deletions src/gui/macOS/fileprovidersettingscontroller_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,14 @@ explicit MacImplementation(FileProviderSettingsController *const parent)

migrateToAppSandbox();
removeOrphanedDomains();
restoreMissingDomains();
Mac::FileProvider::instance()->domainManager()->reconnectAll();
Mac::FileProvider::instance()->configureXPC();

if (Mac::FileProvider::available()) {
restoreMissingDomains();
Mac::FileProvider::instance()->domainManager()->reconnectAll();
Mac::FileProvider::instance()->configureXPC();
} else {
disableFileProviderForAllEnabledAccountsOnUnsupportedOS();
}
};

~MacImplementation() override = default;
Expand Down Expand Up @@ -286,6 +291,32 @@ void removeOrphanedDomains()
qCInfo(lcFileProviderSettingsController) << "Finished removing orphaned domains.";
}

// macOS 13 Ventura cleanup: removes any pre-existing file provider domain
// gracefully (preserving dirty user data) for each account that still has
// VFS enabled. Can be deleted once Ventura is no longer supported.
void disableFileProviderForAllEnabledAccountsOnUnsupportedOS()
{
qCInfo(lcFileProviderSettingsController) << "macOS 13 Ventura: disabling file provider for all enabled accounts.";

const auto accountStates = AccountManager::instance()->accounts();

for (const auto &accountState : accountStates) {
const auto account = accountState->account();

if (!account) {
continue;
}

if (account->fileProviderDomainIdentifier().isEmpty()) {
continue;
}

const auto userIdAtHost = account->userIdAtHostWithPort();
qCInfo(lcFileProviderSettingsController) << "Disabling file provider for account" << userIdAtHost;
(void)setVfsEnabledForAccount(userIdAtHost, false);
}
}

private:
[[maybe_unused]] FileProviderSettingsController *q = nullptr;
};
Expand Down
12 changes: 6 additions & 6 deletions src/gui/wizard/owncloudadvancedsetuppage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* SPDX-License-Identifier: GPL-2.0-or-later
*/

#include <QDir>

Check failure on line 7 in src/gui/wizard/owncloudadvancedsetuppage.cpp

View workflow job for this annotation

GitHub Actions / build

src/gui/wizard/owncloudadvancedsetuppage.cpp:7:10 [clang-diagnostic-error]

'QDir' file not found
#include <QFileDialog>
#include <QUrl>
#include <QTimer>
Expand Down Expand Up @@ -106,7 +106,7 @@
#ifdef Q_OS_WIN
bestAvailableVfsMode() == Vfs::WindowsCfApi
#elif defined(BUILD_FILE_PROVIDER_MODULE)
true
Mac::FileProvider::available()
#else
false
#endif
Expand Down Expand Up @@ -149,14 +149,14 @@
{
WizardCommon::initErrorLabel(_ui.errorLabel);

if (Theme::instance()->disableVirtualFilesSyncFolder()
|| !(Theme::instance()->showVirtualFilesOption()
const auto hideVfsOption = Theme::instance()->disableVirtualFilesSyncFolder()
#ifdef BUILD_FILE_PROVIDER_MODULE
|| true
|| !Mac::FileProvider::available();
#else
&& bestAvailableVfsMode() != Vfs::Off
|| !(Theme::instance()->showVirtualFilesOption() && bestAvailableVfsMode() != Vfs::Off);
#endif
)) {

if (hideVfsOption) {

Check warning on line 159 in src/gui/wizard/owncloudadvancedsetuppage.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use the init-statement to declare "hideVfsOption" inside the if statement.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ4hDXjeoPSkFHa0dAvD&open=AZ4hDXjeoPSkFHa0dAvD&pullRequest=10023
// If the layout were wrapped in a widget, the auto-grouping of the
// radio buttons no longer works and there are surprising margins.
// Just manually hide the button and remove the layout.
Expand Down
2 changes: 1 addition & 1 deletion src/gui/wizard/owncloudwizard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* SPDX-License-Identifier: GPL-2.0-or-later
*/

#include "account.h"

Check failure on line 7 in src/gui/wizard/owncloudwizard.cpp

View workflow job for this annotation

GitHub Actions / build

src/gui/wizard/owncloudwizard.cpp:7:10 [clang-diagnostic-error]

'account.h' file not found
#include "config.h"
#include "configfile.h"
#include "theme.h"
Expand Down Expand Up @@ -233,7 +233,7 @@
bool OwncloudWizard::useVirtualFileSyncByDefault() const
{
#ifdef BUILD_FILE_PROVIDER_MODULE
return true;
return Mac::FileProvider::available();
#else
return false;
#endif
Expand Down
Loading