diff --git a/AGENTS.md b/AGENTS.md index 2bf8c2f..f0e5c0d 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -11,7 +11,7 @@ This project is a C#/.NET WinUI 3 desktop app; an alternative to File Explorer. - Prefer targeted search over full file reads. - Touch only what you must. Clean up only files you created or changed for the task. - Treat file operations, shell integration, drag/drop, preview handlers, archive actions, settings persistence, and localization as high-risk areas. -- For Win32, COM, Shell, clipboard, hotkey, and file operation interop, prefer `src/Files.Core/NativeMethods.txt` and the existing wrappers/helpers in `src/Files.Core/Interop/Windows`. +- For Win32, COM, Shell, clipboard, hotkey, and file operation interop, prefer `src/Files.Core/NativeMethods.txt` and the existing wrappers/helpers in `src/Files.Core/Windows/Interop`. - Avoid ad hoc P/Invoke declarations when CsWin32 or existing interop code can cover the API. - Do not edit generated CsWin32 output directly. Update source declarations, wrappers, or generator inputs instead. - CsWin32 output is build-generated under `src/Files.Core/obj////Generated/CsWin32`; the large `Windows.Win32.NativeMethods.g.cs` file and its manifest are disposable build artifacts. Inspect targeted declarations only and never edit them. @@ -29,7 +29,7 @@ This project is a C#/.NET WinUI 3 desktop app; an alternative to File Explorer. - Express COM interface parameters and results as generated interface types when the signature is known. For deliberately untyped interface values, use `[MarshalAs(UnmanagedType.Interface)] object`; do not introduce raw COM pointers, placeholder `IUnknown` interfaces, or custom marshallers solely to control lifetime. - Source-generated COM wrappers own their native references and release them when collected. Do not call `Marshal.ReleaseComObject`, `ComObject.FinalRelease`, or equivalent helpers, and do not request unique wrappers unless an independently verified native ownership contract requires deterministic release. - Use direct generated activation calls and normal managed casts. Prefer `PInvoke.CoCreateInstance` and `PInvoke.RoGetActivationFactory`, and use `as` for optional `QueryInterface` checks instead of adding activation, query, or release helpers. -- Put custom native declarations that are absent from Win32 metadata, or whose generated declarations cannot safely express the required ABI contract, in the existing `Windows.Win32.PInvoke` partial class in `src/Files.Core/Interop/Windows/Extras.cs`. Keep them as declarations without per-API forwarding helpers, and keep all such declarations in that file. +- Put custom native declarations that are absent from Win32 metadata, or whose generated declarations cannot safely express the required ABI contract, in the existing `Windows.Win32.PInvoke` partial class in `src/Files.Core/Windows/Interop/Extras.cs`. Keep them as declarations without per-API forwarding helpers, and keep all such declarations in that file. - Represent a CLSID that is absent from CsWin32 with a documented `[Guid]` coclass marker type and obtain its value through `typeof(CoclassType).GUID`; do not duplicate it in a `Guid` field. - Prefer `in`, `ref`, and `out` for fixed-size native value types whenever the generated or recovered signature permits it. Use raw pointers only for variable buffers, callbacks, optional pointer semantics that cannot be represented safely, or other unavoidable ABI boundaries. - Reuse one local named `hr` for sequential HRESULT-returning calls within a method when practical. diff --git a/docs/development/repository-layout.md b/docs/development/repository-layout.md index cf4fe62..1244c31 100644 --- a/docs/development/repository-layout.md +++ b/docs/development/repository-layout.md @@ -6,6 +6,9 @@ This page is a navigation map, not a replacement for the architecture docs. .github/ Repository/CI configuration src/ Files.Core/ UI-independent Core and provider/platform logic + Windows/ UI-independent Windows integration + / Physical grouping by responsibility + Interop/ Low-level Win32, COM, and Shell ABI declarations Files/ WinUI application and presentation Files.Controls/ Reusable WinUI controls Files.Operations/ Out-of-process operation host diff --git a/docs/subsystems/windows-shell.md b/docs/subsystems/windows-shell.md index 0fca1d1..ec31a39 100644 --- a/docs/subsystems/windows-shell.md +++ b/docs/subsystems/windows-shell.md @@ -8,9 +8,15 @@ Windows filesystem/Shell integration is a platform subsystem with COM apartment, - enumerate Shell/filesystem-backed folders; - retrieve Shell properties and thumbnails; - consume Shell change notifications; +- expose contextual commands and app-extension commands; +- adapt native clipboard and drag/drop data; +- host preview handlers and read property-sheet data; +- expose Windows Shell archive folders through the generic archive contracts; - execute Shell-dependent operations where appropriate; - schedule COM work on suitable STA workers. +The UI-independent mechanisms share the `Files.Core.Windows` namespace and are grouped physically by responsibility under `Files.Core/Windows`. Raw Win32, COM, and Shell ABI declarations remain under `Files.Core/Windows/Interop`. The Files UI host owns WinUI gestures, `DataPackage` adaptation, presentation, and window integration around those mechanisms. + ## Concurrency model Conceptually the Shell scheduler separates work by ordering/concurrency needs: diff --git a/src/Files.Core/Browsing/BrowsePreviewModel.cs b/src/Files.Core/Browsing/BrowsePreviewModel.cs index 91d0cf9..d7dde7b 100644 --- a/src/Files.Core/Browsing/BrowsePreviewModel.cs +++ b/src/Files.Core/Browsing/BrowsePreviewModel.cs @@ -5,6 +5,7 @@ using Files.Core.Capabilities; using Files.Core.Capabilities.Previews; using Files.Core.Models; +using Files.Core.Windows; namespace Files.Core.Browsing; diff --git a/src/Files.Core/Browsing/FolderBrowseLocationContext.cs b/src/Files.Core/Browsing/FolderBrowseLocationContext.cs index 3a5d535..fa107f9 100644 --- a/src/Files.Core/Browsing/FolderBrowseLocationContext.cs +++ b/src/Files.Core/Browsing/FolderBrowseLocationContext.cs @@ -5,8 +5,8 @@ using Files.Core.Data; using Files.Core.Models; using Files.Core.Storage; -using Files.Core.Storage.Windows; using Files.Core.ViewSettings; +using Files.Core.Windows; using OwlCore.Storage; namespace Files.Core.Browsing; diff --git a/src/Files.Core/Capabilities/Archives/ArchiveSourceFactory.cs b/src/Files.Core/Capabilities/Archives/ArchiveSourceFactory.cs index fb9d2b0..7b6282e 100644 --- a/src/Files.Core/Capabilities/Archives/ArchiveSourceFactory.cs +++ b/src/Files.Core/Capabilities/Archives/ArchiveSourceFactory.cs @@ -3,7 +3,7 @@ using Files.Core.Storage; using Files.Core.Storage.Archives; -using Files.Core.Storage.Windows; +using Files.Core.Windows; using OwlCore.Storage; namespace Files.Core.Capabilities.Archives; diff --git a/src/Files.Core/Capabilities/Previews/PreviewRequest.cs b/src/Files.Core/Capabilities/Previews/PreviewRequest.cs index 208b9e7..a7fb897 100644 --- a/src/Files.Core/Capabilities/Previews/PreviewRequest.cs +++ b/src/Files.Core/Capabilities/Previews/PreviewRequest.cs @@ -4,7 +4,7 @@ using Files.Core.Capabilities; using Files.Core.Models; using Files.Core.Storage; -using Files.Core.Storage.Windows; +using Files.Core.Windows; using OwlCore.Storage; namespace Files.Core.Capabilities.Previews; diff --git a/src/Files.Core/Capabilities/Previews/WindowsPreviewAccessPolicy.cs b/src/Files.Core/Capabilities/Previews/WindowsPreviewAccessPolicy.cs deleted file mode 100644 index 223396c..0000000 --- a/src/Files.Core/Capabilities/Previews/WindowsPreviewAccessPolicy.cs +++ /dev/null @@ -1,415 +0,0 @@ -// Copyright (c) Files Community -// SPDX-License-Identifier: MPL-2.0 - -using System.Buffers.Binary; -using System.IO; -using System.Runtime.InteropServices; -using System.Runtime.Versioning; -using System.Security; -using Files.Core.Capabilities; -using Files.Core.Storage.Windows; -using Microsoft.Win32; -using OwlCore.Storage; -using Windows.Win32; -using Windows.Win32.Foundation; -using Windows.Win32.System.Com.Urlmon; -using Windows.Win32.UI.Shell; - -namespace Files.Core.Capabilities.Previews; - -/// Applies Windows file hydration, size, and trust checks before preview content is accessed. -[SupportedOSPlatform("windows")] -public sealed class WindowsPreviewAccessPolicy : IPreviewStreamAccessPolicy, IWindowsShellPreviewPolicy -{ - private const uint FileAttributeOffline = 0x00001000; - private const uint FileAttributeRecallOnOpen = 0x00040000; - private const uint FileAttributeRecallOnDataAccess = 0x00400000; - private const uint HydrationFileAttributes = FileAttributeOffline | FileAttributeRecallOnOpen | FileAttributeRecallOnDataAccess; - - private readonly IWindowsPreviewFileMetadataResolver _metadataResolver; - private readonly IWindowsPreviewTrustResolver _trustResolver; - private readonly IWindowsPreviewHandlerTrustResolver _handlerTrustResolver; - private readonly IWindowsPreviewEnterpriseIdResolver _enterpriseIdResolver; - - /// Initializes a Windows preview access policy using operating-system metadata and trust resolvers. - public WindowsPreviewAccessPolicy() - : this(new WindowsPreviewFileMetadataResolver(), new WindowsPreviewUrlTrustResolver(), new WindowsPreviewHandlerTrustResolver(), new WindowsPreviewEnterpriseIdResolver()) - { - } - - internal WindowsPreviewAccessPolicy( - IWindowsPreviewFileMetadataResolver metadataResolver, - IWindowsPreviewTrustResolver trustResolver, - IWindowsPreviewHandlerTrustResolver handlerTrustResolver, - IWindowsPreviewEnterpriseIdResolver enterpriseIdResolver) - { - ArgumentNullException.ThrowIfNull(metadataResolver); - ArgumentNullException.ThrowIfNull(trustResolver); - ArgumentNullException.ThrowIfNull(handlerTrustResolver); - ArgumentNullException.ThrowIfNull(enterpriseIdResolver); - - _metadataResolver = metadataResolver; - _trustResolver = trustResolver; - _handlerTrustResolver = handlerTrustResolver; - _enterpriseIdResolver = enterpriseIdResolver; - } - - /// Gets a conservative blocking reason without request-specific Windows trust checks. - /// The item context. - /// The preview handler CLSID. - /// for Windows files, or for items outside this Windows-specific policy. - public PreviewBlockReason? GetBlockReason(ItemContext context, Guid handlerClsid) - { - ArgumentNullException.ThrowIfNull(context); - - if (handlerClsid == Guid.Empty) - { - throw new ArgumentException("A preview handler CLSID is required.", nameof(handlerClsid)); - } - - return IsWindowsFile(context) ? PreviewBlockReason.DisabledByPolicy : null; - } - - /// Gets the reason a Windows Shell preview handler is blocked. - /// The preview request. - /// The item context. - /// The preview handler CLSID. - /// The blocking reason, or when the handler is allowed or the item is not Windows-backed. - public PreviewBlockReason? GetBlockReason(PreviewRequest request, ItemContext context, Guid handlerClsid) - { - if (handlerClsid == Guid.Empty) - { - throw new ArgumentException("A preview handler CLSID is required.", nameof(handlerClsid)); - } - - return GetBlockReasonCore(request, context, handlerClsid); - } - - /// Gets the reason a stream preview is blocked for a Windows-backed file. - /// The preview request. - /// The item context. - /// The token used to cancel the operation. - /// The blocking reason, or when access is allowed or the item is not Windows-backed. - public ValueTask GetBlockReasonAsync(PreviewRequest request, ItemContext context, CancellationToken cancellationToken = default) - { - cancellationToken.ThrowIfCancellationRequested(); - - return ValueTask.FromResult(GetBlockReasonCore(request, context, null)); - } - - /// Gets the reason a Windows Shell preview handler is blocked. - /// The preview request. - /// The item context. - /// The preview handler CLSID. - /// The token used to cancel the operation. - /// The blocking reason, or when the handler is allowed or the item is not Windows-backed. - public ValueTask GetBlockReasonAsync(PreviewRequest request, ItemContext context, Guid handlerClsid, CancellationToken cancellationToken = default) - { - cancellationToken.ThrowIfCancellationRequested(); - - return ValueTask.FromResult(GetBlockReason(request, context, handlerClsid)); - } - - private PreviewBlockReason? GetBlockReasonCore(PreviewRequest request, ItemContext context, Guid? handlerClsid) - { - ArgumentNullException.ThrowIfNull(request); - ArgumentNullException.ThrowIfNull(context); - - if (!IsWindowsFile(context)) - { - return null; - } - - var metadata = _metadataResolver.GetMetadata(context); - - if (metadata is null || metadata.Value.Length < 0) - { - return PreviewBlockReason.AccessDenied; - } - - if (request.HydrationPolicy is PreviewHydrationPolicy.LocalOnly && (metadata.Value.Attributes & HydrationFileAttributes) != 0) - { - return PreviewBlockReason.RequiresHydration; - } - - if (request.MaximumBytes is long maximumBytes && metadata.Value.Length > maximumBytes) - { - return PreviewBlockReason.TooLarge; - } - - if (request.TrustAuthorization?.AppliesTo(context) is true) - { - return null; - } - - var bypassUrlPolicy = handlerClsid is Guid clsid && _handlerTrustResolver.AllowsUntrustedPreviews(clsid); - if (!bypassUrlPolicy && _trustResolver.GetTrust(context).Status is not WindowsPreviewTrustStatus.Allowed) - { - return PreviewBlockReason.Untrusted; - } - - if (_enterpriseIdResolver.HasEnterpriseId(context)) - { - return PreviewBlockReason.Untrusted; - } - - return null; - } - - private static bool IsWindowsFile(ItemContext context) - { - return context.CoreModel is IWindowsStorable and IFile; - } -} - -internal interface IWindowsPreviewFileMetadataResolver -{ - WindowsPreviewFileMetadata? GetMetadata(ItemContext context); -} - -internal interface IWindowsPreviewTrustResolver -{ - WindowsPreviewTrustResult GetTrust(ItemContext context); -} - -internal interface IWindowsPreviewHandlerTrustResolver -{ - bool AllowsUntrustedPreviews(Guid handlerClsid); -} - -internal interface IWindowsPreviewEnterpriseIdResolver -{ - bool HasEnterpriseId(ItemContext context); -} - -internal readonly record struct WindowsPreviewFileMetadata(uint Attributes, long Length); - -internal enum WindowsPreviewTrustStatus -{ - Allowed, - Blocked, - Indeterminate, -} - -internal readonly record struct WindowsPreviewTrustResult(WindowsPreviewTrustStatus Status); - -internal sealed class WindowsPreviewFileMetadataResolver : IWindowsPreviewFileMetadataResolver -{ - private const uint FileAttributeDirectory = 0x00000010; - public WindowsPreviewFileMetadata? GetMetadata(ItemContext context) - { - ArgumentNullException.ThrowIfNull(context); - - if (context.CoreModel is not IWindowsStorable item || context.CoreModel is not IFile || string.IsNullOrWhiteSpace(item.FileSystemPath) || !Path.IsPathFullyQualified(item.FileSystemPath)) - { - return null; - } - - try - { - var attributes = PInvoke.GetFileAttributes(item.FileSystemPath); - if (attributes == PInvoke.INVALID_FILE_ATTRIBUTES || (attributes & FileAttributeDirectory) != 0) - { - return null; - } - - var fileInfo = new FileInfo(item.FileSystemPath); - fileInfo.Refresh(); - if (!fileInfo.Exists) - { - return null; - } - - return new WindowsPreviewFileMetadata(attributes, fileInfo.Length); - } - catch (Exception error) when (error is IOException or UnauthorizedAccessException or ArgumentException or SecurityException or NotSupportedException) - { - return null; - } - } -} - -internal sealed class WindowsPreviewUrlTrustResolver : IWindowsPreviewTrustResolver -{ - private const int FileNotFoundHResult = unchecked((int)0x80070002); - private const uint InternetZone = 3; - - public WindowsPreviewTrustResult GetTrust(ItemContext context) - { - ArgumentNullException.ThrowIfNull(context); - - if (context.CoreModel is not IWindowsStorable item || context.CoreModel is not IFile || string.IsNullOrWhiteSpace(item.ParsingName)) - { - return new WindowsPreviewTrustResult(WindowsPreviewTrustStatus.Indeterminate); - } - - try - { - var hr = PInvoke.SHCreateItemFromParsingName(item.ParsingName, null, out IShellItem shellItem); - if (hr != HRESULT.S_OK) - { - return new WindowsPreviewTrustResult(WindowsPreviewTrustStatus.Indeterminate); - } - - var url = ShellItemHelpers.TryGetDisplayName(shellItem, SIGDN.SIGDN_URL); - - return url is null ? new WindowsPreviewTrustResult(WindowsPreviewTrustStatus.Indeterminate) : EvaluateUrlPolicy(url, item.FileSystemPath); - } - catch (Exception error) when (error is IOException or UnauthorizedAccessException or COMException or InvalidOperationException or NotSupportedException or SecurityException) - { - return new WindowsPreviewTrustResult(WindowsPreviewTrustStatus.Indeterminate); - } - } - - private static WindowsPreviewTrustResult EvaluateUrlPolicy(string url, string? fileSystemPath) - { - try - { - var zoneCheckHr = PInvoke.ZoneCheckUrlExCache(url, out var zonePolicy, sizeof(uint), 0, 0, PInvoke.URLACTION_SHELL_PREVIEW, (uint)PUAF.PUAF_NOUI, null, 0); - - return InterpretZoneCheckPolicy(zoneCheckHr, zonePolicy); - } - catch (EntryPointNotFoundException) - { - } - catch (DllNotFoundException) - { - } - - if (!string.IsNullOrWhiteSpace(fileSystemPath)) - { - try - { - var alternateDataStreamHr = PInvoke.GetZoneFromAlternateDataStreamEx(fileSystemPath, out var alternateDataStreamZone); - if (alternateDataStreamHr == HRESULT.S_OK && alternateDataStreamZone >= InternetZone) - { - return new WindowsPreviewTrustResult(WindowsPreviewTrustStatus.Blocked); - } - - if (alternateDataStreamHr != HRESULT.S_OK && alternateDataStreamHr.Value != FileNotFoundHResult) - { - return new WindowsPreviewTrustResult(WindowsPreviewTrustStatus.Indeterminate); - } - } - catch (EntryPointNotFoundException) - { - } - catch (DllNotFoundException) - { - } - } - - if (PInvoke.CoInternetCreateSecurityManager(null!, out var securityManager, 0) != HRESULT.S_OK) - { - return new WindowsPreviewTrustResult(WindowsPreviewTrustStatus.Indeterminate); - } - - var policy = new byte[sizeof(uint)]; - byte context = 0; - var hr = securityManager.ProcessUrlAction(url, PInvoke.URLACTION_SHELL_PREVIEW, policy, in context, 0, (uint)PUAF.PUAF_NOUI, 0); - - return InterpretUrlPolicy(hr, policy); - } - - internal static WindowsPreviewTrustResult InterpretUrlPolicy(HRESULT hr, ReadOnlySpan policy) - { - if (hr != HRESULT.S_OK || policy.Length < sizeof(uint)) - { - return new WindowsPreviewTrustResult(WindowsPreviewTrustStatus.Indeterminate); - } - - return InterpretUrlPolicy(hr, BinaryPrimitives.ReadUInt32LittleEndian(policy)); - } - - internal static WindowsPreviewTrustResult InterpretZoneCheckPolicy(HRESULT hr, uint policy) - { - if (hr.Failed) - { - return new WindowsPreviewTrustResult(WindowsPreviewTrustStatus.Indeterminate); - } - - return new WindowsPreviewTrustResult(policy == PInvoke.URLPOLICY_ALLOW ? WindowsPreviewTrustStatus.Allowed : WindowsPreviewTrustStatus.Blocked); - } - - internal static WindowsPreviewTrustResult InterpretUrlPolicy(HRESULT hr, uint policy) - { - if (hr != HRESULT.S_OK) - { - return new WindowsPreviewTrustResult(WindowsPreviewTrustStatus.Indeterminate); - } - - return InterpretPolicy(policy); - } - - private static WindowsPreviewTrustResult InterpretPolicy(uint policy) - { - var permissions = policy & PInvoke.URLPOLICY_MASK_PERMISSIONS; - - return new WindowsPreviewTrustResult(permissions == PInvoke.URLPOLICY_ALLOW ? WindowsPreviewTrustStatus.Allowed : WindowsPreviewTrustStatus.Blocked); - } -} - -internal sealed class WindowsPreviewHandlerTrustResolver : IWindowsPreviewHandlerTrustResolver -{ - private const string AutomaticallyPreviewUntrustedFilesValue = "AutomaticallyPreviewUntrustedFiles"; - - public bool AllowsUntrustedPreviews(Guid handlerClsid) - { - try - { - using var key = Registry.ClassesRoot.OpenSubKey($"CLSID\\{handlerClsid:B}", writable: false); - - return key?.GetValue(AutomaticallyPreviewUntrustedFilesValue) is int value && value == 1; - } - catch (Exception error) when (error is IOException or UnauthorizedAccessException or SecurityException) - { - return false; - } - } -} - -internal sealed class WindowsPreviewEnterpriseIdResolver : IWindowsPreviewEnterpriseIdResolver -{ - public bool HasEnterpriseId(ItemContext context) - { - ArgumentNullException.ThrowIfNull(context); - - if (context.CoreModel is not IWindowsStorable item || context.CoreModel is not IFile || string.IsNullOrWhiteSpace(item.ParsingName)) - { - return false; - } - - try - { - var hr = PInvoke.SHCreateItemFromParsingName(item.ParsingName, null, out IShellItem shellItem); - if (hr != HRESULT.S_OK || shellItem is not IShellItem2 shellItem2) - { - return false; - } - - return HasEnterpriseId(shellItem2); - } - catch (Exception error) when (error is IOException or UnauthorizedAccessException or COMException or InvalidOperationException or NotSupportedException or SecurityException) - { - return false; - } - } - - private static unsafe bool HasEnterpriseId(IShellItem2 shellItem) - { - var hr = shellItem.GetString(in PInvoke.PKEY_Security_EncryptionOwners, out var enterpriseId); - if (hr.Failed) - { - return false; - } - - try - { - return !string.IsNullOrEmpty(enterpriseId.ToString()); - } - finally - { - PInvoke.CoTaskMemFree(enterpriseId.Value); - } - } -} diff --git a/src/Files.Core/Capabilities/Previews/WindowsPreviewHandlerActivationPolicy.cs b/src/Files.Core/Capabilities/Previews/WindowsPreviewHandlerActivationPolicy.cs deleted file mode 100644 index 4639a52..0000000 --- a/src/Files.Core/Capabilities/Previews/WindowsPreviewHandlerActivationPolicy.cs +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (c) Files Community -// SPDX-License-Identifier: MPL-2.0 - -namespace Files.Core.Capabilities.Previews; - -/// Specifies the process context allowed for preview handler activation. -[Flags] -public enum WindowsPreviewHandlerActivationContext : uint -{ - /// Activate an in-process preview handler. - InProcessServer = 0x1, - /// Activate a local-server preview handler. - LocalServer = 0x4, - /// Use the caller's impersonation token when activating the local server. - EnableCloaking = 0x100000, -} - -/// Chooses the activation context for a preview handler. -public interface IWindowsPreviewHandlerActivationPolicy -{ - /// Gets the activation context for a handler. - /// The preview handler CLSID. - /// The permitted activation context. - WindowsPreviewHandlerActivationContext GetContext(Guid handlerClsid); -} - -/// Activates preview handlers through a local server. -public sealed class LocalServerWindowsPreviewHandlerActivationPolicy - : IWindowsPreviewHandlerActivationPolicy -{ - /// Gets the local-server activation context. - /// The preview handler CLSID. - /// A local-server activation context with cloaking enabled. - public WindowsPreviewHandlerActivationContext GetContext(Guid handlerClsid) - { - if (handlerClsid == Guid.Empty) - { - throw new ArgumentException("A preview handler CLSID is required.", nameof(handlerClsid)); - } - - return WindowsPreviewHandlerActivationContext.LocalServer | WindowsPreviewHandlerActivationContext.EnableCloaking; - } -} diff --git a/src/Files.Core/Composition/ArchiveFilesCoreBuilderExtensions.cs b/src/Files.Core/Composition/ArchiveFilesCoreBuilderExtensions.cs index b03070f..10edf76 100644 --- a/src/Files.Core/Composition/ArchiveFilesCoreBuilderExtensions.cs +++ b/src/Files.Core/Composition/ArchiveFilesCoreBuilderExtensions.cs @@ -6,6 +6,7 @@ using Files.Core.Capabilities.Archives; using Files.Core.Storage.Archives; using Files.Core.Storage.Archives.SevenZip; +using Files.Core.Windows; namespace Files.Core.Composition; diff --git a/src/Files.Core/Composition/FilesCoreBuilder.cs b/src/Files.Core/Composition/FilesCoreBuilder.cs index 597c742..d654d86 100644 --- a/src/Files.Core/Composition/FilesCoreBuilder.cs +++ b/src/Files.Core/Composition/FilesCoreBuilder.cs @@ -11,6 +11,7 @@ using Files.Core.Models; using Files.Core.Storage; using Files.Core.ViewSettings; +using Files.Core.Windows; namespace Files.Core.Composition; diff --git a/src/Files.Core/Composition/FilesCoreRuntime.cs b/src/Files.Core/Composition/FilesCoreRuntime.cs index 1766cd7..d37312e 100644 --- a/src/Files.Core/Composition/FilesCoreRuntime.cs +++ b/src/Files.Core/Composition/FilesCoreRuntime.cs @@ -8,6 +8,7 @@ using Files.Core.Data; using Files.Core.Storage; using Files.Core.ViewSettings; +using Files.Core.Windows; namespace Files.Core.Composition; diff --git a/src/Files.Core/Interop/Windows/IFileExplorerAppExtension.cs b/src/Files.Core/Interop/Windows/IFileExplorerAppExtension.cs deleted file mode 100644 index c627e93..0000000 --- a/src/Files.Core/Interop/Windows/IFileExplorerAppExtension.cs +++ /dev/null @@ -1,619 +0,0 @@ -// Copyright (c) Files Community -// SPDX-License-Identifier: MPL-2.0 - -using System.Runtime.InteropServices; -using System.Runtime.InteropServices.Marshalling; -using Windows.Win32.Foundation; - -namespace Windows.Win32.System.WinRT; - -/// Provides the base Windows Runtime inspection contract. -[GeneratedComInterface(Options = ComInterfaceOptions.ComObjectWrapper)] -[Guid("AF86E2E0-B12D-4C6A-9C5A-D7AA65101E90")] -[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] -internal partial interface IInspectable -{ - /// Gets the interface identifiers implemented by the object. - /// Receives the number of identifiers. - /// Receives the allocated identifier array. - /// The HRESULT returned by the object. - [PreserveSig] - HRESULT GetIids(out uint iidCount, out global::Windows.Win32.ComHeapPtr iids); - - /// Gets the runtime class name. - /// Receives the runtime class name. - /// The HRESULT returned by the object. - [PreserveSig] - HRESULT GetRuntimeClassName([MarshalUsing(typeof(global::Windows.Win32.HStringStringMarshaller))] out string? className); - - /// Gets the runtime trust level. - /// Receives the trust level. - /// The HRESULT returned by the object. - [PreserveSig] - HRESULT GetTrustLevel(out TrustLevel trustLevel); -} - -/// Enumerates Explorer app extensions for an item type. -[GeneratedComInterface(Options = ComInterfaceOptions.ComObjectWrapper)] -[Guid("104C1AFF-F09F-5AA1-945F-78737EE0FE45")] -[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] -internal partial interface IFileExplorerAppExtensionStatics : IInspectable -{ - /// Gets extensions registered for an item type. - /// The item type. - /// The cache lookup flags. - /// Receives a vector view of extensions. - /// The HRESULT returned by the extension cache. - [PreserveSig] - HRESULT GetExtensions([MarshalUsing(typeof(global::Windows.Win32.HStringStringMarshaller))] string extension, uint flags, [MarshalAs(UnmanagedType.Interface)] out object? extensions); - - /// Gets every cached Explorer app extension. - /// The cache lookup flags. - /// Receives a vector view of extensions. - /// The HRESULT returned by the extension cache. - [PreserveSig] - HRESULT GetAllExtensions(uint flags, [MarshalAs(UnmanagedType.Interface)] out object? extensions); -} - -/// Describes the original recovered Explorer app-extension ABI. -[GeneratedComInterface(Options = ComInterfaceOptions.ComObjectWrapper)] -[Guid("66C23D78-8E71-51EF-A184-ED7B6E6CDC90")] -[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] -internal partial interface IFileExplorerAppExtension : IInspectable -{ - /// Gets the extension display name. - /// Receives the display name. - /// The HRESULT returned by the extension. - [PreserveSig] - HRESULT GetDisplayName([MarshalUsing(typeof(global::Windows.Win32.HStringStringMarshaller))] out string? displayName); - - /// Gets the package full name. - /// Receives the package full name. - /// The HRESULT returned by the extension. - [PreserveSig] - HRESULT GetPackageFullName([MarshalUsing(typeof(global::Windows.Win32.HStringStringMarshaller))] out string? packageFullName); - - /// Gets the extension logo. - /// Receives the logo object. - /// The HRESULT returned by the extension. - [PreserveSig] - HRESULT GetLogo([MarshalAs(UnmanagedType.Interface)] out object? logo); - - /// Gets the extension verbs. - /// The cache lookup flags. - /// Receives the verb vector. - /// The HRESULT returned by the extension. - [PreserveSig] - HRESULT GetVerbs(uint flags, out IPropertySetVectorView? verbs); - - /// Gets the extended verb collection. - /// The cache lookup flags. - /// Receives the extended verb object. - /// The HRESULT returned by the extension. - [PreserveSig] - HRESULT GetVerbsEx(uint flags, [MarshalAs(UnmanagedType.Interface)] out object? verbs); - - /// Gets the extension conditions. - /// Receives the conditions object. - /// The HRESULT returned by the extension. - [PreserveSig] - HRESULT GetConditions([MarshalAs(UnmanagedType.Interface)] out object? conditions); -} - -/// Describes the second recovered Explorer app-extension ABI, which adds the level-one default state. -[GeneratedComInterface(Options = ComInterfaceOptions.ComObjectWrapper)] -[Guid("EB16945B-3A5D-5A8A-B666-8DFE27E5C818")] -[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] -internal partial interface IFileExplorerAppExtension2 : IInspectable -{ - /// Gets the extension display name. - /// Receives the display name. - /// The HRESULT returned by the extension. - [PreserveSig] - HRESULT GetDisplayName([MarshalUsing(typeof(global::Windows.Win32.HStringStringMarshaller))] out string? displayName); - - /// Gets the package full name. - /// Receives the package full name. - /// The HRESULT returned by the extension. - [PreserveSig] - HRESULT GetPackageFullName([MarshalUsing(typeof(global::Windows.Win32.HStringStringMarshaller))] out string? packageFullName); - - /// Gets the extension logo. - /// Receives the logo object. - /// The HRESULT returned by the extension. - [PreserveSig] - HRESULT GetLogo([MarshalAs(UnmanagedType.Interface)] out object? logo); - - /// Gets whether the extension is the level-one default. - /// Receives the default state. - /// The HRESULT returned by the extension. - [PreserveSig] - HRESULT GetIsL1Default([MarshalAs(UnmanagedType.U1)] out bool isDefault); - - /// Gets the extension verbs. - /// The cache lookup flags. - /// Receives the verb vector. - /// The HRESULT returned by the extension. - [PreserveSig] - HRESULT GetVerbs(uint flags, out IPropertySetVectorView? verbs); - - /// Gets the extended verb collection. - /// The cache lookup flags. - /// Receives the extended verb object. - /// The HRESULT returned by the extension. - [PreserveSig] - HRESULT GetVerbsEx(uint flags, [MarshalAs(UnmanagedType.Interface)] out object? verbs); - - /// Gets the extension conditions. - /// Receives the conditions object. - /// The HRESULT returned by the extension. - [PreserveSig] - HRESULT GetConditions([MarshalAs(UnmanagedType.Interface)] out object? conditions); -} - -/// Provides indexed access to the original app-extension interface. -[GeneratedComInterface(Options = ComInterfaceOptions.ComObjectWrapper)] -[Guid("08ED2B5C-6EE2-5C20-B0E1-A1C0C739F17E")] -[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] -internal partial interface IFileExplorerAppExtensionVectorView : IInspectable -{ - /// Gets an extension by index. - /// The zero-based index. - /// Receives the extension. - /// The HRESULT returned by the vector. - [PreserveSig] - HRESULT GetAt(uint index, out IFileExplorerAppExtension? extension); - - /// Gets the number of extensions. - /// Receives the number of extensions. - /// The HRESULT returned by the vector. - [PreserveSig] - HRESULT GetSize(out uint size); - - /// Finds an extension in the vector. - /// The extension to find. - /// Receives its index. - /// Receives whether the extension was found. - /// The HRESULT returned by the vector. - [PreserveSig] - HRESULT IndexOf(IFileExplorerAppExtension? value, out uint index, [MarshalAs(UnmanagedType.U1)] out bool found); - - /// Copies extensions into a caller-provided array. - /// The first index to copy. - /// The array capacity. - /// The destination array. - /// Receives the number copied. - /// The HRESULT returned by the vector. - [PreserveSig] - HRESULT GetMany(uint startIndex, uint capacity, [Out, MarshalUsing(CountElementName = nameof(capacity))] IFileExplorerAppExtension?[] values, out uint actual); -} - -/// Provides indexed access to the second app-extension interface revision. -[GeneratedComInterface(Options = ComInterfaceOptions.ComObjectWrapper)] -[Guid("0E5F24ED-9BC4-5B7B-9DDB-46150318F868")] -[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] -internal partial interface IFileExplorerAppExtensionVectorView2 : IInspectable -{ - /// Gets an extension by index. - /// The zero-based index. - /// Receives the extension. - /// The HRESULT returned by the vector. - [PreserveSig] - HRESULT GetAt(uint index, out IFileExplorerAppExtension2? extension); - - /// Gets the number of extensions. - /// Receives the number of extensions. - /// The HRESULT returned by the vector. - [PreserveSig] - HRESULT GetSize(out uint size); - - /// Finds an extension in the vector. - /// The extension to find. - /// Receives its index. - /// Receives whether the extension was found. - /// The HRESULT returned by the vector. - [PreserveSig] - HRESULT IndexOf(IFileExplorerAppExtension2? value, out uint index, [MarshalAs(UnmanagedType.U1)] out bool found); - - /// Copies extensions into a caller-provided array. - /// The first index to copy. - /// The array capacity. - /// The destination array. - /// Receives the number copied. - /// The HRESULT returned by the vector. - [PreserveSig] - HRESULT GetMany(uint startIndex, uint capacity, [Out, MarshalUsing(CountElementName = nameof(capacity))] IFileExplorerAppExtension2?[] values, out uint actual); -} - -/// Provides indexed access to Explorer verb property sets. -[GeneratedComInterface(Options = ComInterfaceOptions.ComObjectWrapper)] -[Guid("A79C3578-C5C8-5B61-AFC7-8DA842914434")] -[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] -internal partial interface IPropertySetVectorView : IInspectable -{ - /// Gets a property set by index. - /// The zero-based index. - /// Receives the property set. - /// The HRESULT returned by the vector. - [PreserveSig] - HRESULT GetAt(uint index, out IPropertySet? value); - - /// Gets the number of property sets. - /// Receives the number of property sets. - /// The HRESULT returned by the vector. - [PreserveSig] - HRESULT GetSize(out uint size); - - /// Finds a property set in the vector. - /// The property set to find. - /// Receives its index. - /// Receives whether the property set was found. - /// The HRESULT returned by the vector. - [PreserveSig] - HRESULT IndexOf(IPropertySet? value, out uint index, [MarshalAs(UnmanagedType.U1)] out bool found); - - /// Copies property sets into a caller-provided array. - /// The first index to copy. - /// The array capacity. - /// The destination array. - /// Receives the number copied. - /// The HRESULT returned by the vector. - [PreserveSig] - HRESULT GetMany(uint startIndex, uint capacity, [Out, MarshalUsing(CountElementName = nameof(capacity))] IPropertySet?[] values, out uint actual); -} - -/// Identifies a Windows Runtime property set. This interface adds no ABI slots; map access is obtained through . -[GeneratedComInterface(Options = ComInterfaceOptions.ComObjectWrapper)] -[Guid("8A43ED9F-F4E6-4421-ACF9-1DAB2986820C")] -[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] -internal partial interface IPropertySet : IInspectable -{ -} - -/// Provides mutable access to a string-to-inspectable map. -[GeneratedComInterface(Options = ComInterfaceOptions.ComObjectWrapper)] -[Guid("1B0D3570-0877-5EC2-8A2C-3B9539506ACA")] -[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] -internal partial interface IStringInspectableMap : IInspectable -{ - /// Gets a value by key. - /// The lookup key. - /// Receives the value. - /// The HRESULT returned by the map. - [PreserveSig] - HRESULT Lookup([MarshalUsing(typeof(global::Windows.Win32.HStringStringMarshaller))] string key, out IInspectable? value); - - /// Gets the number of entries. - /// Receives the entry count. - /// The HRESULT returned by the map. - [PreserveSig] - HRESULT GetSize(out uint size); - - /// Determines whether the map contains a key. - /// The lookup key. - /// Receives whether the key exists. - /// The HRESULT returned by the map. - [PreserveSig] - HRESULT HasKey([MarshalUsing(typeof(global::Windows.Win32.HStringStringMarshaller))] string key, [MarshalAs(UnmanagedType.U1)] out bool found); - - /// Gets a read-only view of the map. - /// Receives the map view. - /// The HRESULT returned by the map. - [PreserveSig] - HRESULT GetView(out IStringInspectableMapView? view); - - /// Inserts or replaces a value. - /// The key to insert. - /// The value to insert. - /// Receives whether an existing value was replaced. - /// The HRESULT returned by the map. - [PreserveSig] - HRESULT Insert([MarshalUsing(typeof(global::Windows.Win32.HStringStringMarshaller))] string key, IInspectable? value, [MarshalAs(UnmanagedType.U1)] out bool replaced); - - /// Removes a value. - /// The key to remove. - /// The HRESULT returned by the map. - [PreserveSig] - HRESULT Remove([MarshalUsing(typeof(global::Windows.Win32.HStringStringMarshaller))] string key); - - /// Removes every value. - /// The HRESULT returned by the map. - [PreserveSig] - HRESULT Clear(); -} - -/// Provides read-only access to a string-to-inspectable map. -[GeneratedComInterface(Options = ComInterfaceOptions.ComObjectWrapper)] -[Guid("BB78502A-F79D-54FA-92C9-90C5039FDF7E")] -[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] -internal partial interface IStringInspectableMapView : IInspectable -{ - /// Gets a value by key. - /// The lookup key. - /// Receives the value. - /// The HRESULT returned by the map view. - [PreserveSig] - HRESULT Lookup([MarshalUsing(typeof(global::Windows.Win32.HStringStringMarshaller))] string key, out IInspectable? value); - - /// Gets the number of entries. - /// Receives the entry count. - /// The HRESULT returned by the map view. - [PreserveSig] - HRESULT GetSize(out uint size); - - /// Determines whether the map view contains a key. - /// The lookup key. - /// Receives whether the key exists. - /// The HRESULT returned by the map view. - [PreserveSig] - HRESULT HasKey([MarshalUsing(typeof(global::Windows.Win32.HStringStringMarshaller))] string key, [MarshalAs(UnmanagedType.U1)] out bool found); - - /// Splits the map view into two views. - /// Receives the first view. - /// Receives the second view. - /// The HRESULT returned by the map view. - [PreserveSig] - HRESULT Split(out IStringInspectableMapView? first, out IStringInspectableMapView? second); -} - -/// Reads scalar and array values from a Windows Runtime property value. -[GeneratedComInterface(Options = ComInterfaceOptions.ComObjectWrapper)] -[Guid("4BD682DD-7554-40E9-9A9B-82654EDE7E62")] -[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] -internal partial interface IPropertyValue : IInspectable -{ - /// Gets the stored property type. - /// Receives the property type. - /// The HRESULT returned by the value. - [PreserveSig] - HRESULT GetPropertyType(out global::Windows.Foundation.PropertyType value); - - /// Gets whether the value is a numeric scalar. - /// Receives whether the value is a numeric scalar. - /// The HRESULT returned by the value. - [PreserveSig] - HRESULT GetIsNumericScalar([MarshalAs(UnmanagedType.U1)] out bool value); - - /// Gets an unsigned 8-bit value. - /// Receives the value. - /// The HRESULT returned by the value. - [PreserveSig] - HRESULT GetUInt8(out byte value); - - /// Gets a signed 16-bit value. - /// Receives the value. - /// The HRESULT returned by the value. - [PreserveSig] - HRESULT GetInt16(out short value); - - /// Gets an unsigned 16-bit value. - /// Receives the value. - /// The HRESULT returned by the value. - [PreserveSig] - HRESULT GetUInt16(out ushort value); - - /// Gets a signed 32-bit value. - /// Receives the value. - /// The HRESULT returned by the value. - [PreserveSig] - HRESULT GetInt32(out int value); - - /// Gets an unsigned 32-bit value. - /// Receives the value. - /// The HRESULT returned by the value. - [PreserveSig] - HRESULT GetUInt32(out uint value); - - /// Gets a signed 64-bit value. - /// Receives the value. - /// The HRESULT returned by the value. - [PreserveSig] - HRESULT GetInt64(out long value); - - /// Gets an unsigned 64-bit value. - /// Receives the value. - /// The HRESULT returned by the value. - [PreserveSig] - HRESULT GetUInt64(out ulong value); - - /// Gets a single-precision value. - /// Receives the value. - /// The HRESULT returned by the value. - [PreserveSig] - HRESULT GetSingle(out float value); - - /// Gets a double-precision value. - /// Receives the value. - /// The HRESULT returned by the value. - [PreserveSig] - HRESULT GetDouble(out double value); - - /// Gets a UTF-16 character. - /// Receives the value. - /// The HRESULT returned by the value. - [PreserveSig] - HRESULT GetChar16(out char value); - - /// Gets a Boolean value. - /// Receives the value. - /// The HRESULT returned by the value. - [PreserveSig] - HRESULT GetBoolean([MarshalAs(UnmanagedType.U1)] out bool value); - - /// Gets a string value. - /// Receives the value. - /// The HRESULT returned by the value. - [PreserveSig] - HRESULT GetString([MarshalUsing(typeof(global::Windows.Win32.HStringStringMarshaller))] out string? value); - - /// Gets a GUID value. - /// Receives the value. - /// The HRESULT returned by the value. - [PreserveSig] - HRESULT GetGuid(out Guid value); - - /// Gets a Windows Runtime date-time ABI value. - /// Receives the universal-time tick value. - /// The HRESULT returned by the value. - [PreserveSig] - HRESULT GetDateTime(out long universalTime); - - /// Gets a Windows Runtime time-span ABI value. - /// Receives the duration tick value. - /// The HRESULT returned by the value. - [PreserveSig] - HRESULT GetTimeSpan(out long duration); - - /// Gets a point value. - /// Receives the value. - /// The HRESULT returned by the value. - [PreserveSig] - HRESULT GetPoint(out global::Windows.Foundation.Point value); - - /// Gets a size value. - /// Receives the value. - /// The HRESULT returned by the value. - [PreserveSig] - HRESULT GetSize(out global::Windows.Foundation.Size value); - - /// Gets a rectangle value. - /// Receives the value. - /// The HRESULT returned by the value. - [PreserveSig] - HRESULT GetRect(out global::Windows.Foundation.Rect value); - - /// Gets an unsigned 8-bit array. - /// Receives the array length. - /// Receives the allocated array. - /// The HRESULT returned by the value. - [PreserveSig] - HRESULT GetUInt8Array(out uint valueLength, [MarshalUsing(CountElementName = nameof(valueLength))] out byte[]? value); - - /// Gets a signed 16-bit array. - /// Receives the array length. - /// Receives the allocated array. - /// The HRESULT returned by the value. - [PreserveSig] - HRESULT GetInt16Array(out uint valueLength, [MarshalUsing(CountElementName = nameof(valueLength))] out short[]? value); - - /// Gets an unsigned 16-bit array. - /// Receives the array length. - /// Receives the allocated array. - /// The HRESULT returned by the value. - [PreserveSig] - HRESULT GetUInt16Array(out uint valueLength, [MarshalUsing(CountElementName = nameof(valueLength))] out ushort[]? value); - - /// Gets a signed 32-bit array. - /// Receives the array length. - /// Receives the allocated array. - /// The HRESULT returned by the value. - [PreserveSig] - HRESULT GetInt32Array(out uint valueLength, [MarshalUsing(CountElementName = nameof(valueLength))] out int[]? value); - - /// Gets an unsigned 32-bit array. - /// Receives the array length. - /// Receives the allocated array. - /// The HRESULT returned by the value. - [PreserveSig] - HRESULT GetUInt32Array(out uint valueLength, [MarshalUsing(CountElementName = nameof(valueLength))] out uint[]? value); - - /// Gets a signed 64-bit array. - /// Receives the array length. - /// Receives the allocated array. - /// The HRESULT returned by the value. - [PreserveSig] - HRESULT GetInt64Array(out uint valueLength, [MarshalUsing(CountElementName = nameof(valueLength))] out long[]? value); - - /// Gets an unsigned 64-bit array. - /// Receives the array length. - /// Receives the allocated array. - /// The HRESULT returned by the value. - [PreserveSig] - HRESULT GetUInt64Array(out uint valueLength, [MarshalUsing(CountElementName = nameof(valueLength))] out ulong[]? value); - - /// Gets a single-precision array. - /// Receives the array length. - /// Receives the allocated array. - /// The HRESULT returned by the value. - [PreserveSig] - HRESULT GetSingleArray(out uint valueLength, [MarshalUsing(CountElementName = nameof(valueLength))] out float[]? value); - - /// Gets a double-precision array. - /// Receives the array length. - /// Receives the allocated array. - /// The HRESULT returned by the value. - [PreserveSig] - HRESULT GetDoubleArray(out uint valueLength, [MarshalUsing(CountElementName = nameof(valueLength))] out double[]? value); - - /// Gets a UTF-16 character array. - /// Receives the array length. - /// Receives the allocated array. - /// The HRESULT returned by the value. - [PreserveSig] - HRESULT GetChar16Array(out uint valueLength, [MarshalUsing(CountElementName = nameof(valueLength))] out ushort[]? value); - - /// Gets a Windows Runtime Boolean array. - /// Receives the array length. - /// Receives the allocated one-byte Boolean values. - /// The HRESULT returned by the value. - [PreserveSig] - HRESULT GetBooleanArray(out uint valueLength, [MarshalUsing(CountElementName = nameof(valueLength))] out byte[]? value); - - /// Gets a string array. - /// Receives the array length. - /// Receives the allocated array. - /// The HRESULT returned by the value. - [PreserveSig] - HRESULT GetStringArray(out uint valueLength, - [MarshalUsing(CountElementName = nameof(valueLength))] - [MarshalUsing(typeof(global::Windows.Win32.HStringStringMarshaller), ElementIndirectionDepth = 1)] out string?[]? value); - - /// Gets an inspectable array. - /// Receives the array length. - /// Receives the allocated array. - /// The HRESULT returned by the value. - [PreserveSig] - HRESULT GetInspectableArray(out uint valueLength, [MarshalUsing(CountElementName = nameof(valueLength))] out IInspectable?[]? value); - - /// Gets a GUID array. - /// Receives the array length. - /// Receives the allocated array. - /// The HRESULT returned by the value. - [PreserveSig] - HRESULT GetGuidArray(out uint valueLength, [MarshalUsing(CountElementName = nameof(valueLength))] out Guid[]? value); - - /// Gets a Windows Runtime date-time ABI array. - /// Receives the array length. - /// Receives the allocated universal-time tick values. - /// The HRESULT returned by the value. - [PreserveSig] - HRESULT GetDateTimeArray(out uint valueLength, [MarshalUsing(CountElementName = nameof(valueLength))] out long[]? value); - - /// Gets a Windows Runtime time-span ABI array. - /// Receives the array length. - /// Receives the allocated duration tick values. - /// The HRESULT returned by the value. - [PreserveSig] - HRESULT GetTimeSpanArray(out uint valueLength, [MarshalUsing(CountElementName = nameof(valueLength))] out long[]? value); - - /// Gets a point array. - /// Receives the array length. - /// Receives the allocated array. - /// The HRESULT returned by the value. - [PreserveSig] - HRESULT GetPointArray(out uint valueLength, [MarshalUsing(CountElementName = nameof(valueLength))] out global::Windows.Foundation.Point[]? value); - - /// Gets a size array. - /// Receives the array length. - /// Receives the allocated array. - /// The HRESULT returned by the value. - [PreserveSig] - HRESULT GetSizeArray(out uint valueLength, [MarshalUsing(CountElementName = nameof(valueLength))] out global::Windows.Foundation.Size[]? value); - - /// Gets a rectangle array. - /// Receives the array length. - /// Receives the allocated array. - /// The HRESULT returned by the value. - [PreserveSig] - HRESULT GetRectArray(out uint valueLength, [MarshalUsing(CountElementName = nameof(valueLength))] out global::Windows.Foundation.Rect[]? value); -} diff --git a/src/Files.Core/Models/FolderModel.cs b/src/Files.Core/Models/FolderModel.cs index b5a98c0..e8c251d 100644 --- a/src/Files.Core/Models/FolderModel.cs +++ b/src/Files.Core/Models/FolderModel.cs @@ -4,7 +4,7 @@ using System.Runtime.CompilerServices; using Files.Core.Capabilities; using Files.Core.Storage; -using Files.Core.Storage.Windows; +using Files.Core.Windows; using OwlCore.Storage; namespace Files.Core.Models; diff --git a/src/Files.Core/Models/StorableModel.cs b/src/Files.Core/Models/StorableModel.cs index 65fe045..8f64229 100644 --- a/src/Files.Core/Models/StorableModel.cs +++ b/src/Files.Core/Models/StorableModel.cs @@ -3,7 +3,7 @@ using Files.Core.Capabilities; using Files.Core.Storage; -using Files.Core.Storage.Windows; +using Files.Core.Windows; using OwlCore.Storage; namespace Files.Core.Models; diff --git a/src/Files.Core/README.md b/src/Files.Core/README.md index 1400a2a..6c1930b 100644 --- a/src/Files.Core/README.md +++ b/src/Files.Core/README.md @@ -121,9 +121,12 @@ and cross-source transfer coordination remain separate extension boundaries. ## Boundaries +- UI-independent Windows integration lives under `Windows`, grouped by + responsibility with a shared `Files.Core.Windows` namespace. Low-level native + declarations remain under `Windows/Interop`. - WinUI ViewModels, dispatcher adaptation, image decoding, media/document - rendering, the preview child HWND, activation, drag/drop, and context menus - belong to the Files UI host. + rendering, preview presentation, item activation, drag/drop gestures, + `DataPackage` adaptation, and menu presentation belong to the Files UI host. - Search/tag behavior needs a selected backend and custom location handler. - Additional storage sources plug into the same storage, capability, location, and operation contracts. diff --git a/src/Files.Core/Storage/Archives/SevenZip/SevenZipArchiveBackend.cs b/src/Files.Core/Storage/Archives/SevenZip/SevenZipArchiveBackend.cs index 59064d2..87da008 100644 --- a/src/Files.Core/Storage/Archives/SevenZip/SevenZipArchiveBackend.cs +++ b/src/Files.Core/Storage/Archives/SevenZip/SevenZipArchiveBackend.cs @@ -3,7 +3,7 @@ using System.IO; using Files.Core.Models; -using Files.Core.Storage.Windows; +using Files.Core.Windows; using global::SevenZip; using OwlCore.Storage; diff --git a/src/Files.Core/Storage/Windows/WindowsShellContextualCommand.cs b/src/Files.Core/Storage/Windows/WindowsShellContextualCommand.cs deleted file mode 100644 index c213519..0000000 --- a/src/Files.Core/Storage/Windows/WindowsShellContextualCommand.cs +++ /dev/null @@ -1,104 +0,0 @@ -// Copyright (c) Files Community -// SPDX-License-Identifier: MPL-2.0 - -namespace Files.Core.Storage.Windows; - -/// -/// Defines the stable identifiers used for contextual Windows Shell commands. -/// -public static class WindowsShellContextualCommandIds -{ - /// Mounts a disc image. - public const string Mount = "windows.mount"; - - /// Burns a disc image. - public const string BurnDiscImage = "windows.discimage.burn"; - - /// Sets the selected image as the desktop background. - public const string SetDesktopBackground = "windows.setdesktopwallpaper"; - - /// Empties the Recycle Bin. - public const string EmptyRecycleBin = "windows.recyclebin.empty"; - - /// Restores every item in the Recycle Bin. - public const string RestoreAllRecycleBinItems = "windows.recyclebin.restoreall"; - - /// Restores the selected Recycle Bin items. - public const string RestoreRecycleBinItems = "windows.recyclebin.restoreitems"; - - /// Creates a ZIP archive from the selection. - public const string CompressToZip = "windows.zip.action"; - - /// Pins a folder to Quick access. - public const string PinToQuickAccess = "windows.pintohome"; - - /// Adds a file to Favorites. - public const string AddToFavorites = "windows.pintohomefile"; - - /// Copies the selected item paths. - public const string CopyAsPath = "windows.copyaspath"; -} - -/// -/// Describes one contextual Windows Shell command without retaining apartment-bound COM objects. -/// -public sealed class WindowsShellContextualCommand -{ - internal WindowsShellContextualCommandToken Token { get; } - - /// Gets the stable command identifier. - public string Id { get; } - - /// Gets a value indicating whether the command can currently be invoked. - public bool IsEnabled { get; } - - /// Gets the context whose changes can affect this command. - public WindowsShellContextualCommandScope Scope { get; } - - internal WindowsShellContextualCommand(string id, bool isEnabled, WindowsShellContextualCommandScope scope, WindowsShellContextualCommandToken token) - { - ArgumentException.ThrowIfNullOrWhiteSpace(id); - ArgumentNullException.ThrowIfNull(token); - - Id = id; - IsEnabled = isEnabled; - Scope = scope; - Token = token; - } -} - -/// -/// Identifies the browsing context whose changes can affect a contextual Windows Shell command. -/// -[Flags] -public enum WindowsShellContextualCommandScope -{ - /// The command is not affected by the browsing context. - None = 0, - - /// The command depends on the selected items. - Selection = 1 << 0, - - /// The command depends on the current location. - Location = 1 << 1, - - /// The command can depend on the selection or current location. - All = Selection | Location, -} - -internal abstract record WindowsShellContextualCommandToken; - -internal sealed record WindowsShellAppExtensionContextualCommandToken(WindowsShellAppExtensionCommand Command) : WindowsShellContextualCommandToken; - -internal sealed record WindowsShellContextMenuContextualCommandToken(WindowsShellContextMenuTargetKind TargetKind) : WindowsShellContextualCommandToken; - -internal sealed record WindowsShellCommandStoreContextualCommandToken(string BackendId) : WindowsShellContextualCommandToken; - -internal sealed record WindowsShellEmptyRecycleBinContextualCommandToken : WindowsShellContextualCommandToken; - -internal enum WindowsShellContextMenuTargetKind -{ - Selection, - LocationItem, - LocationBackground, -} diff --git a/src/Files.Core/Storage/Windows/WindowsShellPropertySheetData.cs b/src/Files.Core/Storage/Windows/WindowsShellPropertySheetData.cs deleted file mode 100644 index 5491d45..0000000 --- a/src/Files.Core/Storage/Windows/WindowsShellPropertySheetData.cs +++ /dev/null @@ -1,543 +0,0 @@ -// Copyright (c) Files Community -// SPDX-License-Identifier: MPL-2.0 - -namespace Files.Core.Storage.Windows; - -/// -/// Identifies a property page implemented by ReFiles from Windows Shell data sources. -/// -public enum WindowsShellPropertyPageKind -{ - /// The common file-system information page. - General, - - /// The drive error-checking and optimization page. - Tools, - - /// The storage-device inventory page. - Hardware, - - /// The Shell link configuration page. - Shortcut, - - /// The application compatibility page. - Compatibility, - - /// The SMB sharing page. - Sharing, - - /// The NTFS discretionary access control page. - Security, - - /// The File History and volume snapshot page. - PreviousVersions, - - /// The NTFS disk-quota page. - Quota, - - /// The folder customization page. - Customize, - - /// The Authenticode and catalog signature page. - DigitalSignatures, - - /// The Windows property-system details page. - Details, -} - -/// -/// Contains native Windows data used to render a selection's property pages without creating native property-sheet windows. -/// -public sealed class WindowsShellPropertySheetData -{ - /// Gets the pages that apply to the selection in display order. - public IReadOnlyList Pages { get; } - - /// Gets drive capabilities when the selected item is a volume root. - public WindowsShellDriveProperties? Drive { get; } - - /// Gets Shell link data when the selected item is a shortcut. - public WindowsShellShortcutProperties? Shortcut { get; } - - /// Gets application compatibility data when the selection resolves to an executable. - public WindowsShellCompatibilityProperties? Compatibility { get; } - - /// Gets SMB sharing data when the selected item is a folder. - public WindowsShellSharingProperties? Sharing { get; } - - /// Gets NTFS access-control data when the selection contains file-system items. - public WindowsShellSecurityProperties? Security { get; } - - /// Gets the previous versions discovered for the selected item. - public IReadOnlyList PreviousVersions { get; } - - /// Gets the storage devices displayed by the drive Hardware page. - public IReadOnlyList HardwareDevices { get; } - - /// Gets NTFS disk-quota state when the selected volume supports quotas. - public WindowsShellQuotaProperties? Quota { get; } - - /// Gets folder customization data when the selected item is a folder. - public WindowsShellFolderCustomizationProperties? Customization { get; } - - /// Gets embedded Authenticode signatures. - public IReadOnlyList EmbeddedSignatures { get; } - - /// Gets signatures supplied by catalogs that contain the selected file. - public IReadOnlyList CatalogSignatures { get; } - - /// Gets ordered values from the Shell full-details property list. - public IReadOnlyList Details { get; } - - internal WindowsShellPropertySheetData( - IReadOnlyList pages, - WindowsShellDriveProperties? drive, - WindowsShellShortcutProperties? shortcut, - WindowsShellCompatibilityProperties? compatibility, - WindowsShellSharingProperties? sharing, - WindowsShellSecurityProperties? security, - IReadOnlyList previousVersions, - IReadOnlyList hardwareDevices, - WindowsShellQuotaProperties? quota, - WindowsShellFolderCustomizationProperties? customization, - IReadOnlyList embeddedSignatures, - IReadOnlyList catalogSignatures, - IReadOnlyList details) - { - Pages = pages; - Drive = drive; - Shortcut = shortcut; - Compatibility = compatibility; - Sharing = sharing; - Security = security; - PreviousVersions = previousVersions; - HardwareDevices = hardwareDevices; - Quota = quota; - Customization = customization; - EmbeddedSignatures = embeddedSignatures; - CatalogSignatures = catalogSignatures; - Details = details; - } -} - -/// -/// Contains the executable resolved for Explorer's application compatibility page. -/// -public sealed class WindowsShellCompatibilityProperties -{ - /// Gets the executable path whose compatibility settings are managed. - public string ExecutablePath { get; } - - internal WindowsShellCompatibilityProperties(string executablePath) - { - ExecutablePath = executablePath; - } -} - -/// -/// Contains capabilities used by the drive General and Tools pages. -/// -public sealed class WindowsShellDriveProperties -{ - /// Gets the normalized volume-root path. - public string RootPath { get; } - - /// Gets the value returned by GetDriveTypeW. - public uint DriveType { get; } - - /// Gets the filesystem capability flags returned by GetVolumeInformationW. - public uint FileSystemFlags { get; } - - /// Gets a value indicating whether Explorer exposes its error-checking command. - public bool SupportsErrorChecking { get; } - - /// Gets a value indicating whether Explorer exposes its optimization command. - public bool SupportsOptimization { get; } - - internal WindowsShellDriveProperties(string rootPath, uint driveType, uint fileSystemFlags, bool supportsErrorChecking, bool supportsOptimization) - { - RootPath = rootPath; - DriveType = driveType; - FileSystemFlags = fileSystemFlags; - SupportsErrorChecking = supportsErrorChecking; - SupportsOptimization = supportsOptimization; - } -} - -/// -/// Describes one device displayed by Explorer's drive Hardware page. -/// -public sealed class WindowsShellHardwareDevice -{ - /// Gets the PNG data for the device icon loaded by SetupAPI. - public ReadOnlyMemory IconData { get; } - - /// Gets the device's display name. - public string Name { get; } - - /// Gets the localized setup-class description. - public string Type { get; } - - /// Gets the device manufacturer. - public string Manufacturer { get; } - - /// Gets the device location description. - public string Location { get; } - - /// Gets the device UI location number when one is assigned. - public uint? LocationNumber { get; } - - /// Gets the provider-supplied format for the device UI location number. - public string LocationNumberFormat { get; } - - /// Gets the Configuration Manager status flags. - public uint Status { get; } - - /// Gets the Configuration Manager problem code. - public uint ProblemCode { get; } - - /// Gets the stable device-instance identifier. - public string InstanceId { get; } - - internal WindowsShellHardwareDevice( - ReadOnlyMemory iconData, - string name, - string type, - string manufacturer, - string location, - uint? locationNumber, - string locationNumberFormat, - uint status, - uint problemCode, - string instanceId) - { - IconData = iconData; - Name = name; - Type = type; - Manufacturer = manufacturer; - Location = location; - LocationNumber = locationNumber; - LocationNumberFormat = locationNumberFormat; - Status = status; - ProblemCode = problemCode; - InstanceId = instanceId; - } -} - -/// -/// Contains the default NTFS quota policy for a volume. -/// -public sealed class WindowsShellQuotaProperties -{ - /// Gets the volume root path. - public string RootPath { get; } - - /// Gets the Shell display name for the volume. - public string DisplayName { get; } - - /// Gets a value indicating whether reading quota policy requires elevation. - public bool RequiresElevation { get; } - - /// Gets a value indicating whether quota tracking is enabled. - public bool IsTrackingEnabled { get; } - - /// Gets a value indicating whether quota limits are enforced. - public bool IsLimitEnforced { get; } - - /// Gets a value indicating whether limit events are logged. - public bool LogsLimitEvents { get; } - - /// Gets a value indicating whether warning events are logged. - public bool LogsWarningEvents { get; } - - /// Gets the default per-user quota limit in bytes, or -1 for no limit. - public long DefaultLimit { get; } - - /// Gets the default per-user warning threshold in bytes, or -1 for no threshold. - public long DefaultThreshold { get; } - - internal WindowsShellQuotaProperties( - string rootPath, - string displayName, - bool requiresElevation, - bool isTrackingEnabled, - bool isLimitEnforced, - bool logsLimitEvents, - bool logsWarningEvents, - long defaultLimit, - long defaultThreshold) - { - RootPath = rootPath; - DisplayName = displayName; - RequiresElevation = requiresElevation; - IsTrackingEnabled = isTrackingEnabled; - IsLimitEnforced = isLimitEnforced; - LogsLimitEvents = logsLimitEvents; - LogsWarningEvents = logsWarningEvents; - DefaultLimit = defaultLimit; - DefaultThreshold = defaultThreshold; - } -} - -/// -/// Contains values read from an IShellLinkW object. -/// -public sealed class WindowsShellShortcutProperties -{ - /// Gets the shortcut target path. - public string TargetPath { get; } - - /// Gets the target's Shell type description. - public string TargetType { get; } - - /// Gets the target's containing folder name. - public string TargetLocation { get; } - - /// Gets the command-line arguments. - public string Arguments { get; } - - /// Gets the working directory. - public string WorkingDirectory { get; } - - /// Gets the encoded Shell hotkey. - public ushort Hotkey { get; } - - /// Gets the target window show command. - public int ShowCommand { get; } - - /// Gets the shortcut comment. - public string Comment { get; } - - /// Gets the custom icon path. - public string IconPath { get; } - - /// Gets the custom icon resource index. - public int IconIndex { get; } - - internal WindowsShellShortcutProperties( - string targetPath, - string targetType, - string targetLocation, - string arguments, - string workingDirectory, - ushort hotkey, - int showCommand, - string comment, - string iconPath, - int iconIndex) - { - TargetPath = targetPath; - TargetType = targetType; - TargetLocation = targetLocation; - Arguments = arguments; - WorkingDirectory = workingDirectory; - Hotkey = hotkey; - ShowCommand = showCommand; - Comment = comment; - IconPath = iconPath; - IconIndex = iconIndex; - } -} - -/// -/// Contains SMB sharing state for a folder. -/// -public sealed class WindowsShellSharingProperties -{ - /// Gets the local folder path represented by the page. - public string ObjectPath { get; } - - /// Gets the folder name displayed by the page. - public string DisplayName { get; } - - /// Gets a value indicating whether the folder is inside an SMB share. - public bool IsShared { get; } - - /// Gets the containing share name. - public string ShareName { get; } - - /// Gets the UNC path that addresses the selected folder. - public string NetworkPath { get; } - - /// Gets a value indicating whether password-protection guidance is applicable to this computer. - public bool ShowPasswordProtection { get; } - - /// Gets a value indicating whether users must authenticate to access shared folders. - public bool IsPasswordProtectionEnabled { get; } - - internal WindowsShellSharingProperties(string objectPath, string displayName, bool isShared, string shareName, string networkPath, bool showPasswordProtection, bool isPasswordProtectionEnabled) - { - ObjectPath = objectPath; - DisplayName = displayName; - IsShared = isShared; - ShareName = shareName; - NetworkPath = networkPath; - ShowPasswordProtection = showPasswordProtection; - IsPasswordProtectionEnabled = isPasswordProtectionEnabled; - } -} - -/// -/// Contains NTFS discretionary access-control state for one file-system item. -/// -public sealed class WindowsShellSecurityProperties -{ - /// Gets the path whose access-control list was read. - public string ObjectPath { get; } - - /// Gets the principals present in the discretionary access-control list. - public IReadOnlyList Principals { get; } - - internal WindowsShellSecurityProperties(string objectPath, IReadOnlyList principals) - { - ObjectPath = objectPath; - Principals = principals; - } -} - -/// -/// Describes the access masks assigned to a security principal. -/// -public sealed class WindowsShellSecurityPrincipal -{ - /// Gets the account's display name. - public string Name { get; } - - /// Gets the account's string SID. - public string Sid { get; } - - /// Gets the PNG data for the ACLUI principal icon. - public ReadOnlyMemory IconData { get; } - - /// Gets the image index retained for compatibility with the ACLUI image-list source. - public int IconIndex { get; } - - /// Gets the combined allowed access mask. - public uint AllowedAccessMask { get; } - - /// Gets the combined denied access mask. - public uint DeniedAccessMask { get; } - - internal WindowsShellSecurityPrincipal(string name, string sid, ReadOnlyMemory iconData, int iconIndex, uint allowedAccessMask, uint deniedAccessMask) - { - Name = name; - Sid = sid; - IconData = iconData; - IconIndex = iconIndex; - AllowedAccessMask = allowedAccessMask; - DeniedAccessMask = deniedAccessMask; - } -} - -/// -/// Describes one File History or volume snapshot version. -/// -public sealed class WindowsShellPreviousVersion -{ - /// Gets the version's display name. - public string Name { get; } - - /// Gets the version's source path. - public string SourcePath { get; } - - /// Gets the version timestamp. - public DateTimeOffset DateModified { get; } - - internal WindowsShellPreviousVersion(string name, string sourcePath, DateTimeOffset dateModified) - { - Name = name; - SourcePath = sourcePath; - DateModified = dateModified; - } -} - -/// -/// Contains folder customization values read through the Shell customization API. -/// -public sealed class WindowsShellFolderCustomizationProperties -{ - /// Gets the customized folder path. - public string ObjectPath { get; } - - /// Gets the folder-kind canonical name. - public string FolderKind { get; } - - /// Gets the folder picture path. - public string PicturePath { get; } - - /// Gets the custom folder icon path. - public string IconPath { get; } - - /// Gets the custom folder icon resource index. - public int IconIndex { get; } - - /// Gets a value indicating whether Explorer exposes folder-picture customization for this folder. - public bool CanChangePicture { get; } - - /// Gets a value indicating whether Explorer exposes folder-icon customization for this folder. - public bool CanChangeIcon { get; } - - /// Gets a value indicating whether the current template is also stored in Explorer's inherited view-state bag. - public bool ApplyToSubfolders { get; } - - internal WindowsShellFolderCustomizationProperties(string objectPath, string folderKind, string picturePath, string iconPath, int iconIndex, bool canChangePicture, bool canChangeIcon, - bool applyToSubfolders) - { - ObjectPath = objectPath; - FolderKind = folderKind; - PicturePath = picturePath; - IconPath = iconPath; - IconIndex = iconIndex; - CanChangePicture = canChangePicture; - CanChangeIcon = canChangeIcon; - ApplyToSubfolders = applyToSubfolders; - } -} - -/// -/// Describes an embedded or catalog Authenticode signature. -/// -public sealed class WindowsShellDigitalSignature -{ - /// Gets the signer certificate subject. - public string Signer { get; } - - /// Gets the message digest algorithm. - public string DigestAlgorithm { get; } - - /// Gets the signature timestamp text when available. - public string Timestamp { get; } - - /// Gets the containing catalog path for a catalog signature. - public string CatalogPath { get; } - - internal WindowsShellDigitalSignature(string signer, string digestAlgorithm, string timestamp, string catalogPath) - { - Signer = signer; - DigestAlgorithm = digestAlgorithm; - Timestamp = timestamp; - CatalogPath = catalogPath; - } -} - -/// -/// Contains one formatted value from a Shell property-description list. -/// -public sealed class WindowsShellPropertyValue -{ - /// Gets the localized property display name. - public string Name { get; } - - /// Gets the property value formatted by its property description. - public string Value { get; } - - /// Gets a value indicating whether this entry is a property group heading. - public bool IsGroup { get; } - - internal WindowsShellPropertyValue(string name, string value, bool isGroup) - { - Name = name; - Value = value; - IsGroup = isGroup; - } -} diff --git a/src/Files.Core/Storage/Windows/WindowsFileExplorerAppExtensionCatalog.cs b/src/Files.Core/Windows/AppExtensions/WindowsFileExplorerAppExtensionCatalog.cs similarity index 97% rename from src/Files.Core/Storage/Windows/WindowsFileExplorerAppExtensionCatalog.cs rename to src/Files.Core/Windows/AppExtensions/WindowsFileExplorerAppExtensionCatalog.cs index 1b84bc3..85a7f90 100644 --- a/src/Files.Core/Storage/Windows/WindowsFileExplorerAppExtensionCatalog.cs +++ b/src/Files.Core/Windows/AppExtensions/WindowsFileExplorerAppExtensionCatalog.cs @@ -1,11 +1,13 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + using Windows.Win32; using Windows.Win32.Foundation; using Windows.Win32.System.WinRT; -namespace Files.Core.Storage.Windows; +namespace Files.Core.Windows; internal static class WindowsFileExplorerAppExtensionCatalog { @@ -300,5 +302,3 @@ public bool TryGetVerbs(out IPropertySetVectorView? verbs) } } } - -internal sealed record WindowsFileExplorerAppExtensionRegistration(Guid ClassId, string VerbId, string DisplayName, string PackageFullName); diff --git a/src/Files.Core/Windows/AppExtensions/WindowsFileExplorerAppExtensionRegistration.cs b/src/Files.Core/Windows/AppExtensions/WindowsFileExplorerAppExtensionRegistration.cs new file mode 100644 index 0000000..76228c4 --- /dev/null +++ b/src/Files.Core/Windows/AppExtensions/WindowsFileExplorerAppExtensionRegistration.cs @@ -0,0 +1,8 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +namespace Files.Core.Windows; + +internal sealed record WindowsFileExplorerAppExtensionRegistration(Guid ClassId, string VerbId, string DisplayName, string PackageFullName); diff --git a/src/Files.Core/Storage/Windows/WindowsShellAppExtensionCommand.cs b/src/Files.Core/Windows/AppExtensions/WindowsShellAppExtensionCommand.cs similarity index 92% rename from src/Files.Core/Storage/Windows/WindowsShellAppExtensionCommand.cs rename to src/Files.Core/Windows/AppExtensions/WindowsShellAppExtensionCommand.cs index e49157e..672fce5 100644 --- a/src/Files.Core/Storage/Windows/WindowsShellAppExtensionCommand.cs +++ b/src/Files.Core/Windows/AppExtensions/WindowsShellAppExtensionCommand.cs @@ -1,7 +1,9 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 -namespace Files.Core.Storage.Windows; +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +namespace Files.Core.Windows; /// /// Describes an app-provided File Explorer command without retaining apartment-bound COM objects. @@ -65,5 +67,3 @@ internal WindowsShellAppExtensionCommand( Children = children ?? []; } } - -internal sealed record WindowsShellAppExtensionCommandToken(Guid ClassId, string VerbId, IReadOnlyList SubCommandPath); diff --git a/src/Files.Core/Windows/AppExtensions/WindowsShellAppExtensionCommandToken.cs b/src/Files.Core/Windows/AppExtensions/WindowsShellAppExtensionCommandToken.cs new file mode 100644 index 0000000..6c3092a --- /dev/null +++ b/src/Files.Core/Windows/AppExtensions/WindowsShellAppExtensionCommandToken.cs @@ -0,0 +1,8 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +namespace Files.Core.Windows; + +internal sealed record WindowsShellAppExtensionCommandToken(Guid ClassId, string VerbId, IReadOnlyList SubCommandPath); diff --git a/src/Files.Core/Storage/Windows/WindowsShellAppExtensionService.cs b/src/Files.Core/Windows/AppExtensions/WindowsShellAppExtensionService.cs similarity index 99% rename from src/Files.Core/Storage/Windows/WindowsShellAppExtensionService.cs rename to src/Files.Core/Windows/AppExtensions/WindowsShellAppExtensionService.cs index a9f8f30..fa02747 100644 --- a/src/Files.Core/Storage/Windows/WindowsShellAppExtensionService.cs +++ b/src/Files.Core/Windows/AppExtensions/WindowsShellAppExtensionService.cs @@ -1,12 +1,15 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + using System.Buffers.Binary; using System.Diagnostics; using System.Globalization; using System.IO; using System.Runtime.InteropServices; using Files.Core.Capabilities.Thumbnails; +using Files.Core.Storage; using OwlCore.Storage; using Windows.Win32; using Windows.Win32.Foundation; @@ -14,7 +17,7 @@ using Windows.Win32.UI.Shell; using Windows.Win32.UI.Shell.Common; -namespace Files.Core.Storage.Windows; +namespace Files.Core.Windows; /// /// Provides Windows Shell app-extension commands and property pages without constructing an IContextMenu. @@ -624,5 +627,3 @@ private static IReadOnlyList GetItemTypes(WindowsStorable firstItem) private unsafe delegate HRESULT CommandStringGetter(IShellItemArray selection, PWSTR* value); } - -internal sealed record WindowsShellResolvedSelection(IReadOnlyList Locators, IReadOnlyList ItemTypes, IReadOnlyList FileSystemPaths, bool IsSingleFolder); diff --git a/src/Files.Core/Windows/AppExtensions/WindowsShellResolvedSelection.cs b/src/Files.Core/Windows/AppExtensions/WindowsShellResolvedSelection.cs new file mode 100644 index 0000000..82b99f9 --- /dev/null +++ b/src/Files.Core/Windows/AppExtensions/WindowsShellResolvedSelection.cs @@ -0,0 +1,8 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +namespace Files.Core.Windows; + +internal sealed record WindowsShellResolvedSelection(IReadOnlyList Locators, IReadOnlyList ItemTypes, IReadOnlyList FileSystemPaths, bool IsSingleFolder); diff --git a/src/Files.Core/Storage/Archives/WindowsShellArchiveBackend.cs b/src/Files.Core/Windows/Archives/WindowsShellArchiveBackend.cs similarity index 92% rename from src/Files.Core/Storage/Archives/WindowsShellArchiveBackend.cs rename to src/Files.Core/Windows/Archives/WindowsShellArchiveBackend.cs index fbe5be2..37a763e 100644 --- a/src/Files.Core/Storage/Archives/WindowsShellArchiveBackend.cs +++ b/src/Files.Core/Windows/Archives/WindowsShellArchiveBackend.cs @@ -1,11 +1,13 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + using Files.Core.Models; -using Files.Core.Storage.Windows; +using Files.Core.Storage.Archives; using OwlCore.Storage; -namespace Files.Core.Storage.Archives; +namespace Files.Core.Windows; /// /// Reuses a Windows Shell item when the Shell exposes the archive as a folder. diff --git a/src/Files.Core/Storage/Archives/WindowsShellArchiveMount.cs b/src/Files.Core/Windows/Archives/WindowsShellArchiveMount.cs similarity index 90% rename from src/Files.Core/Storage/Archives/WindowsShellArchiveMount.cs rename to src/Files.Core/Windows/Archives/WindowsShellArchiveMount.cs index 5852136..293f21d 100644 --- a/src/Files.Core/Storage/Archives/WindowsShellArchiveMount.cs +++ b/src/Files.Core/Windows/Archives/WindowsShellArchiveMount.cs @@ -1,10 +1,14 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + using System.IO; +using Files.Core.Storage; +using Files.Core.Storage.Archives; using OwlCore.Storage; -namespace Files.Core.Storage.Archives; +namespace Files.Core.Windows; internal sealed class WindowsShellArchiveMount : IArchiveMount { diff --git a/src/Files.Core/Capabilities/Changes/FolderChangeSourceFactory.cs b/src/Files.Core/Windows/Changes/FolderChangeSourceFactory.cs similarity index 81% rename from src/Files.Core/Capabilities/Changes/FolderChangeSourceFactory.cs rename to src/Files.Core/Windows/Changes/FolderChangeSourceFactory.cs index 82b759a..b630301 100644 --- a/src/Files.Core/Capabilities/Changes/FolderChangeSourceFactory.cs +++ b/src/Files.Core/Windows/Changes/FolderChangeSourceFactory.cs @@ -1,10 +1,13 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + using System.Runtime.Versioning; -using Files.Core.Storage.Windows; +using Files.Core.Capabilities; +using Files.Core.Capabilities.Changes; -namespace Files.Core.Capabilities.Changes; +namespace Files.Core.Windows; /// /// Creates a Windows Shell change source for a Windows folder. diff --git a/src/Files.Core/Storage/Windows/WindowsFolderChangeSource.cs b/src/Files.Core/Windows/Changes/WindowsFolderChangeSource.cs similarity index 98% rename from src/Files.Core/Storage/Windows/WindowsFolderChangeSource.cs rename to src/Files.Core/Windows/Changes/WindowsFolderChangeSource.cs index 2d7d115..766ed9d 100644 --- a/src/Files.Core/Storage/Windows/WindowsFolderChangeSource.cs +++ b/src/Files.Core/Windows/Changes/WindowsFolderChangeSource.cs @@ -1,12 +1,14 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + using System.Diagnostics; using Files.Core.Capabilities.Changes; using Files.Core.Storage; using Windows.Win32.UI.Shell; -namespace Files.Core.Storage.Windows; +namespace Files.Core.Windows; internal sealed class WindowsFolderChangeSource : IFolderChangeSource { diff --git a/src/Files.Core/Windows/Changes/WindowsShellChange.cs b/src/Files.Core/Windows/Changes/WindowsShellChange.cs new file mode 100644 index 0000000..b919b47 --- /dev/null +++ b/src/Files.Core/Windows/Changes/WindowsShellChange.cs @@ -0,0 +1,10 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +using Windows.Win32.UI.Shell; + +namespace Files.Core.Windows; + +internal sealed record WindowsShellChange(SHCNE_ID EventId, ReadOnlyMemory FirstAbsolutePidl, ReadOnlyMemory SecondAbsolutePidl); diff --git a/src/Files.Core/Storage/Windows/WindowsShellChangeWatcher.cs b/src/Files.Core/Windows/Changes/WindowsShellChangeWatcher.cs similarity index 98% rename from src/Files.Core/Storage/Windows/WindowsShellChangeWatcher.cs rename to src/Files.Core/Windows/Changes/WindowsShellChangeWatcher.cs index a343a4a..8810642 100644 --- a/src/Files.Core/Storage/Windows/WindowsShellChangeWatcher.cs +++ b/src/Files.Core/Windows/Changes/WindowsShellChangeWatcher.cs @@ -1,6 +1,8 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + using System.Runtime.InteropServices; using System.Threading.Channels; using Windows.Win32; @@ -10,9 +12,7 @@ using Windows.Win32.UI.WindowsAndMessaging; using WNDPROC = Windows.Win32.Extras.ManagedWNDPROC; -namespace Files.Core.Storage.Windows; - -internal sealed record WindowsShellChange(SHCNE_ID EventId, ReadOnlyMemory FirstAbsolutePidl, ReadOnlyMemory SecondAbsolutePidl); +namespace Files.Core.Windows; /// /// Owns one hidden Shell notification window for all folder subscriptions of a source. diff --git a/src/Files.Core/Windows/Commands/WindowsShellAppExtensionContextualCommandToken.cs b/src/Files.Core/Windows/Commands/WindowsShellAppExtensionContextualCommandToken.cs new file mode 100644 index 0000000..b562536 --- /dev/null +++ b/src/Files.Core/Windows/Commands/WindowsShellAppExtensionContextualCommandToken.cs @@ -0,0 +1,8 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +namespace Files.Core.Windows; + +internal sealed record WindowsShellAppExtensionContextualCommandToken(WindowsShellAppExtensionCommand Command) : WindowsShellContextualCommandToken; diff --git a/src/Files.Core/Windows/Commands/WindowsShellCommandStoreContextualCommandToken.cs b/src/Files.Core/Windows/Commands/WindowsShellCommandStoreContextualCommandToken.cs new file mode 100644 index 0000000..b5655ba --- /dev/null +++ b/src/Files.Core/Windows/Commands/WindowsShellCommandStoreContextualCommandToken.cs @@ -0,0 +1,8 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +namespace Files.Core.Windows; + +internal sealed record WindowsShellCommandStoreContextualCommandToken(string BackendId) : WindowsShellContextualCommandToken; diff --git a/src/Files.Core/Storage/Windows/WindowsShellCommandStorePropertyBag.cs b/src/Files.Core/Windows/Commands/WindowsShellCommandStorePropertyBag.cs similarity index 95% rename from src/Files.Core/Storage/Windows/WindowsShellCommandStorePropertyBag.cs rename to src/Files.Core/Windows/Commands/WindowsShellCommandStorePropertyBag.cs index 2e70034..86e0409 100644 --- a/src/Files.Core/Storage/Windows/WindowsShellCommandStorePropertyBag.cs +++ b/src/Files.Core/Windows/Commands/WindowsShellCommandStorePropertyBag.cs @@ -1,6 +1,8 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + using System.IO; using System.Runtime.InteropServices; using System.Runtime.InteropServices.Marshalling; @@ -9,7 +11,7 @@ using Windows.Win32.System.Com; using Windows.Win32.System.Com.StructuredStorage; -namespace Files.Core.Storage.Windows; +namespace Files.Core.Windows; [GeneratedComClass] internal sealed partial class WindowsShellCommandStorePropertyBag : IPropertyBag diff --git a/src/Files.Core/Storage/Windows/WindowsShellContextMenuCommandHelper.cs b/src/Files.Core/Windows/Commands/WindowsShellContextMenuCommandHelper.cs similarity index 96% rename from src/Files.Core/Storage/Windows/WindowsShellContextMenuCommandHelper.cs rename to src/Files.Core/Windows/Commands/WindowsShellContextMenuCommandHelper.cs index e97b03e..f818607 100644 --- a/src/Files.Core/Storage/Windows/WindowsShellContextMenuCommandHelper.cs +++ b/src/Files.Core/Windows/Commands/WindowsShellContextMenuCommandHelper.cs @@ -1,6 +1,8 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + using System.ComponentModel; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -9,7 +11,7 @@ using Windows.Win32.UI.Shell; using Windows.Win32.UI.WindowsAndMessaging; -namespace Files.Core.Storage.Windows; +namespace Files.Core.Windows; internal static class WindowsShellContextMenuCommandHelper { diff --git a/src/Files.Core/Windows/Commands/WindowsShellContextMenuContextualCommandToken.cs b/src/Files.Core/Windows/Commands/WindowsShellContextMenuContextualCommandToken.cs new file mode 100644 index 0000000..6bf3d25 --- /dev/null +++ b/src/Files.Core/Windows/Commands/WindowsShellContextMenuContextualCommandToken.cs @@ -0,0 +1,8 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +namespace Files.Core.Windows; + +internal sealed record WindowsShellContextMenuContextualCommandToken(WindowsShellContextMenuTargetKind TargetKind) : WindowsShellContextualCommandToken; diff --git a/src/Files.Core/Storage/Windows/WindowsShellContextMenuSession.cs b/src/Files.Core/Windows/Commands/WindowsShellContextMenuSession.cs similarity index 97% rename from src/Files.Core/Storage/Windows/WindowsShellContextMenuSession.cs rename to src/Files.Core/Windows/Commands/WindowsShellContextMenuSession.cs index 5cf526f..9ef61fe 100644 --- a/src/Files.Core/Storage/Windows/WindowsShellContextMenuSession.cs +++ b/src/Files.Core/Windows/Commands/WindowsShellContextMenuSession.cs @@ -1,6 +1,8 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + using System.ComponentModel; using System.Drawing; using System.Runtime.CompilerServices; @@ -11,7 +13,7 @@ using Windows.Win32.UI.Shell.Common; using Windows.Win32.UI.WindowsAndMessaging; -namespace Files.Core.Storage.Windows; +namespace Files.Core.Windows; /// /// Owns one classic Shell context-menu session, including its native menu and owner-window message forwarding. diff --git a/src/Files.Core/Storage/Windows/WindowsShellContextMenuTarget.cs b/src/Files.Core/Windows/Commands/WindowsShellContextMenuTarget.cs similarity index 83% rename from src/Files.Core/Storage/Windows/WindowsShellContextMenuTarget.cs rename to src/Files.Core/Windows/Commands/WindowsShellContextMenuTarget.cs index d5fd9da..b3c2e6e 100644 --- a/src/Files.Core/Storage/Windows/WindowsShellContextMenuTarget.cs +++ b/src/Files.Core/Windows/Commands/WindowsShellContextMenuTarget.cs @@ -1,7 +1,9 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 -namespace Files.Core.Storage.Windows; +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +namespace Files.Core.Windows; /// /// Contains apartment-neutral item ID lists for a selection that can be bound to a classic Windows Shell context menu on the UI STA. diff --git a/src/Files.Core/Windows/Commands/WindowsShellContextMenuTargetKind.cs b/src/Files.Core/Windows/Commands/WindowsShellContextMenuTargetKind.cs new file mode 100644 index 0000000..1b2f94a --- /dev/null +++ b/src/Files.Core/Windows/Commands/WindowsShellContextMenuTargetKind.cs @@ -0,0 +1,13 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +namespace Files.Core.Windows; + +internal enum WindowsShellContextMenuTargetKind +{ + Selection, + LocationItem, + LocationBackground, +} diff --git a/src/Files.Core/Windows/Commands/WindowsShellContextualCommand.cs b/src/Files.Core/Windows/Commands/WindowsShellContextualCommand.cs new file mode 100644 index 0000000..ae97694 --- /dev/null +++ b/src/Files.Core/Windows/Commands/WindowsShellContextualCommand.cs @@ -0,0 +1,34 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +namespace Files.Core.Windows; + +/// +/// Describes one contextual Windows Shell command without retaining apartment-bound COM objects. +/// +public sealed class WindowsShellContextualCommand +{ + internal WindowsShellContextualCommandToken Token { get; } + + /// Gets the stable command identifier. + public string Id { get; } + + /// Gets a value indicating whether the command can currently be invoked. + public bool IsEnabled { get; } + + /// Gets the context whose changes can affect this command. + public WindowsShellContextualCommandScope Scope { get; } + + internal WindowsShellContextualCommand(string id, bool isEnabled, WindowsShellContextualCommandScope scope, WindowsShellContextualCommandToken token) + { + ArgumentException.ThrowIfNullOrWhiteSpace(id); + ArgumentNullException.ThrowIfNull(token); + + Id = id; + IsEnabled = isEnabled; + Scope = scope; + Token = token; + } +} diff --git a/src/Files.Core/Windows/Commands/WindowsShellContextualCommandIds.cs b/src/Files.Core/Windows/Commands/WindowsShellContextualCommandIds.cs new file mode 100644 index 0000000..3ff5312 --- /dev/null +++ b/src/Files.Core/Windows/Commands/WindowsShellContextualCommandIds.cs @@ -0,0 +1,42 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +namespace Files.Core.Windows; + +/// +/// Defines the stable identifiers used for contextual Windows Shell commands. +/// +public static class WindowsShellContextualCommandIds +{ + /// Mounts a disc image. + public const string Mount = "windows.mount"; + + /// Burns a disc image. + public const string BurnDiscImage = "windows.discimage.burn"; + + /// Sets the selected image as the desktop background. + public const string SetDesktopBackground = "windows.setdesktopwallpaper"; + + /// Empties the Recycle Bin. + public const string EmptyRecycleBin = "windows.recyclebin.empty"; + + /// Restores every item in the Recycle Bin. + public const string RestoreAllRecycleBinItems = "windows.recyclebin.restoreall"; + + /// Restores the selected Recycle Bin items. + public const string RestoreRecycleBinItems = "windows.recyclebin.restoreitems"; + + /// Creates a ZIP archive from the selection. + public const string CompressToZip = "windows.zip.action"; + + /// Pins a folder to Quick access. + public const string PinToQuickAccess = "windows.pintohome"; + + /// Adds a file to Favorites. + public const string AddToFavorites = "windows.pintohomefile"; + + /// Copies the selected item paths. + public const string CopyAsPath = "windows.copyaspath"; +} diff --git a/src/Files.Core/Windows/Commands/WindowsShellContextualCommandScope.cs b/src/Files.Core/Windows/Commands/WindowsShellContextualCommandScope.cs new file mode 100644 index 0000000..9b0a477 --- /dev/null +++ b/src/Files.Core/Windows/Commands/WindowsShellContextualCommandScope.cs @@ -0,0 +1,25 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +namespace Files.Core.Windows; + +/// +/// Identifies the browsing context whose changes can affect a contextual Windows Shell command. +/// +[Flags] +public enum WindowsShellContextualCommandScope +{ + /// The command is not affected by the browsing context. + None = 0, + + /// The command depends on the selected items. + Selection = 1 << 0, + + /// The command depends on the current location. + Location = 1 << 1, + + /// The command can depend on the selection or current location. + All = Selection | Location, +} diff --git a/src/Files.Core/Storage/Windows/WindowsShellContextualCommandService.cs b/src/Files.Core/Windows/Commands/WindowsShellContextualCommandService.cs similarity index 99% rename from src/Files.Core/Storage/Windows/WindowsShellContextualCommandService.cs rename to src/Files.Core/Windows/Commands/WindowsShellContextualCommandService.cs index c9f7e0e..75d02b5 100644 --- a/src/Files.Core/Storage/Windows/WindowsShellContextualCommandService.cs +++ b/src/Files.Core/Windows/Commands/WindowsShellContextualCommandService.cs @@ -1,9 +1,12 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + using System.ComponentModel; using System.IO; using System.Runtime.InteropServices; +using Files.Core.Storage; using Microsoft.Win32; using Windows.Win32; using Windows.Win32.Foundation; @@ -12,7 +15,7 @@ using Windows.Win32.UI.Shell.Common; using Windows.Win32.UI.WindowsAndMessaging; -namespace Files.Core.Storage.Windows; +namespace Files.Core.Windows; /// /// Resolves and invokes the fixed contextual commands exposed by the Windows Shell. diff --git a/src/Files.Core/Windows/Commands/WindowsShellContextualCommandToken.cs b/src/Files.Core/Windows/Commands/WindowsShellContextualCommandToken.cs new file mode 100644 index 0000000..ec17a11 --- /dev/null +++ b/src/Files.Core/Windows/Commands/WindowsShellContextualCommandToken.cs @@ -0,0 +1,8 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +namespace Files.Core.Windows; + +internal abstract record WindowsShellContextualCommandToken; diff --git a/src/Files.Core/Windows/Commands/WindowsShellDefaultCommand.cs b/src/Files.Core/Windows/Commands/WindowsShellDefaultCommand.cs new file mode 100644 index 0000000..2e71b6a --- /dev/null +++ b/src/Files.Core/Windows/Commands/WindowsShellDefaultCommand.cs @@ -0,0 +1,22 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +namespace Files.Core.Windows; + +/// +/// Describes the default command exposed by a Windows Shell item's context menu. +/// +public sealed class WindowsShellDefaultCommand +{ + /// + /// Gets the language-independent command verb, when the context-menu provider exposes one. + /// + public string? CanonicalVerb { get; } + + internal WindowsShellDefaultCommand(string? canonicalVerb) + { + CanonicalVerb = canonicalVerb; + } +} diff --git a/src/Files.Core/Storage/Windows/WindowsShellDefaultCommandInvoker.cs b/src/Files.Core/Windows/Commands/WindowsShellDefaultCommandInvoker.cs similarity index 96% rename from src/Files.Core/Storage/Windows/WindowsShellDefaultCommandInvoker.cs rename to src/Files.Core/Windows/Commands/WindowsShellDefaultCommandInvoker.cs index 16f4859..d7eee22 100644 --- a/src/Files.Core/Storage/Windows/WindowsShellDefaultCommandInvoker.cs +++ b/src/Files.Core/Windows/Commands/WindowsShellDefaultCommandInvoker.cs @@ -1,11 +1,14 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + using System.Runtime.Versioning; +using Files.Core.Storage; using Windows.Win32; using Windows.Win32.UI.Shell; -namespace Files.Core.Storage.Windows; +namespace Files.Core.Windows; /// /// Resolves and invokes the default context-menu command for Windows Shell items. diff --git a/src/Files.Core/Windows/Commands/WindowsShellEmptyRecycleBinContextualCommandToken.cs b/src/Files.Core/Windows/Commands/WindowsShellEmptyRecycleBinContextualCommandToken.cs new file mode 100644 index 0000000..458062e --- /dev/null +++ b/src/Files.Core/Windows/Commands/WindowsShellEmptyRecycleBinContextualCommandToken.cs @@ -0,0 +1,8 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +namespace Files.Core.Windows; + +internal sealed record WindowsShellEmptyRecycleBinContextualCommandToken : WindowsShellContextualCommandToken; diff --git a/src/Files.Core/Storage/Windows/WindowsShellDefaultCommand.cs b/src/Files.Core/Windows/Commands/WindowsShellInvocationContext.cs similarity index 58% rename from src/Files.Core/Storage/Windows/WindowsShellDefaultCommand.cs rename to src/Files.Core/Windows/Commands/WindowsShellInvocationContext.cs index 36f4cc3..d3a16bc 100644 --- a/src/Files.Core/Storage/Windows/WindowsShellDefaultCommand.cs +++ b/src/Files.Core/Windows/Commands/WindowsShellInvocationContext.cs @@ -1,50 +1,9 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 -namespace Files.Core.Storage.Windows; +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. -/// -/// Describes the default command exposed by a Windows Shell item's context menu. -/// -public sealed class WindowsShellDefaultCommand -{ - /// - /// Gets the language-independent command verb, when the context-menu provider exposes one. - /// - public string? CanonicalVerb { get; } - - internal WindowsShellDefaultCommand(string? canonicalVerb) - { - CanonicalVerb = canonicalVerb; - } -} - -/// -/// Identifies the screen position from which a Windows Shell command was invoked. -/// -public readonly struct WindowsShellInvocationPoint -{ - /// - /// Gets the horizontal screen coordinate. - /// - public int X { get; } - - /// - /// Gets the vertical screen coordinate. - /// - public int Y { get; } - - /// - /// Initializes a Shell command invocation point. - /// - /// The horizontal screen coordinate. - /// The vertical screen coordinate. - public WindowsShellInvocationPoint(int x, int y) - { - X = x; - Y = y; - } -} +namespace Files.Core.Windows; /// /// Provides window and input context for invoking a Windows Shell command. diff --git a/src/Files.Core/Windows/Commands/WindowsShellInvocationPoint.cs b/src/Files.Core/Windows/Commands/WindowsShellInvocationPoint.cs new file mode 100644 index 0000000..4367293 --- /dev/null +++ b/src/Files.Core/Windows/Commands/WindowsShellInvocationPoint.cs @@ -0,0 +1,33 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +namespace Files.Core.Windows; + +/// +/// Identifies the screen position from which a Windows Shell command was invoked. +/// +public readonly struct WindowsShellInvocationPoint +{ + /// + /// Gets the horizontal screen coordinate. + /// + public int X { get; } + + /// + /// Gets the vertical screen coordinate. + /// + public int Y { get; } + + /// + /// Initializes a Shell command invocation point. + /// + /// The horizontal screen coordinate. + /// The vertical screen coordinate. + public WindowsShellInvocationPoint(int x, int y) + { + X = x; + Y = y; + } +} diff --git a/src/Files.Core/Windows/Commands/WindowsShellNewItem.cs b/src/Files.Core/Windows/Commands/WindowsShellNewItem.cs new file mode 100644 index 0000000..d24d47f --- /dev/null +++ b/src/Files.Core/Windows/Commands/WindowsShellNewItem.cs @@ -0,0 +1,47 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +namespace Files.Core.Windows; + +/// +/// Describes one item exposed by the Windows Shell New menu. +/// +public sealed class WindowsShellNewItem +{ + /// + /// Gets the command offset used to invoke the item. + /// + public uint CommandOffset { get; } + + /// + /// Gets the localized display name. + /// + public string Name { get; } + + /// + /// Gets the encoded PNG icon data supplied by the Windows Shell. + /// + public ReadOnlyMemory IconData { get; } + + /// + /// Gets a value indicating whether the Shell enabled the item. + /// + public bool IsEnabled { get; } + + /// + /// Initializes a Shell New menu item. + /// + /// The command offset used by IContextMenu::InvokeCommand. + /// The localized display name. + /// The encoded PNG icon data. + /// A value indicating whether the Shell enabled the item. + internal WindowsShellNewItem(uint commandOffset, string name, ReadOnlyMemory iconData, bool isEnabled) + { + CommandOffset = commandOffset; + Name = name; + IconData = iconData; + IsEnabled = isEnabled; + } +} diff --git a/src/Files.Core/Storage/Windows/WindowsShellNewMenu.cs b/src/Files.Core/Windows/Commands/WindowsShellNewMenu.cs similarity index 84% rename from src/Files.Core/Storage/Windows/WindowsShellNewMenu.cs rename to src/Files.Core/Windows/Commands/WindowsShellNewMenu.cs index 10d224b..71a2bdb 100644 --- a/src/Files.Core/Storage/Windows/WindowsShellNewMenu.cs +++ b/src/Files.Core/Windows/Commands/WindowsShellNewMenu.cs @@ -1,6 +1,8 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + using System.IO; using System.Runtime.InteropServices; using System.Runtime.Versioning; @@ -11,7 +13,7 @@ using Windows.Win32.UI.Shell.Common; using Windows.Win32.UI.WindowsAndMessaging; -namespace Files.Core.Storage.Windows; +namespace Files.Core.Windows; /// /// Retrieves and invokes the Windows Shell New menu for a file-system folder. @@ -249,44 +251,3 @@ private static string NormalizeName(string name) return name.Replace("&", string.Empty, StringComparison.Ordinal).Trim(); } } - -/// -/// Describes one item exposed by the Windows Shell New menu. -/// -public sealed class WindowsShellNewItem -{ - /// - /// Gets the command offset used to invoke the item. - /// - public uint CommandOffset { get; } - - /// - /// Gets the localized display name. - /// - public string Name { get; } - - /// - /// Gets the encoded PNG icon data supplied by the Windows Shell. - /// - public ReadOnlyMemory IconData { get; } - - /// - /// Gets a value indicating whether the Shell enabled the item. - /// - public bool IsEnabled { get; } - - /// - /// Initializes a Shell New menu item. - /// - /// The command offset used by IContextMenu::InvokeCommand. - /// The localized display name. - /// The encoded PNG icon data. - /// A value indicating whether the Shell enabled the item. - internal WindowsShellNewItem(uint commandOffset, string name, ReadOnlyMemory iconData, bool isEnabled) - { - CommandOffset = commandOffset; - Name = name; - IconData = iconData; - IsEnabled = isEnabled; - } -} diff --git a/src/Files.Core/Storage/Windows/WindowsShellClipboardService.cs b/src/Files.Core/Windows/DataTransfer/WindowsShellClipboardService.cs similarity index 96% rename from src/Files.Core/Storage/Windows/WindowsShellClipboardService.cs rename to src/Files.Core/Windows/DataTransfer/WindowsShellClipboardService.cs index 68a2b1e..c332601 100644 --- a/src/Files.Core/Storage/Windows/WindowsShellClipboardService.cs +++ b/src/Files.Core/Windows/DataTransfer/WindowsShellClipboardService.cs @@ -1,6 +1,9 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +using Files.Core.Storage; using OwlCore.Storage; using Windows.Win32; using Windows.Win32.Foundation; @@ -8,7 +11,7 @@ using Windows.Win32.System.Ole; using Windows.Win32.UI.Shell; -namespace Files.Core.Storage.Windows; +namespace Files.Core.Windows; /// /// Places Windows Shell selections on the OLE clipboard without converting them to physical paths. diff --git a/src/Files.Core/Storage/Windows/WindowsShellDataObjectFactory.cs b/src/Files.Core/Windows/DataTransfer/WindowsShellDataObjectFactory.cs similarity index 95% rename from src/Files.Core/Storage/Windows/WindowsShellDataObjectFactory.cs rename to src/Files.Core/Windows/DataTransfer/WindowsShellDataObjectFactory.cs index 5f5e2c7..beb9277 100644 --- a/src/Files.Core/Storage/Windows/WindowsShellDataObjectFactory.cs +++ b/src/Files.Core/Windows/DataTransfer/WindowsShellDataObjectFactory.cs @@ -1,6 +1,8 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + using System.Buffers; using Windows.Win32; using Windows.Win32.Foundation; @@ -8,7 +10,7 @@ using Windows.Win32.UI.Shell; using Windows.Win32.UI.Shell.Common; -namespace Files.Core.Storage.Windows; +namespace Files.Core.Windows; internal static class WindowsShellDataObjectFactory { diff --git a/src/Files.Core/Storage/Windows/WindowsShellDataObjectFormat.cs b/src/Files.Core/Windows/DataTransfer/WindowsShellDataObjectFormat.cs similarity index 96% rename from src/Files.Core/Storage/Windows/WindowsShellDataObjectFormat.cs rename to src/Files.Core/Windows/DataTransfer/WindowsShellDataObjectFormat.cs index 39f79df..1f2665f 100644 --- a/src/Files.Core/Storage/Windows/WindowsShellDataObjectFormat.cs +++ b/src/Files.Core/Windows/DataTransfer/WindowsShellDataObjectFormat.cs @@ -1,6 +1,8 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + using System.ComponentModel; using System.Runtime.InteropServices; using Windows.Win32; @@ -8,7 +10,7 @@ using Windows.Win32.System.Memory; using Windows.Win32.System.Ole; -namespace Files.Core.Storage.Windows; +namespace Files.Core.Windows; internal static class WindowsShellDataObjectFormat { diff --git a/src/Files.Core/Storage/Windows/WindowsShellDragDropData.cs b/src/Files.Core/Windows/DataTransfer/WindowsShellDragDropModifiers.cs similarity index 63% rename from src/Files.Core/Storage/Windows/WindowsShellDragDropData.cs rename to src/Files.Core/Windows/DataTransfer/WindowsShellDragDropModifiers.cs index 3bd8f17..eb72876 100644 --- a/src/Files.Core/Storage/Windows/WindowsShellDragDropData.cs +++ b/src/Files.Core/Windows/DataTransfer/WindowsShellDragDropModifiers.cs @@ -1,26 +1,9 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 -namespace Files.Core.Storage.Windows; +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. -/// -/// Identifies operations supported by a Windows Shell drag source or drop target. -/// -[Flags] -public enum WindowsShellDropEffects : uint -{ - /// No operation is supported. - None = 0, - - /// The data can be copied. - Copy = 1, - - /// The data can be moved. - Move = 2, - - /// A link to the data can be created. - Link = 4, -} +namespace Files.Core.Windows; /// /// Identifies pointer buttons and modifier keys active during a Windows Shell drag operation. diff --git a/src/Files.Core/Storage/Windows/WindowsShellDragDropService.cs b/src/Files.Core/Windows/DataTransfer/WindowsShellDragDropService.cs similarity index 97% rename from src/Files.Core/Storage/Windows/WindowsShellDragDropService.cs rename to src/Files.Core/Windows/DataTransfer/WindowsShellDragDropService.cs index 819e838..d94c27e 100644 --- a/src/Files.Core/Storage/Windows/WindowsShellDragDropService.cs +++ b/src/Files.Core/Windows/DataTransfer/WindowsShellDragDropService.cs @@ -1,13 +1,16 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +using Files.Core.Storage; using OwlCore.Storage; using Windows.Win32; using Windows.Win32.Foundation; using Windows.Win32.UI.Shell; using Windows.Win32.UI.WindowsAndMessaging; -namespace Files.Core.Storage.Windows; +namespace Files.Core.Windows; /// /// Prepares Windows Shell data transfer objects without reducing Shell items to physical paths. diff --git a/src/Files.Core/Storage/Windows/WindowsShellDragSource.cs b/src/Files.Core/Windows/DataTransfer/WindowsShellDragSource.cs similarity index 96% rename from src/Files.Core/Storage/Windows/WindowsShellDragSource.cs rename to src/Files.Core/Windows/DataTransfer/WindowsShellDragSource.cs index cd681a6..c7d12e0 100644 --- a/src/Files.Core/Storage/Windows/WindowsShellDragSource.cs +++ b/src/Files.Core/Windows/DataTransfer/WindowsShellDragSource.cs @@ -1,6 +1,8 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + using Windows.Win32; using Windows.Win32.Foundation; using Windows.Win32.System.Com; @@ -8,7 +10,7 @@ using Windows.Win32.System.SystemServices; using Windows.Win32.UI.Shell; -namespace Files.Core.Storage.Windows; +namespace Files.Core.Windows; /// /// Contains an apartment-neutral Windows Shell selection prepared for a WinUI drag surface. diff --git a/src/Files.Core/Windows/DataTransfer/WindowsShellDropEffects.cs b/src/Files.Core/Windows/DataTransfer/WindowsShellDropEffects.cs new file mode 100644 index 0000000..fb0a8ec --- /dev/null +++ b/src/Files.Core/Windows/DataTransfer/WindowsShellDropEffects.cs @@ -0,0 +1,25 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +namespace Files.Core.Windows; + +/// +/// Identifies operations supported by a Windows Shell drag source or drop target. +/// +[Flags] +public enum WindowsShellDropEffects : uint +{ + /// No operation is supported. + None = 0, + + /// The data can be copied. + Copy = 1, + + /// The data can be moved. + Move = 2, + + /// A link to the data can be created. + Link = 4, +} diff --git a/src/Files.Core/Storage/Windows/WindowsShellDropSession.cs b/src/Files.Core/Windows/DataTransfer/WindowsShellDropSession.cs similarity index 97% rename from src/Files.Core/Storage/Windows/WindowsShellDropSession.cs rename to src/Files.Core/Windows/DataTransfer/WindowsShellDropSession.cs index cd7dfe3..fe3aacb 100644 --- a/src/Files.Core/Storage/Windows/WindowsShellDropSession.cs +++ b/src/Files.Core/Windows/DataTransfer/WindowsShellDropSession.cs @@ -1,6 +1,8 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + using System.Drawing; using Windows.Win32; using Windows.Win32.Foundation; @@ -8,7 +10,7 @@ using Windows.Win32.System.Ole; using Windows.Win32.System.SystemServices; -namespace Files.Core.Storage.Windows; +namespace Files.Core.Windows; /// /// Forwards one WinUI drag sequence to a native Windows Shell drop target. diff --git a/src/Files.Core/Storage/Windows/WindowsShellDropTarget.cs b/src/Files.Core/Windows/DataTransfer/WindowsShellDropTarget.cs similarity index 96% rename from src/Files.Core/Storage/Windows/WindowsShellDropTarget.cs rename to src/Files.Core/Windows/DataTransfer/WindowsShellDropTarget.cs index cb316b6..70ffea6 100644 --- a/src/Files.Core/Storage/Windows/WindowsShellDropTarget.cs +++ b/src/Files.Core/Windows/DataTransfer/WindowsShellDropTarget.cs @@ -1,6 +1,8 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + using System.Buffers; using Windows.Win32; using Windows.Win32.Foundation; @@ -9,7 +11,7 @@ using Windows.Win32.UI.Shell; using Windows.Win32.UI.Shell.Common; -namespace Files.Core.Storage.Windows; +namespace Files.Core.Windows; /// /// Contains an apartment-neutral Windows Shell destination prepared for a WinUI drop surface. diff --git a/src/Files.Core/Storage/Windows/WindowsShellSelectionResolver.cs b/src/Files.Core/Windows/DataTransfer/WindowsShellSelectionResolver.cs similarity index 87% rename from src/Files.Core/Storage/Windows/WindowsShellSelectionResolver.cs rename to src/Files.Core/Windows/DataTransfer/WindowsShellSelectionResolver.cs index 1ddcf80..e90dd26 100644 --- a/src/Files.Core/Storage/Windows/WindowsShellSelectionResolver.cs +++ b/src/Files.Core/Windows/DataTransfer/WindowsShellSelectionResolver.cs @@ -1,9 +1,12 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +using Files.Core.Storage; using OwlCore.Storage; -namespace Files.Core.Storage.Windows; +namespace Files.Core.Windows; internal static class WindowsShellSelectionResolver { diff --git a/src/Files.Core/Windows/Imaging/WindowsBitmapData.cs b/src/Files.Core/Windows/Imaging/WindowsBitmapData.cs new file mode 100644 index 0000000..6fd61d5 --- /dev/null +++ b/src/Files.Core/Windows/Imaging/WindowsBitmapData.cs @@ -0,0 +1,8 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +namespace Files.Core.Windows; + +internal sealed record WindowsBitmapData(byte[] Pixels, int Width, int Height); diff --git a/src/Files.Core/Storage/Windows/WindowsShellIconProvider.cs b/src/Files.Core/Windows/Imaging/WindowsShellIconProvider.cs similarity index 96% rename from src/Files.Core/Storage/Windows/WindowsShellIconProvider.cs rename to src/Files.Core/Windows/Imaging/WindowsShellIconProvider.cs index 3ee75fe..93cd7c6 100644 --- a/src/Files.Core/Storage/Windows/WindowsShellIconProvider.cs +++ b/src/Files.Core/Windows/Imaging/WindowsShellIconProvider.cs @@ -1,11 +1,13 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + using Windows.Win32; using Windows.Win32.Storage.FileSystem; using Windows.Win32.UI.Shell; -namespace Files.Core.Storage.Windows; +namespace Files.Core.Windows; /// /// Loads the system icons used by Windows Shell property pages. diff --git a/src/Files.Core/Storage/Windows/WindowsShellThumbnailBackend.cs b/src/Files.Core/Windows/Imaging/WindowsShellThumbnailBackend.cs similarity index 98% rename from src/Files.Core/Storage/Windows/WindowsShellThumbnailBackend.cs rename to src/Files.Core/Windows/Imaging/WindowsShellThumbnailBackend.cs index 001adb5..286fbfe 100644 --- a/src/Files.Core/Storage/Windows/WindowsShellThumbnailBackend.cs +++ b/src/Files.Core/Windows/Imaging/WindowsShellThumbnailBackend.cs @@ -1,6 +1,8 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + using System.Collections.Concurrent; using System.Runtime.CompilerServices; using System.Runtime.Versioning; @@ -13,7 +15,7 @@ using Windows.Win32.UI.Shell; using Windows.Win32.UI.Shell.Common; -namespace Files.Core.Storage.Windows; +namespace Files.Core.Windows; /// /// Retrieves Windows Shell thumbnails and materializes them as PNG bytes. @@ -674,12 +676,3 @@ internal void Set(ulong itemCacheId, in WTS_THUMBNAILID thumbnailId) private readonly record struct SystemIconCacheKey(int ImageListId, int ImageIndex, uint DrawFlags, int RequestedSize); } - -internal sealed record WindowsThumbnailPayload( - byte[] Content, - string ContentType, - bool IsFallback, - ThumbnailContentFormat Format = ThumbnailContentFormat.EncodedImage, - int PixelWidth = 0, - int PixelHeight = 0, - bool IncludesOverlay = false); diff --git a/src/Files.Core/Storage/Windows/WindowsShellThumbnailSource.cs b/src/Files.Core/Windows/Imaging/WindowsShellThumbnailSource.cs similarity index 94% rename from src/Files.Core/Storage/Windows/WindowsShellThumbnailSource.cs rename to src/Files.Core/Windows/Imaging/WindowsShellThumbnailSource.cs index b49981d..1467b17 100644 --- a/src/Files.Core/Storage/Windows/WindowsShellThumbnailSource.cs +++ b/src/Files.Core/Windows/Imaging/WindowsShellThumbnailSource.cs @@ -1,12 +1,14 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + using System.Diagnostics; using System.Runtime.Versioning; using Files.Core.Diagnostics; using Files.Core.Capabilities.Thumbnails; -namespace Files.Core.Storage.Windows; +namespace Files.Core.Windows; [SupportedOSPlatform("windows6.0.6000")] internal sealed class WindowsShellThumbnailSource : IThumbnailSource diff --git a/src/Files.Core/Windows/Imaging/WindowsThumbnailPayload.cs b/src/Files.Core/Windows/Imaging/WindowsThumbnailPayload.cs new file mode 100644 index 0000000..8c60989 --- /dev/null +++ b/src/Files.Core/Windows/Imaging/WindowsThumbnailPayload.cs @@ -0,0 +1,17 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +using Files.Core.Capabilities.Thumbnails; + +namespace Files.Core.Windows; + +internal sealed record WindowsThumbnailPayload( + byte[] Content, + string ContentType, + bool IsFallback, + ThumbnailContentFormat Format = ThumbnailContentFormat.EncodedImage, + int PixelWidth = 0, + int PixelHeight = 0, + bool IncludesOverlay = false); diff --git a/src/Files.Core/Storage/Windows/WindowsThumbnailRenderer.cs b/src/Files.Core/Windows/Imaging/WindowsThumbnailRenderer.cs similarity index 99% rename from src/Files.Core/Storage/Windows/WindowsThumbnailRenderer.cs rename to src/Files.Core/Windows/Imaging/WindowsThumbnailRenderer.cs index 87b4510..9e6242c 100644 --- a/src/Files.Core/Storage/Windows/WindowsThumbnailRenderer.cs +++ b/src/Files.Core/Windows/Imaging/WindowsThumbnailRenderer.cs @@ -1,6 +1,8 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + using System.IO; using System.Runtime.InteropServices; using Windows.Win32; @@ -11,7 +13,7 @@ using Windows.Win32.System.Com; using Windows.Win32.UI.WindowsAndMessaging; -namespace Files.Core.Storage.Windows; +namespace Files.Core.Windows; /// /// Converts Shell-owned bitmap and icon handles into independent PNG bytes. @@ -658,5 +660,3 @@ private static nuint StartGdiPlus() return token; } } - -internal sealed record WindowsBitmapData(byte[] Pixels, int Width, int Height); diff --git a/src/Files.Core/Storage/Windows/WindowsThumbnailSourceFactory.cs b/src/Files.Core/Windows/Imaging/WindowsThumbnailSourceFactory.cs similarity index 91% rename from src/Files.Core/Storage/Windows/WindowsThumbnailSourceFactory.cs rename to src/Files.Core/Windows/Imaging/WindowsThumbnailSourceFactory.cs index 9e4a277..5df2865 100644 --- a/src/Files.Core/Storage/Windows/WindowsThumbnailSourceFactory.cs +++ b/src/Files.Core/Windows/Imaging/WindowsThumbnailSourceFactory.cs @@ -1,11 +1,13 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + using System.Runtime.Versioning; using Files.Core.Capabilities; using Files.Core.Capabilities.Thumbnails; -namespace Files.Core.Storage.Windows; +namespace Files.Core.Windows; /// /// Creates a thumbnail source for items resolved by the Windows storage source. diff --git a/src/Files.Core/Windows/Interop/CDiskQuotaControl.cs b/src/Files.Core/Windows/Interop/CDiskQuotaControl.cs new file mode 100644 index 0000000..8569e9b --- /dev/null +++ b/src/Files.Core/Windows/Interop/CDiskQuotaControl.cs @@ -0,0 +1,15 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Native declarations preserve Windows SDK namespaces. + +using System.Runtime.InteropServices; + +namespace Windows.Win32.UI.Shell +{ + /// Identifies the NTFS disk-quota controller coclass. + [Guid("7988B571-EC89-11CF-9C00-00AA00A14F56")] + internal sealed class CDiskQuotaControl + { + } +} diff --git a/src/Files.Core/Interop/Windows/ManualGuid.cs b/src/Files.Core/Windows/Interop/CLSID.cs similarity index 61% rename from src/Files.Core/Interop/Windows/ManualGuid.cs rename to src/Files.Core/Windows/Interop/CLSID.cs index bd76709..26a99f4 100644 --- a/src/Files.Core/Interop/Windows/ManualGuid.cs +++ b/src/Files.Core/Windows/Interop/CLSID.cs @@ -1,8 +1,9 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Native declarations preserve Windows SDK namespaces. + using System; -using System.Runtime.InteropServices; namespace Windows.Win32 { @@ -20,22 +21,4 @@ public static partial class CLSID /// The Open With menu class identifier. public static Guid CLSID_OpenWithMenu { get; } = new(0x09799AFBu, 0xAD67, 0x11D1, 0xAB, 0xCD, 0x00, 0xC0, 0x4F, 0xC3, 0x09, 0x36); } - - /// Contains manually declared Shell folder identifiers used by Files. - public static partial class FOLDERID - { - /// The Recycle Bin folder identifier. - public static Guid FOLDERID_RecycleBinFolder { get; } = new(0xB7534046u, 0x3ECB, 0x4C18, 0xBE, 0x4E, 0x64, 0xCD, 0x4C, 0xB7, 0xD6, 0xAC); - /// The Computer folder identifier. - public static Guid FOLDERID_ComputerFolder { get; } = new(0x0AC0837Cu, 0xBBF8, 0x452A, 0x85, 0x0D, 0x79, 0xD0, 0x8E, 0x66, 0x7C, 0xA7); - } -} - -namespace Windows.Win32.UI.Shell -{ - /// Identifies the NTFS disk-quota controller coclass. - [Guid("7988B571-EC89-11CF-9C00-00AA00A14F56")] - internal sealed class CDiskQuotaControl - { - } } diff --git a/src/Files.Core/Interop/Windows/ComHeapPtr`1.cs b/src/Files.Core/Windows/Interop/ComHeapPtr`1.cs similarity index 94% rename from src/Files.Core/Interop/Windows/ComHeapPtr`1.cs rename to src/Files.Core/Windows/Interop/ComHeapPtr`1.cs index e332409..23ec950 100644 --- a/src/Files.Core/Interop/Windows/ComHeapPtr`1.cs +++ b/src/Files.Core/Windows/Interop/ComHeapPtr`1.cs @@ -1,6 +1,8 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Native declarations preserve Windows SDK namespaces. + using System; using System.Runtime.CompilerServices; diff --git a/src/Files.Core/Interop/Windows/ComHelpers.cs b/src/Files.Core/Windows/Interop/ComHelpers.cs similarity index 92% rename from src/Files.Core/Interop/Windows/ComHelpers.cs rename to src/Files.Core/Windows/Interop/ComHelpers.cs index 43fff97..0772661 100644 --- a/src/Files.Core/Interop/Windows/ComHelpers.cs +++ b/src/Files.Core/Windows/Interop/ComHelpers.cs @@ -1,6 +1,8 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Native declarations preserve Windows SDK namespaces. + using System; using Windows.Win32.Foundation; using Windows.Win32.System.Com; diff --git a/src/Files.Core/Interop/Windows/Extras.cs b/src/Files.Core/Windows/Interop/Extras.cs similarity index 84% rename from src/Files.Core/Interop/Windows/Extras.cs rename to src/Files.Core/Windows/Interop/Extras.cs index cf9c6eb..39705d7 100644 --- a/src/Files.Core/Interop/Windows/Extras.cs +++ b/src/Files.Core/Windows/Interop/Extras.cs @@ -1,11 +1,12 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Native declarations preserve Windows SDK namespaces. + using System; using System.Runtime.InteropServices; using Microsoft.Win32.SafeHandles; using Windows.Win32.Foundation; -using Windows.Win32.Graphics.Gdi; using Windows.Win32.System.Com; using Windows.Win32.System.Com.Urlmon; using Windows.Win32.System.Com.StructuredStorage; @@ -13,7 +14,6 @@ using Windows.Win32.UI.Shell; using Windows.Win32.UI.Shell.Common; using Windows.Win32.UI.Shell.PropertiesSystem; -using Windows.Win32.UI.WindowsAndMessaging; namespace Windows.Win32 { @@ -98,26 +98,4 @@ internal static partial HRESULT ZoneCheckUrlExCache( internal static partial NTSTATUS NtFsControlFile(SafeFileHandle fileHandle, SafeFileHandle eventHandle, nint apcRoutine, nint apcContext, ref IO_STATUS_BLOCK ioStatusBlock, uint controlCode, nint inputBuffer, uint inputBufferLength, ref byte outputBuffer, uint outputBufferLength); } - - namespace Extras - { - /// Delegate used to enumerate monitors through the Win32 API. - /// The monitor handle. - /// The device context handle. - /// The monitor rectangle. - /// The application-defined value. - /// A nonzero value to continue enumeration. - [UnmanagedFunctionPointer(CallingConvention.Winapi)] - public delegate BOOL ManagedMONITORENUMPROC([In] HMONITOR param0, [In] HDC param1, [In, Out] ref RECT param2, [In] LPARAM param3); - - /// Delegate used as a managed window procedure callback. - /// The window handle. - /// The window message. - /// The message parameter. - /// The message parameter. - /// The result of processing the message. - [UnmanagedFunctionPointer(CallingConvention.Winapi)] - public delegate LRESULT ManagedWNDPROC(HWND hWnd, uint msg, WPARAM wParam, LPARAM lParam); - - } } diff --git a/src/Files.Core/Windows/Interop/FOLDERID.cs b/src/Files.Core/Windows/Interop/FOLDERID.cs new file mode 100644 index 0000000..7c13f2a --- /dev/null +++ b/src/Files.Core/Windows/Interop/FOLDERID.cs @@ -0,0 +1,18 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Native declarations preserve Windows SDK namespaces. + +using System; + +namespace Windows.Win32 +{ + /// Contains manually declared Shell folder identifiers used by Files. + public static partial class FOLDERID + { + /// The Recycle Bin folder identifier. + public static Guid FOLDERID_RecycleBinFolder { get; } = new(0xB7534046u, 0x3ECB, 0x4C18, 0xBE, 0x4E, 0x64, 0xCD, 0x4C, 0xB7, 0xD6, 0xAC); + /// The Computer folder identifier. + public static Guid FOLDERID_ComputerFolder { get; } = new(0x0AC0837Cu, 0xBBF8, 0x452A, 0x85, 0x0D, 0x79, 0xD0, 0x8E, 0x66, 0x7C, 0xA7); + } +} diff --git a/src/Files.Core/Interop/Windows/HRESULT.cs b/src/Files.Core/Windows/Interop/HRESULT.cs similarity index 89% rename from src/Files.Core/Interop/Windows/HRESULT.cs rename to src/Files.Core/Windows/Interop/HRESULT.cs index 71e1995..c7739a6 100644 --- a/src/Files.Core/Interop/Windows/HRESULT.cs +++ b/src/Files.Core/Windows/Interop/HRESULT.cs @@ -1,6 +1,8 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Native declarations preserve Windows SDK namespaces. + using System.Diagnostics; using System.Runtime.InteropServices; diff --git a/src/Files.Core/Interop/Windows/HStringStringMarshaller.cs b/src/Files.Core/Windows/Interop/HStringStringMarshaller.cs similarity index 94% rename from src/Files.Core/Interop/Windows/HStringStringMarshaller.cs rename to src/Files.Core/Windows/Interop/HStringStringMarshaller.cs index d827fc2..d3be860 100644 --- a/src/Files.Core/Interop/Windows/HStringStringMarshaller.cs +++ b/src/Files.Core/Windows/Interop/HStringStringMarshaller.cs @@ -1,6 +1,8 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Native declarations preserve Windows SDK namespaces. + using System.Runtime.InteropServices; using System.Runtime.InteropServices.Marshalling; using Windows.Win32.Foundation; @@ -181,15 +183,3 @@ private static void DeleteHString(HSTRING hstring) } } } - -/// Extends the generated HSTRING safe handle with ownership transfer for custom marshalling. -public partial class WindowsDeleteStringSafeHandle -{ - internal HSTRING Detach() - { - var value = (HSTRING)DangerousGetHandle(); - SetHandleAsInvalid(); - - return value; - } -} diff --git a/src/Files.Core/Interop/Windows/ICachedPrivateProfile.cs b/src/Files.Core/Windows/Interop/ICachedPrivateProfile.cs similarity index 97% rename from src/Files.Core/Interop/Windows/ICachedPrivateProfile.cs rename to src/Files.Core/Windows/Interop/ICachedPrivateProfile.cs index d244abc..00f10e9 100644 --- a/src/Files.Core/Interop/Windows/ICachedPrivateProfile.cs +++ b/src/Files.Core/Windows/Interop/ICachedPrivateProfile.cs @@ -1,6 +1,8 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Native declarations preserve Windows SDK namespaces. + using System.Runtime.InteropServices; using System.Runtime.InteropServices.Marshalling; using Windows.Win32.Foundation; diff --git a/src/Files.Core/Windows/Interop/IChildId.cs b/src/Files.Core/Windows/Interop/IChildId.cs new file mode 100644 index 0000000..5273ccf --- /dev/null +++ b/src/Files.Core/Windows/Interop/IChildId.cs @@ -0,0 +1,15 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Native declarations preserve Windows SDK namespaces. + +using System.Runtime.InteropServices; +using System.Runtime.InteropServices.Marshalling; + +namespace Windows.Win32.UI.Shell; + +/// Identifies an Explorer child item stored by PIDL. This recovered marker adds no ABI slots. +[GeneratedComInterface, Guid("C412BF5B-91EA-4904-B34A-855504FBBF0B"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] +internal partial interface IChildId +{ +} diff --git a/src/Files.Core/Windows/Interop/IDefViewItemStore.cs b/src/Files.Core/Windows/Interop/IDefViewItemStore.cs new file mode 100644 index 0000000..9f4a7b9 --- /dev/null +++ b/src/Files.Core/Windows/Interop/IDefViewItemStore.cs @@ -0,0 +1,110 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Native declarations preserve Windows SDK namespaces. + +using System.Runtime.InteropServices; +using System.Runtime.InteropServices.Marshalling; +using Windows.Win32.Foundation; +using Windows.Win32.System.Com.StructuredStorage; +using Windows.Win32.UI.Shell.Common; +using Windows.Win32.UI.Shell.PropertiesSystem; + +namespace Windows.Win32.UI.Shell; + +internal enum SET_PROPERTY_STORE_TYPE +{ + Default = 0, +} + +[StructLayout(LayoutKind.Sequential, Size = 8)] +internal struct ITEMGROUP +{ +} + +/// Adds the recovered DefView operations to Explorer's item-store contract. +[GeneratedComInterface, Guid("35C22FEA-79F6-4D3D-AE15-1699CBF54721"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] +internal unsafe partial interface IDefViewItemStore : IItemStore +{ + /// Initializes the store for a root PIDL. + /// The absolute root PIDL. + /// The HRESULT returned by the store. + [PreserveSig] + HRESULT Initialize(in ITEMIDLIST rootPidl); + + /// Deletes an item from the store. + /// The item key. + /// The HRESULT returned by the store. + [PreserveSig] + HRESULT DeleteItem(in ITEMKEY itemKey); + + /// Sets an item's child identifier and selected flags. + /// The item key. + /// The optional child identifier. + /// The flags to change. + /// The new flag values. + /// The HRESULT returned by the store. + [PreserveSig] + HRESULT SetItemIDListAndFlags(in ITEMKEY itemKey, IChildId? childId, ITEM_FLAGS mask, ITEM_FLAGS value); + + /// Sets an item's property store. + /// The property-store type. + /// The item key. + /// The optional property store. + /// The HRESULT returned by the store. + [PreserveSig] + HRESULT SetItemPropertyStore(SET_PROPERTY_STORE_TYPE storeType, in ITEMKEY itemKey, IPropertyStore? propertyStore); + + /// Associates arbitrary COM data with an item. + /// The item key. + /// The optional data object, or to clear it. + /// The HRESULT returned by the store. + [PreserveSig] + HRESULT SetData(in ITEMKEY itemKey, [MarshalAs(UnmanagedType.Interface)] object? data); + + /// Gets arbitrary COM data associated with an item. + /// The item key. + /// The requested interface identifier. + /// Receives the requested interface. + /// The HRESULT returned by the store. + [PreserveSig] + HRESULT GetData(in ITEMKEY itemKey, in Guid interfaceId, [MarshalAs(UnmanagedType.Interface)] out object? data); + + /// Sets an item cookie. + /// The item key. + /// The cookie index. + /// The cookie value. + [PreserveSig] + void SetItemCookie(in ITEMKEY itemKey, int index, uint cookie); + + /// Gets an item cookie. + /// The item key. + /// The cookie index. + /// The cookie value. + [PreserveSig] + uint GetItemCookie(in ITEMKEY itemKey, int index); + + /// Sets an item's opaque group records. + /// The item key. + /// The group type. + /// The group records. + /// The number of group records. + /// The HRESULT returned by the store. + [PreserveSig] + HRESULT SetItemGroups(in ITEMKEY itemKey, uint groupType, [In, MarshalUsing(CountElementName = nameof(count))] ITEMGROUP[] groups, int count); + + /// Gets the store-owned group records for an item. + /// The item key. + /// The group type. + /// Receives a borrowed pointer to the group records. The caller must not free it. + /// Receives the number of group records. + /// The HRESULT returned by the store. + [PreserveSig] + HRESULT GetItemGroups(in ITEMKEY itemKey, uint groupType, out ITEMGROUP* groups, out int count); + + /// Determines whether an item key is valid. + /// The item key. + /// when the key is valid; otherwise, . + [PreserveSig] + BOOL IsItemKeyValid(in ITEMKEY itemKey); +} diff --git a/src/Files.Core/Interop/Windows/IDetectionAndSharing.cs b/src/Files.Core/Windows/Interop/IDetectionAndSharing.cs similarity index 97% rename from src/Files.Core/Interop/Windows/IDetectionAndSharing.cs rename to src/Files.Core/Windows/Interop/IDetectionAndSharing.cs index 4b942bf..a63d9b3 100644 --- a/src/Files.Core/Interop/Windows/IDetectionAndSharing.cs +++ b/src/Files.Core/Windows/Interop/IDetectionAndSharing.cs @@ -1,6 +1,8 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Native declarations preserve Windows SDK namespaces. + using System.Runtime.InteropServices; using System.Runtime.InteropServices.Marshalling; using Windows.Win32.Foundation; diff --git a/src/Files.Core/Interop/Windows/IElevatedDiskQuotaUI.cs b/src/Files.Core/Windows/Interop/IElevatedDiskQuotaUI.cs similarity index 93% rename from src/Files.Core/Interop/Windows/IElevatedDiskQuotaUI.cs rename to src/Files.Core/Windows/Interop/IElevatedDiskQuotaUI.cs index 1ae1224..69109cc 100644 --- a/src/Files.Core/Interop/Windows/IElevatedDiskQuotaUI.cs +++ b/src/Files.Core/Windows/Interop/IElevatedDiskQuotaUI.cs @@ -1,6 +1,8 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Native declarations preserve Windows SDK namespaces. + using System.Runtime.InteropServices; using System.Runtime.InteropServices.Marshalling; using Windows.Win32.Foundation; diff --git a/src/Files.Core/Interop/Windows/IElevatedNtfsSecurity.cs b/src/Files.Core/Windows/Interop/IElevatedNtfsSecurity.cs similarity index 93% rename from src/Files.Core/Interop/Windows/IElevatedNtfsSecurity.cs rename to src/Files.Core/Windows/Interop/IElevatedNtfsSecurity.cs index 18e966c..4abeeee 100644 --- a/src/Files.Core/Interop/Windows/IElevatedNtfsSecurity.cs +++ b/src/Files.Core/Windows/Interop/IElevatedNtfsSecurity.cs @@ -1,6 +1,8 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Native declarations preserve Windows SDK namespaces. + using System.Runtime.InteropServices; using System.Runtime.InteropServices.Marshalling; using Windows.Win32.Foundation; diff --git a/src/Files.Core/Windows/Interop/IFileExplorerAppExtension.cs b/src/Files.Core/Windows/Interop/IFileExplorerAppExtension.cs new file mode 100644 index 0000000..f33ac19 --- /dev/null +++ b/src/Files.Core/Windows/Interop/IFileExplorerAppExtension.cs @@ -0,0 +1,55 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Native declarations preserve Windows SDK namespaces. + +using System.Runtime.InteropServices; +using System.Runtime.InteropServices.Marshalling; +using Windows.Win32.Foundation; + +namespace Windows.Win32.System.WinRT; + +/// Describes the original recovered Explorer app-extension ABI. +[GeneratedComInterface(Options = ComInterfaceOptions.ComObjectWrapper)] +[Guid("66C23D78-8E71-51EF-A184-ED7B6E6CDC90")] +[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] +internal partial interface IFileExplorerAppExtension : IInspectable +{ + /// Gets the extension display name. + /// Receives the display name. + /// The HRESULT returned by the extension. + [PreserveSig] + HRESULT GetDisplayName([MarshalUsing(typeof(global::Windows.Win32.HStringStringMarshaller))] out string? displayName); + + /// Gets the package full name. + /// Receives the package full name. + /// The HRESULT returned by the extension. + [PreserveSig] + HRESULT GetPackageFullName([MarshalUsing(typeof(global::Windows.Win32.HStringStringMarshaller))] out string? packageFullName); + + /// Gets the extension logo. + /// Receives the logo object. + /// The HRESULT returned by the extension. + [PreserveSig] + HRESULT GetLogo([MarshalAs(UnmanagedType.Interface)] out object? logo); + + /// Gets the extension verbs. + /// The cache lookup flags. + /// Receives the verb vector. + /// The HRESULT returned by the extension. + [PreserveSig] + HRESULT GetVerbs(uint flags, out IPropertySetVectorView? verbs); + + /// Gets the extended verb collection. + /// The cache lookup flags. + /// Receives the extended verb object. + /// The HRESULT returned by the extension. + [PreserveSig] + HRESULT GetVerbsEx(uint flags, [MarshalAs(UnmanagedType.Interface)] out object? verbs); + + /// Gets the extension conditions. + /// Receives the conditions object. + /// The HRESULT returned by the extension. + [PreserveSig] + HRESULT GetConditions([MarshalAs(UnmanagedType.Interface)] out object? conditions); +} diff --git a/src/Files.Core/Windows/Interop/IFileExplorerAppExtension2.cs b/src/Files.Core/Windows/Interop/IFileExplorerAppExtension2.cs new file mode 100644 index 0000000..f3c777c --- /dev/null +++ b/src/Files.Core/Windows/Interop/IFileExplorerAppExtension2.cs @@ -0,0 +1,61 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Native declarations preserve Windows SDK namespaces. + +using System.Runtime.InteropServices; +using System.Runtime.InteropServices.Marshalling; +using Windows.Win32.Foundation; + +namespace Windows.Win32.System.WinRT; + +/// Describes the second recovered Explorer app-extension ABI, which adds the level-one default state. +[GeneratedComInterface(Options = ComInterfaceOptions.ComObjectWrapper)] +[Guid("EB16945B-3A5D-5A8A-B666-8DFE27E5C818")] +[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] +internal partial interface IFileExplorerAppExtension2 : IInspectable +{ + /// Gets the extension display name. + /// Receives the display name. + /// The HRESULT returned by the extension. + [PreserveSig] + HRESULT GetDisplayName([MarshalUsing(typeof(global::Windows.Win32.HStringStringMarshaller))] out string? displayName); + + /// Gets the package full name. + /// Receives the package full name. + /// The HRESULT returned by the extension. + [PreserveSig] + HRESULT GetPackageFullName([MarshalUsing(typeof(global::Windows.Win32.HStringStringMarshaller))] out string? packageFullName); + + /// Gets the extension logo. + /// Receives the logo object. + /// The HRESULT returned by the extension. + [PreserveSig] + HRESULT GetLogo([MarshalAs(UnmanagedType.Interface)] out object? logo); + + /// Gets whether the extension is the level-one default. + /// Receives the default state. + /// The HRESULT returned by the extension. + [PreserveSig] + HRESULT GetIsL1Default([MarshalAs(UnmanagedType.U1)] out bool isDefault); + + /// Gets the extension verbs. + /// The cache lookup flags. + /// Receives the verb vector. + /// The HRESULT returned by the extension. + [PreserveSig] + HRESULT GetVerbs(uint flags, out IPropertySetVectorView? verbs); + + /// Gets the extended verb collection. + /// The cache lookup flags. + /// Receives the extended verb object. + /// The HRESULT returned by the extension. + [PreserveSig] + HRESULT GetVerbsEx(uint flags, [MarshalAs(UnmanagedType.Interface)] out object? verbs); + + /// Gets the extension conditions. + /// Receives the conditions object. + /// The HRESULT returned by the extension. + [PreserveSig] + HRESULT GetConditions([MarshalAs(UnmanagedType.Interface)] out object? conditions); +} diff --git a/src/Files.Core/Windows/Interop/IFileExplorerAppExtensionStatics.cs b/src/Files.Core/Windows/Interop/IFileExplorerAppExtensionStatics.cs new file mode 100644 index 0000000..e74b5ad --- /dev/null +++ b/src/Files.Core/Windows/Interop/IFileExplorerAppExtensionStatics.cs @@ -0,0 +1,32 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Native declarations preserve Windows SDK namespaces. + +using System.Runtime.InteropServices; +using System.Runtime.InteropServices.Marshalling; +using Windows.Win32.Foundation; + +namespace Windows.Win32.System.WinRT; + +/// Enumerates Explorer app extensions for an item type. +[GeneratedComInterface(Options = ComInterfaceOptions.ComObjectWrapper)] +[Guid("104C1AFF-F09F-5AA1-945F-78737EE0FE45")] +[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] +internal partial interface IFileExplorerAppExtensionStatics : IInspectable +{ + /// Gets extensions registered for an item type. + /// The item type. + /// The cache lookup flags. + /// Receives a vector view of extensions. + /// The HRESULT returned by the extension cache. + [PreserveSig] + HRESULT GetExtensions([MarshalUsing(typeof(global::Windows.Win32.HStringStringMarshaller))] string extension, uint flags, [MarshalAs(UnmanagedType.Interface)] out object? extensions); + + /// Gets every cached Explorer app extension. + /// The cache lookup flags. + /// Receives a vector view of extensions. + /// The HRESULT returned by the extension cache. + [PreserveSig] + HRESULT GetAllExtensions(uint flags, [MarshalAs(UnmanagedType.Interface)] out object? extensions); +} diff --git a/src/Files.Core/Windows/Interop/IFileExplorerAppExtensionVectorView.cs b/src/Files.Core/Windows/Interop/IFileExplorerAppExtensionVectorView.cs new file mode 100644 index 0000000..0f6acc0 --- /dev/null +++ b/src/Files.Core/Windows/Interop/IFileExplorerAppExtensionVectorView.cs @@ -0,0 +1,47 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Native declarations preserve Windows SDK namespaces. + +using System.Runtime.InteropServices; +using System.Runtime.InteropServices.Marshalling; +using Windows.Win32.Foundation; + +namespace Windows.Win32.System.WinRT; + +/// Provides indexed access to the original app-extension interface. +[GeneratedComInterface(Options = ComInterfaceOptions.ComObjectWrapper)] +[Guid("08ED2B5C-6EE2-5C20-B0E1-A1C0C739F17E")] +[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] +internal partial interface IFileExplorerAppExtensionVectorView : IInspectable +{ + /// Gets an extension by index. + /// The zero-based index. + /// Receives the extension. + /// The HRESULT returned by the vector. + [PreserveSig] + HRESULT GetAt(uint index, out IFileExplorerAppExtension? extension); + + /// Gets the number of extensions. + /// Receives the number of extensions. + /// The HRESULT returned by the vector. + [PreserveSig] + HRESULT GetSize(out uint size); + + /// Finds an extension in the vector. + /// The extension to find. + /// Receives its index. + /// Receives whether the extension was found. + /// The HRESULT returned by the vector. + [PreserveSig] + HRESULT IndexOf(IFileExplorerAppExtension? value, out uint index, [MarshalAs(UnmanagedType.U1)] out bool found); + + /// Copies extensions into a caller-provided array. + /// The first index to copy. + /// The array capacity. + /// The destination array. + /// Receives the number copied. + /// The HRESULT returned by the vector. + [PreserveSig] + HRESULT GetMany(uint startIndex, uint capacity, [Out, MarshalUsing(CountElementName = nameof(capacity))] IFileExplorerAppExtension?[] values, out uint actual); +} diff --git a/src/Files.Core/Windows/Interop/IFileExplorerAppExtensionVectorView2.cs b/src/Files.Core/Windows/Interop/IFileExplorerAppExtensionVectorView2.cs new file mode 100644 index 0000000..3a2dffe --- /dev/null +++ b/src/Files.Core/Windows/Interop/IFileExplorerAppExtensionVectorView2.cs @@ -0,0 +1,47 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Native declarations preserve Windows SDK namespaces. + +using System.Runtime.InteropServices; +using System.Runtime.InteropServices.Marshalling; +using Windows.Win32.Foundation; + +namespace Windows.Win32.System.WinRT; + +/// Provides indexed access to the second app-extension interface revision. +[GeneratedComInterface(Options = ComInterfaceOptions.ComObjectWrapper)] +[Guid("0E5F24ED-9BC4-5B7B-9DDB-46150318F868")] +[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] +internal partial interface IFileExplorerAppExtensionVectorView2 : IInspectable +{ + /// Gets an extension by index. + /// The zero-based index. + /// Receives the extension. + /// The HRESULT returned by the vector. + [PreserveSig] + HRESULT GetAt(uint index, out IFileExplorerAppExtension2? extension); + + /// Gets the number of extensions. + /// Receives the number of extensions. + /// The HRESULT returned by the vector. + [PreserveSig] + HRESULT GetSize(out uint size); + + /// Finds an extension in the vector. + /// The extension to find. + /// Receives its index. + /// Receives whether the extension was found. + /// The HRESULT returned by the vector. + [PreserveSig] + HRESULT IndexOf(IFileExplorerAppExtension2? value, out uint index, [MarshalAs(UnmanagedType.U1)] out bool found); + + /// Copies extensions into a caller-provided array. + /// The first index to copy. + /// The array capacity. + /// The destination array. + /// Receives the number copied. + /// The HRESULT returned by the vector. + [PreserveSig] + HRESULT GetMany(uint startIndex, uint capacity, [Out, MarshalUsing(CountElementName = nameof(capacity))] IFileExplorerAppExtension2?[] values, out uint actual); +} diff --git a/src/Files.Core/Windows/Interop/IInspectable.cs b/src/Files.Core/Windows/Interop/IInspectable.cs new file mode 100644 index 0000000..d3e0ba1 --- /dev/null +++ b/src/Files.Core/Windows/Interop/IInspectable.cs @@ -0,0 +1,36 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Native declarations preserve Windows SDK namespaces. + +using System.Runtime.InteropServices; +using System.Runtime.InteropServices.Marshalling; +using Windows.Win32.Foundation; + +namespace Windows.Win32.System.WinRT; + +/// Provides the base Windows Runtime inspection contract. +[GeneratedComInterface(Options = ComInterfaceOptions.ComObjectWrapper)] +[Guid("AF86E2E0-B12D-4C6A-9C5A-D7AA65101E90")] +[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] +internal partial interface IInspectable +{ + /// Gets the interface identifiers implemented by the object. + /// Receives the number of identifiers. + /// Receives the allocated identifier array. + /// The HRESULT returned by the object. + [PreserveSig] + HRESULT GetIids(out uint iidCount, out global::Windows.Win32.ComHeapPtr iids); + + /// Gets the runtime class name. + /// Receives the runtime class name. + /// The HRESULT returned by the object. + [PreserveSig] + HRESULT GetRuntimeClassName([MarshalUsing(typeof(global::Windows.Win32.HStringStringMarshaller))] out string? className); + + /// Gets the runtime trust level. + /// Receives the trust level. + /// The HRESULT returned by the object. + [PreserveSig] + HRESULT GetTrustLevel(out TrustLevel trustLevel); +} diff --git a/src/Files.Core/Interop/Windows/IItemStore.cs b/src/Files.Core/Windows/Interop/IItemStore.cs similarity index 60% rename from src/Files.Core/Interop/Windows/IItemStore.cs rename to src/Files.Core/Windows/Interop/IItemStore.cs index c677e56..1511bde 100644 --- a/src/Files.Core/Interop/Windows/IItemStore.cs +++ b/src/Files.Core/Windows/Interop/IItemStore.cs @@ -1,6 +1,8 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Native declarations preserve Windows SDK namespaces. + using System.Runtime.InteropServices; using System.Runtime.InteropServices.Marshalling; using Windows.Win32.Foundation; @@ -35,22 +37,6 @@ internal enum GET_PROPERTY_STORE_TYPE : uint Default = 0, } -internal enum SET_PROPERTY_STORE_TYPE -{ - Default = 0, -} - -[StructLayout(LayoutKind.Sequential, Size = 8)] -internal struct ITEMGROUP -{ -} - -/// Identifies an Explorer child item stored by PIDL. This recovered marker adds no ABI slots. -[GeneratedComInterface, Guid("C412BF5B-91EA-4904-B34A-855504FBBF0B"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] -internal partial interface IChildId -{ -} - /// Provides Explorer's recovered item-store contract. [GeneratedComInterface, Guid("DF44CD5D-9AE9-4935-980A-E8ADD2246D41"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] internal partial interface IItemStore @@ -171,90 +157,3 @@ HRESULT GetItemPropertyStore(GET_PROPERTY_STORE_TYPE storeType, in ITEMKEY itemK [PreserveSig] HRESULT GetUnrealizedItem(in ITEMKEY itemKey, in Guid interfaceId, [MarshalAs(UnmanagedType.Interface)] out object? item); } - -/// Adds the recovered DefView operations to Explorer's item-store contract. -[GeneratedComInterface, Guid("35C22FEA-79F6-4D3D-AE15-1699CBF54721"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] -internal unsafe partial interface IDefViewItemStore : IItemStore -{ - /// Initializes the store for a root PIDL. - /// The absolute root PIDL. - /// The HRESULT returned by the store. - [PreserveSig] - HRESULT Initialize(in ITEMIDLIST rootPidl); - - /// Deletes an item from the store. - /// The item key. - /// The HRESULT returned by the store. - [PreserveSig] - HRESULT DeleteItem(in ITEMKEY itemKey); - - /// Sets an item's child identifier and selected flags. - /// The item key. - /// The optional child identifier. - /// The flags to change. - /// The new flag values. - /// The HRESULT returned by the store. - [PreserveSig] - HRESULT SetItemIDListAndFlags(in ITEMKEY itemKey, IChildId? childId, ITEM_FLAGS mask, ITEM_FLAGS value); - - /// Sets an item's property store. - /// The property-store type. - /// The item key. - /// The optional property store. - /// The HRESULT returned by the store. - [PreserveSig] - HRESULT SetItemPropertyStore(SET_PROPERTY_STORE_TYPE storeType, in ITEMKEY itemKey, IPropertyStore? propertyStore); - - /// Associates arbitrary COM data with an item. - /// The item key. - /// The optional data object, or to clear it. - /// The HRESULT returned by the store. - [PreserveSig] - HRESULT SetData(in ITEMKEY itemKey, [MarshalAs(UnmanagedType.Interface)] object? data); - - /// Gets arbitrary COM data associated with an item. - /// The item key. - /// The requested interface identifier. - /// Receives the requested interface. - /// The HRESULT returned by the store. - [PreserveSig] - HRESULT GetData(in ITEMKEY itemKey, in Guid interfaceId, [MarshalAs(UnmanagedType.Interface)] out object? data); - - /// Sets an item cookie. - /// The item key. - /// The cookie index. - /// The cookie value. - [PreserveSig] - void SetItemCookie(in ITEMKEY itemKey, int index, uint cookie); - - /// Gets an item cookie. - /// The item key. - /// The cookie index. - /// The cookie value. - [PreserveSig] - uint GetItemCookie(in ITEMKEY itemKey, int index); - - /// Sets an item's opaque group records. - /// The item key. - /// The group type. - /// The group records. - /// The number of group records. - /// The HRESULT returned by the store. - [PreserveSig] - HRESULT SetItemGroups(in ITEMKEY itemKey, uint groupType, [In, MarshalUsing(CountElementName = nameof(count))] ITEMGROUP[] groups, int count); - - /// Gets the store-owned group records for an item. - /// The item key. - /// The group type. - /// Receives a borrowed pointer to the group records. The caller must not free it. - /// Receives the number of group records. - /// The HRESULT returned by the store. - [PreserveSig] - HRESULT GetItemGroups(in ITEMKEY itemKey, uint groupType, out ITEMGROUP* groups, out int count); - - /// Determines whether an item key is valid. - /// The item key. - /// when the key is valid; otherwise, . - [PreserveSig] - BOOL IsItemKeyValid(in ITEMKEY itemKey); -} diff --git a/src/Files.Core/Windows/Interop/IMountPointRename.cs b/src/Files.Core/Windows/Interop/IMountPointRename.cs new file mode 100644 index 0000000..226ccb7 --- /dev/null +++ b/src/Files.Core/Windows/Interop/IMountPointRename.cs @@ -0,0 +1,30 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Native declarations preserve Windows SDK namespaces. + +using System.Runtime.InteropServices; +using System.Runtime.InteropServices.Marshalling; +using Windows.Win32.Foundation; + +namespace Windows.Win32.UI.Shell; + +/// Identifies the Shell mount-point rename coclass. +[Guid("60173D16-A550-47F0-A14B-C6F9E4DA0831")] +internal sealed class CMountPointRename +{ +} + +/// Renames a filesystem mount point through the Shell's elevated service. +[GeneratedComInterface(StringMarshalling = StringMarshalling.Utf16, Options = ComInterfaceOptions.ComObjectWrapper)] +[Guid("92F8D886-AB61-4113-BD4F-2E894397386F")] +[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] +internal partial interface IMountPointRename +{ + /// Changes a volume label. + /// The volume root path. + /// The new volume label. + /// The HRESULT returned by the Shell service. + [PreserveSig] + HRESULT Rename(string rootPath, string label); +} diff --git a/src/Files.Core/Windows/Interop/IMultiObjectElevationFactory.cs b/src/Files.Core/Windows/Interop/IMultiObjectElevationFactory.cs new file mode 100644 index 0000000..dcf7950 --- /dev/null +++ b/src/Files.Core/Windows/Interop/IMultiObjectElevationFactory.cs @@ -0,0 +1,45 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Native declarations preserve Windows SDK namespaces. + +using System.Runtime.InteropServices; +using System.Runtime.InteropServices.Marshalling; +using Windows.Win32.Foundation; + +namespace Windows.Win32.UI.Shell; + +/// Identifies the Shell multi-object elevation factory coclass. +[Guid("36F0BD14-D84D-468C-B79C-9990F3FA897F")] +internal sealed class CMultiObjectElevationFactory +{ +} + +/// Creates an elevated sharing object after associating it with an owner window. +[GeneratedComInterface(Options = ComInterfaceOptions.ComObjectWrapper)] +[Guid("6FABDA16-031E-47E3-B2A2-2339C05CCB9E")] +[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] +internal partial interface IMultiObjectElevationFactory +{ + /// Initializes the factory for an elevated coclass. + /// The owner window. + /// The elevated coclass identifier. + /// The HRESULT returned by the factory. + [PreserveSig] + HRESULT Initialize(HWND owner, in Guid classId); + + /// Initializes the factory without changing the wait cursor. + /// The owner window. + /// The elevated coclass identifier. + /// The HRESULT returned by the factory. + [PreserveSig] + HRESULT InitializeNoWaitCursor(HWND owner, in Guid classId); + + /// Creates the requested elevated object. + /// The coclass identifier. + /// The requested interface identifier. + /// Receives the requested interface. + /// The HRESULT returned by the factory. + [PreserveSig] + HRESULT CreateElevatedObject(in Guid classId, in Guid interfaceId, [MarshalAs(UnmanagedType.Interface)] out object? instance); +} diff --git a/src/Files.Core/Windows/Interop/IPropertySet.cs b/src/Files.Core/Windows/Interop/IPropertySet.cs new file mode 100644 index 0000000..f35341e --- /dev/null +++ b/src/Files.Core/Windows/Interop/IPropertySet.cs @@ -0,0 +1,17 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Native declarations preserve Windows SDK namespaces. + +using System.Runtime.InteropServices; +using System.Runtime.InteropServices.Marshalling; + +namespace Windows.Win32.System.WinRT; + +/// Identifies a Windows Runtime property set. This interface adds no ABI slots; map access is obtained through . +[GeneratedComInterface(Options = ComInterfaceOptions.ComObjectWrapper)] +[Guid("8A43ED9F-F4E6-4421-ACF9-1DAB2986820C")] +[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] +internal partial interface IPropertySet : IInspectable +{ +} diff --git a/src/Files.Core/Windows/Interop/IPropertySetVectorView.cs b/src/Files.Core/Windows/Interop/IPropertySetVectorView.cs new file mode 100644 index 0000000..ec7ec9b --- /dev/null +++ b/src/Files.Core/Windows/Interop/IPropertySetVectorView.cs @@ -0,0 +1,47 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Native declarations preserve Windows SDK namespaces. + +using System.Runtime.InteropServices; +using System.Runtime.InteropServices.Marshalling; +using Windows.Win32.Foundation; + +namespace Windows.Win32.System.WinRT; + +/// Provides indexed access to Explorer verb property sets. +[GeneratedComInterface(Options = ComInterfaceOptions.ComObjectWrapper)] +[Guid("A79C3578-C5C8-5B61-AFC7-8DA842914434")] +[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] +internal partial interface IPropertySetVectorView : IInspectable +{ + /// Gets a property set by index. + /// The zero-based index. + /// Receives the property set. + /// The HRESULT returned by the vector. + [PreserveSig] + HRESULT GetAt(uint index, out IPropertySet? value); + + /// Gets the number of property sets. + /// Receives the number of property sets. + /// The HRESULT returned by the vector. + [PreserveSig] + HRESULT GetSize(out uint size); + + /// Finds a property set in the vector. + /// The property set to find. + /// Receives its index. + /// Receives whether the property set was found. + /// The HRESULT returned by the vector. + [PreserveSig] + HRESULT IndexOf(IPropertySet? value, out uint index, [MarshalAs(UnmanagedType.U1)] out bool found); + + /// Copies property sets into a caller-provided array. + /// The first index to copy. + /// The array capacity. + /// The destination array. + /// Receives the number copied. + /// The HRESULT returned by the vector. + [PreserveSig] + HRESULT GetMany(uint startIndex, uint capacity, [Out, MarshalUsing(CountElementName = nameof(capacity))] IPropertySet?[] values, out uint actual); +} diff --git a/src/Files.Core/Windows/Interop/IPropertyValue.cs b/src/Files.Core/Windows/Interop/IPropertyValue.cs new file mode 100644 index 0000000..8f2a193 --- /dev/null +++ b/src/Files.Core/Windows/Interop/IPropertyValue.cs @@ -0,0 +1,272 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Native declarations preserve Windows SDK namespaces. + +using System.Runtime.InteropServices; +using System.Runtime.InteropServices.Marshalling; +using Windows.Win32.Foundation; + +namespace Windows.Win32.System.WinRT; + +/// Reads scalar and array values from a Windows Runtime property value. +[GeneratedComInterface(Options = ComInterfaceOptions.ComObjectWrapper)] +[Guid("4BD682DD-7554-40E9-9A9B-82654EDE7E62")] +[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] +internal partial interface IPropertyValue : IInspectable +{ + /// Gets the stored property type. + /// Receives the property type. + /// The HRESULT returned by the value. + [PreserveSig] + HRESULT GetPropertyType(out global::Windows.Foundation.PropertyType value); + + /// Gets whether the value is a numeric scalar. + /// Receives whether the value is a numeric scalar. + /// The HRESULT returned by the value. + [PreserveSig] + HRESULT GetIsNumericScalar([MarshalAs(UnmanagedType.U1)] out bool value); + + /// Gets an unsigned 8-bit value. + /// Receives the value. + /// The HRESULT returned by the value. + [PreserveSig] + HRESULT GetUInt8(out byte value); + + /// Gets a signed 16-bit value. + /// Receives the value. + /// The HRESULT returned by the value. + [PreserveSig] + HRESULT GetInt16(out short value); + + /// Gets an unsigned 16-bit value. + /// Receives the value. + /// The HRESULT returned by the value. + [PreserveSig] + HRESULT GetUInt16(out ushort value); + + /// Gets a signed 32-bit value. + /// Receives the value. + /// The HRESULT returned by the value. + [PreserveSig] + HRESULT GetInt32(out int value); + + /// Gets an unsigned 32-bit value. + /// Receives the value. + /// The HRESULT returned by the value. + [PreserveSig] + HRESULT GetUInt32(out uint value); + + /// Gets a signed 64-bit value. + /// Receives the value. + /// The HRESULT returned by the value. + [PreserveSig] + HRESULT GetInt64(out long value); + + /// Gets an unsigned 64-bit value. + /// Receives the value. + /// The HRESULT returned by the value. + [PreserveSig] + HRESULT GetUInt64(out ulong value); + + /// Gets a single-precision value. + /// Receives the value. + /// The HRESULT returned by the value. + [PreserveSig] + HRESULT GetSingle(out float value); + + /// Gets a double-precision value. + /// Receives the value. + /// The HRESULT returned by the value. + [PreserveSig] + HRESULT GetDouble(out double value); + + /// Gets a UTF-16 character. + /// Receives the value. + /// The HRESULT returned by the value. + [PreserveSig] + HRESULT GetChar16(out char value); + + /// Gets a Boolean value. + /// Receives the value. + /// The HRESULT returned by the value. + [PreserveSig] + HRESULT GetBoolean([MarshalAs(UnmanagedType.U1)] out bool value); + + /// Gets a string value. + /// Receives the value. + /// The HRESULT returned by the value. + [PreserveSig] + HRESULT GetString([MarshalUsing(typeof(global::Windows.Win32.HStringStringMarshaller))] out string? value); + + /// Gets a GUID value. + /// Receives the value. + /// The HRESULT returned by the value. + [PreserveSig] + HRESULT GetGuid(out Guid value); + + /// Gets a Windows Runtime date-time ABI value. + /// Receives the universal-time tick value. + /// The HRESULT returned by the value. + [PreserveSig] + HRESULT GetDateTime(out long universalTime); + + /// Gets a Windows Runtime time-span ABI value. + /// Receives the duration tick value. + /// The HRESULT returned by the value. + [PreserveSig] + HRESULT GetTimeSpan(out long duration); + + /// Gets a point value. + /// Receives the value. + /// The HRESULT returned by the value. + [PreserveSig] + HRESULT GetPoint(out global::Windows.Foundation.Point value); + + /// Gets a size value. + /// Receives the value. + /// The HRESULT returned by the value. + [PreserveSig] + HRESULT GetSize(out global::Windows.Foundation.Size value); + + /// Gets a rectangle value. + /// Receives the value. + /// The HRESULT returned by the value. + [PreserveSig] + HRESULT GetRect(out global::Windows.Foundation.Rect value); + + /// Gets an unsigned 8-bit array. + /// Receives the array length. + /// Receives the allocated array. + /// The HRESULT returned by the value. + [PreserveSig] + HRESULT GetUInt8Array(out uint valueLength, [MarshalUsing(CountElementName = nameof(valueLength))] out byte[]? value); + + /// Gets a signed 16-bit array. + /// Receives the array length. + /// Receives the allocated array. + /// The HRESULT returned by the value. + [PreserveSig] + HRESULT GetInt16Array(out uint valueLength, [MarshalUsing(CountElementName = nameof(valueLength))] out short[]? value); + + /// Gets an unsigned 16-bit array. + /// Receives the array length. + /// Receives the allocated array. + /// The HRESULT returned by the value. + [PreserveSig] + HRESULT GetUInt16Array(out uint valueLength, [MarshalUsing(CountElementName = nameof(valueLength))] out ushort[]? value); + + /// Gets a signed 32-bit array. + /// Receives the array length. + /// Receives the allocated array. + /// The HRESULT returned by the value. + [PreserveSig] + HRESULT GetInt32Array(out uint valueLength, [MarshalUsing(CountElementName = nameof(valueLength))] out int[]? value); + + /// Gets an unsigned 32-bit array. + /// Receives the array length. + /// Receives the allocated array. + /// The HRESULT returned by the value. + [PreserveSig] + HRESULT GetUInt32Array(out uint valueLength, [MarshalUsing(CountElementName = nameof(valueLength))] out uint[]? value); + + /// Gets a signed 64-bit array. + /// Receives the array length. + /// Receives the allocated array. + /// The HRESULT returned by the value. + [PreserveSig] + HRESULT GetInt64Array(out uint valueLength, [MarshalUsing(CountElementName = nameof(valueLength))] out long[]? value); + + /// Gets an unsigned 64-bit array. + /// Receives the array length. + /// Receives the allocated array. + /// The HRESULT returned by the value. + [PreserveSig] + HRESULT GetUInt64Array(out uint valueLength, [MarshalUsing(CountElementName = nameof(valueLength))] out ulong[]? value); + + /// Gets a single-precision array. + /// Receives the array length. + /// Receives the allocated array. + /// The HRESULT returned by the value. + [PreserveSig] + HRESULT GetSingleArray(out uint valueLength, [MarshalUsing(CountElementName = nameof(valueLength))] out float[]? value); + + /// Gets a double-precision array. + /// Receives the array length. + /// Receives the allocated array. + /// The HRESULT returned by the value. + [PreserveSig] + HRESULT GetDoubleArray(out uint valueLength, [MarshalUsing(CountElementName = nameof(valueLength))] out double[]? value); + + /// Gets a UTF-16 character array. + /// Receives the array length. + /// Receives the allocated array. + /// The HRESULT returned by the value. + [PreserveSig] + HRESULT GetChar16Array(out uint valueLength, [MarshalUsing(CountElementName = nameof(valueLength))] out ushort[]? value); + + /// Gets a Windows Runtime Boolean array. + /// Receives the array length. + /// Receives the allocated one-byte Boolean values. + /// The HRESULT returned by the value. + [PreserveSig] + HRESULT GetBooleanArray(out uint valueLength, [MarshalUsing(CountElementName = nameof(valueLength))] out byte[]? value); + + /// Gets a string array. + /// Receives the array length. + /// Receives the allocated array. + /// The HRESULT returned by the value. + [PreserveSig] + HRESULT GetStringArray(out uint valueLength, + [MarshalUsing(CountElementName = nameof(valueLength))] + [MarshalUsing(typeof(global::Windows.Win32.HStringStringMarshaller), ElementIndirectionDepth = 1)] out string?[]? value); + + /// Gets an inspectable array. + /// Receives the array length. + /// Receives the allocated array. + /// The HRESULT returned by the value. + [PreserveSig] + HRESULT GetInspectableArray(out uint valueLength, [MarshalUsing(CountElementName = nameof(valueLength))] out IInspectable?[]? value); + + /// Gets a GUID array. + /// Receives the array length. + /// Receives the allocated array. + /// The HRESULT returned by the value. + [PreserveSig] + HRESULT GetGuidArray(out uint valueLength, [MarshalUsing(CountElementName = nameof(valueLength))] out Guid[]? value); + + /// Gets a Windows Runtime date-time ABI array. + /// Receives the array length. + /// Receives the allocated universal-time tick values. + /// The HRESULT returned by the value. + [PreserveSig] + HRESULT GetDateTimeArray(out uint valueLength, [MarshalUsing(CountElementName = nameof(valueLength))] out long[]? value); + + /// Gets a Windows Runtime time-span ABI array. + /// Receives the array length. + /// Receives the allocated duration tick values. + /// The HRESULT returned by the value. + [PreserveSig] + HRESULT GetTimeSpanArray(out uint valueLength, [MarshalUsing(CountElementName = nameof(valueLength))] out long[]? value); + + /// Gets a point array. + /// Receives the array length. + /// Receives the allocated array. + /// The HRESULT returned by the value. + [PreserveSig] + HRESULT GetPointArray(out uint valueLength, [MarshalUsing(CountElementName = nameof(valueLength))] out global::Windows.Foundation.Point[]? value); + + /// Gets a size array. + /// Receives the array length. + /// Receives the allocated array. + /// The HRESULT returned by the value. + [PreserveSig] + HRESULT GetSizeArray(out uint valueLength, [MarshalUsing(CountElementName = nameof(valueLength))] out global::Windows.Foundation.Size[]? value); + + /// Gets a rectangle array. + /// Receives the array length. + /// Receives the allocated array. + /// The HRESULT returned by the value. + [PreserveSig] + HRESULT GetRectArray(out uint valueLength, [MarshalUsing(CountElementName = nameof(valueLength))] out global::Windows.Foundation.Rect[]? value); +} diff --git a/src/Files.Core/Interop/Windows/ShellPropertyPageInterfaces.cs b/src/Files.Core/Windows/Interop/ISharingConfigurationUI.cs similarity index 61% rename from src/Files.Core/Interop/Windows/ShellPropertyPageInterfaces.cs rename to src/Files.Core/Windows/Interop/ISharingConfigurationUI.cs index 4b35d26..386bcbf 100644 --- a/src/Files.Core/Interop/Windows/ShellPropertyPageInterfaces.cs +++ b/src/Files.Core/Windows/Interop/ISharingConfigurationUI.cs @@ -1,73 +1,20 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Native declarations preserve Windows SDK namespaces. + using System.Runtime.InteropServices; using System.Runtime.InteropServices.Marshalling; using Windows.Win32.Foundation; namespace Windows.Win32.UI.Shell; -/// Identifies the Shell mount-point rename coclass. -[Guid("60173D16-A550-47F0-A14B-C6F9E4DA0831")] -internal sealed class CMountPointRename -{ -} - -/// Identifies the Shell multi-object elevation factory coclass. -[Guid("36F0BD14-D84D-468C-B79C-9990F3FA897F")] -internal sealed class CMultiObjectElevationFactory -{ -} - /// Identifies the Shell elevated sharing factory coclass. [Guid("72A7994A-3092-4054-B6BE-08FF81AEEFFC")] internal sealed class CSharingElevatedFactory { } -/// Renames a filesystem mount point through the Shell's elevated service. -[GeneratedComInterface(StringMarshalling = StringMarshalling.Utf16, Options = ComInterfaceOptions.ComObjectWrapper)] -[Guid("92F8D886-AB61-4113-BD4F-2E894397386F")] -[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] -internal partial interface IMountPointRename -{ - /// Changes a volume label. - /// The volume root path. - /// The new volume label. - /// The HRESULT returned by the Shell service. - [PreserveSig] - HRESULT Rename(string rootPath, string label); -} - -/// Creates an elevated sharing object after associating it with an owner window. -[GeneratedComInterface(Options = ComInterfaceOptions.ComObjectWrapper)] -[Guid("6FABDA16-031E-47E3-B2A2-2339C05CCB9E")] -[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] -internal partial interface IMultiObjectElevationFactory -{ - /// Initializes the factory for an elevated coclass. - /// The owner window. - /// The elevated coclass identifier. - /// The HRESULT returned by the factory. - [PreserveSig] - HRESULT Initialize(HWND owner, in Guid classId); - - /// Initializes the factory without changing the wait cursor. - /// The owner window. - /// The elevated coclass identifier. - /// The HRESULT returned by the factory. - [PreserveSig] - HRESULT InitializeNoWaitCursor(HWND owner, in Guid classId); - - /// Creates the requested elevated object. - /// The coclass identifier. - /// The requested interface identifier. - /// Receives the requested interface. - /// The HRESULT returned by the factory. - [PreserveSig] - HRESULT CreateElevatedObject(in Guid classId, in Guid interfaceId, [MarshalAs(UnmanagedType.Interface)] out object? instance); -} - /// Runs the Shell's sharing commands for a collection of items. [GeneratedComInterface(StringMarshalling = StringMarshalling.Utf16, Options = ComInterfaceOptions.ComObjectWrapper)] [Guid("14AA4AB8-ABE3-4A07-A290-1D5DCCDD2FC2")] diff --git a/src/Files.Core/Windows/Interop/IStringInspectableMap.cs b/src/Files.Core/Windows/Interop/IStringInspectableMap.cs new file mode 100644 index 0000000..6021334 --- /dev/null +++ b/src/Files.Core/Windows/Interop/IStringInspectableMap.cs @@ -0,0 +1,62 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Native declarations preserve Windows SDK namespaces. + +using System.Runtime.InteropServices; +using System.Runtime.InteropServices.Marshalling; +using Windows.Win32.Foundation; + +namespace Windows.Win32.System.WinRT; + +/// Provides mutable access to a string-to-inspectable map. +[GeneratedComInterface(Options = ComInterfaceOptions.ComObjectWrapper)] +[Guid("1B0D3570-0877-5EC2-8A2C-3B9539506ACA")] +[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] +internal partial interface IStringInspectableMap : IInspectable +{ + /// Gets a value by key. + /// The lookup key. + /// Receives the value. + /// The HRESULT returned by the map. + [PreserveSig] + HRESULT Lookup([MarshalUsing(typeof(global::Windows.Win32.HStringStringMarshaller))] string key, out IInspectable? value); + + /// Gets the number of entries. + /// Receives the entry count. + /// The HRESULT returned by the map. + [PreserveSig] + HRESULT GetSize(out uint size); + + /// Determines whether the map contains a key. + /// The lookup key. + /// Receives whether the key exists. + /// The HRESULT returned by the map. + [PreserveSig] + HRESULT HasKey([MarshalUsing(typeof(global::Windows.Win32.HStringStringMarshaller))] string key, [MarshalAs(UnmanagedType.U1)] out bool found); + + /// Gets a read-only view of the map. + /// Receives the map view. + /// The HRESULT returned by the map. + [PreserveSig] + HRESULT GetView(out IStringInspectableMapView? view); + + /// Inserts or replaces a value. + /// The key to insert. + /// The value to insert. + /// Receives whether an existing value was replaced. + /// The HRESULT returned by the map. + [PreserveSig] + HRESULT Insert([MarshalUsing(typeof(global::Windows.Win32.HStringStringMarshaller))] string key, IInspectable? value, [MarshalAs(UnmanagedType.U1)] out bool replaced); + + /// Removes a value. + /// The key to remove. + /// The HRESULT returned by the map. + [PreserveSig] + HRESULT Remove([MarshalUsing(typeof(global::Windows.Win32.HStringStringMarshaller))] string key); + + /// Removes every value. + /// The HRESULT returned by the map. + [PreserveSig] + HRESULT Clear(); +} diff --git a/src/Files.Core/Windows/Interop/IStringInspectableMapView.cs b/src/Files.Core/Windows/Interop/IStringInspectableMapView.cs new file mode 100644 index 0000000..a0804c2 --- /dev/null +++ b/src/Files.Core/Windows/Interop/IStringInspectableMapView.cs @@ -0,0 +1,44 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Native declarations preserve Windows SDK namespaces. + +using System.Runtime.InteropServices; +using System.Runtime.InteropServices.Marshalling; +using Windows.Win32.Foundation; + +namespace Windows.Win32.System.WinRT; + +/// Provides read-only access to a string-to-inspectable map. +[GeneratedComInterface(Options = ComInterfaceOptions.ComObjectWrapper)] +[Guid("BB78502A-F79D-54FA-92C9-90C5039FDF7E")] +[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] +internal partial interface IStringInspectableMapView : IInspectable +{ + /// Gets a value by key. + /// The lookup key. + /// Receives the value. + /// The HRESULT returned by the map view. + [PreserveSig] + HRESULT Lookup([MarshalUsing(typeof(global::Windows.Win32.HStringStringMarshaller))] string key, out IInspectable? value); + + /// Gets the number of entries. + /// Receives the entry count. + /// The HRESULT returned by the map view. + [PreserveSig] + HRESULT GetSize(out uint size); + + /// Determines whether the map view contains a key. + /// The lookup key. + /// Receives whether the key exists. + /// The HRESULT returned by the map view. + [PreserveSig] + HRESULT HasKey([MarshalUsing(typeof(global::Windows.Win32.HStringStringMarshaller))] string key, [MarshalAs(UnmanagedType.U1)] out bool found); + + /// Splits the map view into two views. + /// Receives the first view. + /// Receives the second view. + /// The HRESULT returned by the map view. + [PreserveSig] + HRESULT Split(out IStringInspectableMapView? first, out IStringInspectableMapView? second); +} diff --git a/src/Files.Core/Windows/Interop/ManagedMONITORENUMPROC.cs b/src/Files.Core/Windows/Interop/ManagedMONITORENUMPROC.cs new file mode 100644 index 0000000..407f1ab --- /dev/null +++ b/src/Files.Core/Windows/Interop/ManagedMONITORENUMPROC.cs @@ -0,0 +1,19 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Native declarations preserve Windows SDK namespaces. + +using System.Runtime.InteropServices; +using Windows.Win32.Foundation; +using Windows.Win32.Graphics.Gdi; + +namespace Windows.Win32.Extras; + +/// Delegate used to enumerate monitors through the Win32 API. +/// The monitor handle. +/// The device context handle. +/// The monitor rectangle. +/// The application-defined value. +/// A nonzero value to continue enumeration. +[UnmanagedFunctionPointer(CallingConvention.Winapi)] +public delegate BOOL ManagedMONITORENUMPROC([In] HMONITOR param0, [In] HDC param1, [In, Out] ref RECT param2, [In] LPARAM param3); diff --git a/src/Files.Core/Windows/Interop/ManagedWNDPROC.cs b/src/Files.Core/Windows/Interop/ManagedWNDPROC.cs new file mode 100644 index 0000000..cbb2530 --- /dev/null +++ b/src/Files.Core/Windows/Interop/ManagedWNDPROC.cs @@ -0,0 +1,18 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Native declarations preserve Windows SDK namespaces. + +using System.Runtime.InteropServices; +using Windows.Win32.Foundation; + +namespace Windows.Win32.Extras; + +/// Delegate used as a managed window procedure callback. +/// The window handle. +/// The window message. +/// The message parameter. +/// The message parameter. +/// The result of processing the message. +[UnmanagedFunctionPointer(CallingConvention.Winapi)] +public delegate LRESULT ManagedWNDPROC(HWND hWnd, uint msg, WPARAM wParam, LPARAM lParam); diff --git a/src/Files.Core/Windows/Interop/WindowsDeleteStringSafeHandle.cs b/src/Files.Core/Windows/Interop/WindowsDeleteStringSafeHandle.cs new file mode 100644 index 0000000..e0e2c2b --- /dev/null +++ b/src/Files.Core/Windows/Interop/WindowsDeleteStringSafeHandle.cs @@ -0,0 +1,20 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Native declarations preserve Windows SDK namespaces. + +using Windows.Win32.System.WinRT; + +namespace Windows.Win32; + +/// Extends the generated HSTRING safe handle with ownership transfer for custom marshalling. +public partial class WindowsDeleteStringSafeHandle +{ + internal HSTRING Detach() + { + var value = (HSTRING)DangerousGetHandle(); + SetHandleAsInvalid(); + + return value; + } +} diff --git a/src/Files.Core/Storage/Windows/IWindowsItemIdReader.cs b/src/Files.Core/Windows/Items/IWindowsItemIdReader.cs similarity index 75% rename from src/Files.Core/Storage/Windows/IWindowsItemIdReader.cs rename to src/Files.Core/Windows/Items/IWindowsItemIdReader.cs index ec38736..071093a 100644 --- a/src/Files.Core/Storage/Windows/IWindowsItemIdReader.cs +++ b/src/Files.Core/Windows/Items/IWindowsItemIdReader.cs @@ -1,7 +1,9 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 -namespace Files.Core.Storage.Windows; +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +namespace Files.Core.Windows; /// /// Creates source-specific identities independently from Shell addresses. diff --git a/src/Files.Core/Storage/Windows/IWindowsStorable.cs b/src/Files.Core/Windows/Items/IWindowsStorable.cs similarity index 84% rename from src/Files.Core/Storage/Windows/IWindowsStorable.cs rename to src/Files.Core/Windows/Items/IWindowsStorable.cs index f62e91f..49e1fc9 100644 --- a/src/Files.Core/Storage/Windows/IWindowsStorable.cs +++ b/src/Files.Core/Windows/Items/IWindowsStorable.cs @@ -1,9 +1,12 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +using Files.Core.Storage; using OwlCore.Storage; -namespace Files.Core.Storage.Windows; +namespace Files.Core.Windows; /// /// Describes an OwlCore item backed by the Windows Shell namespace. diff --git a/src/Files.Core/Storage/Windows/ShellItemHelpers.cs b/src/Files.Core/Windows/Items/ShellItemHelpers.cs similarity index 97% rename from src/Files.Core/Storage/Windows/ShellItemHelpers.cs rename to src/Files.Core/Windows/Items/ShellItemHelpers.cs index 16dde11..e30c786 100644 --- a/src/Files.Core/Storage/Windows/ShellItemHelpers.cs +++ b/src/Files.Core/Windows/Items/ShellItemHelpers.cs @@ -1,7 +1,10 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + using System.Runtime.InteropServices; +using Files.Core.Storage; using OwlCore.Storage; using Windows.Win32; using Windows.Win32.System.Com; @@ -9,7 +12,7 @@ using Windows.Win32.UI.Shell; using Windows.Win32.UI.Shell.Common; -namespace Files.Core.Storage.Windows; +namespace Files.Core.Windows; internal static unsafe class ShellItemHelpers { diff --git a/src/Files.Core/Storage/Windows/ShellReadStream.cs b/src/Files.Core/Windows/Items/ShellReadStream.cs similarity index 97% rename from src/Files.Core/Storage/Windows/ShellReadStream.cs rename to src/Files.Core/Windows/Items/ShellReadStream.cs index 666ed5f..1e675b5 100644 --- a/src/Files.Core/Storage/Windows/ShellReadStream.cs +++ b/src/Files.Core/Windows/Items/ShellReadStream.cs @@ -1,10 +1,12 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + using System.IO; using Windows.Win32.System.Com; -namespace Files.Core.Storage.Windows; +namespace Files.Core.Windows; /// /// Keeps a virtual Shell stream private and routes every COM call through its STA lane. diff --git a/src/Files.Core/Storage/Windows/WindowsFile.cs b/src/Files.Core/Windows/Items/WindowsFile.cs similarity index 87% rename from src/Files.Core/Storage/Windows/WindowsFile.cs rename to src/Files.Core/Windows/Items/WindowsFile.cs index 15e2e7a..0b06c4c 100644 --- a/src/Files.Core/Storage/Windows/WindowsFile.cs +++ b/src/Files.Core/Windows/Items/WindowsFile.cs @@ -1,10 +1,12 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + using System.IO; using OwlCore.Storage; -namespace Files.Core.Storage.Windows; +namespace Files.Core.Windows; /// Represents a file exposed by the Windows Shell. public sealed class WindowsFile : WindowsStorable, IChildFile diff --git a/src/Files.Core/Storage/Windows/WindowsFolder.cs b/src/Files.Core/Windows/Items/WindowsFolder.cs similarity index 95% rename from src/Files.Core/Storage/Windows/WindowsFolder.cs rename to src/Files.Core/Windows/Items/WindowsFolder.cs index f0840ba..3e7afbb 100644 --- a/src/Files.Core/Storage/Windows/WindowsFolder.cs +++ b/src/Files.Core/Windows/Items/WindowsFolder.cs @@ -1,12 +1,14 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + using System.Runtime.CompilerServices; using Files.Core.ViewSettings; using OwlCore.Storage; using Windows.Win32.Foundation; -namespace Files.Core.Storage.Windows; +namespace Files.Core.Windows; /// Represents a folder exposed by the Windows Shell. public sealed class WindowsFolder : WindowsStorable, IChildFolder diff --git a/src/Files.Core/Storage/Windows/WindowsItemIdReader.cs b/src/Files.Core/Windows/Items/WindowsItemIdReader.cs similarity index 97% rename from src/Files.Core/Storage/Windows/WindowsItemIdReader.cs rename to src/Files.Core/Windows/Items/WindowsItemIdReader.cs index fd988ce..84139d5 100644 --- a/src/Files.Core/Storage/Windows/WindowsItemIdReader.cs +++ b/src/Files.Core/Windows/Items/WindowsItemIdReader.cs @@ -1,6 +1,8 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + using System.Collections.Concurrent; using System.IO; using System.Runtime.Versioning; @@ -9,7 +11,7 @@ using Windows.Win32.Storage.FileSystem; using Windows.Win32.System.SystemServices; -namespace Files.Core.Storage.Windows; +namespace Files.Core.Windows; /// /// Uses the filesystem volume and file index when available and otherwise keeps an explicit address fallback. diff --git a/src/Files.Core/Storage/Windows/WindowsItemLocator.cs b/src/Files.Core/Windows/Items/WindowsItemLocator.cs similarity index 91% rename from src/Files.Core/Storage/Windows/WindowsItemLocator.cs rename to src/Files.Core/Windows/Items/WindowsItemLocator.cs index c57d29f..e64b1c3 100644 --- a/src/Files.Core/Storage/Windows/WindowsItemLocator.cs +++ b/src/Files.Core/Windows/Items/WindowsItemLocator.cs @@ -1,7 +1,9 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 -namespace Files.Core.Storage.Windows; +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +namespace Files.Core.Windows; /// /// Contains the Shell identity and optional free-threaded item-store reference needed to materialize a Windows Shell item. diff --git a/src/Files.Core/Storage/Windows/WindowsShellItemArrayFactory.cs b/src/Files.Core/Windows/Items/WindowsShellItemArrayFactory.cs similarity index 92% rename from src/Files.Core/Storage/Windows/WindowsShellItemArrayFactory.cs rename to src/Files.Core/Windows/Items/WindowsShellItemArrayFactory.cs index d29cb20..996f8ce 100644 --- a/src/Files.Core/Storage/Windows/WindowsShellItemArrayFactory.cs +++ b/src/Files.Core/Windows/Items/WindowsShellItemArrayFactory.cs @@ -1,12 +1,14 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + using System.Buffers; using Windows.Win32; using Windows.Win32.UI.Shell; using Windows.Win32.UI.Shell.Common; -namespace Files.Core.Storage.Windows; +namespace Files.Core.Windows; internal static class WindowsShellItemArrayFactory { diff --git a/src/Files.Core/Storage/Windows/WindowsShellItemResolver.cs b/src/Files.Core/Windows/Items/WindowsShellItemResolver.cs similarity index 98% rename from src/Files.Core/Storage/Windows/WindowsShellItemResolver.cs rename to src/Files.Core/Windows/Items/WindowsShellItemResolver.cs index d0f98d7..c356359 100644 --- a/src/Files.Core/Storage/Windows/WindowsShellItemResolver.cs +++ b/src/Files.Core/Windows/Items/WindowsShellItemResolver.cs @@ -1,12 +1,14 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + using Windows.Win32; using Windows.Win32.System.SystemServices; using Windows.Win32.UI.Shell; using Windows.Win32.UI.Shell.Common; -namespace Files.Core.Storage.Windows; +namespace Files.Core.Windows; /// /// Materializes Shell items on the scheduler and never returns a COM object to callers. diff --git a/src/Files.Core/Storage/Windows/WindowsShellItemStore.cs b/src/Files.Core/Windows/Items/WindowsShellItemStore.cs similarity index 81% rename from src/Files.Core/Storage/Windows/WindowsShellItemStore.cs rename to src/Files.Core/Windows/Items/WindowsShellItemStore.cs index ed9a60c..0386062 100644 --- a/src/Files.Core/Storage/Windows/WindowsShellItemStore.cs +++ b/src/Files.Core/Windows/Items/WindowsShellItemStore.cs @@ -1,12 +1,14 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + using Windows.Win32; using Windows.Win32.Foundation; using Windows.Win32.UI.Shell; using Windows.Win32.UI.Shell.Common; -namespace Files.Core.Storage.Windows; +namespace Files.Core.Windows; internal sealed class WindowsShellItemStore { @@ -82,21 +84,3 @@ private WindowsShellItemStore(IDefViewItemStore itemStore) return hr.Succeeded ? item as IShellItem : null; } } - -internal sealed class WindowsShellItemStoreReference -{ - private readonly WindowsShellItemStore _itemStore; - - private readonly ITEMKEY _itemKey; - - internal WindowsShellItemStoreReference(WindowsShellItemStore itemStore, ITEMKEY itemKey) - { - _itemStore = itemStore; - _itemKey = itemKey; - } - - internal IShellItem? TryGetItem(IShellFolder parentFolder) - { - return _itemStore.TryGetItem(in _itemKey, parentFolder); - } -} diff --git a/src/Files.Core/Windows/Items/WindowsShellItemStoreReference.cs b/src/Files.Core/Windows/Items/WindowsShellItemStoreReference.cs new file mode 100644 index 0000000..497ddfa --- /dev/null +++ b/src/Files.Core/Windows/Items/WindowsShellItemStoreReference.cs @@ -0,0 +1,27 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +using Windows.Win32.UI.Shell; +using Windows.Win32.UI.Shell.Common; + +namespace Files.Core.Windows; + +internal sealed class WindowsShellItemStoreReference +{ + private readonly WindowsShellItemStore _itemStore; + + private readonly ITEMKEY _itemKey; + + internal WindowsShellItemStoreReference(WindowsShellItemStore itemStore, ITEMKEY itemKey) + { + _itemStore = itemStore; + _itemKey = itemKey; + } + + internal IShellItem? TryGetItem(IShellFolder parentFolder) + { + return _itemStore.TryGetItem(in _itemKey, parentFolder); + } +} diff --git a/src/Files.Core/Storage/Windows/WindowsStorable.cs b/src/Files.Core/Windows/Items/WindowsStorable.cs similarity index 95% rename from src/Files.Core/Storage/Windows/WindowsStorable.cs rename to src/Files.Core/Windows/Items/WindowsStorable.cs index bbb0420..8641fac 100644 --- a/src/Files.Core/Storage/Windows/WindowsStorable.cs +++ b/src/Files.Core/Windows/Items/WindowsStorable.cs @@ -1,9 +1,12 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +using Files.Core.Storage; using OwlCore.Storage; -namespace Files.Core.Storage.Windows; +namespace Files.Core.Windows; /// /// Represents an apartment-neutral snapshot of a Windows Shell item. diff --git a/src/Files.Core/Storage/Windows/WindowsStorableDescriptor.cs b/src/Files.Core/Windows/Items/WindowsStorableDescriptor.cs similarity index 66% rename from src/Files.Core/Storage/Windows/WindowsStorableDescriptor.cs rename to src/Files.Core/Windows/Items/WindowsStorableDescriptor.cs index 194c60f..423c89d 100644 --- a/src/Files.Core/Storage/Windows/WindowsStorableDescriptor.cs +++ b/src/Files.Core/Windows/Items/WindowsStorableDescriptor.cs @@ -1,13 +1,14 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +using Files.Core.Storage; using OwlCore.Storage; -namespace Files.Core.Storage.Windows; +namespace Files.Core.Windows; /// /// Describes a Shell item without retaining an apartment-bound COM object. /// internal sealed record WindowsStorableDescriptor(string ItemId, StorageAddress Address, WindowsItemLocator Locator, WindowsStorableSnapshot Snapshot); - -internal sealed record WindowsStorableDescriptorData(StorageAddress Address, WindowsItemLocator Locator, WindowsStorableSnapshot Snapshot); diff --git a/src/Files.Core/Windows/Items/WindowsStorableDescriptorData.cs b/src/Files.Core/Windows/Items/WindowsStorableDescriptorData.cs new file mode 100644 index 0000000..07711f5 --- /dev/null +++ b/src/Files.Core/Windows/Items/WindowsStorableDescriptorData.cs @@ -0,0 +1,10 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +using Files.Core.Storage; + +namespace Files.Core.Windows; + +internal sealed record WindowsStorableDescriptorData(StorageAddress Address, WindowsItemLocator Locator, WindowsStorableSnapshot Snapshot); diff --git a/src/Files.Core/Storage/Windows/WindowsStorableFactory.cs b/src/Files.Core/Windows/Items/WindowsStorableFactory.cs similarity index 99% rename from src/Files.Core/Storage/Windows/WindowsStorableFactory.cs rename to src/Files.Core/Windows/Items/WindowsStorableFactory.cs index 1635d86..c8e8a3e 100644 --- a/src/Files.Core/Storage/Windows/WindowsStorableFactory.cs +++ b/src/Files.Core/Windows/Items/WindowsStorableFactory.cs @@ -1,11 +1,14 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + using System.Diagnostics; using System.IO; using System.Runtime.CompilerServices; using System.Threading.Channels; using Files.Core.Diagnostics; +using Files.Core.Storage; using OwlCore.Storage; using Windows.Win32; using Windows.Win32.Foundation; @@ -14,7 +17,7 @@ using Windows.Win32.UI.Shell; using Windows.Win32.UI.Shell.Common; -namespace Files.Core.Storage.Windows; +namespace Files.Core.Windows; /// /// Resolves Shell interfaces on the ordered STA lane and returns managed models or affine wrappers. diff --git a/src/Files.Core/Storage/Windows/WindowsStorableSnapshot.cs b/src/Files.Core/Windows/Items/WindowsStorableSnapshot.cs similarity index 70% rename from src/Files.Core/Storage/Windows/WindowsStorableSnapshot.cs rename to src/Files.Core/Windows/Items/WindowsStorableSnapshot.cs index e47595b..2fd4af9 100644 --- a/src/Files.Core/Storage/Windows/WindowsStorableSnapshot.cs +++ b/src/Files.Core/Windows/Items/WindowsStorableSnapshot.cs @@ -1,7 +1,9 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 -namespace Files.Core.Storage.Windows; +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +namespace Files.Core.Windows; /// /// Contains apartment-neutral identity and display data copied from a Shell item. diff --git a/src/Files.Core/Storage/Windows/WindowsPropertyReader.cs b/src/Files.Core/Windows/Metadata/WindowsPropertyReader.cs similarity index 99% rename from src/Files.Core/Storage/Windows/WindowsPropertyReader.cs rename to src/Files.Core/Windows/Metadata/WindowsPropertyReader.cs index 725eec5..5591716 100644 --- a/src/Files.Core/Storage/Windows/WindowsPropertyReader.cs +++ b/src/Files.Core/Windows/Metadata/WindowsPropertyReader.cs @@ -1,6 +1,8 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + using System.Collections.ObjectModel; using System.Diagnostics; using System.Runtime.InteropServices; @@ -14,7 +16,7 @@ using Windows.Win32.System.Com.StructuredStorage; using Windows.Win32.UI.Shell; -namespace Files.Core.Storage.Windows; +namespace Files.Core.Windows; /// /// Reads Windows Shell properties for filesystem items. diff --git a/src/Files.Core/Storage/Windows/WindowsShellColumn.cs b/src/Files.Core/Windows/Metadata/WindowsShellColumn.cs similarity index 67% rename from src/Files.Core/Storage/Windows/WindowsShellColumn.cs rename to src/Files.Core/Windows/Metadata/WindowsShellColumn.cs index 76a6bb2..0d566e3 100644 --- a/src/Files.Core/Storage/Windows/WindowsShellColumn.cs +++ b/src/Files.Core/Windows/Metadata/WindowsShellColumn.cs @@ -1,40 +1,9 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 -namespace Files.Core.Storage.Windows; +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. -/// -/// Describes the alignment used by a Windows Shell details column. -/// -public enum WindowsShellColumnAlignment -{ - /// Aligns values to the left. - Left, - - /// Aligns values to the right. - Right, - - /// Centers values. - Center, -} - -/// -/// Describes the display type suggested by a Windows Shell column. -/// -public enum WindowsShellColumnType -{ - /// The Shell did not specify a display type. - Default, - - /// The value is displayed as text. - String, - - /// The value is displayed as an integer. - Integer, - - /// The value is displayed as a date and time. - DateTime, -} +namespace Files.Core.Windows; /// /// Describes one column exposed by a Windows Shell folder. @@ -138,32 +107,3 @@ public WindowsShellColumn( PreferVariantCompare = preferVariantCompare; } } - -/// -/// Contains all column metadata returned by one Windows Shell folder. -/// -public sealed class WindowsShellColumnSet -{ - /// Gets all columns exposed by the folder in Shell column order. - public IReadOnlyList All { get; } - - /// Gets the columns marked for the Shell's default Details view. - public IReadOnlyList DefaultVisible { get; } - - /// Gets the default Shell sort column index, or when unavailable. - public int? DefaultSortColumnIndex { get; } - - /// Gets the default Shell display column index, or when unavailable. - public int? DefaultDisplayColumnIndex { get; } - - internal WindowsShellColumnSet(IEnumerable columns, int? defaultSortColumnIndex, int? defaultDisplayColumnIndex) - { - ArgumentNullException.ThrowIfNull(columns); - - var columnArray = columns.ToArray(); - All = Array.AsReadOnly(columnArray); - DefaultVisible = Array.AsReadOnly(columnArray.Where(static column => column.IsVisibleByDefault && !column.IsHidden).ToArray()); - DefaultSortColumnIndex = defaultSortColumnIndex; - DefaultDisplayColumnIndex = defaultDisplayColumnIndex; - } -} diff --git a/src/Files.Core/Windows/Metadata/WindowsShellColumnAlignment.cs b/src/Files.Core/Windows/Metadata/WindowsShellColumnAlignment.cs new file mode 100644 index 0000000..06df753 --- /dev/null +++ b/src/Files.Core/Windows/Metadata/WindowsShellColumnAlignment.cs @@ -0,0 +1,21 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +namespace Files.Core.Windows; + +/// +/// Describes the alignment used by a Windows Shell details column. +/// +public enum WindowsShellColumnAlignment +{ + /// Aligns values to the left. + Left, + + /// Aligns values to the right. + Right, + + /// Centers values. + Center, +} diff --git a/src/Files.Core/Storage/Windows/WindowsShellColumnReader.cs b/src/Files.Core/Windows/Metadata/WindowsShellColumnReader.cs similarity index 99% rename from src/Files.Core/Storage/Windows/WindowsShellColumnReader.cs rename to src/Files.Core/Windows/Metadata/WindowsShellColumnReader.cs index 228cfbb..09c346c 100644 --- a/src/Files.Core/Storage/Windows/WindowsShellColumnReader.cs +++ b/src/Files.Core/Windows/Metadata/WindowsShellColumnReader.cs @@ -1,6 +1,8 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + using System.Collections.Concurrent; using System.Collections.ObjectModel; using System.Runtime.InteropServices; @@ -13,7 +15,7 @@ using Windows.Win32.UI.Shell.Common; using Windows.Win32.UI.Shell.PropertiesSystem; -namespace Files.Core.Storage.Windows; +namespace Files.Core.Windows; internal static unsafe class WindowsShellColumnReader { @@ -802,5 +804,3 @@ private static bool HasColumnState(uint state, CM_STATE flag) return checked((int)index); } } - -internal readonly record struct WindowsShellPropertyDetails(IReadOnlyDictionary RawValues, IReadOnlyDictionary DisplayValues); diff --git a/src/Files.Core/Windows/Metadata/WindowsShellColumnSet.cs b/src/Files.Core/Windows/Metadata/WindowsShellColumnSet.cs new file mode 100644 index 0000000..6de1051 --- /dev/null +++ b/src/Files.Core/Windows/Metadata/WindowsShellColumnSet.cs @@ -0,0 +1,35 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +namespace Files.Core.Windows; + +/// +/// Contains all column metadata returned by one Windows Shell folder. +/// +public sealed class WindowsShellColumnSet +{ + /// Gets all columns exposed by the folder in Shell column order. + public IReadOnlyList All { get; } + + /// Gets the columns marked for the Shell's default Details view. + public IReadOnlyList DefaultVisible { get; } + + /// Gets the default Shell sort column index, or when unavailable. + public int? DefaultSortColumnIndex { get; } + + /// Gets the default Shell display column index, or when unavailable. + public int? DefaultDisplayColumnIndex { get; } + + internal WindowsShellColumnSet(IEnumerable columns, int? defaultSortColumnIndex, int? defaultDisplayColumnIndex) + { + ArgumentNullException.ThrowIfNull(columns); + + var columnArray = columns.ToArray(); + All = Array.AsReadOnly(columnArray); + DefaultVisible = Array.AsReadOnly(columnArray.Where(static column => column.IsVisibleByDefault && !column.IsHidden).ToArray()); + DefaultSortColumnIndex = defaultSortColumnIndex; + DefaultDisplayColumnIndex = defaultDisplayColumnIndex; + } +} diff --git a/src/Files.Core/Windows/Metadata/WindowsShellColumnType.cs b/src/Files.Core/Windows/Metadata/WindowsShellColumnType.cs new file mode 100644 index 0000000..650d090 --- /dev/null +++ b/src/Files.Core/Windows/Metadata/WindowsShellColumnType.cs @@ -0,0 +1,24 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +namespace Files.Core.Windows; + +/// +/// Describes the display type suggested by a Windows Shell column. +/// +public enum WindowsShellColumnType +{ + /// The Shell did not specify a display type. + Default, + + /// The value is displayed as text. + String, + + /// The value is displayed as an integer. + Integer, + + /// The value is displayed as a date and time. + DateTime, +} diff --git a/src/Files.Core/Storage/Windows/WindowsShellItemSorter.cs b/src/Files.Core/Windows/Metadata/WindowsShellItemSorter.cs similarity index 96% rename from src/Files.Core/Storage/Windows/WindowsShellItemSorter.cs rename to src/Files.Core/Windows/Metadata/WindowsShellItemSorter.cs index b3b2420..615483a 100644 --- a/src/Files.Core/Storage/Windows/WindowsShellItemSorter.cs +++ b/src/Files.Core/Windows/Metadata/WindowsShellItemSorter.cs @@ -1,13 +1,15 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + using Files.Core.ViewSettings; using Windows.Win32; using Windows.Win32.Foundation; using Windows.Win32.UI.Shell; using Windows.Win32.UI.Shell.Common; -namespace Files.Core.Storage.Windows; +namespace Files.Core.Windows; internal static unsafe class WindowsShellItemSorter { diff --git a/src/Files.Core/Windows/Metadata/WindowsShellPropertyDetails.cs b/src/Files.Core/Windows/Metadata/WindowsShellPropertyDetails.cs new file mode 100644 index 0000000..3e62e2e --- /dev/null +++ b/src/Files.Core/Windows/Metadata/WindowsShellPropertyDetails.cs @@ -0,0 +1,8 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +namespace Files.Core.Windows; + +internal readonly record struct WindowsShellPropertyDetails(IReadOnlyDictionary RawValues, IReadOnlyDictionary DisplayValues); diff --git a/src/Files.Core/Storage/Windows/WindowsFileOperationProgressSink.cs b/src/Files.Core/Windows/Operations/WindowsFileOperationProgressSink.cs similarity index 98% rename from src/Files.Core/Storage/Windows/WindowsFileOperationProgressSink.cs rename to src/Files.Core/Windows/Operations/WindowsFileOperationProgressSink.cs index 8c04772..1e23782 100644 --- a/src/Files.Core/Storage/Windows/WindowsFileOperationProgressSink.cs +++ b/src/Files.Core/Windows/Operations/WindowsFileOperationProgressSink.cs @@ -1,13 +1,16 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + using System.Diagnostics; using System.Runtime.InteropServices.Marshalling; +using Files.Core.Storage; using Windows.Win32.Foundation; using Windows.Win32.UI.Shell; using Windows.Win32.UI.Shell.PropertiesSystem; -namespace Files.Core.Storage.Windows; +namespace Files.Core.Windows; [GeneratedComClass] internal sealed partial class WindowsFileOperationProgressSink : IFileOperationProgressSink, IOperationsProgressDialog diff --git a/src/Files.Core/Storage/Windows/WindowsStorageOperationErrorClassifier.cs b/src/Files.Core/Windows/Operations/WindowsStorageOperationErrorClassifier.cs similarity index 97% rename from src/Files.Core/Storage/Windows/WindowsStorageOperationErrorClassifier.cs rename to src/Files.Core/Windows/Operations/WindowsStorageOperationErrorClassifier.cs index 8bda5b3..62c61af 100644 --- a/src/Files.Core/Storage/Windows/WindowsStorageOperationErrorClassifier.cs +++ b/src/Files.Core/Windows/Operations/WindowsStorageOperationErrorClassifier.cs @@ -1,10 +1,13 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + using System.IO; +using Files.Core.Storage; using Windows.Win32.Foundation; -namespace Files.Core.Storage.Windows; +namespace Files.Core.Windows; internal static class WindowsStorageOperationErrorClassifier { diff --git a/src/Files.Core/Storage/Windows/WindowsStorageOperationHandler.cs b/src/Files.Core/Windows/Operations/WindowsStorageOperationHandler.cs similarity index 99% rename from src/Files.Core/Storage/Windows/WindowsStorageOperationHandler.cs rename to src/Files.Core/Windows/Operations/WindowsStorageOperationHandler.cs index 8192fb2..f26cd26 100644 --- a/src/Files.Core/Storage/Windows/WindowsStorageOperationHandler.cs +++ b/src/Files.Core/Windows/Operations/WindowsStorageOperationHandler.cs @@ -1,15 +1,18 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + using System.IO; using System.Runtime.InteropServices; using System.Runtime.Versioning; +using Files.Core.Storage; using Windows.Win32; using Windows.Win32.Storage.FileSystem; using Windows.Win32.System.Com; using Windows.Win32.UI.Shell; -namespace Files.Core.Storage.Windows; +namespace Files.Core.Windows; /// /// Executes Windows Shell storage operations. diff --git a/src/Files.Core/Capabilities/Previews/AllowWindowsShellPreviewPolicy.cs b/src/Files.Core/Windows/Previews/AllowWindowsShellPreviewPolicy.cs similarity index 92% rename from src/Files.Core/Capabilities/Previews/AllowWindowsShellPreviewPolicy.cs rename to src/Files.Core/Windows/Previews/AllowWindowsShellPreviewPolicy.cs index 86a212a..265cb7d 100644 --- a/src/Files.Core/Capabilities/Previews/AllowWindowsShellPreviewPolicy.cs +++ b/src/Files.Core/Windows/Previews/AllowWindowsShellPreviewPolicy.cs @@ -1,9 +1,12 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + using Files.Core.Capabilities; +using Files.Core.Capabilities.Previews; -namespace Files.Core.Capabilities.Previews; +namespace Files.Core.Windows; /// /// Allows registered Shell preview handlers. The default activator still uses a local server. diff --git a/src/Files.Core/Windows/Previews/IWindowsPreviewEnterpriseIdResolver.cs b/src/Files.Core/Windows/Previews/IWindowsPreviewEnterpriseIdResolver.cs new file mode 100644 index 0000000..4b993a7 --- /dev/null +++ b/src/Files.Core/Windows/Previews/IWindowsPreviewEnterpriseIdResolver.cs @@ -0,0 +1,13 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +using Files.Core.Capabilities; + +namespace Files.Core.Windows; + +internal interface IWindowsPreviewEnterpriseIdResolver +{ + bool HasEnterpriseId(ItemContext context); +} diff --git a/src/Files.Core/Windows/Previews/IWindowsPreviewFileMetadataResolver.cs b/src/Files.Core/Windows/Previews/IWindowsPreviewFileMetadataResolver.cs new file mode 100644 index 0000000..f75af01 --- /dev/null +++ b/src/Files.Core/Windows/Previews/IWindowsPreviewFileMetadataResolver.cs @@ -0,0 +1,13 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +using Files.Core.Capabilities; + +namespace Files.Core.Windows; + +internal interface IWindowsPreviewFileMetadataResolver +{ + WindowsPreviewFileMetadata? GetMetadata(ItemContext context); +} diff --git a/src/Files.Core/Windows/Previews/IWindowsPreviewHandlerActivationPolicy.cs b/src/Files.Core/Windows/Previews/IWindowsPreviewHandlerActivationPolicy.cs new file mode 100644 index 0000000..367a7e6 --- /dev/null +++ b/src/Files.Core/Windows/Previews/IWindowsPreviewHandlerActivationPolicy.cs @@ -0,0 +1,15 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +namespace Files.Core.Windows; + +/// Chooses the activation context for a preview handler. +public interface IWindowsPreviewHandlerActivationPolicy +{ + /// Gets the activation context for a handler. + /// The preview handler CLSID. + /// The permitted activation context. + WindowsPreviewHandlerActivationContext GetContext(Guid handlerClsid); +} diff --git a/src/Files.Core/Capabilities/Previews/IWindowsPreviewHandlerAssociation.cs b/src/Files.Core/Windows/Previews/IWindowsPreviewHandlerAssociation.cs similarity index 81% rename from src/Files.Core/Capabilities/Previews/IWindowsPreviewHandlerAssociation.cs rename to src/Files.Core/Windows/Previews/IWindowsPreviewHandlerAssociation.cs index ca55555..cd80f10 100644 --- a/src/Files.Core/Capabilities/Previews/IWindowsPreviewHandlerAssociation.cs +++ b/src/Files.Core/Windows/Previews/IWindowsPreviewHandlerAssociation.cs @@ -1,7 +1,9 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 -namespace Files.Core.Capabilities.Previews; +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +namespace Files.Core.Windows; /// Looks up Windows preview handlers by file extension. public interface IWindowsPreviewHandlerAssociation diff --git a/src/Files.Core/Capabilities/Previews/IWindowsPreviewHandlerController.cs b/src/Files.Core/Windows/Previews/IWindowsPreviewHandlerController.cs similarity index 86% rename from src/Files.Core/Capabilities/Previews/IWindowsPreviewHandlerController.cs rename to src/Files.Core/Windows/Previews/IWindowsPreviewHandlerController.cs index be61704..1afbb8f 100644 --- a/src/Files.Core/Capabilities/Previews/IWindowsPreviewHandlerController.cs +++ b/src/Files.Core/Windows/Previews/IWindowsPreviewHandlerController.cs @@ -1,9 +1,11 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + using Windows.Win32.Foundation; -namespace Files.Core.Capabilities.Previews; +namespace Files.Core.Windows; /// Controls the lifetime and rendering surface of a Windows preview handler. public interface IWindowsPreviewHandlerController : IDisposable @@ -63,12 +65,3 @@ void ApplySystemVisuals() /// The focused window handle, or zero when no window has focus. HWND QueryFocus(); } - -/// Creates Windows preview handler controllers. -public interface IWindowsPreviewHandlerControllerFactory -{ - /// Creates a controller for a preview handler CLSID. - /// The preview handler CLSID. - /// The created controller. - IWindowsPreviewHandlerController Create(Guid handlerClsid); -} diff --git a/src/Files.Core/Windows/Previews/IWindowsPreviewHandlerControllerFactory.cs b/src/Files.Core/Windows/Previews/IWindowsPreviewHandlerControllerFactory.cs new file mode 100644 index 0000000..1faba64 --- /dev/null +++ b/src/Files.Core/Windows/Previews/IWindowsPreviewHandlerControllerFactory.cs @@ -0,0 +1,15 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +namespace Files.Core.Windows; + +/// Creates Windows preview handler controllers. +public interface IWindowsPreviewHandlerControllerFactory +{ + /// Creates a controller for a preview handler CLSID. + /// The preview handler CLSID. + /// The created controller. + IWindowsPreviewHandlerController Create(Guid handlerClsid); +} diff --git a/src/Files.Core/Windows/Previews/IWindowsPreviewHandlerIsolationPolicy.cs b/src/Files.Core/Windows/Previews/IWindowsPreviewHandlerIsolationPolicy.cs new file mode 100644 index 0000000..adfdabf --- /dev/null +++ b/src/Files.Core/Windows/Previews/IWindowsPreviewHandlerIsolationPolicy.cs @@ -0,0 +1,11 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +namespace Files.Core.Windows; + +internal interface IWindowsPreviewHandlerIsolationPolicy +{ + bool RequiresLowIntegrity(Guid handlerClsid); +} diff --git a/src/Files.Core/Capabilities/Previews/IWindowsPreviewHandlerRegistrationAllowlist.cs b/src/Files.Core/Windows/Previews/IWindowsPreviewHandlerRegistrationAllowlist.cs similarity index 81% rename from src/Files.Core/Capabilities/Previews/IWindowsPreviewHandlerRegistrationAllowlist.cs rename to src/Files.Core/Windows/Previews/IWindowsPreviewHandlerRegistrationAllowlist.cs index b6613a0..004b7bd 100644 --- a/src/Files.Core/Capabilities/Previews/IWindowsPreviewHandlerRegistrationAllowlist.cs +++ b/src/Files.Core/Windows/Previews/IWindowsPreviewHandlerRegistrationAllowlist.cs @@ -1,7 +1,9 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 -namespace Files.Core.Capabilities.Previews; +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +namespace Files.Core.Windows; /// Determines whether a Windows preview handler is registered for use by the Shell preview host. public interface IWindowsPreviewHandlerRegistrationAllowlist diff --git a/src/Files.Core/Windows/Previews/IWindowsPreviewHandlerRegistrationValidator.cs b/src/Files.Core/Windows/Previews/IWindowsPreviewHandlerRegistrationValidator.cs new file mode 100644 index 0000000..b93c76c --- /dev/null +++ b/src/Files.Core/Windows/Previews/IWindowsPreviewHandlerRegistrationValidator.cs @@ -0,0 +1,13 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +using Files.Core.Capabilities; + +namespace Files.Core.Windows; + +internal interface IWindowsPreviewHandlerRegistrationValidator +{ + bool IsCurrentHandler(ItemContext context, Guid handlerClsid); +} diff --git a/src/Files.Core/Capabilities/Previews/IWindowsPreviewHandlerResolver.cs b/src/Files.Core/Windows/Previews/IWindowsPreviewHandlerResolver.cs similarity index 83% rename from src/Files.Core/Capabilities/Previews/IWindowsPreviewHandlerResolver.cs rename to src/Files.Core/Windows/Previews/IWindowsPreviewHandlerResolver.cs index 517d027..7615733 100644 --- a/src/Files.Core/Capabilities/Previews/IWindowsPreviewHandlerResolver.cs +++ b/src/Files.Core/Windows/Previews/IWindowsPreviewHandlerResolver.cs @@ -1,9 +1,11 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + using Files.Core.Capabilities; -namespace Files.Core.Capabilities.Previews; +namespace Files.Core.Windows; /// Resolves the Windows preview handler registered for an item. public interface IWindowsPreviewHandlerResolver diff --git a/src/Files.Core/Windows/Previews/IWindowsPreviewHandlerTrustResolver.cs b/src/Files.Core/Windows/Previews/IWindowsPreviewHandlerTrustResolver.cs new file mode 100644 index 0000000..ffdf0f1 --- /dev/null +++ b/src/Files.Core/Windows/Previews/IWindowsPreviewHandlerTrustResolver.cs @@ -0,0 +1,11 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +namespace Files.Core.Windows; + +internal interface IWindowsPreviewHandlerTrustResolver +{ + bool AllowsUntrustedPreviews(Guid handlerClsid); +} diff --git a/src/Files.Core/Capabilities/Previews/IWindowsPreviewTargetResolver.cs b/src/Files.Core/Windows/Previews/IWindowsPreviewTargetResolver.cs similarity index 84% rename from src/Files.Core/Capabilities/Previews/IWindowsPreviewTargetResolver.cs rename to src/Files.Core/Windows/Previews/IWindowsPreviewTargetResolver.cs index c265409..788995c 100644 --- a/src/Files.Core/Capabilities/Previews/IWindowsPreviewTargetResolver.cs +++ b/src/Files.Core/Windows/Previews/IWindowsPreviewTargetResolver.cs @@ -1,9 +1,11 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + using Files.Core.Storage; -namespace Files.Core.Capabilities.Previews; +namespace Files.Core.Windows; /// Resolves items to Windows preview targets. public interface IWindowsPreviewTargetResolver diff --git a/src/Files.Core/Windows/Previews/IWindowsPreviewTrustResolver.cs b/src/Files.Core/Windows/Previews/IWindowsPreviewTrustResolver.cs new file mode 100644 index 0000000..19356bf --- /dev/null +++ b/src/Files.Core/Windows/Previews/IWindowsPreviewTrustResolver.cs @@ -0,0 +1,13 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +using Files.Core.Capabilities; + +namespace Files.Core.Windows; + +internal interface IWindowsPreviewTrustResolver +{ + WindowsPreviewTrustResult GetTrust(ItemContext context); +} diff --git a/src/Files.Core/Capabilities/Previews/IWindowsShellPreviewPolicy.cs b/src/Files.Core/Windows/Previews/IWindowsShellPreviewPolicy.cs similarity index 92% rename from src/Files.Core/Capabilities/Previews/IWindowsShellPreviewPolicy.cs rename to src/Files.Core/Windows/Previews/IWindowsShellPreviewPolicy.cs index bee4be5..9f8262b 100644 --- a/src/Files.Core/Capabilities/Previews/IWindowsShellPreviewPolicy.cs +++ b/src/Files.Core/Windows/Previews/IWindowsShellPreviewPolicy.cs @@ -1,9 +1,12 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + using Files.Core.Capabilities; +using Files.Core.Capabilities.Previews; -namespace Files.Core.Capabilities.Previews; +namespace Files.Core.Windows; /// Controls whether Windows Shell preview handlers may run for an item. public interface IWindowsShellPreviewPolicy diff --git a/src/Files.Core/Capabilities/Previews/IWindowsShellPreviewSession.cs b/src/Files.Core/Windows/Previews/IWindowsShellPreviewSession.cs similarity index 92% rename from src/Files.Core/Capabilities/Previews/IWindowsShellPreviewSession.cs rename to src/Files.Core/Windows/Previews/IWindowsShellPreviewSession.cs index 86b9a1d..01238a5 100644 --- a/src/Files.Core/Capabilities/Previews/IWindowsShellPreviewSession.cs +++ b/src/Files.Core/Windows/Previews/IWindowsShellPreviewSession.cs @@ -1,9 +1,11 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + using Windows.Win32.Foundation; -namespace Files.Core.Capabilities.Previews; +namespace Files.Core.Windows; /// Provides asynchronous control over a Windows Shell preview session. public interface IWindowsShellPreviewSession : IAsyncDisposable diff --git a/src/Files.Core/Capabilities/Previews/IWindowsShellPreviewSessionFactory.cs b/src/Files.Core/Windows/Previews/IWindowsShellPreviewSessionFactory.cs similarity index 84% rename from src/Files.Core/Capabilities/Previews/IWindowsShellPreviewSessionFactory.cs rename to src/Files.Core/Windows/Previews/IWindowsShellPreviewSessionFactory.cs index 5fc7a43..1431a32 100644 --- a/src/Files.Core/Capabilities/Previews/IWindowsShellPreviewSessionFactory.cs +++ b/src/Files.Core/Windows/Previews/IWindowsShellPreviewSessionFactory.cs @@ -1,7 +1,9 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 -namespace Files.Core.Capabilities.Previews; +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +namespace Files.Core.Windows; /// Creates Windows Shell preview sessions. public interface IWindowsShellPreviewSessionFactory diff --git a/src/Files.Core/Windows/Previews/LocalServerWindowsPreviewHandlerActivationPolicy.cs b/src/Files.Core/Windows/Previews/LocalServerWindowsPreviewHandlerActivationPolicy.cs new file mode 100644 index 0000000..9edc861 --- /dev/null +++ b/src/Files.Core/Windows/Previews/LocalServerWindowsPreviewHandlerActivationPolicy.cs @@ -0,0 +1,24 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +namespace Files.Core.Windows; + +/// Activates preview handlers through a local server. +public sealed class LocalServerWindowsPreviewHandlerActivationPolicy + : IWindowsPreviewHandlerActivationPolicy +{ + /// Gets the local-server activation context. + /// The preview handler CLSID. + /// A local-server activation context with cloaking enabled. + public WindowsPreviewHandlerActivationContext GetContext(Guid handlerClsid) + { + if (handlerClsid == Guid.Empty) + { + throw new ArgumentException("A preview handler CLSID is required.", nameof(handlerClsid)); + } + + return WindowsPreviewHandlerActivationContext.LocalServer | WindowsPreviewHandlerActivationContext.EnableCloaking; + } +} diff --git a/src/Files.Core/Windows/Previews/WindowsPreviewAcceleratorForwarder.cs b/src/Files.Core/Windows/Previews/WindowsPreviewAcceleratorForwarder.cs new file mode 100644 index 0000000..012675a --- /dev/null +++ b/src/Files.Core/Windows/Previews/WindowsPreviewAcceleratorForwarder.cs @@ -0,0 +1,13 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +using Windows.Win32.UI.WindowsAndMessaging; + +namespace Files.Core.Windows; + +/// Forwards an accelerator message from a Windows preview handler without waiting for UI processing. +/// The native keyboard message. +/// when the message was accepted for asynchronous processing. +public delegate bool WindowsPreviewAcceleratorForwarder(in MSG message); diff --git a/src/Files.Core/Windows/Previews/WindowsPreviewAccessPolicy.cs b/src/Files.Core/Windows/Previews/WindowsPreviewAccessPolicy.cs new file mode 100644 index 0000000..8df4a2f --- /dev/null +++ b/src/Files.Core/Windows/Previews/WindowsPreviewAccessPolicy.cs @@ -0,0 +1,165 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +using System.Buffers.Binary; +using System.IO; +using System.Runtime.InteropServices; +using System.Runtime.Versioning; +using System.Security; +using Files.Core.Capabilities; +using Files.Core.Capabilities.Previews; +using Microsoft.Win32; +using OwlCore.Storage; +using Windows.Win32; +using Windows.Win32.Foundation; +using Windows.Win32.System.Com.Urlmon; +using Windows.Win32.UI.Shell; + +namespace Files.Core.Windows; + +/// Applies Windows file hydration, size, and trust checks before preview content is accessed. +[SupportedOSPlatform("windows")] +public sealed class WindowsPreviewAccessPolicy : IPreviewStreamAccessPolicy, IWindowsShellPreviewPolicy +{ + private const uint FileAttributeOffline = 0x00001000; + private const uint FileAttributeRecallOnOpen = 0x00040000; + private const uint FileAttributeRecallOnDataAccess = 0x00400000; + private const uint HydrationFileAttributes = FileAttributeOffline | FileAttributeRecallOnOpen | FileAttributeRecallOnDataAccess; + + private readonly IWindowsPreviewFileMetadataResolver _metadataResolver; + private readonly IWindowsPreviewTrustResolver _trustResolver; + private readonly IWindowsPreviewHandlerTrustResolver _handlerTrustResolver; + private readonly IWindowsPreviewEnterpriseIdResolver _enterpriseIdResolver; + + /// Initializes a Windows preview access policy using operating-system metadata and trust resolvers. + public WindowsPreviewAccessPolicy() + : this(new WindowsPreviewFileMetadataResolver(), new WindowsPreviewUrlTrustResolver(), new WindowsPreviewHandlerTrustResolver(), new WindowsPreviewEnterpriseIdResolver()) + { + } + + internal WindowsPreviewAccessPolicy( + IWindowsPreviewFileMetadataResolver metadataResolver, + IWindowsPreviewTrustResolver trustResolver, + IWindowsPreviewHandlerTrustResolver handlerTrustResolver, + IWindowsPreviewEnterpriseIdResolver enterpriseIdResolver) + { + ArgumentNullException.ThrowIfNull(metadataResolver); + ArgumentNullException.ThrowIfNull(trustResolver); + ArgumentNullException.ThrowIfNull(handlerTrustResolver); + ArgumentNullException.ThrowIfNull(enterpriseIdResolver); + + _metadataResolver = metadataResolver; + _trustResolver = trustResolver; + _handlerTrustResolver = handlerTrustResolver; + _enterpriseIdResolver = enterpriseIdResolver; + } + + /// Gets a conservative blocking reason without request-specific Windows trust checks. + /// The item context. + /// The preview handler CLSID. + /// for Windows files, or for items outside this Windows-specific policy. + public PreviewBlockReason? GetBlockReason(ItemContext context, Guid handlerClsid) + { + ArgumentNullException.ThrowIfNull(context); + + if (handlerClsid == Guid.Empty) + { + throw new ArgumentException("A preview handler CLSID is required.", nameof(handlerClsid)); + } + + return IsWindowsFile(context) ? PreviewBlockReason.DisabledByPolicy : null; + } + + /// Gets the reason a Windows Shell preview handler is blocked. + /// The preview request. + /// The item context. + /// The preview handler CLSID. + /// The blocking reason, or when the handler is allowed or the item is not Windows-backed. + public PreviewBlockReason? GetBlockReason(PreviewRequest request, ItemContext context, Guid handlerClsid) + { + if (handlerClsid == Guid.Empty) + { + throw new ArgumentException("A preview handler CLSID is required.", nameof(handlerClsid)); + } + + return GetBlockReasonCore(request, context, handlerClsid); + } + + /// Gets the reason a stream preview is blocked for a Windows-backed file. + /// The preview request. + /// The item context. + /// The token used to cancel the operation. + /// The blocking reason, or when access is allowed or the item is not Windows-backed. + public ValueTask GetBlockReasonAsync(PreviewRequest request, ItemContext context, CancellationToken cancellationToken = default) + { + cancellationToken.ThrowIfCancellationRequested(); + + return ValueTask.FromResult(GetBlockReasonCore(request, context, null)); + } + + /// Gets the reason a Windows Shell preview handler is blocked. + /// The preview request. + /// The item context. + /// The preview handler CLSID. + /// The token used to cancel the operation. + /// The blocking reason, or when the handler is allowed or the item is not Windows-backed. + public ValueTask GetBlockReasonAsync(PreviewRequest request, ItemContext context, Guid handlerClsid, CancellationToken cancellationToken = default) + { + cancellationToken.ThrowIfCancellationRequested(); + + return ValueTask.FromResult(GetBlockReason(request, context, handlerClsid)); + } + + private PreviewBlockReason? GetBlockReasonCore(PreviewRequest request, ItemContext context, Guid? handlerClsid) + { + ArgumentNullException.ThrowIfNull(request); + ArgumentNullException.ThrowIfNull(context); + + if (!IsWindowsFile(context)) + { + return null; + } + + var metadata = _metadataResolver.GetMetadata(context); + + if (metadata is null || metadata.Value.Length < 0) + { + return PreviewBlockReason.AccessDenied; + } + + if (request.HydrationPolicy is PreviewHydrationPolicy.LocalOnly && (metadata.Value.Attributes & HydrationFileAttributes) != 0) + { + return PreviewBlockReason.RequiresHydration; + } + + if (request.MaximumBytes is long maximumBytes && metadata.Value.Length > maximumBytes) + { + return PreviewBlockReason.TooLarge; + } + + if (request.TrustAuthorization?.AppliesTo(context) is true) + { + return null; + } + + var bypassUrlPolicy = handlerClsid is Guid clsid && _handlerTrustResolver.AllowsUntrustedPreviews(clsid); + if (!bypassUrlPolicy && _trustResolver.GetTrust(context).Status is not WindowsPreviewTrustStatus.Allowed) + { + return PreviewBlockReason.Untrusted; + } + + if (_enterpriseIdResolver.HasEnterpriseId(context)) + { + return PreviewBlockReason.Untrusted; + } + + return null; + } + + private static bool IsWindowsFile(ItemContext context) + { + return context.CoreModel is IWindowsStorable and IFile; + } +} diff --git a/src/Files.Core/Windows/Previews/WindowsPreviewBounds.cs b/src/Files.Core/Windows/Previews/WindowsPreviewBounds.cs new file mode 100644 index 0000000..7eb9222 --- /dev/null +++ b/src/Files.Core/Windows/Previews/WindowsPreviewBounds.cs @@ -0,0 +1,38 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +namespace Files.Core.Windows; + +/// Describes the bounds of a Windows preview host. +public readonly record struct WindowsPreviewBounds +{ + /// Gets the horizontal position. + public int X { get; } + + /// Gets the vertical position. + public int Y { get; } + + /// Gets the host width. + public int Width { get; } + + /// Gets the host height. + public int Height { get; } + + /// Initializes preview bounds. + /// The horizontal position. + /// The vertical position. + /// The host width. + /// The host height. + public WindowsPreviewBounds(int x, int y, int width, int height) + { + ArgumentOutOfRangeException.ThrowIfNegative(width); + ArgumentOutOfRangeException.ThrowIfNegative(height); + + X = x; + Y = y; + Width = width; + Height = height; + } +} diff --git a/src/Files.Core/Windows/Previews/WindowsPreviewColor.cs b/src/Files.Core/Windows/Previews/WindowsPreviewColor.cs new file mode 100644 index 0000000..6de2440 --- /dev/null +++ b/src/Files.Core/Windows/Previews/WindowsPreviewColor.cs @@ -0,0 +1,12 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +namespace Files.Core.Windows; + +/// Describes an RGB color used by a Windows preview handler. +/// The red component. +/// The green component. +/// The blue component. +public readonly record struct WindowsPreviewColor(byte Red, byte Green, byte Blue); diff --git a/src/Files.Core/Windows/Previews/WindowsPreviewEnterpriseIdResolver.cs b/src/Files.Core/Windows/Previews/WindowsPreviewEnterpriseIdResolver.cs new file mode 100644 index 0000000..7e6cf62 --- /dev/null +++ b/src/Files.Core/Windows/Previews/WindowsPreviewEnterpriseIdResolver.cs @@ -0,0 +1,61 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +using System.IO; +using System.Runtime.InteropServices; +using System.Security; +using Files.Core.Capabilities; +using OwlCore.Storage; +using Windows.Win32; +using Windows.Win32.Foundation; +using Windows.Win32.UI.Shell; + +namespace Files.Core.Windows; + +internal sealed class WindowsPreviewEnterpriseIdResolver : IWindowsPreviewEnterpriseIdResolver +{ + public bool HasEnterpriseId(ItemContext context) + { + ArgumentNullException.ThrowIfNull(context); + + if (context.CoreModel is not IWindowsStorable item || context.CoreModel is not IFile || string.IsNullOrWhiteSpace(item.ParsingName)) + { + return false; + } + + try + { + var hr = PInvoke.SHCreateItemFromParsingName(item.ParsingName, null, out IShellItem shellItem); + if (hr != HRESULT.S_OK || shellItem is not IShellItem2 shellItem2) + { + return false; + } + + return HasEnterpriseId(shellItem2); + } + catch (Exception error) when (error is IOException or UnauthorizedAccessException or COMException or InvalidOperationException or NotSupportedException or SecurityException) + { + return false; + } + } + + private static unsafe bool HasEnterpriseId(IShellItem2 shellItem) + { + var hr = shellItem.GetString(in PInvoke.PKEY_Security_EncryptionOwners, out var enterpriseId); + if (hr.Failed) + { + return false; + } + + try + { + return !string.IsNullOrEmpty(enterpriseId.ToString()); + } + finally + { + PInvoke.CoTaskMemFree(enterpriseId.Value); + } + } +} diff --git a/src/Files.Core/Windows/Previews/WindowsPreviewFileMetadata.cs b/src/Files.Core/Windows/Previews/WindowsPreviewFileMetadata.cs new file mode 100644 index 0000000..51eb54a --- /dev/null +++ b/src/Files.Core/Windows/Previews/WindowsPreviewFileMetadata.cs @@ -0,0 +1,8 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +namespace Files.Core.Windows; + +internal readonly record struct WindowsPreviewFileMetadata(uint Attributes, long Length); diff --git a/src/Files.Core/Windows/Previews/WindowsPreviewFileMetadataResolver.cs b/src/Files.Core/Windows/Previews/WindowsPreviewFileMetadataResolver.cs new file mode 100644 index 0000000..9985510 --- /dev/null +++ b/src/Files.Core/Windows/Previews/WindowsPreviewFileMetadataResolver.cs @@ -0,0 +1,48 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +using System.IO; +using System.Security; +using Files.Core.Capabilities; +using OwlCore.Storage; +using Windows.Win32; + +namespace Files.Core.Windows; + +internal sealed class WindowsPreviewFileMetadataResolver : IWindowsPreviewFileMetadataResolver +{ + private const uint FileAttributeDirectory = 0x00000010; + public WindowsPreviewFileMetadata? GetMetadata(ItemContext context) + { + ArgumentNullException.ThrowIfNull(context); + + if (context.CoreModel is not IWindowsStorable item || context.CoreModel is not IFile || string.IsNullOrWhiteSpace(item.FileSystemPath) || !Path.IsPathFullyQualified(item.FileSystemPath)) + { + return null; + } + + try + { + var attributes = PInvoke.GetFileAttributes(item.FileSystemPath); + if (attributes == PInvoke.INVALID_FILE_ATTRIBUTES || (attributes & FileAttributeDirectory) != 0) + { + return null; + } + + var fileInfo = new FileInfo(item.FileSystemPath); + fileInfo.Refresh(); + if (!fileInfo.Exists) + { + return null; + } + + return new WindowsPreviewFileMetadata(attributes, fileInfo.Length); + } + catch (Exception error) when (error is IOException or UnauthorizedAccessException or ArgumentException or SecurityException or NotSupportedException) + { + return null; + } + } +} diff --git a/src/Files.Core/Windows/Previews/WindowsPreviewHandlerActivationContext.cs b/src/Files.Core/Windows/Previews/WindowsPreviewHandlerActivationContext.cs new file mode 100644 index 0000000..eb9dc3e --- /dev/null +++ b/src/Files.Core/Windows/Previews/WindowsPreviewHandlerActivationContext.cs @@ -0,0 +1,18 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +namespace Files.Core.Windows; + +/// Specifies the process context allowed for preview handler activation. +[Flags] +public enum WindowsPreviewHandlerActivationContext : uint +{ + /// Activate an in-process preview handler. + InProcessServer = 0x1, + /// Activate a local-server preview handler. + LocalServer = 0x4, + /// Use the caller's impersonation token when activating the local server. + EnableCloaking = 0x100000, +} diff --git a/src/Files.Core/Windows/Previews/WindowsPreviewHandlerAssociationQuery.cs b/src/Files.Core/Windows/Previews/WindowsPreviewHandlerAssociationQuery.cs new file mode 100644 index 0000000..f5c3145 --- /dev/null +++ b/src/Files.Core/Windows/Previews/WindowsPreviewHandlerAssociationQuery.cs @@ -0,0 +1,10 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +using Windows.Win32.Foundation; + +namespace Files.Core.Windows; + +internal delegate HRESULT WindowsPreviewHandlerAssociationQuery(string normalizedExtension, Span buffer, ref uint characterCount); diff --git a/src/Files.Core/Capabilities/Previews/WindowsPreviewHandlerFrame.cs b/src/Files.Core/Windows/Previews/WindowsPreviewHandlerFrame.cs similarity index 96% rename from src/Files.Core/Capabilities/Previews/WindowsPreviewHandlerFrame.cs rename to src/Files.Core/Windows/Previews/WindowsPreviewHandlerFrame.cs index 55804e9..4d92082 100644 --- a/src/Files.Core/Capabilities/Previews/WindowsPreviewHandlerFrame.cs +++ b/src/Files.Core/Windows/Previews/WindowsPreviewHandlerFrame.cs @@ -1,13 +1,15 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + using System.Runtime.InteropServices.Marshalling; using Windows.Win32; using Windows.Win32.Foundation; using Windows.Win32.UI.Shell; using Windows.Win32.UI.WindowsAndMessaging; -namespace Files.Core.Capabilities.Previews; +namespace Files.Core.Windows; /// /// Minimal in-process COM site exposed to a preview handler. diff --git a/src/Files.Core/Windows/Previews/WindowsPreviewHandlerIsolationPolicy.cs b/src/Files.Core/Windows/Previews/WindowsPreviewHandlerIsolationPolicy.cs new file mode 100644 index 0000000..57cae92 --- /dev/null +++ b/src/Files.Core/Windows/Previews/WindowsPreviewHandlerIsolationPolicy.cs @@ -0,0 +1,72 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +using System.Buffers.Binary; +using System.IO; +using System.Security; +using Microsoft.Win32; + +namespace Files.Core.Windows; + +internal sealed class WindowsPreviewHandlerIsolationPolicy : IWindowsPreviewHandlerIsolationPolicy +{ + private const string DisableLowIntegrityValue = "DisableLowILProcessIsolation"; + + public bool RequiresLowIntegrity(Guid handlerClsid) + { + var keyPath = $"Software\\Classes\\CLSID\\{handlerClsid:B}"; + if (TryReadOptOut(RegistryView.Registry64, keyPath, out var disabled) || TryReadOptOut(RegistryView.Registry32, keyPath, out disabled)) + { + return !disabled; + } + + return true; + } + + internal static bool IsLowIntegrityDisabled(object? value, RegistryValueKind valueKind) + { + if (valueKind is RegistryValueKind.DWord && value is int numericValue) + { + return numericValue is not 0; + } + + return valueKind is RegistryValueKind.Binary && value is byte[] { Length: sizeof(uint) } bytes && BinaryPrimitives.ReadUInt32LittleEndian(bytes) is not 0; + } + + private static bool TryReadOptOut(RegistryView view, string keyPath, out bool disabled) + { + disabled = false; + RegistryKey? key; + try + { + using var localMachine = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, view); + key = localMachine.OpenSubKey(keyPath, writable: false); + } + catch (Exception error) when (error is IOException or UnauthorizedAccessException or SecurityException or ArgumentException) + { + return false; + } + + if (key is null) + { + return false; + } + + using (key) + { + try + { + var value = key.GetValue(DisableLowIntegrityValue); + disabled = value is not null && IsLowIntegrityDisabled(value, key.GetValueKind(DisableLowIntegrityValue)); + } + catch (Exception error) when (error is IOException or UnauthorizedAccessException or SecurityException or ArgumentException) + { + disabled = false; + } + } + + return true; + } +} diff --git a/src/Files.Core/Capabilities/Previews/WindowsPreviewHandlerRegistrationAllowlist.cs b/src/Files.Core/Windows/Previews/WindowsPreviewHandlerRegistrationAllowlist.cs similarity index 94% rename from src/Files.Core/Capabilities/Previews/WindowsPreviewHandlerRegistrationAllowlist.cs rename to src/Files.Core/Windows/Previews/WindowsPreviewHandlerRegistrationAllowlist.cs index d5f0772..a927c4d 100644 --- a/src/Files.Core/Capabilities/Previews/WindowsPreviewHandlerRegistrationAllowlist.cs +++ b/src/Files.Core/Windows/Previews/WindowsPreviewHandlerRegistrationAllowlist.cs @@ -1,12 +1,14 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + using System.IO; using System.Runtime.Versioning; using System.Security; using Microsoft.Win32; -namespace Files.Core.Capabilities.Previews; +namespace Files.Core.Windows; /// Checks the per-user and machine-wide Windows Shell preview handler registrations. [SupportedOSPlatform("windows")] diff --git a/src/Files.Core/Capabilities/Previews/WindowsPreviewHandlerRegistrationValidator.cs b/src/Files.Core/Windows/Previews/WindowsPreviewHandlerRegistrationValidator.cs similarity index 89% rename from src/Files.Core/Capabilities/Previews/WindowsPreviewHandlerRegistrationValidator.cs rename to src/Files.Core/Windows/Previews/WindowsPreviewHandlerRegistrationValidator.cs index 970aeca..0bbfe35 100644 --- a/src/Files.Core/Capabilities/Previews/WindowsPreviewHandlerRegistrationValidator.cs +++ b/src/Files.Core/Windows/Previews/WindowsPreviewHandlerRegistrationValidator.cs @@ -1,15 +1,12 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + using System.Runtime.Versioning; using Files.Core.Capabilities; -namespace Files.Core.Capabilities.Previews; - -internal interface IWindowsPreviewHandlerRegistrationValidator -{ - bool IsCurrentHandler(ItemContext context, Guid handlerClsid); -} +namespace Files.Core.Windows; [SupportedOSPlatform("windows5.0")] internal sealed class WindowsPreviewHandlerRegistrationValidator : IWindowsPreviewHandlerRegistrationValidator diff --git a/src/Files.Core/Capabilities/Previews/WindowsPreviewHandlerResolver.cs b/src/Files.Core/Windows/Previews/WindowsPreviewHandlerResolver.cs similarity index 97% rename from src/Files.Core/Capabilities/Previews/WindowsPreviewHandlerResolver.cs rename to src/Files.Core/Windows/Previews/WindowsPreviewHandlerResolver.cs index ec1075e..16ee65b 100644 --- a/src/Files.Core/Capabilities/Previews/WindowsPreviewHandlerResolver.cs +++ b/src/Files.Core/Windows/Previews/WindowsPreviewHandlerResolver.cs @@ -1,13 +1,14 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + using System.IO; using System.Runtime.Versioning; using Files.Core.Capabilities; -using Files.Core.Storage.Windows; using OwlCore.Storage; -namespace Files.Core.Capabilities.Previews; +namespace Files.Core.Windows; /// Resolves and caches Windows Shell preview handler registrations. public sealed class WindowsPreviewHandlerResolver : IWindowsPreviewHandlerResolver diff --git a/src/Files.Core/Windows/Previews/WindowsPreviewHandlerTrustResolver.cs b/src/Files.Core/Windows/Previews/WindowsPreviewHandlerTrustResolver.cs new file mode 100644 index 0000000..55d8063 --- /dev/null +++ b/src/Files.Core/Windows/Previews/WindowsPreviewHandlerTrustResolver.cs @@ -0,0 +1,29 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +using System.IO; +using System.Security; +using Microsoft.Win32; + +namespace Files.Core.Windows; + +internal sealed class WindowsPreviewHandlerTrustResolver : IWindowsPreviewHandlerTrustResolver +{ + private const string AutomaticallyPreviewUntrustedFilesValue = "AutomaticallyPreviewUntrustedFiles"; + + public bool AllowsUntrustedPreviews(Guid handlerClsid) + { + try + { + using var key = Registry.ClassesRoot.OpenSubKey($"CLSID\\{handlerClsid:B}", writable: false); + + return key?.GetValue(AutomaticallyPreviewUntrustedFilesValue) is int value && value == 1; + } + catch (Exception error) when (error is IOException or UnauthorizedAccessException or SecurityException) + { + return false; + } + } +} diff --git a/src/Files.Core/Capabilities/Previews/WindowsPreviewHost.cs b/src/Files.Core/Windows/Previews/WindowsPreviewHost.cs similarity index 50% rename from src/Files.Core/Capabilities/Previews/WindowsPreviewHost.cs rename to src/Files.Core/Windows/Previews/WindowsPreviewHost.cs index 397e488..76a6b18 100644 --- a/src/Files.Core/Capabilities/Previews/WindowsPreviewHost.cs +++ b/src/Files.Core/Windows/Previews/WindowsPreviewHost.cs @@ -1,54 +1,12 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + using Windows.Win32; using Windows.Win32.Foundation; -using Windows.Win32.UI.WindowsAndMessaging; - -namespace Files.Core.Capabilities.Previews; - -/// Describes the bounds of a Windows preview host. -public readonly record struct WindowsPreviewBounds -{ - /// Gets the horizontal position. - public int X { get; } - - /// Gets the vertical position. - public int Y { get; } - - /// Gets the host width. - public int Width { get; } - - /// Gets the host height. - public int Height { get; } - - /// Initializes preview bounds. - /// The horizontal position. - /// The vertical position. - /// The host width. - /// The host height. - public WindowsPreviewBounds(int x, int y, int width, int height) - { - ArgumentOutOfRangeException.ThrowIfNegative(width); - ArgumentOutOfRangeException.ThrowIfNegative(height); - - X = x; - Y = y; - Width = width; - Height = height; - } -} - -/// Describes an RGB color used by a Windows preview handler. -/// The red component. -/// The green component. -/// The blue component. -public readonly record struct WindowsPreviewColor(byte Red, byte Green, byte Blue); -/// Forwards an accelerator message from a Windows preview handler without waiting for UI processing. -/// The native keyboard message. -/// when the message was accepted for asynchronous processing. -public delegate bool WindowsPreviewAcceleratorForwarder(in MSG message); +namespace Files.Core.Windows; /// Identifies the native window that hosts a preview handler. public sealed record WindowsPreviewHost diff --git a/src/Files.Core/Capabilities/Previews/WindowsPreviewTarget.cs b/src/Files.Core/Windows/Previews/WindowsPreviewTarget.cs similarity index 95% rename from src/Files.Core/Capabilities/Previews/WindowsPreviewTarget.cs rename to src/Files.Core/Windows/Previews/WindowsPreviewTarget.cs index f4241ab..c7133ea 100644 --- a/src/Files.Core/Capabilities/Previews/WindowsPreviewTarget.cs +++ b/src/Files.Core/Windows/Previews/WindowsPreviewTarget.cs @@ -1,13 +1,14 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + using System.IO; using Files.Core.Capabilities; using Files.Core.Models; using Files.Core.Storage; -using Files.Core.Storage.Windows; -namespace Files.Core.Capabilities.Previews; +namespace Files.Core.Windows; /// Owns a model and its Windows Shell item for preview operations. public sealed class WindowsPreviewTarget : IDisposable, IAsyncDisposable diff --git a/src/Files.Core/Capabilities/Previews/WindowsPreviewTargetResolver.cs b/src/Files.Core/Windows/Previews/WindowsPreviewTargetResolver.cs similarity index 92% rename from src/Files.Core/Capabilities/Previews/WindowsPreviewTargetResolver.cs rename to src/Files.Core/Windows/Previews/WindowsPreviewTargetResolver.cs index 841e2c1..1e7765a 100644 --- a/src/Files.Core/Capabilities/Previews/WindowsPreviewTargetResolver.cs +++ b/src/Files.Core/Windows/Previews/WindowsPreviewTargetResolver.cs @@ -1,14 +1,16 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + using System.IO; using Files.Core.Data; using Files.Core.Models; using Files.Core.Storage; -using Files.Core.Storage.Windows; +using Files.Core.Capabilities; using OwlCore.Storage; -namespace Files.Core.Capabilities.Previews; +namespace Files.Core.Windows; /// Resolves Files item references to owned Windows Shell preview targets. public sealed class WindowsPreviewTargetResolver : IWindowsPreviewTargetResolver diff --git a/src/Files.Core/Windows/Previews/WindowsPreviewTrustResult.cs b/src/Files.Core/Windows/Previews/WindowsPreviewTrustResult.cs new file mode 100644 index 0000000..5149f2f --- /dev/null +++ b/src/Files.Core/Windows/Previews/WindowsPreviewTrustResult.cs @@ -0,0 +1,8 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +namespace Files.Core.Windows; + +internal readonly record struct WindowsPreviewTrustResult(WindowsPreviewTrustStatus Status); diff --git a/src/Files.Core/Windows/Previews/WindowsPreviewTrustStatus.cs b/src/Files.Core/Windows/Previews/WindowsPreviewTrustStatus.cs new file mode 100644 index 0000000..def130f --- /dev/null +++ b/src/Files.Core/Windows/Previews/WindowsPreviewTrustStatus.cs @@ -0,0 +1,13 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +namespace Files.Core.Windows; + +internal enum WindowsPreviewTrustStatus +{ + Allowed, + Blocked, + Indeterminate, +} diff --git a/src/Files.Core/Windows/Previews/WindowsPreviewUrlTrustResolver.cs b/src/Files.Core/Windows/Previews/WindowsPreviewUrlTrustResolver.cs new file mode 100644 index 0000000..60746a7 --- /dev/null +++ b/src/Files.Core/Windows/Previews/WindowsPreviewUrlTrustResolver.cs @@ -0,0 +1,137 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +using System.Buffers.Binary; +using System.IO; +using System.Runtime.InteropServices; +using System.Security; +using Files.Core.Capabilities; +using OwlCore.Storage; +using Windows.Win32; +using Windows.Win32.Foundation; +using Windows.Win32.System.Com.Urlmon; +using Windows.Win32.UI.Shell; + +namespace Files.Core.Windows; + +internal sealed class WindowsPreviewUrlTrustResolver : IWindowsPreviewTrustResolver +{ + private const int FileNotFoundHResult = unchecked((int)0x80070002); + private const uint InternetZone = 3; + + public WindowsPreviewTrustResult GetTrust(ItemContext context) + { + ArgumentNullException.ThrowIfNull(context); + + if (context.CoreModel is not IWindowsStorable item || context.CoreModel is not IFile || string.IsNullOrWhiteSpace(item.ParsingName)) + { + return new WindowsPreviewTrustResult(WindowsPreviewTrustStatus.Indeterminate); + } + + try + { + var hr = PInvoke.SHCreateItemFromParsingName(item.ParsingName, null, out IShellItem shellItem); + if (hr != HRESULT.S_OK) + { + return new WindowsPreviewTrustResult(WindowsPreviewTrustStatus.Indeterminate); + } + + var url = ShellItemHelpers.TryGetDisplayName(shellItem, SIGDN.SIGDN_URL); + + return url is null ? new WindowsPreviewTrustResult(WindowsPreviewTrustStatus.Indeterminate) : EvaluateUrlPolicy(url, item.FileSystemPath); + } + catch (Exception error) when (error is IOException or UnauthorizedAccessException or COMException or InvalidOperationException or NotSupportedException or SecurityException) + { + return new WindowsPreviewTrustResult(WindowsPreviewTrustStatus.Indeterminate); + } + } + + private static WindowsPreviewTrustResult EvaluateUrlPolicy(string url, string? fileSystemPath) + { + try + { + var zoneCheckHr = PInvoke.ZoneCheckUrlExCache(url, out var zonePolicy, sizeof(uint), 0, 0, PInvoke.URLACTION_SHELL_PREVIEW, (uint)PUAF.PUAF_NOUI, null, 0); + + return InterpretZoneCheckPolicy(zoneCheckHr, zonePolicy); + } + catch (EntryPointNotFoundException) + { + } + catch (DllNotFoundException) + { + } + + if (!string.IsNullOrWhiteSpace(fileSystemPath)) + { + try + { + var alternateDataStreamHr = PInvoke.GetZoneFromAlternateDataStreamEx(fileSystemPath, out var alternateDataStreamZone); + if (alternateDataStreamHr == HRESULT.S_OK && alternateDataStreamZone >= InternetZone) + { + return new WindowsPreviewTrustResult(WindowsPreviewTrustStatus.Blocked); + } + + if (alternateDataStreamHr != HRESULT.S_OK && alternateDataStreamHr.Value != FileNotFoundHResult) + { + return new WindowsPreviewTrustResult(WindowsPreviewTrustStatus.Indeterminate); + } + } + catch (EntryPointNotFoundException) + { + } + catch (DllNotFoundException) + { + } + } + + if (PInvoke.CoInternetCreateSecurityManager(null!, out var securityManager, 0) != HRESULT.S_OK) + { + return new WindowsPreviewTrustResult(WindowsPreviewTrustStatus.Indeterminate); + } + + var policy = new byte[sizeof(uint)]; + byte context = 0; + var hr = securityManager.ProcessUrlAction(url, PInvoke.URLACTION_SHELL_PREVIEW, policy, in context, 0, (uint)PUAF.PUAF_NOUI, 0); + + return InterpretUrlPolicy(hr, policy); + } + + internal static WindowsPreviewTrustResult InterpretUrlPolicy(HRESULT hr, ReadOnlySpan policy) + { + if (hr != HRESULT.S_OK || policy.Length < sizeof(uint)) + { + return new WindowsPreviewTrustResult(WindowsPreviewTrustStatus.Indeterminate); + } + + return InterpretUrlPolicy(hr, BinaryPrimitives.ReadUInt32LittleEndian(policy)); + } + + internal static WindowsPreviewTrustResult InterpretZoneCheckPolicy(HRESULT hr, uint policy) + { + if (hr.Failed) + { + return new WindowsPreviewTrustResult(WindowsPreviewTrustStatus.Indeterminate); + } + + return new WindowsPreviewTrustResult(policy == PInvoke.URLPOLICY_ALLOW ? WindowsPreviewTrustStatus.Allowed : WindowsPreviewTrustStatus.Blocked); + } + + internal static WindowsPreviewTrustResult InterpretUrlPolicy(HRESULT hr, uint policy) + { + if (hr != HRESULT.S_OK) + { + return new WindowsPreviewTrustResult(WindowsPreviewTrustStatus.Indeterminate); + } + + return InterpretPolicy(policy); + } + + private static WindowsPreviewTrustResult InterpretPolicy(uint policy) + { + var permissions = policy & PInvoke.URLPOLICY_MASK_PERMISSIONS; + + return new WindowsPreviewTrustResult(permissions == PInvoke.URLPOLICY_ALLOW ? WindowsPreviewTrustStatus.Allowed : WindowsPreviewTrustStatus.Blocked); + } +} diff --git a/src/Files.Core/Capabilities/Previews/WindowsShellPreviewBlockedException.cs b/src/Files.Core/Windows/Previews/WindowsShellPreviewBlockedException.cs similarity index 84% rename from src/Files.Core/Capabilities/Previews/WindowsShellPreviewBlockedException.cs rename to src/Files.Core/Windows/Previews/WindowsShellPreviewBlockedException.cs index a8391de..2d8109a 100644 --- a/src/Files.Core/Capabilities/Previews/WindowsShellPreviewBlockedException.cs +++ b/src/Files.Core/Windows/Previews/WindowsShellPreviewBlockedException.cs @@ -1,7 +1,11 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 -namespace Files.Core.Capabilities.Previews; +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +using Files.Core.Capabilities.Previews; + +namespace Files.Core.Windows; /// Indicates that a Shell preview became unsafe before handler activation. public sealed class WindowsShellPreviewBlockedException : InvalidOperationException diff --git a/src/Files.Core/Capabilities/Previews/WindowsShellPreviewHandlerAssociation.cs b/src/Files.Core/Windows/Previews/WindowsShellPreviewHandlerAssociation.cs similarity index 92% rename from src/Files.Core/Capabilities/Previews/WindowsShellPreviewHandlerAssociation.cs rename to src/Files.Core/Windows/Previews/WindowsShellPreviewHandlerAssociation.cs index 4c09ada..4f1b624 100644 --- a/src/Files.Core/Capabilities/Previews/WindowsShellPreviewHandlerAssociation.cs +++ b/src/Files.Core/Windows/Previews/WindowsShellPreviewHandlerAssociation.cs @@ -1,14 +1,14 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + using System.Runtime.Versioning; using Windows.Win32; using Windows.Win32.Foundation; using Windows.Win32.UI.Shell; -namespace Files.Core.Capabilities.Previews; - -internal delegate HRESULT WindowsPreviewHandlerAssociationQuery(string normalizedExtension, Span buffer, ref uint characterCount); +namespace Files.Core.Windows; /// Reads Windows Shell preview handler associations. [SupportedOSPlatform("windows5.0")] diff --git a/src/Files.Core/Capabilities/Previews/WindowsShellPreviewHandlerController.cs b/src/Files.Core/Windows/Previews/WindowsShellPreviewHandlerController.cs similarity index 72% rename from src/Files.Core/Capabilities/Previews/WindowsShellPreviewHandlerController.cs rename to src/Files.Core/Windows/Previews/WindowsShellPreviewHandlerController.cs index 2e2fe38..3df7824 100644 --- a/src/Files.Core/Capabilities/Previews/WindowsShellPreviewHandlerController.cs +++ b/src/Files.Core/Windows/Previews/WindowsShellPreviewHandlerController.cs @@ -1,15 +1,13 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 -using System.Buffers.Binary; +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + using System.ComponentModel; using System.Diagnostics.CodeAnalysis; -using System.IO; using System.Runtime.ExceptionServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; -using System.Security; -using Microsoft.Win32; using Windows.Win32; using Windows.Win32.Foundation; using Windows.Win32.Graphics.Gdi; @@ -20,126 +18,7 @@ using Windows.Win32.UI.Shell.PropertiesSystem; using Windows.Win32.UI.WindowsAndMessaging; -namespace Files.Core.Capabilities.Previews; - -/// Creates controllers for Windows Shell preview handlers. -[SupportedOSPlatform("windows6.0.6000")] -public sealed class WindowsShellPreviewHandlerControllerFactory : IWindowsPreviewHandlerControllerFactory -{ - private readonly IWindowsPreviewHandlerActivationPolicy _activationPolicy; - private readonly IWindowsPreviewHandlerIsolationPolicy _isolationPolicy; - - /// Initializes a controller factory with the local-server policy. - public WindowsShellPreviewHandlerControllerFactory() - : this(new LocalServerWindowsPreviewHandlerActivationPolicy(), new WindowsPreviewHandlerIsolationPolicy()) - { - } - - /// Initializes a controller factory. - /// The activation policy. - public WindowsShellPreviewHandlerControllerFactory(IWindowsPreviewHandlerActivationPolicy activationPolicy) - : this(activationPolicy, new WindowsPreviewHandlerIsolationPolicy()) - { - } - - internal WindowsShellPreviewHandlerControllerFactory(IWindowsPreviewHandlerActivationPolicy activationPolicy, IWindowsPreviewHandlerIsolationPolicy isolationPolicy) - { - ArgumentNullException.ThrowIfNull(activationPolicy); - ArgumentNullException.ThrowIfNull(isolationPolicy); - - _activationPolicy = activationPolicy; - _isolationPolicy = isolationPolicy; - } - - /// Creates a controller for a preview handler CLSID. - /// The preview handler CLSID. - /// The created controller. - public IWindowsPreviewHandlerController Create(Guid handlerClsid) - { - if (handlerClsid == Guid.Empty) - { - throw new ArgumentException("A preview handler CLSID is required.", nameof(handlerClsid)); - } - - var activationContext = _activationPolicy.GetContext(handlerClsid); - var requiredContext = WindowsPreviewHandlerActivationContext.LocalServer | WindowsPreviewHandlerActivationContext.EnableCloaking; - if (activationContext != requiredContext) - { - throw new InvalidOperationException("Preview handlers must be activated through a cloaked local server."); - } - - var useLowIntegrity = _isolationPolicy.RequiresLowIntegrity(handlerClsid); - var nativeContext = useLowIntegrity ? activationContext : WindowsPreviewHandlerActivationContext.LocalServer; - - return WindowsShellPreviewHandlerController.Create(handlerClsid, (uint)nativeContext, useLowIntegrity); - } -} - -internal interface IWindowsPreviewHandlerIsolationPolicy -{ - bool RequiresLowIntegrity(Guid handlerClsid); -} - -internal sealed class WindowsPreviewHandlerIsolationPolicy : IWindowsPreviewHandlerIsolationPolicy -{ - private const string DisableLowIntegrityValue = "DisableLowILProcessIsolation"; - - public bool RequiresLowIntegrity(Guid handlerClsid) - { - var keyPath = $"Software\\Classes\\CLSID\\{handlerClsid:B}"; - if (TryReadOptOut(RegistryView.Registry64, keyPath, out var disabled) || TryReadOptOut(RegistryView.Registry32, keyPath, out disabled)) - { - return !disabled; - } - - return true; - } - - internal static bool IsLowIntegrityDisabled(object? value, RegistryValueKind valueKind) - { - if (valueKind is RegistryValueKind.DWord && value is int numericValue) - { - return numericValue is not 0; - } - - return valueKind is RegistryValueKind.Binary && value is byte[] { Length: sizeof(uint) } bytes && BinaryPrimitives.ReadUInt32LittleEndian(bytes) is not 0; - } - - private static bool TryReadOptOut(RegistryView view, string keyPath, out bool disabled) - { - disabled = false; - RegistryKey? key; - try - { - using var localMachine = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, view); - key = localMachine.OpenSubKey(keyPath, writable: false); - } - catch (Exception error) when (error is IOException or UnauthorizedAccessException or SecurityException or ArgumentException) - { - return false; - } - - if (key is null) - { - return false; - } - - using (key) - { - try - { - var value = key.GetValue(DisableLowIntegrityValue); - disabled = value is not null && IsLowIntegrityDisabled(value, key.GetValueKind(DisableLowIntegrityValue)); - } - catch (Exception error) when (error is IOException or UnauthorizedAccessException or SecurityException or ArgumentException) - { - disabled = false; - } - } - - return true; - } -} +namespace Files.Core.Windows; [SupportedOSPlatform("windows6.0.6000")] internal sealed class WindowsShellPreviewHandlerController : IWindowsPreviewHandlerController diff --git a/src/Files.Core/Windows/Previews/WindowsShellPreviewHandlerControllerFactory.cs b/src/Files.Core/Windows/Previews/WindowsShellPreviewHandlerControllerFactory.cs new file mode 100644 index 0000000..6e0255d --- /dev/null +++ b/src/Files.Core/Windows/Previews/WindowsShellPreviewHandlerControllerFactory.cs @@ -0,0 +1,61 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +using System.Runtime.Versioning; + +namespace Files.Core.Windows; + +/// Creates controllers for Windows Shell preview handlers. +[SupportedOSPlatform("windows6.0.6000")] +public sealed class WindowsShellPreviewHandlerControllerFactory : IWindowsPreviewHandlerControllerFactory +{ + private readonly IWindowsPreviewHandlerActivationPolicy _activationPolicy; + private readonly IWindowsPreviewHandlerIsolationPolicy _isolationPolicy; + + /// Initializes a controller factory with the local-server policy. + public WindowsShellPreviewHandlerControllerFactory() + : this(new LocalServerWindowsPreviewHandlerActivationPolicy(), new WindowsPreviewHandlerIsolationPolicy()) + { + } + + /// Initializes a controller factory. + /// The activation policy. + public WindowsShellPreviewHandlerControllerFactory(IWindowsPreviewHandlerActivationPolicy activationPolicy) + : this(activationPolicy, new WindowsPreviewHandlerIsolationPolicy()) + { + } + + internal WindowsShellPreviewHandlerControllerFactory(IWindowsPreviewHandlerActivationPolicy activationPolicy, IWindowsPreviewHandlerIsolationPolicy isolationPolicy) + { + ArgumentNullException.ThrowIfNull(activationPolicy); + ArgumentNullException.ThrowIfNull(isolationPolicy); + + _activationPolicy = activationPolicy; + _isolationPolicy = isolationPolicy; + } + + /// Creates a controller for a preview handler CLSID. + /// The preview handler CLSID. + /// The created controller. + public IWindowsPreviewHandlerController Create(Guid handlerClsid) + { + if (handlerClsid == Guid.Empty) + { + throw new ArgumentException("A preview handler CLSID is required.", nameof(handlerClsid)); + } + + var activationContext = _activationPolicy.GetContext(handlerClsid); + var requiredContext = WindowsPreviewHandlerActivationContext.LocalServer | WindowsPreviewHandlerActivationContext.EnableCloaking; + if (activationContext != requiredContext) + { + throw new InvalidOperationException("Preview handlers must be activated through a cloaked local server."); + } + + var useLowIntegrity = _isolationPolicy.RequiresLowIntegrity(handlerClsid); + var nativeContext = useLowIntegrity ? activationContext : WindowsPreviewHandlerActivationContext.LocalServer; + + return WindowsShellPreviewHandlerController.Create(handlerClsid, (uint)nativeContext, useLowIntegrity); + } +} diff --git a/src/Files.Core/Capabilities/Previews/WindowsShellPreviewLoader.cs b/src/Files.Core/Windows/Previews/WindowsShellPreviewLoader.cs similarity index 94% rename from src/Files.Core/Capabilities/Previews/WindowsShellPreviewLoader.cs rename to src/Files.Core/Windows/Previews/WindowsShellPreviewLoader.cs index 4c3b4da..bb3f5ed 100644 --- a/src/Files.Core/Capabilities/Previews/WindowsShellPreviewLoader.cs +++ b/src/Files.Core/Windows/Previews/WindowsShellPreviewLoader.cs @@ -1,12 +1,14 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + using System.Runtime.Versioning; using Files.Core.Capabilities; -using Files.Core.Storage.Windows; +using Files.Core.Capabilities.Previews; using OwlCore.Storage; -namespace Files.Core.Capabilities.Previews; +namespace Files.Core.Windows; /// Loads Windows Shell preview handler results for supported files. [SupportedOSPlatform("windows")] diff --git a/src/Files.Core/Capabilities/Previews/WindowsShellPreviewResult.cs b/src/Files.Core/Windows/Previews/WindowsShellPreviewResult.cs similarity index 88% rename from src/Files.Core/Capabilities/Previews/WindowsShellPreviewResult.cs rename to src/Files.Core/Windows/Previews/WindowsShellPreviewResult.cs index 711bff2..d21d75b 100644 --- a/src/Files.Core/Capabilities/Previews/WindowsShellPreviewResult.cs +++ b/src/Files.Core/Windows/Previews/WindowsShellPreviewResult.cs @@ -1,9 +1,12 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + using Files.Core.Storage; +using Files.Core.Capabilities.Previews; -namespace Files.Core.Capabilities.Previews; +namespace Files.Core.Windows; /// /// Describes a Shell preview handler without owning Shell or UI resources. diff --git a/src/Files.Core/Capabilities/Previews/WindowsShellPreviewSession.cs b/src/Files.Core/Windows/Previews/WindowsShellPreviewSession.cs similarity index 87% rename from src/Files.Core/Capabilities/Previews/WindowsShellPreviewSession.cs rename to src/Files.Core/Windows/Previews/WindowsShellPreviewSession.cs index 7893beb..4c234d6 100644 --- a/src/Files.Core/Capabilities/Previews/WindowsShellPreviewSession.cs +++ b/src/Files.Core/Windows/Previews/WindowsShellPreviewSession.cs @@ -1,27 +1,11 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 -using Files.Core.Storage.Windows; -using Windows.Win32.Foundation; +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. -namespace Files.Core.Capabilities.Previews; +using Windows.Win32.Foundation; -/// Describes the lifecycle state of a Windows Shell preview session. -public enum WindowsShellPreviewSessionState -{ - /// The session has been created. - Created, - /// The preview handler is being activated. - Activating, - /// The preview handler has been initialized. - Initialized, - /// The preview handler is rendering a preview. - Previewing, - /// Activation or rendering failed. - Faulted, - /// The session has been disposed. - Disposed, -} +namespace Files.Core.Windows; /// Coordinates a Windows Shell preview handler session. public sealed class WindowsShellPreviewSession : IWindowsShellPreviewSession diff --git a/src/Files.Core/Capabilities/Previews/WindowsShellPreviewSessionFactory.cs b/src/Files.Core/Windows/Previews/WindowsShellPreviewSessionFactory.cs similarity index 97% rename from src/Files.Core/Capabilities/Previews/WindowsShellPreviewSessionFactory.cs rename to src/Files.Core/Windows/Previews/WindowsShellPreviewSessionFactory.cs index 329bb64..5da04bb 100644 --- a/src/Files.Core/Capabilities/Previews/WindowsShellPreviewSessionFactory.cs +++ b/src/Files.Core/Windows/Previews/WindowsShellPreviewSessionFactory.cs @@ -1,11 +1,14 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + using System.Runtime.Versioning; using Files.Core.Data; -using Files.Core.Storage.Windows; +using Files.Core.Capabilities; +using Files.Core.Capabilities.Previews; -namespace Files.Core.Capabilities.Previews; +namespace Files.Core.Windows; /// Creates Windows Shell preview sessions on a dedicated scheduler. [SupportedOSPlatform("windows6.0.6000")] diff --git a/src/Files.Core/Windows/Previews/WindowsShellPreviewSessionState.cs b/src/Files.Core/Windows/Previews/WindowsShellPreviewSessionState.cs new file mode 100644 index 0000000..1552d5a --- /dev/null +++ b/src/Files.Core/Windows/Previews/WindowsShellPreviewSessionState.cs @@ -0,0 +1,23 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +namespace Files.Core.Windows; + +/// Describes the lifecycle state of a Windows Shell preview session. +public enum WindowsShellPreviewSessionState +{ + /// The session has been created. + Created, + /// The preview handler is being activated. + Activating, + /// The preview handler has been initialized. + Initialized, + /// The preview handler is rendering a preview. + Previewing, + /// Activation or rendering failed. + Faulted, + /// The session has been disposed. + Disposed, +} diff --git a/src/Files.Core/Windows/PropertySheets/WindowsFileAttributeCapabilities.cs b/src/Files.Core/Windows/PropertySheets/WindowsFileAttributeCapabilities.cs new file mode 100644 index 0000000..84de87a --- /dev/null +++ b/src/Files.Core/Windows/PropertySheets/WindowsFileAttributeCapabilities.cs @@ -0,0 +1,29 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +namespace Files.Core.Windows; + +/// +/// Describes advanced filesystem attribute capabilities. +/// +public readonly record struct WindowsFileAttributeCapabilities +{ + /// Gets a value indicating whether per-file compression is supported. + public bool SupportsCompression { get; } + + /// Gets a value indicating whether EFS encryption is supported. + public bool SupportsEncryption { get; } + + /// + /// Initializes a new instance of the structure. + /// + /// Whether per-file compression is supported. + /// Whether EFS encryption is supported. + public WindowsFileAttributeCapabilities(bool supportsCompression, bool supportsEncryption) + { + SupportsCompression = supportsCompression; + SupportsEncryption = supportsEncryption; + } +} diff --git a/src/Files.Core/Storage/Windows/WindowsFileAttributeService.cs b/src/Files.Core/Windows/PropertySheets/WindowsFileAttributeService.cs similarity index 74% rename from src/Files.Core/Storage/Windows/WindowsFileAttributeService.cs rename to src/Files.Core/Windows/PropertySheets/WindowsFileAttributeService.cs index c3901ac..5e66d1c 100644 --- a/src/Files.Core/Storage/Windows/WindowsFileAttributeService.cs +++ b/src/Files.Core/Windows/PropertySheets/WindowsFileAttributeService.cs @@ -1,13 +1,15 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + using System.ComponentModel; using System.IO; using System.Runtime.InteropServices; using Windows.Win32; using Windows.Win32.Storage.FileSystem; -namespace Files.Core.Storage.Windows; +namespace Files.Core.Windows; /// /// Reads filesystem attribute capabilities and changes NTFS compression or encryption state. @@ -75,26 +77,3 @@ public static void SetEncryption(string path, bool encrypt) } } } - -/// -/// Describes advanced filesystem attribute capabilities. -/// -public readonly record struct WindowsFileAttributeCapabilities -{ - /// Gets a value indicating whether per-file compression is supported. - public bool SupportsCompression { get; } - - /// Gets a value indicating whether EFS encryption is supported. - public bool SupportsEncryption { get; } - - /// - /// Initializes a new instance of the structure. - /// - /// Whether per-file compression is supported. - /// Whether EFS encryption is supported. - public WindowsFileAttributeCapabilities(bool supportsCompression, bool supportsEncryption) - { - SupportsCompression = supportsCompression; - SupportsEncryption = supportsEncryption; - } -} diff --git a/src/Files.Core/Storage/Windows/WindowsPreviousVersionProvider.cs b/src/Files.Core/Windows/PropertySheets/WindowsPreviousVersionProvider.cs similarity index 98% rename from src/Files.Core/Storage/Windows/WindowsPreviousVersionProvider.cs rename to src/Files.Core/Windows/PropertySheets/WindowsPreviousVersionProvider.cs index eadc073..91f7f2f 100644 --- a/src/Files.Core/Storage/Windows/WindowsPreviousVersionProvider.cs +++ b/src/Files.Core/Windows/PropertySheets/WindowsPreviousVersionProvider.cs @@ -1,6 +1,8 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + using System.Buffers.Binary; using System.Globalization; using System.IO; @@ -12,7 +14,7 @@ using Windows.Win32.Storage.FileSystem; using Windows.Win32.System.IO; -namespace Files.Core.Storage.Windows; +namespace Files.Core.Windows; internal static unsafe class WindowsPreviousVersionProvider { diff --git a/src/Files.Core/Storage/Windows/WindowsSecurityPrincipalIconProvider.cs b/src/Files.Core/Windows/PropertySheets/WindowsSecurityPrincipalIconProvider.cs similarity index 94% rename from src/Files.Core/Storage/Windows/WindowsSecurityPrincipalIconProvider.cs rename to src/Files.Core/Windows/PropertySheets/WindowsSecurityPrincipalIconProvider.cs index a5fb02e..f74f3b0 100644 --- a/src/Files.Core/Storage/Windows/WindowsSecurityPrincipalIconProvider.cs +++ b/src/Files.Core/Windows/PropertySheets/WindowsSecurityPrincipalIconProvider.cs @@ -1,12 +1,14 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + using System.IO; using Windows.Win32; using Windows.Win32.Foundation; using Windows.Win32.Security; -namespace Files.Core.Storage.Windows; +namespace Files.Core.Windows; internal static unsafe class WindowsSecurityPrincipalIconProvider { diff --git a/src/Files.Core/Windows/PropertySheets/WindowsShellCompatibilityProperties.cs b/src/Files.Core/Windows/PropertySheets/WindowsShellCompatibilityProperties.cs new file mode 100644 index 0000000..bf66e9a --- /dev/null +++ b/src/Files.Core/Windows/PropertySheets/WindowsShellCompatibilityProperties.cs @@ -0,0 +1,20 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +namespace Files.Core.Windows; + +/// +/// Contains the executable resolved for Explorer's application compatibility page. +/// +public sealed class WindowsShellCompatibilityProperties +{ + /// Gets the executable path whose compatibility settings are managed. + public string ExecutablePath { get; } + + internal WindowsShellCompatibilityProperties(string executablePath) + { + ExecutablePath = executablePath; + } +} diff --git a/src/Files.Core/Windows/PropertySheets/WindowsShellDigitalSignature.cs b/src/Files.Core/Windows/PropertySheets/WindowsShellDigitalSignature.cs new file mode 100644 index 0000000..21a06d9 --- /dev/null +++ b/src/Files.Core/Windows/PropertySheets/WindowsShellDigitalSignature.cs @@ -0,0 +1,32 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +namespace Files.Core.Windows; + +/// +/// Describes an embedded or catalog Authenticode signature. +/// +public sealed class WindowsShellDigitalSignature +{ + /// Gets the signer certificate subject. + public string Signer { get; } + + /// Gets the message digest algorithm. + public string DigestAlgorithm { get; } + + /// Gets the signature timestamp text when available. + public string Timestamp { get; } + + /// Gets the containing catalog path for a catalog signature. + public string CatalogPath { get; } + + internal WindowsShellDigitalSignature(string signer, string digestAlgorithm, string timestamp, string catalogPath) + { + Signer = signer; + DigestAlgorithm = digestAlgorithm; + Timestamp = timestamp; + CatalogPath = catalogPath; + } +} diff --git a/src/Files.Core/Windows/PropertySheets/WindowsShellDriveProperties.cs b/src/Files.Core/Windows/PropertySheets/WindowsShellDriveProperties.cs new file mode 100644 index 0000000..c4f83d8 --- /dev/null +++ b/src/Files.Core/Windows/PropertySheets/WindowsShellDriveProperties.cs @@ -0,0 +1,36 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +namespace Files.Core.Windows; + +/// +/// Contains capabilities used by the drive General and Tools pages. +/// +public sealed class WindowsShellDriveProperties +{ + /// Gets the normalized volume-root path. + public string RootPath { get; } + + /// Gets the value returned by GetDriveTypeW. + public uint DriveType { get; } + + /// Gets the filesystem capability flags returned by GetVolumeInformationW. + public uint FileSystemFlags { get; } + + /// Gets a value indicating whether Explorer exposes its error-checking command. + public bool SupportsErrorChecking { get; } + + /// Gets a value indicating whether Explorer exposes its optimization command. + public bool SupportsOptimization { get; } + + internal WindowsShellDriveProperties(string rootPath, uint driveType, uint fileSystemFlags, bool supportsErrorChecking, bool supportsOptimization) + { + RootPath = rootPath; + DriveType = driveType; + FileSystemFlags = fileSystemFlags; + SupportsErrorChecking = supportsErrorChecking; + SupportsOptimization = supportsOptimization; + } +} diff --git a/src/Files.Core/Storage/Windows/WindowsShellDriveToolsService.cs b/src/Files.Core/Windows/PropertySheets/WindowsShellDriveToolsService.cs similarity index 95% rename from src/Files.Core/Storage/Windows/WindowsShellDriveToolsService.cs rename to src/Files.Core/Windows/PropertySheets/WindowsShellDriveToolsService.cs index 7bbf594..53a5007 100644 --- a/src/Files.Core/Storage/Windows/WindowsShellDriveToolsService.cs +++ b/src/Files.Core/Windows/PropertySheets/WindowsShellDriveToolsService.cs @@ -1,13 +1,15 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + using System.IO; using System.Runtime.InteropServices; using Windows.Win32; using Windows.Win32.Foundation; using Windows.Win32.UI.Shell; -namespace Files.Core.Storage.Windows; +namespace Files.Core.Windows; /// /// Launches the Windows drive-maintenance tools represented by the Shell Tools property page. diff --git a/src/Files.Core/Windows/PropertySheets/WindowsShellFolderCustomizationProperties.cs b/src/Files.Core/Windows/PropertySheets/WindowsShellFolderCustomizationProperties.cs new file mode 100644 index 0000000..656247d --- /dev/null +++ b/src/Files.Core/Windows/PropertySheets/WindowsShellFolderCustomizationProperties.cs @@ -0,0 +1,49 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +namespace Files.Core.Windows; + +/// +/// Contains folder customization values read through the Shell customization API. +/// +public sealed class WindowsShellFolderCustomizationProperties +{ + /// Gets the customized folder path. + public string ObjectPath { get; } + + /// Gets the folder-kind canonical name. + public string FolderKind { get; } + + /// Gets the folder picture path. + public string PicturePath { get; } + + /// Gets the custom folder icon path. + public string IconPath { get; } + + /// Gets the custom folder icon resource index. + public int IconIndex { get; } + + /// Gets a value indicating whether Explorer exposes folder-picture customization for this folder. + public bool CanChangePicture { get; } + + /// Gets a value indicating whether Explorer exposes folder-icon customization for this folder. + public bool CanChangeIcon { get; } + + /// Gets a value indicating whether the current template is also stored in Explorer's inherited view-state bag. + public bool ApplyToSubfolders { get; } + + internal WindowsShellFolderCustomizationProperties(string objectPath, string folderKind, string picturePath, string iconPath, int iconIndex, bool canChangePicture, bool canChangeIcon, + bool applyToSubfolders) + { + ObjectPath = objectPath; + FolderKind = folderKind; + PicturePath = picturePath; + IconPath = iconPath; + IconIndex = iconIndex; + CanChangePicture = canChangePicture; + CanChangeIcon = canChangeIcon; + ApplyToSubfolders = applyToSubfolders; + } +} diff --git a/src/Files.Core/Storage/Windows/WindowsShellFolderCustomizationService.cs b/src/Files.Core/Windows/PropertySheets/WindowsShellFolderCustomizationService.cs similarity index 98% rename from src/Files.Core/Storage/Windows/WindowsShellFolderCustomizationService.cs rename to src/Files.Core/Windows/PropertySheets/WindowsShellFolderCustomizationService.cs index 5563981..8620d27 100644 --- a/src/Files.Core/Storage/Windows/WindowsShellFolderCustomizationService.cs +++ b/src/Files.Core/Windows/PropertySheets/WindowsShellFolderCustomizationService.cs @@ -1,6 +1,8 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + using Windows.Win32; using Windows.Win32.Foundation; using Windows.Win32.Storage.FileSystem; @@ -8,7 +10,7 @@ using Windows.Win32.UI.Shell; using Windows.Win32.UI.Shell.Common; -namespace Files.Core.Storage.Windows; +namespace Files.Core.Windows; /// /// Applies folder customization using the same Shell property bags and customization API used by Explorer. diff --git a/src/Files.Core/Windows/PropertySheets/WindowsShellHardwareDevice.cs b/src/Files.Core/Windows/PropertySheets/WindowsShellHardwareDevice.cs new file mode 100644 index 0000000..7cea15d --- /dev/null +++ b/src/Files.Core/Windows/PropertySheets/WindowsShellHardwareDevice.cs @@ -0,0 +1,66 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +namespace Files.Core.Windows; + +/// +/// Describes one device displayed by Explorer's drive Hardware page. +/// +public sealed class WindowsShellHardwareDevice +{ + /// Gets the PNG data for the device icon loaded by SetupAPI. + public ReadOnlyMemory IconData { get; } + + /// Gets the device's display name. + public string Name { get; } + + /// Gets the localized setup-class description. + public string Type { get; } + + /// Gets the device manufacturer. + public string Manufacturer { get; } + + /// Gets the device location description. + public string Location { get; } + + /// Gets the device UI location number when one is assigned. + public uint? LocationNumber { get; } + + /// Gets the provider-supplied format for the device UI location number. + public string LocationNumberFormat { get; } + + /// Gets the Configuration Manager status flags. + public uint Status { get; } + + /// Gets the Configuration Manager problem code. + public uint ProblemCode { get; } + + /// Gets the stable device-instance identifier. + public string InstanceId { get; } + + internal WindowsShellHardwareDevice( + ReadOnlyMemory iconData, + string name, + string type, + string manufacturer, + string location, + uint? locationNumber, + string locationNumberFormat, + uint status, + uint problemCode, + string instanceId) + { + IconData = iconData; + Name = name; + Type = type; + Manufacturer = manufacturer; + Location = location; + LocationNumber = locationNumber; + LocationNumberFormat = locationNumberFormat; + Status = status; + ProblemCode = problemCode; + InstanceId = instanceId; + } +} diff --git a/src/Files.Core/Windows/PropertySheets/WindowsShellPreviousVersion.cs b/src/Files.Core/Windows/PropertySheets/WindowsShellPreviousVersion.cs new file mode 100644 index 0000000..0b12e8c --- /dev/null +++ b/src/Files.Core/Windows/PropertySheets/WindowsShellPreviousVersion.cs @@ -0,0 +1,28 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +namespace Files.Core.Windows; + +/// +/// Describes one File History or volume snapshot version. +/// +public sealed class WindowsShellPreviousVersion +{ + /// Gets the version's display name. + public string Name { get; } + + /// Gets the version's source path. + public string SourcePath { get; } + + /// Gets the version timestamp. + public DateTimeOffset DateModified { get; } + + internal WindowsShellPreviousVersion(string name, string sourcePath, DateTimeOffset dateModified) + { + Name = name; + SourcePath = sourcePath; + DateModified = dateModified; + } +} diff --git a/src/Files.Core/Storage/Windows/WindowsShellPropertyPage.cs b/src/Files.Core/Windows/PropertySheets/WindowsShellPropertyPage.cs similarity index 90% rename from src/Files.Core/Storage/Windows/WindowsShellPropertyPage.cs rename to src/Files.Core/Windows/PropertySheets/WindowsShellPropertyPage.cs index 857836d..14a06c3 100644 --- a/src/Files.Core/Storage/Windows/WindowsShellPropertyPage.cs +++ b/src/Files.Core/Windows/PropertySheets/WindowsShellPropertyPage.cs @@ -1,7 +1,9 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 -namespace Files.Core.Storage.Windows; +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +namespace Files.Core.Windows; /// /// Describes a Windows-style property page that ReFiles can render for a selection. diff --git a/src/Files.Core/Storage/Windows/WindowsShellPropertyPageEnumerator.cs b/src/Files.Core/Windows/PropertySheets/WindowsShellPropertyPageEnumerator.cs similarity index 98% rename from src/Files.Core/Storage/Windows/WindowsShellPropertyPageEnumerator.cs rename to src/Files.Core/Windows/PropertySheets/WindowsShellPropertyPageEnumerator.cs index 4674af2..b365bec 100644 --- a/src/Files.Core/Storage/Windows/WindowsShellPropertyPageEnumerator.cs +++ b/src/Files.Core/Windows/PropertySheets/WindowsShellPropertyPageEnumerator.cs @@ -1,13 +1,15 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + using System.IO; using Windows.Win32; using Windows.Win32.System.SystemInformation; using Windows.Win32.System.SystemServices; using Windows.Win32.UI.Shell; -namespace Files.Core.Storage.Windows; +namespace Files.Core.Windows; internal static class WindowsShellPropertyPageEnumerator { diff --git a/src/Files.Core/Windows/PropertySheets/WindowsShellPropertyPageKind.cs b/src/Files.Core/Windows/PropertySheets/WindowsShellPropertyPageKind.cs new file mode 100644 index 0000000..e0ed5dd --- /dev/null +++ b/src/Files.Core/Windows/PropertySheets/WindowsShellPropertyPageKind.cs @@ -0,0 +1,48 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +namespace Files.Core.Windows; + +/// +/// Identifies a property page implemented by ReFiles from Windows Shell data sources. +/// +public enum WindowsShellPropertyPageKind +{ + /// The common file-system information page. + General, + + /// The drive error-checking and optimization page. + Tools, + + /// The storage-device inventory page. + Hardware, + + /// The Shell link configuration page. + Shortcut, + + /// The application compatibility page. + Compatibility, + + /// The SMB sharing page. + Sharing, + + /// The NTFS discretionary access control page. + Security, + + /// The File History and volume snapshot page. + PreviousVersions, + + /// The NTFS disk-quota page. + Quota, + + /// The folder customization page. + Customize, + + /// The Authenticode and catalog signature page. + DigitalSignatures, + + /// The Windows property-system details page. + Details, +} diff --git a/src/Files.Core/Windows/PropertySheets/WindowsShellPropertySheetData.cs b/src/Files.Core/Windows/PropertySheets/WindowsShellPropertySheetData.cs new file mode 100644 index 0000000..899c833 --- /dev/null +++ b/src/Files.Core/Windows/PropertySheets/WindowsShellPropertySheetData.cs @@ -0,0 +1,81 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +namespace Files.Core.Windows; + +/// +/// Contains native Windows data used to render a selection's property pages without creating native property-sheet windows. +/// +public sealed class WindowsShellPropertySheetData +{ + /// Gets the pages that apply to the selection in display order. + public IReadOnlyList Pages { get; } + + /// Gets drive capabilities when the selected item is a volume root. + public WindowsShellDriveProperties? Drive { get; } + + /// Gets Shell link data when the selected item is a shortcut. + public WindowsShellShortcutProperties? Shortcut { get; } + + /// Gets application compatibility data when the selection resolves to an executable. + public WindowsShellCompatibilityProperties? Compatibility { get; } + + /// Gets SMB sharing data when the selected item is a folder. + public WindowsShellSharingProperties? Sharing { get; } + + /// Gets NTFS access-control data when the selection contains file-system items. + public WindowsShellSecurityProperties? Security { get; } + + /// Gets the previous versions discovered for the selected item. + public IReadOnlyList PreviousVersions { get; } + + /// Gets the storage devices displayed by the drive Hardware page. + public IReadOnlyList HardwareDevices { get; } + + /// Gets NTFS disk-quota state when the selected volume supports quotas. + public WindowsShellQuotaProperties? Quota { get; } + + /// Gets folder customization data when the selected item is a folder. + public WindowsShellFolderCustomizationProperties? Customization { get; } + + /// Gets embedded Authenticode signatures. + public IReadOnlyList EmbeddedSignatures { get; } + + /// Gets signatures supplied by catalogs that contain the selected file. + public IReadOnlyList CatalogSignatures { get; } + + /// Gets ordered values from the Shell full-details property list. + public IReadOnlyList Details { get; } + + internal WindowsShellPropertySheetData( + IReadOnlyList pages, + WindowsShellDriveProperties? drive, + WindowsShellShortcutProperties? shortcut, + WindowsShellCompatibilityProperties? compatibility, + WindowsShellSharingProperties? sharing, + WindowsShellSecurityProperties? security, + IReadOnlyList previousVersions, + IReadOnlyList hardwareDevices, + WindowsShellQuotaProperties? quota, + WindowsShellFolderCustomizationProperties? customization, + IReadOnlyList embeddedSignatures, + IReadOnlyList catalogSignatures, + IReadOnlyList details) + { + Pages = pages; + Drive = drive; + Shortcut = shortcut; + Compatibility = compatibility; + Sharing = sharing; + Security = security; + PreviousVersions = previousVersions; + HardwareDevices = hardwareDevices; + Quota = quota; + Customization = customization; + EmbeddedSignatures = embeddedSignatures; + CatalogSignatures = catalogSignatures; + Details = details; + } +} diff --git a/src/Files.Core/Storage/Windows/WindowsShellPropertySheetReader.cs b/src/Files.Core/Windows/PropertySheets/WindowsShellPropertySheetReader.cs similarity index 99% rename from src/Files.Core/Storage/Windows/WindowsShellPropertySheetReader.cs rename to src/Files.Core/Windows/PropertySheets/WindowsShellPropertySheetReader.cs index 9fbc799..ec733f1 100644 --- a/src/Files.Core/Storage/Windows/WindowsShellPropertySheetReader.cs +++ b/src/Files.Core/Windows/PropertySheets/WindowsShellPropertySheetReader.cs @@ -1,6 +1,8 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + using System.Buffers.Binary; using System.IO; using System.Runtime.InteropServices; @@ -19,7 +21,7 @@ using Windows.Win32.UI.Shell; using Windows.Win32.UI.Shell.PropertiesSystem; -namespace Files.Core.Storage.Windows; +namespace Files.Core.Windows; internal static unsafe class WindowsShellPropertySheetReader { diff --git a/src/Files.Core/Windows/PropertySheets/WindowsShellPropertyValue.cs b/src/Files.Core/Windows/PropertySheets/WindowsShellPropertyValue.cs new file mode 100644 index 0000000..870edcc --- /dev/null +++ b/src/Files.Core/Windows/PropertySheets/WindowsShellPropertyValue.cs @@ -0,0 +1,28 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +namespace Files.Core.Windows; + +/// +/// Contains one formatted value from a Shell property-description list. +/// +public sealed class WindowsShellPropertyValue +{ + /// Gets the localized property display name. + public string Name { get; } + + /// Gets the property value formatted by its property description. + public string Value { get; } + + /// Gets a value indicating whether this entry is a property group heading. + public bool IsGroup { get; } + + internal WindowsShellPropertyValue(string name, string value, bool isGroup) + { + Name = name; + Value = value; + IsGroup = isGroup; + } +} diff --git a/src/Files.Core/Windows/PropertySheets/WindowsShellQuotaProperties.cs b/src/Files.Core/Windows/PropertySheets/WindowsShellQuotaProperties.cs new file mode 100644 index 0000000..e782d2d --- /dev/null +++ b/src/Files.Core/Windows/PropertySheets/WindowsShellQuotaProperties.cs @@ -0,0 +1,61 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +namespace Files.Core.Windows; + +/// +/// Contains the default NTFS quota policy for a volume. +/// +public sealed class WindowsShellQuotaProperties +{ + /// Gets the volume root path. + public string RootPath { get; } + + /// Gets the Shell display name for the volume. + public string DisplayName { get; } + + /// Gets a value indicating whether reading quota policy requires elevation. + public bool RequiresElevation { get; } + + /// Gets a value indicating whether quota tracking is enabled. + public bool IsTrackingEnabled { get; } + + /// Gets a value indicating whether quota limits are enforced. + public bool IsLimitEnforced { get; } + + /// Gets a value indicating whether limit events are logged. + public bool LogsLimitEvents { get; } + + /// Gets a value indicating whether warning events are logged. + public bool LogsWarningEvents { get; } + + /// Gets the default per-user quota limit in bytes, or -1 for no limit. + public long DefaultLimit { get; } + + /// Gets the default per-user warning threshold in bytes, or -1 for no threshold. + public long DefaultThreshold { get; } + + internal WindowsShellQuotaProperties( + string rootPath, + string displayName, + bool requiresElevation, + bool isTrackingEnabled, + bool isLimitEnforced, + bool logsLimitEvents, + bool logsWarningEvents, + long defaultLimit, + long defaultThreshold) + { + RootPath = rootPath; + DisplayName = displayName; + RequiresElevation = requiresElevation; + IsTrackingEnabled = isTrackingEnabled; + IsLimitEnforced = isLimitEnforced; + LogsLimitEvents = logsLimitEvents; + LogsWarningEvents = logsWarningEvents; + DefaultLimit = defaultLimit; + DefaultThreshold = defaultThreshold; + } +} diff --git a/src/Files.Core/Storage/Windows/WindowsShellQuotaService.cs b/src/Files.Core/Windows/PropertySheets/WindowsShellQuotaService.cs similarity index 92% rename from src/Files.Core/Storage/Windows/WindowsShellQuotaService.cs rename to src/Files.Core/Windows/PropertySheets/WindowsShellQuotaService.cs index 58949e8..981d715 100644 --- a/src/Files.Core/Storage/Windows/WindowsShellQuotaService.cs +++ b/src/Files.Core/Windows/PropertySheets/WindowsShellQuotaService.cs @@ -1,13 +1,15 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + using System.Runtime.InteropServices; using Windows.Win32; using Windows.Win32.Foundation; using Windows.Win32.System.Com; using Windows.Win32.UI.Shell; -namespace Files.Core.Storage.Windows; +namespace Files.Core.Windows; /// /// Opens the elevated Windows NTFS disk-quota editor used by the Shell property page. diff --git a/src/Files.Core/Windows/PropertySheets/WindowsShellSecurityPrincipal.cs b/src/Files.Core/Windows/PropertySheets/WindowsShellSecurityPrincipal.cs new file mode 100644 index 0000000..f440097 --- /dev/null +++ b/src/Files.Core/Windows/PropertySheets/WindowsShellSecurityPrincipal.cs @@ -0,0 +1,40 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +namespace Files.Core.Windows; + +/// +/// Describes the access masks assigned to a security principal. +/// +public sealed class WindowsShellSecurityPrincipal +{ + /// Gets the account's display name. + public string Name { get; } + + /// Gets the account's string SID. + public string Sid { get; } + + /// Gets the PNG data for the ACLUI principal icon. + public ReadOnlyMemory IconData { get; } + + /// Gets the image index retained for compatibility with the ACLUI image-list source. + public int IconIndex { get; } + + /// Gets the combined allowed access mask. + public uint AllowedAccessMask { get; } + + /// Gets the combined denied access mask. + public uint DeniedAccessMask { get; } + + internal WindowsShellSecurityPrincipal(string name, string sid, ReadOnlyMemory iconData, int iconIndex, uint allowedAccessMask, uint deniedAccessMask) + { + Name = name; + Sid = sid; + IconData = iconData; + IconIndex = iconIndex; + AllowedAccessMask = allowedAccessMask; + DeniedAccessMask = deniedAccessMask; + } +} diff --git a/src/Files.Core/Windows/PropertySheets/WindowsShellSecurityProperties.cs b/src/Files.Core/Windows/PropertySheets/WindowsShellSecurityProperties.cs new file mode 100644 index 0000000..503a8e4 --- /dev/null +++ b/src/Files.Core/Windows/PropertySheets/WindowsShellSecurityProperties.cs @@ -0,0 +1,24 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +namespace Files.Core.Windows; + +/// +/// Contains NTFS discretionary access-control state for one file-system item. +/// +public sealed class WindowsShellSecurityProperties +{ + /// Gets the path whose access-control list was read. + public string ObjectPath { get; } + + /// Gets the principals present in the discretionary access-control list. + public IReadOnlyList Principals { get; } + + internal WindowsShellSecurityProperties(string objectPath, IReadOnlyList principals) + { + ObjectPath = objectPath; + Principals = principals; + } +} diff --git a/src/Files.Core/Storage/Windows/WindowsShellSecurityService.cs b/src/Files.Core/Windows/PropertySheets/WindowsShellSecurityService.cs similarity index 96% rename from src/Files.Core/Storage/Windows/WindowsShellSecurityService.cs rename to src/Files.Core/Windows/PropertySheets/WindowsShellSecurityService.cs index 3488146..6e1da7b 100644 --- a/src/Files.Core/Storage/Windows/WindowsShellSecurityService.cs +++ b/src/Files.Core/Windows/PropertySheets/WindowsShellSecurityService.cs @@ -1,6 +1,8 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + using System.IO; using System.Runtime.InteropServices; using Windows.Win32; @@ -9,7 +11,7 @@ using Windows.Win32.System.Com; using Windows.Win32.UI.Shell; -namespace Files.Core.Storage.Windows; +namespace Files.Core.Windows; /// /// Opens the Windows NTFS access-control editors used by the Shell security property page. diff --git a/src/Files.Core/Windows/PropertySheets/WindowsShellSharingProperties.cs b/src/Files.Core/Windows/PropertySheets/WindowsShellSharingProperties.cs new file mode 100644 index 0000000..52ca9bf --- /dev/null +++ b/src/Files.Core/Windows/PropertySheets/WindowsShellSharingProperties.cs @@ -0,0 +1,44 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +namespace Files.Core.Windows; + +/// +/// Contains SMB sharing state for a folder. +/// +public sealed class WindowsShellSharingProperties +{ + /// Gets the local folder path represented by the page. + public string ObjectPath { get; } + + /// Gets the folder name displayed by the page. + public string DisplayName { get; } + + /// Gets a value indicating whether the folder is inside an SMB share. + public bool IsShared { get; } + + /// Gets the containing share name. + public string ShareName { get; } + + /// Gets the UNC path that addresses the selected folder. + public string NetworkPath { get; } + + /// Gets a value indicating whether password-protection guidance is applicable to this computer. + public bool ShowPasswordProtection { get; } + + /// Gets a value indicating whether users must authenticate to access shared folders. + public bool IsPasswordProtectionEnabled { get; } + + internal WindowsShellSharingProperties(string objectPath, string displayName, bool isShared, string shareName, string networkPath, bool showPasswordProtection, bool isPasswordProtectionEnabled) + { + ObjectPath = objectPath; + DisplayName = displayName; + IsShared = isShared; + ShareName = shareName; + NetworkPath = networkPath; + ShowPasswordProtection = showPasswordProtection; + IsPasswordProtectionEnabled = isPasswordProtectionEnabled; + } +} diff --git a/src/Files.Core/Storage/Windows/WindowsShellSharingService.cs b/src/Files.Core/Windows/PropertySheets/WindowsShellSharingService.cs similarity index 98% rename from src/Files.Core/Storage/Windows/WindowsShellSharingService.cs rename to src/Files.Core/Windows/PropertySheets/WindowsShellSharingService.cs index bddc7bb..cb51c22 100644 --- a/src/Files.Core/Storage/Windows/WindowsShellSharingService.cs +++ b/src/Files.Core/Windows/PropertySheets/WindowsShellSharingService.cs @@ -1,6 +1,8 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + using System.IO; using Windows.Win32; using Windows.Win32.Foundation; @@ -10,7 +12,7 @@ using Windows.Win32.System.Com; using Windows.Win32.UI.Shell; -namespace Files.Core.Storage.Windows; +namespace Files.Core.Windows; /// /// Reads local SMB sharing state and opens the Windows sharing experiences. diff --git a/src/Files.Core/Windows/PropertySheets/WindowsShellShortcutProperties.cs b/src/Files.Core/Windows/PropertySheets/WindowsShellShortcutProperties.cs new file mode 100644 index 0000000..ce4d663 --- /dev/null +++ b/src/Files.Core/Windows/PropertySheets/WindowsShellShortcutProperties.cs @@ -0,0 +1,66 @@ +// Copyright (c) Files Community +// SPDX-License-Identifier: MPL-2.0 + +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + +namespace Files.Core.Windows; + +/// +/// Contains values read from an IShellLinkW object. +/// +public sealed class WindowsShellShortcutProperties +{ + /// Gets the shortcut target path. + public string TargetPath { get; } + + /// Gets the target's Shell type description. + public string TargetType { get; } + + /// Gets the target's containing folder name. + public string TargetLocation { get; } + + /// Gets the command-line arguments. + public string Arguments { get; } + + /// Gets the working directory. + public string WorkingDirectory { get; } + + /// Gets the encoded Shell hotkey. + public ushort Hotkey { get; } + + /// Gets the target window show command. + public int ShowCommand { get; } + + /// Gets the shortcut comment. + public string Comment { get; } + + /// Gets the custom icon path. + public string IconPath { get; } + + /// Gets the custom icon resource index. + public int IconIndex { get; } + + internal WindowsShellShortcutProperties( + string targetPath, + string targetType, + string targetLocation, + string arguments, + string workingDirectory, + ushort hotkey, + int showCommand, + string comment, + string iconPath, + int iconIndex) + { + TargetPath = targetPath; + TargetType = targetType; + TargetLocation = targetLocation; + Arguments = arguments; + WorkingDirectory = workingDirectory; + Hotkey = hotkey; + ShowCommand = showCommand; + Comment = comment; + IconPath = iconPath; + IconIndex = iconIndex; + } +} diff --git a/src/Files.Core/Storage/Windows/WindowsShellStorageSettingsService.cs b/src/Files.Core/Windows/PropertySheets/WindowsShellStorageSettingsService.cs similarity index 96% rename from src/Files.Core/Storage/Windows/WindowsShellStorageSettingsService.cs rename to src/Files.Core/Windows/PropertySheets/WindowsShellStorageSettingsService.cs index 0beefce..913bb14 100644 --- a/src/Files.Core/Storage/Windows/WindowsShellStorageSettingsService.cs +++ b/src/Files.Core/Windows/PropertySheets/WindowsShellStorageSettingsService.cs @@ -1,13 +1,15 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + using System.IO; using System.Runtime.InteropServices; using Windows.Win32; using Windows.Win32.Foundation; using Windows.Win32.UI.Shell; -namespace Files.Core.Storage.Windows; +namespace Files.Core.Windows; /// /// Opens the Windows Settings storage page used by Explorer's drive property sheet. diff --git a/src/Files.Core/Storage/Windows/WindowsVolumeLabelService.cs b/src/Files.Core/Windows/PropertySheets/WindowsVolumeLabelService.cs similarity index 97% rename from src/Files.Core/Storage/Windows/WindowsVolumeLabelService.cs rename to src/Files.Core/Windows/PropertySheets/WindowsVolumeLabelService.cs index 6efb33d..eff6b69 100644 --- a/src/Files.Core/Storage/Windows/WindowsVolumeLabelService.cs +++ b/src/Files.Core/Windows/PropertySheets/WindowsVolumeLabelService.cs @@ -1,6 +1,8 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + using System.ComponentModel; using System.IO; using System.Runtime.CompilerServices; @@ -11,7 +13,7 @@ using Windows.Win32.UI.Controls; using Windows.Win32.UI.Shell; -namespace Files.Core.Storage.Windows; +namespace Files.Core.Windows; /// /// Reads Shell drive display names and changes filesystem volume labels. diff --git a/src/Files.Core/Storage/Windows/IWindowsShellScheduler.cs b/src/Files.Core/Windows/Scheduling/IWindowsShellScheduler.cs similarity index 88% rename from src/Files.Core/Storage/Windows/IWindowsShellScheduler.cs rename to src/Files.Core/Windows/Scheduling/IWindowsShellScheduler.cs index 448932c..9e6b887 100644 --- a/src/Files.Core/Storage/Windows/IWindowsShellScheduler.cs +++ b/src/Files.Core/Windows/Scheduling/IWindowsShellScheduler.cs @@ -1,9 +1,11 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + using System.Runtime.Versioning; -namespace Files.Core.Storage.Windows; +namespace Files.Core.Windows; /// /// Schedules Windows Shell COM work on message-pumped STA threads. diff --git a/src/Files.Core/Storage/Windows/WindowsShellScheduler.cs b/src/Files.Core/Windows/Scheduling/WindowsShellScheduler.cs similarity index 99% rename from src/Files.Core/Storage/Windows/WindowsShellScheduler.cs rename to src/Files.Core/Windows/Scheduling/WindowsShellScheduler.cs index 3900dcc..8349967 100644 --- a/src/Files.Core/Storage/Windows/WindowsShellScheduler.cs +++ b/src/Files.Core/Windows/Scheduling/WindowsShellScheduler.cs @@ -1,6 +1,8 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +#pragma warning disable IDE0130 // Windows APIs share a namespace across responsibility folders. + using System.Collections.Concurrent; using System.ComponentModel; using System.Diagnostics; @@ -11,7 +13,7 @@ using Windows.Win32.Foundation; using Windows.Win32.UI.WindowsAndMessaging; -namespace Files.Core.Storage.Windows; +namespace Files.Core.Windows; /// /// Owns the message-pumped STA lanes used by the Windows storage source. diff --git a/src/Files.Core/Composition/WindowsFilesCoreBuilderExtensions.cs b/src/Files.Core/Windows/WindowsFilesCoreBuilderExtensions.cs similarity index 98% rename from src/Files.Core/Composition/WindowsFilesCoreBuilderExtensions.cs rename to src/Files.Core/Windows/WindowsFilesCoreBuilderExtensions.cs index f8d704e..4ce823f 100644 --- a/src/Files.Core/Composition/WindowsFilesCoreBuilderExtensions.cs +++ b/src/Files.Core/Windows/WindowsFilesCoreBuilderExtensions.cs @@ -7,9 +7,9 @@ using Files.Core.Capabilities.Properties; using Files.Core.Capabilities.Thumbnails; using Files.Core.Storage.Archives; -using Files.Core.Storage.Windows; +using Files.Core.Composition; -namespace Files.Core.Composition; +namespace Files.Core.Windows; /// /// Adds the Windows Shell vertical slice to a Core runtime. diff --git a/src/Files.Core/Storage/Windows/WindowsStorageSource.cs b/src/Files.Core/Windows/WindowsStorageSource.cs similarity index 99% rename from src/Files.Core/Storage/Windows/WindowsStorageSource.cs rename to src/Files.Core/Windows/WindowsStorageSource.cs index 14cd3de..83220ef 100644 --- a/src/Files.Core/Storage/Windows/WindowsStorageSource.cs +++ b/src/Files.Core/Windows/WindowsStorageSource.cs @@ -3,11 +3,12 @@ using System.IO; using System.Runtime.CompilerServices; +using Files.Core.Storage; using OwlCore.Storage; using Windows.Win32; using Windows.Win32.UI.Shell; -namespace Files.Core.Storage.Windows; +namespace Files.Core.Windows; /// /// Resolves file-system and virtual items through the Windows Shell namespace. diff --git a/src/Files/Activation/ItemActivationService.cs b/src/Files/Activation/ItemActivationService.cs index d19ab25..ac5a4b9 100644 --- a/src/Files/Activation/ItemActivationService.cs +++ b/src/Files/Activation/ItemActivationService.cs @@ -3,7 +3,7 @@ using Files.Core.Data; using Files.Core.Storage; -using Files.Core.Storage.Windows; +using Files.Core.Windows; namespace Files.Activation; diff --git a/src/Files/Adapters/BrowsePresentationAdapter.cs b/src/Files/Adapters/BrowsePresentationAdapter.cs index a2117a8..46d7b53 100644 --- a/src/Files/Adapters/BrowsePresentationAdapter.cs +++ b/src/Files/Adapters/BrowsePresentationAdapter.cs @@ -13,8 +13,8 @@ using Files.Core.Capabilities.Thumbnails; using Files.Core.Models; using Files.Core.Storage; -using Files.Core.Storage.Windows; using Files.Core.ViewSettings; +using Files.Core.Windows; using Microsoft.UI.Dispatching; namespace Files.Adapters; diff --git a/src/Files/App.xaml.cs b/src/Files/App.xaml.cs index 0de427b..fc27685 100644 --- a/src/Files/App.xaml.cs +++ b/src/Files/App.xaml.cs @@ -8,6 +8,7 @@ using Files.StorageOperations; using Files.Core.Composition; using Files.Core.Sessions; +using Files.Core.Windows; using Microsoft.UI.Xaml; using System.Diagnostics; diff --git a/src/Files/Commands/AppCommandRegistration.cs b/src/Files/Commands/AppCommandRegistration.cs index e707935..b78a5e6 100644 --- a/src/Files/Commands/AppCommandRegistration.cs +++ b/src/Files/Commands/AppCommandRegistration.cs @@ -2,8 +2,8 @@ // SPDX-License-Identifier: MPL-2.0 using Files.Commands.Handlers; -using Files.Core.Storage.Windows; using Files.Localization; +using Files.Core.Windows; namespace Files.Commands; diff --git a/src/Files/Commands/CommandContext.cs b/src/Files/Commands/CommandContext.cs index 4be7aeb..3658456 100644 --- a/src/Files/Commands/CommandContext.cs +++ b/src/Files/Commands/CommandContext.cs @@ -2,7 +2,7 @@ // SPDX-License-Identifier: MPL-2.0 using Files.ViewModels; -using Files.Core.Storage.Windows; +using Files.Core.Windows; namespace Files.Commands; diff --git a/src/Files/Commands/Handlers/OpenItemCommandHandler.cs b/src/Files/Commands/Handlers/OpenItemCommandHandler.cs index 09da33b..0a66f58 100644 --- a/src/Files/Commands/Handlers/OpenItemCommandHandler.cs +++ b/src/Files/Commands/Handlers/OpenItemCommandHandler.cs @@ -3,7 +3,7 @@ using Files.Activation; using Files.Core.Browsing; -using Files.Core.Storage.Windows; +using Files.Core.Windows; namespace Files.Commands.Handlers; diff --git a/src/Files/Commands/OpenItemCommandParameter.cs b/src/Files/Commands/OpenItemCommandParameter.cs index 86af762..4bb9d05 100644 --- a/src/Files/Commands/OpenItemCommandParameter.cs +++ b/src/Files/Commands/OpenItemCommandParameter.cs @@ -1,8 +1,8 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 -using Files.Core.Storage.Windows; using Files.ViewModels; +using Files.Core.Windows; namespace Files.Commands; diff --git a/src/Files/Infrastructure/WinUiDataObjectBridge.cs b/src/Files/Infrastructure/WinUiDataObjectBridge.cs index 3048758..9dc8ac2 100644 --- a/src/Files/Infrastructure/WinUiDataObjectBridge.cs +++ b/src/Files/Infrastructure/WinUiDataObjectBridge.cs @@ -1,7 +1,7 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 -using Files.Core.Storage.Windows; +using Files.Core.Windows; using Windows.ApplicationModel.DataTransfer; using Windows.Win32.System.Com; using Windows.Win32.UI.Shell; diff --git a/src/Files/Infrastructure/WinUiShellDropTargetController.cs b/src/Files/Infrastructure/WinUiShellDropTargetController.cs index dad120b..3e87614 100644 --- a/src/Files/Infrastructure/WinUiShellDropTargetController.cs +++ b/src/Files/Infrastructure/WinUiShellDropTargetController.cs @@ -2,7 +2,7 @@ // SPDX-License-Identifier: MPL-2.0 using Files.Core.Storage; -using Files.Core.Storage.Windows; +using Files.Core.Windows; using Microsoft.UI.Xaml; using System.Drawing; using Windows.ApplicationModel.DataTransfer; diff --git a/src/Files/ItemProperties/CompatibilityPropertyView.xaml.cs b/src/Files/ItemProperties/CompatibilityPropertyView.xaml.cs index 8509f0d..596a595 100644 --- a/src/Files/ItemProperties/CompatibilityPropertyView.xaml.cs +++ b/src/Files/ItemProperties/CompatibilityPropertyView.xaml.cs @@ -1,8 +1,8 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 -using Files.Core.Storage.Windows; using Files.Localization; +using Files.Core.Windows; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; diff --git a/src/Files/ItemProperties/CustomizePropertyView.xaml.cs b/src/Files/ItemProperties/CustomizePropertyView.xaml.cs index 061cc44..3bb2dd7 100644 --- a/src/Files/ItemProperties/CustomizePropertyView.xaml.cs +++ b/src/Files/ItemProperties/CustomizePropertyView.xaml.cs @@ -3,8 +3,8 @@ using System.IO; using Files.Adapters; -using Files.Core.Storage.Windows; using Files.Localization; +using Files.Core.Windows; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; using Windows.Storage.Pickers; diff --git a/src/Files/ItemProperties/DigitalSignaturesPropertyView.xaml.cs b/src/Files/ItemProperties/DigitalSignaturesPropertyView.xaml.cs index 030e906..eb3565c 100644 --- a/src/Files/ItemProperties/DigitalSignaturesPropertyView.xaml.cs +++ b/src/Files/ItemProperties/DigitalSignaturesPropertyView.xaml.cs @@ -2,7 +2,7 @@ // SPDX-License-Identifier: MPL-2.0 using System.IO; -using Files.Core.Storage.Windows; +using Files.Core.Windows; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; diff --git a/src/Files/ItemProperties/ElevationShieldIcon.xaml.cs b/src/Files/ItemProperties/ElevationShieldIcon.xaml.cs index 85ad281..3929595 100644 --- a/src/Files/ItemProperties/ElevationShieldIcon.xaml.cs +++ b/src/Files/ItemProperties/ElevationShieldIcon.xaml.cs @@ -2,7 +2,7 @@ // SPDX-License-Identifier: MPL-2.0 using Files.Adapters; -using Files.Core.Storage.Windows; +using Files.Core.Windows; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; diff --git a/src/Files/ItemProperties/GeneralPropertyView.xaml.cs b/src/Files/ItemProperties/GeneralPropertyView.xaml.cs index c366531..03ce31b 100644 --- a/src/Files/ItemProperties/GeneralPropertyView.xaml.cs +++ b/src/Files/ItemProperties/GeneralPropertyView.xaml.cs @@ -2,7 +2,7 @@ // SPDX-License-Identifier: MPL-2.0 using System.Runtime.InteropServices; -using Files.Core.Storage.Windows; +using Files.Core.Windows; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; diff --git a/src/Files/ItemProperties/HardwarePropertyView.xaml.cs b/src/Files/ItemProperties/HardwarePropertyView.xaml.cs index 5f774a4..b5cbb0a 100644 --- a/src/Files/ItemProperties/HardwarePropertyView.xaml.cs +++ b/src/Files/ItemProperties/HardwarePropertyView.xaml.cs @@ -6,8 +6,8 @@ using System.Globalization; using System.Runtime.CompilerServices; using Files.Adapters; -using Files.Core.Storage.Windows; using Files.Localization; +using Files.Core.Windows; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Media.Imaging; diff --git a/src/Files/ItemProperties/ItemPropertiesFileSystem.cs b/src/Files/ItemProperties/ItemPropertiesFileSystem.cs index a03f49a..7e84ded 100644 --- a/src/Files/ItemProperties/ItemPropertiesFileSystem.cs +++ b/src/Files/ItemProperties/ItemPropertiesFileSystem.cs @@ -5,7 +5,7 @@ using System.IO; using System.Runtime.InteropServices; -using Files.Core.Storage.Windows; +using Files.Core.Windows; using Windows.Win32; namespace Files.ItemProperties; diff --git a/src/Files/ItemProperties/ItemPropertiesService.cs b/src/Files/ItemProperties/ItemPropertiesService.cs index efc47e2..b209cbc 100644 --- a/src/Files/ItemProperties/ItemPropertiesService.cs +++ b/src/Files/ItemProperties/ItemPropertiesService.cs @@ -2,8 +2,8 @@ // SPDX-License-Identifier: MPL-2.0 using Files.Core.Storage; -using Files.Core.Storage.Windows; using Files.ViewModels; +using Files.Core.Windows; using Microsoft.UI.Xaml; using Windows.Win32; using Windows.Win32.UI.WindowsAndMessaging; diff --git a/src/Files/ItemProperties/ItemPropertiesViewModel.cs b/src/Files/ItemProperties/ItemPropertiesViewModel.cs index aae964e..9223a98 100644 --- a/src/Files/ItemProperties/ItemPropertiesViewModel.cs +++ b/src/Files/ItemProperties/ItemPropertiesViewModel.cs @@ -6,9 +6,9 @@ using System.IO; using CommunityToolkit.Mvvm.ComponentModel; using Files.Core.Storage; -using Files.Core.Storage.Windows; using Files.Localization; using Files.ViewModels; +using Files.Core.Windows; using Microsoft.UI.Xaml.Media; using Windows.Win32.Foundation; diff --git a/src/Files/ItemProperties/ItemPropertiesWindow.xaml.cs b/src/Files/ItemProperties/ItemPropertiesWindow.xaml.cs index dd31b49..70a0000 100644 --- a/src/Files/ItemProperties/ItemPropertiesWindow.xaml.cs +++ b/src/Files/ItemProperties/ItemPropertiesWindow.xaml.cs @@ -6,9 +6,9 @@ using Files.Adapters; using Files.Core.Capabilities.Thumbnails; using Files.Core.Storage; -using Files.Core.Storage.Windows; using Files.Localization; using Files.ViewModels; +using Files.Core.Windows; using Microsoft.UI.Windowing; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; diff --git a/src/Files/ItemProperties/PreviousVersionsPropertyView.xaml.cs b/src/Files/ItemProperties/PreviousVersionsPropertyView.xaml.cs index aa8473f..4e3bc8c 100644 --- a/src/Files/ItemProperties/PreviousVersionsPropertyView.xaml.cs +++ b/src/Files/ItemProperties/PreviousVersionsPropertyView.xaml.cs @@ -5,7 +5,7 @@ using System.ComponentModel; using System.Runtime.CompilerServices; using Files.Adapters; -using Files.Core.Storage.Windows; +using Files.Core.Windows; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Media.Imaging; diff --git a/src/Files/ItemProperties/QuotaPropertyView.xaml.cs b/src/Files/ItemProperties/QuotaPropertyView.xaml.cs index 5c6b50d..9fa3787 100644 --- a/src/Files/ItemProperties/QuotaPropertyView.xaml.cs +++ b/src/Files/ItemProperties/QuotaPropertyView.xaml.cs @@ -2,8 +2,8 @@ // SPDX-License-Identifier: MPL-2.0 using System.Globalization; -using Files.Core.Storage.Windows; using Files.Localization; +using Files.Core.Windows; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; using Windows.Win32.Foundation; diff --git a/src/Files/ItemProperties/SecurityPropertyView.xaml.cs b/src/Files/ItemProperties/SecurityPropertyView.xaml.cs index a02bb72..02e243f 100644 --- a/src/Files/ItemProperties/SecurityPropertyView.xaml.cs +++ b/src/Files/ItemProperties/SecurityPropertyView.xaml.cs @@ -6,8 +6,8 @@ using System.Globalization; using System.Runtime.CompilerServices; using Files.Adapters; -using Files.Core.Storage.Windows; using Files.Localization; +using Files.Core.Windows; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Media.Imaging; diff --git a/src/Files/ItemProperties/SharingPropertyView.xaml.cs b/src/Files/ItemProperties/SharingPropertyView.xaml.cs index 6c8c602..df1bb45 100644 --- a/src/Files/ItemProperties/SharingPropertyView.xaml.cs +++ b/src/Files/ItemProperties/SharingPropertyView.xaml.cs @@ -3,8 +3,8 @@ using System.Runtime.InteropServices; using Files.Adapters; -using Files.Core.Storage.Windows; using Files.Localization; +using Files.Core.Windows; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Documents; diff --git a/src/Files/ItemProperties/ShortcutPropertyView.xaml.cs b/src/Files/ItemProperties/ShortcutPropertyView.xaml.cs index 7c4cd83..375d63a 100644 --- a/src/Files/ItemProperties/ShortcutPropertyView.xaml.cs +++ b/src/Files/ItemProperties/ShortcutPropertyView.xaml.cs @@ -1,8 +1,8 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 -using Files.Core.Storage.Windows; using Files.Localization; +using Files.Core.Windows; using Microsoft.UI.Xaml.Controls; namespace Files.ItemProperties; diff --git a/src/Files/ItemProperties/ToolsPropertyView.xaml.cs b/src/Files/ItemProperties/ToolsPropertyView.xaml.cs index bf932cb..5483562 100644 --- a/src/Files/ItemProperties/ToolsPropertyView.xaml.cs +++ b/src/Files/ItemProperties/ToolsPropertyView.xaml.cs @@ -1,7 +1,7 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 -using Files.Core.Storage.Windows; +using Files.Core.Windows; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; using Windows.Win32.Foundation; diff --git a/src/Files/MainWindow.xaml.cs b/src/Files/MainWindow.xaml.cs index 1ab2c3b..0fe707c 100644 --- a/src/Files/MainWindow.xaml.cs +++ b/src/Files/MainWindow.xaml.cs @@ -8,12 +8,12 @@ using Files.Core.Data; using Files.Core.Capabilities.Previews; using Files.Core.Storage; -using Files.Core.Storage.Windows; using Files.Infrastructure; using Files.Presentation; using Files.ItemProperties; using Files.Settings; using Files.StorageOperations; +using Files.Core.Windows; using Microsoft.UI.Windowing; using Microsoft.UI.Xaml; using System.Diagnostics; diff --git a/src/Files/ViewModels/DetailsColumnViewModel.cs b/src/Files/ViewModels/DetailsColumnViewModel.cs index 3549ec9..6aa56a4 100644 --- a/src/Files/ViewModels/DetailsColumnViewModel.cs +++ b/src/Files/ViewModels/DetailsColumnViewModel.cs @@ -1,8 +1,8 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +using Files.Core.Windows; using CommunityToolkit.Mvvm.ComponentModel; -using Files.Core.Storage.Windows; using Microsoft.UI.Xaml; namespace Files.ViewModels; diff --git a/src/Files/ViewModels/FolderBrowserViewModel.cs b/src/Files/ViewModels/FolderBrowserViewModel.cs index 4276464..3e8ae99 100644 --- a/src/Files/ViewModels/FolderBrowserViewModel.cs +++ b/src/Files/ViewModels/FolderBrowserViewModel.cs @@ -18,8 +18,8 @@ using Files.Core.Models; using Files.Core.Storage; using Files.Core.Storage.Archives; -using Files.Core.Storage.Windows; using Files.Core.ViewSettings; +using Files.Core.Windows; using Microsoft.UI.Dispatching; using Microsoft.UI.Xaml.Data; using Microsoft.UI.Xaml.Media; diff --git a/src/Files/ViewModels/NavigationItemLoader.cs b/src/Files/ViewModels/NavigationItemLoader.cs index ce0a4fb..86e6569 100644 --- a/src/Files/ViewModels/NavigationItemLoader.cs +++ b/src/Files/ViewModels/NavigationItemLoader.cs @@ -10,9 +10,9 @@ using Files.Core.Capabilities.Thumbnails; using Files.Core.Models; using Files.Core.Storage; -using Files.Core.Storage.Windows; using Files.Infrastructure; using Files.Localization; +using Files.Core.Windows; using OwlCore.Storage; using Windows.Storage.Provider; using Windows.Win32; diff --git a/src/Files/ViewModels/PreviewPaneViewModel.cs b/src/Files/ViewModels/PreviewPaneViewModel.cs index 7766010..4e0f7d5 100644 --- a/src/Files/ViewModels/PreviewPaneViewModel.cs +++ b/src/Files/ViewModels/PreviewPaneViewModel.cs @@ -8,6 +8,7 @@ using Files.Core.Sessions; using Files.Infrastructure; using Files.Localization; +using Files.Core.Windows; namespace Files.ViewModels; diff --git a/src/Files/ViewModels/ToolbarViewModel.cs b/src/Files/ViewModels/ToolbarViewModel.cs index bcbb2b8..e7c61fc 100644 --- a/src/Files/ViewModels/ToolbarViewModel.cs +++ b/src/Files/ViewModels/ToolbarViewModel.cs @@ -4,8 +4,8 @@ using CommunityToolkit.Mvvm.ComponentModel; using Files.Commands; using Files.Controls; -using Files.Core.Storage.Windows; using Files.Core.ViewSettings; +using Files.Core.Windows; namespace Files.ViewModels; diff --git a/src/Files/Views/ItemContextMenu.cs b/src/Files/Views/ItemContextMenu.cs index b1b4e4d..3eda3d8 100644 --- a/src/Files/Views/ItemContextMenu.cs +++ b/src/Files/Views/ItemContextMenu.cs @@ -3,9 +3,9 @@ using Files.Adapters; using Files.Commands; -using Files.Core.Storage.Windows; using Files.Localization; using Files.ViewModels; +using Files.Core.Windows; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Controls.Primitives; diff --git a/src/Files/Views/NavigationToolbar.xaml.cs b/src/Files/Views/NavigationToolbar.xaml.cs index 6af7980..2c0fb94 100644 --- a/src/Files/Views/NavigationToolbar.xaml.cs +++ b/src/Files/Views/NavigationToolbar.xaml.cs @@ -4,10 +4,10 @@ using Files.Adapters; using Files.Controls; using Files.Core.Browsing; -using Files.Core.Storage.Windows; using Files.Infrastructure; using Files.Localization; using Files.ViewModels; +using Files.Core.Windows; using Microsoft.UI.Input; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; diff --git a/src/Files/Views/PreviewPane.xaml.cs b/src/Files/Views/PreviewPane.xaml.cs index d33470e..bcfa7cb 100644 --- a/src/Files/Views/PreviewPane.xaml.cs +++ b/src/Files/Views/PreviewPane.xaml.cs @@ -9,6 +9,7 @@ using Files.Core.Capabilities.Previews; using Files.Localization; using Files.ViewModels; +using Files.Core.Windows; using Microsoft.UI.Dispatching; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; diff --git a/src/Files/Views/RootView.xaml.cs b/src/Files/Views/RootView.xaml.cs index e534664..7bdfcf0 100644 --- a/src/Files/Views/RootView.xaml.cs +++ b/src/Files/Views/RootView.xaml.cs @@ -5,6 +5,7 @@ using Files.Controls; using Files.Infrastructure; using Files.Core.Capabilities.Previews; +using Files.Core.Windows; using System.Diagnostics; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; diff --git a/src/Files/Views/Selection/FolderViewInteraction.cs b/src/Files/Views/Selection/FolderViewInteraction.cs index aae326b..059cc4f 100644 --- a/src/Files/Views/Selection/FolderViewInteraction.cs +++ b/src/Files/Views/Selection/FolderViewInteraction.cs @@ -5,9 +5,9 @@ using Files.Controls; using Files.Core.Browsing; using Files.Core.Storage; -using Files.Core.Storage.Windows; using Files.Infrastructure; using Files.ViewModels; +using Files.Core.Windows; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Controls.Primitives; diff --git a/src/Files/Views/ToolbarView.xaml.cs b/src/Files/Views/ToolbarView.xaml.cs index b9d4101..76bbe6b 100644 --- a/src/Files/Views/ToolbarView.xaml.cs +++ b/src/Files/Views/ToolbarView.xaml.cs @@ -4,8 +4,8 @@ using Files.Adapters; using Files.Commands; using Files.Controls; -using Files.Core.Storage.Windows; using Files.ViewModels; +using Files.Core.Windows; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Controls.Primitives; diff --git a/tests/Files.PresentationTests/ItemActivationServiceTests.cs b/tests/Files.PresentationTests/ItemActivationServiceTests.cs index d5beab3..a9e3377 100644 --- a/tests/Files.PresentationTests/ItemActivationServiceTests.cs +++ b/tests/Files.PresentationTests/ItemActivationServiceTests.cs @@ -3,7 +3,7 @@ using Files.Activation; using Files.Core.Storage; -using Files.Core.Storage.Windows; +using Files.Core.Windows; using Microsoft.VisualStudio.TestTools.UnitTesting; namespace Files.PresentationTests; diff --git a/tests/Files.UITests/InfrastructureTests/WinUiDataObjectBridgeTests.cs b/tests/Files.UITests/InfrastructureTests/WinUiDataObjectBridgeTests.cs index fa922dc..334606d 100644 --- a/tests/Files.UITests/InfrastructureTests/WinUiDataObjectBridgeTests.cs +++ b/tests/Files.UITests/InfrastructureTests/WinUiDataObjectBridgeTests.cs @@ -4,8 +4,8 @@ using System.Drawing; using System.IO; using Files.Core.Storage; -using Files.Core.Storage.Windows; using Files.Infrastructure; +using Files.Core.Windows; using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting.AppContainer; using Windows.ApplicationModel.DataTransfer; diff --git a/tests/Files.UITests/PresentationTests/BrowsePerformanceTests.cs b/tests/Files.UITests/PresentationTests/BrowsePerformanceTests.cs index a8e8661..be31636 100644 --- a/tests/Files.UITests/PresentationTests/BrowsePerformanceTests.cs +++ b/tests/Files.UITests/PresentationTests/BrowsePerformanceTests.cs @@ -27,6 +27,7 @@ using Files.StorageOperations; using Files.ViewModels; using Files.Views; +using Files.Core.Windows; using Microsoft.UI.Dispatching; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; diff --git a/tests/Files.UITests/PresentationTests/ItemPropertiesViewModelTests.cs b/tests/Files.UITests/PresentationTests/ItemPropertiesViewModelTests.cs index 7d11974..2958cf5 100644 --- a/tests/Files.UITests/PresentationTests/ItemPropertiesViewModelTests.cs +++ b/tests/Files.UITests/PresentationTests/ItemPropertiesViewModelTests.cs @@ -3,9 +3,9 @@ using System.IO; using Files.Core.Storage; -using Files.Core.Storage.Windows; using Files.ItemProperties; using Files.ViewModels; +using Files.Core.Windows; using Microsoft.UI.Xaml.Controls; using Microsoft.VisualStudio.TestTools.UnitTesting; diff --git a/tests/Files.UITests/PresentationTests/PreviewPaneViewModelTests.cs b/tests/Files.UITests/PresentationTests/PreviewPaneViewModelTests.cs index f8b1f72..b6b036f 100644 --- a/tests/Files.UITests/PresentationTests/PreviewPaneViewModelTests.cs +++ b/tests/Files.UITests/PresentationTests/PreviewPaneViewModelTests.cs @@ -6,6 +6,7 @@ using Files.Core.Capabilities.Previews; using Files.Infrastructure; using Files.ViewModels; +using Files.Core.Windows; using Microsoft.UI.Dispatching; using Microsoft.VisualStudio.TestTools.UnitTesting; diff --git a/tests/Files.UnitTests/ArchiveBrowsingTests.cs b/tests/Files.UnitTests/ArchiveBrowsingTests.cs index 61eb29a..0f426d8 100644 --- a/tests/Files.UnitTests/ArchiveBrowsingTests.cs +++ b/tests/Files.UnitTests/ArchiveBrowsingTests.cs @@ -9,6 +9,7 @@ using Files.Core.Models; using Files.Core.Storage; using Files.Core.Storage.Archives; +using Files.Core.Windows; using OwlCore.Storage; namespace Files.UnitTests; diff --git a/tests/Files.UnitTests/BrowsePreviewModelTests.cs b/tests/Files.UnitTests/BrowsePreviewModelTests.cs index 75a459b..e0f48c4 100644 --- a/tests/Files.UnitTests/BrowsePreviewModelTests.cs +++ b/tests/Files.UnitTests/BrowsePreviewModelTests.cs @@ -7,6 +7,7 @@ using Files.Core.Models; using Files.Core.Storage; using Files.Core.ViewSettings; +using Files.Core.Windows; namespace Files.UnitTests; diff --git a/tests/Files.UnitTests/GlobalUsings.cs b/tests/Files.UnitTests/GlobalUsings.cs index 0c74238..b1f4ef5 100644 --- a/tests/Files.UnitTests/GlobalUsings.cs +++ b/tests/Files.UnitTests/GlobalUsings.cs @@ -5,6 +5,5 @@ global using System.Linq; global using System.Threading; global using System.Threading.Tasks; -global using Files.Core.Storage.Windows; global using Microsoft.VisualStudio.TestTools.UnitTesting; global using OwlCore.Storage; diff --git a/tests/Files.UnitTests/WindowsFilesCoreBuilderTests.cs b/tests/Files.UnitTests/WindowsFilesCoreBuilderTests.cs index 6d4512e..fde15b7 100644 --- a/tests/Files.UnitTests/WindowsFilesCoreBuilderTests.cs +++ b/tests/Files.UnitTests/WindowsFilesCoreBuilderTests.cs @@ -3,6 +3,7 @@ using Files.Core.Composition; using Files.Core.Storage; +using Files.Core.Windows; namespace Files.UnitTests; diff --git a/tests/Files.UnitTests/WindowsFolderChangeTests.cs b/tests/Files.UnitTests/WindowsFolderChangeTests.cs index 1b29f42..129e069 100644 --- a/tests/Files.UnitTests/WindowsFolderChangeTests.cs +++ b/tests/Files.UnitTests/WindowsFolderChangeTests.cs @@ -4,7 +4,7 @@ using Files.Core.Capabilities; using Files.Core.Capabilities.Changes; using Files.Core.Storage; -using Files.Core.Storage.Windows; +using Files.Core.Windows; namespace Files.UnitTests; diff --git a/tests/Files.UnitTests/WindowsIdentityTests.cs b/tests/Files.UnitTests/WindowsIdentityTests.cs index 64f4a4a..3a7cf78 100644 --- a/tests/Files.UnitTests/WindowsIdentityTests.cs +++ b/tests/Files.UnitTests/WindowsIdentityTests.cs @@ -2,7 +2,7 @@ // SPDX-License-Identifier: MPL-2.0 using Files.Core.Storage; -using Files.Core.Storage.Windows; +using Files.Core.Windows; namespace Files.UnitTests; diff --git a/tests/Files.UnitTests/WindowsPreviewAccessPolicyTests.cs b/tests/Files.UnitTests/WindowsPreviewAccessPolicyTests.cs index 177ffcb..e235c34 100644 --- a/tests/Files.UnitTests/WindowsPreviewAccessPolicyTests.cs +++ b/tests/Files.UnitTests/WindowsPreviewAccessPolicyTests.cs @@ -4,7 +4,7 @@ using Files.Core.Capabilities; using Files.Core.Capabilities.Previews; using Files.Core.Storage; -using Files.Core.Storage.Windows; +using Files.Core.Windows; using OwlCore.Storage; using Windows.Win32; using Windows.Win32.Foundation; diff --git a/tests/Files.UnitTests/WindowsPreviewHandlerRegistrationTests.cs b/tests/Files.UnitTests/WindowsPreviewHandlerRegistrationTests.cs index 7932508..a3c34c0 100644 --- a/tests/Files.UnitTests/WindowsPreviewHandlerRegistrationTests.cs +++ b/tests/Files.UnitTests/WindowsPreviewHandlerRegistrationTests.cs @@ -6,7 +6,7 @@ using Files.Core.Capabilities; using Files.Core.Capabilities.Previews; using Files.Core.Storage; -using Files.Core.Storage.Windows; +using Files.Core.Windows; using Microsoft.Win32; using OwlCore.Storage; using Windows.Win32.Foundation; diff --git a/tests/Files.UnitTests/WindowsPropertyTests.cs b/tests/Files.UnitTests/WindowsPropertyTests.cs index 67d62f6..e048646 100644 --- a/tests/Files.UnitTests/WindowsPropertyTests.cs +++ b/tests/Files.UnitTests/WindowsPropertyTests.cs @@ -8,8 +8,8 @@ using Files.Core.Models; using Files.Core.Sessions; using Files.Core.Storage; -using Files.Core.Storage.Windows; using Files.Core.ViewSettings; +using Files.Core.Windows; using OwlCore.Storage; namespace Files.UnitTests; diff --git a/tests/Files.UnitTests/WindowsShellColumnTests.cs b/tests/Files.UnitTests/WindowsShellColumnTests.cs index 8b1ca73..da4f35f 100644 --- a/tests/Files.UnitTests/WindowsShellColumnTests.cs +++ b/tests/Files.UnitTests/WindowsShellColumnTests.cs @@ -2,7 +2,7 @@ // SPDX-License-Identifier: MPL-2.0 using Files.Core.Storage; -using Files.Core.Storage.Windows; +using Files.Core.Windows; namespace Files.UnitTests; diff --git a/tests/Files.UnitTests/WindowsShellContextualCommandTests.cs b/tests/Files.UnitTests/WindowsShellContextualCommandTests.cs index 68fb3ac..61c384c 100644 --- a/tests/Files.UnitTests/WindowsShellContextualCommandTests.cs +++ b/tests/Files.UnitTests/WindowsShellContextualCommandTests.cs @@ -2,7 +2,7 @@ // SPDX-License-Identifier: MPL-2.0 using Files.Core.Storage; -using Files.Core.Storage.Windows; +using Files.Core.Windows; namespace Files.UnitTests; diff --git a/tests/Files.UnitTests/WindowsShellDefaultCommandTests.cs b/tests/Files.UnitTests/WindowsShellDefaultCommandTests.cs index 6598132..69da54d 100644 --- a/tests/Files.UnitTests/WindowsShellDefaultCommandTests.cs +++ b/tests/Files.UnitTests/WindowsShellDefaultCommandTests.cs @@ -2,7 +2,7 @@ // SPDX-License-Identifier: MPL-2.0 using Files.Core.Storage; -using Files.Core.Storage.Windows; +using Files.Core.Windows; namespace Files.UnitTests; diff --git a/tests/Files.UnitTests/WindowsShellDragDropTests.cs b/tests/Files.UnitTests/WindowsShellDragDropTests.cs index 004f031..31bd412 100644 --- a/tests/Files.UnitTests/WindowsShellDragDropTests.cs +++ b/tests/Files.UnitTests/WindowsShellDragDropTests.cs @@ -4,6 +4,7 @@ using System.Drawing; using System.IO.Compression; using Files.Core.Storage; +using Files.Core.Windows; using Windows.Win32; using Windows.Win32.Foundation; using Windows.Win32.System.Com; diff --git a/tests/Files.UnitTests/WindowsShellNewMenuTests.cs b/tests/Files.UnitTests/WindowsShellNewMenuTests.cs index 6d1fbd3..ada7c12 100644 --- a/tests/Files.UnitTests/WindowsShellNewMenuTests.cs +++ b/tests/Files.UnitTests/WindowsShellNewMenuTests.cs @@ -1,7 +1,7 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 -using Files.Core.Storage.Windows; +using Files.Core.Windows; namespace Files.UnitTests; diff --git a/tests/Files.UnitTests/WindowsShellPreviewTests.cs b/tests/Files.UnitTests/WindowsShellPreviewTests.cs index f3b5c50..69a8a29 100644 --- a/tests/Files.UnitTests/WindowsShellPreviewTests.cs +++ b/tests/Files.UnitTests/WindowsShellPreviewTests.cs @@ -7,7 +7,7 @@ using Files.Core.Capabilities.Previews; using Files.Core.Models; using Files.Core.Storage; -using Files.Core.Storage.Windows; +using Files.Core.Windows; using Microsoft.Win32; using Windows.Win32; using Windows.Win32.Foundation; diff --git a/tests/Files.UnitTests/WindowsShellPropertyPageTests.cs b/tests/Files.UnitTests/WindowsShellPropertyPageTests.cs index 8b621bc..2e563c5 100644 --- a/tests/Files.UnitTests/WindowsShellPropertyPageTests.cs +++ b/tests/Files.UnitTests/WindowsShellPropertyPageTests.cs @@ -3,7 +3,7 @@ using System.Buffers.Binary; using Files.Core.Storage; -using Files.Core.Storage.Windows; +using Files.Core.Windows; namespace Files.UnitTests; diff --git a/tests/Files.UnitTests/WindowsShellSchedulerTests.cs b/tests/Files.UnitTests/WindowsShellSchedulerTests.cs index 903e0f0..650d932 100644 --- a/tests/Files.UnitTests/WindowsShellSchedulerTests.cs +++ b/tests/Files.UnitTests/WindowsShellSchedulerTests.cs @@ -1,6 +1,8 @@ // Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 +using Files.Core.Windows; + namespace Files.UnitTests; /// diff --git a/tests/Files.UnitTests/WindowsShellSortTests.cs b/tests/Files.UnitTests/WindowsShellSortTests.cs index fbe0680..83c2583 100644 --- a/tests/Files.UnitTests/WindowsShellSortTests.cs +++ b/tests/Files.UnitTests/WindowsShellSortTests.cs @@ -5,8 +5,8 @@ using Files.Core.Composition; using Files.Core.Sessions; using Files.Core.Storage; -using Files.Core.Storage.Windows; using Files.Core.ViewSettings; +using Files.Core.Windows; namespace Files.UnitTests; diff --git a/tests/Files.UnitTests/WindowsStorageOperationInterruptionTests.cs b/tests/Files.UnitTests/WindowsStorageOperationInterruptionTests.cs index 37fc6c1..294d89c 100644 --- a/tests/Files.UnitTests/WindowsStorageOperationInterruptionTests.cs +++ b/tests/Files.UnitTests/WindowsStorageOperationInterruptionTests.cs @@ -2,6 +2,7 @@ // SPDX-License-Identifier: MPL-2.0 using Files.Core.Storage; +using Files.Core.Windows; namespace Files.UnitTests; diff --git a/tests/Files.UnitTests/WindowsStorageOperationTests.cs b/tests/Files.UnitTests/WindowsStorageOperationTests.cs index fdc7e52..90f0ad6 100644 --- a/tests/Files.UnitTests/WindowsStorageOperationTests.cs +++ b/tests/Files.UnitTests/WindowsStorageOperationTests.cs @@ -3,6 +3,7 @@ using System.Diagnostics; using Files.Core.Storage; +using Files.Core.Windows; namespace Files.UnitTests; diff --git a/tests/Files.UnitTests/WindowsStorageTests.cs b/tests/Files.UnitTests/WindowsStorageTests.cs index 44b1cc5..160af73 100644 --- a/tests/Files.UnitTests/WindowsStorageTests.cs +++ b/tests/Files.UnitTests/WindowsStorageTests.cs @@ -6,6 +6,7 @@ using Files.Core.Composition; using Files.Core.Sessions; using Files.Core.Storage; +using Files.Core.Windows; namespace Files.UnitTests; diff --git a/tests/Files.UnitTests/WindowsThumbnailTests.cs b/tests/Files.UnitTests/WindowsThumbnailTests.cs index 5e19541..7b7e65c 100644 --- a/tests/Files.UnitTests/WindowsThumbnailTests.cs +++ b/tests/Files.UnitTests/WindowsThumbnailTests.cs @@ -4,8 +4,8 @@ using Files.Core.Capabilities; using Files.Core.Models; using Files.Core.Storage; -using Files.Core.Storage.Windows; using Files.Core.Capabilities.Thumbnails; +using Files.Core.Windows; using OwlCore.Storage; using Windows.Win32.UI.Shell;