Skip to content

Commit

Permalink
Merge pull request #6351 from nextcloud/feature/file-provider-config-ui
Browse files Browse the repository at this point in the history
Add a configuration interface for macOS File Provider virtual files
  • Loading branch information
claucambra authored Feb 19, 2024
2 parents 8ab52b8 + 92a1d80 commit 478d65c
Show file tree
Hide file tree
Showing 44 changed files with 2,769 additions and 120 deletions.
7 changes: 6 additions & 1 deletion resources.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<file>src/gui/filedetails/FileDetailsView.qml</file>
<file>src/gui/filedetails/FileDetailsWindow.qml</file>
<file>src/gui/filedetails/FileTag.qml</file>
<file>src/gui/filedetails/NCInputDateField.qml</file>
<file>src/gui/filedetails/NCInputTextEdit.qml</file>
<file>src/gui/filedetails/NCInputTextField.qml</file>
<file>src/gui/filedetails/NCTabButton.qml</file>
Expand Down Expand Up @@ -61,6 +62,10 @@
<file>src/gui/ResolveConflictsDialog.qml</file>
<file>src/gui/ConflictDelegate.qml</file>
<file>src/gui/ConflictItemFileInfo.qml</file>
<file>src/gui/filedetails/NCInputDateField.qml</file>
<file>src/gui/macOS/ui/FileProviderSettings.qml</file>
<file>src/gui/macOS/ui/FileProviderFileDelegate.qml</file>
<file>src/gui/macOS/ui/FileProviderEvictionDialog.qml</file>
<file>src/gui/macOS/ui/FileProviderSyncStatus.qml</file>
<file>src/gui/macOS/ui/FileProviderStorageInfo.qml</file>
</qresource>
</RCC>
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,27 @@ extension Logger {
static let localFileOps = Logger(subsystem: subsystem, category: "localfileoperations")
static let ncFilesDatabase = Logger(subsystem: subsystem, category: "nextcloudfilesdatabase")
static let materialisedFileHandling = Logger(
subsystem: subsystem, category: "materialisedfilehandling")
subsystem: subsystem, category: "materialisedfilehandling"
)
static let logger = Logger(subsystem: subsystem, category: "logger")

@available(macOSApplicationExtension 12.0, *)
static func logEntries(interval: TimeInterval = -3600) -> (Array<String>?, Error?) {
do {
let logStore = try OSLogStore(scope: .currentProcessIdentifier)
let timeDate = Date().addingTimeInterval(interval)
let logPosition = logStore.position(date: timeDate)
let entries = try logStore.getEntries(at: logPosition)

return (entries
.compactMap { $0 as? OSLogEntryLog }
.filter { $0.subsystem == Logger.subsystem }
.map { $0.composedMessage }, nil)

} catch let error {
Logger.logger.error("Could not acquire os log store: \(error)");
return (nil, error)
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
serverUrl:(NSString *)serverUrl
password:(NSString *)password;
- (void)removeAccountConfig;
- (void)createDebugLogStringWithCompletionHandler:(void(^)(NSString *debugLogString, NSError *error))completionHandler;

@end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,21 @@ class ClientCommunicationService: NSObject, NSFileProviderServiceSource, NSXPCLi
func removeAccountConfig() {
self.fpExtension.removeAccountConfig()
}

func createDebugLogString(completionHandler: ((String?, Error?) -> Void)!) {
if #available(macOSApplicationExtension 12.0, *) {
let (logs, error) = Logger.logEntries()
guard error == nil else {
Logger.logger.error("Cannot create debug archive, received error: \(error, privacy: .public)")
completionHandler(nil, error)
return
}
guard let logs = logs else {
Logger.logger.error("Canot create debug archive with nil logs.")
completionHandler(nil, nil)
return
}
completionHandler(logs.joined(separator: "\n"), nil)
}
}
}
6 changes: 6 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ set_package_properties(Qt5Concurrent PROPERTIES
TYPE REQUIRED
)

find_package(Qt5QuickWidgets ${REQUIRED_QT_VERSION} CONFIG QUIET)
set_package_properties(Qt5QuickWidgets PROPERTIES
DESCRIPTION "Qt5 QuickWidgets component."
TYPE REQUIRED
)

find_package(Qt5WebEngineWidgets ${REQUIRED_QT_VERSION} CONFIG QUIET)
if(NOT BUILD_WITH_WEBENGINE)
set_package_properties(Qt5WebEngineWidgets PROPERTIES
Expand Down
21 changes: 19 additions & 2 deletions src/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
project(gui)
find_package(Qt5 REQUIRED COMPONENTS Widgets Svg Qml Quick QuickControls2 Xml Network)
find_package(Qt5 REQUIRED COMPONENTS Widgets Svg Qml Quick QuickControls2 QuickWidgets Xml Network)
find_package(KF5Archive REQUIRED)

if(QUICK_COMPILER)
Expand Down Expand Up @@ -293,15 +293,31 @@ IF( APPLE )
macOS/fileprovider_mac.mm
macOS/fileproviderdomainmanager.h
macOS/fileproviderdomainmanager_mac.mm
macOS/fileproviderdomainsyncstatus.h
macOS/fileproviderdomainsyncstatus_mac.mm
macOS/fileprovideritemmetadata.h
macOS/fileprovideritemmetadata.cpp
macOS/fileprovideritemmetadata_mac.mm
macOS/fileprovidermaterialiseditemsmodel.h
macOS/fileprovidermaterialiseditemsmodel.cpp
macOS/fileprovidermaterialiseditemsmodel_mac.mm
macOS/fileprovidersettingscontroller.h
macOS/fileprovidersettingscontroller_mac.mm
macOS/fileprovidersocketcontroller.h
macOS/fileprovidersocketcontroller.cpp
macOS/fileprovidersocketserver.h
macOS/fileprovidersocketserver.cpp
macOS/fileprovidersocketserver_mac.mm
macOS/fileproviderstorageuseenumerationobserver.h
macOS/fileproviderstorageuseenumerationobserver.m
macOS/fileproviderutils.h
macOS/fileproviderutils_mac.mm
macOS/fileproviderxpc.h
macOS/fileproviderxpc_mac.mm
macOS/fileproviderxpc_mac_utils.h
macOS/fileproviderxpc_mac_utils.mm)
macOS/fileproviderxpc_mac_utils.mm
macOS/progressobserver.h
macOS/progressobserver.m)
endif()

if(SPARKLE_FOUND AND BUILD_UPDATER)
Expand Down Expand Up @@ -543,6 +559,7 @@ target_link_libraries(nextcloudCore
Qt5::Qml
Qt5::Quick
Qt5::QuickControls2
Qt5::QuickWidgets
KF5::Archive
)

Expand Down
30 changes: 30 additions & 0 deletions src/gui/accountsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@
#include <QJsonDocument>
#include <QToolTip>

#ifdef BUILD_FILE_PROVIDER_MODULE
#include "macOS/fileprovider.h"
#endif

#include "account.h"

namespace {
Expand Down Expand Up @@ -193,6 +197,24 @@ AccountSettings::AccountSettings(AccountState *accountState, QWidget *parent)
#endif
new ToolTipUpdater(_ui->_folderList);

#if defined(BUILD_FILE_PROVIDER_MODULE)
if (Mac::FileProvider::fileProviderAvailable()) {
const auto fileProviderTab = _ui->fileProviderTab;
const auto fpSettingsLayout = new QVBoxLayout(fileProviderTab);
const auto fpAccountUserIdAtHost = _accountState->account()->userIdAtHostWithPort();
const auto fpSettingsController = Mac::FileProviderSettingsController::instance();
const auto fpSettingsWidget = fpSettingsController->settingsViewWidget(fpAccountUserIdAtHost, fileProviderTab);
fpSettingsLayout->setMargin(0);
fpSettingsLayout->addWidget(fpSettingsWidget);
fileProviderTab->setLayout(fpSettingsLayout);
} else {
disguiseTabWidget();
}
#else
disguiseTabWidget();
_ui->tabWidget->setCurrentIndex(0);
#endif

const auto mouseCursorChanger = new MouseCursorChanger(this);
mouseCursorChanger->folderList = _ui->_folderList;
mouseCursorChanger->model = _model;
Expand Down Expand Up @@ -1688,6 +1710,14 @@ void AccountSettings::initializeE2eEncryptionSettingsMessage()
connect(actionEnableE2e, &QAction::triggered, this, &AccountSettings::slotE2eEncryptionGenerateKeys);
}

void AccountSettings::disguiseTabWidget() const
{
// Ensure all elements of the tab widget are hidden.
// Document mode lets the child view take up the whole view.
_ui->tabWidget->setDocumentMode(true);
_ui->tabWidget->tabBar()->hide();
}

} // namespace OCC

#include "accountsettings.moc"
6 changes: 6 additions & 0 deletions src/gui/accountsettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
#include "owncloudgui.h"
#include "folderstatusmodel.h"

#ifdef BUILD_FILE_PROVIDER_MODULE
#include "macOS/fileprovidersettingscontroller.h"
#endif

class QModelIndex;
class QNetworkReply;
class QListWidgetItem;
Expand Down Expand Up @@ -137,6 +141,8 @@ private slots:
/// Returns the alias of the selected folder, empty string if none
[[nodiscard]] QString selectedFolderAlias() const;

void disguiseTabWidget() const;

Ui::AccountSettings *_ui;

FolderStatusModel *_model;
Expand Down
Loading

0 comments on commit 478d65c

Please sign in to comment.