From 6083d72f45f1812ca41d6b80e0fd16c2b091e993 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Tue, 20 Feb 2024 20:03:50 +0800 Subject: [PATCH 001/172] Add new FileProviderUIExt target Signed-off-by: Claudio Cambra --- .../DocumentActionViewController.swift | 35 ++++ .../FileProviderUIExt/Info.plist | 24 +++ .../FileProviderUIExt/MainInterface.xib | 12 ++ .../project.pbxproj | 194 +++++++++++++++++- 4 files changed, 264 insertions(+), 1 deletion(-) create mode 100644 shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/DocumentActionViewController.swift create mode 100644 shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Info.plist create mode 100644 shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/MainInterface.xib diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/DocumentActionViewController.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/DocumentActionViewController.swift new file mode 100644 index 0000000000000..2d91de1408ce9 --- /dev/null +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/DocumentActionViewController.swift @@ -0,0 +1,35 @@ +// +// DocumentActionViewController.swift +// FileProviderUIExt +// +// Created by Claudio Cambra on 20/2/24. +// + +import FileProviderUI + +class DocumentActionViewController: FPUIActionExtensionViewController { + + @IBOutlet weak var identifierLabel: NSTextField! + @IBOutlet weak var actionTypeLabel: NSTextField! + + override func prepare(forAction actionIdentifier: String, itemIdentifiers: [NSFileProviderItemIdentifier]) { + identifierLabel?.stringValue = actionIdentifier + actionTypeLabel?.stringValue = "Custom action" + } + + override func prepare(forError error: Error) { + identifierLabel?.stringValue = error.localizedDescription + actionTypeLabel?.stringValue = "Authenticate" + } + + @IBAction func doneButtonTapped(_ sender: Any) { + // Perform the action and call the completion block. If an unrecoverable error occurs you must still call the completion block with an error. Use the error code FPUIExtensionErrorCode.failed to signal the failure. + extensionContext.completeRequest() + } + + @IBAction func cancelButtonTapped(_ sender: Any) { + extensionContext.cancelRequest(withError: NSError(domain: FPUIErrorDomain, code: Int(FPUIExtensionErrorCode.userCancelled.rawValue), userInfo: nil)) + } + +} + diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Info.plist b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Info.plist new file mode 100644 index 0000000000000..92d193b8bb646 --- /dev/null +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Info.plist @@ -0,0 +1,24 @@ + + + + + NSExtension + + NSExtensionFileProviderActions + + + NSExtensionFileProviderActionActivationRule + TRUEPREDICATE + NSExtensionFileProviderActionIdentifier + com.mycompany.FileProviderUI.CustomAction + NSExtensionFileProviderActionName + Custom Action + + + NSExtensionPrincipalClass + $(PRODUCT_MODULE_NAME).DocumentActionViewController + NSExtensionPointIdentifier + com.apple.fileprovider-actionsui + + + diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/MainInterface.xib b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/MainInterface.xib new file mode 100644 index 0000000000000..a8973aa4f2ac3 --- /dev/null +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/MainInterface.xib @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj b/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj index 6149378d5343a..db76d692357bd 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj +++ b/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj @@ -39,6 +39,8 @@ 53903D352956184400D0B308 /* LocalSocketClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 539158B127BE891500816F56 /* LocalSocketClient.h */; settings = {ATTRIBUTES = (Public, ); }; }; 53903D37295618A400D0B308 /* LineProcessor.h in Headers */ = {isa = PBXBuildFile; fileRef = 53903D36295618A400D0B308 /* LineProcessor.h */; settings = {ATTRIBUTES = (Public, ); }; }; 539158AC27BE71A900816F56 /* FinderSyncSocketLineProcessor.m in Sources */ = {isa = PBXBuildFile; fileRef = 539158AB27BE71A900816F56 /* FinderSyncSocketLineProcessor.m */; }; + 53B979812B84C81F002DA742 /* DocumentActionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53B979802B84C81F002DA742 /* DocumentActionViewController.swift */; }; + 53B9798A2B84CB0F002DA742 /* MainInterface.xib in Resources */ = {isa = PBXBuildFile; fileRef = 53B979892B84CB0F002DA742 /* MainInterface.xib */; }; 53D056312970594F00988392 /* LocalFilesUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53D056302970594F00988392 /* LocalFilesUtils.swift */; }; 53D666612B70C9A70042C03D /* FileProviderConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53D666602B70C9A70042C03D /* FileProviderConfig.swift */; }; 53ED472029C5E64200795DB1 /* FileProviderEnumerator+SyncEngine.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53ED471F29C5E64200795DB1 /* FileProviderEnumerator+SyncEngine.swift */; }; @@ -172,6 +174,10 @@ 539158AB27BE71A900816F56 /* FinderSyncSocketLineProcessor.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FinderSyncSocketLineProcessor.m; sourceTree = ""; }; 539158B127BE891500816F56 /* LocalSocketClient.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LocalSocketClient.h; sourceTree = ""; }; 539158B227BEC98A00816F56 /* LocalSocketClient.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LocalSocketClient.m; sourceTree = ""; }; + 53B9797E2B84C81F002DA742 /* FileProviderUIExt.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = FileProviderUIExt.appex; sourceTree = BUILT_PRODUCTS_DIR; }; + 53B979802B84C81F002DA742 /* DocumentActionViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DocumentActionViewController.swift; sourceTree = ""; }; + 53B979852B84C81F002DA742 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 53B979892B84CB0F002DA742 /* MainInterface.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = MainInterface.xib; sourceTree = ""; }; 53D056302970594F00988392 /* LocalFilesUtils.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocalFilesUtils.swift; sourceTree = ""; }; 53D666602B70C9A70042C03D /* FileProviderConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileProviderConfig.swift; sourceTree = ""; }; 53ED471F29C5E64200795DB1 /* FileProviderEnumerator+SyncEngine.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "FileProviderEnumerator+SyncEngine.swift"; sourceTree = ""; }; @@ -211,6 +217,13 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 53B9797B2B84C81F002DA742 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; C2B573AE1B1CD91E00303B36 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -306,12 +319,23 @@ path = NCDesktopClientSocketKit; sourceTree = ""; }; + 53B9797F2B84C81F002DA742 /* FileProviderUIExt */ = { + isa = PBXGroup; + children = ( + 53B979892B84CB0F002DA742 /* MainInterface.xib */, + 53B979802B84C81F002DA742 /* DocumentActionViewController.swift */, + 53B979852B84C81F002DA742 /* Info.plist */, + ); + path = FileProviderUIExt; + sourceTree = ""; + }; C2B573941B1CD88000303B36 = { isa = PBXGroup; children = ( C2B573B31B1CD91E00303B36 /* desktopclient */, C2B573D81B1CD9CE00303B36 /* FinderSyncExt */, 538E396B27F4765000FA63D5 /* FileProviderExt */, + 53B9797F2B84C81F002DA742 /* FileProviderUIExt */, 53903D0D2956164F00D0B308 /* NCDesktopClientSocketKit */, 538E396827F4765000FA63D5 /* Frameworks */, C2B573B21B1CD91E00303B36 /* Products */, @@ -325,6 +349,7 @@ C2B573D71B1CD9CE00303B36 /* FinderSyncExt.appex */, 538E396727F4765000FA63D5 /* FileProviderExt.appex */, 53903D0C2956164F00D0B308 /* NCDesktopClientSocketKit.framework */, + 53B9797E2B84C81F002DA742 /* FileProviderUIExt.appex */, ); name = Products; sourceTree = ""; @@ -430,6 +455,23 @@ productReference = 53903D0C2956164F00D0B308 /* NCDesktopClientSocketKit.framework */; productType = "com.apple.product-type.framework"; }; + 53B9797D2B84C81F002DA742 /* FileProviderUIExt */ = { + isa = PBXNativeTarget; + buildConfigurationList = 53B979882B84C820002DA742 /* Build configuration list for PBXNativeTarget "FileProviderUIExt" */; + buildPhases = ( + 53B9797A2B84C81F002DA742 /* Sources */, + 53B9797B2B84C81F002DA742 /* Frameworks */, + 53B9797C2B84C81F002DA742 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = FileProviderUIExt; + productName = FileProviderUIExt; + productReference = 53B9797E2B84C81F002DA742 /* FileProviderUIExt.appex */; + productType = "com.apple.product-type.app-extension"; + }; C2B573B01B1CD91E00303B36 /* desktopclient */ = { isa = PBXNativeTarget; buildConfigurationList = C2B573CC1B1CD91E00303B36 /* Build configuration list for PBXNativeTarget "desktopclient" */; @@ -482,7 +524,7 @@ isa = PBXProject; attributes = { BuildIndependentTargetsInParallel = YES; - LastSwiftUpdateCheck = 1420; + LastSwiftUpdateCheck = 1520; LastUpgradeCheck = 1240; TargetAttributes = { 538E396627F4765000FA63D5 = { @@ -492,6 +534,9 @@ CreatedOnToolsVersion = 14.2; ProvisioningStyle = Manual; }; + 53B9797D2B84C81F002DA742 = { + CreatedOnToolsVersion = 15.2; + }; C2B573B01B1CD91E00303B36 = { CreatedOnToolsVersion = 6.3.1; DevelopmentTeam = 9B5WD74GWJ; @@ -530,6 +575,7 @@ C2B573B01B1CD91E00303B36 /* desktopclient */, C2B573D61B1CD9CE00303B36 /* FinderSyncExt */, 538E396627F4765000FA63D5 /* FileProviderExt */, + 53B9797D2B84C81F002DA742 /* FileProviderUIExt */, 53903D0B2956164F00D0B308 /* NCDesktopClientSocketKit */, ); }; @@ -550,6 +596,14 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 53B9797C2B84C81F002DA742 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 53B9798A2B84CB0F002DA742 /* MainInterface.xib in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; C2B573AF1B1CD91E00303B36 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; @@ -626,6 +680,14 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 53B9797A2B84C81F002DA742 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 53B979812B84C81F002DA742 /* DocumentActionViewController.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; C2B573AD1B1CD91E00303B36 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -910,6 +972,127 @@ }; name = Release; }; + 53B979862B84C81F002DA742 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_STYLE = Automatic; + COPY_PHASE_STRIP = NO; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + GCC_DYNAMIC_NO_PIC = NO; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = FileProviderUIExt/Info.plist; + INFOPLIST_KEY_CFBundleDisplayName = FileProviderUIExt; + INFOPLIST_KEY_NSHumanReadableCopyright = ""; + INFOPLIST_OUTPUT_FORMAT = "same-as-input"; + INFOPLIST_PREPROCESS = NO; + IPHONEOS_DEPLOYMENT_TARGET = 17.2; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@executable_path/../../Frameworks", + ); + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MACOSX_DEPLOYMENT_TARGET = 11.0; + MARKETING_VERSION = 1.0; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + PRODUCT_BUNDLE_IDENTIFIER = "$(OC_APPLICATION_REV_DOMAIN).$(PRODUCT_NAME)"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = macosx; + SKIP_INSTALL = YES; + SUPPORTED_PLATFORMS = macosx; + SUPPORTS_MACCATALYST = NO; + SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO; + SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)"; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = macOS; + }; + name = Debug; + }; + 53B979872B84C81F002DA742 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_STYLE = Manual; + COPY_PHASE_STRIP = NO; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + DEVELOPMENT_TEAM = ""; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = FileProviderUIExt/Info.plist; + INFOPLIST_KEY_CFBundleDisplayName = FileProviderUIExt; + INFOPLIST_KEY_NSHumanReadableCopyright = ""; + INFOPLIST_OUTPUT_FORMAT = "same-as-input"; + INFOPLIST_PREPROCESS = NO; + IPHONEOS_DEPLOYMENT_TARGET = 17.2; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@executable_path/../../Frameworks", + ); + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MACOSX_DEPLOYMENT_TARGET = 11.0; + MARKETING_VERSION = 1.0; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + PRODUCT_BUNDLE_IDENTIFIER = "$(OC_APPLICATION_REV_DOMAIN).$(PRODUCT_NAME)"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = macosx; + SKIP_INSTALL = YES; + SUPPORTED_PLATFORMS = macosx; + SUPPORTS_MACCATALYST = NO; + SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO; + SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = macOS; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; C2B573991B1CD88000303B36 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -1216,6 +1399,15 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + 53B979882B84C820002DA742 /* Build configuration list for PBXNativeTarget "FileProviderUIExt" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 53B979862B84C81F002DA742 /* Debug */, + 53B979872B84C81F002DA742 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; C2B573981B1CD88000303B36 /* Build configuration list for PBXProject "NextcloudIntegration" */ = { isa = XCConfigurationList; buildConfigurations = ( From eb4bdba4c7f5b42ad01c720fdfcb69f78bb10db1 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 21 Feb 2024 15:43:07 +0800 Subject: [PATCH 002/172] Build and install FileProviderUIExt via CMake Signed-off-by: Claudio Cambra --- shell_integration/MacOSX/CMakeLists.txt | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/shell_integration/MacOSX/CMakeLists.txt b/shell_integration/MacOSX/CMakeLists.txt index 327392a84a013..512aae44781b7 100644 --- a/shell_integration/MacOSX/CMakeLists.txt +++ b/shell_integration/MacOSX/CMakeLists.txt @@ -35,7 +35,19 @@ if(APPLE) COMMENT building macOS File Provider extension VERBATIM) - add_dependencies(mac_overlayplugin mac_fileproviderplugin nextcloud) # for the ownCloud.icns to be generated + add_custom_target( mac_fileprovideruiplugin ALL + xcodebuild ARCHS=${CMAKE_OSX_ARCHITECTURES} ONLY_ACTIVE_ARCH=NO + -project ${CMAKE_SOURCE_DIR}/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj + -target FileProviderUIExt -configuration ${XCODE_TARGET_CONFIGURATION} "SYMROOT=${CMAKE_CURRENT_BINARY_DIR}" + "OC_APPLICATION_EXECUTABLE_NAME=${APPLICATION_EXECUTABLE}" + "OC_APPLICATION_VENDOR=${APPLICATION_VENDOR}" + "OC_APPLICATION_NAME=${APPLICATION_NAME}" + "OC_APPLICATION_REV_DOMAIN=${APPLICATION_REV_DOMAIN}" + "OC_SOCKETAPI_TEAM_IDENTIFIER_PREFIX=${SOCKETAPI_TEAM_IDENTIFIER_PREFIX}" + COMMENT building macOS File Provider UI extension + VERBATIM) + + add_dependencies(mac_overlayplugin mac_fileproviderplugin mac_fileprovideruiplugin nextcloud) # for the ownCloud.icns to be generated else() add_dependencies(mac_overlayplugin nextcloud) # for the ownCloud.icns to be generated endif() @@ -55,6 +67,10 @@ if(APPLE) install(DIRECTORY ${OSX_PLUGINS_BINARY_DIR}/FileProviderExt.appex DESTINATION ${OSX_PLUGINS_INSTALL_DIR} USE_SOURCE_PERMISSIONS) + + install(DIRECTORY ${OSX_PLUGINS_BINARY_DIR}/FileProviderUIExt.appex + DESTINATION ${OSX_PLUGINS_INSTALL_DIR} + USE_SOURCE_PERMISSIONS) endif() endif() endif() From f22d7bef35a2d04014b2f927d2086a854b91a77a Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 21 Feb 2024 16:18:52 +0800 Subject: [PATCH 003/172] Add FileProviderUIExt entitlements file Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/FileProviderUIExt.entitlements | 12 ++++++++++++ .../NextcloudIntegration.xcodeproj/project.pbxproj | 5 +++++ 2 files changed, 17 insertions(+) create mode 100644 shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/FileProviderUIExt.entitlements diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/FileProviderUIExt.entitlements b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/FileProviderUIExt.entitlements new file mode 100644 index 0000000000000..5d2a36d31b72d --- /dev/null +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/FileProviderUIExt.entitlements @@ -0,0 +1,12 @@ + + + + + com.apple.security.app-sandbox + + com.apple.security.application-groups + + $(OC_SOCKETAPI_TEAM_IDENTIFIER_PREFIX)$(OC_APPLICATION_REV_DOMAIN) + + + diff --git a/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj b/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj index db76d692357bd..8bdc19c3084cf 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj +++ b/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj @@ -159,6 +159,7 @@ 535AE30D29C0A2CC0042A9BA /* Logger+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Logger+Extensions.swift"; sourceTree = ""; }; 536EFBF6295CF58100F4CB13 /* FileProviderSocketLineProcessor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileProviderSocketLineProcessor.swift; sourceTree = ""; }; 536EFC35295E3C1100F4CB13 /* NextcloudAccount.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NextcloudAccount.swift; sourceTree = ""; }; + 5376307E2B85E5650026BFAB /* FileProviderUIExt.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = FileProviderUIExt.entitlements; sourceTree = ""; }; 538E396727F4765000FA63D5 /* FileProviderExt.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = FileProviderExt.appex; sourceTree = BUILT_PRODUCTS_DIR; }; 538E396927F4765000FA63D5 /* UniformTypeIdentifiers.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UniformTypeIdentifiers.framework; path = System/Library/Frameworks/UniformTypeIdentifiers.framework; sourceTree = SDKROOT; }; 538E396C27F4765000FA63D5 /* FileProviderExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileProviderExtension.swift; sourceTree = ""; }; @@ -324,6 +325,7 @@ children = ( 53B979892B84CB0F002DA742 /* MainInterface.xib */, 53B979802B84C81F002DA742 /* DocumentActionViewController.swift */, + 5376307E2B85E5650026BFAB /* FileProviderUIExt.entitlements */, 53B979852B84C81F002DA742 /* Info.plist */, ); path = FileProviderUIExt; @@ -987,6 +989,7 @@ CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_ENTITLEMENTS = FileProviderUIExt/FileProviderUIExt.entitlements; CODE_SIGN_STYLE = Automatic; COPY_PHASE_STRIP = NO; CURRENT_PROJECT_VERSION = 1; @@ -1050,6 +1053,8 @@ CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_ENTITLEMENTS = FileProviderUIExt/FileProviderUIExt.entitlements; + CODE_SIGN_INJECT_BASE_ENTITLEMENTS = NO; CODE_SIGN_STYLE = Manual; COPY_PHASE_STRIP = NO; CURRENT_PROJECT_VERSION = 1; From 4e9fc26dc3ae0e395cedc8ffcb09a7774558202e Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 21 Feb 2024 17:18:57 +0800 Subject: [PATCH 004/172] Add logger extension to FileProviderUIExt Signed-off-by: Claudio Cambra --- .../Extensions/Logger+Extensions.swift | 15 +++++++++++++++ .../project.pbxproj | 12 ++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Extensions/Logger+Extensions.swift diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Extensions/Logger+Extensions.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Extensions/Logger+Extensions.swift new file mode 100644 index 0000000000000..88e9b15a930a1 --- /dev/null +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Extensions/Logger+Extensions.swift @@ -0,0 +1,15 @@ +// +// Logger+Extensions.swift +// FileProviderUIExt +// +// Created by Claudio Cambra on 21/2/24. +// + +import OSLog + +extension Logger { + private static var subsystem = Bundle.main.bundleIdentifier! + + static let actionViewController = Logger(subsystem: subsystem, category: "actionViewController") +} + diff --git a/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj b/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj index 8bdc19c3084cf..01b5d74ad7357 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj +++ b/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj @@ -23,6 +23,7 @@ 535AE30E29C0A2CC0042A9BA /* Logger+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 535AE30D29C0A2CC0042A9BA /* Logger+Extensions.swift */; }; 536EFBF7295CF58100F4CB13 /* FileProviderSocketLineProcessor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 536EFBF6295CF58100F4CB13 /* FileProviderSocketLineProcessor.swift */; }; 536EFC36295E3C1100F4CB13 /* NextcloudAccount.swift in Sources */ = {isa = PBXBuildFile; fileRef = 536EFC35295E3C1100F4CB13 /* NextcloudAccount.swift */; }; + 5376307D2B85E2ED0026BFAB /* Logger+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5376307C2B85E2ED0026BFAB /* Logger+Extensions.swift */; }; 538E396A27F4765000FA63D5 /* UniformTypeIdentifiers.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 538E396927F4765000FA63D5 /* UniformTypeIdentifiers.framework */; }; 538E396D27F4765000FA63D5 /* FileProviderExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 538E396C27F4765000FA63D5 /* FileProviderExtension.swift */; }; 538E396F27F4765000FA63D5 /* FileProviderItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 538E396E27F4765000FA63D5 /* FileProviderItem.swift */; }; @@ -159,6 +160,7 @@ 535AE30D29C0A2CC0042A9BA /* Logger+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Logger+Extensions.swift"; sourceTree = ""; }; 536EFBF6295CF58100F4CB13 /* FileProviderSocketLineProcessor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileProviderSocketLineProcessor.swift; sourceTree = ""; }; 536EFC35295E3C1100F4CB13 /* NextcloudAccount.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NextcloudAccount.swift; sourceTree = ""; }; + 5376307C2B85E2ED0026BFAB /* Logger+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Logger+Extensions.swift"; sourceTree = ""; }; 5376307E2B85E5650026BFAB /* FileProviderUIExt.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = FileProviderUIExt.entitlements; sourceTree = ""; }; 538E396727F4765000FA63D5 /* FileProviderExt.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = FileProviderExt.appex; sourceTree = BUILT_PRODUCTS_DIR; }; 538E396927F4765000FA63D5 /* UniformTypeIdentifiers.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UniformTypeIdentifiers.framework; path = System/Library/Frameworks/UniformTypeIdentifiers.framework; sourceTree = SDKROOT; }; @@ -277,6 +279,14 @@ path = Extensions; sourceTree = ""; }; + 5376307B2B85E2E00026BFAB /* Extensions */ = { + isa = PBXGroup; + children = ( + 5376307C2B85E2ED0026BFAB /* Logger+Extensions.swift */, + ); + path = Extensions; + sourceTree = ""; + }; 538E396827F4765000FA63D5 /* Frameworks */ = { isa = PBXGroup; children = ( @@ -324,6 +334,7 @@ isa = PBXGroup; children = ( 53B979892B84CB0F002DA742 /* MainInterface.xib */, + 5376307B2B85E2E00026BFAB /* Extensions */, 53B979802B84C81F002DA742 /* DocumentActionViewController.swift */, 5376307E2B85E5650026BFAB /* FileProviderUIExt.entitlements */, 53B979852B84C81F002DA742 /* Info.plist */, @@ -687,6 +698,7 @@ buildActionMask = 2147483647; files = ( 53B979812B84C81F002DA742 /* DocumentActionViewController.swift in Sources */, + 5376307D2B85E2ED0026BFAB /* Logger+Extensions.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; From 533680c43b5eaa339c02f37b4739f3cd92d245c8 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 21 Feb 2024 17:20:48 +0800 Subject: [PATCH 005/172] Add logging for prepare methods of document action view controller Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/DocumentActionViewController.swift | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/DocumentActionViewController.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/DocumentActionViewController.swift index 2d91de1408ce9..0a676e81d7243 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/DocumentActionViewController.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/DocumentActionViewController.swift @@ -6,13 +6,17 @@ // import FileProviderUI +import OSLog class DocumentActionViewController: FPUIActionExtensionViewController { @IBOutlet weak var identifierLabel: NSTextField! @IBOutlet weak var actionTypeLabel: NSTextField! + override func prepare( + forAction actionIdentifier: String, itemIdentifiers: [NSFileProviderItemIdentifier] + ) { + Logger.actionViewController.info("Preparing for action: \(actionIdentifier)") - override func prepare(forAction actionIdentifier: String, itemIdentifiers: [NSFileProviderItemIdentifier]) { identifierLabel?.stringValue = actionIdentifier actionTypeLabel?.stringValue = "Custom action" } @@ -20,6 +24,7 @@ class DocumentActionViewController: FPUIActionExtensionViewController { override func prepare(forError error: Error) { identifierLabel?.stringValue = error.localizedDescription actionTypeLabel?.stringValue = "Authenticate" + Logger.actionViewController.info("Preparing for error: \(error.localizedDescription)") } @IBAction func doneButtonTapped(_ sender: Any) { From 28bbdc0cd56d841c878b8a9e2b588a67344d252a Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 21 Feb 2024 17:21:50 +0800 Subject: [PATCH 006/172] Create ShareViewController Signed-off-by: Claudio Cambra --- .../DocumentActionViewController.swift | 20 +++--- .../FileProviderUIExt/MainInterface.xib | 12 ---- .../ShareViewController.swift | 21 +++++++ .../FileProviderUIExt/ShareViewController.xib | 61 +++++++++++++++++++ .../project.pbxproj | 12 ++-- 5 files changed, 103 insertions(+), 23 deletions(-) delete mode 100644 shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/MainInterface.xib create mode 100644 shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift create mode 100644 shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/DocumentActionViewController.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/DocumentActionViewController.swift index 0a676e81d7243..8054d50517794 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/DocumentActionViewController.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/DocumentActionViewController.swift @@ -9,24 +9,30 @@ import FileProviderUI import OSLog class DocumentActionViewController: FPUIActionExtensionViewController { - - @IBOutlet weak var identifierLabel: NSTextField! - @IBOutlet weak var actionTypeLabel: NSTextField! override func prepare( forAction actionIdentifier: String, itemIdentifiers: [NSFileProviderItemIdentifier] ) { Logger.actionViewController.info("Preparing for action: \(actionIdentifier)") + let shareViewController = ShareViewController() + addChild(shareViewController) + view.addSubview(shareViewController.view) - identifierLabel?.stringValue = actionIdentifier - actionTypeLabel?.stringValue = "Custom action" + NSLayoutConstraint.activate([ + view.leadingAnchor.constraint(equalTo: shareViewController.view.leadingAnchor), + view.trailingAnchor.constraint(equalTo: shareViewController.view.trailingAnchor), + view.topAnchor.constraint(equalTo: shareViewController.view.topAnchor), + view.bottomAnchor.constraint(equalTo: shareViewController.view.bottomAnchor) + ]) } override func prepare(forError error: Error) { - identifierLabel?.stringValue = error.localizedDescription - actionTypeLabel?.stringValue = "Authenticate" Logger.actionViewController.info("Preparing for error: \(error.localizedDescription)") } + override public func loadView() { + self.view = NSView() + } + @IBAction func doneButtonTapped(_ sender: Any) { // Perform the action and call the completion block. If an unrecoverable error occurs you must still call the completion block with an error. Use the error code FPUIExtensionErrorCode.failed to signal the failure. extensionContext.completeRequest() diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/MainInterface.xib b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/MainInterface.xib deleted file mode 100644 index a8973aa4f2ac3..0000000000000 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/MainInterface.xib +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift new file mode 100644 index 0000000000000..25d535d343d6c --- /dev/null +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift @@ -0,0 +1,21 @@ +// +// ShareViewController.swift +// FileProviderUIExt +// +// Created by Claudio Cambra on 21/2/24. +// + +import AppKit + +class ShareViewController: NSViewController { + @IBOutlet weak var identifierLabel: NSTextField! + @IBOutlet weak var actionTypeLabel: NSTextField! + + public override var nibName: NSNib.Name? { + return NSNib.Name(self.className) + } + + var actionViewController: DocumentActionViewController! { + return parent as? DocumentActionViewController + } +} diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib new file mode 100644 index 0000000000000..f80ef2f47dce4 --- /dev/null +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj b/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj index 01b5d74ad7357..39a15a49c3dc0 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj +++ b/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj @@ -24,6 +24,8 @@ 536EFBF7295CF58100F4CB13 /* FileProviderSocketLineProcessor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 536EFBF6295CF58100F4CB13 /* FileProviderSocketLineProcessor.swift */; }; 536EFC36295E3C1100F4CB13 /* NextcloudAccount.swift in Sources */ = {isa = PBXBuildFile; fileRef = 536EFC35295E3C1100F4CB13 /* NextcloudAccount.swift */; }; 5376307D2B85E2ED0026BFAB /* Logger+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5376307C2B85E2ED0026BFAB /* Logger+Extensions.swift */; }; + 537630912B85F4980026BFAB /* ShareViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 537630902B85F4980026BFAB /* ShareViewController.xib */; }; + 537630932B85F4B00026BFAB /* ShareViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 537630922B85F4B00026BFAB /* ShareViewController.swift */; }; 538E396A27F4765000FA63D5 /* UniformTypeIdentifiers.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 538E396927F4765000FA63D5 /* UniformTypeIdentifiers.framework */; }; 538E396D27F4765000FA63D5 /* FileProviderExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 538E396C27F4765000FA63D5 /* FileProviderExtension.swift */; }; 538E396F27F4765000FA63D5 /* FileProviderItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 538E396E27F4765000FA63D5 /* FileProviderItem.swift */; }; @@ -41,7 +43,6 @@ 53903D37295618A400D0B308 /* LineProcessor.h in Headers */ = {isa = PBXBuildFile; fileRef = 53903D36295618A400D0B308 /* LineProcessor.h */; settings = {ATTRIBUTES = (Public, ); }; }; 539158AC27BE71A900816F56 /* FinderSyncSocketLineProcessor.m in Sources */ = {isa = PBXBuildFile; fileRef = 539158AB27BE71A900816F56 /* FinderSyncSocketLineProcessor.m */; }; 53B979812B84C81F002DA742 /* DocumentActionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53B979802B84C81F002DA742 /* DocumentActionViewController.swift */; }; - 53B9798A2B84CB0F002DA742 /* MainInterface.xib in Resources */ = {isa = PBXBuildFile; fileRef = 53B979892B84CB0F002DA742 /* MainInterface.xib */; }; 53D056312970594F00988392 /* LocalFilesUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53D056302970594F00988392 /* LocalFilesUtils.swift */; }; 53D666612B70C9A70042C03D /* FileProviderConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53D666602B70C9A70042C03D /* FileProviderConfig.swift */; }; 53ED472029C5E64200795DB1 /* FileProviderEnumerator+SyncEngine.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53ED471F29C5E64200795DB1 /* FileProviderEnumerator+SyncEngine.swift */; }; @@ -162,6 +163,8 @@ 536EFC35295E3C1100F4CB13 /* NextcloudAccount.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NextcloudAccount.swift; sourceTree = ""; }; 5376307C2B85E2ED0026BFAB /* Logger+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Logger+Extensions.swift"; sourceTree = ""; }; 5376307E2B85E5650026BFAB /* FileProviderUIExt.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = FileProviderUIExt.entitlements; sourceTree = ""; }; + 537630902B85F4980026BFAB /* ShareViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ShareViewController.xib; sourceTree = ""; }; + 537630922B85F4B00026BFAB /* ShareViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareViewController.swift; sourceTree = ""; }; 538E396727F4765000FA63D5 /* FileProviderExt.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = FileProviderExt.appex; sourceTree = BUILT_PRODUCTS_DIR; }; 538E396927F4765000FA63D5 /* UniformTypeIdentifiers.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UniformTypeIdentifiers.framework; path = System/Library/Frameworks/UniformTypeIdentifiers.framework; sourceTree = SDKROOT; }; 538E396C27F4765000FA63D5 /* FileProviderExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileProviderExtension.swift; sourceTree = ""; }; @@ -180,7 +183,6 @@ 53B9797E2B84C81F002DA742 /* FileProviderUIExt.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = FileProviderUIExt.appex; sourceTree = BUILT_PRODUCTS_DIR; }; 53B979802B84C81F002DA742 /* DocumentActionViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DocumentActionViewController.swift; sourceTree = ""; }; 53B979852B84C81F002DA742 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 53B979892B84CB0F002DA742 /* MainInterface.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = MainInterface.xib; sourceTree = ""; }; 53D056302970594F00988392 /* LocalFilesUtils.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocalFilesUtils.swift; sourceTree = ""; }; 53D666602B70C9A70042C03D /* FileProviderConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileProviderConfig.swift; sourceTree = ""; }; 53ED471F29C5E64200795DB1 /* FileProviderEnumerator+SyncEngine.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "FileProviderEnumerator+SyncEngine.swift"; sourceTree = ""; }; @@ -333,9 +335,10 @@ 53B9797F2B84C81F002DA742 /* FileProviderUIExt */ = { isa = PBXGroup; children = ( - 53B979892B84CB0F002DA742 /* MainInterface.xib */, 5376307B2B85E2E00026BFAB /* Extensions */, 53B979802B84C81F002DA742 /* DocumentActionViewController.swift */, + 537630922B85F4B00026BFAB /* ShareViewController.swift */, + 537630902B85F4980026BFAB /* ShareViewController.xib */, 5376307E2B85E5650026BFAB /* FileProviderUIExt.entitlements */, 53B979852B84C81F002DA742 /* Info.plist */, ); @@ -613,7 +616,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - 53B9798A2B84CB0F002DA742 /* MainInterface.xib in Resources */, + 537630912B85F4980026BFAB /* ShareViewController.xib in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -697,6 +700,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 537630932B85F4B00026BFAB /* ShareViewController.swift in Sources */, 53B979812B84C81F002DA742 /* DocumentActionViewController.swift in Sources */, 5376307D2B85E2ED0026BFAB /* Logger+Extensions.swift in Sources */, ); From 247a1d750c3a8d1e351b6c9dcb8958cb02cc6db1 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 21 Feb 2024 17:44:49 +0800 Subject: [PATCH 007/172] Add convenience method to prepare child view controllers in DocumentActionViewController Signed-off-by: Claudio Cambra --- .../DocumentActionViewController.swift | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/DocumentActionViewController.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/DocumentActionViewController.swift index 8054d50517794..52596a3d4586d 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/DocumentActionViewController.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/DocumentActionViewController.swift @@ -9,6 +9,18 @@ import FileProviderUI import OSLog class DocumentActionViewController: FPUIActionExtensionViewController { + func prepare(childViewController: NSViewController) { + addChild(childViewController) + view.addSubview(childViewController.view) + + NSLayoutConstraint.activate([ + view.leadingAnchor.constraint(equalTo: childViewController.view.leadingAnchor), + view.trailingAnchor.constraint(equalTo: childViewController.view.trailingAnchor), + view.topAnchor.constraint(equalTo: childViewController.view.topAnchor), + view.bottomAnchor.constraint(equalTo: childViewController.view.bottomAnchor) + ]) + } + override func prepare( forAction actionIdentifier: String, itemIdentifiers: [NSFileProviderItemIdentifier] ) { From df5a4a83a53241eccffed10407b69b2402e0eb21 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 21 Feb 2024 17:45:03 +0800 Subject: [PATCH 008/172] Remove unused IBActions in DocumentActionViewController Signed-off-by: Claudio Cambra --- .../DocumentActionViewController.swift | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/DocumentActionViewController.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/DocumentActionViewController.swift index 52596a3d4586d..264b0fd566abd 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/DocumentActionViewController.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/DocumentActionViewController.swift @@ -44,15 +44,5 @@ class DocumentActionViewController: FPUIActionExtensionViewController { override public func loadView() { self.view = NSView() } - - @IBAction func doneButtonTapped(_ sender: Any) { - // Perform the action and call the completion block. If an unrecoverable error occurs you must still call the completion block with an error. Use the error code FPUIExtensionErrorCode.failed to signal the failure. - extensionContext.completeRequest() - } - - @IBAction func cancelButtonTapped(_ sender: Any) { - extensionContext.cancelRequest(withError: NSError(domain: FPUIErrorDomain, code: Int(FPUIExtensionErrorCode.userCancelled.rawValue), userInfo: nil)) - } - } From 5162302aa81403e4c765e509a39787bec278de0d Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 21 Feb 2024 17:45:20 +0800 Subject: [PATCH 009/172] Properly add share custom action Signed-off-by: Claudio Cambra --- .../DocumentActionViewController.swift | 13 ++++--------- .../FileProviderUIExt/Info.plist | 4 ++-- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/DocumentActionViewController.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/DocumentActionViewController.swift index 264b0fd566abd..98d2714b6910d 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/DocumentActionViewController.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/DocumentActionViewController.swift @@ -25,16 +25,11 @@ class DocumentActionViewController: FPUIActionExtensionViewController { forAction actionIdentifier: String, itemIdentifiers: [NSFileProviderItemIdentifier] ) { Logger.actionViewController.info("Preparing for action: \(actionIdentifier)") - let shareViewController = ShareViewController() - addChild(shareViewController) - view.addSubview(shareViewController.view) - NSLayoutConstraint.activate([ - view.leadingAnchor.constraint(equalTo: shareViewController.view.leadingAnchor), - view.trailingAnchor.constraint(equalTo: shareViewController.view.trailingAnchor), - view.topAnchor.constraint(equalTo: shareViewController.view.topAnchor), - view.bottomAnchor.constraint(equalTo: shareViewController.view.bottomAnchor) - ]) + if actionIdentifier == "com.nextcloud.desktopclient.FileProviderUIExt.ShareAction" { + prepare(childViewController: ShareViewController()) + } + } override func prepare(forError error: Error) { diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Info.plist b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Info.plist index 92d193b8bb646..f559d75c46ab4 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Info.plist +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Info.plist @@ -10,9 +10,9 @@ NSExtensionFileProviderActionActivationRule TRUEPREDICATE NSExtensionFileProviderActionIdentifier - com.mycompany.FileProviderUI.CustomAction + com.nextcloud.desktopclient.FileProviderUIExt.ShareAction NSExtensionFileProviderActionName - Custom Action + Share options NSExtensionPrincipalClass From 39f307403504340739d402539a23df5e27f3c44e Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 21 Feb 2024 17:56:57 +0800 Subject: [PATCH 010/172] Add proper design for share view in file provider UI Signed-off-by: Claudio Cambra --- .../ShareViewController.swift | 6 +- .../FileProviderUIExt/ShareViewController.xib | 94 ++++++++++++++----- 2 files changed, 72 insertions(+), 28 deletions(-) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift index 25d535d343d6c..ba707dc1dfb36 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift @@ -8,8 +8,10 @@ import AppKit class ShareViewController: NSViewController { - @IBOutlet weak var identifierLabel: NSTextField! - @IBOutlet weak var actionTypeLabel: NSTextField! + @IBOutlet weak var fileNameIcon: NSImageView! + @IBOutlet weak var fileNameLabel: NSTextField! + @IBOutlet weak var descriptionLabel: NSTextField! + @IBOutlet weak var closeButton: NSButton! public override var nibName: NSNib.Name? { return NSNib.Name(self.className) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib index f80ef2f47dce4..201ba5ea43401 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib @@ -3,59 +3,101 @@ + - - + + + + - - + + - - + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + + + + + From c1243587a83faa0e2c4cd33c8848e93a0757c762 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 21 Feb 2024 17:58:39 +0800 Subject: [PATCH 011/172] Store file provider item identifiers in ShareViewController Signed-off-by: Claudio Cambra --- .../DocumentActionViewController.swift | 2 +- .../FileProviderUIExt/ShareViewController.swift | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/DocumentActionViewController.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/DocumentActionViewController.swift index 98d2714b6910d..d14e60c71a07d 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/DocumentActionViewController.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/DocumentActionViewController.swift @@ -27,7 +27,7 @@ class DocumentActionViewController: FPUIActionExtensionViewController { Logger.actionViewController.info("Preparing for action: \(actionIdentifier)") if actionIdentifier == "com.nextcloud.desktopclient.FileProviderUIExt.ShareAction" { - prepare(childViewController: ShareViewController()) + prepare(childViewController: ShareViewController(itemIdentifiers)) } } diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift index ba707dc1dfb36..6946ff32e3238 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift @@ -6,8 +6,11 @@ // import AppKit +import FileProvider class ShareViewController: NSViewController { + let itemIdentifiers: [NSFileProviderItemIdentifier] + @IBOutlet weak var fileNameIcon: NSImageView! @IBOutlet weak var fileNameLabel: NSTextField! @IBOutlet weak var descriptionLabel: NSTextField! @@ -20,4 +23,13 @@ class ShareViewController: NSViewController { var actionViewController: DocumentActionViewController! { return parent as? DocumentActionViewController } + + init(_ itemIdentifiers: [NSFileProviderItemIdentifier]) { + self.itemIdentifiers = itemIdentifiers + super.init(nibName: nil, bundle: nil) + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } } From e592ee8f4e38bb5e1263df7a5bac4e40acb64f32 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 21 Feb 2024 18:03:29 +0800 Subject: [PATCH 012/172] Make close button work properly in share view Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/ShareViewController.swift | 4 ++++ .../FileProviderUIExt/ShareViewController.xib | 3 +++ 2 files changed, 7 insertions(+) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift index 6946ff32e3238..4ffc8f73110ea 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift @@ -32,4 +32,8 @@ class ShareViewController: NSViewController { required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } + + @IBAction func closeAction(_ sender: Any) { + actionViewController.extensionContext.completeRequest() + } } diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib index 201ba5ea43401..10be5ff11a4de 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib @@ -68,6 +68,9 @@ + + + From d12b32009d0314f84756cdd10cde9ebfa5f5e467 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 21 Feb 2024 18:48:42 +0800 Subject: [PATCH 013/172] Add domain property to document action view controller Signed-off-by: Claudio Cambra --- .../DocumentActionViewController.swift | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/DocumentActionViewController.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/DocumentActionViewController.swift index d14e60c71a07d..dd068f0aca3a5 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/DocumentActionViewController.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/DocumentActionViewController.swift @@ -9,6 +9,16 @@ import FileProviderUI import OSLog class DocumentActionViewController: FPUIActionExtensionViewController { + var domain: NSFileProviderDomain { + guard let identifier = extensionContext.domainIdentifier else { + fatalError("not expected to be called with default domain") + } + return NSFileProviderDomain( + identifier: NSFileProviderDomainIdentifier(rawValue: identifier.rawValue), + displayName: "" + ) + } + func prepare(childViewController: NSViewController) { addChild(childViewController) view.addSubview(childViewController.view) From 13cf81578275e5211bc9fade72c5e548b88ab473 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 21 Feb 2024 18:49:58 +0800 Subject: [PATCH 014/172] Set the right filename and icon on share view controller view Signed-off-by: Claudio Cambra --- .../Extensions/Logger+Extensions.swift | 1 + .../ShareViewController.swift | 46 +++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Extensions/Logger+Extensions.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Extensions/Logger+Extensions.swift index 88e9b15a930a1..8ec218668472f 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Extensions/Logger+Extensions.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Extensions/Logger+Extensions.swift @@ -11,5 +11,6 @@ extension Logger { private static var subsystem = Bundle.main.bundleIdentifier! static let actionViewController = Logger(subsystem: subsystem, category: "actionViewController") + static let shareViewController = Logger(subsystem: subsystem, category: "shareViewController") } diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift index 4ffc8f73110ea..068349e269a3e 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift @@ -7,6 +7,8 @@ import AppKit import FileProvider +import OSLog +import QuickLookThumbnailing class ShareViewController: NSViewController { let itemIdentifiers: [NSFileProviderItemIdentifier] @@ -27,6 +29,16 @@ class ShareViewController: NSViewController { init(_ itemIdentifiers: [NSFileProviderItemIdentifier]) { self.itemIdentifiers = itemIdentifiers super.init(nibName: nil, bundle: nil) + + guard let firstItem = itemIdentifiers.first else { + Logger.shareViewController.error("called without items") + closeAction(self) + return + } + + Task { + await processItemIdentifier(firstItem) + } } required init?(coder: NSCoder) { @@ -36,4 +48,38 @@ class ShareViewController: NSViewController { @IBAction func closeAction(_ sender: Any) { actionViewController.extensionContext.completeRequest() } + + func processItemIdentifier(_ itemIdentifier: NSFileProviderItemIdentifier) async { + guard let manager = NSFileProviderManager(for: actionViewController.domain) else { + fatalError("NSFileProviderManager isn't expected to fail") + } + + do { + let itemUrl = try await manager.getUserVisibleURL(for: itemIdentifier) + fileNameLabel.stringValue = itemUrl.lastPathComponent + + let request = QLThumbnailGenerator.Request( + fileAt: itemUrl, + size: CGSize(width: 128, height: 128), + scale: 1.0, + representationTypes: .icon + ) + + let generator = QLThumbnailGenerator.shared + let fileThumbnail = await withCheckedContinuation { continuation in + generator.generateRepresentations(for: request) { thumbnail, type, error in + if thumbnail == nil || error != nil { + Logger.shareViewController.error("Could not get thumbnail: \(error)") + } + continuation.resume(returning: thumbnail) + } + } + fileNameIcon.image = fileThumbnail?.nsImage + } catch let error { + let errorString = "Error processing item: \(error)" + Logger.shareViewController.error("\(errorString)") + fileNameLabel.stringValue = "Unknown item" + descriptionLabel.stringValue = errorString + } + } } From 8ab8e7e4a2c075a4fa5fe5175ebba94ca1fe0f97 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 21 Feb 2024 18:59:39 +0800 Subject: [PATCH 015/172] Extract display updating upon url acquisition to different method in ShareViewController Signed-off-by: Claudio Cambra --- .../ShareViewController.swift | 44 ++++++++++--------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift index 068349e269a3e..756eb92102415 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift @@ -49,32 +49,14 @@ class ShareViewController: NSViewController { actionViewController.extensionContext.completeRequest() } - func processItemIdentifier(_ itemIdentifier: NSFileProviderItemIdentifier) async { + private func processItemIdentifier(_ itemIdentifier: NSFileProviderItemIdentifier) async { guard let manager = NSFileProviderManager(for: actionViewController.domain) else { fatalError("NSFileProviderManager isn't expected to fail") } do { let itemUrl = try await manager.getUserVisibleURL(for: itemIdentifier) - fileNameLabel.stringValue = itemUrl.lastPathComponent - - let request = QLThumbnailGenerator.Request( - fileAt: itemUrl, - size: CGSize(width: 128, height: 128), - scale: 1.0, - representationTypes: .icon - ) - - let generator = QLThumbnailGenerator.shared - let fileThumbnail = await withCheckedContinuation { continuation in - generator.generateRepresentations(for: request) { thumbnail, type, error in - if thumbnail == nil || error != nil { - Logger.shareViewController.error("Could not get thumbnail: \(error)") - } - continuation.resume(returning: thumbnail) - } - } - fileNameIcon.image = fileThumbnail?.nsImage + await updateDisplay(itemUrl: itemUrl) } catch let error { let errorString = "Error processing item: \(error)" Logger.shareViewController.error("\(errorString)") @@ -82,4 +64,26 @@ class ShareViewController: NSViewController { descriptionLabel.stringValue = errorString } } + + private func updateDisplay(itemUrl: URL) async { + fileNameLabel.stringValue = itemUrl.lastPathComponent + + let request = QLThumbnailGenerator.Request( + fileAt: itemUrl, + size: CGSize(width: 128, height: 128), + scale: 1.0, + representationTypes: .icon + ) + + let generator = QLThumbnailGenerator.shared + let fileThumbnail = await withCheckedContinuation { continuation in + generator.generateRepresentations(for: request) { thumbnail, type, error in + if thumbnail == nil || error != nil { + Logger.shareViewController.error("Could not get thumbnail: \(error)") + } + continuation.resume(returning: thumbnail) + } + } + fileNameIcon.image = fileThumbnail?.nsImage + } } From fd63f2ee3188af795ee5d058e8ba47cb60e7afcd Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 21 Feb 2024 19:19:41 +0800 Subject: [PATCH 016/172] Add starter FPUIExtensionService protocol Signed-off-by: Claudio Cambra --- .../Services/FPUIExtensionService.swift | 16 ++++++++++++++++ .../project.pbxproj | 6 ++++++ 2 files changed, 22 insertions(+) create mode 100644 shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Services/FPUIExtensionService.swift diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Services/FPUIExtensionService.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Services/FPUIExtensionService.swift new file mode 100644 index 0000000000000..94e9109ab8800 --- /dev/null +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Services/FPUIExtensionService.swift @@ -0,0 +1,16 @@ +// +// FPUIExtensionCommunicationProtocol.swift +// FileProviderExt +// +// Created by Claudio Cambra on 21/2/24. +// + +import Foundation + +let fpUiExtensionServiceName = NSFileProviderServiceName( + "com.nextcloud.desktopclient.FPUIExtensionService" +) + +@objc protocol FPUIExtensionService { + +} diff --git a/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj b/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj index 39a15a49c3dc0..dd76f48fd8dca 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj +++ b/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj @@ -26,6 +26,8 @@ 5376307D2B85E2ED0026BFAB /* Logger+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5376307C2B85E2ED0026BFAB /* Logger+Extensions.swift */; }; 537630912B85F4980026BFAB /* ShareViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 537630902B85F4980026BFAB /* ShareViewController.xib */; }; 537630932B85F4B00026BFAB /* ShareViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 537630922B85F4B00026BFAB /* ShareViewController.swift */; }; + 537630972B860D920026BFAB /* FPUIExtensionService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 537630962B860D920026BFAB /* FPUIExtensionService.swift */; }; + 537630982B8612F00026BFAB /* FPUIExtensionService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 537630962B860D920026BFAB /* FPUIExtensionService.swift */; }; 538E396A27F4765000FA63D5 /* UniformTypeIdentifiers.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 538E396927F4765000FA63D5 /* UniformTypeIdentifiers.framework */; }; 538E396D27F4765000FA63D5 /* FileProviderExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 538E396C27F4765000FA63D5 /* FileProviderExtension.swift */; }; 538E396F27F4765000FA63D5 /* FileProviderItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 538E396E27F4765000FA63D5 /* FileProviderItem.swift */; }; @@ -165,6 +167,7 @@ 5376307E2B85E5650026BFAB /* FileProviderUIExt.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = FileProviderUIExt.entitlements; sourceTree = ""; }; 537630902B85F4980026BFAB /* ShareViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ShareViewController.xib; sourceTree = ""; }; 537630922B85F4B00026BFAB /* ShareViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareViewController.swift; sourceTree = ""; }; + 537630962B860D920026BFAB /* FPUIExtensionService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FPUIExtensionService.swift; sourceTree = ""; }; 538E396727F4765000FA63D5 /* FileProviderExt.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = FileProviderExt.appex; sourceTree = BUILT_PRODUCTS_DIR; }; 538E396927F4765000FA63D5 /* UniformTypeIdentifiers.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UniformTypeIdentifiers.framework; path = System/Library/Frameworks/UniformTypeIdentifiers.framework; sourceTree = SDKROOT; }; 538E396C27F4765000FA63D5 /* FileProviderExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileProviderExtension.swift; sourceTree = ""; }; @@ -267,6 +270,7 @@ children = ( 5350E4E72B0C514400F276CB /* ClientCommunicationProtocol.h */, 5350E4E82B0C534A00F276CB /* ClientCommunicationService.swift */, + 537630962B860D920026BFAB /* FPUIExtensionService.swift */, ); path = Services; sourceTree = ""; @@ -673,6 +677,7 @@ 53ED472029C5E64200795DB1 /* FileProviderEnumerator+SyncEngine.swift in Sources */, 5318AD9929BF58D000CBB71C /* NKError+Extensions.swift in Sources */, 53ED472829C88E7000795DB1 /* NextcloudItemMetadataTable+NKFile.swift in Sources */, + 537630972B860D920026BFAB /* FPUIExtensionService.swift in Sources */, 5318AD9529BF438F00CBB71C /* NextcloudLocalFileMetadataTable.swift in Sources */, 535AE30E29C0A2CC0042A9BA /* Logger+Extensions.swift in Sources */, 5307A6F229675346001E0C6A /* NextcloudFilesDatabaseManager.swift in Sources */, @@ -703,6 +708,7 @@ 537630932B85F4B00026BFAB /* ShareViewController.swift in Sources */, 53B979812B84C81F002DA742 /* DocumentActionViewController.swift in Sources */, 5376307D2B85E2ED0026BFAB /* Logger+Extensions.swift in Sources */, + 537630982B8612F00026BFAB /* FPUIExtensionService.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; From efe35934adc8e5ee7143f1383957a896007552da Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 21 Feb 2024 20:23:57 +0800 Subject: [PATCH 017/172] Implement convenience method to acquire FPUIExtensionService in share view controller Signed-off-by: Claudio Cambra --- .../ShareViewController.swift | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift index 756eb92102415..acf5f84422f34 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift @@ -86,4 +86,23 @@ class ShareViewController: NSViewController { } fileNameIcon.image = fileThumbnail?.nsImage } + + private func serviceConnection(url: URL) async throws -> FPUIExtensionService { + let services = try await FileManager().fileProviderServicesForItem(at: url) + guard let service = services[fpUiExtensionServiceName] else { + Logger.shareViewController.error("Couldn't get service, required service not present") + throw NSFileProviderError(.providerNotFound) + } + let connection: NSXPCConnection + connection = try await service.fileProviderConnection() + connection.remoteObjectInterface = NSXPCInterface(with: FPUIExtensionService.self) + connection.interruptionHandler = { + Logger.shareViewController.error("Service connection interrupted") + } + connection.resume() + guard let proxy = connection.remoteObjectProxy as? FPUIExtensionService else { + throw NSFileProviderError(.serverUnreachable) + } + return proxy + } } From ef924b2bafecc80513d9140c45bc666975eb59b7 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 21 Feb 2024 20:29:03 +0800 Subject: [PATCH 018/172] Add starter FPUIExtensionServiceSource Signed-off-by: Claudio Cambra --- .../Extensions/Logger+Extensions.swift | 1 + .../Services/FPUIExtensionServiceSource.swift | 41 +++++++++++++++++++ .../project.pbxproj | 4 ++ 3 files changed, 46 insertions(+) create mode 100644 shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Services/FPUIExtensionServiceSource.swift diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Extensions/Logger+Extensions.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Extensions/Logger+Extensions.swift index 6edb6ab4be9f5..c6c166374010b 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Extensions/Logger+Extensions.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Extensions/Logger+Extensions.swift @@ -19,6 +19,7 @@ extension Logger { static let desktopClientConnection = Logger( subsystem: subsystem, category: "desktopclientconnection") + static let fpUiExtensionService = Logger(subsystem: subsystem, category: "fpUiExtensionService") static let enumeration = Logger(subsystem: subsystem, category: "enumeration") static let fileProviderExtension = Logger( subsystem: subsystem, category: "fileproviderextension") diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Services/FPUIExtensionServiceSource.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Services/FPUIExtensionServiceSource.swift new file mode 100644 index 0000000000000..ac9107deda9d5 --- /dev/null +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Services/FPUIExtensionServiceSource.swift @@ -0,0 +1,41 @@ +// +// FPUIExtensionCommunicationService.swift +// FileProviderExt +// +// Created by Claudio Cambra on 21/2/24. +// + +import FileProvider +import Foundation +import OSLog + +class FPUIExtensionServiceSource: NSObject, NSFileProviderServiceSource, NSXPCListenerDelegate, FPUIExtensionService { + let listener = NSXPCListener.anonymous() + let serviceName = fpUiExtensionServiceName + let fpExtension: FileProviderExtension + + init(fpExtension: FileProviderExtension) { + Logger.fpUiExtensionService.debug("Instantiating FPUIExtensionService service") + self.fpExtension = fpExtension + super.init() + } + + func makeListenerEndpoint() throws -> NSXPCListenerEndpoint { + listener.delegate = self + listener.resume() + return listener.endpoint + } + + func listener( + _ listener: NSXPCListener, + shouldAcceptNewConnection newConnection: NSXPCConnection + ) -> Bool { + newConnection.exportedInterface = NSXPCInterface(with: ClientCommunicationProtocol.self) + newConnection.exportedObject = self + newConnection.resume() + return true + } + + //MARK: - FPUIExtensionService protocol methods + +} diff --git a/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj b/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj index dd76f48fd8dca..b7b7fa01fc039 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj +++ b/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj @@ -26,6 +26,7 @@ 5376307D2B85E2ED0026BFAB /* Logger+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5376307C2B85E2ED0026BFAB /* Logger+Extensions.swift */; }; 537630912B85F4980026BFAB /* ShareViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 537630902B85F4980026BFAB /* ShareViewController.xib */; }; 537630932B85F4B00026BFAB /* ShareViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 537630922B85F4B00026BFAB /* ShareViewController.swift */; }; + 537630952B860D560026BFAB /* FPUIExtensionServiceSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = 537630942B860D560026BFAB /* FPUIExtensionServiceSource.swift */; }; 537630972B860D920026BFAB /* FPUIExtensionService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 537630962B860D920026BFAB /* FPUIExtensionService.swift */; }; 537630982B8612F00026BFAB /* FPUIExtensionService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 537630962B860D920026BFAB /* FPUIExtensionService.swift */; }; 538E396A27F4765000FA63D5 /* UniformTypeIdentifiers.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 538E396927F4765000FA63D5 /* UniformTypeIdentifiers.framework */; }; @@ -167,6 +168,7 @@ 5376307E2B85E5650026BFAB /* FileProviderUIExt.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = FileProviderUIExt.entitlements; sourceTree = ""; }; 537630902B85F4980026BFAB /* ShareViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ShareViewController.xib; sourceTree = ""; }; 537630922B85F4B00026BFAB /* ShareViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareViewController.swift; sourceTree = ""; }; + 537630942B860D560026BFAB /* FPUIExtensionServiceSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FPUIExtensionServiceSource.swift; sourceTree = ""; }; 537630962B860D920026BFAB /* FPUIExtensionService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FPUIExtensionService.swift; sourceTree = ""; }; 538E396727F4765000FA63D5 /* FileProviderExt.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = FileProviderExt.appex; sourceTree = BUILT_PRODUCTS_DIR; }; 538E396927F4765000FA63D5 /* UniformTypeIdentifiers.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UniformTypeIdentifiers.framework; path = System/Library/Frameworks/UniformTypeIdentifiers.framework; sourceTree = SDKROOT; }; @@ -271,6 +273,7 @@ 5350E4E72B0C514400F276CB /* ClientCommunicationProtocol.h */, 5350E4E82B0C534A00F276CB /* ClientCommunicationService.swift */, 537630962B860D920026BFAB /* FPUIExtensionService.swift */, + 537630942B860D560026BFAB /* FPUIExtensionServiceSource.swift */, ); path = Services; sourceTree = ""; @@ -681,6 +684,7 @@ 5318AD9529BF438F00CBB71C /* NextcloudLocalFileMetadataTable.swift in Sources */, 535AE30E29C0A2CC0042A9BA /* Logger+Extensions.swift in Sources */, 5307A6F229675346001E0C6A /* NextcloudFilesDatabaseManager.swift in Sources */, + 537630952B860D560026BFAB /* FPUIExtensionServiceSource.swift in Sources */, 53D056312970594F00988392 /* LocalFilesUtils.swift in Sources */, 538E396F27F4765000FA63D5 /* FileProviderItem.swift in Sources */, 5352B36829DC17D60011CE03 /* NextcloudFilesDatabaseManager+LocalFiles.swift in Sources */, From 05ac3063b233a3ed3695b2fcd584f306834c685e Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Tue, 27 Feb 2024 14:44:15 +0800 Subject: [PATCH 019/172] Add starter ItemSharesController Signed-off-by: Claudio Cambra --- .../Shares/ItemSharesController.swift | 17 +++++++++++++++++ .../project.pbxproj | 12 ++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Shares/ItemSharesController.swift diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Shares/ItemSharesController.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Shares/ItemSharesController.swift new file mode 100644 index 0000000000000..457acca3699e4 --- /dev/null +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Shares/ItemSharesController.swift @@ -0,0 +1,17 @@ +// +// ItemSharesController.swift +// FileProviderExt +// +// Created by Claudio Cambra on 27/2/24. +// + +import FileProvider +import Foundation + +class ItemSharesController { + let itemIdentifier: NSFileProviderItemIdentifier + + init(itemIdentifier: NSFileProviderItemIdentifier) { + self.itemIdentifier = itemIdentifier + } +} diff --git a/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj b/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj index b7b7fa01fc039..dfd6f9e12a7ea 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj +++ b/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj @@ -11,6 +11,7 @@ 5307A6E82965DAD8001E0C6A /* NextcloudKit in Frameworks */ = {isa = PBXBuildFile; productRef = 5307A6E72965DAD8001E0C6A /* NextcloudKit */; }; 5307A6EB2965DB8D001E0C6A /* RealmSwift in Frameworks */ = {isa = PBXBuildFile; productRef = 5307A6EA2965DB8D001E0C6A /* RealmSwift */; }; 5307A6F229675346001E0C6A /* NextcloudFilesDatabaseManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5307A6F129675346001E0C6A /* NextcloudFilesDatabaseManager.swift */; }; + 531522802B8DBBA2002E31BE /* ItemSharesController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5315227F2B8DBBA2002E31BE /* ItemSharesController.swift */; }; 5318AD9129BF42FB00CBB71C /* NextcloudItemMetadataTable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5318AD9029BF42FB00CBB71C /* NextcloudItemMetadataTable.swift */; }; 5318AD9529BF438F00CBB71C /* NextcloudLocalFileMetadataTable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5318AD9429BF438F00CBB71C /* NextcloudLocalFileMetadataTable.swift */; }; 5318AD9729BF493600CBB71C /* FileProviderMaterialisedEnumerationObserver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5318AD9629BF493600CBB71C /* FileProviderMaterialisedEnumerationObserver.swift */; }; @@ -150,6 +151,7 @@ /* Begin PBXFileReference section */ 5307A6F129675346001E0C6A /* NextcloudFilesDatabaseManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NextcloudFilesDatabaseManager.swift; sourceTree = ""; }; + 5315227F2B8DBBA2002E31BE /* ItemSharesController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ItemSharesController.swift; sourceTree = ""; }; 5318AD9029BF42FB00CBB71C /* NextcloudItemMetadataTable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NextcloudItemMetadataTable.swift; sourceTree = ""; }; 5318AD9429BF438F00CBB71C /* NextcloudLocalFileMetadataTable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NextcloudLocalFileMetadataTable.swift; sourceTree = ""; }; 5318AD9629BF493600CBB71C /* FileProviderMaterialisedEnumerationObserver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileProviderMaterialisedEnumerationObserver.swift; sourceTree = ""; }; @@ -254,6 +256,14 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 5315227E2B8DBB7E002E31BE /* Shares */ = { + isa = PBXGroup; + children = ( + 5315227F2B8DBBA2002E31BE /* ItemSharesController.swift */, + ); + path = Shares; + sourceTree = ""; + }; 5318AD8F29BF406500CBB71C /* Database */ = { isa = PBXGroup; children = ( @@ -310,6 +320,7 @@ 5318AD8F29BF406500CBB71C /* Database */, 5352E85929B7BFB4002CE85C /* Extensions */, 5350E4C72B0C368B00F276CB /* Services */, + 5315227E2B8DBB7E002E31BE /* Shares */, 53D666602B70C9A70042C03D /* FileProviderConfig.swift */, 538E397027F4765000FA63D5 /* FileProviderEnumerator.swift */, 53ED471F29C5E64200795DB1 /* FileProviderEnumerator+SyncEngine.swift */, @@ -685,6 +696,7 @@ 535AE30E29C0A2CC0042A9BA /* Logger+Extensions.swift in Sources */, 5307A6F229675346001E0C6A /* NextcloudFilesDatabaseManager.swift in Sources */, 537630952B860D560026BFAB /* FPUIExtensionServiceSource.swift in Sources */, + 531522802B8DBBA2002E31BE /* ItemSharesController.swift in Sources */, 53D056312970594F00988392 /* LocalFilesUtils.swift in Sources */, 538E396F27F4765000FA63D5 /* FileProviderItem.swift in Sources */, 5352B36829DC17D60011CE03 /* NextcloudFilesDatabaseManager+LocalFiles.swift in Sources */, From b3c65f1830fc40459a93185311a549185960a353 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Tue, 27 Feb 2024 15:07:02 +0800 Subject: [PATCH 020/172] Add fetch method to itemsharescontroller Signed-off-by: Claudio Cambra --- .../Extensions/Logger+Extensions.swift | 1 + .../Shares/ItemSharesController.swift | 37 ++++++++++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Extensions/Logger+Extensions.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Extensions/Logger+Extensions.swift index c6c166374010b..0f84447e28371 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Extensions/Logger+Extensions.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Extensions/Logger+Extensions.swift @@ -26,6 +26,7 @@ extension Logger { static let fileTransfer = Logger(subsystem: subsystem, category: "filetransfer") static let localFileOps = Logger(subsystem: subsystem, category: "localfileoperations") static let ncFilesDatabase = Logger(subsystem: subsystem, category: "nextcloudfilesdatabase") + static let shares = Logger(subsystem: subsystem, category: "shares") static let materialisedFileHandling = Logger( subsystem: subsystem, category: "materialisedfilehandling" ) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Shares/ItemSharesController.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Shares/ItemSharesController.swift index 457acca3699e4..d8b8ef51cc6ad 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Shares/ItemSharesController.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Shares/ItemSharesController.swift @@ -7,11 +7,46 @@ import FileProvider import Foundation +import NextcloudKit +import OSLog class ItemSharesController { let itemIdentifier: NSFileProviderItemIdentifier + let parentExtension: FileProviderExtension - init(itemIdentifier: NSFileProviderItemIdentifier) { + init(itemIdentifier: NSFileProviderItemIdentifier, parentExtension: FileProviderExtension) { self.itemIdentifier = itemIdentifier + self.parentExtension = parentExtension + } + + func fetch() async -> [NKShare]? { + let rawIdentifier = itemIdentifier.rawValue + Logger.shares.info("Fetching shares for item \(rawIdentifier)") + + guard let baseUrl = parentExtension.ncAccount?.davFilesUrl else { + Logger.shares.error("Could not fetch shares as ncAccount on parent extension is nil") + return nil + } + + let dbManager = NextcloudFilesDatabaseManager.shared + guard let item = dbManager.itemMetadataFromFileProviderItemIdentifier(itemIdentifier) else { + Logger.shares.error("No item \(rawIdentifier) in database, no shares.") + return nil + } + + let completePath = item.serverUrl + "/" + item.fileName + let relativePath = completePath.replacingOccurrences(of: baseUrl, with: "") + let parameter = NKShareParameter(path: relativePath) + + return await withCheckedContinuation { continuation in + let kit = parentExtension.ncKit + kit.readShares(parameters: parameter) { account, shares, data, error in + defer { continuation.resume(returning: shares) } + guard error == .success else { + Logger.shares.error("Error fetching shares for \(rawIdentifier): \(error)") + return + } + } + } } } From b00226cc88efcd852d8fdf96f2dd2ccf9af1c560 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Tue, 27 Feb 2024 19:39:49 +0800 Subject: [PATCH 021/172] Add table to ShareViewControlelr XIB Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/ShareViewController.xib | 176 +++++++++++++----- 1 file changed, 128 insertions(+), 48 deletions(-) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib index 10be5ff11a4de..67c247f8942c1 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib @@ -19,82 +19,162 @@ - + - - + + - - - - - - - - - + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + + - - - - - - + + + + From df27d98203a61a24383de4905301a73c9bb12fba Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Tue, 27 Feb 2024 19:56:47 +0800 Subject: [PATCH 022/172] Add starter ShareTableItemView XIB Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/ShareTableItemView.xib | 11 +++++++++++ .../NextcloudIntegration.xcodeproj/project.pbxproj | 4 ++++ 2 files changed, 15 insertions(+) create mode 100644 shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableItemView.xib diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableItemView.xib b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableItemView.xib new file mode 100644 index 0000000000000..e33e68a68285a --- /dev/null +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableItemView.xib @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj b/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj index dfd6f9e12a7ea..2b9fc595c8a1a 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj +++ b/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj @@ -12,6 +12,7 @@ 5307A6EB2965DB8D001E0C6A /* RealmSwift in Frameworks */ = {isa = PBXBuildFile; productRef = 5307A6EA2965DB8D001E0C6A /* RealmSwift */; }; 5307A6F229675346001E0C6A /* NextcloudFilesDatabaseManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5307A6F129675346001E0C6A /* NextcloudFilesDatabaseManager.swift */; }; 531522802B8DBBA2002E31BE /* ItemSharesController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5315227F2B8DBBA2002E31BE /* ItemSharesController.swift */; }; + 531522822B8E01C6002E31BE /* ShareTableItemView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 531522812B8E01C6002E31BE /* ShareTableItemView.xib */; }; 5318AD9129BF42FB00CBB71C /* NextcloudItemMetadataTable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5318AD9029BF42FB00CBB71C /* NextcloudItemMetadataTable.swift */; }; 5318AD9529BF438F00CBB71C /* NextcloudLocalFileMetadataTable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5318AD9429BF438F00CBB71C /* NextcloudLocalFileMetadataTable.swift */; }; 5318AD9729BF493600CBB71C /* FileProviderMaterialisedEnumerationObserver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5318AD9629BF493600CBB71C /* FileProviderMaterialisedEnumerationObserver.swift */; }; @@ -152,6 +153,7 @@ /* Begin PBXFileReference section */ 5307A6F129675346001E0C6A /* NextcloudFilesDatabaseManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NextcloudFilesDatabaseManager.swift; sourceTree = ""; }; 5315227F2B8DBBA2002E31BE /* ItemSharesController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ItemSharesController.swift; sourceTree = ""; }; + 531522812B8E01C6002E31BE /* ShareTableItemView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ShareTableItemView.xib; sourceTree = ""; }; 5318AD9029BF42FB00CBB71C /* NextcloudItemMetadataTable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NextcloudItemMetadataTable.swift; sourceTree = ""; }; 5318AD9429BF438F00CBB71C /* NextcloudLocalFileMetadataTable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NextcloudLocalFileMetadataTable.swift; sourceTree = ""; }; 5318AD9629BF493600CBB71C /* FileProviderMaterialisedEnumerationObserver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileProviderMaterialisedEnumerationObserver.swift; sourceTree = ""; }; @@ -355,6 +357,7 @@ children = ( 5376307B2B85E2E00026BFAB /* Extensions */, 53B979802B84C81F002DA742 /* DocumentActionViewController.swift */, + 531522812B8E01C6002E31BE /* ShareTableItemView.xib */, 537630922B85F4B00026BFAB /* ShareViewController.swift */, 537630902B85F4980026BFAB /* ShareViewController.xib */, 5376307E2B85E5650026BFAB /* FileProviderUIExt.entitlements */, @@ -634,6 +637,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 531522822B8E01C6002E31BE /* ShareTableItemView.xib in Resources */, 537630912B85F4980026BFAB /* ShareViewController.xib in Resources */, ); runOnlyForDeploymentPostprocessing = 0; From d4ba8b14e801a445104aee8f724f3cba0fb838d9 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Tue, 27 Feb 2024 19:57:01 +0800 Subject: [PATCH 023/172] Add more complete ShareTableItemView design Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/ShareTableItemView.xib | 97 ++++++++++++++++++- 1 file changed, 94 insertions(+), 3 deletions(-) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableItemView.xib b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableItemView.xib index e33e68a68285a..7f3dafe090fef 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableItemView.xib +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableItemView.xib @@ -1,11 +1,102 @@ - - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From b14ef9f5096ff8c13d04e676ca1c267f998e5fc0 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Tue, 27 Feb 2024 20:27:04 +0800 Subject: [PATCH 024/172] Add starter ShareTableViewDataSource Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/ShareTableViewDataSource.swift | 8 ++++++++ .../NextcloudIntegration.xcodeproj/project.pbxproj | 4 ++++ 2 files changed, 12 insertions(+) create mode 100644 shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift new file mode 100644 index 0000000000000..ac609094734d0 --- /dev/null +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift @@ -0,0 +1,8 @@ +// +// ShareTableViewDataSource.swift +// FileProviderUIExt +// +// Created by Claudio Cambra on 27/2/24. +// + +import Foundation diff --git a/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj b/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj index 2b9fc595c8a1a..ad7e28593eee3 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj +++ b/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj @@ -53,6 +53,7 @@ 53ED472029C5E64200795DB1 /* FileProviderEnumerator+SyncEngine.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53ED471F29C5E64200795DB1 /* FileProviderEnumerator+SyncEngine.swift */; }; 53ED472829C88E7000795DB1 /* NextcloudItemMetadataTable+NKFile.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53ED472729C88E7000795DB1 /* NextcloudItemMetadataTable+NKFile.swift */; }; 53ED473029C9CE0B00795DB1 /* FileProviderExtension+ClientInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53ED472F29C9CE0B00795DB1 /* FileProviderExtension+ClientInterface.swift */; }; + 53FE14502B8E0658006C4193 /* ShareTableViewDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53FE144F2B8E0658006C4193 /* ShareTableViewDataSource.swift */; }; C2B573BA1B1CD91E00303B36 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = C2B573B91B1CD91E00303B36 /* main.m */; }; C2B573D21B1CD94B00303B36 /* main.m in Resources */ = {isa = PBXBuildFile; fileRef = C2B573B91B1CD91E00303B36 /* main.m */; }; C2B573DE1B1CD9CE00303B36 /* FinderSync.m in Sources */ = {isa = PBXBuildFile; fileRef = C2B573DD1B1CD9CE00303B36 /* FinderSync.m */; }; @@ -197,6 +198,7 @@ 53ED471F29C5E64200795DB1 /* FileProviderEnumerator+SyncEngine.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "FileProviderEnumerator+SyncEngine.swift"; sourceTree = ""; }; 53ED472729C88E7000795DB1 /* NextcloudItemMetadataTable+NKFile.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NextcloudItemMetadataTable+NKFile.swift"; sourceTree = ""; }; 53ED472F29C9CE0B00795DB1 /* FileProviderExtension+ClientInterface.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "FileProviderExtension+ClientInterface.swift"; sourceTree = ""; }; + 53FE144F2B8E0658006C4193 /* ShareTableViewDataSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareTableViewDataSource.swift; sourceTree = ""; }; C2B573B11B1CD91E00303B36 /* desktopclient.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = desktopclient.app; sourceTree = BUILT_PRODUCTS_DIR; }; C2B573B51B1CD91E00303B36 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; C2B573B91B1CD91E00303B36 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; @@ -358,6 +360,7 @@ 5376307B2B85E2E00026BFAB /* Extensions */, 53B979802B84C81F002DA742 /* DocumentActionViewController.swift */, 531522812B8E01C6002E31BE /* ShareTableItemView.xib */, + 53FE144F2B8E0658006C4193 /* ShareTableViewDataSource.swift */, 537630922B85F4B00026BFAB /* ShareViewController.swift */, 537630902B85F4980026BFAB /* ShareViewController.xib */, 5376307E2B85E5650026BFAB /* FileProviderUIExt.entitlements */, @@ -728,6 +731,7 @@ 537630932B85F4B00026BFAB /* ShareViewController.swift in Sources */, 53B979812B84C81F002DA742 /* DocumentActionViewController.swift in Sources */, 5376307D2B85E2ED0026BFAB /* Logger+Extensions.swift in Sources */, + 53FE14502B8E0658006C4193 /* ShareTableViewDataSource.swift in Sources */, 537630982B8612F00026BFAB /* FPUIExtensionService.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; From b5edb7407390fa30a313be782965c9730f03f4a8 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Tue, 27 Feb 2024 20:27:19 +0800 Subject: [PATCH 025/172] Add outlet for share view table view Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/ShareViewController.swift | 1 + .../FileProviderUIExt/ShareViewController.xib | 1 + 2 files changed, 2 insertions(+) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift index acf5f84422f34..bd7d48fa16665 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift @@ -17,6 +17,7 @@ class ShareViewController: NSViewController { @IBOutlet weak var fileNameLabel: NSTextField! @IBOutlet weak var descriptionLabel: NSTextField! @IBOutlet weak var closeButton: NSButton! + @IBOutlet weak var tableView: NSTableView! public override var nibName: NSNib.Name? { return NSNib.Name(self.className) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib index 67c247f8942c1..90aca5a253314 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib @@ -13,6 +13,7 @@ + From b421e378b8b3a791f568df05f198ac1953e519d2 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Tue, 27 Feb 2024 20:28:09 +0800 Subject: [PATCH 026/172] Add base properties to ShareTableViewDataSource Signed-off-by: Claudio Cambra --- .../ShareTableViewDataSource.swift | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift index ac609094734d0..4ab42ac4d9bfa 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift @@ -5,4 +5,19 @@ // Created by Claudio Cambra on 27/2/24. // -import Foundation +import AppKit +import FileProvider +import NextcloudKit +class ShareTableViewDataSource: NSObject, NSTableViewDataSource { + var sharesTableView: NSTableView? { + didSet { + sharesTableView?.dataSource = self + sharesTableView?.reloadData() + } + } + private var itemIdentifier: NSFileProviderItemIdentifier? + private var itemURL: URL? + private var shares: [NKShare] = [] { + didSet { sharesTableView?.reloadData() } + } +} From 7ba8f2c943ae858791302bcda7a8afb91fd713b0 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Tue, 27 Feb 2024 20:28:27 +0800 Subject: [PATCH 027/172] Move serviceConnection method to table view data source Signed-off-by: Claudio Cambra --- .../ShareTableViewDataSource.swift | 19 +++++++++++++++++++ .../ShareViewController.swift | 19 ------------------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift index 4ab42ac4d9bfa..77fc2e42f2ca1 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift @@ -20,4 +20,23 @@ class ShareTableViewDataSource: NSObject, NSTableViewDataSource { private var shares: [NKShare] = [] { didSet { sharesTableView?.reloadData() } } + + private func serviceConnection(url: URL) async throws -> FPUIExtensionService { + let services = try await FileManager().fileProviderServicesForItem(at: url) + guard let service = services[fpUiExtensionServiceName] else { + Logger.sharesDataSource.error("Couldn't get service, required service not present") + throw NSFileProviderError(.providerNotFound) + } + let connection: NSXPCConnection + connection = try await service.fileProviderConnection() + connection.remoteObjectInterface = NSXPCInterface(with: FPUIExtensionService.self) + connection.interruptionHandler = { + Logger.sharesDataSource.error("Service connection interrupted") + } + connection.resume() + guard let proxy = connection.remoteObjectProxy as? FPUIExtensionService else { + throw NSFileProviderError(.serverUnreachable) + } + return proxy + } } diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift index bd7d48fa16665..fb5058ec9bbc3 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift @@ -87,23 +87,4 @@ class ShareViewController: NSViewController { } fileNameIcon.image = fileThumbnail?.nsImage } - - private func serviceConnection(url: URL) async throws -> FPUIExtensionService { - let services = try await FileManager().fileProviderServicesForItem(at: url) - guard let service = services[fpUiExtensionServiceName] else { - Logger.shareViewController.error("Couldn't get service, required service not present") - throw NSFileProviderError(.providerNotFound) - } - let connection: NSXPCConnection - connection = try await service.fileProviderConnection() - connection.remoteObjectInterface = NSXPCInterface(with: FPUIExtensionService.self) - connection.interruptionHandler = { - Logger.shareViewController.error("Service connection interrupted") - } - connection.resume() - guard let proxy = connection.remoteObjectProxy as? FPUIExtensionService else { - throw NSFileProviderError(.serverUnreachable) - } - return proxy - } } From ea2f67f2687b9044511595899aee03f20e950ffd Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Tue, 27 Feb 2024 20:29:46 +0800 Subject: [PATCH 028/172] Add share fetching routine to FPUIExtensionService Signed-off-by: Claudio Cambra --- .../FileProviderExt/Services/FPUIExtensionService.swift | 5 +++-- .../Services/FPUIExtensionServiceSource.swift | 9 +++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Services/FPUIExtensionService.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Services/FPUIExtensionService.swift index 94e9109ab8800..5d80b1fa9bc8d 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Services/FPUIExtensionService.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Services/FPUIExtensionService.swift @@ -5,12 +5,13 @@ // Created by Claudio Cambra on 21/2/24. // -import Foundation +import FileProvider +import NextcloudKit let fpUiExtensionServiceName = NSFileProviderServiceName( "com.nextcloud.desktopclient.FPUIExtensionService" ) @objc protocol FPUIExtensionService { - + func shares(forItemIdentifier itemIdentifier: NSFileProviderItemIdentifier) async -> [NKShare]? } diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Services/FPUIExtensionServiceSource.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Services/FPUIExtensionServiceSource.swift index ac9107deda9d5..85f3de7e6ef48 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Services/FPUIExtensionServiceSource.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Services/FPUIExtensionServiceSource.swift @@ -7,6 +7,7 @@ import FileProvider import Foundation +import NextcloudKit import OSLog class FPUIExtensionServiceSource: NSObject, NSFileProviderServiceSource, NSXPCListenerDelegate, FPUIExtensionService { @@ -38,4 +39,12 @@ class FPUIExtensionServiceSource: NSObject, NSFileProviderServiceSource, NSXPCLi //MARK: - FPUIExtensionService protocol methods + func shares( + forItemIdentifier itemIdentifier: NSFileProviderItemIdentifier + ) async -> [NKShare]? { + let controller = ItemSharesController( + itemIdentifier: itemIdentifier, parentExtension: fpExtension + ) + return await controller.fetch() + } } From d3260989fd4632d6e8abcaa11ea96dedbaca087f Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Tue, 27 Feb 2024 20:28:55 +0800 Subject: [PATCH 029/172] Add item shares loading routine to ShareTableViewDataSource Signed-off-by: Claudio Cambra --- .../Extensions/Logger+Extensions.swift | 1 + .../ShareTableViewDataSource.swift | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Extensions/Logger+Extensions.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Extensions/Logger+Extensions.swift index 8ec218668472f..63ff845a69d80 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Extensions/Logger+Extensions.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Extensions/Logger+Extensions.swift @@ -11,6 +11,7 @@ extension Logger { private static var subsystem = Bundle.main.bundleIdentifier! static let actionViewController = Logger(subsystem: subsystem, category: "actionViewController") + static let sharesDataSource = Logger(subsystem: subsystem, category: "sharesDataSource") static let shareViewController = Logger(subsystem: subsystem, category: "shareViewController") } diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift index 77fc2e42f2ca1..7d19fb7fe91e2 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift @@ -8,6 +8,8 @@ import AppKit import FileProvider import NextcloudKit +import OSLog + class ShareTableViewDataSource: NSObject, NSTableViewDataSource { var sharesTableView: NSTableView? { didSet { @@ -21,6 +23,24 @@ class ShareTableViewDataSource: NSObject, NSTableViewDataSource { didSet { sharesTableView?.reloadData() } } + func loadItem(identifier: NSFileProviderItemIdentifier, url: URL) { + itemIdentifier = identifier + itemURL = url + Task { + await reload() + } + } + + private func reload() async { + guard let itemIdentifier = itemIdentifier, let itemURL = itemURL else { return } + do { + let connection = try await serviceConnection(url: itemURL) + shares = await connection.shares(forItemIdentifier: itemIdentifier) ?? [] + } catch let error { + Logger.sharesDataSource.error("Could not reload data: \(error)") + } + } + private func serviceConnection(url: URL) async throws -> FPUIExtensionService { let services = try await FileManager().fileProviderServicesForItem(at: url) guard let service = services[fpUiExtensionServiceName] else { From 0dd8c3166595bd097f69c4659b8ccb7c8546d734 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Tue, 27 Feb 2024 20:29:07 +0800 Subject: [PATCH 030/172] Instantiate share data source in share view controller Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/ShareViewController.swift | 3 +++ 1 file changed, 3 insertions(+) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift index fb5058ec9bbc3..d2d8fac636d14 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift @@ -11,6 +11,7 @@ import OSLog import QuickLookThumbnailing class ShareViewController: NSViewController { + let shareDataSource = ShareTableViewDataSource() let itemIdentifiers: [NSFileProviderItemIdentifier] @IBOutlet weak var fileNameIcon: NSImageView! @@ -58,6 +59,8 @@ class ShareViewController: NSViewController { do { let itemUrl = try await manager.getUserVisibleURL(for: itemIdentifier) await updateDisplay(itemUrl: itemUrl) + shareDataSource.sharesTableView = tableView + shareDataSource.loadItem(identifier: itemIdentifier, url: itemUrl) } catch let error { let errorString = "Error processing item: \(error)" Logger.shareViewController.error("\(errorString)") From ae9cd35e72631dd3c31737c9e03baddb406bcbfd Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Tue, 27 Feb 2024 21:24:49 +0800 Subject: [PATCH 031/172] Fix protocol used for FPUIExtensionServiceSource Signed-off-by: Claudio Cambra --- .../FileProviderExt/Services/FPUIExtensionServiceSource.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Services/FPUIExtensionServiceSource.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Services/FPUIExtensionServiceSource.swift index 85f3de7e6ef48..fc78889932c64 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Services/FPUIExtensionServiceSource.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Services/FPUIExtensionServiceSource.swift @@ -31,7 +31,7 @@ class FPUIExtensionServiceSource: NSObject, NSFileProviderServiceSource, NSXPCLi _ listener: NSXPCListener, shouldAcceptNewConnection newConnection: NSXPCConnection ) -> Bool { - newConnection.exportedInterface = NSXPCInterface(with: ClientCommunicationProtocol.self) + newConnection.exportedInterface = NSXPCInterface(with: FPUIExtensionService.self) newConnection.exportedObject = self newConnection.resume() return true From 2155fc943a6c27cc6da7a03df2175647a9a80747 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Tue, 27 Feb 2024 21:25:02 +0800 Subject: [PATCH 032/172] Fix visibility of logging in ItemSharesController Signed-off-by: Claudio Cambra --- .../FileProviderExt/Shares/ItemSharesController.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Shares/ItemSharesController.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Shares/ItemSharesController.swift index d8b8ef51cc6ad..6db1a91665e8f 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Shares/ItemSharesController.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Shares/ItemSharesController.swift @@ -21,7 +21,7 @@ class ItemSharesController { func fetch() async -> [NKShare]? { let rawIdentifier = itemIdentifier.rawValue - Logger.shares.info("Fetching shares for item \(rawIdentifier)") + Logger.shares.info("Fetching shares for item \(rawIdentifier, privacy: .public)") guard let baseUrl = parentExtension.ncAccount?.davFilesUrl else { Logger.shares.error("Could not fetch shares as ncAccount on parent extension is nil") @@ -30,7 +30,7 @@ class ItemSharesController { let dbManager = NextcloudFilesDatabaseManager.shared guard let item = dbManager.itemMetadataFromFileProviderItemIdentifier(itemIdentifier) else { - Logger.shares.error("No item \(rawIdentifier) in database, no shares.") + Logger.shares.error("No item \(rawIdentifier, privacy: .public) in db, no shares.") return nil } From d3eceeb42473c90395e1dbf6d17de7e0e3ac0d06 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Tue, 27 Feb 2024 21:25:22 +0800 Subject: [PATCH 033/172] Add FPUIExtensionServiceSource to services published by FileProviderExt Signed-off-by: Claudio Cambra --- .../FileProviderExtension+ClientInterface.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/FileProviderExtension+ClientInterface.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/FileProviderExtension+ClientInterface.swift index a357b79eae20a..5a5fcecfce60e 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/FileProviderExtension+ClientInterface.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/FileProviderExtension+ClientInterface.swift @@ -39,7 +39,8 @@ extension FileProviderExtension: NSFileProviderServicing { ) -> Progress { Logger.desktopClientConnection.debug("Serving supported service sources") let clientCommService = ClientCommunicationService(fpExtension: self) - let services = [clientCommService] + let fpuiExtService = FPUIExtensionServiceSource(fpExtension: self) + let services: [NSFileProviderServiceSource] = [clientCommService, fpuiExtService] completionHandler(services, nil) let progress = Progress() progress.cancellationHandler = { From fa8e39f5670a74e9d70e1344af1b3d7fc53df994 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Tue, 27 Feb 2024 21:25:47 +0800 Subject: [PATCH 034/172] Fix linking of FileProviderUIExt which was missing NextcloudKit symbols Signed-off-by: Claudio Cambra --- .../project.pbxproj | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj b/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj index ad7e28593eee3..d2eafb3d26510 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj +++ b/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj @@ -54,6 +54,7 @@ 53ED472829C88E7000795DB1 /* NextcloudItemMetadataTable+NKFile.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53ED472729C88E7000795DB1 /* NextcloudItemMetadataTable+NKFile.swift */; }; 53ED473029C9CE0B00795DB1 /* FileProviderExtension+ClientInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53ED472F29C9CE0B00795DB1 /* FileProviderExtension+ClientInterface.swift */; }; 53FE14502B8E0658006C4193 /* ShareTableViewDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53FE144F2B8E0658006C4193 /* ShareTableViewDataSource.swift */; }; + 53FE14542B8E1219006C4193 /* NextcloudKit in Frameworks */ = {isa = PBXBuildFile; productRef = 53FE14532B8E1219006C4193 /* NextcloudKit */; }; C2B573BA1B1CD91E00303B36 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = C2B573B91B1CD91E00303B36 /* main.m */; }; C2B573D21B1CD94B00303B36 /* main.m in Resources */ = {isa = PBXBuildFile; fileRef = C2B573B91B1CD91E00303B36 /* main.m */; }; C2B573DE1B1CD9CE00303B36 /* FinderSync.m in Sources */ = {isa = PBXBuildFile; fileRef = C2B573DD1B1CD9CE00303B36 /* FinderSync.m */; }; @@ -237,6 +238,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 53FE14542B8E1219006C4193 /* NextcloudKit in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -506,8 +508,12 @@ buildRules = ( ); dependencies = ( + 53FE14522B8E1213006C4193 /* PBXTargetDependency */, ); name = FileProviderUIExt; + packageProductDependencies = ( + 53FE14532B8E1219006C4193 /* NextcloudKit */, + ); productName = FileProviderUIExt; productReference = 53B9797E2B84C81F002DA742 /* FileProviderUIExt.appex */; productType = "com.apple.product-type.app-extension"; @@ -776,6 +782,10 @@ target = 53903D0B2956164F00D0B308 /* NCDesktopClientSocketKit */; targetProxy = 53903D322956173F00D0B308 /* PBXContainerItemProxy */; }; + 53FE14522B8E1213006C4193 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + productRef = 53FE14512B8E1213006C4193 /* NextcloudKit */; + }; C2B573E01B1CD9CE00303B36 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = C2B573D61B1CD9CE00303B36 /* FinderSyncExt */; @@ -1523,6 +1533,16 @@ package = 5307A6E92965DB57001E0C6A /* XCRemoteSwiftPackageReference "realm-swift" */; productName = RealmSwift; }; + 53FE14512B8E1213006C4193 /* NextcloudKit */ = { + isa = XCSwiftPackageProductDependency; + package = 5307A6E42965C6FA001E0C6A /* XCRemoteSwiftPackageReference "NextcloudKit" */; + productName = NextcloudKit; + }; + 53FE14532B8E1219006C4193 /* NextcloudKit */ = { + isa = XCSwiftPackageProductDependency; + package = 5307A6E42965C6FA001E0C6A /* XCRemoteSwiftPackageReference "NextcloudKit" */; + productName = NextcloudKit; + }; /* End XCSwiftPackageProductDependency section */ }; rootObject = C2B573951B1CD88000303B36 /* Project object */; From e1062292c2cd6638154909684b7ae50665308a47 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Tue, 27 Feb 2024 22:43:46 +0800 Subject: [PATCH 035/172] Add method to export NextcloudAccount details to dictionary Signed-off-by: Claudio Cambra --- .../FileProviderExt/NextcloudAccount.swift | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/NextcloudAccount.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/NextcloudAccount.swift index cb3b7ea628f9c..14c242b49332e 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/NextcloudAccount.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/NextcloudAccount.swift @@ -15,6 +15,12 @@ import FileProvider import Foundation +let ncAccountDictUsernameKey = "usernameKey" +let ncAccountDictPasswordKey = "passwordKey" +let ncAccountDictNcKitAccountKey = "ncKitAccountKey" +let ncAccountDictServerUrlKey = "serverUrlKey" +let ncAccountDictDavFilesUrlKey = "davFilesUrlKey" + struct NextcloudAccount: Equatable { static let webDavFilesUrlSuffix: String = "/remote.php/dav/files/" let username, password, ncKitAccount, serverUrl, davFilesUrl: String @@ -26,4 +32,14 @@ struct NextcloudAccount: Equatable { self.serverUrl = serverUrl davFilesUrl = serverUrl + NextcloudAccount.webDavFilesUrlSuffix + user } + + func dictionary() -> Dictionary { + return [ + ncAccountDictUsernameKey: username, + ncAccountDictPasswordKey: password, + ncAccountDictNcKitAccountKey: ncKitAccount, + ncAccountDictServerUrlKey: serverUrl, + ncAccountDictDavFilesUrlKey: davFilesUrl + ] + } } From 1a5213cdcfbfd8b79fe38e4e939ec33e963a4ab3 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Tue, 27 Feb 2024 22:43:58 +0800 Subject: [PATCH 036/172] Add method to convert dictionary to NextcloudAccount Signed-off-by: Claudio Cambra --- .../Extensions/Logger+Extensions.swift | 1 + .../FileProviderExt/NextcloudAccount.swift | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Extensions/Logger+Extensions.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Extensions/Logger+Extensions.swift index 0f84447e28371..e9e5d78fd0d2a 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Extensions/Logger+Extensions.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Extensions/Logger+Extensions.swift @@ -27,6 +27,7 @@ extension Logger { static let localFileOps = Logger(subsystem: subsystem, category: "localfileoperations") static let ncFilesDatabase = Logger(subsystem: subsystem, category: "nextcloudfilesdatabase") static let shares = Logger(subsystem: subsystem, category: "shares") + static let ncAccount = Logger(subsystem: subsystem, category: "ncAccount") static let materialisedFileHandling = Logger( subsystem: subsystem, category: "materialisedfilehandling" ) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/NextcloudAccount.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/NextcloudAccount.swift index 14c242b49332e..b522d8d0386fe 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/NextcloudAccount.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/NextcloudAccount.swift @@ -14,6 +14,7 @@ import FileProvider import Foundation +import OSLog let ncAccountDictUsernameKey = "usernameKey" let ncAccountDictPasswordKey = "passwordKey" @@ -33,6 +34,24 @@ struct NextcloudAccount: Equatable { davFilesUrl = serverUrl + NextcloudAccount.webDavFilesUrlSuffix + user } + init?(dictionary: Dictionary) { + guard let username = dictionary[ncAccountDictUsernameKey], + let password = dictionary[ncAccountDictPasswordKey], + let ncKitAccount = dictionary[ncAccountDictNcKitAccountKey], + let serverUrl = dictionary[ncAccountDictServerUrlKey], + let davFilesUrl = dictionary[ncAccountDictDavFilesUrlKey] + else { + Logger.ncAccount.error("Could not convert dictionary to NextcloudAccount!") + return nil + } + + self.username = username + self.password = password + self.ncKitAccount = ncKitAccount + self.serverUrl = serverUrl + self.davFilesUrl = davFilesUrl + } + func dictionary() -> Dictionary { return [ ncAccountDictUsernameKey: username, From 4ab690bf54545b6ab9aac325d6dc9f6f46333333 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Tue, 27 Feb 2024 22:44:12 +0800 Subject: [PATCH 037/172] Add NextcloudAccount to FileProviderUIExt Signed-off-by: Claudio Cambra --- .../NextcloudIntegration.xcodeproj/project.pbxproj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj b/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj index d2eafb3d26510..0e04308d4c0e5 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj +++ b/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj @@ -55,6 +55,7 @@ 53ED473029C9CE0B00795DB1 /* FileProviderExtension+ClientInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53ED472F29C9CE0B00795DB1 /* FileProviderExtension+ClientInterface.swift */; }; 53FE14502B8E0658006C4193 /* ShareTableViewDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53FE144F2B8E0658006C4193 /* ShareTableViewDataSource.swift */; }; 53FE14542B8E1219006C4193 /* NextcloudKit in Frameworks */ = {isa = PBXBuildFile; productRef = 53FE14532B8E1219006C4193 /* NextcloudKit */; }; + 53FE14552B8E28E9006C4193 /* NextcloudAccount.swift in Sources */ = {isa = PBXBuildFile; fileRef = 536EFC35295E3C1100F4CB13 /* NextcloudAccount.swift */; }; C2B573BA1B1CD91E00303B36 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = C2B573B91B1CD91E00303B36 /* main.m */; }; C2B573D21B1CD94B00303B36 /* main.m in Resources */ = {isa = PBXBuildFile; fileRef = C2B573B91B1CD91E00303B36 /* main.m */; }; C2B573DE1B1CD9CE00303B36 /* FinderSync.m in Sources */ = {isa = PBXBuildFile; fileRef = C2B573DD1B1CD9CE00303B36 /* FinderSync.m */; }; @@ -736,6 +737,7 @@ files = ( 537630932B85F4B00026BFAB /* ShareViewController.swift in Sources */, 53B979812B84C81F002DA742 /* DocumentActionViewController.swift in Sources */, + 53FE14552B8E28E9006C4193 /* NextcloudAccount.swift in Sources */, 5376307D2B85E2ED0026BFAB /* Logger+Extensions.swift in Sources */, 53FE14502B8E0658006C4193 /* ShareTableViewDataSource.swift in Sources */, 537630982B8612F00026BFAB /* FPUIExtensionService.swift in Sources */, From 610a235b6c960b0844a89971d149dc3e23fca761 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Tue, 27 Feb 2024 22:47:43 +0800 Subject: [PATCH 038/172] Add method to FPUIExtensionServiceSource to get extension account details Signed-off-by: Claudio Cambra --- .../FileProviderExt/Services/FPUIExtensionService.swift | 1 + .../FileProviderExt/Services/FPUIExtensionServiceSource.swift | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Services/FPUIExtensionService.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Services/FPUIExtensionService.swift index 5d80b1fa9bc8d..4cfa0fe4d9cf3 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Services/FPUIExtensionService.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Services/FPUIExtensionService.swift @@ -14,4 +14,5 @@ let fpUiExtensionServiceName = NSFileProviderServiceName( @objc protocol FPUIExtensionService { func shares(forItemIdentifier itemIdentifier: NSFileProviderItemIdentifier) async -> [NKShare]? + func credentials() async -> NSDictionary } diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Services/FPUIExtensionServiceSource.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Services/FPUIExtensionServiceSource.swift index fc78889932c64..af4c39a902d31 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Services/FPUIExtensionServiceSource.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Services/FPUIExtensionServiceSource.swift @@ -47,4 +47,8 @@ class FPUIExtensionServiceSource: NSObject, NSFileProviderServiceSource, NSXPCLi ) return await controller.fetch() } + + func credentials() async -> NSDictionary { + return (fpExtension.ncAccount?.dictionary() ?? [:]) as NSDictionary + } } From 41f2d9ed87c4334abe8a39601f15755ebd71c7df Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Tue, 27 Feb 2024 23:53:19 +0800 Subject: [PATCH 039/172] Remove logging from NextcloudAccount Signed-off-by: Claudio Cambra --- .../NextcloudIntegration/FileProviderExt/NextcloudAccount.swift | 2 -- 1 file changed, 2 deletions(-) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/NextcloudAccount.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/NextcloudAccount.swift index b522d8d0386fe..4af76fa4fdf91 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/NextcloudAccount.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/NextcloudAccount.swift @@ -14,7 +14,6 @@ import FileProvider import Foundation -import OSLog let ncAccountDictUsernameKey = "usernameKey" let ncAccountDictPasswordKey = "passwordKey" @@ -41,7 +40,6 @@ struct NextcloudAccount: Equatable { let serverUrl = dictionary[ncAccountDictServerUrlKey], let davFilesUrl = dictionary[ncAccountDictDavFilesUrlKey] else { - Logger.ncAccount.error("Could not convert dictionary to NextcloudAccount!") return nil } From ba685fb6014fa8f62bc20857c55c881c643be270 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Tue, 27 Feb 2024 23:53:49 +0800 Subject: [PATCH 040/172] Add method to get an item's server path through FPUIExtensionService Signed-off-by: Claudio Cambra --- .../Services/FPUIExtensionService.swift | 1 + .../Services/FPUIExtensionServiceSource.swift | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Services/FPUIExtensionService.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Services/FPUIExtensionService.swift index 4cfa0fe4d9cf3..b308fae0592f6 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Services/FPUIExtensionService.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Services/FPUIExtensionService.swift @@ -15,4 +15,5 @@ let fpUiExtensionServiceName = NSFileProviderServiceName( @objc protocol FPUIExtensionService { func shares(forItemIdentifier itemIdentifier: NSFileProviderItemIdentifier) async -> [NKShare]? func credentials() async -> NSDictionary + func itemServerPath(identifier: NSFileProviderItemIdentifier) async -> NSString? } diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Services/FPUIExtensionServiceSource.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Services/FPUIExtensionServiceSource.swift index af4c39a902d31..7e58a0e0147d9 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Services/FPUIExtensionServiceSource.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Services/FPUIExtensionServiceSource.swift @@ -51,4 +51,23 @@ class FPUIExtensionServiceSource: NSObject, NSFileProviderServiceSource, NSXPCLi func credentials() async -> NSDictionary { return (fpExtension.ncAccount?.dictionary() ?? [:]) as NSDictionary } + + func itemServerPath(identifier: NSFileProviderItemIdentifier) async -> NSString? { + let rawIdentifier = identifier.rawValue + Logger.shares.info("Fetching shares for item \(rawIdentifier, privacy: .public)") + + guard let baseUrl = fpExtension.ncAccount?.davFilesUrl else { + Logger.shares.error("Could not fetch shares as ncAccount on parent extension is nil") + return nil + } + + let dbManager = NextcloudFilesDatabaseManager.shared + guard let item = dbManager.itemMetadataFromFileProviderItemIdentifier(identifier) else { + Logger.shares.error("No item \(rawIdentifier, privacy: .public) in db, no shares.") + return nil + } + + let completePath = item.serverUrl + "/" + item.fileName + return completePath.replacingOccurrences(of: baseUrl, with: "") as NSString + } } From 421f51fbcd7d863c332bb965dbb93dcf6872a7b7 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Tue, 27 Feb 2024 23:54:12 +0800 Subject: [PATCH 041/172] Add release entitlements fro FileProviderUIExt Signed-off-by: Claudio Cambra --- .../FileProviderUIExtRelease.entitlements | 16 ++++++++++++++++ .../project.pbxproj | 4 +++- 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/FileProviderUIExtRelease.entitlements diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/FileProviderUIExtRelease.entitlements b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/FileProviderUIExtRelease.entitlements new file mode 100644 index 0000000000000..eab912dc49600 --- /dev/null +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/FileProviderUIExtRelease.entitlements @@ -0,0 +1,16 @@ + + + + + com.apple.security.app-sandbox + + com.apple.security.application-groups + + $(OC_SOCKETAPI_TEAM_IDENTIFIER_PREFIX)$(OC_APPLICATION_REV_DOMAIN) + + com.apple.security.network.client + + com.apple.security.network.server + + + diff --git a/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj b/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj index 0e04308d4c0e5..80b5bc295400d 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj +++ b/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj @@ -201,6 +201,7 @@ 53ED472729C88E7000795DB1 /* NextcloudItemMetadataTable+NKFile.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NextcloudItemMetadataTable+NKFile.swift"; sourceTree = ""; }; 53ED472F29C9CE0B00795DB1 /* FileProviderExtension+ClientInterface.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "FileProviderExtension+ClientInterface.swift"; sourceTree = ""; }; 53FE144F2B8E0658006C4193 /* ShareTableViewDataSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareTableViewDataSource.swift; sourceTree = ""; }; + 53FE14572B8E3A7C006C4193 /* FileProviderUIExtRelease.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = FileProviderUIExtRelease.entitlements; sourceTree = ""; }; C2B573B11B1CD91E00303B36 /* desktopclient.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = desktopclient.app; sourceTree = BUILT_PRODUCTS_DIR; }; C2B573B51B1CD91E00303B36 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; C2B573B91B1CD91E00303B36 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; @@ -367,6 +368,7 @@ 537630922B85F4B00026BFAB /* ShareViewController.swift */, 537630902B85F4980026BFAB /* ShareViewController.xib */, 5376307E2B85E5650026BFAB /* FileProviderUIExt.entitlements */, + 53FE14572B8E3A7C006C4193 /* FileProviderUIExtRelease.entitlements */, 53B979852B84C81F002DA742 /* Info.plist */, ); path = FileProviderUIExt; @@ -1111,7 +1113,7 @@ CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CODE_SIGN_ENTITLEMENTS = FileProviderUIExt/FileProviderUIExt.entitlements; + CODE_SIGN_ENTITLEMENTS = FileProviderUIExt/FileProviderUIExtRelease.entitlements; CODE_SIGN_INJECT_BASE_ENTITLEMENTS = NO; CODE_SIGN_STYLE = Manual; COPY_PHASE_STRIP = NO; From 02c7f57261929ee37ea0cc8b50ca5d35a1afb49c Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Tue, 27 Feb 2024 23:55:26 +0800 Subject: [PATCH 042/172] Add essential table view data source method to ShareTableViewDataSource Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/ShareTableViewDataSource.swift | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift index 7d19fb7fe91e2..fac590e2afde6 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift @@ -59,4 +59,10 @@ class ShareTableViewDataSource: NSObject, NSTableViewDataSource { } return proxy } + + // MARK: - NSTableViewDataSource protocol methods + + @objc func numberOfRows(in tableView: NSTableView) -> Int { + shares.count + } } From f98d38e1022b1b306758a5af6ebe89556d12e9ed Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Tue, 27 Feb 2024 23:56:08 +0800 Subject: [PATCH 043/172] Implement NSTableViewDelegate viewFor method in sharetableviewdatasource Signed-off-by: Claudio Cambra --- .../ShareTableViewDataSource.swift | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift index fac590e2afde6..e02377ffe499f 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift @@ -10,7 +10,8 @@ import FileProvider import NextcloudKit import OSLog -class ShareTableViewDataSource: NSObject, NSTableViewDataSource { +class ShareTableViewDataSource: NSObject, NSTableViewDataSource, NSTableViewDelegate { + private let shareItemViewIdentifier = NSUserInterfaceItemIdentifier("ShareTableItemView") var sharesTableView: NSTableView? { didSet { sharesTableView?.dataSource = self @@ -65,4 +66,14 @@ class ShareTableViewDataSource: NSObject, NSTableViewDataSource { @objc func numberOfRows(in tableView: NSTableView) -> Int { shares.count } + + // MARK: - NSTableViewDelegate protocol methods + + @objc func tableView( + _ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int + ) -> NSView? { + //let share = shares[row] + let view = tableView.makeView(withIdentifier: shareItemViewIdentifier, owner: self) + return view + } } From da3633545da1b77bc138ac6dc21b2fb3ec81678f Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Tue, 27 Feb 2024 23:56:18 +0800 Subject: [PATCH 044/172] Register shareItemView nib in shareTableView Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/ShareTableViewDataSource.swift | 3 +++ 1 file changed, 3 insertions(+) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift index e02377ffe499f..d5a1b2163ef95 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift @@ -12,8 +12,11 @@ import OSLog class ShareTableViewDataSource: NSObject, NSTableViewDataSource, NSTableViewDelegate { private let shareItemViewIdentifier = NSUserInterfaceItemIdentifier("ShareTableItemView") + private let shareItemViewNib = NSNib(nibNamed: "ShareTableItemView", bundle: nil) + var sharesTableView: NSTableView? { didSet { + sharesTableView?.register(shareItemViewNib, forIdentifier: shareItemViewIdentifier) sharesTableView?.dataSource = self sharesTableView?.reloadData() } From 456b2525e420d997d9330b3910c0358386fb4ede Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Tue, 27 Feb 2024 23:56:55 +0800 Subject: [PATCH 045/172] Move all share fetching logic to FileProviderUIExt Signed-off-by: Claudio Cambra --- .../Services/FPUIExtensionService.swift | 1 - .../Services/FPUIExtensionServiceSource.swift | 9 --- .../Shares/ItemSharesController.swift | 52 ------------- .../ShareTableViewDataSource.swift | 74 +++++++++++++++++-- .../ShareViewController.swift | 2 +- .../project.pbxproj | 12 --- 6 files changed, 69 insertions(+), 81 deletions(-) delete mode 100644 shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Shares/ItemSharesController.swift diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Services/FPUIExtensionService.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Services/FPUIExtensionService.swift index b308fae0592f6..0c3e444a9abbc 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Services/FPUIExtensionService.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Services/FPUIExtensionService.swift @@ -13,7 +13,6 @@ let fpUiExtensionServiceName = NSFileProviderServiceName( ) @objc protocol FPUIExtensionService { - func shares(forItemIdentifier itemIdentifier: NSFileProviderItemIdentifier) async -> [NKShare]? func credentials() async -> NSDictionary func itemServerPath(identifier: NSFileProviderItemIdentifier) async -> NSString? } diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Services/FPUIExtensionServiceSource.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Services/FPUIExtensionServiceSource.swift index 7e58a0e0147d9..76f7f10f4e48d 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Services/FPUIExtensionServiceSource.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Services/FPUIExtensionServiceSource.swift @@ -39,15 +39,6 @@ class FPUIExtensionServiceSource: NSObject, NSFileProviderServiceSource, NSXPCLi //MARK: - FPUIExtensionService protocol methods - func shares( - forItemIdentifier itemIdentifier: NSFileProviderItemIdentifier - ) async -> [NKShare]? { - let controller = ItemSharesController( - itemIdentifier: itemIdentifier, parentExtension: fpExtension - ) - return await controller.fetch() - } - func credentials() async -> NSDictionary { return (fpExtension.ncAccount?.dictionary() ?? [:]) as NSDictionary } diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Shares/ItemSharesController.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Shares/ItemSharesController.swift deleted file mode 100644 index 6db1a91665e8f..0000000000000 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Shares/ItemSharesController.swift +++ /dev/null @@ -1,52 +0,0 @@ -// -// ItemSharesController.swift -// FileProviderExt -// -// Created by Claudio Cambra on 27/2/24. -// - -import FileProvider -import Foundation -import NextcloudKit -import OSLog - -class ItemSharesController { - let itemIdentifier: NSFileProviderItemIdentifier - let parentExtension: FileProviderExtension - - init(itemIdentifier: NSFileProviderItemIdentifier, parentExtension: FileProviderExtension) { - self.itemIdentifier = itemIdentifier - self.parentExtension = parentExtension - } - - func fetch() async -> [NKShare]? { - let rawIdentifier = itemIdentifier.rawValue - Logger.shares.info("Fetching shares for item \(rawIdentifier, privacy: .public)") - - guard let baseUrl = parentExtension.ncAccount?.davFilesUrl else { - Logger.shares.error("Could not fetch shares as ncAccount on parent extension is nil") - return nil - } - - let dbManager = NextcloudFilesDatabaseManager.shared - guard let item = dbManager.itemMetadataFromFileProviderItemIdentifier(itemIdentifier) else { - Logger.shares.error("No item \(rawIdentifier, privacy: .public) in db, no shares.") - return nil - } - - let completePath = item.serverUrl + "/" + item.fileName - let relativePath = completePath.replacingOccurrences(of: baseUrl, with: "") - let parameter = NKShareParameter(path: relativePath) - - return await withCheckedContinuation { continuation in - let kit = parentExtension.ncKit - kit.readShares(parameters: parameter) { account, shares, data, error in - defer { continuation.resume(returning: shares) } - guard error == .success else { - Logger.shares.error("Error fetching shares for \(rawIdentifier): \(error)") - return - } - } - } - } -} diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift index d5a1b2163ef95..636e5a10d09b9 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift @@ -21,14 +21,25 @@ class ShareTableViewDataSource: NSObject, NSTableViewDataSource, NSTableViewDele sharesTableView?.reloadData() } } - private var itemIdentifier: NSFileProviderItemIdentifier? + private var kit: NextcloudKit? private var itemURL: URL? private var shares: [NKShare] = [] { didSet { sharesTableView?.reloadData() } } + private var account: NextcloudAccount? { + didSet { + guard let account = account else { return } + kit = NextcloudKit() + kit?.setup( + user: account.username, + userId: account.username, + password: account.password, + urlBase: account.serverUrl + ) + } + } - func loadItem(identifier: NSFileProviderItemIdentifier, url: URL) { - itemIdentifier = identifier + func loadItem(url: URL) { itemURL = url Task { await reload() @@ -36,12 +47,37 @@ class ShareTableViewDataSource: NSObject, NSTableViewDataSource, NSTableViewDele } private func reload() async { - guard let itemIdentifier = itemIdentifier, let itemURL = itemURL else { return } + guard let itemURL = itemURL else { return } + guard let itemIdentifier = await withCheckedContinuation({ + (continuation: CheckedContinuation) -> Void in + NSFileProviderManager.getIdentifierForUserVisibleFile( + at: itemURL + ) { identifier, domainIdentifier, error in + defer { continuation.resume(returning: identifier) } + guard error == nil else { + Logger.sharesDataSource.error("No identifier: \(error, privacy: .public)") + return + } + } + }) else { + Logger.sharesDataSource.error("Could not get identifier for item, no shares.") + return + } + do { let connection = try await serviceConnection(url: itemURL) - shares = await connection.shares(forItemIdentifier: itemIdentifier) ?? [] + guard let serverPath = await connection.itemServerPath(identifier: itemIdentifier), + let credentials = await connection.credentials() as? Dictionary, + let convertedAccount = NextcloudAccount(dictionary: credentials) else { + Logger.sharesDataSource.error("Failed to get details from FileProviderExt") + return + } + account = convertedAccount + shares = await fetch( + itemIdentifier: itemIdentifier, itemRelativePath: serverPath as String + ) } catch let error { - Logger.sharesDataSource.error("Could not reload data: \(error)") + Logger.sharesDataSource.error("Could not reload data: \(error, privacy: .public)") } } @@ -64,6 +100,32 @@ class ShareTableViewDataSource: NSObject, NSTableViewDataSource, NSTableViewDele return proxy } + private func fetch( + itemIdentifier: NSFileProviderItemIdentifier, itemRelativePath: String + ) async -> [NKShare] { + let rawIdentifier = itemIdentifier.rawValue + Logger.sharesDataSource.info("Fetching shares for item \(rawIdentifier, privacy: .public)") + + guard let kit = kit else { + Logger.sharesDataSource.error("NextcloudKit instance is nil") + return [] + } + + let parameter = NKShareParameter(path: itemRelativePath) + + return await withCheckedContinuation { continuation in + kit.readShares(parameters: parameter) { account, shares, data, error in + let shareCount = shares?.count ?? 0 + Logger.sharesDataSource.info("Received \(shareCount, privacy: .public) shares") + defer { continuation.resume(returning: shares ?? []) } + guard error == .success else { + Logger.sharesDataSource.error("Error fetching shares: \(error)") + return + } + } + } + } + // MARK: - NSTableViewDataSource protocol methods @objc func numberOfRows(in tableView: NSTableView) -> Int { diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift index d2d8fac636d14..45dd36cbf8f64 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift @@ -60,7 +60,7 @@ class ShareViewController: NSViewController { let itemUrl = try await manager.getUserVisibleURL(for: itemIdentifier) await updateDisplay(itemUrl: itemUrl) shareDataSource.sharesTableView = tableView - shareDataSource.loadItem(identifier: itemIdentifier, url: itemUrl) + shareDataSource.loadItem(url: itemUrl) } catch let error { let errorString = "Error processing item: \(error)" Logger.shareViewController.error("\(errorString)") diff --git a/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj b/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj index 80b5bc295400d..294d9d56f3695 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj +++ b/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj @@ -11,7 +11,6 @@ 5307A6E82965DAD8001E0C6A /* NextcloudKit in Frameworks */ = {isa = PBXBuildFile; productRef = 5307A6E72965DAD8001E0C6A /* NextcloudKit */; }; 5307A6EB2965DB8D001E0C6A /* RealmSwift in Frameworks */ = {isa = PBXBuildFile; productRef = 5307A6EA2965DB8D001E0C6A /* RealmSwift */; }; 5307A6F229675346001E0C6A /* NextcloudFilesDatabaseManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5307A6F129675346001E0C6A /* NextcloudFilesDatabaseManager.swift */; }; - 531522802B8DBBA2002E31BE /* ItemSharesController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5315227F2B8DBBA2002E31BE /* ItemSharesController.swift */; }; 531522822B8E01C6002E31BE /* ShareTableItemView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 531522812B8E01C6002E31BE /* ShareTableItemView.xib */; }; 5318AD9129BF42FB00CBB71C /* NextcloudItemMetadataTable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5318AD9029BF42FB00CBB71C /* NextcloudItemMetadataTable.swift */; }; 5318AD9529BF438F00CBB71C /* NextcloudLocalFileMetadataTable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5318AD9429BF438F00CBB71C /* NextcloudLocalFileMetadataTable.swift */; }; @@ -155,7 +154,6 @@ /* Begin PBXFileReference section */ 5307A6F129675346001E0C6A /* NextcloudFilesDatabaseManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NextcloudFilesDatabaseManager.swift; sourceTree = ""; }; - 5315227F2B8DBBA2002E31BE /* ItemSharesController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ItemSharesController.swift; sourceTree = ""; }; 531522812B8E01C6002E31BE /* ShareTableItemView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ShareTableItemView.xib; sourceTree = ""; }; 5318AD9029BF42FB00CBB71C /* NextcloudItemMetadataTable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NextcloudItemMetadataTable.swift; sourceTree = ""; }; 5318AD9429BF438F00CBB71C /* NextcloudLocalFileMetadataTable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NextcloudLocalFileMetadataTable.swift; sourceTree = ""; }; @@ -264,14 +262,6 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ - 5315227E2B8DBB7E002E31BE /* Shares */ = { - isa = PBXGroup; - children = ( - 5315227F2B8DBBA2002E31BE /* ItemSharesController.swift */, - ); - path = Shares; - sourceTree = ""; - }; 5318AD8F29BF406500CBB71C /* Database */ = { isa = PBXGroup; children = ( @@ -328,7 +318,6 @@ 5318AD8F29BF406500CBB71C /* Database */, 5352E85929B7BFB4002CE85C /* Extensions */, 5350E4C72B0C368B00F276CB /* Services */, - 5315227E2B8DBB7E002E31BE /* Shares */, 53D666602B70C9A70042C03D /* FileProviderConfig.swift */, 538E397027F4765000FA63D5 /* FileProviderEnumerator.swift */, 53ED471F29C5E64200795DB1 /* FileProviderEnumerator+SyncEngine.swift */, @@ -712,7 +701,6 @@ 535AE30E29C0A2CC0042A9BA /* Logger+Extensions.swift in Sources */, 5307A6F229675346001E0C6A /* NextcloudFilesDatabaseManager.swift in Sources */, 537630952B860D560026BFAB /* FPUIExtensionServiceSource.swift in Sources */, - 531522802B8DBBA2002E31BE /* ItemSharesController.swift in Sources */, 53D056312970594F00988392 /* LocalFilesUtils.swift in Sources */, 538E396F27F4765000FA63D5 /* FileProviderItem.swift in Sources */, 5352B36829DC17D60011CE03 /* NextcloudFilesDatabaseManager+LocalFiles.swift in Sources */, From f35d73a6c6355906f53ab8b8388911eae12c8de8 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 28 Feb 2024 00:19:25 +0800 Subject: [PATCH 046/172] Remove default item view in ShareViewController table XIB Signed-off-by: Claudio Cambra --- .../ShareTableItemView.swift | 8 ++++++++ .../FileProviderUIExt/ShareViewController.xib | 20 ------------------- 2 files changed, 8 insertions(+), 20 deletions(-) create mode 100644 shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableItemView.swift diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableItemView.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableItemView.swift new file mode 100644 index 0000000000000..ee9807886115b --- /dev/null +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableItemView.swift @@ -0,0 +1,8 @@ +// +// ShareTableItemView.swift +// FileProviderUIExt +// +// Created by Claudio Cambra on 28/2/24. +// + +import Foundation diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib index 90aca5a253314..474c82fe86a84 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib @@ -118,26 +118,6 @@ - - - - - - - - - - - - - - - - - - - - From 27dd699e1365f175d32166b7947070ff80da801c Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 28 Feb 2024 00:19:37 +0800 Subject: [PATCH 047/172] Set delegate for shares table view Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/ShareTableViewDataSource.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift index 636e5a10d09b9..513f364ae12a8 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift @@ -18,6 +18,7 @@ class ShareTableViewDataSource: NSObject, NSTableViewDataSource, NSTableViewDele didSet { sharesTableView?.register(shareItemViewNib, forIdentifier: shareItemViewIdentifier) sharesTableView?.dataSource = self + sharesTableView?.delegate = self sharesTableView?.reloadData() } } From 0a3bf104673062e7c3c24eb6a0f43ff0fdd8c025 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 28 Feb 2024 00:20:05 +0800 Subject: [PATCH 048/172] Add corresponding class for ShareTableItemView Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/ShareTableItemView.swift | 9 ++++++++- .../FileProviderUIExt/ShareTableItemView.xib | 8 +++++++- .../NextcloudIntegration.xcodeproj/project.pbxproj | 4 ++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableItemView.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableItemView.swift index ee9807886115b..2588f5383055b 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableItemView.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableItemView.swift @@ -5,4 +5,11 @@ // Created by Claudio Cambra on 28/2/24. // -import Foundation +import AppKit + +class ShareTableItemView: NSTableCellView { + @IBOutlet weak var typeImageView: NSImageView! + @IBOutlet weak var label: NSTextField! + @IBOutlet weak var copyLinkButton: NSButton! + @IBOutlet weak var optionsButton: NSButton! +} diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableItemView.xib b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableItemView.xib index 7f3dafe090fef..7685eedb24673 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableItemView.xib +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableItemView.xib @@ -11,7 +11,7 @@ - + @@ -88,6 +88,12 @@ + + + + + + diff --git a/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj b/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj index 294d9d56f3695..e2723e67b0533 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj +++ b/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj @@ -55,6 +55,7 @@ 53FE14502B8E0658006C4193 /* ShareTableViewDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53FE144F2B8E0658006C4193 /* ShareTableViewDataSource.swift */; }; 53FE14542B8E1219006C4193 /* NextcloudKit in Frameworks */ = {isa = PBXBuildFile; productRef = 53FE14532B8E1219006C4193 /* NextcloudKit */; }; 53FE14552B8E28E9006C4193 /* NextcloudAccount.swift in Sources */ = {isa = PBXBuildFile; fileRef = 536EFC35295E3C1100F4CB13 /* NextcloudAccount.swift */; }; + 53FE14592B8E3F6C006C4193 /* ShareTableItemView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53FE14582B8E3F6C006C4193 /* ShareTableItemView.swift */; }; C2B573BA1B1CD91E00303B36 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = C2B573B91B1CD91E00303B36 /* main.m */; }; C2B573D21B1CD94B00303B36 /* main.m in Resources */ = {isa = PBXBuildFile; fileRef = C2B573B91B1CD91E00303B36 /* main.m */; }; C2B573DE1B1CD9CE00303B36 /* FinderSync.m in Sources */ = {isa = PBXBuildFile; fileRef = C2B573DD1B1CD9CE00303B36 /* FinderSync.m */; }; @@ -200,6 +201,7 @@ 53ED472F29C9CE0B00795DB1 /* FileProviderExtension+ClientInterface.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "FileProviderExtension+ClientInterface.swift"; sourceTree = ""; }; 53FE144F2B8E0658006C4193 /* ShareTableViewDataSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareTableViewDataSource.swift; sourceTree = ""; }; 53FE14572B8E3A7C006C4193 /* FileProviderUIExtRelease.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = FileProviderUIExtRelease.entitlements; sourceTree = ""; }; + 53FE14582B8E3F6C006C4193 /* ShareTableItemView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareTableItemView.swift; sourceTree = ""; }; C2B573B11B1CD91E00303B36 /* desktopclient.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = desktopclient.app; sourceTree = BUILT_PRODUCTS_DIR; }; C2B573B51B1CD91E00303B36 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; C2B573B91B1CD91E00303B36 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; @@ -352,6 +354,7 @@ children = ( 5376307B2B85E2E00026BFAB /* Extensions */, 53B979802B84C81F002DA742 /* DocumentActionViewController.swift */, + 53FE14582B8E3F6C006C4193 /* ShareTableItemView.swift */, 531522812B8E01C6002E31BE /* ShareTableItemView.xib */, 53FE144F2B8E0658006C4193 /* ShareTableViewDataSource.swift */, 537630922B85F4B00026BFAB /* ShareViewController.swift */, @@ -727,6 +730,7 @@ files = ( 537630932B85F4B00026BFAB /* ShareViewController.swift in Sources */, 53B979812B84C81F002DA742 /* DocumentActionViewController.swift in Sources */, + 53FE14592B8E3F6C006C4193 /* ShareTableItemView.swift in Sources */, 53FE14552B8E28E9006C4193 /* NextcloudAccount.swift in Sources */, 5376307D2B85E2ED0026BFAB /* Logger+Extensions.swift in Sources */, 53FE14502B8E0658006C4193 /* ShareTableViewDataSource.swift in Sources */, From 6878efe4006ac4090431f118fcf0aa5016d7a5e3 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 28 Feb 2024 00:20:43 +0800 Subject: [PATCH 049/172] Set basic property of sharetableitemview in delegate method of data source Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/ShareTableViewDataSource.swift | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift index 513f364ae12a8..52d8523da65b6 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift @@ -138,8 +138,14 @@ class ShareTableViewDataSource: NSObject, NSTableViewDataSource, NSTableViewDele @objc func tableView( _ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int ) -> NSView? { - //let share = shares[row] - let view = tableView.makeView(withIdentifier: shareItemViewIdentifier, owner: self) + let share = shares[row] + guard let view = tableView.makeView( + withIdentifier: shareItemViewIdentifier, owner: self + ) as? ShareTableItemView else { + Logger.sharesDataSource.error("Acquired item view from table is not a Share item view!") + return nil + } + view.label.stringValue = share.label return view } } From 972532f7e63899a3d1d648094f524aaeddaf9996 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 28 Feb 2024 00:21:01 +0800 Subject: [PATCH 050/172] Ensure usable rowHeight for shares table view Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/ShareTableViewDataSource.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift index 52d8523da65b6..8a5f53b13170b 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift @@ -17,6 +17,7 @@ class ShareTableViewDataSource: NSObject, NSTableViewDataSource, NSTableViewDele var sharesTableView: NSTableView? { didSet { sharesTableView?.register(shareItemViewNib, forIdentifier: shareItemViewIdentifier) + sharesTableView?.rowHeight = 42.0 // Height of view in ShareTableItemView XIB sharesTableView?.dataSource = self sharesTableView?.delegate = self sharesTableView?.reloadData() From 93aec4ba2392cf6f9060d8f51c6955ce10f52349 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 28 Feb 2024 14:54:57 +0800 Subject: [PATCH 051/172] Customise prepareForReuse in ShareTableItemView Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/ShareTableItemView.swift | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableItemView.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableItemView.swift index 2588f5383055b..b20527e2e2a58 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableItemView.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableItemView.swift @@ -12,4 +12,11 @@ class ShareTableItemView: NSTableCellView { @IBOutlet weak var label: NSTextField! @IBOutlet weak var copyLinkButton: NSButton! @IBOutlet weak var optionsButton: NSButton! + + override func prepareForReuse() { + typeImageView.image = nil + label.stringValue = "" + copyLinkButton.isHidden = false + super.prepareForReuse() + } } From 988069c7be33acceeb49e82bc746dd157658f442 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 28 Feb 2024 15:31:45 +0800 Subject: [PATCH 052/172] Add starter NKShare extension Signed-off-by: Claudio Cambra --- .../Extensions/NKShare+Extensions.swift | 11 +++++++++++ .../NextcloudIntegration.xcodeproj/project.pbxproj | 4 ++++ 2 files changed, 15 insertions(+) create mode 100644 shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Extensions/NKShare+Extensions.swift diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Extensions/NKShare+Extensions.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Extensions/NKShare+Extensions.swift new file mode 100644 index 0000000000000..ae0cb87cb51ab --- /dev/null +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Extensions/NKShare+Extensions.swift @@ -0,0 +1,11 @@ +// +// NKShare+Extensions.swift +// FileProviderUIExt +// +// Created by Claudio Cambra on 28/2/24. +// + +import NextcloudKit + +extension NKShare { +} diff --git a/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj b/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj index e2723e67b0533..9e0a448105ef0 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj +++ b/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj @@ -56,6 +56,7 @@ 53FE14542B8E1219006C4193 /* NextcloudKit in Frameworks */ = {isa = PBXBuildFile; productRef = 53FE14532B8E1219006C4193 /* NextcloudKit */; }; 53FE14552B8E28E9006C4193 /* NextcloudAccount.swift in Sources */ = {isa = PBXBuildFile; fileRef = 536EFC35295E3C1100F4CB13 /* NextcloudAccount.swift */; }; 53FE14592B8E3F6C006C4193 /* ShareTableItemView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53FE14582B8E3F6C006C4193 /* ShareTableItemView.swift */; }; + 53FE145B2B8F1305006C4193 /* NKShare+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53FE145A2B8F1305006C4193 /* NKShare+Extensions.swift */; }; C2B573BA1B1CD91E00303B36 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = C2B573B91B1CD91E00303B36 /* main.m */; }; C2B573D21B1CD94B00303B36 /* main.m in Resources */ = {isa = PBXBuildFile; fileRef = C2B573B91B1CD91E00303B36 /* main.m */; }; C2B573DE1B1CD9CE00303B36 /* FinderSync.m in Sources */ = {isa = PBXBuildFile; fileRef = C2B573DD1B1CD9CE00303B36 /* FinderSync.m */; }; @@ -202,6 +203,7 @@ 53FE144F2B8E0658006C4193 /* ShareTableViewDataSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareTableViewDataSource.swift; sourceTree = ""; }; 53FE14572B8E3A7C006C4193 /* FileProviderUIExtRelease.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = FileProviderUIExtRelease.entitlements; sourceTree = ""; }; 53FE14582B8E3F6C006C4193 /* ShareTableItemView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareTableItemView.swift; sourceTree = ""; }; + 53FE145A2B8F1305006C4193 /* NKShare+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NKShare+Extensions.swift"; sourceTree = ""; }; C2B573B11B1CD91E00303B36 /* desktopclient.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = desktopclient.app; sourceTree = BUILT_PRODUCTS_DIR; }; C2B573B51B1CD91E00303B36 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; C2B573B91B1CD91E00303B36 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; @@ -302,6 +304,7 @@ isa = PBXGroup; children = ( 5376307C2B85E2ED0026BFAB /* Logger+Extensions.swift */, + 53FE145A2B8F1305006C4193 /* NKShare+Extensions.swift */, ); path = Extensions; sourceTree = ""; @@ -730,6 +733,7 @@ files = ( 537630932B85F4B00026BFAB /* ShareViewController.swift in Sources */, 53B979812B84C81F002DA742 /* DocumentActionViewController.swift in Sources */, + 53FE145B2B8F1305006C4193 /* NKShare+Extensions.swift in Sources */, 53FE14592B8E3F6C006C4193 /* ShareTableItemView.swift in Sources */, 53FE14552B8E28E9006C4193 /* NextcloudAccount.swift in Sources */, 5376307D2B85E2ED0026BFAB /* Logger+Extensions.swift in Sources */, From 29d67ee434323ded190d857eaee0a4597344fbcc Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 28 Feb 2024 15:59:53 +0800 Subject: [PATCH 053/172] Add ShareType enum to NKShare extension Signed-off-by: Claudio Cambra --- .../Extensions/NKShare+Extensions.swift | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Extensions/NKShare+Extensions.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Extensions/NKShare+Extensions.swift index ae0cb87cb51ab..f1020fe98e609 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Extensions/NKShare+Extensions.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Extensions/NKShare+Extensions.swift @@ -8,4 +8,13 @@ import NextcloudKit extension NKShare { + enum ShareType: Int { + case user = 0 + case group = 1 + case publicLink = 3 + case email = 4 + case federatedCloud = 6 + case circle = 7 + case talkConversation = 10 + } } From eb125f9666d8de6a23198e197195bcfca346d8ee Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 28 Feb 2024 16:00:11 +0800 Subject: [PATCH 054/172] Add typeImage property to NKShare extension Signed-off-by: Claudio Cambra --- .../Extensions/NKShare+Extensions.swift | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Extensions/NKShare+Extensions.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Extensions/NKShare+Extensions.swift index f1020fe98e609..0ffeb7323aaaa 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Extensions/NKShare+Extensions.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Extensions/NKShare+Extensions.swift @@ -5,6 +5,7 @@ // Created by Claudio Cambra on 28/2/24. // +import AppKit import NextcloudKit extension NKShare { @@ -17,4 +18,55 @@ extension NKShare { case circle = 7 case talkConversation = 10 } + + var typeImage: NSImage? { + var image: NSImage? + switch shareType { + case ShareType.user.rawValue: + image = NSImage( + systemSymbolName: "person.circle.fill", + accessibilityDescription: "User share icon" + ) + case ShareType.group.rawValue: + image = NSImage( + systemSymbolName: "person.2.circle.fill", + accessibilityDescription: "Group share icon" + ) + case ShareType.publicLink.rawValue: + image = NSImage( + systemSymbolName: "link.circle.fill", + accessibilityDescription: "Public link share icon" + ) + case ShareType.email.rawValue: + image = NSImage( + systemSymbolName: "envelope.circle.fill", + accessibilityDescription: "Email share icon" + ) + case ShareType.federatedCloud.rawValue: + image = NSImage( + systemSymbolName: "cloud.circle.fill", + accessibilityDescription: "Federated cloud share icon" + ) + case ShareType.circle.rawValue: + image = NSImage( + systemSymbolName: "circle.circle.fill", + accessibilityDescription: "Circle share icon" + ) + case ShareType.talkConversation.rawValue: + image = NSImage( + systemSymbolName: "message.circle.fill", + accessibilityDescription: "Talk conversation share icon" + ) + default: + return nil + } + + var config = NSImage.SymbolConfiguration(textStyle: .body, scale: .large) + if #available(macOS 12.0, *) { + config = config.applying( + .init(paletteColors: [.controlBackgroundColor, .controlAccentColor]) + ) + } + return image?.withSymbolConfiguration(config) + } } From 225f48e5a9521d7070db200eedaa541f54758591 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 28 Feb 2024 16:00:28 +0800 Subject: [PATCH 055/172] Add displayString property to NKShare extension Signed-off-by: Claudio Cambra --- .../Extensions/NKShare+Extensions.swift | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Extensions/NKShare+Extensions.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Extensions/NKShare+Extensions.swift index 0ffeb7323aaaa..0db7d83b3cfe3 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Extensions/NKShare+Extensions.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Extensions/NKShare+Extensions.swift @@ -69,4 +69,29 @@ extension NKShare { } return image?.withSymbolConfiguration(config) } + + var displayString: String { + if label != "" { + return label + } + + switch shareType { + case ShareType.user.rawValue: + return "User share" + case ShareType.group.rawValue: + return "Group share" + case ShareType.publicLink.rawValue: + return "Public link share" + case ShareType.email.rawValue: + return "Email share" + case ShareType.federatedCloud.rawValue: + return "Federated cloud share" + case ShareType.circle.rawValue: + return "Circle share" + case ShareType.talkConversation.rawValue: + return "Talk conversation share" + default: + return "Unknown share" + } + } } From 14ba5f589b61ff28303f77f8fec1c0dc3dadeee6 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 28 Feb 2024 16:01:01 +0800 Subject: [PATCH 056/172] Make share property central to display update of share table item view Signed-off-by: Claudio Cambra --- .../ShareTableItemView.swift | 21 +++++++++++++++---- .../ShareTableViewDataSource.swift | 2 +- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableItemView.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableItemView.swift index b20527e2e2a58..fe68e91a733b7 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableItemView.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableItemView.swift @@ -6,12 +6,25 @@ // import AppKit +import NextcloudKit class ShareTableItemView: NSTableCellView { - @IBOutlet weak var typeImageView: NSImageView! - @IBOutlet weak var label: NSTextField! - @IBOutlet weak var copyLinkButton: NSButton! - @IBOutlet weak var optionsButton: NSButton! + @IBOutlet private weak var typeImageView: NSImageView! + @IBOutlet private weak var label: NSTextField! + @IBOutlet private weak var copyLinkButton: NSButton! + @IBOutlet private weak var optionsButton: NSButton! + + var share: NKShare? { + didSet { + guard let share = share else { + prepareForReuse() + return + } + typeImageView.image = share.typeImage + label.stringValue = share.displayString + copyLinkButton.isHidden = share.shareType != NKShare.ShareType.publicLink.rawValue + } + } override func prepareForReuse() { typeImageView.image = nil diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift index 8a5f53b13170b..f86829876e01a 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift @@ -146,7 +146,7 @@ class ShareTableViewDataSource: NSObject, NSTableViewDataSource, NSTableViewDele Logger.sharesDataSource.error("Acquired item view from table is not a Share item view!") return nil } - view.label.stringValue = share.label + view.share = share return view } } From 14733a364ff18aa2e864318e32391fee38d12b0a Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 28 Feb 2024 16:03:15 +0800 Subject: [PATCH 057/172] Improve share table style Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/ShareViewController.xib | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib index 474c82fe86a84..7e9f7c5ed9424 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib @@ -100,14 +100,14 @@ - + - + @@ -125,7 +125,7 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From e34eb7f5e6608134032ab205e5621ab6ea22dbe7 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 28 Feb 2024 19:39:01 +0800 Subject: [PATCH 063/172] Replace ShareOptionsView with a ShareOptionsWindow Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/ShareOptionsView.xib | 191 ----------------- .../FileProviderUIExt/ShareOptionsWindow.xib | 199 ++++++++++++++++++ .../project.pbxproj | 8 +- 3 files changed, 203 insertions(+), 195 deletions(-) delete mode 100644 shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.xib create mode 100644 shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsWindow.xib diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.xib b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.xib deleted file mode 100644 index c339b31cfa246..0000000000000 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.xib +++ /dev/null @@ -1,191 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - NSAllRomanInputSourcesLocaleIdentifier - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsWindow.xib b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsWindow.xib new file mode 100644 index 0000000000000..466a6dc020530 --- /dev/null +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsWindow.xib @@ -0,0 +1,199 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + NSAllRomanInputSourcesLocaleIdentifier + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj b/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj index 0588c02df829d..06df406ee6fed 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj +++ b/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj @@ -57,7 +57,7 @@ 53FE14552B8E28E9006C4193 /* NextcloudAccount.swift in Sources */ = {isa = PBXBuildFile; fileRef = 536EFC35295E3C1100F4CB13 /* NextcloudAccount.swift */; }; 53FE14592B8E3F6C006C4193 /* ShareTableItemView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53FE14582B8E3F6C006C4193 /* ShareTableItemView.swift */; }; 53FE145B2B8F1305006C4193 /* NKShare+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53FE145A2B8F1305006C4193 /* NKShare+Extensions.swift */; }; - 53FE145D2B8F2AFE006C4193 /* ShareOptionsView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 53FE145C2B8F2AFE006C4193 /* ShareOptionsView.xib */; }; + 53FE145F2B8F3771006C4193 /* ShareOptionsWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 53FE145E2B8F3771006C4193 /* ShareOptionsWindow.xib */; }; C2B573BA1B1CD91E00303B36 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = C2B573B91B1CD91E00303B36 /* main.m */; }; C2B573D21B1CD94B00303B36 /* main.m in Resources */ = {isa = PBXBuildFile; fileRef = C2B573B91B1CD91E00303B36 /* main.m */; }; C2B573DE1B1CD9CE00303B36 /* FinderSync.m in Sources */ = {isa = PBXBuildFile; fileRef = C2B573DD1B1CD9CE00303B36 /* FinderSync.m */; }; @@ -205,7 +205,7 @@ 53FE14572B8E3A7C006C4193 /* FileProviderUIExtRelease.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = FileProviderUIExtRelease.entitlements; sourceTree = ""; }; 53FE14582B8E3F6C006C4193 /* ShareTableItemView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareTableItemView.swift; sourceTree = ""; }; 53FE145A2B8F1305006C4193 /* NKShare+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NKShare+Extensions.swift"; sourceTree = ""; }; - 53FE145C2B8F2AFE006C4193 /* ShareOptionsView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ShareOptionsView.xib; sourceTree = ""; }; + 53FE145E2B8F3771006C4193 /* ShareOptionsWindow.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ShareOptionsWindow.xib; sourceTree = ""; }; C2B573B11B1CD91E00303B36 /* desktopclient.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = desktopclient.app; sourceTree = BUILT_PRODUCTS_DIR; }; C2B573B51B1CD91E00303B36 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; C2B573B91B1CD91E00303B36 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; @@ -359,7 +359,7 @@ children = ( 5376307B2B85E2E00026BFAB /* Extensions */, 53B979802B84C81F002DA742 /* DocumentActionViewController.swift */, - 53FE145C2B8F2AFE006C4193 /* ShareOptionsView.xib */, + 53FE145E2B8F3771006C4193 /* ShareOptionsWindow.xib */, 53FE14582B8E3F6C006C4193 /* ShareTableItemView.swift */, 531522812B8E01C6002E31BE /* ShareTableItemView.xib */, 53FE144F2B8E0658006C4193 /* ShareTableViewDataSource.swift */, @@ -647,8 +647,8 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - 53FE145D2B8F2AFE006C4193 /* ShareOptionsView.xib in Resources */, 531522822B8E01C6002E31BE /* ShareTableItemView.xib in Resources */, + 53FE145F2B8F3771006C4193 /* ShareOptionsWindow.xib in Resources */, 537630912B85F4980026BFAB /* ShareViewController.xib in Resources */, ); runOnlyForDeploymentPostprocessing = 0; From ba1f6278cf599ba30e2956c976845ef285940be5 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 28 Feb 2024 20:17:23 +0800 Subject: [PATCH 064/172] Add starter ShareOptionsWindow class Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/ShareOptionsWindow.swift | 12 ++++++++++++ .../NextcloudIntegration.xcodeproj/project.pbxproj | 4 ++++ 2 files changed, 16 insertions(+) create mode 100644 shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsWindow.swift diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsWindow.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsWindow.swift new file mode 100644 index 0000000000000..1b07a1f7dbbc1 --- /dev/null +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsWindow.swift @@ -0,0 +1,12 @@ +// +// ShareOptionsWindow.swift +// FileProviderUIExt +// +// Created by Claudio Cambra on 28/2/24. +// + +import AppKit + +class ShareOptionsWindow: NSPanel { + +} diff --git a/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj b/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj index 06df406ee6fed..692fb16733fdc 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj +++ b/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj @@ -58,6 +58,7 @@ 53FE14592B8E3F6C006C4193 /* ShareTableItemView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53FE14582B8E3F6C006C4193 /* ShareTableItemView.swift */; }; 53FE145B2B8F1305006C4193 /* NKShare+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53FE145A2B8F1305006C4193 /* NKShare+Extensions.swift */; }; 53FE145F2B8F3771006C4193 /* ShareOptionsWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 53FE145E2B8F3771006C4193 /* ShareOptionsWindow.xib */; }; + 53FE14612B8F5279006C4193 /* ShareOptionsWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53FE14602B8F5279006C4193 /* ShareOptionsWindow.swift */; }; C2B573BA1B1CD91E00303B36 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = C2B573B91B1CD91E00303B36 /* main.m */; }; C2B573D21B1CD94B00303B36 /* main.m in Resources */ = {isa = PBXBuildFile; fileRef = C2B573B91B1CD91E00303B36 /* main.m */; }; C2B573DE1B1CD9CE00303B36 /* FinderSync.m in Sources */ = {isa = PBXBuildFile; fileRef = C2B573DD1B1CD9CE00303B36 /* FinderSync.m */; }; @@ -206,6 +207,7 @@ 53FE14582B8E3F6C006C4193 /* ShareTableItemView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareTableItemView.swift; sourceTree = ""; }; 53FE145A2B8F1305006C4193 /* NKShare+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NKShare+Extensions.swift"; sourceTree = ""; }; 53FE145E2B8F3771006C4193 /* ShareOptionsWindow.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ShareOptionsWindow.xib; sourceTree = ""; }; + 53FE14602B8F5279006C4193 /* ShareOptionsWindow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareOptionsWindow.swift; sourceTree = ""; }; C2B573B11B1CD91E00303B36 /* desktopclient.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = desktopclient.app; sourceTree = BUILT_PRODUCTS_DIR; }; C2B573B51B1CD91E00303B36 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; C2B573B91B1CD91E00303B36 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; @@ -360,6 +362,7 @@ 5376307B2B85E2E00026BFAB /* Extensions */, 53B979802B84C81F002DA742 /* DocumentActionViewController.swift */, 53FE145E2B8F3771006C4193 /* ShareOptionsWindow.xib */, + 53FE14602B8F5279006C4193 /* ShareOptionsWindow.swift */, 53FE14582B8E3F6C006C4193 /* ShareTableItemView.swift */, 531522812B8E01C6002E31BE /* ShareTableItemView.xib */, 53FE144F2B8E0658006C4193 /* ShareTableViewDataSource.swift */, @@ -736,6 +739,7 @@ buildActionMask = 2147483647; files = ( 537630932B85F4B00026BFAB /* ShareViewController.swift in Sources */, + 53FE14612B8F5279006C4193 /* ShareOptionsWindow.swift in Sources */, 53B979812B84C81F002DA742 /* DocumentActionViewController.swift in Sources */, 53FE145B2B8F1305006C4193 /* NKShare+Extensions.swift in Sources */, 53FE14592B8E3F6C006C4193 /* ShareTableItemView.swift in Sources */, From f26ed4c49950d0233479f00a16ee9b15bfc79f17 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 28 Feb 2024 20:50:09 +0800 Subject: [PATCH 065/172] Redesign shares to incorporate share options into main share view Signed-off-by: Claudio Cambra --- .../ShareOptionsWindow.swift | 12 - .../FileProviderUIExt/ShareOptionsWindow.xib | 199 --------- .../FileProviderUIExt/ShareTableItemView.xib | 28 +- .../FileProviderUIExt/ShareViewController.xib | 410 +++++++++++++----- .../project.pbxproj | 8 - 5 files changed, 305 insertions(+), 352 deletions(-) delete mode 100644 shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsWindow.swift delete mode 100644 shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsWindow.xib diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsWindow.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsWindow.swift deleted file mode 100644 index 1b07a1f7dbbc1..0000000000000 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsWindow.swift +++ /dev/null @@ -1,12 +0,0 @@ -// -// ShareOptionsWindow.swift -// FileProviderUIExt -// -// Created by Claudio Cambra on 28/2/24. -// - -import AppKit - -class ShareOptionsWindow: NSPanel { - -} diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsWindow.xib b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsWindow.xib deleted file mode 100644 index 466a6dc020530..0000000000000 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsWindow.xib +++ /dev/null @@ -1,199 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - NSAllRomanInputSourcesLocaleIdentifier - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableItemView.xib b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableItemView.xib index fcf7ef726625a..026f2acf210ef 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableItemView.xib +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableItemView.xib @@ -30,7 +30,7 @@ - + @@ -38,7 +38,7 @@ - - - @@ -75,13 +63,11 @@ - - @@ -94,23 +80,13 @@ - - - - - - - - - - diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib index 7e9f7c5ed9424..4a601d82de602 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib @@ -19,145 +19,341 @@ - - - + + - - + + - - + + - - - - - - - - - + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + NSAllRomanInputSourcesLocaleIdentifier + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - + + + - - - - - - - - - + + + + + - - - - + + + + + + + - + diff --git a/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj b/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj index 692fb16733fdc..9e0a448105ef0 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj +++ b/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj @@ -57,8 +57,6 @@ 53FE14552B8E28E9006C4193 /* NextcloudAccount.swift in Sources */ = {isa = PBXBuildFile; fileRef = 536EFC35295E3C1100F4CB13 /* NextcloudAccount.swift */; }; 53FE14592B8E3F6C006C4193 /* ShareTableItemView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53FE14582B8E3F6C006C4193 /* ShareTableItemView.swift */; }; 53FE145B2B8F1305006C4193 /* NKShare+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53FE145A2B8F1305006C4193 /* NKShare+Extensions.swift */; }; - 53FE145F2B8F3771006C4193 /* ShareOptionsWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 53FE145E2B8F3771006C4193 /* ShareOptionsWindow.xib */; }; - 53FE14612B8F5279006C4193 /* ShareOptionsWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53FE14602B8F5279006C4193 /* ShareOptionsWindow.swift */; }; C2B573BA1B1CD91E00303B36 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = C2B573B91B1CD91E00303B36 /* main.m */; }; C2B573D21B1CD94B00303B36 /* main.m in Resources */ = {isa = PBXBuildFile; fileRef = C2B573B91B1CD91E00303B36 /* main.m */; }; C2B573DE1B1CD9CE00303B36 /* FinderSync.m in Sources */ = {isa = PBXBuildFile; fileRef = C2B573DD1B1CD9CE00303B36 /* FinderSync.m */; }; @@ -206,8 +204,6 @@ 53FE14572B8E3A7C006C4193 /* FileProviderUIExtRelease.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = FileProviderUIExtRelease.entitlements; sourceTree = ""; }; 53FE14582B8E3F6C006C4193 /* ShareTableItemView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareTableItemView.swift; sourceTree = ""; }; 53FE145A2B8F1305006C4193 /* NKShare+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NKShare+Extensions.swift"; sourceTree = ""; }; - 53FE145E2B8F3771006C4193 /* ShareOptionsWindow.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ShareOptionsWindow.xib; sourceTree = ""; }; - 53FE14602B8F5279006C4193 /* ShareOptionsWindow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareOptionsWindow.swift; sourceTree = ""; }; C2B573B11B1CD91E00303B36 /* desktopclient.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = desktopclient.app; sourceTree = BUILT_PRODUCTS_DIR; }; C2B573B51B1CD91E00303B36 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; C2B573B91B1CD91E00303B36 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; @@ -361,8 +357,6 @@ children = ( 5376307B2B85E2E00026BFAB /* Extensions */, 53B979802B84C81F002DA742 /* DocumentActionViewController.swift */, - 53FE145E2B8F3771006C4193 /* ShareOptionsWindow.xib */, - 53FE14602B8F5279006C4193 /* ShareOptionsWindow.swift */, 53FE14582B8E3F6C006C4193 /* ShareTableItemView.swift */, 531522812B8E01C6002E31BE /* ShareTableItemView.xib */, 53FE144F2B8E0658006C4193 /* ShareTableViewDataSource.swift */, @@ -651,7 +645,6 @@ buildActionMask = 2147483647; files = ( 531522822B8E01C6002E31BE /* ShareTableItemView.xib in Resources */, - 53FE145F2B8F3771006C4193 /* ShareOptionsWindow.xib in Resources */, 537630912B85F4980026BFAB /* ShareViewController.xib in Resources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -739,7 +732,6 @@ buildActionMask = 2147483647; files = ( 537630932B85F4B00026BFAB /* ShareViewController.swift in Sources */, - 53FE14612B8F5279006C4193 /* ShareOptionsWindow.swift in Sources */, 53B979812B84C81F002DA742 /* DocumentActionViewController.swift in Sources */, 53FE145B2B8F1305006C4193 /* NKShare+Extensions.swift in Sources */, 53FE14592B8E3F6C006C4193 /* ShareTableItemView.swift in Sources */, From bd996a87706e2f538525172e524e8f288b864f32 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 28 Feb 2024 21:15:11 +0800 Subject: [PATCH 066/172] Extract options view to different XIB Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/ShareOptionsView.xib | 192 ++++++++++++++++++ .../FileProviderUIExt/ShareViewController.xib | 175 ---------------- .../project.pbxproj | 4 + 3 files changed, 196 insertions(+), 175 deletions(-) create mode 100644 shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.xib diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.xib b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.xib new file mode 100644 index 0000000000000..a3bb747a9477c --- /dev/null +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.xib @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + NSAllRomanInputSourcesLocaleIdentifier + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib index 4a601d82de602..71d90ac519c41 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib @@ -156,181 +156,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - NSAllRomanInputSourcesLocaleIdentifier - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj b/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj index 9e0a448105ef0..f53c959eae239 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj +++ b/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj @@ -57,6 +57,7 @@ 53FE14552B8E28E9006C4193 /* NextcloudAccount.swift in Sources */ = {isa = PBXBuildFile; fileRef = 536EFC35295E3C1100F4CB13 /* NextcloudAccount.swift */; }; 53FE14592B8E3F6C006C4193 /* ShareTableItemView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53FE14582B8E3F6C006C4193 /* ShareTableItemView.swift */; }; 53FE145B2B8F1305006C4193 /* NKShare+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53FE145A2B8F1305006C4193 /* NKShare+Extensions.swift */; }; + 53FE14632B8F6502006C4193 /* ShareOptionsView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 53FE14622B8F6502006C4193 /* ShareOptionsView.xib */; }; C2B573BA1B1CD91E00303B36 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = C2B573B91B1CD91E00303B36 /* main.m */; }; C2B573D21B1CD94B00303B36 /* main.m in Resources */ = {isa = PBXBuildFile; fileRef = C2B573B91B1CD91E00303B36 /* main.m */; }; C2B573DE1B1CD9CE00303B36 /* FinderSync.m in Sources */ = {isa = PBXBuildFile; fileRef = C2B573DD1B1CD9CE00303B36 /* FinderSync.m */; }; @@ -204,6 +205,7 @@ 53FE14572B8E3A7C006C4193 /* FileProviderUIExtRelease.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = FileProviderUIExtRelease.entitlements; sourceTree = ""; }; 53FE14582B8E3F6C006C4193 /* ShareTableItemView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareTableItemView.swift; sourceTree = ""; }; 53FE145A2B8F1305006C4193 /* NKShare+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NKShare+Extensions.swift"; sourceTree = ""; }; + 53FE14622B8F6502006C4193 /* ShareOptionsView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ShareOptionsView.xib; sourceTree = ""; }; C2B573B11B1CD91E00303B36 /* desktopclient.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = desktopclient.app; sourceTree = BUILT_PRODUCTS_DIR; }; C2B573B51B1CD91E00303B36 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; C2B573B91B1CD91E00303B36 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; @@ -362,6 +364,7 @@ 53FE144F2B8E0658006C4193 /* ShareTableViewDataSource.swift */, 537630922B85F4B00026BFAB /* ShareViewController.swift */, 537630902B85F4980026BFAB /* ShareViewController.xib */, + 53FE14622B8F6502006C4193 /* ShareOptionsView.xib */, 5376307E2B85E5650026BFAB /* FileProviderUIExt.entitlements */, 53FE14572B8E3A7C006C4193 /* FileProviderUIExtRelease.entitlements */, 53B979852B84C81F002DA742 /* Info.plist */, @@ -644,6 +647,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 53FE14632B8F6502006C4193 /* ShareOptionsView.xib in Resources */, 531522822B8E01C6002E31BE /* ShareTableItemView.xib in Resources */, 537630912B85F4980026BFAB /* ShareViewController.xib in Resources */, ); From 81e4630607f2603136665b133232b1e88e5f87c8 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 28 Feb 2024 21:15:31 +0800 Subject: [PATCH 067/172] Add a shareview ui delegate protocol for datasources Signed-off-by: Claudio Cambra --- .../ShareViewDataSourceUIDelegate.swift | 14 ++++++++++++++ .../NextcloudIntegration.xcodeproj/project.pbxproj | 4 ++++ 2 files changed, 18 insertions(+) create mode 100644 shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewDataSourceUIDelegate.swift diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewDataSourceUIDelegate.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewDataSourceUIDelegate.swift new file mode 100644 index 0000000000000..29ea26f54b9e3 --- /dev/null +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewDataSourceUIDelegate.swift @@ -0,0 +1,14 @@ +// +// ShareViewDataSourceUIDelegate.swift +// FileProviderUIExt +// +// Created by Claudio Cambra on 28/2/24. +// + +import Foundation +import NextcloudKit + +protocol ShareViewDataSourceUIDelegate { + func hideOptions() + func showOptions(share: NKShare) +} diff --git a/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj b/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj index f53c959eae239..a780a39ffb344 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj +++ b/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj @@ -58,6 +58,7 @@ 53FE14592B8E3F6C006C4193 /* ShareTableItemView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53FE14582B8E3F6C006C4193 /* ShareTableItemView.swift */; }; 53FE145B2B8F1305006C4193 /* NKShare+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53FE145A2B8F1305006C4193 /* NKShare+Extensions.swift */; }; 53FE14632B8F6502006C4193 /* ShareOptionsView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 53FE14622B8F6502006C4193 /* ShareOptionsView.xib */; }; + 53FE14652B8F6700006C4193 /* ShareViewDataSourceUIDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53FE14642B8F6700006C4193 /* ShareViewDataSourceUIDelegate.swift */; }; C2B573BA1B1CD91E00303B36 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = C2B573B91B1CD91E00303B36 /* main.m */; }; C2B573D21B1CD94B00303B36 /* main.m in Resources */ = {isa = PBXBuildFile; fileRef = C2B573B91B1CD91E00303B36 /* main.m */; }; C2B573DE1B1CD9CE00303B36 /* FinderSync.m in Sources */ = {isa = PBXBuildFile; fileRef = C2B573DD1B1CD9CE00303B36 /* FinderSync.m */; }; @@ -206,6 +207,7 @@ 53FE14582B8E3F6C006C4193 /* ShareTableItemView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareTableItemView.swift; sourceTree = ""; }; 53FE145A2B8F1305006C4193 /* NKShare+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NKShare+Extensions.swift"; sourceTree = ""; }; 53FE14622B8F6502006C4193 /* ShareOptionsView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ShareOptionsView.xib; sourceTree = ""; }; + 53FE14642B8F6700006C4193 /* ShareViewDataSourceUIDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareViewDataSourceUIDelegate.swift; sourceTree = ""; }; C2B573B11B1CD91E00303B36 /* desktopclient.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = desktopclient.app; sourceTree = BUILT_PRODUCTS_DIR; }; C2B573B51B1CD91E00303B36 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; C2B573B91B1CD91E00303B36 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; @@ -365,6 +367,7 @@ 537630922B85F4B00026BFAB /* ShareViewController.swift */, 537630902B85F4980026BFAB /* ShareViewController.xib */, 53FE14622B8F6502006C4193 /* ShareOptionsView.xib */, + 53FE14642B8F6700006C4193 /* ShareViewDataSourceUIDelegate.swift */, 5376307E2B85E5650026BFAB /* FileProviderUIExt.entitlements */, 53FE14572B8E3A7C006C4193 /* FileProviderUIExtRelease.entitlements */, 53B979852B84C81F002DA742 /* Info.plist */, @@ -736,6 +739,7 @@ buildActionMask = 2147483647; files = ( 537630932B85F4B00026BFAB /* ShareViewController.swift in Sources */, + 53FE14652B8F6700006C4193 /* ShareViewDataSourceUIDelegate.swift in Sources */, 53B979812B84C81F002DA742 /* DocumentActionViewController.swift in Sources */, 53FE145B2B8F1305006C4193 /* NKShare+Extensions.swift in Sources */, 53FE14592B8E3F6C006C4193 /* ShareTableItemView.swift in Sources */, From 1cebc14419a13dfbd7e81d7cdd0aedc654743b7c Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 28 Feb 2024 21:15:53 +0800 Subject: [PATCH 068/172] Treat bottom view in share view as a target view to inject other views Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/ShareViewController.swift | 1 + .../FileProviderUIExt/ShareViewController.xib | 1 + 2 files changed, 2 insertions(+) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift index 45dd36cbf8f64..8f8d72e5c7aec 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift @@ -19,6 +19,7 @@ class ShareViewController: NSViewController { @IBOutlet weak var descriptionLabel: NSTextField! @IBOutlet weak var closeButton: NSButton! @IBOutlet weak var tableView: NSTableView! + @IBOutlet weak var optionsTargetView: NSView! public override var nibName: NSNib.Name? { return NSNib.Name(self.className) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib index 71d90ac519c41..3b159c7ff4b67 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib @@ -13,6 +13,7 @@ + From 9039145fd74dfe2bb9d3a77447883010b8bd81f8 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 28 Feb 2024 21:16:34 +0800 Subject: [PATCH 069/172] Implement ui delegate in ShareTableViewDataSource Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/ShareTableViewDataSource.swift | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift index f86829876e01a..d19a8d0ae419b 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift @@ -14,6 +14,7 @@ class ShareTableViewDataSource: NSObject, NSTableViewDataSource, NSTableViewDele private let shareItemViewIdentifier = NSUserInterfaceItemIdentifier("ShareTableItemView") private let shareItemViewNib = NSNib(nibNamed: "ShareTableItemView", bundle: nil) + var uiDelegate: ShareViewDataSourceUIDelegate? var sharesTableView: NSTableView? { didSet { sharesTableView?.register(shareItemViewNib, forIdentifier: shareItemViewIdentifier) @@ -23,6 +24,7 @@ class ShareTableViewDataSource: NSObject, NSTableViewDataSource, NSTableViewDele sharesTableView?.reloadData() } } + private var kit: NextcloudKit? private var itemURL: URL? private var shares: [NKShare] = [] { @@ -149,4 +151,13 @@ class ShareTableViewDataSource: NSObject, NSTableViewDataSource, NSTableViewDele view.share = share return view } + + @objc func tableViewSelectionDidChange(_ notification: Notification) { + guard let selectedRow = sharesTableView?.selectedRow, selectedRow >= 0 else { + uiDelegate?.hideOptions() + return + } + let share = shares[selectedRow] + uiDelegate?.showOptions(share: share) + } } From 22f02c82226c697b34f23c7beb8565a3eb82ab6b Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 28 Feb 2024 21:28:07 +0800 Subject: [PATCH 070/172] Re-integrate share options view into main share view controller XIB Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/ShareOptionsView.xib | 192 ------------------ .../ShareViewController.swift | 2 +- .../FileProviderUIExt/ShareViewController.xib | 177 +++++++++++++++- .../project.pbxproj | 4 - 4 files changed, 177 insertions(+), 198 deletions(-) delete mode 100644 shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.xib diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.xib b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.xib deleted file mode 100644 index a3bb747a9477c..0000000000000 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.xib +++ /dev/null @@ -1,192 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - NSAllRomanInputSourcesLocaleIdentifier - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift index 8f8d72e5c7aec..29526e21e815c 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift @@ -19,7 +19,7 @@ class ShareViewController: NSViewController { @IBOutlet weak var descriptionLabel: NSTextField! @IBOutlet weak var closeButton: NSButton! @IBOutlet weak var tableView: NSTableView! - @IBOutlet weak var optionsTargetView: NSView! + @IBOutlet weak var optionsView: NSView! public override var nibName: NSNib.Name? { return NSNib.Name(self.className) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib index 3b159c7ff4b67..94ca48770f8e9 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib @@ -13,7 +13,7 @@ - + @@ -157,6 +157,181 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + NSAllRomanInputSourcesLocaleIdentifier + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj b/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj index a780a39ffb344..0e4e2802c28db 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj +++ b/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj @@ -57,7 +57,6 @@ 53FE14552B8E28E9006C4193 /* NextcloudAccount.swift in Sources */ = {isa = PBXBuildFile; fileRef = 536EFC35295E3C1100F4CB13 /* NextcloudAccount.swift */; }; 53FE14592B8E3F6C006C4193 /* ShareTableItemView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53FE14582B8E3F6C006C4193 /* ShareTableItemView.swift */; }; 53FE145B2B8F1305006C4193 /* NKShare+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53FE145A2B8F1305006C4193 /* NKShare+Extensions.swift */; }; - 53FE14632B8F6502006C4193 /* ShareOptionsView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 53FE14622B8F6502006C4193 /* ShareOptionsView.xib */; }; 53FE14652B8F6700006C4193 /* ShareViewDataSourceUIDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53FE14642B8F6700006C4193 /* ShareViewDataSourceUIDelegate.swift */; }; C2B573BA1B1CD91E00303B36 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = C2B573B91B1CD91E00303B36 /* main.m */; }; C2B573D21B1CD94B00303B36 /* main.m in Resources */ = {isa = PBXBuildFile; fileRef = C2B573B91B1CD91E00303B36 /* main.m */; }; @@ -206,7 +205,6 @@ 53FE14572B8E3A7C006C4193 /* FileProviderUIExtRelease.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = FileProviderUIExtRelease.entitlements; sourceTree = ""; }; 53FE14582B8E3F6C006C4193 /* ShareTableItemView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareTableItemView.swift; sourceTree = ""; }; 53FE145A2B8F1305006C4193 /* NKShare+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NKShare+Extensions.swift"; sourceTree = ""; }; - 53FE14622B8F6502006C4193 /* ShareOptionsView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ShareOptionsView.xib; sourceTree = ""; }; 53FE14642B8F6700006C4193 /* ShareViewDataSourceUIDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareViewDataSourceUIDelegate.swift; sourceTree = ""; }; C2B573B11B1CD91E00303B36 /* desktopclient.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = desktopclient.app; sourceTree = BUILT_PRODUCTS_DIR; }; C2B573B51B1CD91E00303B36 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; @@ -366,7 +364,6 @@ 53FE144F2B8E0658006C4193 /* ShareTableViewDataSource.swift */, 537630922B85F4B00026BFAB /* ShareViewController.swift */, 537630902B85F4980026BFAB /* ShareViewController.xib */, - 53FE14622B8F6502006C4193 /* ShareOptionsView.xib */, 53FE14642B8F6700006C4193 /* ShareViewDataSourceUIDelegate.swift */, 5376307E2B85E5650026BFAB /* FileProviderUIExt.entitlements */, 53FE14572B8E3A7C006C4193 /* FileProviderUIExtRelease.entitlements */, @@ -650,7 +647,6 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - 53FE14632B8F6502006C4193 /* ShareOptionsView.xib in Resources */, 531522822B8E01C6002E31BE /* ShareTableItemView.xib in Resources */, 537630912B85F4980026BFAB /* ShareViewController.xib in Resources */, ); From 48bd2bb9a641789d0e4ae6b6d5022124df11993a Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 28 Feb 2024 21:36:19 +0800 Subject: [PATCH 071/172] Implement hide and show of share options in share view controller Signed-off-by: Claudio Cambra --- .../ShareViewController.swift | 19 ++++++++++++++++++- .../FileProviderUIExt/ShareViewController.xib | 1 + 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift index 29526e21e815c..2a292c07ee42d 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift @@ -7,10 +7,11 @@ import AppKit import FileProvider +import NextcloudKit import OSLog import QuickLookThumbnailing -class ShareViewController: NSViewController { +class ShareViewController: NSViewController, ShareViewDataSourceUIDelegate { let shareDataSource = ShareTableViewDataSource() let itemIdentifiers: [NSFileProviderItemIdentifier] @@ -20,6 +21,7 @@ class ShareViewController: NSViewController { @IBOutlet weak var closeButton: NSButton! @IBOutlet weak var tableView: NSTableView! @IBOutlet weak var optionsView: NSView! + @IBOutlet weak var splitView: NSSplitView! public override var nibName: NSNib.Name? { return NSNib.Name(self.className) @@ -48,6 +50,10 @@ class ShareViewController: NSViewController { fatalError("init(coder:) has not been implemented") } + override func viewDidLoad() { + hideOptions() + } + @IBAction func closeAction(_ sender: Any) { actionViewController.extensionContext.completeRequest() } @@ -60,6 +66,7 @@ class ShareViewController: NSViewController { do { let itemUrl = try await manager.getUserVisibleURL(for: itemIdentifier) await updateDisplay(itemUrl: itemUrl) + shareDataSource.uiDelegate = self shareDataSource.sharesTableView = tableView shareDataSource.loadItem(url: itemUrl) } catch let error { @@ -91,4 +98,14 @@ class ShareViewController: NSViewController { } fileNameIcon.image = fileThumbnail?.nsImage } + + func hideOptions() { + splitView.removeArrangedSubview(optionsView) + optionsView.isHidden = true + } + + func showOptions(share: NKShare) { + splitView.addArrangedSubview(optionsView) + optionsView.isHidden = false + } } diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib index 94ca48770f8e9..f1d5801aab275 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib @@ -14,6 +14,7 @@ + From b604c09338616158fe2bf9c4c56a399ab2af0f87 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 28 Feb 2024 21:56:26 +0800 Subject: [PATCH 072/172] Add a loading overlay to table view to indicate fetch in progress Signed-off-by: Claudio Cambra --- .../ShareViewController.swift | 2 ++ .../FileProviderUIExt/ShareViewController.xib | 23 +++++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift index 2a292c07ee42d..7bc8ffa452070 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift @@ -22,6 +22,8 @@ class ShareViewController: NSViewController, ShareViewDataSourceUIDelegate { @IBOutlet weak var tableView: NSTableView! @IBOutlet weak var optionsView: NSView! @IBOutlet weak var splitView: NSSplitView! + @IBOutlet weak var loadingEffectView: NSVisualEffectView! + @IBOutlet weak var loadingIndicator: NSProgressIndicator! public override var nibName: NSNib.Name? { return NSNib.Name(self.className) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib index f1d5801aab275..27ffb97d4c1c0 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib @@ -13,6 +13,8 @@ + + @@ -160,7 +162,7 @@ - + @@ -345,17 +347,34 @@ Gw + + + + + + + + + + + + + + + + + - + From e1e42004db08f4daaa28cb56126994f98f654dfd Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 28 Feb 2024 21:56:47 +0800 Subject: [PATCH 073/172] Add fetch related handling functions to ui delegate Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/ShareViewController.swift | 10 ++++++++++ .../ShareViewDataSourceUIDelegate.swift | 2 ++ 2 files changed, 12 insertions(+) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift index 7bc8ffa452070..d4e408d717083 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift @@ -101,6 +101,16 @@ class ShareViewController: NSViewController, ShareViewDataSourceUIDelegate { fileNameIcon.image = fileThumbnail?.nsImage } + func fetchStarted() { + loadingEffectView.isHidden = false + loadingIndicator.startAnimation(self) + } + + func fetchFinished() { + loadingEffectView.isHidden = true + loadingIndicator.stopAnimation(self) + } + func hideOptions() { splitView.removeArrangedSubview(optionsView) optionsView.isHidden = true diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewDataSourceUIDelegate.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewDataSourceUIDelegate.swift index 29ea26f54b9e3..2af2d05a55410 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewDataSourceUIDelegate.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewDataSourceUIDelegate.swift @@ -9,6 +9,8 @@ import Foundation import NextcloudKit protocol ShareViewDataSourceUIDelegate { + func fetchStarted() + func fetchFinished() func hideOptions() func showOptions(share: NKShare) } From 4187e99a16245bff35ab58e95874d33503da89b4 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 28 Feb 2024 21:57:08 +0800 Subject: [PATCH 074/172] Tell delegate when fetch ongoing in share table view data source Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/ShareTableViewDataSource.swift | 3 +++ 1 file changed, 3 insertions(+) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift index d19a8d0ae419b..52360ada1b132 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift @@ -107,6 +107,9 @@ class ShareTableViewDataSource: NSObject, NSTableViewDataSource, NSTableViewDele private func fetch( itemIdentifier: NSFileProviderItemIdentifier, itemRelativePath: String ) async -> [NKShare] { + Task { @MainActor in uiDelegate?.fetchStarted() } + defer { Task { @MainActor in uiDelegate?.fetchFinished() } } + let rawIdentifier = itemIdentifier.rawValue Logger.sharesDataSource.info("Fetching shares for item \(rawIdentifier, privacy: .public)") From f93da48480f68266254a9c0c031e18cd9ba58d53 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 28 Feb 2024 21:57:23 +0800 Subject: [PATCH 075/172] Ensure calls are made via main actor to delegate in share table view data source Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/ShareTableViewDataSource.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift index 52360ada1b132..38c14a979e278 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift @@ -157,10 +157,10 @@ class ShareTableViewDataSource: NSObject, NSTableViewDataSource, NSTableViewDele @objc func tableViewSelectionDidChange(_ notification: Notification) { guard let selectedRow = sharesTableView?.selectedRow, selectedRow >= 0 else { - uiDelegate?.hideOptions() + Task { @MainActor in uiDelegate?.hideOptions() } return } let share = shares[selectedRow] - uiDelegate?.showOptions(share: share) + Task { @MainActor in uiDelegate?.showOptions(share: share) } } } From 10fe1891b52e18ff1596eab806d4178e0e08edcc Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 28 Feb 2024 22:37:01 +0800 Subject: [PATCH 076/172] Add a ShareOptionsView class Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/ShareOptionsView.swift | 22 +++++++++++++ .../FileProviderUIExt/ShareViewController.xib | 33 ++++++++++--------- .../project.pbxproj | 4 +++ 3 files changed, 43 insertions(+), 16 deletions(-) create mode 100644 shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift new file mode 100644 index 0000000000000..4ad2f28616970 --- /dev/null +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift @@ -0,0 +1,22 @@ +// +// ShareOptionsView.swift +// FileProviderUIExt +// +// Created by Claudio Cambra on 28/2/24. +// + +import AppKit + +class ShareOptionsView: NSView { + @IBOutlet weak var labelTextField: NSTextField! + @IBOutlet weak var uploadEditPermissionCheckbox: NSButton! + @IBOutlet weak var hideDownloadCheckbox: NSButton! + @IBOutlet weak var passwordProtectCheckbox: NSButton! + @IBOutlet weak var passwordSecureField: NSSecureTextField! + @IBOutlet weak var expirationDateCheckbox: NSButton! + @IBOutlet weak var expirationDatePicker: NSDatePicker! + @IBOutlet weak var noteForRecipientCheckbox: NSButton! + @IBOutlet weak var noteTextField: NSTextField! + @IBOutlet weak var saveButton: NSButton! + @IBOutlet weak var deleteButton: NSButton! +} diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib index 27ffb97d4c1c0..938862bb605d5 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib @@ -158,7 +158,7 @@ - + @@ -166,7 +166,7 @@ - + @@ -249,39 +249,27 @@ - - - @@ -335,6 +323,19 @@ Gw + + + + + + + + + + + + + diff --git a/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj b/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj index 0e4e2802c28db..eebc0fa414f2f 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj +++ b/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj @@ -58,6 +58,7 @@ 53FE14592B8E3F6C006C4193 /* ShareTableItemView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53FE14582B8E3F6C006C4193 /* ShareTableItemView.swift */; }; 53FE145B2B8F1305006C4193 /* NKShare+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53FE145A2B8F1305006C4193 /* NKShare+Extensions.swift */; }; 53FE14652B8F6700006C4193 /* ShareViewDataSourceUIDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53FE14642B8F6700006C4193 /* ShareViewDataSourceUIDelegate.swift */; }; + 53FE14672B8F78B6006C4193 /* ShareOptionsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53FE14662B8F78B6006C4193 /* ShareOptionsView.swift */; }; C2B573BA1B1CD91E00303B36 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = C2B573B91B1CD91E00303B36 /* main.m */; }; C2B573D21B1CD94B00303B36 /* main.m in Resources */ = {isa = PBXBuildFile; fileRef = C2B573B91B1CD91E00303B36 /* main.m */; }; C2B573DE1B1CD9CE00303B36 /* FinderSync.m in Sources */ = {isa = PBXBuildFile; fileRef = C2B573DD1B1CD9CE00303B36 /* FinderSync.m */; }; @@ -206,6 +207,7 @@ 53FE14582B8E3F6C006C4193 /* ShareTableItemView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareTableItemView.swift; sourceTree = ""; }; 53FE145A2B8F1305006C4193 /* NKShare+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NKShare+Extensions.swift"; sourceTree = ""; }; 53FE14642B8F6700006C4193 /* ShareViewDataSourceUIDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareViewDataSourceUIDelegate.swift; sourceTree = ""; }; + 53FE14662B8F78B6006C4193 /* ShareOptionsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareOptionsView.swift; sourceTree = ""; }; C2B573B11B1CD91E00303B36 /* desktopclient.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = desktopclient.app; sourceTree = BUILT_PRODUCTS_DIR; }; C2B573B51B1CD91E00303B36 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; C2B573B91B1CD91E00303B36 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; @@ -359,6 +361,7 @@ children = ( 5376307B2B85E2E00026BFAB /* Extensions */, 53B979802B84C81F002DA742 /* DocumentActionViewController.swift */, + 53FE14662B8F78B6006C4193 /* ShareOptionsView.swift */, 53FE14582B8E3F6C006C4193 /* ShareTableItemView.swift */, 531522812B8E01C6002E31BE /* ShareTableItemView.xib */, 53FE144F2B8E0658006C4193 /* ShareTableViewDataSource.swift */, @@ -735,6 +738,7 @@ buildActionMask = 2147483647; files = ( 537630932B85F4B00026BFAB /* ShareViewController.swift in Sources */, + 53FE14672B8F78B6006C4193 /* ShareOptionsView.swift in Sources */, 53FE14652B8F6700006C4193 /* ShareViewDataSourceUIDelegate.swift in Sources */, 53B979812B84C81F002DA742 /* DocumentActionViewController.swift in Sources */, 53FE145B2B8F1305006C4193 /* NKShare+Extensions.swift in Sources */, From 586e98b777f1267c66b505b7f7834fe67e166619 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Mon, 4 Mar 2024 19:08:35 +0800 Subject: [PATCH 077/172] Improve placeholder text for share view password field Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/ShareViewController.xib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib index 938862bb605d5..488fb85624f6e 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib @@ -203,7 +203,7 @@ - + From f8420652ea559853269f14405be6286f321bb63f Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Mon, 4 Mar 2024 19:16:57 +0800 Subject: [PATCH 078/172] Handle state of share options view via setting of NKShare Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/ShareOptionsView.swift | 39 +++++++++++++------ 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift index 4ad2f28616970..ca197bb30039f 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift @@ -6,17 +6,34 @@ // import AppKit +import NextcloudKit class ShareOptionsView: NSView { - @IBOutlet weak var labelTextField: NSTextField! - @IBOutlet weak var uploadEditPermissionCheckbox: NSButton! - @IBOutlet weak var hideDownloadCheckbox: NSButton! - @IBOutlet weak var passwordProtectCheckbox: NSButton! - @IBOutlet weak var passwordSecureField: NSSecureTextField! - @IBOutlet weak var expirationDateCheckbox: NSButton! - @IBOutlet weak var expirationDatePicker: NSDatePicker! - @IBOutlet weak var noteForRecipientCheckbox: NSButton! - @IBOutlet weak var noteTextField: NSTextField! - @IBOutlet weak var saveButton: NSButton! - @IBOutlet weak var deleteButton: NSButton! + @IBOutlet private weak var labelTextField: NSTextField! + @IBOutlet private weak var uploadEditPermissionCheckbox: NSButton! + @IBOutlet private weak var hideDownloadCheckbox: NSButton! + @IBOutlet private weak var passwordProtectCheckbox: NSButton! + @IBOutlet private weak var passwordSecureField: NSSecureTextField! + @IBOutlet private weak var expirationDateCheckbox: NSButton! + @IBOutlet private weak var expirationDatePicker: NSDatePicker! + @IBOutlet private weak var noteForRecipientCheckbox: NSButton! + @IBOutlet private weak var noteTextField: NSTextField! + @IBOutlet private weak var saveButton: NSButton! + @IBOutlet private weak var deleteButton: NSButton! + + var share: NKShare? { + didSet { + guard let share = share else { return } + labelTextField.stringValue = share.label + uploadEditPermissionCheckbox.state = share.canEdit ? .on : .off + hideDownloadCheckbox.state = share.hideDownload ? .on : .off + passwordProtectCheckbox.state = share.password.isEmpty ? .off : .on + passwordSecureField.isHidden = passwordProtectCheckbox.state == .off + expirationDateCheckbox.state = share.expirationDate == nil ? .off : .on + expirationDatePicker.isHidden = expirationDateCheckbox.state == .off + noteForRecipientCheckbox.state = share.note.isEmpty ? .off : .on + noteTextField.isHidden = noteForRecipientCheckbox.state == .off + deleteButton.isEnabled = share.canDelete + } + } } From ba48403c83f44132f1173ef48658ad0c48663150 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Mon, 4 Mar 2024 19:17:19 +0800 Subject: [PATCH 079/172] Handle optionsview as ShareOptionsView in share view controller Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/ShareViewController.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift index d4e408d717083..6e719a6afdc6d 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift @@ -20,7 +20,7 @@ class ShareViewController: NSViewController, ShareViewDataSourceUIDelegate { @IBOutlet weak var descriptionLabel: NSTextField! @IBOutlet weak var closeButton: NSButton! @IBOutlet weak var tableView: NSTableView! - @IBOutlet weak var optionsView: NSView! + @IBOutlet weak var optionsView: ShareOptionsView! @IBOutlet weak var splitView: NSSplitView! @IBOutlet weak var loadingEffectView: NSVisualEffectView! @IBOutlet weak var loadingIndicator: NSProgressIndicator! @@ -117,6 +117,7 @@ class ShareViewController: NSViewController, ShareViewDataSourceUIDelegate { } func showOptions(share: NKShare) { + optionsView.share = share splitView.addArrangedSubview(optionsView) optionsView.isHidden = false } From 4469e38c0f8b31cf59e1f17aa3d91a2ffa85c3f6 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Mon, 4 Mar 2024 20:09:17 +0800 Subject: [PATCH 080/172] Add starter sharecontroller for fileprovider Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/ShareController.swift | 19 +++++++++++++++++++ .../project.pbxproj | 4 ++++ 2 files changed, 23 insertions(+) create mode 100644 shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareController.swift diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareController.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareController.swift new file mode 100644 index 0000000000000..fdd4b5a8a2717 --- /dev/null +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareController.swift @@ -0,0 +1,19 @@ +// +// ShareController.swift +// FileProviderUIExt +// +// Created by Claudio Cambra on 4/3/24. +// + +import Foundation +import NextcloudKit + +class ShareController { + let share: NKShare + private let kit: NextcloudKit + + init(share: NKShare, kit: NextcloudKit) { + self.share = share + self.kit = kit + } +} diff --git a/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj b/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj index eebc0fa414f2f..2bfe9c6944a44 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj +++ b/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj @@ -24,6 +24,7 @@ 535AE30E29C0A2CC0042A9BA /* Logger+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 535AE30D29C0A2CC0042A9BA /* Logger+Extensions.swift */; }; 536EFBF7295CF58100F4CB13 /* FileProviderSocketLineProcessor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 536EFBF6295CF58100F4CB13 /* FileProviderSocketLineProcessor.swift */; }; 536EFC36295E3C1100F4CB13 /* NextcloudAccount.swift in Sources */ = {isa = PBXBuildFile; fileRef = 536EFC35295E3C1100F4CB13 /* NextcloudAccount.swift */; }; + 5374FD442B95EE1400C78D54 /* ShareController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5374FD432B95EE1400C78D54 /* ShareController.swift */; }; 5376307D2B85E2ED0026BFAB /* Logger+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5376307C2B85E2ED0026BFAB /* Logger+Extensions.swift */; }; 537630912B85F4980026BFAB /* ShareViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 537630902B85F4980026BFAB /* ShareViewController.xib */; }; 537630932B85F4B00026BFAB /* ShareViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 537630922B85F4B00026BFAB /* ShareViewController.swift */; }; @@ -173,6 +174,7 @@ 535AE30D29C0A2CC0042A9BA /* Logger+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Logger+Extensions.swift"; sourceTree = ""; }; 536EFBF6295CF58100F4CB13 /* FileProviderSocketLineProcessor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileProviderSocketLineProcessor.swift; sourceTree = ""; }; 536EFC35295E3C1100F4CB13 /* NextcloudAccount.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NextcloudAccount.swift; sourceTree = ""; }; + 5374FD432B95EE1400C78D54 /* ShareController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareController.swift; sourceTree = ""; }; 5376307C2B85E2ED0026BFAB /* Logger+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Logger+Extensions.swift"; sourceTree = ""; }; 5376307E2B85E5650026BFAB /* FileProviderUIExt.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = FileProviderUIExt.entitlements; sourceTree = ""; }; 537630902B85F4980026BFAB /* ShareViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ShareViewController.xib; sourceTree = ""; }; @@ -361,6 +363,7 @@ children = ( 5376307B2B85E2E00026BFAB /* Extensions */, 53B979802B84C81F002DA742 /* DocumentActionViewController.swift */, + 5374FD432B95EE1400C78D54 /* ShareController.swift */, 53FE14662B8F78B6006C4193 /* ShareOptionsView.swift */, 53FE14582B8E3F6C006C4193 /* ShareTableItemView.swift */, 531522812B8E01C6002E31BE /* ShareTableItemView.xib */, @@ -741,6 +744,7 @@ 53FE14672B8F78B6006C4193 /* ShareOptionsView.swift in Sources */, 53FE14652B8F6700006C4193 /* ShareViewDataSourceUIDelegate.swift in Sources */, 53B979812B84C81F002DA742 /* DocumentActionViewController.swift in Sources */, + 5374FD442B95EE1400C78D54 /* ShareController.swift in Sources */, 53FE145B2B8F1305006C4193 /* NKShare+Extensions.swift in Sources */, 53FE14592B8E3F6C006C4193 /* ShareTableItemView.swift in Sources */, 53FE14552B8E28E9006C4193 /* NextcloudAccount.swift in Sources */, From b1cf42fa924fdd2e8a00869ad231a55c31971283 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Mon, 4 Mar 2024 20:40:31 +0800 Subject: [PATCH 081/172] Add convenience property to nkshare extension to get valid expiration date string Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/Extensions/NKShare+Extensions.swift | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Extensions/NKShare+Extensions.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Extensions/NKShare+Extensions.swift index 0db7d83b3cfe3..e458a7a2ea3fa 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Extensions/NKShare+Extensions.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Extensions/NKShare+Extensions.swift @@ -94,4 +94,11 @@ extension NKShare { return "Unknown share" } } + + var expirationDateString: String? { + guard let date = expirationDate else { return nil } + let dateFormatter = DateFormatter() + dateFormatter.dateFormat = "YYYY-MM-dd HH:mm:ss" + return dateFormatter.string(from: date as Date) + } } From 47048743524313cf39c1b87826b6d0d452997df3 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Mon, 4 Mar 2024 20:41:01 +0800 Subject: [PATCH 082/172] Add functionality to share controller to save changes Signed-off-by: Claudio Cambra --- .../Extensions/Logger+Extensions.swift | 1 + .../FileProviderUIExt/ShareController.swift | 29 +++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Extensions/Logger+Extensions.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Extensions/Logger+Extensions.swift index 63ff845a69d80..c668e3a8dd5b8 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Extensions/Logger+Extensions.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Extensions/Logger+Extensions.swift @@ -11,6 +11,7 @@ extension Logger { private static var subsystem = Bundle.main.bundleIdentifier! static let actionViewController = Logger(subsystem: subsystem, category: "actionViewController") + static let shareController = Logger(subsystem: subsystem, category: "shareController") static let sharesDataSource = Logger(subsystem: subsystem, category: "sharesDataSource") static let shareViewController = Logger(subsystem: subsystem, category: "shareViewController") } diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareController.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareController.swift index fdd4b5a8a2717..4a51d609a7447 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareController.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareController.swift @@ -5,15 +5,40 @@ // Created by Claudio Cambra on 4/3/24. // +import Combine import Foundation import NextcloudKit +import OSLog -class ShareController { - let share: NKShare +class ShareController: ObservableObject { + @Published private(set) var share: NKShare private let kit: NextcloudKit init(share: NKShare, kit: NextcloudKit) { self.share = share self.kit = kit } + + func save() async -> NKError? { + return await withCheckedContinuation { continuation in + kit.updateShare( + idShare: share.idShare, + password: share.password, + expireDate: share.expirationDateString ?? "", + permissions: share.permissions, + note: share.note, + label: share.label, + hideDownload: share.hideDownload, + attributes: share.attributes + ) { account, share, data, error in + Logger.shareController.info("Received update response: \(share?.url ?? "")") + defer { continuation.resume(returning: error) } + guard error == .success, let share = share else { + Logger.shareController.error("Error updating save: \(error.errorDescription)") + return + } + self.share = share + } + } + } } From fea4e8855e72847e8ced644215014783273edbad Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Mon, 4 Mar 2024 20:42:52 +0800 Subject: [PATCH 083/172] Use ShareController in ShareOptionsView Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/ShareOptionsView.swift | 47 ++++++++++++++----- 1 file changed, 35 insertions(+), 12 deletions(-) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift index ca197bb30039f..d0f75a13c4802 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift @@ -21,19 +21,42 @@ class ShareOptionsView: NSView { @IBOutlet private weak var saveButton: NSButton! @IBOutlet private weak var deleteButton: NSButton! - var share: NKShare? { + var controller: ShareController? { didSet { - guard let share = share else { return } - labelTextField.stringValue = share.label - uploadEditPermissionCheckbox.state = share.canEdit ? .on : .off - hideDownloadCheckbox.state = share.hideDownload ? .on : .off - passwordProtectCheckbox.state = share.password.isEmpty ? .off : .on - passwordSecureField.isHidden = passwordProtectCheckbox.state == .off - expirationDateCheckbox.state = share.expirationDate == nil ? .off : .on - expirationDatePicker.isHidden = expirationDateCheckbox.state == .off - noteForRecipientCheckbox.state = share.note.isEmpty ? .off : .on - noteTextField.isHidden = noteForRecipientCheckbox.state == .off - deleteButton.isEnabled = share.canDelete + update() + + } + } + + private func update() { + guard let share = controller?.share else { + reset() + saveButton.isEnabled = false + deleteButton.isEnabled = false + return } + labelTextField.stringValue = share.label + uploadEditPermissionCheckbox.state = share.canEdit ? .on : .off + hideDownloadCheckbox.state = share.hideDownload ? .on : .off + passwordProtectCheckbox.state = share.password.isEmpty ? .off : .on + passwordSecureField.isHidden = passwordProtectCheckbox.state == .off + expirationDateCheckbox.state = share.expirationDate == nil ? .off : .on + expirationDatePicker.isHidden = expirationDateCheckbox.state == .off + noteForRecipientCheckbox.state = share.note.isEmpty ? .off : .on + noteTextField.isHidden = noteForRecipientCheckbox.state == .off + deleteButton.isEnabled = share.canDelete + saveButton.isEnabled = true + } + + func reset() { + labelTextField.stringValue = "" + uploadEditPermissionCheckbox.state = .off + hideDownloadCheckbox.state = .off + passwordProtectCheckbox.state = .off + passwordSecureField.isHidden = true + expirationDateCheckbox.state = .off + expirationDatePicker.isHidden = true + noteForRecipientCheckbox.state = .off + noteTextField.isHidden = true } } From 34630dff0d48898151297dbfbbe7e42b923bbedb Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Mon, 4 Mar 2024 21:02:00 +0800 Subject: [PATCH 084/172] Add convenience function to format date to valid server string in nkshare Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/Extensions/NKShare+Extensions.swift | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Extensions/NKShare+Extensions.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Extensions/NKShare+Extensions.swift index e458a7a2ea3fa..605f2b85fbb08 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Extensions/NKShare+Extensions.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Extensions/NKShare+Extensions.swift @@ -101,4 +101,10 @@ extension NKShare { dateFormatter.dateFormat = "YYYY-MM-dd HH:mm:ss" return dateFormatter.string(from: date as Date) } + + static func formattedDateString(date: Date) -> String { + let dateFormatter = DateFormatter() + dateFormatter.dateFormat = "YYYY-MM-dd HH:mm:ss" + return dateFormatter.string(from: date) + } } From c6195fdc0402ff3e8771e4b5a9c7a1b6a6836450 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Mon, 4 Mar 2024 21:02:35 +0800 Subject: [PATCH 085/172] Respond to changes in share of sharecontroller in shareoptionsview Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/ShareOptionsView.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift index d0f75a13c4802..6a3e63c315df1 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift @@ -6,6 +6,7 @@ // import AppKit +import Combine import NextcloudKit class ShareOptionsView: NSView { @@ -23,10 +24,12 @@ class ShareOptionsView: NSView { var controller: ShareController? { didSet { + cancellable?.cancel() update() - + cancellable = controller.publisher.sink { _ in self.update() } } } + private var cancellable: AnyCancellable? private func update() { guard let share = controller?.share else { From f0d997acc67ce5583daaea87151f7c1f87c8acc5 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Mon, 4 Mar 2024 21:35:25 +0800 Subject: [PATCH 086/172] Add convenience function to enable or disable all share option fields Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/ShareOptionsView.swift | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift index 6a3e63c315df1..5aebe0fb7587e 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift @@ -62,4 +62,18 @@ class ShareOptionsView: NSView { noteForRecipientCheckbox.state = .off noteTextField.isHidden = true } + + func setAllFields(enabled: Bool) { + labelTextField.isEnabled = enabled + uploadEditPermissionCheckbox.isEnabled = enabled + hideDownloadCheckbox.isEnabled = enabled + passwordProtectCheckbox.isEnabled = enabled + passwordSecureField.isEnabled = enabled + expirationDateCheckbox.isEnabled = enabled + expirationDatePicker.isEnabled = enabled + noteForRecipientCheckbox.isEnabled = enabled + noteTextField.isEnabled = enabled + saveButton.isEnabled = enabled + deleteButton.isEnabled = enabled + } } From 5df0028c5a4c17134e8f0d4373bd6c3a96ecb72d Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Mon, 4 Mar 2024 21:35:40 +0800 Subject: [PATCH 087/172] Correctly handle NKShare's "canEdit" in share options view Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/ShareOptionsView.swift | 29 ++++++++++++------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift index 5aebe0fb7587e..3a46cb3fa3300 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift @@ -34,21 +34,30 @@ class ShareOptionsView: NSView { private func update() { guard let share = controller?.share else { reset() + setAllFields(enabled: false) saveButton.isEnabled = false deleteButton.isEnabled = false return } - labelTextField.stringValue = share.label - uploadEditPermissionCheckbox.state = share.canEdit ? .on : .off - hideDownloadCheckbox.state = share.hideDownload ? .on : .off - passwordProtectCheckbox.state = share.password.isEmpty ? .off : .on - passwordSecureField.isHidden = passwordProtectCheckbox.state == .off - expirationDateCheckbox.state = share.expirationDate == nil ? .off : .on - expirationDatePicker.isHidden = expirationDateCheckbox.state == .off - noteForRecipientCheckbox.state = share.note.isEmpty ? .off : .on - noteTextField.isHidden = noteForRecipientCheckbox.state == .off + deleteButton.isEnabled = share.canDelete - saveButton.isEnabled = true + saveButton.isEnabled = share.canEdit + + if share.canEdit { + setAllFields(enabled: true) + labelTextField.stringValue = share.label + uploadEditPermissionCheckbox.state = share.canEdit ? .on : .off + hideDownloadCheckbox.state = share.hideDownload ? .on : .off + passwordProtectCheckbox.state = share.password.isEmpty ? .off : .on + passwordSecureField.isHidden = passwordProtectCheckbox.state == .off + expirationDateCheckbox.state = share.expirationDate == nil ? .off : .on + expirationDatePicker.isHidden = expirationDateCheckbox.state == .off + noteForRecipientCheckbox.state = share.note.isEmpty ? .off : .on + noteTextField.isHidden = noteForRecipientCheckbox.state == .off + } else { + setAllFields(enabled: false) + reset() + } } func reset() { From 95ed9b663b8bf42384d24805bc1bcfa3b250b5ea Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Mon, 4 Mar 2024 21:37:04 +0800 Subject: [PATCH 088/172] Add fields as parameters to save in sharecontroller Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/ShareController.swift | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareController.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareController.swift index 4a51d609a7447..0831d7eb41b7b 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareController.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareController.swift @@ -19,17 +19,29 @@ class ShareController: ObservableObject { self.kit = kit } - func save() async -> NKError? { + func save( + password: String? = nil, + expireDate: String? = nil, + permissions: Int = 1, + publicUpload: Bool = false, + note: String? = nil, + label: String? = nil, + hideDownload: Bool, + attributes: String? = nil, + options: NKRequestOptions = NKRequestOptions() + ) async -> NKError? { return await withCheckedContinuation { continuation in kit.updateShare( idShare: share.idShare, - password: share.password, - expireDate: share.expirationDateString ?? "", - permissions: share.permissions, - note: share.note, - label: share.label, - hideDownload: share.hideDownload, - attributes: share.attributes + password: password, + expireDate: expireDate, + permissions: permissions, + publicUpload: publicUpload, + note: note, + label: label, + hideDownload: hideDownload, + attributes: attributes, + options: options ) { account, share, data, error in Logger.shareController.info("Received update response: \(share?.url ?? "")") defer { continuation.resume(returning: error) } From 4f8c3ece31e62e4e4c5e838a57bf4184a2dc891b Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Mon, 4 Mar 2024 21:40:01 +0800 Subject: [PATCH 089/172] Make save button functional in share view Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/ShareOptionsView.swift | 27 +++++++++++++++++++ .../FileProviderUIExt/ShareViewController.xib | 3 +++ 2 files changed, 30 insertions(+) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift index 3a46cb3fa3300..02f2b95fa77fe 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift @@ -85,4 +85,31 @@ class ShareOptionsView: NSView { saveButton.isEnabled = enabled deleteButton.isEnabled = enabled } + + @IBAction func save(_ sender: Any) { + Task { @MainActor in + let password = passwordProtectCheckbox.state == .on + ? passwordSecureField.stringValue + : "" + let expireDate = expirationDateCheckbox.state == .on + ? NKShare.formattedDateString(date: expirationDatePicker.dateValue) + : "" + let note = noteForRecipientCheckbox.state == .on + ? noteTextField.stringValue + : "" + let label = labelTextField.stringValue + let hideDownload = hideDownloadCheckbox.state == .on + + setAllFields(enabled: false) + deleteButton.isEnabled = false + saveButton.isEnabled = false + _ = await controller?.save( + password: password, + expireDate: expireDate, + note: note, + label: label, + hideDownload: hideDownload + ) + } + } } diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib index 488fb85624f6e..ff0ea39a56532 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib @@ -254,6 +254,9 @@ + + + + + + + + + + + + + + + + + + + + - + @@ -128,6 +168,7 @@ + @@ -152,20 +193,22 @@ + + - + - + - - + + @@ -173,7 +216,7 @@ - + @@ -181,28 +224,28 @@ - + @@ -213,32 +256,32 @@ - + - - + + - + @@ -246,7 +289,7 @@ - + - @@ -424,7 +431,12 @@ + + + + + From 796740a246b96eea83d556e175839606d5f60128 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Tue, 5 Mar 2024 17:50:40 +0800 Subject: [PATCH 106/172] Implement deletion functionality for share options view Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/ShareOptionsView.swift | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift index f43018f32e34f..b25ab327d9515 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift @@ -124,4 +124,17 @@ class ShareOptionsView: NSView { await dataSource?.reload() } } + + @IBAction func delete(_ sender: Any) { + Task { @MainActor in + setAllFields(enabled: false) + deleteButton.isEnabled = false + saveButton.isEnabled = false + let error = await controller?.delete() + if let error = error, error != .success { + dataSource?.uiDelegate?.showError("Error deleting share: \(error.errorDescription)") + } + await dataSource?.reload() + } + } } From d7cfa4e5e2d5c16f18adf7bdbddd9191c9ada279 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Tue, 5 Mar 2024 17:50:59 +0800 Subject: [PATCH 107/172] Remove unused outlets in tableitemview Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/ShareTableItemView.swift | 3 --- 1 file changed, 3 deletions(-) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableItemView.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableItemView.swift index 8ac72d6fc238a..6651062934380 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableItemView.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableItemView.swift @@ -12,9 +12,6 @@ class ShareTableItemView: NSTableCellView { @IBOutlet private weak var typeImageView: NSImageView! @IBOutlet private weak var label: NSTextField! @IBOutlet private weak var copyLinkButton: NSButton! - @IBOutlet private weak var optionsButton: NSButton! - @IBOutlet private weak var popover: NSPopover! - @IBOutlet private weak var popoverContentViewController: NSViewController! private var originalCopyImage: NSImage? private var copiedButtonImage: NSImage? private var tempButtonTimer: Timer? From 3e9d89599d2b6ff34d45a68b3f0806c8ba4fcd41 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Tue, 5 Mar 2024 18:16:17 +0800 Subject: [PATCH 108/172] Add button to create new share in share view Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/ShareOptionsView.swift | 1 + .../FileProviderUIExt/ShareViewController.xib | 22 ++++++++++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift index b25ab327d9515..a9fac05e6675c 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift @@ -26,6 +26,7 @@ class ShareOptionsView: NSView { var controller: ShareController? { didSet { cancellable?.cancel() + createMode = false update() cancellable = controller.publisher.sink { _ in self.update() } } diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib index 0d4ba929c1a55..128761021624e 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib @@ -46,7 +46,7 @@ - + @@ -74,6 +74,17 @@ + From 9ccd190dc102291e3850d998756d7e6b5711968f Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Thu, 7 Mar 2024 02:00:41 +0800 Subject: [PATCH 126/172] Adapt visibility of expiration date field upon toggling checkbox Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/ShareOptionsView.swift | 4 ++++ .../FileProviderUIExt/ShareViewController.xib | 3 +++ 2 files changed, 7 insertions(+) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift index 914f50ee23f54..463a2b36225bc 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift @@ -139,6 +139,10 @@ class ShareOptionsView: NSView { passwordSecureField.isHidden = passwordProtectCheckbox.state == .off } + @IBAction func expirationDateCheckboxAction(_ sender: Any) { + expirationDatePicker.isHidden = expirationDateCheckbox.state == .off + } + @IBAction func save(_ sender: Any) { Task { @MainActor in let password = passwordProtectCheckbox.state == .on diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib index 5d02b3704cd18..3f01627946786 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib @@ -315,6 +315,9 @@ + + + From 0e50bc774e9e1e08f73be273876116165bbcc693 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Tue, 12 Mar 2024 14:27:35 +0800 Subject: [PATCH 127/172] Adapt visibility of note recipient text field upon toggling checkbox Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/ShareOptionsView.swift | 4 ++++ .../FileProviderUIExt/ShareViewController.xib | 3 +++ 2 files changed, 7 insertions(+) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift index 463a2b36225bc..7201bc564fa69 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift @@ -143,6 +143,10 @@ class ShareOptionsView: NSView { expirationDatePicker.isHidden = expirationDateCheckbox.state == .off } + @IBAction func noteForRecipientCheckboxAction(_ sender: Any) { + noteTextField.isHidden = noteForRecipientCheckbox.state == .off + } + @IBAction func save(_ sender: Any) { Task { @MainActor in let password = passwordProtectCheckbox.state == .on diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib index 3f01627946786..857d01cbb3ebf 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib @@ -336,6 +336,9 @@ + + + From 8d8b8cc66bc5d5b0cb22117dc1d6ce152cffc485 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 13 Mar 2024 18:16:51 +0800 Subject: [PATCH 128/172] Add ShareCapabilities struct Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/ShareCapabilities.swift | 28 +++++++++++++++++++ .../project.pbxproj | 4 +++ 2 files changed, 32 insertions(+) create mode 100644 shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareCapabilities.swift diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareCapabilities.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareCapabilities.swift new file mode 100644 index 0000000000000..c9520757792fb --- /dev/null +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareCapabilities.swift @@ -0,0 +1,28 @@ +// +// ShareCapabilities.swift +// FileProviderUIExt +// +// Created by Claudio Cambra on 13/3/24. +// + +import Foundation + +struct ShareCapabilities { + private(set) var shareApiEnabled = false + private(set) var shareEmailPasswordEnabled = false + private(set) var shareEmailPasswordEnforced = false + private(set) var sharePublicLinkEnabled = false + private(set) var sharePublicLinkAllowUpload = false + private(set) var sharePublicLinkSupportsUploadOnly = false + private(set) var sharePublicLinkAskOptionalPassword = false + private(set) var sharePublicLinkEnforcePassword = false + private(set) var sharePublicLinkEnforceExpireDate = 0 + private(set) var sharePublicLinkExpireDateDays = false + private(set) var shareInternalEnforceExpireDate = false + private(set) var shareInternalExpireDateDays = 0 + private(set) var shareRemoteEnforceExpireDate = false + private(set) var shareRemoteExpireDateDays = 0 + private(set) var sharePublicLinkMultiple = false + private(set) var shareResharing = false + private(set) var shareDefaultPermissions = 0 +} diff --git a/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj b/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj index 2bfe9c6944a44..98460d511d39b 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj +++ b/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj @@ -16,6 +16,7 @@ 5318AD9529BF438F00CBB71C /* NextcloudLocalFileMetadataTable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5318AD9429BF438F00CBB71C /* NextcloudLocalFileMetadataTable.swift */; }; 5318AD9729BF493600CBB71C /* FileProviderMaterialisedEnumerationObserver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5318AD9629BF493600CBB71C /* FileProviderMaterialisedEnumerationObserver.swift */; }; 5318AD9929BF58D000CBB71C /* NKError+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5318AD9829BF58D000CBB71C /* NKError+Extensions.swift */; }; + 534F812F2BA1B3D80068D145 /* ShareCapabilities.swift in Sources */ = {isa = PBXBuildFile; fileRef = 534F812E2BA1B3D80068D145 /* ShareCapabilities.swift */; }; 5350E4E92B0C534A00F276CB /* ClientCommunicationService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5350E4E82B0C534A00F276CB /* ClientCommunicationService.swift */; }; 5352B36629DC14970011CE03 /* NextcloudFilesDatabaseManager+Directories.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5352B36529DC14970011CE03 /* NextcloudFilesDatabaseManager+Directories.swift */; }; 5352B36829DC17D60011CE03 /* NextcloudFilesDatabaseManager+LocalFiles.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5352B36729DC17D60011CE03 /* NextcloudFilesDatabaseManager+LocalFiles.swift */; }; @@ -164,6 +165,7 @@ 5318AD9429BF438F00CBB71C /* NextcloudLocalFileMetadataTable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NextcloudLocalFileMetadataTable.swift; sourceTree = ""; }; 5318AD9629BF493600CBB71C /* FileProviderMaterialisedEnumerationObserver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileProviderMaterialisedEnumerationObserver.swift; sourceTree = ""; }; 5318AD9829BF58D000CBB71C /* NKError+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NKError+Extensions.swift"; sourceTree = ""; }; + 534F812E2BA1B3D80068D145 /* ShareCapabilities.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareCapabilities.swift; sourceTree = ""; }; 5350E4E72B0C514400F276CB /* ClientCommunicationProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ClientCommunicationProtocol.h; sourceTree = ""; }; 5350E4E82B0C534A00F276CB /* ClientCommunicationService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClientCommunicationService.swift; sourceTree = ""; }; 5350E4EA2B0C9CE100F276CB /* FileProviderExt-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "FileProviderExt-Bridging-Header.h"; sourceTree = ""; }; @@ -363,6 +365,7 @@ children = ( 5376307B2B85E2E00026BFAB /* Extensions */, 53B979802B84C81F002DA742 /* DocumentActionViewController.swift */, + 534F812E2BA1B3D80068D145 /* ShareCapabilities.swift */, 5374FD432B95EE1400C78D54 /* ShareController.swift */, 53FE14662B8F78B6006C4193 /* ShareOptionsView.swift */, 53FE14582B8E3F6C006C4193 /* ShareTableItemView.swift */, @@ -747,6 +750,7 @@ 5374FD442B95EE1400C78D54 /* ShareController.swift in Sources */, 53FE145B2B8F1305006C4193 /* NKShare+Extensions.swift in Sources */, 53FE14592B8E3F6C006C4193 /* ShareTableItemView.swift in Sources */, + 534F812F2BA1B3D80068D145 /* ShareCapabilities.swift in Sources */, 53FE14552B8E28E9006C4193 /* NextcloudAccount.swift in Sources */, 5376307D2B85E2ED0026BFAB /* Logger+Extensions.swift in Sources */, 53FE14502B8E0658006C4193 /* ShareTableViewDataSource.swift in Sources */, From 39a8edea531543e36c6a5a0dcf7895b4244848b9 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 13 Mar 2024 18:59:28 +0800 Subject: [PATCH 129/172] Restructure ShareCapabilities Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/ShareCapabilities.swift | 51 ++++++++++++------- 1 file changed, 34 insertions(+), 17 deletions(-) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareCapabilities.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareCapabilities.swift index c9520757792fb..421fdf1dfe0c6 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareCapabilities.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareCapabilities.swift @@ -6,23 +6,40 @@ // import Foundation +import OSLog struct ShareCapabilities { - private(set) var shareApiEnabled = false - private(set) var shareEmailPasswordEnabled = false - private(set) var shareEmailPasswordEnforced = false - private(set) var sharePublicLinkEnabled = false - private(set) var sharePublicLinkAllowUpload = false - private(set) var sharePublicLinkSupportsUploadOnly = false - private(set) var sharePublicLinkAskOptionalPassword = false - private(set) var sharePublicLinkEnforcePassword = false - private(set) var sharePublicLinkEnforceExpireDate = 0 - private(set) var sharePublicLinkExpireDateDays = false - private(set) var shareInternalEnforceExpireDate = false - private(set) var shareInternalExpireDateDays = 0 - private(set) var shareRemoteEnforceExpireDate = false - private(set) var shareRemoteExpireDateDays = 0 - private(set) var sharePublicLinkMultiple = false - private(set) var shareResharing = false - private(set) var shareDefaultPermissions = 0 + struct EmailCapabilities { + private(set) var passwordEnabled = false + private(set) var passwordEnforced = false + } + + struct PublicLinkCapabilities { + private(set) var enabled = false + private(set) var allowUpload = false + private(set) var supportsUploadOnly = false + private(set) var askOptionalPassword = false + private(set) var enforcePassword = false + private(set) var enforceExpireDate = false + private(set) var expireDateDays = 0 + private(set) var multipleAllowed = false + } + + struct InternalCapabilities { + private(set) var enforceExpireDate = false + private(set) var expireDateDays = 0 + } + + struct RemoteCapabilities { + private(set) var enforceExpireDate = false + private(set) var expireDateDays = 0 + } + + private(set) var apiEnabled = false + private(set) var resharing = false + private(set) var defaultPermissions = 0 + private(set) var email = EmailCapabilities() + private(set) var publicLink = PublicLinkCapabilities() + private(set) var internalShares = InternalCapabilities() + private(set) var remote = RemoteCapabilities() } From 82528b35593c3cf55dcb7c404a6cd3a3b7c9f16e Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 13 Mar 2024 19:08:07 +0800 Subject: [PATCH 130/172] Add initialiser from dictionary for EmailCapabilities Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/ShareCapabilities.swift | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareCapabilities.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareCapabilities.swift index 421fdf1dfe0c6..b8081117f1f7e 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareCapabilities.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareCapabilities.swift @@ -12,6 +12,13 @@ struct ShareCapabilities { struct EmailCapabilities { private(set) var passwordEnabled = false private(set) var passwordEnforced = false + + init(dict: [String: Any]) { + if let passwordCapabilities = dict["password"] as? [String : Any] { + passwordEnabled = passwordCapabilities["enabled"] as? Bool ?? false + passwordEnforced = passwordCapabilities["enforced"] as? Bool ?? false + } + } } struct PublicLinkCapabilities { @@ -38,8 +45,8 @@ struct ShareCapabilities { private(set) var apiEnabled = false private(set) var resharing = false private(set) var defaultPermissions = 0 - private(set) var email = EmailCapabilities() private(set) var publicLink = PublicLinkCapabilities() private(set) var internalShares = InternalCapabilities() private(set) var remote = RemoteCapabilities() + private(set) var email = EmailCapabilities(dict: [:]) } From c6fdfeebda1095902238deb0cd7caa98b9621a58 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Mon, 18 Mar 2024 17:49:47 +0800 Subject: [PATCH 131/172] Add init for public link capabilities Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/ShareCapabilities.swift | 43 +++++++++++++------ 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareCapabilities.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareCapabilities.swift index b8081117f1f7e..6adceb0a6aa45 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareCapabilities.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareCapabilities.swift @@ -28,25 +28,44 @@ struct ShareCapabilities { private(set) var askOptionalPassword = false private(set) var enforcePassword = false private(set) var enforceExpireDate = false - private(set) var expireDateDays = 0 + private(set) var expireDateDays = 1 + private(set) var internalEnforceExpireDate = false + private(set) var internalExpireDateDays = 1 + private(set) var remoteEnforceExpireDate = false + private(set) var remoteExpireDateDays = 1 private(set) var multipleAllowed = false - } - struct InternalCapabilities { - private(set) var enforceExpireDate = false - private(set) var expireDateDays = 0 - } + init(dict: [String: Any]) { + enabled = dict["enabled"] as? Bool ?? false + allowUpload = dict["upload"] as? Bool ?? false + supportsUploadOnly = dict["supports_upload_only"] as? Bool ?? false + multipleAllowed = dict["multiple"] as? Bool ?? false - struct RemoteCapabilities { - private(set) var enforceExpireDate = false - private(set) var expireDateDays = 0 + if let passwordCapabilities = dict["password"] as? [String : Any] { + askOptionalPassword = dict["askForOptionalPassword"] as? Bool ?? false + enforcePassword = dict["enforced"] as? Bool ?? false + } + + if let expireDateCapabilities = dict["expire_date"] as? [String: Any] { + expireDateDays = expireDateCapabilities["days"] as? Int ?? 1 + enforceExpireDate = expireDateCapabilities["enforced"] as? Bool ?? false + } + + if let internalExpDateCaps = dict["expire_date_internal"] as? [String: Any] { + internalExpireDateDays = internalExpDateCaps["days"] as? Int ?? 1 + internalEnforceExpireDate = internalExpDateCaps["enforced"] as? Bool ?? false + } + + if let remoteExpDateCaps = dict["expire_date_remote"] as? [String: Any] { + remoteExpireDateDays = remoteExpDateCaps["days"] as? Int ?? 1 + remoteEnforceExpireDate = remoteExpDateCaps["enforced"] as? Bool ?? false + } + } } private(set) var apiEnabled = false private(set) var resharing = false private(set) var defaultPermissions = 0 - private(set) var publicLink = PublicLinkCapabilities() - private(set) var internalShares = InternalCapabilities() - private(set) var remote = RemoteCapabilities() private(set) var email = EmailCapabilities(dict: [:]) + private(set) var publicLink = PublicLinkCapabilities(dict: [:]) } From 3e118f867e4844101e6bce9d481ef41135fbcdea Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Mon, 18 Mar 2024 17:51:10 +0800 Subject: [PATCH 132/172] Add init for ShareCapabilities Signed-off-by: Claudio Cambra --- .../Extensions/Logger+Extensions.swift | 1 + .../FileProviderUIExt/ShareCapabilities.swift | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Extensions/Logger+Extensions.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Extensions/Logger+Extensions.swift index c05677bbf9bbe..54e3e599a1e90 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Extensions/Logger+Extensions.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Extensions/Logger+Extensions.swift @@ -11,6 +11,7 @@ extension Logger { private static var subsystem = Bundle.main.bundleIdentifier! static let actionViewController = Logger(subsystem: subsystem, category: "actionViewController") + static let shareCapabilities = Logger(subsystem: subsystem, category: "shareCapabilities") static let shareController = Logger(subsystem: subsystem, category: "shareController") static let sharesDataSource = Logger(subsystem: subsystem, category: "sharesDataSource") static let shareOptionsView = Logger(subsystem: subsystem, category: "shareOptionsView") diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareCapabilities.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareCapabilities.swift index 6adceb0a6aa45..62252a66056f4 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareCapabilities.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareCapabilities.swift @@ -68,4 +68,23 @@ struct ShareCapabilities { private(set) var defaultPermissions = 0 private(set) var email = EmailCapabilities(dict: [:]) private(set) var publicLink = PublicLinkCapabilities(dict: [:]) + + init(json: Data) { + guard let anyJson = try? JSONSerialization.jsonObject(with: json, options: []), + let jsonDict = anyJson as? [String : Any], + let sharingCapabilities = jsonDict["files_sharing"] as? [String : Any] + else { + Logger.shareCapabilities.error("Could not parse share capabilities!") + return + } + apiEnabled = sharingCapabilities["api_enabled"] as? Bool ?? false + + if let emailCapabilities = sharingCapabilities["sharebymail"] as? [String : Any] { + email = EmailCapabilities(dict: emailCapabilities) + } + + if let publicLinkCapabilities = sharingCapabilities["public"] as? [String : Any] { + publicLink = PublicLinkCapabilities(dict: publicLinkCapabilities) + } + } } From 6932ab2cd072cd1dd0652075f961afc4386cd2eb Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Mon, 18 Mar 2024 18:06:26 +0800 Subject: [PATCH 133/172] Fetch sharing capabilities in ShareTableViewDataSource Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/ShareCapabilities.swift | 7 +++++++ .../ShareTableViewDataSource.swift | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareCapabilities.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareCapabilities.swift index 62252a66056f4..497d803e5baa1 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareCapabilities.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareCapabilities.swift @@ -69,6 +69,11 @@ struct ShareCapabilities { private(set) var email = EmailCapabilities(dict: [:]) private(set) var publicLink = PublicLinkCapabilities(dict: [:]) + + init() { + Logger.shareCapabilities.warning("Providing defaulted share capabilities!") + } + init(json: Data) { guard let anyJson = try? JSONSerialization.jsonObject(with: json, options: []), let jsonDict = anyJson as? [String : Any], @@ -86,5 +91,7 @@ struct ShareCapabilities { if let publicLinkCapabilities = sharingCapabilities["public"] as? [String : Any] { publicLink = PublicLinkCapabilities(dict: publicLinkCapabilities) } + + Logger.shareCapabilities.debug("Parses share capabilities.") } } diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift index 192158be7d084..22faba216c1b2 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift @@ -43,6 +43,7 @@ class ShareTableViewDataSource: NSObject, NSTableViewDataSource, NSTableViewDele ) } } + private var shareCapabilities = ShareCapabilities() func loadItem(url: URL) { itemServerRelativePath = nil @@ -81,6 +82,7 @@ class ShareTableViewDataSource: NSObject, NSTableViewDataSource, NSTableViewDele itemServerRelativePath = serverPath as String account = convertedAccount await sharesTableView?.deselectAll(self) + shareCapabilities = await fetchCapabilities() shares = await fetch( itemIdentifier: itemIdentifier, itemRelativePath: serverPath as String ) @@ -139,6 +141,22 @@ class ShareTableViewDataSource: NSObject, NSTableViewDataSource, NSTableViewDele } } + private func fetchCapabilities() async -> ShareCapabilities { + return await withCheckedContinuation { continuation in + kit?.getCapabilities { account, capabilitiesJson, error in + guard error == .success, let capabilitiesJson = capabilitiesJson else { + let errorString = "Error getting server capabilities: \(error.errorDescription)" + Logger.sharesDataSource.error("\(errorString)") + Task { @MainActor in self.uiDelegate?.showError(errorString) } + continuation.resume(returning: ShareCapabilities()) + return + } + Logger.sharesDataSource.info("Successfully retrieved server share capabilities") + continuation.resume(returning: ShareCapabilities(json: capabilitiesJson)) + } + } + } + // MARK: - NSTableViewDataSource protocol methods @objc func numberOfRows(in tableView: NSTableView) -> Int { From 3e85162d5506bc550a056329f1c0b713cab32002 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Mon, 18 Mar 2024 18:06:56 +0800 Subject: [PATCH 134/172] Do not bother fetching shares if sharing is disabled on server Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/ShareTableViewDataSource.swift | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift index 22faba216c1b2..548f3aa94d190 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift @@ -83,6 +83,12 @@ class ShareTableViewDataSource: NSObject, NSTableViewDataSource, NSTableViewDele account = convertedAccount await sharesTableView?.deselectAll(self) shareCapabilities = await fetchCapabilities() + guard shareCapabilities.apiEnabled else { + let errorMsg = "Server does not support shares." + Logger.sharesDataSource.info("\(errorMsg)") + uiDelegate?.showError(errorMsg) + return + } shares = await fetch( itemIdentifier: itemIdentifier, itemRelativePath: serverPath as String ) From 0863663ef2bd488a14cc251e8d622f1aac439224 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Mon, 18 Mar 2024 18:52:39 +0800 Subject: [PATCH 135/172] Extract conversion of picked menu item in share type picker into NKShare ShareType into new method Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/ShareOptionsView.swift | 39 +++++++++++-------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift index 7201bc564fa69..a90cd3196e09d 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift @@ -135,6 +135,27 @@ class ShareOptionsView: NSView { deleteButton.isEnabled = enabled } + func pickedShareType() -> NKShare.ShareType { + let selectedShareTypeItem = shareTypePicker.selectedItem + var selectedShareType = NKShare.ShareType.publicLink + if selectedShareTypeItem == publicLinkShareMenuItem { + selectedShareType = .publicLink + } else if selectedShareTypeItem == userShareMenuItem { + selectedShareType = .user + } else if selectedShareTypeItem == groupShareMenuItem { + selectedShareType = .group + } else if selectedShareTypeItem == emailShareMenuItem { + selectedShareType = .email + } else if selectedShareTypeItem == federatedCloudShareMenuItem { + selectedShareType = .federatedCloud + } else if selectedShareTypeItem == circleShare { + selectedShareType = .circle + } else if selectedShareTypeItem == talkConversationShare { + selectedShareType = .talkConversation + } + return selectedShareType + } + @IBAction func passwordCheckboxAction(_ sender: Any) { passwordSecureField.isHidden = passwordProtectCheckbox.state == .off } @@ -178,23 +199,7 @@ class ShareOptionsView: NSView { return } - let selectedShareTypeItem = shareTypePicker.selectedItem - var selectedShareType = NKShare.ShareType.publicLink - if selectedShareTypeItem == publicLinkShareMenuItem { - selectedShareType = .publicLink - } else if selectedShareTypeItem == userShareMenuItem { - selectedShareType = .user - } else if selectedShareTypeItem == groupShareMenuItem { - selectedShareType = .group - } else if selectedShareTypeItem == emailShareMenuItem { - selectedShareType = .email - } else if selectedShareTypeItem == federatedCloudShareMenuItem { - selectedShareType = .federatedCloud - } else if selectedShareTypeItem == circleShare { - selectedShareType = .circle - } else if selectedShareTypeItem == talkConversationShare { - selectedShareType = .talkConversation - } + let selectedShareType = pickedShareType() let shareWith = shareRecipientTextField.stringValue var permissions = NKShare.PermissionValues.all.rawValue From f7844bd1957be810856956ad0ecf7cb1edf4ea6e Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Mon, 18 Mar 2024 19:15:10 +0800 Subject: [PATCH 136/172] Update reset to make sure it also resets min and max dates in date picker, don't affect share type Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/ShareOptionsView.swift | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift index a90cd3196e09d..5b2e85b6c9c7c 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift @@ -102,8 +102,7 @@ class ShareOptionsView: NSView { } } - func reset() { - shareTypePicker.select(publicLinkShareMenuItem) + private func reset() { shareRecipientTextField.stringValue = "" labelTextField.stringValue = "" uploadEditPermissionCheckbox.state = .off @@ -114,6 +113,8 @@ class ShareOptionsView: NSView { expirationDateCheckbox.state = .off expirationDatePicker.isHidden = true expirationDatePicker.dateValue = NSDate.now + expirationDatePicker.minDate = NSDate.now + expirationDatePicker.maxDate = nil noteForRecipientCheckbox.state = .off noteTextField.isHidden = true noteTextField.stringValue = "" From 66afef1784dabf25d2bbc1938bbc579f8b242be4 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Mon, 18 Mar 2024 19:16:29 +0800 Subject: [PATCH 137/172] Setup the fields in share options view when creating a new form according to capabilities Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/ShareOptionsView.swift | 43 ++++++++++++++++++- .../ShareTableViewDataSource.swift | 2 +- 2 files changed, 42 insertions(+), 3 deletions(-) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift index 5b2e85b6c9c7c..41c9688dd061f 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift @@ -68,7 +68,7 @@ class ShareOptionsView: NSView { cancellable = nil controller = nil reset() - setAllFields(enabled: true) + setupCreateForm() } } private var cancellable: AnyCancellable? @@ -120,6 +120,45 @@ class ShareOptionsView: NSView { noteTextField.stringValue = "" } + private func setupCreateForm() { + guard createMode else { return } + + setAllFields(enabled: true) + + let type = pickedShareType() + shareRecipientTextField.isHidden = type != .publicLink + + if let caps = dataSource?.shareCapabilities { + uploadEditPermissionCheckbox.state = + caps.defaultPermissions & NKShare.PermissionValues.updateShare.rawValue != 0 + ? .on : .off + + switch type { + case .publicLink: + passwordProtectCheckbox.isHidden = false + passwordProtectCheckbox.state = caps.publicLink.enforcePassword ? .on : .off + passwordProtectCheckbox.isEnabled = !caps.publicLink.enforceExpireDate + expirationDateCheckbox.state = caps.publicLink.enforceExpireDate ? .on : .off + expirationDateCheckbox.isEnabled = !caps.publicLink.enforceExpireDate + expirationDatePicker.dateValue = Date( + timeIntervalSinceNow: + TimeInterval(caps.publicLink.expireDateDays * 24 * 60 * 60) + ) + if caps.publicLink.enforceExpireDate { + expirationDatePicker.maxDate = expirationDatePicker.dateValue + } + case .email: + passwordProtectCheckbox.isHidden = !caps.email.passwordEnabled + passwordProtectCheckbox.state = caps.email.passwordEnforced ? .on : .off + default: + break + } + } + + passwordSecureField.isHidden = passwordProtectCheckbox.state == .off + expirationDatePicker.isHidden = expirationDateCheckbox.state == .off + } + func setAllFields(enabled: Bool) { shareTypePicker.isEnabled = enabled shareRecipientTextField.isEnabled = enabled @@ -136,7 +175,7 @@ class ShareOptionsView: NSView { deleteButton.isEnabled = enabled } - func pickedShareType() -> NKShare.ShareType { + private func pickedShareType() -> NKShare.ShareType { let selectedShareTypeItem = shareTypePicker.selectedItem var selectedShareType = NKShare.ShareType.publicLink if selectedShareTypeItem == publicLinkShareMenuItem { diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift index 548f3aa94d190..e5f54996d3c92 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift @@ -24,6 +24,7 @@ class ShareTableViewDataSource: NSObject, NSTableViewDataSource, NSTableViewDele sharesTableView?.reloadData() } } + var shareCapabilities = ShareCapabilities() private(set) var kit: NextcloudKit? private(set) var itemURL: URL? @@ -43,7 +44,6 @@ class ShareTableViewDataSource: NSObject, NSTableViewDataSource, NSTableViewDele ) } } - private var shareCapabilities = ShareCapabilities() func loadItem(url: URL) { itemServerRelativePath = nil From 7a045393318ce3f08e53fb0b83eb5160edbce1e9 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Mon, 18 Mar 2024 19:17:13 +0800 Subject: [PATCH 138/172] Update form layout according to picked type when picked type changed Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/ShareOptionsView.swift | 6 ++++++ .../FileProviderUIExt/ShareViewController.xib | 3 +++ 2 files changed, 9 insertions(+) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift index 41c9688dd061f..401f013ff6e22 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift @@ -196,6 +196,12 @@ class ShareOptionsView: NSView { return selectedShareType } + @IBAction func shareTypePickerAction(_ sender: Any) { + if createMode { + setupCreateForm() + } + } + @IBAction func passwordCheckboxAction(_ sender: Any) { passwordSecureField.isHidden = passwordProtectCheckbox.state == .off } diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib index 857d01cbb3ebf..a797c5e9b1d31 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib @@ -257,6 +257,9 @@ + + + From 7adc380a675dcdc5a6b897e4dee9822f671c4b5c Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Mon, 18 Mar 2024 19:18:27 +0800 Subject: [PATCH 139/172] Fix password capabilities for public link capabilities Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/ShareCapabilities.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareCapabilities.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareCapabilities.swift index 497d803e5baa1..6560a9d8d0bc1 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareCapabilities.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareCapabilities.swift @@ -41,9 +41,9 @@ struct ShareCapabilities { supportsUploadOnly = dict["supports_upload_only"] as? Bool ?? false multipleAllowed = dict["multiple"] as? Bool ?? false - if let passwordCapabilities = dict["password"] as? [String : Any] { - askOptionalPassword = dict["askForOptionalPassword"] as? Bool ?? false - enforcePassword = dict["enforced"] as? Bool ?? false + if let passwordCaps = dict["password"] as? [String : Any] { + askOptionalPassword = passwordCaps["askForOptionalPassword"] as? Bool ?? false + enforcePassword = passwordCaps["enforced"] as? Bool ?? false } if let expireDateCapabilities = dict["expire_date"] as? [String: Any] { From f8f87aec095e2dde09b8dd6535ac30b448dcf124 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Mon, 18 Mar 2024 19:58:30 +0800 Subject: [PATCH 140/172] Fix ShareCapabilities parsing Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/ShareCapabilities.swift | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareCapabilities.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareCapabilities.swift index 6560a9d8d0bc1..61f454809aebf 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareCapabilities.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareCapabilities.swift @@ -75,11 +75,24 @@ struct ShareCapabilities { } init(json: Data) { - guard let anyJson = try? JSONSerialization.jsonObject(with: json, options: []), - let jsonDict = anyJson as? [String : Any], - let sharingCapabilities = jsonDict["files_sharing"] as? [String : Any] + guard let anyJson = try? JSONSerialization.jsonObject(with: json, options: []) else { + let jsonString = String(data: json, encoding: .utf8) ?? "UNKNOWN" + Logger.shareCapabilities.error( + "Received capabilities is not valid JSON! \(jsonString, privacy: .public)" + ) + return + } + + guard let jsonDict = anyJson as? [String : Any], + let ocsData = jsonDict["ocs"] as? [String : Any], + let receivedData = ocsData["data"] as? [String : Any], + let capabilities = receivedData["capabilities"] as? [String : Any], + let sharingCapabilities = capabilities["files_sharing"] as? [String : Any] else { - Logger.shareCapabilities.error("Could not parse share capabilities!") + let jsonString = anyJson as? [String : Any] ?? ["UNKNOWN" : "UNKNOWN"] + Logger.shareCapabilities.error( + "Could not parse share capabilities! \(jsonString, privacy: .public)" + ) return } apiEnabled = sharingCapabilities["api_enabled"] as? Bool ?? false From b4fd20dae84ff6e8500dd378a996b7cceee8a422 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Mon, 18 Mar 2024 20:14:22 +0800 Subject: [PATCH 141/172] Fix default states around passwords for share options view Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/ShareOptionsView.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift index 401f013ff6e22..4b64d2e08fded 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift @@ -126,7 +126,7 @@ class ShareOptionsView: NSView { setAllFields(enabled: true) let type = pickedShareType() - shareRecipientTextField.isHidden = type != .publicLink + shareRecipientTextField.isHidden = type == .publicLink if let caps = dataSource?.shareCapabilities { uploadEditPermissionCheckbox.state = @@ -137,7 +137,7 @@ class ShareOptionsView: NSView { case .publicLink: passwordProtectCheckbox.isHidden = false passwordProtectCheckbox.state = caps.publicLink.enforcePassword ? .on : .off - passwordProtectCheckbox.isEnabled = !caps.publicLink.enforceExpireDate + passwordProtectCheckbox.isEnabled = !caps.publicLink.enforcePassword expirationDateCheckbox.state = caps.publicLink.enforceExpireDate ? .on : .off expirationDateCheckbox.isEnabled = !caps.publicLink.enforceExpireDate expirationDatePicker.dateValue = Date( @@ -151,6 +151,8 @@ class ShareOptionsView: NSView { passwordProtectCheckbox.isHidden = !caps.email.passwordEnabled passwordProtectCheckbox.state = caps.email.passwordEnforced ? .on : .off default: + passwordProtectCheckbox.isHidden = true + passwordProtectCheckbox.state = .off break } } From cea99f021974652e155c6ffcac8bd4c511bf5fea Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Mon, 18 Mar 2024 20:14:31 +0800 Subject: [PATCH 142/172] Add more debug logging to sharecapabilities Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/ShareCapabilities.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareCapabilities.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareCapabilities.swift index 61f454809aebf..747802c2787a7 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareCapabilities.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareCapabilities.swift @@ -14,6 +14,8 @@ struct ShareCapabilities { private(set) var passwordEnforced = false init(dict: [String: Any]) { + Logger.shareCapabilities.debug("Parsing email capabilities: \(dict, privacy: .public)") + if let passwordCapabilities = dict["password"] as? [String : Any] { passwordEnabled = passwordCapabilities["enabled"] as? Bool ?? false passwordEnforced = passwordCapabilities["enforced"] as? Bool ?? false @@ -36,6 +38,8 @@ struct ShareCapabilities { private(set) var multipleAllowed = false init(dict: [String: Any]) { + Logger.shareCapabilities.debug("Parsing link capabilities: \(dict, privacy: .public)") + enabled = dict["enabled"] as? Bool ?? false allowUpload = dict["upload"] as? Bool ?? false supportsUploadOnly = dict["supports_upload_only"] as? Bool ?? false From 64c40faff47f2f94d8aa9e03b707aacfa5ab06cc Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Tue, 19 Mar 2024 18:57:28 +0800 Subject: [PATCH 143/172] Add method to ShareTableViewDataSource to fetch the given item's metadata Signed-off-by: Claudio Cambra --- .../ShareTableViewDataSource.swift | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift index e5f54996d3c92..7c03ef60f3741 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift @@ -163,6 +163,23 @@ class ShareTableViewDataSource: NSObject, NSTableViewDataSource, NSTableViewDele } } + private func fetchItemMetadata(itemRelativePath: String) async -> NKFile? { + return await withCheckedContinuation { continuation in + kit?.readFileOrFolder(serverUrlFileName: itemRelativePath, depth: "0") { + account, files, data, error in + guard error == .success else { + let errorString = "Error getting item metadata: \(error.errorDescription)" + Logger.sharesDataSource.error("\(errorString)") + Task { @MainActor in self.uiDelegate?.showError(errorString) } + continuation.resume(returning: nil) + return + } + Logger.sharesDataSource.info("Successfully retrieved item metadata") + continuation.resume(returning: files.first) + } + } + } + // MARK: - NSTableViewDataSource protocol methods @objc func numberOfRows(in tableView: NSTableView) -> Int { From d1dafc125823311ff723cb5d66d3c790d1f81d49 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Tue, 19 Mar 2024 18:57:52 +0800 Subject: [PATCH 144/172] Check if the given item is shareable before fetching shares Signed-off-by: Claudio Cambra --- .../ShareTableViewDataSource.swift | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift index 7c03ef60f3741..cab0f43a42513 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift @@ -25,6 +25,7 @@ class ShareTableViewDataSource: NSObject, NSTableViewDataSource, NSTableViewDele } } var shareCapabilities = ShareCapabilities() + var itemMetadata: NKFile? private(set) var kit: NextcloudKit? private(set) var itemURL: URL? @@ -79,7 +80,8 @@ class ShareTableViewDataSource: NSObject, NSTableViewDataSource, NSTableViewDele Logger.sharesDataSource.error("Failed to get details from FileProviderExt") return } - itemServerRelativePath = serverPath as String + let serverPathString = serverPath as String + itemServerRelativePath = serverPathString account = convertedAccount await sharesTableView?.deselectAll(self) shareCapabilities = await fetchCapabilities() @@ -89,8 +91,15 @@ class ShareTableViewDataSource: NSObject, NSTableViewDataSource, NSTableViewDele uiDelegate?.showError(errorMsg) return } + itemMetadata = await fetchItemMetadata(itemRelativePath: serverPathString) + guard itemMetadata?.permissions.contains("S") == true else { + let errorMsg = "This file cannot be shared." + Logger.sharesDataSource.warning("\(errorMsg)") + uiDelegate?.showError(errorMsg) + return + } shares = await fetch( - itemIdentifier: itemIdentifier, itemRelativePath: serverPath as String + itemIdentifier: itemIdentifier, itemRelativePath: serverPathString ) } catch let error { Logger.sharesDataSource.error("Could not reload data: \(error, privacy: .public)") From c902bb0b90cc36f74904ce53bee04410124420e6 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Tue, 19 Mar 2024 19:05:54 +0800 Subject: [PATCH 145/172] Ensure interpolated logging string in share table view data source is public Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/ShareTableViewDataSource.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift index cab0f43a42513..db7bf883b1846 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift @@ -161,7 +161,7 @@ class ShareTableViewDataSource: NSObject, NSTableViewDataSource, NSTableViewDele kit?.getCapabilities { account, capabilitiesJson, error in guard error == .success, let capabilitiesJson = capabilitiesJson else { let errorString = "Error getting server capabilities: \(error.errorDescription)" - Logger.sharesDataSource.error("\(errorString)") + Logger.sharesDataSource.error("\(errorString, privacy: .public)") Task { @MainActor in self.uiDelegate?.showError(errorString) } continuation.resume(returning: ShareCapabilities()) return @@ -178,7 +178,7 @@ class ShareTableViewDataSource: NSObject, NSTableViewDataSource, NSTableViewDele account, files, data, error in guard error == .success else { let errorString = "Error getting item metadata: \(error.errorDescription)" - Logger.sharesDataSource.error("\(errorString)") + Logger.sharesDataSource.error("\(errorString, privacy: .public)") Task { @MainActor in self.uiDelegate?.showError(errorString) } continuation.resume(returning: nil) return From de4709c928df2e2bd86f99a024933d0bb6402b03 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Tue, 19 Mar 2024 19:38:41 +0800 Subject: [PATCH 146/172] Fix scan path to retrieve item metadata in share table view data source Signed-off-by: Claudio Cambra --- .../ShareTableViewDataSource.swift | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift index db7bf883b1846..c55306093e4ce 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift @@ -173,8 +173,33 @@ class ShareTableViewDataSource: NSObject, NSTableViewDataSource, NSTableViewDele } private func fetchItemMetadata(itemRelativePath: String) async -> NKFile? { + guard let kit = kit else { + let errorString = "Could not fetch item metadata as nckit unavailable" + Logger.sharesDataSource.error("\(errorString, privacy: .public)") + Task { @MainActor in self.uiDelegate?.showError(errorString) } + return nil + } + + func slashlessPath(_ string: String) -> String { + var strCopy = string + if strCopy.hasPrefix("/") { + strCopy.removeFirst() + } + if strCopy.hasSuffix("/") { + strCopy.removeLast() + } + return strCopy + } + + let nkCommon = kit.nkCommonInstance + let urlBase = slashlessPath(nkCommon.urlBase) + let davSuffix = slashlessPath(nkCommon.dav) + let userId = nkCommon.userId + let itemRelPath = slashlessPath(itemRelativePath) + + let itemFullServerPath = "\(urlBase)/\(davSuffix)/files/\(userId)/\(itemRelPath)" return await withCheckedContinuation { continuation in - kit?.readFileOrFolder(serverUrlFileName: itemRelativePath, depth: "0") { + kit.readFileOrFolder(serverUrlFileName: itemFullServerPath, depth: "0") { account, files, data, error in guard error == .success else { let errorString = "Error getting item metadata: \(error.errorDescription)" From 8745b813eca957623be45926d066d497ec04c00e Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Tue, 19 Mar 2024 19:38:56 +0800 Subject: [PATCH 147/172] Fix letter used to identify shareability in sharetableviewdatasource Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/ShareTableViewDataSource.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift index c55306093e4ce..a4184e18028fe 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift @@ -92,7 +92,7 @@ class ShareTableViewDataSource: NSObject, NSTableViewDataSource, NSTableViewDele return } itemMetadata = await fetchItemMetadata(itemRelativePath: serverPathString) - guard itemMetadata?.permissions.contains("S") == true else { + guard itemMetadata?.permissions.contains("R") == true else { let errorMsg = "This file cannot be shared." Logger.sharesDataSource.warning("\(errorMsg)") uiDelegate?.showError(errorMsg) From f166d854b67c607847044ac0132d9d0920ac7199 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Tue, 19 Mar 2024 20:08:14 +0800 Subject: [PATCH 148/172] Fix options view disappearing when clicking create button in share view controller Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/ShareOptionsView.swift | 6 ++--- .../ShareTableViewDataSource.swift | 2 +- .../ShareViewController.swift | 24 +++++++++++++------ .../ShareViewDataSourceUIDelegate.swift | 2 +- 4 files changed, 22 insertions(+), 12 deletions(-) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift index 4b64d2e08fded..d8231de288f0b 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift @@ -274,7 +274,7 @@ class ShareOptionsView: NSView { dataSource.uiDelegate?.showError("Error creating: \(error.errorDescription)") setAllFields(enabled: true) } else { - dataSource.uiDelegate?.hideOptions() + dataSource.uiDelegate?.hideOptions(self) await dataSource.reload() } return @@ -306,7 +306,7 @@ class ShareOptionsView: NSView { dataSource?.uiDelegate?.showError("Error updating share: \(error.errorDescription)") setAllFields(enabled: true) } else { - dataSource?.uiDelegate?.hideOptions() + dataSource?.uiDelegate?.hideOptions(self) await dataSource?.reload() } } @@ -315,7 +315,7 @@ class ShareOptionsView: NSView { @IBAction func delete(_ sender: Any) { Task { @MainActor in guard !createMode else { - dataSource?.uiDelegate?.hideOptions() + dataSource?.uiDelegate?.hideOptions(self) reset() return } diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift index a4184e18028fe..312e59cf1fc9b 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift @@ -238,7 +238,7 @@ class ShareTableViewDataSource: NSObject, NSTableViewDataSource, NSTableViewDele @objc func tableViewSelectionDidChange(_ notification: Notification) { guard let selectedRow = sharesTableView?.selectedRow, selectedRow >= 0 else { - Task { @MainActor in uiDelegate?.hideOptions() } + Task { @MainActor in uiDelegate?.hideOptions(self) } return } let share = shares[selectedRow] diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift index dd57050f5e88b..d104e3360899d 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift @@ -57,7 +57,7 @@ class ShareViewController: NSViewController, ShareViewDataSourceUIDelegate { override func viewDidLoad() { dismissError(self) - hideOptions() + hideOptions(self) } @IBAction func closeAction(_ sender: Any) { @@ -111,10 +111,12 @@ class ShareViewController: NSViewController, ShareViewDataSourceUIDelegate { } @IBAction func createShare(_ sender: Any) { - tableView.deselectAll(self) optionsView.createMode = true - splitView.addArrangedSubview(optionsView) - optionsView.isHidden = false + tableView.deselectAll(self) + if !splitView.arrangedSubviews.contains(optionsView) { + splitView.addArrangedSubview(optionsView) + optionsView.isHidden = false + } } func fetchStarted() { @@ -127,16 +129,24 @@ class ShareViewController: NSViewController, ShareViewDataSourceUIDelegate { loadingIndicator.stopAnimation(self) } - func hideOptions() { + func hideOptions(_ sender: Any) { + if sender as? ShareTableViewDataSource == shareDataSource, optionsView.createMode { + // Do not hide options if the table view has had everything deselected when we set the + // options view to be in create mode + return + } splitView.removeArrangedSubview(optionsView) optionsView.isHidden = true + } func showOptions(share: NKShare) { guard let kit = shareDataSource.kit else { return } optionsView.controller = ShareController(share: share, kit: kit) - splitView.addArrangedSubview(optionsView) - optionsView.isHidden = false + if !splitView.arrangedSubviews.contains(optionsView) { + splitView.addArrangedSubview(optionsView) + optionsView.isHidden = false + } } func showError(_ errorString: String) { diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewDataSourceUIDelegate.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewDataSourceUIDelegate.swift index 615de16b4f7a3..09bd3f7e4945b 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewDataSourceUIDelegate.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewDataSourceUIDelegate.swift @@ -11,7 +11,7 @@ import NextcloudKit protocol ShareViewDataSourceUIDelegate { func fetchStarted() func fetchFinished() - func hideOptions() + func hideOptions(_ sender: Any) func showOptions(share: NKShare) func showError(_ errorString: String) } From aa84ed15144b54b5e66e522ecb4d2591fbd1d1ce Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Tue, 19 Mar 2024 20:19:16 +0800 Subject: [PATCH 149/172] Deduplicate error presentation in ShareTableViewDataSource Signed-off-by: Claudio Cambra --- .../ShareTableViewDataSource.swift | 41 ++++++++----------- 1 file changed, 17 insertions(+), 24 deletions(-) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift index 312e59cf1fc9b..8a6565c74e70e 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift @@ -63,12 +63,12 @@ class ShareTableViewDataSource: NSObject, NSTableViewDataSource, NSTableViewDele ) { identifier, domainIdentifier, error in defer { continuation.resume(returning: identifier) } guard error == nil else { - Logger.sharesDataSource.error("No identifier: \(error, privacy: .public)") + self.presentError("No item with identifier: \(error.debugDescription)") return } } }) else { - Logger.sharesDataSource.error("Could not get identifier for item, no shares.") + presentError("Could not get identifier for item, no shares can be acquired.") return } @@ -77,7 +77,7 @@ class ShareTableViewDataSource: NSObject, NSTableViewDataSource, NSTableViewDele guard let serverPath = await connection.itemServerPath(identifier: itemIdentifier), let credentials = await connection.credentials() as? Dictionary, let convertedAccount = NextcloudAccount(dictionary: credentials) else { - Logger.sharesDataSource.error("Failed to get details from FileProviderExt") + presentError("Failed to get details from FileProviderExt") return } let serverPathString = serverPath as String @@ -86,23 +86,19 @@ class ShareTableViewDataSource: NSObject, NSTableViewDataSource, NSTableViewDele await sharesTableView?.deselectAll(self) shareCapabilities = await fetchCapabilities() guard shareCapabilities.apiEnabled else { - let errorMsg = "Server does not support shares." - Logger.sharesDataSource.info("\(errorMsg)") - uiDelegate?.showError(errorMsg) + presentError("Server does not support shares.") return } itemMetadata = await fetchItemMetadata(itemRelativePath: serverPathString) guard itemMetadata?.permissions.contains("R") == true else { - let errorMsg = "This file cannot be shared." - Logger.sharesDataSource.warning("\(errorMsg)") - uiDelegate?.showError(errorMsg) + presentError("This file cannot be shared.") return } shares = await fetch( itemIdentifier: itemIdentifier, itemRelativePath: serverPathString ) } catch let error { - Logger.sharesDataSource.error("Could not reload data: \(error, privacy: .public)") + presentError("Could not reload data: \(error)") } } @@ -135,7 +131,7 @@ class ShareTableViewDataSource: NSObject, NSTableViewDataSource, NSTableViewDele Logger.sharesDataSource.info("Fetching shares for item \(rawIdentifier, privacy: .public)") guard let kit = kit else { - Logger.sharesDataSource.error("NextcloudKit instance is nil") + self.presentError("NextcloudKit instance is unavailable, cannot fetch shares!") return [] } @@ -147,9 +143,7 @@ class ShareTableViewDataSource: NSObject, NSTableViewDataSource, NSTableViewDele Logger.sharesDataSource.info("Received \(shareCount, privacy: .public) shares") defer { continuation.resume(returning: shares ?? []) } guard error == .success else { - let errorString = "Error fetching shares: \(error.errorDescription)" - Logger.sharesDataSource.error("\(errorString)") - Task { @MainActor in self.uiDelegate?.showError(errorString) } + self.presentError("Error fetching shares: \(error.errorDescription)") return } } @@ -160,9 +154,7 @@ class ShareTableViewDataSource: NSObject, NSTableViewDataSource, NSTableViewDele return await withCheckedContinuation { continuation in kit?.getCapabilities { account, capabilitiesJson, error in guard error == .success, let capabilitiesJson = capabilitiesJson else { - let errorString = "Error getting server capabilities: \(error.errorDescription)" - Logger.sharesDataSource.error("\(errorString, privacy: .public)") - Task { @MainActor in self.uiDelegate?.showError(errorString) } + self.presentError("Error getting server capabilities: \(error.errorDescription)") continuation.resume(returning: ShareCapabilities()) return } @@ -174,9 +166,7 @@ class ShareTableViewDataSource: NSObject, NSTableViewDataSource, NSTableViewDele private func fetchItemMetadata(itemRelativePath: String) async -> NKFile? { guard let kit = kit else { - let errorString = "Could not fetch item metadata as nckit unavailable" - Logger.sharesDataSource.error("\(errorString, privacy: .public)") - Task { @MainActor in self.uiDelegate?.showError(errorString) } + presentError("Could not fetch item metadata as NextcloudKit instance is unavailable") return nil } @@ -202,9 +192,7 @@ class ShareTableViewDataSource: NSObject, NSTableViewDataSource, NSTableViewDele kit.readFileOrFolder(serverUrlFileName: itemFullServerPath, depth: "0") { account, files, data, error in guard error == .success else { - let errorString = "Error getting item metadata: \(error.errorDescription)" - Logger.sharesDataSource.error("\(errorString, privacy: .public)") - Task { @MainActor in self.uiDelegate?.showError(errorString) } + self.presentError("Error getting item metadata: \(error.errorDescription)") continuation.resume(returning: nil) return } @@ -214,6 +202,11 @@ class ShareTableViewDataSource: NSObject, NSTableViewDataSource, NSTableViewDele } } + private func presentError(_ errorString: String) { + Logger.sharesDataSource.error("\(errorString, privacy: .public)") + Task { @MainActor in self.uiDelegate?.showError(errorString) } + } + // MARK: - NSTableViewDataSource protocol methods @objc func numberOfRows(in tableView: NSTableView) -> Int { @@ -229,7 +222,7 @@ class ShareTableViewDataSource: NSObject, NSTableViewDataSource, NSTableViewDele guard let view = tableView.makeView( withIdentifier: shareItemViewIdentifier, owner: self ) as? ShareTableItemView else { - Logger.sharesDataSource.error("Acquired item view from table is not a Share item view!") + Logger.sharesDataSource.error("Acquired item view from table is not a share item view!") return nil } view.share = share From 97f2c4311871867e02fcb61aae667ee0d7396dd8 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Tue, 19 Mar 2024 20:54:41 +0800 Subject: [PATCH 150/172] Retry getting information from FileProviderExt if doing so has failed (usually due to opening share view before auth details are present) Signed-off-by: Claudio Cambra --- .../ShareTableViewDataSource.swift | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift index 8a6565c74e70e..d61d38b73ce42 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift @@ -13,6 +13,7 @@ import OSLog class ShareTableViewDataSource: NSObject, NSTableViewDataSource, NSTableViewDelegate { private let shareItemViewIdentifier = NSUserInterfaceItemIdentifier("ShareTableItemView") private let shareItemViewNib = NSNib(nibNamed: "ShareTableItemView", bundle: nil) + private let reattemptInterval: TimeInterval = 3.0 var uiDelegate: ShareViewDataSourceUIDelegate? var sharesTableView: NSTableView? { @@ -54,6 +55,14 @@ class ShareTableViewDataSource: NSObject, NSTableViewDataSource, NSTableViewDele } } + func reattempt() { + DispatchQueue.main.async { + Timer.scheduledTimer(withTimeInterval: self.reattemptInterval, repeats: false) { _ in + Task { await self.reload() } + } + } + } + func reload() async { guard let itemURL = itemURL else { return } guard let itemIdentifier = await withCheckedContinuation({ @@ -76,8 +85,11 @@ class ShareTableViewDataSource: NSObject, NSTableViewDataSource, NSTableViewDele let connection = try await serviceConnection(url: itemURL) guard let serverPath = await connection.itemServerPath(identifier: itemIdentifier), let credentials = await connection.credentials() as? Dictionary, - let convertedAccount = NextcloudAccount(dictionary: credentials) else { - presentError("Failed to get details from FileProviderExt") + let convertedAccount = NextcloudAccount(dictionary: credentials), + !convertedAccount.password.isEmpty + else { + presentError("Failed to get details from File Provider Extension. Retrying.") + reattempt() return } let serverPathString = serverPath as String @@ -98,7 +110,8 @@ class ShareTableViewDataSource: NSObject, NSTableViewDataSource, NSTableViewDele itemIdentifier: itemIdentifier, itemRelativePath: serverPathString ) } catch let error { - presentError("Could not reload data: \(error)") + presentError("Could not reload data: \(error), will try again.") + reattempt() } } From 9de6655d4318f5669f6505f7f2b96e5f17e3c165 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 20 Mar 2024 02:26:35 +0800 Subject: [PATCH 151/172] Add package dependency NextcloudCapabilitiesKit to NextcloudIntegration Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/ShareCapabilities.swift | 114 ------------------ .../FileProviderUIExt/ShareOptionsView.swift | 18 +-- .../ShareTableViewDataSource.swift | 15 +-- .../project.pbxproj | 21 +++- 4 files changed, 34 insertions(+), 134 deletions(-) delete mode 100644 shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareCapabilities.swift diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareCapabilities.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareCapabilities.swift deleted file mode 100644 index 747802c2787a7..0000000000000 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareCapabilities.swift +++ /dev/null @@ -1,114 +0,0 @@ -// -// ShareCapabilities.swift -// FileProviderUIExt -// -// Created by Claudio Cambra on 13/3/24. -// - -import Foundation -import OSLog - -struct ShareCapabilities { - struct EmailCapabilities { - private(set) var passwordEnabled = false - private(set) var passwordEnforced = false - - init(dict: [String: Any]) { - Logger.shareCapabilities.debug("Parsing email capabilities: \(dict, privacy: .public)") - - if let passwordCapabilities = dict["password"] as? [String : Any] { - passwordEnabled = passwordCapabilities["enabled"] as? Bool ?? false - passwordEnforced = passwordCapabilities["enforced"] as? Bool ?? false - } - } - } - - struct PublicLinkCapabilities { - private(set) var enabled = false - private(set) var allowUpload = false - private(set) var supportsUploadOnly = false - private(set) var askOptionalPassword = false - private(set) var enforcePassword = false - private(set) var enforceExpireDate = false - private(set) var expireDateDays = 1 - private(set) var internalEnforceExpireDate = false - private(set) var internalExpireDateDays = 1 - private(set) var remoteEnforceExpireDate = false - private(set) var remoteExpireDateDays = 1 - private(set) var multipleAllowed = false - - init(dict: [String: Any]) { - Logger.shareCapabilities.debug("Parsing link capabilities: \(dict, privacy: .public)") - - enabled = dict["enabled"] as? Bool ?? false - allowUpload = dict["upload"] as? Bool ?? false - supportsUploadOnly = dict["supports_upload_only"] as? Bool ?? false - multipleAllowed = dict["multiple"] as? Bool ?? false - - if let passwordCaps = dict["password"] as? [String : Any] { - askOptionalPassword = passwordCaps["askForOptionalPassword"] as? Bool ?? false - enforcePassword = passwordCaps["enforced"] as? Bool ?? false - } - - if let expireDateCapabilities = dict["expire_date"] as? [String: Any] { - expireDateDays = expireDateCapabilities["days"] as? Int ?? 1 - enforceExpireDate = expireDateCapabilities["enforced"] as? Bool ?? false - } - - if let internalExpDateCaps = dict["expire_date_internal"] as? [String: Any] { - internalExpireDateDays = internalExpDateCaps["days"] as? Int ?? 1 - internalEnforceExpireDate = internalExpDateCaps["enforced"] as? Bool ?? false - } - - if let remoteExpDateCaps = dict["expire_date_remote"] as? [String: Any] { - remoteExpireDateDays = remoteExpDateCaps["days"] as? Int ?? 1 - remoteEnforceExpireDate = remoteExpDateCaps["enforced"] as? Bool ?? false - } - } - } - - private(set) var apiEnabled = false - private(set) var resharing = false - private(set) var defaultPermissions = 0 - private(set) var email = EmailCapabilities(dict: [:]) - private(set) var publicLink = PublicLinkCapabilities(dict: [:]) - - - init() { - Logger.shareCapabilities.warning("Providing defaulted share capabilities!") - } - - init(json: Data) { - guard let anyJson = try? JSONSerialization.jsonObject(with: json, options: []) else { - let jsonString = String(data: json, encoding: .utf8) ?? "UNKNOWN" - Logger.shareCapabilities.error( - "Received capabilities is not valid JSON! \(jsonString, privacy: .public)" - ) - return - } - - guard let jsonDict = anyJson as? [String : Any], - let ocsData = jsonDict["ocs"] as? [String : Any], - let receivedData = ocsData["data"] as? [String : Any], - let capabilities = receivedData["capabilities"] as? [String : Any], - let sharingCapabilities = capabilities["files_sharing"] as? [String : Any] - else { - let jsonString = anyJson as? [String : Any] ?? ["UNKNOWN" : "UNKNOWN"] - Logger.shareCapabilities.error( - "Could not parse share capabilities! \(jsonString, privacy: .public)" - ) - return - } - apiEnabled = sharingCapabilities["api_enabled"] as? Bool ?? false - - if let emailCapabilities = sharingCapabilities["sharebymail"] as? [String : Any] { - email = EmailCapabilities(dict: emailCapabilities) - } - - if let publicLinkCapabilities = sharingCapabilities["public"] as? [String : Any] { - publicLink = PublicLinkCapabilities(dict: publicLinkCapabilities) - } - - Logger.shareCapabilities.debug("Parses share capabilities.") - } -} diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift index d8231de288f0b..1a9d51fa81b50 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift @@ -128,7 +128,7 @@ class ShareOptionsView: NSView { let type = pickedShareType() shareRecipientTextField.isHidden = type == .publicLink - if let caps = dataSource?.shareCapabilities { + if let caps = dataSource?.capabilities?.filesSharing { uploadEditPermissionCheckbox.state = caps.defaultPermissions & NKShare.PermissionValues.updateShare.rawValue != 0 ? .on : .off @@ -136,20 +136,20 @@ class ShareOptionsView: NSView { switch type { case .publicLink: passwordProtectCheckbox.isHidden = false - passwordProtectCheckbox.state = caps.publicLink.enforcePassword ? .on : .off - passwordProtectCheckbox.isEnabled = !caps.publicLink.enforcePassword - expirationDateCheckbox.state = caps.publicLink.enforceExpireDate ? .on : .off - expirationDateCheckbox.isEnabled = !caps.publicLink.enforceExpireDate + passwordProtectCheckbox.state = caps.publicLink?.passwordEnforced == true ? .on : .off + passwordProtectCheckbox.isEnabled = caps.publicLink?.passwordEnforced == false + expirationDateCheckbox.state = caps.publicLink?.expireDateEnforced == true ? .on : .off + expirationDateCheckbox.isEnabled = caps.publicLink?.expireDateEnforced == false expirationDatePicker.dateValue = Date( timeIntervalSinceNow: - TimeInterval(caps.publicLink.expireDateDays * 24 * 60 * 60) + TimeInterval((caps.publicLink?.expireDateDays ?? 1) * 24 * 60 * 60) ) - if caps.publicLink.enforceExpireDate { + if caps.publicLink?.expireDateEnforced == true { expirationDatePicker.maxDate = expirationDatePicker.dateValue } case .email: - passwordProtectCheckbox.isHidden = !caps.email.passwordEnabled - passwordProtectCheckbox.state = caps.email.passwordEnforced ? .on : .off + passwordProtectCheckbox.isHidden = caps.email?.passwordEnabled == false + passwordProtectCheckbox.state = caps.email?.passwordEnforced == true ? .on : .off default: passwordProtectCheckbox.isHidden = true passwordProtectCheckbox.state = .off diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift index d61d38b73ce42..cf8087bc46724 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift @@ -8,6 +8,7 @@ import AppKit import FileProvider import NextcloudKit +import NextcloudCapabilitiesKit import OSLog class ShareTableViewDataSource: NSObject, NSTableViewDataSource, NSTableViewDelegate { @@ -25,7 +26,7 @@ class ShareTableViewDataSource: NSObject, NSTableViewDataSource, NSTableViewDele sharesTableView?.reloadData() } } - var shareCapabilities = ShareCapabilities() + var capabilities: Capabilities? var itemMetadata: NKFile? private(set) var kit: NextcloudKit? @@ -96,8 +97,8 @@ class ShareTableViewDataSource: NSObject, NSTableViewDataSource, NSTableViewDele itemServerRelativePath = serverPathString account = convertedAccount await sharesTableView?.deselectAll(self) - shareCapabilities = await fetchCapabilities() - guard shareCapabilities.apiEnabled else { + capabilities = await fetchCapabilities() + guard capabilities?.filesSharing?.apiEnabled == true else { presentError("Server does not support shares.") return } @@ -163,16 +164,16 @@ class ShareTableViewDataSource: NSObject, NSTableViewDataSource, NSTableViewDele } } - private func fetchCapabilities() async -> ShareCapabilities { + private func fetchCapabilities() async -> Capabilities? { return await withCheckedContinuation { continuation in kit?.getCapabilities { account, capabilitiesJson, error in guard error == .success, let capabilitiesJson = capabilitiesJson else { - self.presentError("Error getting server capabilities: \(error.errorDescription)") - continuation.resume(returning: ShareCapabilities()) + self.presentError("Error getting server caps: \(error.errorDescription)") + continuation.resume(returning: nil) return } Logger.sharesDataSource.info("Successfully retrieved server share capabilities") - continuation.resume(returning: ShareCapabilities(json: capabilitiesJson)) + continuation.resume(returning: Capabilities(data: capabilitiesJson)) } } } diff --git a/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj b/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj index 98460d511d39b..421fc64e9dee7 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj +++ b/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj @@ -16,12 +16,12 @@ 5318AD9529BF438F00CBB71C /* NextcloudLocalFileMetadataTable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5318AD9429BF438F00CBB71C /* NextcloudLocalFileMetadataTable.swift */; }; 5318AD9729BF493600CBB71C /* FileProviderMaterialisedEnumerationObserver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5318AD9629BF493600CBB71C /* FileProviderMaterialisedEnumerationObserver.swift */; }; 5318AD9929BF58D000CBB71C /* NKError+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5318AD9829BF58D000CBB71C /* NKError+Extensions.swift */; }; - 534F812F2BA1B3D80068D145 /* ShareCapabilities.swift in Sources */ = {isa = PBXBuildFile; fileRef = 534F812E2BA1B3D80068D145 /* ShareCapabilities.swift */; }; 5350E4E92B0C534A00F276CB /* ClientCommunicationService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5350E4E82B0C534A00F276CB /* ClientCommunicationService.swift */; }; 5352B36629DC14970011CE03 /* NextcloudFilesDatabaseManager+Directories.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5352B36529DC14970011CE03 /* NextcloudFilesDatabaseManager+Directories.swift */; }; 5352B36829DC17D60011CE03 /* NextcloudFilesDatabaseManager+LocalFiles.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5352B36729DC17D60011CE03 /* NextcloudFilesDatabaseManager+LocalFiles.swift */; }; 5352B36C29DC44B50011CE03 /* FileProviderExtension+Thumbnailing.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5352B36B29DC44B50011CE03 /* FileProviderExtension+Thumbnailing.swift */; }; 5352E85B29B7BFE6002CE85C /* Progress+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5352E85A29B7BFE6002CE85C /* Progress+Extensions.swift */; }; + 5358F2B92BAA0F5300E3C729 /* NextcloudCapabilitiesKit in Frameworks */ = {isa = PBXBuildFile; productRef = 5358F2B82BAA0F5300E3C729 /* NextcloudCapabilitiesKit */; }; 535AE30E29C0A2CC0042A9BA /* Logger+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 535AE30D29C0A2CC0042A9BA /* Logger+Extensions.swift */; }; 536EFBF7295CF58100F4CB13 /* FileProviderSocketLineProcessor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 536EFBF6295CF58100F4CB13 /* FileProviderSocketLineProcessor.swift */; }; 536EFC36295E3C1100F4CB13 /* NextcloudAccount.swift in Sources */ = {isa = PBXBuildFile; fileRef = 536EFC35295E3C1100F4CB13 /* NextcloudAccount.swift */; }; @@ -165,7 +165,6 @@ 5318AD9429BF438F00CBB71C /* NextcloudLocalFileMetadataTable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NextcloudLocalFileMetadataTable.swift; sourceTree = ""; }; 5318AD9629BF493600CBB71C /* FileProviderMaterialisedEnumerationObserver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileProviderMaterialisedEnumerationObserver.swift; sourceTree = ""; }; 5318AD9829BF58D000CBB71C /* NKError+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NKError+Extensions.swift"; sourceTree = ""; }; - 534F812E2BA1B3D80068D145 /* ShareCapabilities.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareCapabilities.swift; sourceTree = ""; }; 5350E4E72B0C514400F276CB /* ClientCommunicationProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ClientCommunicationProtocol.h; sourceTree = ""; }; 5350E4E82B0C534A00F276CB /* ClientCommunicationService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClientCommunicationService.swift; sourceTree = ""; }; 5350E4EA2B0C9CE100F276CB /* FileProviderExt-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "FileProviderExt-Bridging-Header.h"; sourceTree = ""; }; @@ -250,6 +249,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 5358F2B92BAA0F5300E3C729 /* NextcloudCapabilitiesKit in Frameworks */, 53FE14542B8E1219006C4193 /* NextcloudKit in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -365,7 +365,6 @@ children = ( 5376307B2B85E2E00026BFAB /* Extensions */, 53B979802B84C81F002DA742 /* DocumentActionViewController.swift */, - 534F812E2BA1B3D80068D145 /* ShareCapabilities.swift */, 5374FD432B95EE1400C78D54 /* ShareController.swift */, 53FE14662B8F78B6006C4193 /* ShareOptionsView.swift */, 53FE14582B8E3F6C006C4193 /* ShareTableItemView.swift */, @@ -523,6 +522,7 @@ name = FileProviderUIExt; packageProductDependencies = ( 53FE14532B8E1219006C4193 /* NextcloudKit */, + 5358F2B82BAA0F5300E3C729 /* NextcloudCapabilitiesKit */, ); productName = FileProviderUIExt; productReference = 53B9797E2B84C81F002DA742 /* FileProviderUIExt.appex */; @@ -623,6 +623,7 @@ packageReferences = ( 5307A6E42965C6FA001E0C6A /* XCRemoteSwiftPackageReference "NextcloudKit" */, 5307A6E92965DB57001E0C6A /* XCRemoteSwiftPackageReference "realm-swift" */, + 5358F2B72BAA045E00E3C729 /* XCRemoteSwiftPackageReference "NextcloudCapabilitiesKit" */, ); productRefGroup = C2B573B21B1CD91E00303B36 /* Products */; projectDirPath = ""; @@ -750,7 +751,6 @@ 5374FD442B95EE1400C78D54 /* ShareController.swift in Sources */, 53FE145B2B8F1305006C4193 /* NKShare+Extensions.swift in Sources */, 53FE14592B8E3F6C006C4193 /* ShareTableItemView.swift in Sources */, - 534F812F2BA1B3D80068D145 /* ShareCapabilities.swift in Sources */, 53FE14552B8E28E9006C4193 /* NextcloudAccount.swift in Sources */, 5376307D2B85E2ED0026BFAB /* Logger+Extensions.swift in Sources */, 53FE14502B8E0658006C4193 /* ShareTableViewDataSource.swift in Sources */, @@ -1531,6 +1531,14 @@ version = 10.33.0; }; }; + 5358F2B72BAA045E00E3C729 /* XCRemoteSwiftPackageReference "NextcloudCapabilitiesKit" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/claucambra/NextcloudCapabilitiesKit.git"; + requirement = { + branch = main; + kind = branch; + }; + }; /* End XCRemoteSwiftPackageReference section */ /* Begin XCSwiftPackageProductDependency section */ @@ -1549,6 +1557,11 @@ package = 5307A6E92965DB57001E0C6A /* XCRemoteSwiftPackageReference "realm-swift" */; productName = RealmSwift; }; + 5358F2B82BAA0F5300E3C729 /* NextcloudCapabilitiesKit */ = { + isa = XCSwiftPackageProductDependency; + package = 5358F2B72BAA045E00E3C729 /* XCRemoteSwiftPackageReference "NextcloudCapabilitiesKit" */; + productName = NextcloudCapabilitiesKit; + }; 53FE14512B8E1213006C4193 /* NextcloudKit */ = { isa = XCSwiftPackageProductDependency; package = 5307A6E42965C6FA001E0C6A /* XCRemoteSwiftPackageReference "NextcloudKit" */; From d568c73644cd62cde703ba135c31e87a5e3074bd Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Tue, 2 Apr 2024 18:16:31 +0800 Subject: [PATCH 152/172] Add SuggestionsTextFieldKit dependency Signed-off-by: Claudio Cambra --- .../project.pbxproj | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj b/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj index 421fc64e9dee7..896cc25435b19 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj +++ b/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj @@ -23,6 +23,7 @@ 5352E85B29B7BFE6002CE85C /* Progress+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5352E85A29B7BFE6002CE85C /* Progress+Extensions.swift */; }; 5358F2B92BAA0F5300E3C729 /* NextcloudCapabilitiesKit in Frameworks */ = {isa = PBXBuildFile; productRef = 5358F2B82BAA0F5300E3C729 /* NextcloudCapabilitiesKit */; }; 535AE30E29C0A2CC0042A9BA /* Logger+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 535AE30D29C0A2CC0042A9BA /* Logger+Extensions.swift */; }; + 53651E442BBC0CA300ECAC29 /* SuggestionsTextFieldKit in Frameworks */ = {isa = PBXBuildFile; productRef = 53651E432BBC0CA300ECAC29 /* SuggestionsTextFieldKit */; }; 536EFBF7295CF58100F4CB13 /* FileProviderSocketLineProcessor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 536EFBF6295CF58100F4CB13 /* FileProviderSocketLineProcessor.swift */; }; 536EFC36295E3C1100F4CB13 /* NextcloudAccount.swift in Sources */ = {isa = PBXBuildFile; fileRef = 536EFC35295E3C1100F4CB13 /* NextcloudAccount.swift */; }; 5374FD442B95EE1400C78D54 /* ShareController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5374FD432B95EE1400C78D54 /* ShareController.swift */; }; @@ -250,6 +251,7 @@ buildActionMask = 2147483647; files = ( 5358F2B92BAA0F5300E3C729 /* NextcloudCapabilitiesKit in Frameworks */, + 53651E442BBC0CA300ECAC29 /* SuggestionsTextFieldKit in Frameworks */, 53FE14542B8E1219006C4193 /* NextcloudKit in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -523,6 +525,7 @@ packageProductDependencies = ( 53FE14532B8E1219006C4193 /* NextcloudKit */, 5358F2B82BAA0F5300E3C729 /* NextcloudCapabilitiesKit */, + 53651E432BBC0CA300ECAC29 /* SuggestionsTextFieldKit */, ); productName = FileProviderUIExt; productReference = 53B9797E2B84C81F002DA742 /* FileProviderUIExt.appex */; @@ -624,6 +627,7 @@ 5307A6E42965C6FA001E0C6A /* XCRemoteSwiftPackageReference "NextcloudKit" */, 5307A6E92965DB57001E0C6A /* XCRemoteSwiftPackageReference "realm-swift" */, 5358F2B72BAA045E00E3C729 /* XCRemoteSwiftPackageReference "NextcloudCapabilitiesKit" */, + 53651E422BBC0C7F00ECAC29 /* XCRemoteSwiftPackageReference "SuggestionsTextFieldKit" */, ); productRefGroup = C2B573B21B1CD91E00303B36 /* Products */; projectDirPath = ""; @@ -1539,6 +1543,14 @@ kind = branch; }; }; + 53651E422BBC0C7F00ECAC29 /* XCRemoteSwiftPackageReference "SuggestionsTextFieldKit" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/claucambra/SuggestionsTextFieldKit.git"; + requirement = { + branch = main; + kind = branch; + }; + }; /* End XCRemoteSwiftPackageReference section */ /* Begin XCSwiftPackageProductDependency section */ @@ -1562,6 +1574,11 @@ package = 5358F2B72BAA045E00E3C729 /* XCRemoteSwiftPackageReference "NextcloudCapabilitiesKit" */; productName = NextcloudCapabilitiesKit; }; + 53651E432BBC0CA300ECAC29 /* SuggestionsTextFieldKit */ = { + isa = XCSwiftPackageProductDependency; + package = 53651E422BBC0C7F00ECAC29 /* XCRemoteSwiftPackageReference "SuggestionsTextFieldKit" */; + productName = SuggestionsTextFieldKit; + }; 53FE14512B8E1213006C4193 /* NextcloudKit */ = { isa = XCSwiftPackageProductDependency; package = 5307A6E42965C6FA001E0C6A /* XCRemoteSwiftPackageReference "NextcloudKit" */; From 7d23616ebe435fcea00f216217f06d8f57931afb Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Tue, 2 Apr 2024 18:17:08 +0800 Subject: [PATCH 153/172] Add basic shareesuggestionsdatasource Signed-off-by: Claudio Cambra --- .../ShareeSuggestionsDataSource.swift | 21 +++++++++++++++++++ .../project.pbxproj | 4 ++++ 2 files changed, 25 insertions(+) create mode 100644 shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareeSuggestionsDataSource.swift diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareeSuggestionsDataSource.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareeSuggestionsDataSource.swift new file mode 100644 index 0000000000000..f31db0ee192ee --- /dev/null +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareeSuggestionsDataSource.swift @@ -0,0 +1,21 @@ +// +// ShareeSuggestionsDataSource.swift +// FileProviderUIExt +// +// Created by Claudio Cambra on 2/4/24. +// + +import Foundation +import NextcloudKit +import OSLog +import SuggestionsTextFieldKit + +class ShareeSuggestionsDataSource: SuggestionsDataSource { + let kit: NextcloudKit + var suggestions: [SuggestionsTextFieldKit.Suggestion] = [] + var inputString: String = "" + + init(kit: NextcloudKit) { + self.kit = kit + } +} diff --git a/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj b/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj index 896cc25435b19..84ed83528a058 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj +++ b/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj @@ -24,6 +24,7 @@ 5358F2B92BAA0F5300E3C729 /* NextcloudCapabilitiesKit in Frameworks */ = {isa = PBXBuildFile; productRef = 5358F2B82BAA0F5300E3C729 /* NextcloudCapabilitiesKit */; }; 535AE30E29C0A2CC0042A9BA /* Logger+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 535AE30D29C0A2CC0042A9BA /* Logger+Extensions.swift */; }; 53651E442BBC0CA300ECAC29 /* SuggestionsTextFieldKit in Frameworks */ = {isa = PBXBuildFile; productRef = 53651E432BBC0CA300ECAC29 /* SuggestionsTextFieldKit */; }; + 53651E462BBC0D9500ECAC29 /* ShareeSuggestionsDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53651E452BBC0D9500ECAC29 /* ShareeSuggestionsDataSource.swift */; }; 536EFBF7295CF58100F4CB13 /* FileProviderSocketLineProcessor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 536EFBF6295CF58100F4CB13 /* FileProviderSocketLineProcessor.swift */; }; 536EFC36295E3C1100F4CB13 /* NextcloudAccount.swift in Sources */ = {isa = PBXBuildFile; fileRef = 536EFC35295E3C1100F4CB13 /* NextcloudAccount.swift */; }; 5374FD442B95EE1400C78D54 /* ShareController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5374FD432B95EE1400C78D54 /* ShareController.swift */; }; @@ -174,6 +175,7 @@ 5352B36B29DC44B50011CE03 /* FileProviderExtension+Thumbnailing.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "FileProviderExtension+Thumbnailing.swift"; sourceTree = ""; }; 5352E85A29B7BFE6002CE85C /* Progress+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Progress+Extensions.swift"; sourceTree = ""; }; 535AE30D29C0A2CC0042A9BA /* Logger+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Logger+Extensions.swift"; sourceTree = ""; }; + 53651E452BBC0D9500ECAC29 /* ShareeSuggestionsDataSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareeSuggestionsDataSource.swift; sourceTree = ""; }; 536EFBF6295CF58100F4CB13 /* FileProviderSocketLineProcessor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileProviderSocketLineProcessor.swift; sourceTree = ""; }; 536EFC35295E3C1100F4CB13 /* NextcloudAccount.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NextcloudAccount.swift; sourceTree = ""; }; 5374FD432B95EE1400C78D54 /* ShareController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareController.swift; sourceTree = ""; }; @@ -368,6 +370,7 @@ 5376307B2B85E2E00026BFAB /* Extensions */, 53B979802B84C81F002DA742 /* DocumentActionViewController.swift */, 5374FD432B95EE1400C78D54 /* ShareController.swift */, + 53651E452BBC0D9500ECAC29 /* ShareeSuggestionsDataSource.swift */, 53FE14662B8F78B6006C4193 /* ShareOptionsView.swift */, 53FE14582B8E3F6C006C4193 /* ShareTableItemView.swift */, 531522812B8E01C6002E31BE /* ShareTableItemView.xib */, @@ -750,6 +753,7 @@ files = ( 537630932B85F4B00026BFAB /* ShareViewController.swift in Sources */, 53FE14672B8F78B6006C4193 /* ShareOptionsView.swift in Sources */, + 53651E462BBC0D9500ECAC29 /* ShareeSuggestionsDataSource.swift in Sources */, 53FE14652B8F6700006C4193 /* ShareViewDataSourceUIDelegate.swift in Sources */, 53B979812B84C81F002DA742 /* DocumentActionViewController.swift in Sources */, 5374FD442B95EE1400C78D54 /* ShareController.swift in Sources */, From 2eeeda76f6b04b4640262544bef108f25b9413fb Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Tue, 2 Apr 2024 18:17:35 +0800 Subject: [PATCH 154/172] Add sharee fetcher method to shareesuggestionsdatasource Signed-off-by: Claudio Cambra --- .../Extensions/Logger+Extensions.swift | 1 + .../ShareeSuggestionsDataSource.swift | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Extensions/Logger+Extensions.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Extensions/Logger+Extensions.swift index 54e3e599a1e90..960171034da09 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Extensions/Logger+Extensions.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Extensions/Logger+Extensions.swift @@ -13,6 +13,7 @@ extension Logger { static let actionViewController = Logger(subsystem: subsystem, category: "actionViewController") static let shareCapabilities = Logger(subsystem: subsystem, category: "shareCapabilities") static let shareController = Logger(subsystem: subsystem, category: "shareController") + static let shareeDataSource = Logger(subsystem: subsystem, category: "shareeDataSource") static let sharesDataSource = Logger(subsystem: subsystem, category: "sharesDataSource") static let shareOptionsView = Logger(subsystem: subsystem, category: "shareOptionsView") static let shareViewController = Logger(subsystem: subsystem, category: "shareViewController") diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareeSuggestionsDataSource.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareeSuggestionsDataSource.swift index f31db0ee192ee..17a7140b57de9 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareeSuggestionsDataSource.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareeSuggestionsDataSource.swift @@ -18,4 +18,23 @@ class ShareeSuggestionsDataSource: SuggestionsDataSource { init(kit: NextcloudKit) { self.kit = kit } + + private func fetchSharees(search: String) async -> [NKSharee] { + return await withCheckedContinuation { continuation in + kit.searchSharees( + search: inputString, + page: 1, + perPage: 20, + completion: { account, sharees, data, error in + defer { continuation.resume(returning: sharees ?? []) } + guard error == .success else { + Logger.shareeDataSource.error( + "Error fetching sharees: \(error.description, privacy: .public)" + ) + return + } + } + ) + } + } } From 8a2f440d79064d1eb04e5a9d14938ebdf2d95557 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Tue, 2 Apr 2024 18:18:42 +0800 Subject: [PATCH 155/172] Add converter method fro nksharee to suggestion Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/ShareeSuggestionsDataSource.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareeSuggestionsDataSource.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareeSuggestionsDataSource.swift index 17a7140b57de9..5c84f5bd14c04 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareeSuggestionsDataSource.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareeSuggestionsDataSource.swift @@ -37,4 +37,8 @@ class ShareeSuggestionsDataSource: SuggestionsDataSource { ) } } + + private func suggestionsFromSharees(_ sharees: [NKSharee]) -> [Suggestion] { + sharees.map { Suggestion(imageName: "person.fill", displayText: $0.name, data: $0) } + } // TODO: Improve img } From d44f5c4f867d779c08cef3f57552f84381f51bf5 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Tue, 2 Apr 2024 18:19:01 +0800 Subject: [PATCH 156/172] Update suggestions on inputString change in sharee suggestions data source Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/ShareeSuggestionsDataSource.swift | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareeSuggestionsDataSource.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareeSuggestionsDataSource.swift index 5c84f5bd14c04..aa3f6388abcdf 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareeSuggestionsDataSource.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareeSuggestionsDataSource.swift @@ -13,12 +13,19 @@ import SuggestionsTextFieldKit class ShareeSuggestionsDataSource: SuggestionsDataSource { let kit: NextcloudKit var suggestions: [SuggestionsTextFieldKit.Suggestion] = [] - var inputString: String = "" + var inputString: String = "" { + didSet { Task { await updateSuggestions() } } + } init(kit: NextcloudKit) { self.kit = kit } + private func updateSuggestions() async { + let sharees = await fetchSharees(search: inputString) + suggestions = suggestionsFromSharees(sharees) + } + private func fetchSharees(search: String) async -> [NKSharee] { return await withCheckedContinuation { continuation in kit.searchSharees( From 75c977cf865b53a2cef5f285dd8d8f34f0c5e7e7 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 3 Apr 2024 20:40:58 +0800 Subject: [PATCH 157/172] Post suggestions changed notification in ShareeSuggestionsDataSource Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/ShareeSuggestionsDataSource.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareeSuggestionsDataSource.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareeSuggestionsDataSource.swift index aa3f6388abcdf..604efff32c67c 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareeSuggestionsDataSource.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareeSuggestionsDataSource.swift @@ -24,6 +24,7 @@ class ShareeSuggestionsDataSource: SuggestionsDataSource { private func updateSuggestions() async { let sharees = await fetchSharees(search: inputString) suggestions = suggestionsFromSharees(sharees) + NotificationCenter.default.post(name: SuggestionsChangedNotificationName, object: self) } private func fetchSharees(search: String) async -> [NKSharee] { From e59c12e3f458b80f29a6cbd0fbf46ccc417851dd Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 3 Apr 2024 20:41:08 +0800 Subject: [PATCH 158/172] Improve logging in ShareeSuggestionsDataSource Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/ShareeSuggestionsDataSource.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareeSuggestionsDataSource.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareeSuggestionsDataSource.swift index 604efff32c67c..a8b247e9c3c2a 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareeSuggestionsDataSource.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareeSuggestionsDataSource.swift @@ -23,11 +23,13 @@ class ShareeSuggestionsDataSource: SuggestionsDataSource { private func updateSuggestions() async { let sharees = await fetchSharees(search: inputString) + Logger.shareeDataSource.info("Fetched \(sharees.count, privacy: .public) sharees.") suggestions = suggestionsFromSharees(sharees) NotificationCenter.default.post(name: SuggestionsChangedNotificationName, object: self) } private func fetchSharees(search: String) async -> [NKSharee] { + Logger.shareeDataSource.debug("Searching sharees with: \(search, privacy: .public)") return await withCheckedContinuation { continuation in kit.searchSharees( search: inputString, From 3017ed4f3645dd3c695f8fb8d4e9af8c47abf3cf Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 3 Apr 2024 20:46:01 +0800 Subject: [PATCH 159/172] Use suggestions window controller in share options view Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/ShareOptionsView.swift | 24 ++++++++++++++++--- .../ShareViewController.swift | 4 +++- .../ShareeSuggestionsDataSource.swift | 3 +-- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift index 1a9d51fa81b50..893d6bb3ce9a0 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift @@ -35,6 +35,22 @@ class ShareOptionsView: NSView { @IBOutlet private weak var circleShare: NSMenuItem! @IBOutlet private weak var talkConversationShare: NSMenuItem! + var kit: NextcloudKit? { + didSet { + Logger.shareOptionsView.info("Setting up the kit.") + guard let kit = kit else { + Logger.shareOptionsView.error("Could not configure suggestions data source.") + return + } + suggestionsWindowController.dataSource = ShareeSuggestionsDataSource(kit: kit) + suggestionsWindowController.parentTextField = shareRecipientTextField + + suggestionsTextFieldDelegate.suggestionsWindowController = suggestionsWindowController + shareRecipientTextField.delegate = suggestionsTextFieldDelegate + + suggestionsWindowController.begin(for: shareRecipientTextField) + } + } var dataSource: ShareTableViewDataSource? var controller: ShareController? { didSet { @@ -72,6 +88,8 @@ class ShareOptionsView: NSView { } } private var cancellable: AnyCancellable? + private var suggestionsWindowController = SuggestionsWindowController() + private var suggestionsTextFieldDelegate = SuggestionsTextFieldDelegate() private func update() { guard let share = controller?.share else { @@ -161,7 +179,7 @@ class ShareOptionsView: NSView { expirationDatePicker.isHidden = expirationDateCheckbox.state == .off } - func setAllFields(enabled: Bool) { + private func setAllFields(enabled: Bool) { shareTypePicker.isEnabled = enabled shareRecipientTextField.isEnabled = enabled labelTextField.isEnabled = enabled @@ -235,12 +253,12 @@ class ShareOptionsView: NSView { Logger.shareOptionsView.info("Creating new share!") guard let dataSource = dataSource, - let kit = dataSource.kit, + let kit = kit, let itemServerRelativePath = dataSource.itemServerRelativePath else { Logger.shareOptionsView.error("Cannot create new share due to missing data.") Logger.shareOptionsView.error("dataSource: \(self.dataSource)") - Logger.shareOptionsView.error("kit: \(self.dataSource?.kit)") + Logger.shareOptionsView.error("kit: \(self.kit)") Logger.shareOptionsView.error( "path: \(self.dataSource?.itemServerRelativePath ?? "")" ) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift index d104e3360899d..3293328316dd5 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift @@ -111,6 +111,8 @@ class ShareViewController: NSViewController, ShareViewDataSourceUIDelegate { } @IBAction func createShare(_ sender: Any) { + guard let kit = shareDataSource.kit else { return } + optionsView.kit = kit optionsView.createMode = true tableView.deselectAll(self) if !splitView.arrangedSubviews.contains(optionsView) { @@ -137,11 +139,11 @@ class ShareViewController: NSViewController, ShareViewDataSourceUIDelegate { } splitView.removeArrangedSubview(optionsView) optionsView.isHidden = true - } func showOptions(share: NKShare) { guard let kit = shareDataSource.kit else { return } + optionsView.kit = kit optionsView.controller = ShareController(share: share, kit: kit) if !splitView.arrangedSubviews.contains(optionsView) { splitView.addArrangedSubview(optionsView) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareeSuggestionsDataSource.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareeSuggestionsDataSource.swift index a8b247e9c3c2a..66c637ab4b5ba 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareeSuggestionsDataSource.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareeSuggestionsDataSource.swift @@ -8,11 +8,10 @@ import Foundation import NextcloudKit import OSLog -import SuggestionsTextFieldKit class ShareeSuggestionsDataSource: SuggestionsDataSource { let kit: NextcloudKit - var suggestions: [SuggestionsTextFieldKit.Suggestion] = [] + var suggestions: [Suggestion] = [] var inputString: String = "" { didSet { Task { await updateSuggestions() } } } From eedd0b8f754e347bc8e794cf8f18a5dc652dce1e Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Sat, 6 Apr 2024 18:04:34 +0800 Subject: [PATCH 160/172] Fix suggestion labels for sharees Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/ShareeSuggestionsDataSource.swift | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareeSuggestionsDataSource.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareeSuggestionsDataSource.swift index 66c637ab4b5ba..cf5c5c9236b1f 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareeSuggestionsDataSource.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareeSuggestionsDataSource.swift @@ -48,6 +48,12 @@ class ShareeSuggestionsDataSource: SuggestionsDataSource { } private func suggestionsFromSharees(_ sharees: [NKSharee]) -> [Suggestion] { - sharees.map { Suggestion(imageName: "person.fill", displayText: $0.name, data: $0) } + return sharees.map { + Suggestion( + imageName: "person.fill", + displayText: $0.label.isEmpty ? $0.name : $0.label, + data: $0 + ) + } } // TODO: Improve img } From 5098476ae2882460526ff6910d08909b53aeacac Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Sat, 6 Apr 2024 22:11:29 +0800 Subject: [PATCH 161/172] Simplify configuration of text field delegate Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/ShareOptionsView.swift | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift index 893d6bb3ce9a0..d3f41c79c8c88 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift @@ -42,13 +42,16 @@ class ShareOptionsView: NSView { Logger.shareOptionsView.error("Could not configure suggestions data source.") return } - suggestionsWindowController.dataSource = ShareeSuggestionsDataSource(kit: kit) - suggestionsWindowController.parentTextField = shareRecipientTextField - suggestionsTextFieldDelegate.suggestionsWindowController = suggestionsWindowController - shareRecipientTextField.delegate = suggestionsTextFieldDelegate - - suggestionsWindowController.begin(for: shareRecipientTextField) + suggestionsTextFieldDelegate.suggestionsDataSource = ShareeSuggestionsDataSource( + kit: kit + ) + suggestionsTextFieldDelegate.confirmationHandler = { suggestion in + guard let sharee = suggestion?.data as? NKSharee else { return } + self.shareRecipientTextField.stringValue = sharee.shareWith + Logger.shareOptionsView.debug("Chose sharee \(sharee.shareWith, privacy: .public)") + } + suggestionsTextFieldDelegate.targetTextField = shareRecipientTextField } } var dataSource: ShareTableViewDataSource? From a77664e7aea6bbce65b4ea38c6ab05240a74dc90 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Sat, 6 Apr 2024 22:14:52 +0800 Subject: [PATCH 162/172] Fix SuggestionsTextFieldKit import Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/ShareOptionsView.swift | 1 + .../FileProviderUIExt/ShareeSuggestionsDataSource.swift | 1 + 2 files changed, 2 insertions(+) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift index d3f41c79c8c88..ff44f197a3608 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift @@ -9,6 +9,7 @@ import AppKit import Combine import NextcloudKit import OSLog +import SuggestionsTextFieldKit // TODO: Handle shareWith! // TODO: Handle visibility of textfields on relevant checkbox toggle diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareeSuggestionsDataSource.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareeSuggestionsDataSource.swift index cf5c5c9236b1f..da9e6b7655b4c 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareeSuggestionsDataSource.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareeSuggestionsDataSource.swift @@ -8,6 +8,7 @@ import Foundation import NextcloudKit import OSLog +import SuggestionsTextFieldKit class ShareeSuggestionsDataSource: SuggestionsDataSource { let kit: NextcloudKit From c767cf787f07404b5263efa03ac139d5665a728e Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Sat, 6 Apr 2024 22:28:10 +0800 Subject: [PATCH 163/172] Clean up TODO comments in file provider ui ext Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/ShareOptionsView.swift | 2 -- .../FileProviderUIExt/ShareeSuggestionsDataSource.swift | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift index ff44f197a3608..516909055156d 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift @@ -11,8 +11,6 @@ import NextcloudKit import OSLog import SuggestionsTextFieldKit -// TODO: Handle shareWith! -// TODO: Handle visibility of textfields on relevant checkbox toggle class ShareOptionsView: NSView { @IBOutlet private weak var optionsTitleTextField: NSTextField! @IBOutlet private weak var shareRecipientTextField: NSTextField! // Hide if public link share diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareeSuggestionsDataSource.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareeSuggestionsDataSource.swift index da9e6b7655b4c..cc1b91fe3951e 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareeSuggestionsDataSource.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareeSuggestionsDataSource.swift @@ -56,5 +56,5 @@ class ShareeSuggestionsDataSource: SuggestionsDataSource { data: $0 ) } - } // TODO: Improve img + } } From f46f842188b86e0f9e4fd70f5102d3d64a154acd Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Sat, 6 Apr 2024 22:28:22 +0800 Subject: [PATCH 164/172] Set suggestionstextfieldkit to 1.0.0 Signed-off-by: Claudio Cambra --- .../NextcloudIntegration.xcodeproj/project.pbxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj b/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj index 84ed83528a058..b01e8e5f72ef9 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj +++ b/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj @@ -1551,8 +1551,8 @@ isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/claucambra/SuggestionsTextFieldKit.git"; requirement = { - branch = main; - kind = branch; + kind = exactVersion; + version = 1.0.0; }; }; /* End XCRemoteSwiftPackageReference section */ From a1bcd2e1fc1ab1cf140077a6bb1979c39c3bed27 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Sat, 6 Apr 2024 22:30:27 +0800 Subject: [PATCH 165/172] Pin NextcloudKit version Signed-off-by: Claudio Cambra --- .../NextcloudIntegration.xcodeproj/project.pbxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj b/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj index b01e8e5f72ef9..5b79d80fe352b 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj +++ b/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj @@ -1527,8 +1527,8 @@ isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/nextcloud/NextcloudKit.git"; requirement = { - branch = develop; - kind = branch; + kind = upToNextMajorVersion; + minimumVersion = 2.5.9; }; }; 5307A6E92965DB57001E0C6A /* XCRemoteSwiftPackageReference "realm-swift" */ = { From fcb5b8a4e188e8d396721059394f3f55384c0495 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Sun, 7 Apr 2024 00:42:18 +0800 Subject: [PATCH 166/172] Pin NextcloudCapabilitiesKit version Signed-off-by: Claudio Cambra --- .../NextcloudIntegration.xcodeproj/project.pbxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj b/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj index 5b79d80fe352b..413eba67a9aa8 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj +++ b/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj @@ -1543,8 +1543,8 @@ isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/claucambra/NextcloudCapabilitiesKit.git"; requirement = { - branch = main; - kind = branch; + kind = exactVersion; + version = 1.0.0; }; }; 53651E422BBC0C7F00ECAC29 /* XCRemoteSwiftPackageReference "SuggestionsTextFieldKit" */ = { From b72539ff57a4fa92b3afededdc53c041664ff137 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Sun, 7 Apr 2024 00:46:38 +0800 Subject: [PATCH 167/172] Display shareWith in nkshare displaystring extension Signed-off-by: Claudio Cambra --- .../Extensions/NKShare+Extensions.swift | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Extensions/NKShare+Extensions.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Extensions/NKShare+Extensions.swift index ff560bcffd65a..2527fb83c5caf 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Extensions/NKShare+Extensions.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Extensions/NKShare+Extensions.swift @@ -86,19 +86,19 @@ extension NKShare { switch shareType { case ShareType.user.rawValue: - return "User share" + return "User share (\(shareWith))" case ShareType.group.rawValue: - return "Group share" + return "Group share (\(shareWith))" case ShareType.publicLink.rawValue: return "Public link share" case ShareType.email.rawValue: - return "Email share" + return "Email share (\(shareWith))" case ShareType.federatedCloud.rawValue: - return "Federated cloud share" + return "Federated cloud share (\(shareWith))" case ShareType.circle.rawValue: - return "Circle share" + return "Circle share (\(shareWith))" case ShareType.talkConversation.rawValue: - return "Talk conversation share" + return "Talk conversation share (\(shareWith))" default: return "Unknown share" } From 6b61e6622f1877cd8c31259be889a7deb6cf025b Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Sun, 7 Apr 2024 00:58:26 +0800 Subject: [PATCH 168/172] Update description label in share view Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/ShareViewController.swift | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift index 3293328316dd5..17016dcc44052 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift @@ -104,6 +104,22 @@ class ShareViewController: NSViewController, ShareViewDataSourceUIDelegate { } } fileNameIcon.image = fileThumbnail?.nsImage + + let resourceValues = try? itemUrl.resourceValues( + forKeys: [.fileSizeKey, .contentModificationDateKey] + ) + var sizeDesc = "Unknown size" + var modDesc = "Unknown modification date" + if let fileSize = resourceValues?.fileSize { + sizeDesc = ByteCountFormatter().string(fromByteCount: Int64(fileSize)) + } + if let modificationDate = resourceValues?.contentModificationDate { + let modDateString = DateFormatter.localizedString( + from: modificationDate, dateStyle: .short, timeStyle: .short + ) + modDesc = "Last modified: \(modDateString)" + } + descriptionLabel.stringValue = "\(sizeDesc) · \(modDesc)" } @IBAction func dismissError(_ sender: Any) { From 06e66a96637490a896da2e3c993116d2b461171b Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Sun, 7 Apr 2024 01:09:13 +0800 Subject: [PATCH 169/172] Add a "no shares" label if there are no shares available in share view Signed-off-by: Claudio Cambra --- .../ShareTableViewDataSource.swift | 2 +- .../ShareViewController.swift | 2 + .../FileProviderUIExt/ShareViewController.xib | 50 ++++++++++++------- 3 files changed, 34 insertions(+), 20 deletions(-) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift index cf8087bc46724..1200499ab5ec0 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift @@ -32,7 +32,7 @@ class ShareTableViewDataSource: NSObject, NSTableViewDataSource, NSTableViewDele private(set) var kit: NextcloudKit? private(set) var itemURL: URL? private(set) var itemServerRelativePath: String? - private var shares: [NKShare] = [] { + private(set) var shares: [NKShare] = [] { didSet { Task { @MainActor in sharesTableView?.reloadData() } } } private var account: NextcloudAccount? { diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift index 17016dcc44052..55955f143984d 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.swift @@ -27,6 +27,7 @@ class ShareViewController: NSViewController, ShareViewDataSourceUIDelegate { @IBOutlet weak var loadingIndicator: NSProgressIndicator! @IBOutlet weak var errorMessageStackView: NSStackView! @IBOutlet weak var errorTextLabel: NSTextField! + @IBOutlet weak var noSharesLabel: NSTextField! public override var nibName: NSNib.Name? { return NSNib.Name(self.className) @@ -143,6 +144,7 @@ class ShareViewController: NSViewController, ShareViewDataSourceUIDelegate { } func fetchFinished() { + noSharesLabel.isHidden = !shareDataSource.shares.isEmpty loadingEffectView.isHidden = true loadingIndicator.stopAnimation(self) } diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib index a797c5e9b1d31..7a61de7033656 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareViewController.xib @@ -1,8 +1,8 @@ - + - + @@ -19,6 +19,7 @@ + @@ -28,10 +29,10 @@ - + - + @@ -49,7 +50,7 @@ - + @@ -57,7 +58,7 @@ - + @@ -123,8 +124,8 @@ - - + + @@ -132,7 +133,7 @@ - + @@ -326,8 +327,8 @@ - - + + @@ -343,7 +344,7 @@ - + @@ -478,6 +479,14 @@ + + + + + + + + @@ -503,6 +512,9 @@ + + + From da5e53e7a5249c33ca3e3341739492fe25f359f6 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Mon, 8 Apr 2024 18:45:18 +0800 Subject: [PATCH 170/172] Upgrade NextcloudCapabilitiesKit version Signed-off-by: Claudio Cambra --- .../NextcloudIntegration.xcodeproj/project.pbxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj b/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj index 413eba67a9aa8..047882e279c52 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj +++ b/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj @@ -1543,8 +1543,8 @@ isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/claucambra/NextcloudCapabilitiesKit.git"; requirement = { - kind = exactVersion; - version = 1.0.0; + kind = upToNextMajorVersion; + minimumVersion = 2.0.0; }; }; 53651E422BBC0C7F00ECAC29 /* XCRemoteSwiftPackageReference "SuggestionsTextFieldKit" */ = { From 060b92629c3d5c09dbc9548089847e24506f9f70 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Mon, 15 Apr 2024 15:18:07 +0800 Subject: [PATCH 171/172] Allow SuggestionsTextFieldKit to use up to next major version Signed-off-by: Claudio Cambra --- .../NextcloudIntegration.xcodeproj/project.pbxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj b/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj index 047882e279c52..e830d9ac877dc 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj +++ b/shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.pbxproj @@ -1551,8 +1551,8 @@ isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/claucambra/SuggestionsTextFieldKit.git"; requirement = { - kind = exactVersion; - version = 1.0.0; + kind = upToNextMajorVersion; + minimumVersion = 1.0.0; }; }; /* End XCRemoteSwiftPackageReference section */ From fad069b66c3e6172cc075b7d55c91c8a9ba992a7 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 17 Apr 2024 13:47:17 +0800 Subject: [PATCH 172/172] Set file provider extension target as a dependency of file provider ui extension target in CMake Signed-off-by: Claudio Cambra --- shell_integration/MacOSX/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/shell_integration/MacOSX/CMakeLists.txt b/shell_integration/MacOSX/CMakeLists.txt index 512aae44781b7..a3f561484aa09 100644 --- a/shell_integration/MacOSX/CMakeLists.txt +++ b/shell_integration/MacOSX/CMakeLists.txt @@ -44,6 +44,7 @@ if(APPLE) "OC_APPLICATION_NAME=${APPLICATION_NAME}" "OC_APPLICATION_REV_DOMAIN=${APPLICATION_REV_DOMAIN}" "OC_SOCKETAPI_TEAM_IDENTIFIER_PREFIX=${SOCKETAPI_TEAM_IDENTIFIER_PREFIX}" + DEPENDS mac_fileproviderplugin COMMENT building macOS File Provider UI extension VERBATIM)