diff --git a/.github/README.md b/.github/README.md index 6cd757f71e10..f0ea097e90b8 100644 --- a/.github/README.md +++ b/.github/README.md @@ -11,6 +11,8 @@ Files is created and maintained by the [Files Community](https://github.com/file > [!WARNING] > **Status: alpha.** Expect missing features and rough edges, and do not rely on it for data you cannot afford to lose. The official, supported Files for Windows is at [files.community](https://files.community/). +LinuxFiles is now an independent fork: upstream stays a read-only remote, fixes are cherry-picked selectively, and upstream branches are no longer merged. See the [upstream policy](../docs/linux-port/upstream-policy.md). MIT/MPL licenses and contributor notices remain preserved. + ## Linux port: current state This fork runs Files natively on Linux (Uno Platform, Skia, X11). The shell, Settings, file operations, trash, archives, clipboard and drag and drop, UDisks2 volumes and desktop integration are in place. See the [showcase](../docs/linux-port/SHOWCASE.md) for the full feature checklist and what is not working yet. diff --git a/.github/scripts/Configure-AppxManifest.ps1 b/.github/scripts/Configure-AppxManifest.ps1 deleted file mode 100644 index c587e372fc9d..000000000000 --- a/.github/scripts/Configure-AppxManifest.ps1 +++ /dev/null @@ -1,183 +0,0 @@ -# Copyright (c) Files Community -# SPDX-License-Identifier: MPL-2.0 - -param( - [string]$Branch = "", # This has to correspond with one of the AppEnvironment enum values - [string]$PackageManifestPath = "", - [string]$Publisher = "", - [string]$WorkingDir = "", - [string]$SecretBingMapsKey = "", - [string]$SecretSentry = "", - [string]$SecretGitHubOAuthClientId = "" -) - -# Load Package.appxmanifest -[xml]$xmlDoc = Get-Content $PackageManifestPath - -# Add namespaces -$nsmgr = New-Object System.Xml.XmlNamespaceManager($xmlDoc.NameTable) -$nsmgr.AddNamespace("pkg", "http://schemas.microsoft.com/appx/manifest/foundation/windows10") -$nsmgr.AddNamespace("rescap", "http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities") -$nsmgr.AddNamespace("uap", "http://schemas.microsoft.com/appx/manifest/uap/windows10") -$nsmgr.AddNamespace("uap5", "http://schemas.microsoft.com/appx/manifest/uap/windows10/5") -$ap = $xmlDoc.SelectSingleNode("/pkg:Package/pkg:Applications/pkg:Application/pkg:Extensions/uap:Extension[@Category='windows.protocol']/uap:Protocol", $nsmgr) -$aea = $xmlDoc.SelectSingleNode("/pkg:Package/pkg:Applications/pkg:Application/pkg:Extensions/uap5:Extension[@Category='windows.appExecutionAlias']/uap5:AppExecutionAlias", $nsmgr) -$ea = $xmlDoc.SelectSingleNode("/pkg:Package/pkg:Applications/pkg:Application/pkg:Extensions/uap5:Extension[@Category='windows.appExecutionAlias']/uap5:AppExecutionAlias/uap5:ExecutionAlias", $nsmgr) - -# Update the publisher -$xmlDoc.Package.Identity.Publisher = $Publisher - -if ($Branch -eq "SideloadPreview") -{ - # Set identities - $xmlDoc.Package.Identity.Name="FilesPreview" - $xmlDoc.Package.Properties.DisplayName="Files - Preview" - $xmlDoc.Package.Applications.Application.VisualElements.DisplayName="Files - Preview" - $xmlDoc.Package.Applications.Application.VisualElements.DefaultTile.ShortName="Files - Preview" - - # Update app protocol and execution alias - $ap.SetAttribute("Name", "files-preview"); - $ea.SetAttribute("Alias", "files-preview.exe"); - - # Save modified Package.appxmanifest - $xmlDoc.Save($PackageManifestPath) - - Get-ChildItem $WorkingDir -Include *.csproj, *.appxmanifest, *.xaml -recurse | ForEach-Object -Process ` - { ` - (Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "Assets\\AppTiles\\Dev", "Assets\AppTiles\Preview" }) | ` - Set-Content $_ -NoNewline ` - } - - Get-ChildItem $WorkingDir -Include *.cs, *.cpp -recurse | ForEach-Object -Process ` - { ` - (Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "files-dev", "files-preview" }) | ` - Set-Content $_ -NoNewline ` - } - -} -elseif ($Branch -eq "StorePreview") -{ - # Set identities - $xmlDoc.Package.Identity.Name="49306atecsolution.FilesPreview" - $xmlDoc.Package.Properties.DisplayName="Files - Preview" - $xmlDoc.Package.Applications.Application.VisualElements.DisplayName="Files - Preview" - $xmlDoc.Package.Applications.Application.VisualElements.DefaultTile.ShortName="Files - Preview" - - # Remove capability that is only used for the sideload package - $nsmgr = New-Object System.Xml.XmlNamespaceManager($xmlDoc.NameTable) - $nsmgr.AddNamespace("pkg", "http://schemas.microsoft.com/appx/manifest/foundation/windows10") - $nsmgr.AddNamespace("rescap", "http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities") - $pm = $xmlDoc.SelectSingleNode("/pkg:Package/pkg:Capabilities/rescap:Capability[@Name='packageManagement']", $nsmgr) - $xmlDoc.Package.Capabilities.RemoveChild($pm) - - # Update app protocol and execution alias - $ap.SetAttribute("Name", "files-preview"); - $ea.SetAttribute("Alias", "files-preview.exe"); - - $xmlDoc.Save($PackageManifestPath) - - Get-ChildItem $WorkingDir -Include *.csproj, *.appxmanifest, *.xaml -recurse | ForEach-Object -Process ` - { ` - (Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "Assets\\AppTiles\\Dev", "Assets\AppTiles\Preview" }) | ` - Set-Content $_ -NoNewline ` - } - - Get-ChildItem $WorkingDir -Include *.cs, *.cpp -recurse | ForEach-Object -Process ` - { ` - (Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "files-dev", "files-preview" }) | ` - Set-Content $_ -NoNewline ` - } - -} -elseif ($Branch -eq "SideloadStable") -{ - # Set identities - $xmlDoc.Package.Identity.Name="Files" - $xmlDoc.Package.Properties.DisplayName="Files" - $xmlDoc.Package.Applications.Application.VisualElements.DisplayName="Files" - $xmlDoc.Package.Applications.Application.VisualElements.DefaultTile.ShortName="Files" - - # Update app protocol and execution alias - $ap.SetAttribute("Name", "files-stable"); - $ea.SetAttribute("Alias", "files-stable.exe"); - - # Save modified Package.appxmanifest - $xmlDoc.Save($PackageManifestPath) - - Get-ChildItem $WorkingDir -Include *.csproj, *.appxmanifest, *.xaml -recurse | ForEach-Object -Process ` - { ` - (Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "Assets\\AppTiles\\Dev", "Assets\AppTiles\Release" }) | ` - Set-Content $_ -NoNewline ` - } - - Get-ChildItem $WorkingDir -Include *.cs, *.cpp -recurse | ForEach-Object -Process ` - { ` - (Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "files-dev", "files-stable" }) | ` - Set-Content $_ -NoNewline ` - } - -} -elseif ($Branch -eq "StoreStable") -{ - # Set identities - $xmlDoc.Package.Identity.Name="49306atecsolution.FilesUWP" - $xmlDoc.Package.Properties.DisplayName="Files App" - $xmlDoc.Package.Applications.Application.VisualElements.DisplayName="Files" - $xmlDoc.Package.Applications.Application.VisualElements.DefaultTile.ShortName="Files" - - # Remove capability that is only used for the sideload package - $pm = $xmlDoc.SelectSingleNode("/pkg:Package/pkg:Capabilities/rescap:Capability[@Name='packageManagement']", $nsmgr) - $xmlDoc.Package.Capabilities.RemoveChild($pm) - - # Update app protocol and execution alias - $ap.SetAttribute("Name", "files-stable"); - $ea.SetAttribute("Alias", "files-stable.exe"); - - # Save modified Package.appxmanifest - $xmlDoc.Save($PackageManifestPath) - - Get-ChildItem $WorkingDir -Include *.csproj, *.appxmanifest, *.xaml -recurse | ForEach-Object -Process ` - { ` - (Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "Assets\\AppTiles\\Dev", "Assets\AppTiles\Release" }) | ` - Set-Content $_ -NoNewline ` - } - - Get-ChildItem $WorkingDir -Include *.cs, *.cpp -recurse | ForEach-Object -Process ` - { ` - (Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "files-dev", "files-stable" }) | ` - Set-Content $_ -NoNewline ` - } - -} - -# Remove unused tile assets so they don't end up in the package -$keepTiles = if ($Branch -match 'Preview') { 'Preview' } elseif ($Branch -match 'Stable') { 'Release' } else { $null } -foreach ($folder in @('Dev', 'Preview', 'Release')) { - if ($folder -eq $keepTiles) { continue } - $tilePath = Join-Path $WorkingDir "src\Files.App\Assets\AppTiles\$folder" - if (Test-Path $tilePath) { Remove-Item $tilePath -Recurse -Force } -} - -Get-ChildItem $WorkingDir -Include *.cs -recurse | ForEach-Object -Process ` -{ ` - (Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "cd_app_env_placeholder", $Branch }) | ` - Set-Content $_ -NoNewline ` -} - -Get-ChildItem $WorkingDir -Include *.cs -recurse | ForEach-Object -Process ` -{ ` - (Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "bingmapskey.secret", "$SecretBingMapsKey" }) | ` - Set-Content $_ -NoNewline ` -} - -Get-ChildItem $WorkingDir -Include *.cs -recurse | ForEach-Object -Process ` -{ - (Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "sentry.secret", "$SecretSentry" }) | ` - Set-Content $_ -NoNewline ` -} - -Get-ChildItem $WorkingDir -Include *.cs -recurse | ForEach-Object -Process ` -{ ` - (Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "githubclientid.secret", "$SecretGitHubOAuthClientId" }) | ` - Set-Content $_ -NoNewline ` -} diff --git a/.github/scripts/Convert-TrxToMarkdown.ps1 b/.github/scripts/Convert-TrxToMarkdown.ps1 deleted file mode 100644 index f48f981b6c9a..000000000000 --- a/.github/scripts/Convert-TrxToMarkdown.ps1 +++ /dev/null @@ -1,219 +0,0 @@ -# Copyright (c) Files Community -# SPDX-License-Identifier: MPL-2.0 - -# Abstract: -# This script analyzes the trx file that is the result of executing dotnet test and -# converts it to markdown, which is used for the Files CI. - -using namespace System.Collections.Generic; -using namespace System.Linq; - -param( - [string]$Source = "", - [string]$Destination = "" -) - -class Trx -{ - [ResultSummary] $ResultSummary - [TrxTimes] $Times - [TrxTestDefinition[]]$TestDefinitions - [TrxUnitTestResult[]]$Results - - Trx() - { - $this.Times = New-Object TrxTimes - $this.ResultSummary = New-Object ResultSummary - } -} - -class ResultSummary -{ - [int] $total - [int] $passed - [int] $failed -} - -class TrxTimes -{ - [Datetime] $creation - [Datetime] $queuing - [Datetime] $start - [Datetime] $finish -} - -class TrxTestDefinition -{ - [string] $id - [string] $name - [string] $className -} - -class TrxUnitTestResult -{ - [string] $id - [string] $result - [string] $name - [string] $errorMessage - [string] $errorStackTrace -} - -[xml]$xmlDoc = Get-Content $Source - -$trxObject = New-Object Trx - -# Result summary -$trxObject.ResultSummary.total = $xmlDoc.TestRun.ResultSummary.Counters.total -$trxObject.ResultSummary.passed = $xmlDoc.TestRun.ResultSummary.Counters.passed -$trxObject.ResultSummary.failed = $xmlDoc.TestRun.ResultSummary.Counters.failed - -# Times -$trxObject.Times.start = $xmlDoc.TestRun.Times.start -$trxObject.Times.finish = $xmlDoc.TestRun.Times.finish - -# Unit test definitions -foreach ($item in $xmlDoc.TestRun.TestDefinitions.UnitTest) -{ - $newOne = [TrxTestDefinition]::new() - - $newOne.id = $item.Execution.id - $newOne.name = $item.name - $newOne.className = $item.TestMethod.className - - $trxObject.TestDefinitions += $newOne -} - -# Unit tests -foreach ($item in $xmlDoc.TestRun.Results.UnitTestResult) -{ - $newOne = [TrxUnitTestResult]::new() - - $newOne.id = $item.executionId - $newOne.result = $item.outcome - $newOne.name = $item.testName - $newOne.errorMessage = $item.Output.ErrorInfo.Message - $newOne.errorStackTrace = $item.Output.ErrorInfo.StackTrace - - $trxObject.Results += $newOne -} - -$stringBuilder = New-Object System.Text.StringBuilder - -$title = "## Tested with Files " -$AbbreviatedOid = $env:GITHUB_SHA -$AbbreviatedOid = $AbbreviatedOid.Substring(0, 7) -$resultOverview = "" - -# Header -[void]$stringBuilder.AppendLine($title); -[void]$stringBuilder.AppendLine(""); - -$skippedIcon = "⏩" -$passedIcon = "✅" -$failedIcon = "❌" -$unknownIcon = "⚠️" - -# Skipped -if ($trxObject.ResultSummary.failed -ne 0 -and $trxObject.ResultSummary.passed -ne 0) -{ - $resultOverview = $partialSuccessfulfulIcon + "Some tests were not successful" -} -# Passed -elseif ($trxObject.ResultSummary.failed -eq 0) -{ - $resultOverview = $passedIcon + " All tests have passed" -} -# Failed -elseif ($trxObject.ResultSummary.failed -ne 0 -and $trxObject.ResultSummary.passed -eq 0) -{ - $resultOverview = $failedIcon + " All tests have failed" -} -else -{ - $resultOverview = $unknownIcon + " Unknown result" -} - -# Overview table -[void]$stringBuilder.AppendLine(""); -[void]$stringBuilder.AppendLine(""); -[void]$stringBuilder.AppendLine(""); -[void]$stringBuilder.AppendLine(""); -[void]$stringBuilder.AppendLine(""); -[void]$stringBuilder.AppendLine(""); -[void]$stringBuilder.AppendLine(""); -[void]$stringBuilder.AppendLine(""); -[void]$stringBuilder.AppendLine(""); -[void]$stringBuilder.AppendLine(""); -[void]$stringBuilder.AppendLine(""); -[void]$stringBuilder.AppendLine(""); -[void]$stringBuilder.AppendLine(""); -[void]$stringBuilder.AppendLine("
Commit:$AbbreviatedOid
Status:$resultOverview
Full log:https://github.com/files-community/Files/actions/runs/$GITHUB_RUN_ID/job/$GITHUB_JOB
"); -[void]$stringBuilder.AppendLine(""); - -if ($trxObject.ResultSummary.failed -eq 0) -{ - $stringBuilder.ToString() | Out-File -FilePath $Destination - Exit -} - -# Details Table -[void]$stringBuilder.AppendLine("### Details"); -[void]$stringBuilder.AppendLine("Name|Status|Failed class"); -[void]$stringBuilder.AppendLine(":---|:---|:---"); - -$index = 0 - -foreach ($item in $trxObject.Results) -{ - $resultStatus = "" - if ($item.result.Equals("Failed")) - { - $resultStatus = $failedIcon + " Failed" - } - elseif ($item.result.Equals("Passed")) - { - $resultStatus = $successfulIcon + " Passed" - } - else - { - $resultStatus = $skippedIcon + " Unknown" - } - - $failedClassName = "_None_" - $testName = $item.name - $baseClassName = $trxObject.TestDefinitions | Where-Object { $_.id -eq $item.id } - if ($null -ne $item.errorMessage) - { - $failedClassName = "" + $baseClassName.className + "." + $item.name + "" - } - - [void]$stringBuilder.AppendLine("$testName`|$resultStatus`|$failedClassName"); - - $index++ -} - -[void]$stringBuilder.AppendLine(""); - -[void]$stringBuilder.AppendLine("
"); -[void]$stringBuilder.AppendLine("View logs"); -[void]$stringBuilder.AppendLine("
"); -[void]$stringBuilder.AppendLine(""); - -foreach ($item in $trxObject.Results) -{ - $baseClassName = $trxObject.TestDefinitions | Where-Object { $_.id -eq $item.id } - $failedClassName = $baseClassName.className + "." + $item.name - [void]$stringBuilder.AppendLine("- **" + $failedClassName + "**"); - - $stackTraceText = $item.errorStackTrace - [void]$stringBuilder.AppendLine(" ``````"); - [void]$stringBuilder.Append("$stackTraceText"); - [void]$stringBuilder.AppendLine(" ``````"); -} - -[void]$stringBuilder.AppendLine(""); -[void]$stringBuilder.AppendLine("
"); -[void]$stringBuilder.AppendLine(""); - - -$stringBuilder.ToString() | Out-File -FilePath $Destination diff --git a/.github/scripts/Create-MsixBundle.ps1 b/.github/scripts/Create-MsixBundle.ps1 deleted file mode 100644 index 39c88c11fc80..000000000000 --- a/.github/scripts/Create-MsixBundle.ps1 +++ /dev/null @@ -1,275 +0,0 @@ -# Copyright (c) Files Community -# SPDX-License-Identifier: MPL-2.0 - -# Creates an .msixbundle from individual per-platform .msix packages produced -# by single-project MSIX packaging. Optionally generates an .appinstaller file -# for sideload deployments, and an .msixupload for Store submissions. - -param( - [Parameter(Mandatory)] - [string]$AppxPackageDir, - - [Parameter(Mandatory)] - [string]$BundleName, - - [string]$Version = "", - - [string]$PackageManifestPath = "", - - [string]$AppInstallerUri = "", - - [ValidateSet("Sideload", "StoreUpload", "SideloadOnly")] - [string]$BuildMode = "Sideload" -) - -$ErrorActionPreference = "Stop" - -function Ensure-Directory([string]$Path) { - if (-not (Test-Path $Path)) { New-Item -ItemType Directory -Path $Path | Out-Null } -} - -# Canonical arch names for the WAP-compatible folder layout -$archMap = @{ 'arm64' = 'ARM64'; 'x64' = 'x64'; 'x86' = 'x86' } - -# --- Locate makeappx.exe --- - -$sdkRoot = "${env:ProgramFiles(x86)}\Windows Kits\10\bin" -$makeAppx = Get-ChildItem -Path $sdkRoot -Filter "makeappx.exe" -Recurse -ErrorAction SilentlyContinue | - Where-Object { $_.DirectoryName -match '\\x64$' } | - Sort-Object { [version]($_.DirectoryName -replace '^.*\\bin\\([^\\]+)\\.*$','$1') } -Descending | - Select-Object -First 1 -if ($null -eq $makeAppx) { - Write-Error "makeappx.exe not found under '$sdkRoot'" - exit 1 -} -Write-Host "Using makeappx: $($makeAppx.FullName)" - -# --- Discover per-platform .msix packages --- - -$msixFiles = Get-ChildItem -Path $AppxPackageDir -Filter "*.msix" -Recurse | - Where-Object { $_.DirectoryName -notmatch '\\Dependencies\\' } -if ($msixFiles.Count -eq 0) { - Write-Error "No .msix files found in '$AppxPackageDir'" - exit 1 -} -Write-Host "Found $($msixFiles.Count) .msix package(s):" -$msixFiles | ForEach-Object { Write-Host " $_" } - -if ($Version -eq "" -and $PackageManifestPath -ne "" -and (Test-Path $PackageManifestPath)) { - [xml]$versionManifest = Get-Content $PackageManifestPath - $Version = $versionManifest.Package.Identity.Version - Write-Host "Version from manifest: $Version" -} -if ($Version -eq "") { - $Version = $msixFiles[0].BaseName -replace '^[^_]+_([^_]+)_.*$','$1' - Write-Host "Detected version from filename: $Version" -} - -$platformList = $msixFiles | ForEach-Object { $_.BaseName -replace '.*_(\w+)$','$1' } | Sort-Object -Descending -$platforms = $platformList -join '_' - -# --- Create .msixbundle --- - -$mappingDir = Join-Path $AppxPackageDir "_bundletemp" -if (Test-Path $mappingDir) { Remove-Item $mappingDir -Recurse -Force } -New-Item -ItemType Directory -Path $mappingDir | Out-Null -foreach ($msix in $msixFiles) { Copy-Item $msix.FullName -Destination $mappingDir } - -$bundlePath = Join-Path $AppxPackageDir "$BundleName.msixbundle" -if (Test-Path $bundlePath) { Remove-Item $bundlePath -Force } - -Write-Host "Creating msixbundle at: $bundlePath" -& $makeAppx.FullName bundle /d $mappingDir /p $bundlePath /bv $Version /o -if ($LASTEXITCODE -ne 0) { - Write-Error "MakeAppx bundle creation failed with exit code $LASTEXITCODE" - exit 1 -} -Remove-Item $mappingDir -Recurse -Force -Write-Host "Successfully created: $bundlePath" - -# --- Reorganize into WAP-compatible folder structure for CDN upload --- -# Target layout: {BundleName}_{Version}_Test/{BundleName}_{Version}_{platforms}.msixbundle -# {BundleName}_{Version}_Test/Dependencies/{arch}/... - -$bundleFolder = "${BundleName}_${Version}_Test" -$bundleFolderPath = Join-Path $AppxPackageDir $bundleFolder -Ensure-Directory $bundleFolderPath - -$organizedBundleName = "${BundleName}_${Version}_${platforms}.msixbundle" -$organizedBundlePath = Join-Path $bundleFolderPath $organizedBundleName -Move-Item $bundlePath $organizedBundlePath -Force -Write-Host "Moved bundle to: $organizedBundlePath" - -# --- Merge dependency folders from each per-platform build --- - -$organizedDepsDir = Join-Path $bundleFolderPath "Dependencies" -foreach ($msix in $msixFiles) { - $perPlatDepsDir = Join-Path $msix.DirectoryName "Dependencies" - if (-not (Test-Path $perPlatDepsDir)) { continue } - - Get-ChildItem -Path $perPlatDepsDir -Directory | ForEach-Object { - $archName = $_.Name - $canonicalArch = $archMap[$archName] - if (-not $canonicalArch) { return } - if (-not ($platformList -contains $archName)) { return } - - $targetArchDir = Join-Path $organizedDepsDir $canonicalArch - Ensure-Directory $targetArchDir - Get-ChildItem -Path $_.FullName -File | ForEach-Object { - $destFile = Join-Path $targetArchDir $_.Name - if (-not (Test-Path $destFile)) { - Copy-Item $_.FullName -Destination $destFile - Write-Host " Copied dependency: $destFile" - } - } - } -} - -# --- Add VCLibs framework packages (not produced by single-project builds) --- - -$vcLibsSdkBase = "${env:ProgramFiles(x86)}\Microsoft SDKs\Windows Kits\10\ExtensionSDKs" -$vcLibsPackages = @( - @{ SdkFolder = "Microsoft.VCLibs"; FileTemplate = "Microsoft.VCLibs.{0}.14.00.appx" }, - @{ SdkFolder = "Microsoft.VCLibs.Desktop"; FileTemplate = "Microsoft.VCLibs.{0}.14.00.Desktop.appx" } -) - -foreach ($platform in $platformList) { - $canonicalArch = $archMap[$platform] - if (-not $canonicalArch) { continue } - - $targetArchDir = Join-Path $organizedDepsDir $canonicalArch - Ensure-Directory $targetArchDir - - foreach ($vcLib in $vcLibsPackages) { - $fileName = $vcLib.FileTemplate -f $canonicalArch - $destPath = Join-Path $targetArchDir $fileName - if (Test-Path $destPath) { continue } - - $sdkPath = Join-Path $vcLibsSdkBase "$($vcLib.SdkFolder)\14.0\Appx\Retail\$platform\$fileName" - if (Test-Path $sdkPath) { - Copy-Item $sdkPath -Destination $destPath - Write-Host " Copied VCLibs from SDK: $destPath" - } else { - Write-Host " Downloading $fileName for $platform..." - try { - Invoke-WebRequest -Uri "https://aka.ms/$fileName" -OutFile $destPath -UseBasicParsing - Write-Host " Downloaded VCLibs: $destPath" - } catch { - Write-Warning " Failed to download $fileName for ${platform}: $_" - } - } - } -} - -# --- Collect symbol files and clean up per-platform build folders --- - -foreach ($msix in $msixFiles) { - Get-ChildItem -Path $msix.DirectoryName -Filter "*.appxsym" -ErrorAction SilentlyContinue | ForEach-Object { - $symPlatform = $_.BaseName -replace '.*_(\w+)$','$1' - $newSymPath = Join-Path $bundleFolderPath "${BundleName}_${Version}_${symPlatform}.appxsym" - Move-Item $_.FullName $newSymPath -Force - Write-Host "Moved symbol file to: $newSymPath" - } -} - -Get-ChildItem -Path $AppxPackageDir -Filter "*.msixupload" -ErrorAction SilentlyContinue | - ForEach-Object { Remove-Item $_.FullName -Force; Write-Host "Removed per-platform upload: $($_.Name)" } - -foreach ($msix in $msixFiles) { - if (Test-Path $msix.DirectoryName) { - Remove-Item $msix.DirectoryName -Recurse -Force - Write-Host "Removed per-platform dir: $($msix.DirectoryName)" - } -} - -# --- Generate .msixupload for Store submissions --- - -if ($BuildMode -eq "StoreUpload") { - $uploadName = "${BundleName}_${Version}_${platforms}_bundle.msixupload" - $uploadPath = Join-Path $AppxPackageDir $uploadName - if (Test-Path $uploadPath) { Remove-Item $uploadPath -Force } - - Write-Host "Creating msixupload at: $uploadPath" - $zipPath = "$uploadPath.zip" - Compress-Archive -Path $organizedBundlePath -DestinationPath $zipPath -Force - Move-Item $zipPath $uploadPath -Force - Write-Host "Successfully created: $uploadPath" -} - -# --- Generate .appinstaller for sideload deployments --- - -if ($AppInstallerUri -ne "" -and ($BuildMode -eq "Sideload" -or $BuildMode -eq "SideloadOnly")) { - $appInstallerPath = Join-Path $AppxPackageDir "$BundleName.appinstaller" - - if ($PackageManifestPath -ne "" -and (Test-Path $PackageManifestPath)) { - [xml]$manifestXml = Get-Content $PackageManifestPath - $packageName = $manifestXml.Package.Identity.Name - $packagePublisher = $manifestXml.Package.Identity.Publisher - } else { - Write-Warning "PackageManifestPath not provided; falling back to BundleName for identity" - $packageName = $BundleName - $packagePublisher = "" - } - - $bundleUri = "${AppInstallerUri}${bundleFolder}/${organizedBundleName}" - - # Build dependency XML entries by reading each package's embedded manifest - $dependencyEntries = "" - if (Test-Path $organizedDepsDir) { - Add-Type -AssemblyName System.IO.Compression.FileSystem -ErrorAction SilentlyContinue - Get-ChildItem -Path $organizedDepsDir -Recurse -Include *.appx, *.msix | ForEach-Object { - $depArch = Split-Path (Split-Path $_.FullName -Parent) -Leaf - - $depZip = [System.IO.Compression.ZipFile]::OpenRead($_.FullName) - try { - $entry = $depZip.Entries | Where-Object { $_.FullName -eq "AppxManifest.xml" } | Select-Object -First 1 - if ($null -eq $entry) { return } - $reader = New-Object System.IO.StreamReader($entry.Open()) - [xml]$depManifest = $reader.ReadToEnd() - $reader.Close() - } finally { $depZip.Dispose() } - - $nsMgr = New-Object System.Xml.XmlNamespaceManager($depManifest.NameTable) - $nsMgr.AddNamespace("pkg", "http://schemas.microsoft.com/appx/manifest/foundation/windows10") - $id = $depManifest.SelectSingleNode("/pkg:Package/pkg:Identity", $nsMgr) - if ($null -eq $id) { return } - - $arch = $id.GetAttribute("ProcessorArchitecture") - if ([string]::IsNullOrEmpty($arch)) { $arch = $depArch } - $depUri = "${AppInstallerUri}${bundleFolder}/Dependencies/$depArch/$($_.Name)" - - $dependencyEntries += @" - - -"@ - } - } - - if ($dependencyEntries -eq "") { - Write-Warning "No dependency packages found" - } else { - Write-Host "Discovered dependencies:$dependencyEntries" - } - - @" - - - - $dependencyEntries - - -"@ | Set-Content -Path $appInstallerPath -Encoding UTF8 - - Write-Host "Created appinstaller at: $appInstallerPath" -} diff --git a/.github/scripts/Generate-SelfCertPfx.ps1 b/.github/scripts/Generate-SelfCertPfx.ps1 deleted file mode 100644 index 9856f8f481c7..000000000000 --- a/.github/scripts/Generate-SelfCertPfx.ps1 +++ /dev/null @@ -1,28 +0,0 @@ -# Copyright (c) Files Community -# SPDX-License-Identifier: MPL-2.0 - -# Abstract: -# This script generates a self-signed certificate for the temporary packaging as a pfx file. - -param( - [string]$Destination = "" -) - -$CertFriendlyName = "FilesApp_SelfSigned" -$CertPublisher = "CN=Files" -$CertStoreLocation = "Cert:\CurrentUser\My" - -# Generate self signed cert -$cert = New-SelfSignedCertificate ` - -Type Custom ` - -Subject $CertPublisher ` - -KeyUsage DigitalSignature ` - -FriendlyName $CertFriendlyName ` - -CertStoreLocation $CertStoreLocation ` - -TextExtension @("2.5.29.37={text}1.3.6.1.5.5.7.3.3", "2.5.29.19={text}") - -# Get size of the self signed cert -$certificateBytes = $cert.Export([System.Security.Cryptography.X509Certificates.X509ContentType]::Pkcs12) - -# Save the self signed cert as a file -[System.IO.File]::WriteAllBytes($Destination, $certificateBytes) \ No newline at end of file diff --git a/.github/workflows/cd-sideload-preview.yml b/.github/workflows/cd-sideload-preview.yml deleted file mode 100644 index 7abf63dd9b96..000000000000 --- a/.github/workflows/cd-sideload-preview.yml +++ /dev/null @@ -1,204 +0,0 @@ -# Copyright (c) Files Community -# Licensed under the MIT License. - -# Abstract: -# Deploys Files Preview (Sideload). -# -# Workflow: -# 1. Configure manifest, logo and secrets -# 2. Restore, build and package Files -# 3. Publish the appinstaller to files.community -# 4. Sign the package -# 5. Publish the package to Azure - -name: Files CD (Sideload Preview) - -on: - workflow_dispatch: - -jobs: - build: - runs-on: windows-2025-vs2026 - environment: Deployments - strategy: - fail-fast: false - matrix: - configuration: [Release] - platform: [x64] - env: - SOLUTION_NAME: 'Files.slnx' - CONFIGURATION: '${{ matrix.configuration }}' - PLATFORM: '${{ matrix.platform }}' - APPX_BUNDLE_PLATFORMS: 'x64|arm64' - WORKING_DIR: '${{ github.workspace }}' # D:\a\Files\Files\ - ARTIFACTS_STAGING_DIR: '${{ github.workspace }}\artifacts' - APPX_PACKAGE_DIR: '${{ github.workspace }}\artifacts\AppxPackages\' - APP_PROJECT_PATH: 'src\Files.App\Files.App.csproj' - PACKAGE_MANIFEST_PATH: 'src\Files.App\Package.appxmanifest' - LAUNCHER_PROJECT_PATH: 'src\Files.App.Launcher\Files.App.Launcher.vcxproj' - TEST_PROJECT_PATH: 'tests\Files.InteractionTests\Files.InteractionTests.csproj' - APP_INSTALLER_SIDELOAD_URL: 'https://cdn.files.community/files/preview/' - - steps: - - name: Checkout the repository - uses: actions/checkout@v6 - - name: Setup MSBuild - uses: microsoft/setup-msbuild@v3 - - name: Setup NuGet - uses: NuGet/setup-nuget@v3 - - name: Setup .NET - uses: actions/setup-dotnet@v5 - with: - global-json-file: global.json - - - name: Configure the package manifest, logo, and secrets - shell: pwsh - run: | - . './.github/scripts/Configure-AppxManifest.ps1' ` - -Branch "SideloadPreview" ` - -PackageManifestPath "$env:PACKAGE_MANIFEST_PATH" ` - -Publisher "$env:SIDELOAD_PUBLISHER_SECRET" ` - -WorkingDir "$env:WORKING_DIR" ` - -SecretBingMapsKey "$env:SECRET_BINGMAPS_KEY" ` - -SecretSentry "$env:SECRET_SENTRY" ` - -SecretGitHubOAuthClientId "$env:SECRET_GITHUB_OAUTH_CLIENT_ID" - env: - SIDELOAD_PUBLISHER_SECRET: ${{ secrets.SIDELOAD_PUBLISHER_SECRET }} - SECRET_BINGMAPS_KEY: ${{ secrets.BING_MAPS_SECRET }} - SECRET_SENTRY: ${{ secrets.SENTRY_SECRET }} - SECRET_GITHUB_OAUTH_CLIENT_ID: ${{ secrets.GH_OAUTH_CLIENT_ID }} - - - name: Restore Files - shell: pwsh - run: | - msbuild $env:SOLUTION_NAME ` - -t:Restore ` - -p:Platform=$env:PLATFORM ` - -p:Configuration=$env:CONFIGURATION ` - -p:PublishReadyToRun=true ` - -v:quiet - - - name: Restore NuGet Packages for Launcher Project - shell: pwsh - run: | - nuget restore "$env:LAUNCHER_PROJECT_PATH" ` - -SolutionDirectory "$env:WORKING_DIR" ` - -Verbosity detailed - - - name: Build launcher project - shell: pwsh - run: | - msbuild "$env:LAUNCHER_PROJECT_PATH" ` - -t:Build ` - -p:Platform=$env:PLATFORM ` - -p:Configuration=$env:CONFIGURATION ` - -v:quiet - - - name: Hide NuGet.Config from signing action - shell: pwsh - run: Move-Item NuGet.Config NuGet.Config.bak - - - name: Sign launcher EXE with Azure Trusted Signing - uses: Azure/artifact-signing-action@v1 - with: - azure-tenant-id: ${{ secrets.AZURE_TENANT_ID }} - azure-client-id: ${{ secrets.AZURE_CLIENT_ID }} - azure-client-secret: ${{ secrets.AZURE_CLIENT_SECRET }} - endpoint: https://eus.codesigning.azure.net/ - signing-account-name: ${{ secrets.SIGNING_ACCOUNT_NAME }} - certificate-profile-name: ${{ secrets.SIGNING_PROFILE_NAME }} - files-folder: ${{ github.workspace }}\src\Files.App\Assets\FilesOpenDialog - files-folder-filter: "*.exe" - files-folder-recurse: false - file-digest: SHA256 - timestamp-rfc3161: http://timestamp.acs.microsoft.com - timestamp-digest: SHA256 - - - name: Restore NuGet.Config - if: always() - shell: pwsh - run: Move-Item NuGet.Config.bak NuGet.Config - - - name: Build & package Files - shell: pwsh - run: | - $platforms = "$env:APPX_BUNDLE_PLATFORMS" -split '\|' - foreach ($plat in $platforms) { - Write-Host "Building for $plat..." - msbuild "$env:APP_PROJECT_PATH" ` - -t:Build ` - -p:Platform=$plat ` - -p:Configuration=$env:CONFIGURATION ` - -p:AppxPackageDir="$env:APPX_PACKAGE_DIR" ` - -p:AppxBundle=Never ` - -p:GenerateAppxPackageOnBuild=true ` - -p:UapAppxPackageBuildMode=Sideload ` - -v:quiet - } - env: - SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} - - - name: Upload debug symbols to Sentry - shell: pwsh - run: | - if (-not $env:SENTRY_AUTH_TOKEN) { Write-Host 'SENTRY_AUTH_TOKEN not set; skipping symbol upload'; exit 0 } - npm install --global @sentry/cli - sentry-cli debug-files upload --org files-org --project files-app src\Files.App\bin src\Files.App\obj - env: - SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} - - - name: Create msixbundle and appinstaller - shell: pwsh - run: | - . './.github/scripts/Create-MsixBundle.ps1' ` - -AppxPackageDir "$env:APPX_PACKAGE_DIR" ` - -BundleName "Files.Package" ` - -PackageManifestPath "$env:PACKAGE_MANIFEST_PATH" ` - -AppInstallerUri "$env:APP_INSTALLER_SIDELOAD_URL" ` - -BuildMode "Sideload" - - - name: Remove empty files from the packages - shell: bash - run: find $ARTIFACTS_STAGING_DIR -empty -delete - - - name: Hide NuGet.Config from signing action - shell: pwsh - run: Move-Item NuGet.Config NuGet.Config.bak - - - name: Sign Files with Azure Trusted Signing - uses: Azure/artifact-signing-action@v1 - with: - azure-tenant-id: ${{ secrets.AZURE_TENANT_ID }} - azure-client-id: ${{ secrets.AZURE_CLIENT_ID }} - azure-client-secret: ${{ secrets.AZURE_CLIENT_SECRET }} - endpoint: https://eus.codesigning.azure.net/ - signing-account-name: ${{ secrets.SIGNING_ACCOUNT_NAME }} - certificate-profile-name: ${{ secrets.SIGNING_PROFILE_NAME }} - files-folder: ${{ env.APPX_PACKAGE_DIR }} - files-folder-filter: msixbundle - files-folder-recurse: true - files-folder-depth: 4 - file-digest: SHA256 - timestamp-rfc3161: http://timestamp.acs.microsoft.com - timestamp-digest: SHA256 - - - name: Restore NuGet.Config - if: always() - shell: pwsh - run: Move-Item NuGet.Config.bak NuGet.Config - - - name: Upload packages to Cloudflare - uses: ryand56/r2-upload-action@latest - with: - r2-account-id: ${{ secrets.R2_ACCOUNT_ID }} - r2-access-key-id: ${{ secrets.R2_ACCESS_KEY_ID }} - r2-secret-access-key: ${{ secrets.R2_SECRET_ACCESS_KEY }} - r2-bucket: ${{ secrets.R2_BUCKET }} - source-dir: ${{ env.APPX_PACKAGE_DIR }} - destination-dir: ./files/preview - - - name: Upload the packages to GitHub Actions - uses: actions/upload-artifact@v7 - with: - name: 'Appx Packages (${{ env.CONFIGURATION }}, ${{ env.PLATFORM }})' - path: ${{ env.ARTIFACTS_STAGING_DIR }} diff --git a/.github/workflows/cd-sideload-stable.yml b/.github/workflows/cd-sideload-stable.yml deleted file mode 100644 index f97867e9d87e..000000000000 --- a/.github/workflows/cd-sideload-stable.yml +++ /dev/null @@ -1,204 +0,0 @@ -# Copyright (c) Files Community -# Licensed under the MIT License. - -# Abstract: -# Deploys Files (Sideload). -# -# Workflow: -# 1. Configure manifest, logo and secrets -# 2. Restore, build and package Files -# 3. Publish the appinstaller to files.community -# 4. Sign the package -# 5. Publish the package to Azure - -name: Files CD (Sideload Stable) - -on: - workflow_dispatch: - -jobs: - build: - runs-on: windows-2025-vs2026 - environment: Deployments - strategy: - fail-fast: false - matrix: - configuration: [Release] - platform: [x64] - env: - SOLUTION_NAME: 'Files.slnx' - CONFIGURATION: '${{ matrix.configuration }}' - PLATFORM: '${{ matrix.platform }}' - APPX_BUNDLE_PLATFORMS: 'x64|arm64' - WORKING_DIR: '${{ github.workspace }}' # D:\a\Files\Files\ - ARTIFACTS_STAGING_DIR: '${{ github.workspace }}\artifacts' - APPX_PACKAGE_DIR: '${{ github.workspace }}\artifacts\AppxPackages\' - APP_PROJECT_PATH: 'src\Files.App\Files.App.csproj' - PACKAGE_MANIFEST_PATH: 'src\Files.App\Package.appxmanifest' - LAUNCHER_PROJECT_PATH: 'src\Files.App.Launcher\Files.App.Launcher.vcxproj' - TEST_PROJECT_PATH: 'tests\Files.InteractionTests\Files.InteractionTests.csproj' - APP_INSTALLER_SIDELOAD_URL: 'https://cdn.files.community/files/stable/' - - steps: - - name: Checkout the repository - uses: actions/checkout@v6 - - name: Setup MSBuild - uses: microsoft/setup-msbuild@v3 - - name: Setup NuGet - uses: NuGet/setup-nuget@v3 - - name: Setup .NET - uses: actions/setup-dotnet@v5 - with: - global-json-file: global.json - - - name: Configure the package manifest, logo, and secrets - shell: pwsh - run: | - . './.github/scripts/Configure-AppxManifest.ps1' ` - -Branch "SideloadStable" ` - -PackageManifestPath "$env:PACKAGE_MANIFEST_PATH" ` - -Publisher "$env:SIDELOAD_PUBLISHER_SECRET" ` - -WorkingDir "$env:WORKING_DIR" ` - -SecretBingMapsKey "$env:SECRET_BINGMAPS_KEY" ` - -SecretSentry "$env:SECRET_SENTRY" ` - -SecretGitHubOAuthClientId "$env:SECRET_GITHUB_OAUTH_CLIENT_ID" - env: - SIDELOAD_PUBLISHER_SECRET: ${{ secrets.SIDELOAD_PUBLISHER_SECRET }} - SECRET_BINGMAPS_KEY: ${{ secrets.BING_MAPS_SECRET }} - SECRET_SENTRY: ${{ secrets.SENTRY_SECRET }} - SECRET_GITHUB_OAUTH_CLIENT_ID: ${{ secrets.GH_OAUTH_CLIENT_ID }} - - - name: Restore Files - shell: pwsh - run: | - msbuild $env:SOLUTION_NAME ` - -t:Restore ` - -p:Platform=$env:PLATFORM ` - -p:Configuration=$env:CONFIGURATION ` - -p:PublishReadyToRun=true ` - -v:quiet - - - name: Restore NuGet Packages for Launcher Project - shell: pwsh - run: | - nuget restore "$env:LAUNCHER_PROJECT_PATH" ` - -SolutionDirectory "$env:WORKING_DIR" ` - -Verbosity detailed - - - name: Build launcher project - shell: pwsh - run: | - msbuild "$env:LAUNCHER_PROJECT_PATH" ` - -t:Build ` - -p:Platform=$env:PLATFORM ` - -p:Configuration=$env:CONFIGURATION ` - -v:quiet - - - name: Hide NuGet.Config from signing action - shell: pwsh - run: Move-Item NuGet.Config NuGet.Config.bak - - - name: Sign launcher EXE with Azure Trusted Signing - uses: Azure/artifact-signing-action@v1 - with: - azure-tenant-id: ${{ secrets.AZURE_TENANT_ID }} - azure-client-id: ${{ secrets.AZURE_CLIENT_ID }} - azure-client-secret: ${{ secrets.AZURE_CLIENT_SECRET }} - endpoint: https://eus.codesigning.azure.net/ - signing-account-name: ${{ secrets.SIGNING_ACCOUNT_NAME }} - certificate-profile-name: ${{ secrets.SIGNING_PROFILE_NAME }} - files-folder: ${{ github.workspace }}\src\Files.App\Assets\FilesOpenDialog - files-folder-filter: "*.exe" - files-folder-recurse: false - file-digest: SHA256 - timestamp-rfc3161: http://timestamp.acs.microsoft.com - timestamp-digest: SHA256 - - - name: Restore NuGet.Config - if: always() - shell: pwsh - run: Move-Item NuGet.Config.bak NuGet.Config - - - name: Build & package Files - shell: pwsh - run: | - $platforms = "$env:APPX_BUNDLE_PLATFORMS" -split '\|' - foreach ($plat in $platforms) { - Write-Host "Building for $plat..." - msbuild "$env:APP_PROJECT_PATH" ` - -t:Build ` - -p:Platform=$plat ` - -p:Configuration=$env:CONFIGURATION ` - -p:AppxPackageDir="$env:APPX_PACKAGE_DIR" ` - -p:AppxBundle=Never ` - -p:GenerateAppxPackageOnBuild=true ` - -p:UapAppxPackageBuildMode=Sideload ` - -v:quiet - } - env: - SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} - - - name: Upload debug symbols to Sentry - shell: pwsh - run: | - if (-not $env:SENTRY_AUTH_TOKEN) { Write-Host 'SENTRY_AUTH_TOKEN not set; skipping symbol upload'; exit 0 } - npm install --global @sentry/cli - sentry-cli debug-files upload --org files-org --project files-app src\Files.App\bin src\Files.App\obj - env: - SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} - - - name: Create msixbundle and appinstaller - shell: pwsh - run: | - . './.github/scripts/Create-MsixBundle.ps1' ` - -AppxPackageDir "$env:APPX_PACKAGE_DIR" ` - -BundleName "Files.Package" ` - -PackageManifestPath "$env:PACKAGE_MANIFEST_PATH" ` - -AppInstallerUri "$env:APP_INSTALLER_SIDELOAD_URL" ` - -BuildMode "Sideload" - - - name: Remove empty files from the packages - shell: bash - run: find $ARTIFACTS_STAGING_DIR -empty -delete - - - name: Hide NuGet.Config from signing action - shell: pwsh - run: Move-Item NuGet.Config NuGet.Config.bak - - - name: Sign Files with Azure Trusted Signing - uses: Azure/artifact-signing-action@v1 - with: - azure-tenant-id: ${{ secrets.AZURE_TENANT_ID }} - azure-client-id: ${{ secrets.AZURE_CLIENT_ID }} - azure-client-secret: ${{ secrets.AZURE_CLIENT_SECRET }} - endpoint: https://eus.codesigning.azure.net/ - signing-account-name: ${{ secrets.SIGNING_ACCOUNT_NAME }} - certificate-profile-name: ${{ secrets.SIGNING_PROFILE_NAME }} - files-folder: ${{ env.APPX_PACKAGE_DIR }} - files-folder-filter: msixbundle - files-folder-recurse: true - files-folder-depth: 4 - file-digest: SHA256 - timestamp-rfc3161: http://timestamp.acs.microsoft.com - timestamp-digest: SHA256 - - - name: Restore NuGet.Config - if: always() - shell: pwsh - run: Move-Item NuGet.Config.bak NuGet.Config - - - name: Upload packages to Cloudflare - uses: ryand56/r2-upload-action@latest - with: - r2-account-id: ${{ secrets.R2_ACCOUNT_ID }} - r2-access-key-id: ${{ secrets.R2_ACCESS_KEY_ID }} - r2-secret-access-key: ${{ secrets.R2_SECRET_ACCESS_KEY }} - r2-bucket: ${{ secrets.R2_BUCKET }} - source-dir: ${{ env.APPX_PACKAGE_DIR }} - destination-dir: ./files/stable - - - name: Upload the packages to GitHub Actions - uses: actions/upload-artifact@v7 - with: - name: 'Appx Packages (${{ env.CONFIGURATION }}, ${{ env.PLATFORM }})' - path: ${{ env.ARTIFACTS_STAGING_DIR }} diff --git a/.github/workflows/cd-store-preview.yml b/.github/workflows/cd-store-preview.yml deleted file mode 100644 index 8c3694e0b7e9..000000000000 --- a/.github/workflows/cd-store-preview.yml +++ /dev/null @@ -1,163 +0,0 @@ -# Copyright (c) Files Community -# Licensed under the MIT License. - -# Abstract: -# Deploys Files Preview (Store). -# -# Workflow: -# 1. Configure manifest, logo and secrets -# 2. Restore, build and package Files -# 3. Generate a msixupload file -# 4. Publish the msixupload to GitHub Actions - -name: Files CD (Store Preview) - -on: - workflow_dispatch: - -jobs: - build: - runs-on: windows-2025-vs2026 - environment: Deployments - strategy: - fail-fast: false - matrix: - configuration: [Release] - platform: [x64] - env: - SOLUTION_NAME: 'Files.slnx' - CONFIGURATION: '${{ matrix.configuration }}' - PLATFORM: '${{ matrix.platform }}' - APPX_BUNDLE_PLATFORMS: 'x64|arm64' - WORKING_DIR: '${{ github.workspace }}' # D:\a\Files\Files\ - ARTIFACTS_STAGING_DIR: '${{ github.workspace }}\artifacts' - APPX_PACKAGE_DIR: '${{ github.workspace }}\artifacts\AppxPackages\' - APP_PROJECT_PATH: '${{ github.workspace }}\src\Files.App\Files.App.csproj' - PACKAGE_MANIFEST_PATH: '${{ github.workspace }}\src\Files.App\Package.appxmanifest' - LAUNCHER_PROJECT_PATH: 'src\Files.App.Launcher\Files.App.Launcher.vcxproj' - - steps: - - name: Checkout the repository - uses: actions/checkout@v6 - - name: Setup MSBuild - uses: microsoft/setup-msbuild@v3 - - name: Setup NuGet - uses: NuGet/setup-nuget@v3 - - name: Setup .NET - uses: actions/setup-dotnet@v5 - with: - global-json-file: global.json - - - name: Configure the package manifest, logo, and secrets - shell: pwsh - run: | - . './.github/scripts/Configure-AppxManifest.ps1' ` - -Branch "StorePreview" ` - -PackageManifestPath "$env:PACKAGE_MANIFEST_PATH" ` - -Publisher "$env:STORE_PUBLISHER_SECRET" ` - -WorkingDir "$env:WORKING_DIR" ` - -SecretBingMapsKey "$env:SECRET_BINGMAPS_KEY" ` - -SecretSentry "$env:SECRET_SENTRY" ` - -SecretGitHubOAuthClientId "$env:SECRET_GITHUB_OAUTH_CLIENT_ID" - env: - STORE_PUBLISHER_SECRET: ${{ secrets.STORE_PUBLISHER_SECRET }} - SECRET_BINGMAPS_KEY: ${{ secrets.BING_MAPS_SECRET }} - SECRET_SENTRY: ${{ secrets.SENTRY_SECRET }} - SECRET_GITHUB_OAUTH_CLIENT_ID: ${{ secrets.GH_OAUTH_CLIENT_ID }} - - - name: Restore Files - shell: pwsh - run: | - msbuild $env:SOLUTION_NAME ` - -t:Restore ` - -p:Platform=$env:PLATFORM ` - -p:Configuration=$env:CONFIGURATION ` - -p:PublishReadyToRun=true ` - -v:quiet - - - name: Restore NuGet Packages for Launcher Project - shell: pwsh - run: | - nuget restore "$env:LAUNCHER_PROJECT_PATH" ` - -SolutionDirectory "$env:WORKING_DIR" ` - -Verbosity detailed - - - name: Build launcher project - shell: pwsh - run: | - msbuild "$env:LAUNCHER_PROJECT_PATH" ` - -t:Build ` - -p:Platform=$env:PLATFORM ` - -p:Configuration=$env:CONFIGURATION ` - -v:quiet - - - name: Hide NuGet.Config from signing action - shell: pwsh - run: Move-Item NuGet.Config NuGet.Config.bak - - - name: Sign launcher EXE with Azure Trusted Signing - uses: Azure/artifact-signing-action@v1 - with: - azure-tenant-id: ${{ secrets.AZURE_TENANT_ID }} - azure-client-id: ${{ secrets.AZURE_CLIENT_ID }} - azure-client-secret: ${{ secrets.AZURE_CLIENT_SECRET }} - endpoint: https://eus.codesigning.azure.net/ - signing-account-name: ${{ secrets.SIGNING_ACCOUNT_NAME }} - certificate-profile-name: ${{ secrets.SIGNING_PROFILE_NAME }} - files-folder: ${{ github.workspace }}\src\Files.App\Assets\FilesOpenDialog - files-folder-filter: "*.exe" - files-folder-recurse: false - file-digest: SHA256 - timestamp-rfc3161: http://timestamp.acs.microsoft.com - timestamp-digest: SHA256 - - - name: Restore NuGet.Config - if: always() - shell: pwsh - run: Move-Item NuGet.Config.bak NuGet.Config - - - name: Build & package Files - shell: pwsh - run: | - $platforms = "$env:APPX_BUNDLE_PLATFORMS" -split '\|' - foreach ($plat in $platforms) { - Write-Host "Building for $plat..." - msbuild "$env:APP_PROJECT_PATH" ` - -t:Build ` - -p:Platform=$plat ` - -p:Configuration=$env:CONFIGURATION ` - -p:AppxPackageDir="$env:APPX_PACKAGE_DIR" ` - -p:AppxBundle=Never ` - -p:GenerateAppxPackageOnBuild=true ` - -p:UapAppxPackageBuildMode=StoreUpload ` - -v:quiet - } - env: - SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} - - - name: Upload debug symbols to Sentry - shell: pwsh - run: | - if (-not $env:SENTRY_AUTH_TOKEN) { Write-Host 'SENTRY_AUTH_TOKEN not set; skipping symbol upload'; exit 0 } - npm install --global @sentry/cli - sentry-cli debug-files upload --org files-org --project files-app src\Files.App\bin src\Files.App\obj - env: - SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} - - - name: Create msixbundle and msixupload - shell: pwsh - run: | - . './.github/scripts/Create-MsixBundle.ps1' ` - -AppxPackageDir "$env:APPX_PACKAGE_DIR" ` - -BundleName "Files.Package" ` - -BuildMode "StoreUpload" - - - name: Remove empty files from the packages - shell: bash - run: find $ARTIFACTS_STAGING_DIR -empty -delete - - - name: Upload the packages to GitHub Actions - uses: actions/upload-artifact@v7 - with: - archive: false - path: ${{ env.APPX_PACKAGE_DIR }}*.msixupload diff --git a/.github/workflows/cd-store-stable.yml b/.github/workflows/cd-store-stable.yml deleted file mode 100644 index 088bdd41af05..000000000000 --- a/.github/workflows/cd-store-stable.yml +++ /dev/null @@ -1,163 +0,0 @@ -# Copyright (c) Files Community -# Licensed under the MIT License. - -# Abstract: -# Deploys Files (Store). -# -# Workflow: -# 1. Configure manifest, logo and secrets -# 2. Restore, build and package Files -# 3. Generate a msixupload file -# 4. Publish the msixupload to GitHub Actions - -name: Files CD (Store Stable) - -on: - workflow_dispatch: - -jobs: - build: - runs-on: windows-2025-vs2026 - environment: Deployments - strategy: - fail-fast: false - matrix: - configuration: [Release] - platform: [x64] - env: - SOLUTION_NAME: 'Files.slnx' - CONFIGURATION: '${{ matrix.configuration }}' - PLATFORM: '${{ matrix.platform }}' - APPX_BUNDLE_PLATFORMS: 'x64|arm64' - WORKING_DIR: '${{ github.workspace }}' # D:\a\Files\Files\ - ARTIFACTS_STAGING_DIR: '${{ github.workspace }}\artifacts' - APPX_PACKAGE_DIR: '${{ github.workspace }}\artifacts\AppxPackages\' - APP_PROJECT_PATH: '${{ github.workspace }}\src\Files.App\Files.App.csproj' - PACKAGE_MANIFEST_PATH: '${{ github.workspace }}\src\Files.App\Package.appxmanifest' - LAUNCHER_PROJECT_PATH: 'src\Files.App.Launcher\Files.App.Launcher.vcxproj' - - steps: - - name: Checkout the repository - uses: actions/checkout@v6 - - name: Setup MSBuild - uses: microsoft/setup-msbuild@v3 - - name: Setup NuGet - uses: NuGet/setup-nuget@v3 - - name: Setup .NET - uses: actions/setup-dotnet@v5 - with: - global-json-file: global.json - - - name: Configure the package manifest, logo, and secrets - shell: pwsh - run: | - . './.github/scripts/Configure-AppxManifest.ps1' ` - -Branch "StoreStable" ` - -PackageManifestPath "$env:PACKAGE_MANIFEST_PATH" ` - -Publisher "$env:STORE_PUBLISHER_SECRET" ` - -WorkingDir "$env:WORKING_DIR" ` - -SecretBingMapsKey "$env:SECRET_BINGMAPS_KEY" ` - -SecretSentry "$env:SECRET_SENTRY" ` - -SecretGitHubOAuthClientId "$env:SECRET_GITHUB_OAUTH_CLIENT_ID" - env: - STORE_PUBLISHER_SECRET: ${{ secrets.STORE_PUBLISHER_SECRET }} - SECRET_BINGMAPS_KEY: ${{ secrets.BING_MAPS_SECRET }} - SECRET_SENTRY: ${{ secrets.SENTRY_SECRET }} - SECRET_GITHUB_OAUTH_CLIENT_ID: ${{ secrets.GH_OAUTH_CLIENT_ID }} - - - name: Restore Files - shell: pwsh - run: | - msbuild $env:SOLUTION_NAME ` - -t:Restore ` - -p:Platform=$env:PLATFORM ` - -p:Configuration=$env:CONFIGURATION ` - -p:PublishReadyToRun=true ` - -v:quiet - - - name: Restore NuGet Packages for Launcher Project - shell: pwsh - run: | - nuget restore "$env:LAUNCHER_PROJECT_PATH" ` - -SolutionDirectory "$env:WORKING_DIR" ` - -Verbosity detailed - - - name: Build launcher project - shell: pwsh - run: | - msbuild "$env:LAUNCHER_PROJECT_PATH" ` - -t:Build ` - -p:Platform=$env:PLATFORM ` - -p:Configuration=$env:CONFIGURATION ` - -v:quiet - - - name: Hide NuGet.Config from signing action - shell: pwsh - run: Move-Item NuGet.Config NuGet.Config.bak - - - name: Sign launcher EXE with Azure Trusted Signing - uses: Azure/artifact-signing-action@v1 - with: - azure-tenant-id: ${{ secrets.AZURE_TENANT_ID }} - azure-client-id: ${{ secrets.AZURE_CLIENT_ID }} - azure-client-secret: ${{ secrets.AZURE_CLIENT_SECRET }} - endpoint: https://eus.codesigning.azure.net/ - signing-account-name: ${{ secrets.SIGNING_ACCOUNT_NAME }} - certificate-profile-name: ${{ secrets.SIGNING_PROFILE_NAME }} - files-folder: ${{ github.workspace }}\src\Files.App\Assets\FilesOpenDialog - files-folder-filter: "*.exe" - files-folder-recurse: false - file-digest: SHA256 - timestamp-rfc3161: http://timestamp.acs.microsoft.com - timestamp-digest: SHA256 - - - name: Restore NuGet.Config - if: always() - shell: pwsh - run: Move-Item NuGet.Config.bak NuGet.Config - - - name: Build & package Files - shell: pwsh - run: | - $platforms = "$env:APPX_BUNDLE_PLATFORMS" -split '\|' - foreach ($plat in $platforms) { - Write-Host "Building for $plat..." - msbuild "$env:APP_PROJECT_PATH" ` - -t:Build ` - -p:Platform=$plat ` - -p:Configuration=$env:CONFIGURATION ` - -p:AppxPackageDir="$env:APPX_PACKAGE_DIR" ` - -p:AppxBundle=Never ` - -p:GenerateAppxPackageOnBuild=true ` - -p:UapAppxPackageBuildMode=StoreUpload ` - -v:quiet - } - env: - SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} - - - name: Upload debug symbols to Sentry - shell: pwsh - run: | - if (-not $env:SENTRY_AUTH_TOKEN) { Write-Host 'SENTRY_AUTH_TOKEN not set; skipping symbol upload'; exit 0 } - npm install --global @sentry/cli - sentry-cli debug-files upload --org files-org --project files-app src\Files.App\bin src\Files.App\obj - env: - SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} - - - name: Create msixbundle and msixupload - shell: pwsh - run: | - . './.github/scripts/Create-MsixBundle.ps1' ` - -AppxPackageDir "$env:APPX_PACKAGE_DIR" ` - -BundleName "Files.Package" ` - -BuildMode "StoreUpload" - - - name: Remove empty files from the packages - shell: bash - run: find $ARTIFACTS_STAGING_DIR -empty -delete - - - name: Upload the packages to GitHub Actions - uses: actions/upload-artifact@v7 - with: - archive: false - path: ${{ env.APPX_PACKAGE_DIR }}*.msixupload diff --git a/.github/workflows/ci-windows.yml b/.github/workflows/ci-windows.yml deleted file mode 100644 index b563d9633ecb..000000000000 --- a/.github/workflows/ci-windows.yml +++ /dev/null @@ -1,81 +0,0 @@ -# Copyright (c) Files Community -# Licensed under the MIT License. - -# Abstract: -# This CI builds Files on Windows for forks only (it is skipped on the -# files-community organization, where ci.yml already runs). It is executed -# manually only (workflow_dispatch): the port is Linux-first for now. -# It only compiles the app (Release | x64): MSIX packaging, signing -# certificates, bundle-size reporting and interaction tests from ci.yml are -# intentionally left out. Packaging is disabled with AppxBundle=Never and -# GenerateAppxPackageOnBuild=false, as in the non-Release legs of ci.yml. -# It is skipped if files not directly related to source code maintenance -# are updated. - -name: Files CI (Windows fork) - -on: - workflow_dispatch: - -run-name: ${{ github.event_name == 'pull_request' && 'Files Windows PR Validation' || 'Files Windows CI Validation' }} - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -permissions: - contents: read - -env: - SOLUTION_PATH: '${{ github.workspace }}\Files.slnx' - APP_PROJECT_PATH: '${{ github.workspace }}\src\Files.App\Files.App.csproj' - -jobs: - - build-windows: - - if: github.repository_owner != 'files-community' - - runs-on: windows-2025-vs2026 - strategy: - fail-fast: false - matrix: - configuration: [Release] - platform: [x64] - env: - CONFIGURATION: ${{ matrix.configuration }} - ARCHITECTURE: ${{ matrix.platform }} - - steps: - - - name: Checkout the repository - uses: actions/checkout@v6 - - name: Setup MSBuild - uses: microsoft/setup-msbuild@v3 - - name: Setup NuGet - uses: NuGet/setup-nuget@v3 - - name: Setup .NET - uses: actions/setup-dotnet@v5 - with: - global-json-file: global.json - - - name: Restore Files - shell: pwsh - run: | - msbuild $env:SOLUTION_PATH ` - -t:Restore ` - -p:Platform=$env:ARCHITECTURE ` - -p:Configuration=$env:CONFIGURATION ` - -p:PublishReadyToRun=true ` - -v:quiet - - - name: Build Files - run: | - msbuild ` - $env:APP_PROJECT_PATH ` - -t:Build ` - -p:Configuration=$env:CONFIGURATION ` - -p:Platform=$env:ARCHITECTURE ` - -p:AppxBundle=Never ` - -p:GenerateAppxPackageOnBuild=false ` - -v:quiet diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 420b45d7923c..000000000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,370 +0,0 @@ -# Copyright (c) Files Community -# Licensed under the MIT License. - -# Abstract: -# Windows CI for the upstream WinUI build. Manual only: this fork is Linux-first (see ci-linux.yml). - -name: Files CI - -on: - workflow_dispatch: - -run-name: ${{ github.event_name == 'pull_request' && 'Files PR Validation' || 'Files CI Validation' }} - -env: - WORKING_DIR: ${{ github.workspace }} # Default: 'D:\a\Files\Files' - SOLUTION_PATH: '${{ github.workspace }}\Files.slnx' - APP_PROJECT_PATH: '${{ github.workspace }}\src\Files.App\Files.App.csproj' - AUTOMATED_TESTS_ARCHITECTURE: 'x64' - AUTOMATED_TESTS_CONFIGURATION: 'Release' - AUTOMATED_TESTS_PROJECT_DIR: '${{ github.workspace }}\tests\Files.InteractionTests' - AUTOMATED_TESTS_PROJECT_PATH: '${{ github.workspace }}\tests\Files.InteractionTests\Files.InteractionTests.csproj' - AUTOMATED_TESTS_ASSEMBLY_DIR: '${{ github.workspace }}\artifacts\TestsAssembly' - ARTIFACTS_STAGING_DIR: '${{ github.workspace }}\artifacts' - APPX_PACKAGE_DIR: '${{ github.workspace }}\artifacts\AppxPackages\' - APPX_SELFSIGNED_CERT_PATH: '${{ github.workspace }}\.github\workflows\FilesApp_SelfSigned.pfx' - -jobs: - - check-formatting: - - if: github.repository_owner == 'files-community' - - runs-on: windows-2025-vs2026 - - steps: - - - name: Checkout the repository - uses: actions/checkout@v6 - with: - fetch-depth: 2 - - name: Setup .NET - uses: actions/setup-dotnet@v5 - - - name: Install XamlStyler.Console - run: 'dotnet tool install --global XamlStyler.Console' - - - name: Check XAML formatting - id: check-step - run: | - $changedFiles = (git diff --diff-filter=d --name-only HEAD~1) -split "\n" | Where-Object {$_ -like "*.xaml"} - foreach ($file in $changedFiles) - { - xstyler -p -l None -f $file - if ($LASTEXITCODE -ne 0) - { - echo "::error file=$file::Format check failed" - } - } - continue-on-error: true - - - name: Fail if necessary - if: steps.check-step.outcome == 'failure' - run: exit 1 - - build: - - if: github.repository_owner == 'files-community' - - runs-on: windows-2025-vs2026 - strategy: - fail-fast: false - matrix: - configuration: [Debug, Release] - platform: [x64, arm64] - env: - CONFIGURATION: ${{ matrix.configuration }} - ARCHITECTURE: ${{ matrix.platform }} - - steps: - - - name: Checkout the repository - uses: actions/checkout@v6 - - name: Setup MSBuild - uses: microsoft/setup-msbuild@v3 - - name: Setup NuGet - uses: NuGet/setup-nuget@v3 - - name: Setup .NET - uses: actions/setup-dotnet@v5 - with: - global-json-file: global.json - - - name: Restore Files - shell: pwsh - run: | - msbuild $env:SOLUTION_PATH ` - -t:Restore ` - -p:Platform=$env:ARCHITECTURE ` - -p:Configuration=$env:CONFIGURATION ` - -p:PublishReadyToRun=true ` - -v:quiet - - - if: env.CONFIGURATION != env.AUTOMATED_TESTS_CONFIGURATION - name: Build Files - run: | - msbuild ` - $env:APP_PROJECT_PATH ` - -t:Build ` - -p:Configuration=$env:CONFIGURATION ` - -p:Platform=$env:ARCHITECTURE ` - -p:AppxBundle=Never ` - -p:GenerateAppxPackageOnBuild=false ` - -v:quiet - - - if: env.CONFIGURATION == env.AUTOMATED_TESTS_CONFIGURATION && env.ARCHITECTURE == env.AUTOMATED_TESTS_ARCHITECTURE - name: Create self signed cert as a pfx file - run: ./.github/scripts/Generate-SelfCertPfx.ps1 -Destination "$env:APPX_SELFSIGNED_CERT_PATH" - - - if: env.CONFIGURATION == env.AUTOMATED_TESTS_CONFIGURATION && env.ARCHITECTURE == env.AUTOMATED_TESTS_ARCHITECTURE - name: Build & package Files - run: | - msbuild ` - $env:APP_PROJECT_PATH ` - -t:Build ` - -p:Configuration=$env:CONFIGURATION ` - -p:Platform=$env:ARCHITECTURE ` - -p:AppxBundlePlatforms=$env:AUTOMATED_TESTS_ARCHITECTURE ` - -p:AppxBundle=Always ` - -p:GenerateAppxPackageOnBuild=true ` - -p:UapAppxPackageBuildMode=SideloadOnly ` - -p:AppxPackageDir=$env:APPX_PACKAGE_DIR ` - -p:AppxPackageSigningEnabled=true ` - -p:PackageCertificateKeyFile=$env:APPX_SELFSIGNED_CERT_PATH ` - -p:PackageCertificatePassword="" ` - -p:PackageCertificateThumbprint="" ` - -v:quiet - - - if: env.CONFIGURATION == env.AUTOMATED_TESTS_CONFIGURATION && env.ARCHITECTURE != env.AUTOMATED_TESTS_ARCHITECTURE - name: Package Files - run: | - msbuild ` - $env:APP_PROJECT_PATH ` - -t:Build ` - -p:Configuration=$env:CONFIGURATION ` - -p:Platform=$env:ARCHITECTURE ` - -p:AppxBundlePlatforms=$env:ARCHITECTURE ` - -p:AppxBundle=Always ` - -p:GenerateAppxPackageOnBuild=true ` - -p:UapAppxPackageBuildMode=SideloadOnly ` - -p:AppxPackageDir=$env:APPX_PACKAGE_DIR ` - -p:AppxPackageSigningEnabled=false ` - -v:quiet - - - if: env.CONFIGURATION == env.AUTOMATED_TESTS_CONFIGURATION - name: Measure MSIX package size - shell: pwsh - run: | - $packages = Get-ChildItem $env:APPX_PACKAGE_DIR -Recurse -Include *.msixbundle, *.msix | - Where-Object { $_.DirectoryName -notmatch '\\Dependencies\\' } - - $totalBytes = 0 - foreach ($package in $packages) - { - Write-Host "$($package.Name): $([math]::Round($package.Length / 1MB, 2)) MB" - $totalBytes += $package.Length - } - - # Persist this architecture's total so the bundle-size job can sum across legs - New-Item -ItemType Directory -Force -Path $env:ARTIFACTS_STAGING_DIR | Out-Null - "$totalBytes" | Out-File -FilePath (Join-Path $env:ARTIFACTS_STAGING_DIR "msix-size-$env:ARCHITECTURE.txt") - - - if: env.CONFIGURATION == env.AUTOMATED_TESTS_CONFIGURATION - name: Upload MSIX size - uses: actions/upload-artifact@v7 - with: - name: 'msix-size-${{ env.ARCHITECTURE }}' - path: ${{ env.ARTIFACTS_STAGING_DIR }}\msix-size-${{ env.ARCHITECTURE }}.txt - - - if: env.ARCHITECTURE == env.AUTOMATED_TESTS_ARCHITECTURE && env.CONFIGURATION == env.AUTOMATED_TESTS_CONFIGURATION - name: Build interaction tests - run: | - msbuild $env:AUTOMATED_TESTS_PROJECT_PATH ` - -t:Build ` - -p:Configuration=$env:CONFIGURATION ` - -p:Platform=$env:AUTOMATED_TESTS_ARCHITECTURE ` - -v:quiet - - - if: env.ARCHITECTURE == env.AUTOMATED_TESTS_ARCHITECTURE && env.CONFIGURATION == env.AUTOMATED_TESTS_CONFIGURATION - name: Copy tests bin to the artifacts dir - shell: pwsh - run: | - Copy-Item ` - -Path "$env:AUTOMATED_TESTS_PROJECT_DIR\bin" ` - -Destination "$env:AUTOMATED_TESTS_ASSEMBLY_DIR" -Recurse - # Copy the self-signed cert so the test job can trust it - Copy-Item -Path "$env:APPX_SELFSIGNED_CERT_PATH" -Destination "$env:ARTIFACTS_STAGING_DIR" - - - if: env.ARCHITECTURE == env.AUTOMATED_TESTS_ARCHITECTURE && env.CONFIGURATION == env.AUTOMATED_TESTS_CONFIGURATION - name: Upload the packages to the Artifacts - uses: actions/upload-artifact@v7 - with: - name: 'Appx Packages (${{ env.CONFIGURATION }}, ${{ env.ARCHITECTURE }})' - path: ${{ env.ARTIFACTS_STAGING_DIR }} - - report-bundle-size: - - if: github.repository_owner == 'files-community' - - needs: [build] - runs-on: windows-2025-vs2026 - - steps: - - - name: Download MSIX sizes - uses: actions/download-artifact@v8 - with: - pattern: msix-size-* - merge-multiple: true - path: ${{ github.workspace }}\sizes - - - name: Sum bundle size - shell: pwsh - run: | - $total = 0 - $rows = @() - foreach ($file in Get-ChildItem "$env:WORKING_DIR\sizes" -Filter *.txt) - { - $arch = $file.BaseName -replace '^msix-size-', '' - $bytes = [long]((Get-Content $file.FullName -Raw).Trim()) - $total += $bytes - $rows += "| $arch | $([math]::Round($bytes / 1MB, 2)) MB |" - } - - "## Total bundle size" | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Append - "" | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Append - "| Architecture | Size |" | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Append - "| :--- | ---: |" | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Append - $rows | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Append - "| **Bundle total** | **$([math]::Round($total / 1MB, 2)) MB** |" | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Append - Write-Host "Bundle total: $([math]::Round($total / 1MB, 2)) MB" - - test: - - if: github.repository_owner == 'files-community' && always() - - needs: [build] - runs-on: windows-2025-vs2026 - strategy: - fail-fast: false - matrix: - configuration: [Release] - platform: [x64] - env: - CONFIGURATION: ${{ matrix.configuration }} - permissions: - contents: read - pull-requests: write - - steps: - - - if: contains(join(needs.*.result, ','), 'failure') - name: Fail if necessary - run: exit 1 - - - name: Checkout the repository - uses: actions/checkout@v6 - - name: Setup .NET - uses: actions/setup-dotnet@v5 - with: - global-json-file: global.json - - - name: Download the packages from the Artifacts - uses: actions/download-artifact@v8 - with: - name: 'Appx Packages (${{ env.CONFIGURATION }}, ${{ env.AUTOMATED_TESTS_ARCHITECTURE }})' - path: ${{ env.ARTIFACTS_STAGING_DIR }} - - - name: Install Files - shell: powershell - run: | - # Trust the self-signed certificate - Import-PfxCertificate ` - -FilePath (Join-Path $env:ARTIFACTS_STAGING_DIR "FilesApp_SelfSigned.pfx") ` - -CertStoreLocation Cert:\LocalMachine\Root ` - -Password (New-Object System.Security.SecureString) - - # Install Windows App Runtime matching the SDK NuGet — pin to the exact version because - # aka.ms/windowsappsdk//latest can lag behind the latest servicing release, - # leaving the runtime below the package's MinVersion and failing Add-AppxPackage with 0x80073CF3. - [xml]$pkgProps = Get-Content "$env:WORKING_DIR\Directory.Packages.props" - $sdkVer = ($pkgProps.Project.ItemGroup.PackageVersion | Where-Object Include -eq 'Microsoft.WindowsAppSDK').Version - $majorMinor = ($sdkVer -split '\.')[0..1] -join '.' - $installer = Join-Path $env:TEMP "windowsappruntimeinstall-x64.exe" - Invoke-WebRequest -Uri "https://aka.ms/windowsappsdk/$majorMinor/$sdkVer/windowsappruntimeinstall-x64.exe" -OutFile $installer - Start-Process $installer -ArgumentList "--quiet","--force" -Wait -NoNewWindow - - # Install the app package (with any sideload dependencies) - $pkg = Get-ChildItem $env:APPX_PACKAGE_DIR -Recurse -Include *.msixbundle, *.msix | - Where-Object { $_.DirectoryName -notmatch '\\Dependencies\\' } | Select-Object -First 1 - $deps = @(Get-ChildItem $env:APPX_PACKAGE_DIR -Recurse -Filter *.appx | - Where-Object { $_.DirectoryName -match '\\Dependencies\\' } | ForEach-Object { $_.FullName }) - if ($deps.Count -gt 0) { - Add-AppxPackage -Path $pkg.FullName -DependencyPath $deps - } else { - Add-AppxPackage -Path $pkg.FullName - } - - - name: Set full HD resolution - run: Set-DisplayResolution -Width 1920 -Height 1080 -Force - - # Appium drives the tests and starts the WinAppDriver installed on the runner itself - - name: Install Appium - shell: pwsh - run: | - npm install --global appium@3 - appium driver install --source=npm appium-windows-driver@6 - - - name: Start Appium server - shell: pwsh - run: Start-Process -FilePath "appium.cmd" -ArgumentList "--log","$env:AUTOMATED_TESTS_ASSEMBLY_DIR\appium.log" - - # Retry integration tests if first attempt fails - - name: Run interaction tests - uses: nick-fields/retry@v4 - with: - timeout_minutes: 20 - max_attempts: 3 - shell: pwsh - command: | - dotnet test ` - --test-modules **\Files.InteractionTests.dll ` - --root-directory $env:AUTOMATED_TESTS_ASSEMBLY_DIR ` - --results-directory $env:AUTOMATED_TESTS_ASSEMBLY_DIR ` - --report-trx ` - --report-trx-filename testResults.trx - - - if: github.event_name == 'pull_request' - uses: geekyeggo/delete-artifact@v6 - with: - name: '*' - - # Uploaded after the cleanup step above so a failed run keeps its diagnostics - - if: failure() - name: Upload the test diagnostics to the Artifacts - uses: actions/upload-artifact@v7 - with: - name: 'Test Diagnostics (${{ env.CONFIGURATION }}, ${{ env.AUTOMATED_TESTS_ARCHITECTURE }})' - if-no-files-found: warn - path: | - ${{ env.AUTOMATED_TESTS_ASSEMBLY_DIR }}\appium.log - ${{ env.AUTOMATED_TESTS_ASSEMBLY_DIR }}\testResults.trx - - # - name: Generate markdown from the tests result - # shell: pwsh - # run: | - # . './scripts/Convert-TrxToMarkdown.ps1' ` - # -Source "$env:AUTOMATED_TESTS_ASSEMBLY_DIR\testResults.trx" ` - # -Destination "$env:AUTOMATED_TESTS_ASSEMBLY_DIR\testResults.md" - # env: - # PULL_REQUEST_ID: ${{ github.event.pull_request_id }} - - # - name: Display the markdown on the output (temp) - # shell: pwsh - # run: | - # Get-Content $env:AUTOMATED_TESTS_ASSEMBLY_DIR\testResults.md - - # - name: Publish tests result - # uses: marocchino/sticky-pull-request-comment@v2 - # with: - # header: test-result - # path: '${{ env.AUTOMATED_TESTS_ASSEMBLY_DIR }}\testResults.md' diff --git a/.github/workflows/format-xaml.yml b/.github/workflows/format-xaml.yml deleted file mode 100644 index 329542f72a51..000000000000 --- a/.github/workflows/format-xaml.yml +++ /dev/null @@ -1,143 +0,0 @@ -name: Format XAML -on: - issue_comment: - types: [created] - -jobs: - format-xaml: - if: github.event.issue.pull_request && github.event.comment.body == '/format' - runs-on: windows-2025-vs2026 - environment: Pull Requests - permissions: - contents: write - - steps: - - name: Generate GitHub Apps token - id: generate - uses: actions/create-github-app-token@v3 - with: - app-id: ${{ secrets.BOT_APP_ID }} - private-key: ${{ secrets.BOT_PRIVATE_KEY }} - - - name: Create run condition variable - run: | - # this is required for early termination in case any conditions aren't satisfied - # https://github.com/actions/runner/issues/662 - - "CAN_RUN=1" | Out-File -FilePath $env:GITHUB_ENV -Append - - - name: Login to gh cli - run: | - "GH_TOKEN=${{ steps.generate.outputs.token }}" | Out-File -FilePath $env:GITHUB_ENV -Append - - - name: Check if PR can be committed to - run: | - if (!(gh pr -R ${{ github.repository }} view ${{ github.event.issue.number }} --json maintainerCanModify -q '.maintainerCanModify' | ConvertFrom-Json)) - { - gh pr comment ${{ github.event.issue.number }} -b "🔒 This PR cannot be committed to. Ensure that Allow edits from maintainers is enabled." - "CAN_RUN=0" | Out-File -FilePath $env:GITHUB_ENV -Append - } - - # all steps after this one must have the env.CAN_RUN == 1 condition - - - uses: actions/checkout@v6 - if: env.CAN_RUN == 1 - - - name: Setup .NET - uses: actions/setup-dotnet@v5 - - - name: Set git identity - if: env.CAN_RUN == 1 - run: | - $data = gh api graphql -f query='query { - viewer { - login - databaseId - } - }' --jq '.data.viewer' | ConvertFrom-Json - - git config --global user.name "$($data.login)" - git config --global user.email "$($data.databaseId)+$($data.login)@users.noreply.github.com" - - - name: Checkout PR - if: env.CAN_RUN == 1 - run: gh pr checkout ${{ github.event.issue.number }} -b pr - - - name: Check if PR has modified XAML files - if: env.CAN_RUN == 1 - run: | - $baseRef = gh pr view ${{ github.event.issue.number }} --json baseRefName --jq '.baseRefName' - $changedFiles = (git diff --name-only pr..$baseRef) -split "\n" | Where-Object {$_ -like "*.xaml"} - if ($changedFiles.Count -eq 0) - { - gh pr comment ${{ github.event.issue.number }} -b "⛔ No XAML files found to format." - "CAN_RUN=0" | Out-File -FilePath $env:GITHUB_ENV -Append - } - - - name: Install XamlStyler.Console - if: env.CAN_RUN == 1 - run: dotnet tool install --global XamlStyler.Console - - - name: Format XAML files - if: env.CAN_RUN == 1 - run: | - xstyler -l None -r -d src/Files.App - xstyler -l None -r -d src/Files.App.Controls - xstyler -l None -r -d tests/Files.App.UITests - - - name: Commit formatted files - if: env.CAN_RUN == 1 - run: | - git add --renormalize *.xaml - git status --porcelain - if ((git status --porcelain) -eq $null) - { - gh pr comment ${{ github.event.issue.number }} -b "⛔ No XAML files changed." - "CAN_RUN=0" | Out-File -FilePath $env:GITHUB_ENV -Append - } - else - { - git commit -m "Formatted XAML files" - } - - - name: Push to PR - if: env.CAN_RUN == 1 - run: | - # this is all to get the right repo and branch to push to - - $repo = '${{ github.repository }}' -split '/' - $owner = $repo[0] - $name = $repo[1] - $number = ${{ github.event.issue.number }} - - $data = gh api graphql -f query='query($owner:String!, $name:String!, $number:Int!) { - repository(owner:$owner, name:$name) { - pullRequest(number:$number) { - headRef { - name - } - headRepository { - url - } - } - } - }' -F owner=$owner -F name=$name -F number=$number --jq '{Branch: .data.repository.pullRequest.headRef.name, Url: .data.repository.pullRequest.headRepository.url}' | ConvertFrom-Json - - $url = [UriBuilder]($data.Url) - $url.UserName = 'x-access-token' - $url.Password = '${{ steps.generate.outputs.token }}' - git push $url.Uri.AbsoluteUri pr:$($data.Branch) - - if ($LASTEXITCODE -eq 0) - { - gh pr comment ${{ github.event.issue.number }} -b "✅ Successfully formatted XAML files." - } - else - { - "CAN_RUN=0" | Out-File -FilePath $env:GITHUB_ENV -Append - } - continue-on-error: true - - - name: Comment if failed - if: failure() && env.CAN_RUN == 0 - run: gh pr comment ${{ github.event.issue.number }} -b "⚠️ Failed to format XAML files, check [the logs](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) for more information." diff --git a/.github/workflows/sync-upstream.yml b/.github/workflows/sync-upstream.yml deleted file mode 100644 index d17f6ecad38d..000000000000 --- a/.github/workflows/sync-upstream.yml +++ /dev/null @@ -1,141 +0,0 @@ -# Copyright (c) Files Community -# Licensed under the MIT License. - -# Abstract: -# Daily, merges new commits from upstream files-community/Files into a sync/upstream-* branch and opens a PR -# against main. Upstream is only fetched (read-only). Conflicts are reported in a single tracking issue instead -# of a PR. Pushes made with GITHUB_TOKEN do not trigger other workflows, so the PR build is dispatched here. - -name: Sync Upstream - -on: - workflow_dispatch: - schedule: - - cron: '0 5 * * *' - -concurrency: - group: sync-upstream - cancel-in-progress: false - -permissions: - contents: write - pull-requests: write - issues: write - actions: write - -env: - GH_TOKEN: ${{ github.token }} - GH_REPO: ${{ github.repository }} - UPSTREAM_URL: https://github.com/files-community/Files.git - -jobs: - - sync: - - if: github.repository != 'files-community/Files' - runs-on: ubuntu-24.04 - - steps: - - - name: Checkout the repository - uses: actions/checkout@v6 - with: - ref: main - fetch-depth: 0 - - - name: Fetch upstream - run: | - git remote add upstream "$UPSTREAM_URL" - git fetch --no-tags upstream main - behind=$(git rev-list --count HEAD..upstream/main) - echo "BEHIND=$behind" >> "$GITHUB_ENV" - echo "Behind upstream by $behind commit(s)" - - - name: Merge upstream - if: env.BEHIND != '0' - run: | - git config user.name "github-actions[bot]" - git config user.email "41898282+github-actions[bot]@users.noreply.github.com" - branch=$(gh pr list --base main --state open --limit 100 --json headRefName,isCrossRepository \ - --jq '[.[] | select(.isCrossRepository == false and (.headRefName | startswith("sync/upstream-")))] | .[0].headRefName // empty') - branch=${branch:-"sync/upstream-$(date -u +%F)"} - echo "BRANCH=$branch" >> "$GITHUB_ENV" - if git show-ref --verify --quiet "refs/remotes/origin/$branch"; then - git fetch origin "refs/heads/$branch:refs/remotes/origin/$branch" - git checkout -b "$branch" "origin/$branch" - else - git checkout -b "$branch" - fi - # Freeze our policy/helper before upstream can change or conflict with them. - git show origin/main:scripts/linux/windows-paths.txt > "$RUNNER_TEMP/windows-paths.txt" - git show origin/main:scripts/linux/prune-windows.sh | sed 's/\r$//' > "$RUNNER_TEMP/prune-windows.sh" - if git merge upstream/main --no-edit; then - echo "CONFLICTS=false" >> "$GITHUB_ENV" - else - # Only keep allowlisted modify/delete conflicts where main deleted the file. - git rev-parse -q --verify MERGE_HEAD >/dev/null || exit 1 - bash "$RUNNER_TEMP/prune-windows.sh" --apply --conflicts-only \ - --paths-file "$RUNNER_TEMP/windows-paths.txt" - git diff --name-only --diff-filter=U > "$RUNNER_TEMP/conflicts.txt" - if [ -s "$RUNNER_TEMP/conflicts.txt" ]; then - git merge --abort - echo "CONFLICTS=true" >> "$GITHUB_ENV" - else - git commit --no-edit - echo "CONFLICTS=false" >> "$GITHUB_ENV" - fi - fi - git log -50 --format='- %s' main..upstream/main > "$RUNNER_TEMP/commits.txt" - - - name: Update or open the sync PR - if: env.BEHIND != '0' && env.CONFLICTS == 'false' - run: | - git push origin "$BRANCH" - { - echo "Merges \`upstream/main\` (files-community/Files) into \`main\`: $BEHIND commit(s)." - echo - cat "$RUNNER_TEMP/commits.txt" - echo - echo "Merged by the Sync Upstream workflow, keeping allowlisted Windows deletions where needed. The build was dispatched; check" - echo "that it passes before merging." - } > "$RUNNER_TEMP/body.md" - number=$(gh pr list --base main --head "$BRANCH" --state open --json number,isCrossRepository \ - --jq '[.[] | select(.isCrossRepository == false)] | .[0].number // empty') - if [ -z "$number" ]; then - number=$(gh pr list --base main --head "$BRANCH" --state closed --json number,state,isCrossRepository \ - --jq '[.[] | select(.state == "CLOSED" and .isCrossRepository == false)] | .[0].number // empty') - if [ -n "$number" ]; then - gh pr reopen "$number" - fi - fi - if [ -n "$number" ]; then - gh pr edit "$number" --body-file "$RUNNER_TEMP/body.md" - else - gh pr create --base main --head "$BRANCH" \ - --title "Code Quality: Sync upstream Files ($(date -u +%F))" \ - --body-file "$RUNNER_TEMP/body.md" - fi - gh workflow run nightly-linux.yml --ref "$BRANCH" - - - name: Report conflicts - if: env.BEHIND != '0' && env.CONFLICTS == 'true' - run: | - title="Upstream sync has merge conflicts" - { - echo "\`upstream/main\` is $BEHIND commit(s) ahead of \`main\` and does not merge cleanly into \`$BRANCH\`." - echo - echo "Conflicting files:" - sed 's/^/- /' "$RUNNER_TEMP/conflicts.txt" - echo - echo "Upstream commits:" - cat "$RUNNER_TEMP/commits.txt" - echo - echo "Resolve locally: \`git fetch upstream && git merge upstream/main\`, then open a PR from a \`sync/upstream-*\` branch." - echo "Run: $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" - } > "$RUNNER_TEMP/issue.md" - number=$(gh issue list --state open --search "\"$title\" in:title" --json number --jq '.[0].number // empty') - if [ -n "$number" ]; then - gh issue comment "$number" --body-file "$RUNNER_TEMP/issue.md" - else - gh issue create --title "$title" --body-file "$RUNNER_TEMP/issue.md" - fi diff --git a/.gitignore b/.gitignore index 7eb6bf52d695..65f3f1fec003 100644 --- a/.gitignore +++ b/.gitignore @@ -4,9 +4,6 @@ ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore # Custom files -Files.App.OpenDialog*.dll -Files.App.SaveDialog*.dll -Files.App.Launcher.exe # User-specific files *.rsuser @@ -408,7 +405,6 @@ FodyWeavers.xsd # JetBrains Rider *.sln.iml .idea/ -src/Files.App/Assets/FilesOpenDialog/Files.App.Launcher.exe.sha256 .cache/ # Shared opt-in Linux publish analysis profile diff --git a/AGENTS.md b/AGENTS.md index 8b8b4c3d31e2..2952659bb32b 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -43,8 +43,6 @@ This project is a C#/.NET WinUI 3 desktop app; an alternative to File Explorer. ├── Files.App.Controls Shared app controls ├── Files.App.Storage App storage abstractions and implementations ├── Files.App.CsWin32 Generated/native Win32 interop project -├── Files.App.BackgroundTasks Background task project -├── Files.App.Server App service/server project ├── Files.Core.SourceGenerator Roslyn source generators and analyzers ├── Files.Core.Storage Core storage abstractions └── Files.Shared Shared attributes, extensions, and common code @@ -52,9 +50,7 @@ This project is a C#/.NET WinUI 3 desktop app; an alternative to File Explorer. ```text /tests -├── Files.App.UITests -├── Files.App.UnitTests -└── Files.InteractionTests +└── Files.Platform.Tests Linux platform tests ``` ## Build diff --git a/Files.slnx b/Files.slnx index a0b303381e7f..4890a9f11ef1 100644 --- a/Files.slnx +++ b/Files.slnx @@ -29,11 +29,6 @@ - - - - - @@ -44,21 +39,6 @@ - - - - - - - - - - - - - - - @@ -69,18 +49,7 @@ - - - - - - - - - - - @@ -88,17 +57,6 @@ - - - - - - - - - - - diff --git a/docs/linux-port/AGENT-RULES.md b/docs/linux-port/AGENT-RULES.md index 803fa7c4bc58..8c5a1ddadec3 100644 --- a/docs/linux-port/AGENT-RULES.md +++ b/docs/linux-port/AGENT-RULES.md @@ -27,7 +27,8 @@ Read this first, then `PLAN.md` §0, then `CLAUDE.md`. - Route OS functionality through `Files.Platform.Abstractions` services implemented in `Files.Platform.Linux` (unit-tested in `tests/Files.Platform.Tests`). Don't call Win32 on Linux. - Native interop only via `[LibraryImport]` in `src/Files.Platform.Linux/Native/`. No `DllImport`/`ComImport`. - Mark stubs `// LINUX-TODO(): ...`. -- Shared files (`Strings/en-US/Resources.resw`, `Directory.Packages.props`, `Files.App.csproj`, `PlatformServiceCollectionExtensions.cs`, `AppLifecycleHelper.cs`): make minimal, append-only edits so merges stay trivial. +- Keep edits to shared files scoped. New strings in `Strings/en-US/Resources.resw` are append-only. +- This fork is independent: no upstream merges or automatic sync. Selectively cherry-pick reviewed fixes with attribution; follow [upstream-policy.md](upstream-policy.md). - Security: treat file names, `.desktop` files, archives and anything from disk as untrusted. No shell interpolation. Use fd-relative ops for recursive destructive actions (`Native/PosixNative`). - Match the surrounding style (license header, tabs, block namespaces). diff --git a/docs/linux-port/PLAN-alpha3.md b/docs/linux-port/PLAN-alpha3.md index 118450372165..439b674c248c 100644 --- a/docs/linux-port/PLAN-alpha3.md +++ b/docs/linux-port/PLAN-alpha3.md @@ -1,3 +1,5 @@ +> Historical alpha3 plan. The [upstream policy](upstream-policy.md) supersedes its upstream-sync and soft-only Windows removal guidance. + # Plan: 0.1.0-alpha3 and the road to 0.2 Source: seven read-only investigations (Codex, 2026-10-09), kept in [investigations/](investigations/). Findings marked @@ -19,8 +21,8 @@ Source: seven read-only investigations (Codex, 2026-10-09), kept in [investigati ## Proposals -- **Remove unused Windows code: soft only.** Hard deletion makes the daily upstream sync hit modify/delete conflicts and - kills the path back to Windows. Do the safe part: compile-item exclusions, drop `System.Drawing.Common`, gate SevenZip +- **Remove unused Windows code in stages.** The independent-fork policy replaces the earlier soft-only + recommendation. Keep Linux consumers building: compile-item exclusions, drop `System.Drawing.Common`, gate SevenZip and registry generators on Windows, add a trim/AOT analysis profile. Expected gain about 7-9 MiB unpacked and little startup. - **Rust: no-go for now.** First take cheap C# wins (batched `getdents64`, pooling, parallel stat) and benchmark 10k/100k folders. Spike Rust only for read-only directory scanning, and only if it beats optimised C# by 2x on the phase and 20% diff --git a/docs/linux-port/PLAN-rust-and-trim.md b/docs/linux-port/PLAN-rust-and-trim.md index 1013a14fb47b..4545d5b76652 100644 --- a/docs/linux-port/PLAN-rust-and-trim.md +++ b/docs/linux-port/PLAN-rust-and-trim.md @@ -1,6 +1,6 @@ # Plan: keep Uno, Rust backend, drop Windows code -Decision (user, 2026-10-09): keep Uno for the UI, move hot backend paths to Rust, and remove Windows-specific code without breaking the fork's upstream sync. Supersedes the "Rust no-go until benchmark" verdict in `investigations/rust.md` only in direction; the benchmark gate still applies per component. +Decision (user, 2026-10-09): keep Uno for the UI, move hot backend paths to Rust, and remove Windows-specific code from the independent fork. Supersedes the "Rust no-go until benchmark" verdict in `investigations/rust.md` only in direction; the benchmark gate still applies per component. ## Track 1: Rust backend (`native/linuxfiles-core`, cdylib) @@ -17,16 +17,17 @@ Packaging: cargo build in CI per target, `.so` bundled in AppImage/Flatpak/tarba Phases: P0 benchmark harness (C# baseline, 1 week). P1 enumeration spike behind flag. P2 watcher + archives. P3 default-on if gates pass. Release as alpha4+. -## Track 2: Windows code removal without breaking sync +## Track 2: Windows code removal in the independent fork -Already done: soft trim (compile exclusions, #1 `#if WINDOWS`, analysis publish profile). +The [upstream policy](upstream-policy.md) supersedes the earlier sync-preservation plan. Upstream stays read-only; fixes are cherry-picked selectively, with no upstream merges. -Hard deletion becomes viable with sync automation: -1. List Windows-only paths in `scripts/linux/windows-paths.txt` (projects, CsWin32, BackgroundTasks, Package manifests, Windows installers, Windows-only tests). -2. Daily sync workflow merges upstream, then for modify/delete conflicts on listed paths runs `git rm` (keep our deletion) and commits; all other conflicts still open a PR for review. -3. Shared files (Files.App.csproj, Files.slnx, Directory.Packages.props) stay, with Windows items conditioned, to keep conflict surface small. -4. Staged: (a) build/bundle exclusion verified by size comparison (`compare-publish.py`), (b) delete leaf Windows-only projects first, (c) delete Windows-only files inside Files.App last, after two clean syncs. -Rollback: every stage is one revertable PR. If a sync produces non-trivial conflicts twice in a row, stop at the previous stage. +Already done: soft trim (compile exclusions, `#if WINDOWS`, analysis publish profile). + +1. Stage 1: remove Windows leaf projects, their build references, Windows CI/packaging, and sync/pruning automation. Keep the desktop app and remaining tests building. +2. Later stages: remove Windows-only code inside `Files.App` after checking Linux consumers and build exclusions. Preserve shared assets needed by Linux, localization, licenses and notices. +3. Verify each stage with focused builds and tests; compare publish manifests when changing shipped assets (`compare-publish.py`). + +Rollback: each stage remains a scoped, revertible change. ## Track 3: Parallel, not blocked @@ -34,5 +35,5 @@ Pixelation diagnosis (1x/1.5x/2x), Wayland host spike decision, per `PLAN-alpha3 ## Order -alpha3 (Wave 1 merged) -> P0 benchmark + Track 2(a) -> P1 Rust enumeration + Track 2(b) -> alpha4 -> P2/P3 + Track 2(c) -> alpha5. +alpha3 (Wave 1 merged) -> P0 benchmark + Track 2 publish verification -> P1 Rust enumeration + Track 2 Stage 1 -> alpha4 -> P2/P3 + later Windows removal -> alpha5. Work split: Codex implements Rust crates and CI; Claude Sonnet verifies headless; cross-review before merge. diff --git a/docs/linux-port/PLAN.md b/docs/linux-port/PLAN.md index 7bdfb0d7f35c..5daea1ed15f1 100644 --- a/docs/linux-port/PLAN.md +++ b/docs/linux-port/PLAN.md @@ -4,15 +4,21 @@ Status: phases 0–7 done (2026-10-06); phase 8 optional · draft v1 · 2026-10-04 · fork base `0e3c17ca4` (in sync with `files-community/Files` main) -## 0. Revision 2 (2026-10-04): Linux-first +## 0. Independent fork (Stage 1) + +The [upstream policy](upstream-policy.md) overrides earlier merge-preservation and Windows-restoration guidance below. LinuxFiles no longer merges upstream; the upstream remote is read-only and individual fixes are cherry-picked selectively. Windows leaf projects, their build references, Windows CI/MSIX packaging, and sync/pruning automation are removed. Windows code inside `Files.App` remains for later stages. Preserve MIT/MPL licenses and NOTICE credit. + +The remaining sections record the original porting plan and its completed phases. + +### Revision 2 (2026-10-04): Linux-first **This section overrides anything below that conflicts with it.** ### Decision The owner decided to focus on Linux first. Windows support is revisited only after the Linux version works. -- The Windows build no longer has to stay green. `ci-windows.yml` is manual (`workflow_dispatch`) and informational. -- We still put platform code behind `Files.Platform.Abstractions` interfaces. That keeps the Linux code clean, keeps - upstream merges manageable, and leaves a path back to Windows. Windows-only code may be excluded from the build +- The Windows build no longer has to stay green; Windows workflows have been removed. +- We still put platform code behind `Files.Platform.Abstractions` interfaces. That keeps the Linux code clean and + gives selectively imported fixes clear platform boundaries. Windows-only code may be excluded from the build or left uncompiled instead of carefully wrapped. - Fork autonomy: agents may push branches, open and merge PRs on `MemerGamer/LinuxFiles` freely. Never touch upstream. @@ -80,14 +86,13 @@ largely independent problems: IFileOperation, preview handlers) Strategy: **introduce a platform abstraction layer, move Windows code behind it unchanged, then add a Linux backend -and an Uno head.** The Windows build must keep working at every step so the fork can keep merging upstream. +and an Uno head.** The Linux desktop build must keep working at every step. ## 2. Guiding principles -- **Keep upstream mergeable.** Prefer additive files, partial classes, DI registration, and `#if` in a few - well-known seams over rewriting upstream files. Each upstream sync should be a routine merge. -- **Windows build never breaks.** Every PR must build `net10.0-windows` (CI on Windows) *and* whatever Linux targets - exist at that point (CI on Linux). +- **Independent fork.** Use clear platform seams and selectively cherry-pick upstream fixes with attribution. + Do not merge upstream branches; see [upstream-policy.md](upstream-policy.md). +- **Linux build stays green.** Every PR must build the desktop app and remaining Linux tests. - **Drop, don't port, Windows-only features** (listed in §6). Hide them in the UI on Linux via a capability flag. - **Managed first, native second.** Prefer `System.IO`, `FileSystemWatcher`, SharpCompress, TagLibSharp, Tmds.DBus over P/Invoking GLib. Use GIO only where a managed path is clearly worse (thumbnails, mime/app info). @@ -107,9 +112,9 @@ and an Uno head.** The Windows build must keep working at every step so the fork | Files.App.Controls | windows (WinUI) | Clean of Win32/Composition — ports to Uno with minor changes | | Files.App | windows (WinUI, MSIX) | The bulk of the work | | Files.App.CsWin32 | windows | Windows-only | -| Files.App.Server | windows (OOP WinRT server) | Drop on Linux | -| Files.App.BackgroundTasks | windows (MSIX update task) | Drop on Linux | -| Files.App.Launcher / OpenDialog / SaveDialog | C++ vcxproj | Drop on Linux (see §6 for replacements) | +| legacy Windows COM server | windows (OOP WinRT server) | Drop on Linux | +| legacy Windows update-task project | windows (MSIX update task) | Drop on Linux | +| legacy Windows launcher / OpenDialog / SaveDialog | C++ vcxproj | Drop on Linux (see §6 for replacements) | | tests/* | windows (Appium/WinAppDriver, WinUI gallery) | No unit tests exist today | All csproj files hard-code `RuntimeIdentifiers=win-x86;win-x64;win-arm64`, including the neutral ones. @@ -169,9 +174,8 @@ Directory watching is implemented separately in five places (`ShellViewModel`, ` Files.Shared (net10.0) — unchanged Files.Core.Storage (net10.0) — unchanged (OwlCore contracts) Files.Platform.Abstractions (net10.0) — NEW: interfaces + capability flags, no implementations -Files.Platform.Windows (net10.0-windows) — NEW: wraps existing Windows code (moved, not rewritten) Files.Platform.Linux (net10.0) — NEW: Linux implementations -Files.App.Storage — split: portable parts → net10.0; Windows/ → Files.Platform.Windows +Files.App.Storage — split: portable parts → net10.0; Windows/ retained for later removal Files.App.Controls — multi-target: net10.0-windows (WinAppSDK) + net10.0-desktop (Uno) Files.App — multi-target: net10.0-windows (WinAppSDK) + net10.0-desktop (Uno Skia) ``` @@ -226,13 +230,13 @@ Each phase lists its **exit criteria**. Phases 2 and 3 overlap heavily once Phas Uno vs Avalonia decision confirmed. ### Phase 1 — Abstraction skeleton (serial, blocks everything) -- Create `Files.Platform.Abstractions` (interfaces from §4.1 + `IPlatformCapabilities`), `Files.Platform.Windows`, +- Create `Files.Platform.Abstractions` (interfaces from §4.1 + `IPlatformCapabilities`), the former Windows platform project, `Files.Platform.Linux` (empty), and a `tests/Files.Platform.Tests` (MSTest, net10.0) project. Add them to `Files.slnx`. - Add `AddWindowsPlatform()` / `AddLinuxPlatform()` DI entry points; call `AddWindowsPlatform()` from `AppLifecycleHelper`. - **Exit:** Windows build and behaviour unchanged; new projects build on Linux. ### Phase 2 — Move Windows code behind the seams (parallel, W1–W8) -Each workstream: define its interface methods from real call sites, implement them in `Files.Platform.Windows` by +Each workstream: define its interface methods from real call sites, implement them in the former Windows platform project by **moving or wrapping** existing code, then update call sites to use the interface. No behaviour change on Windows. - **Exit per workstream:** zero direct `PInvoke.`/`Windows.Storage`/Registry calls remaining in the workstream's owned consumer files (checked with `rg --no-ignore`); Windows CI green. @@ -313,7 +317,7 @@ files (outside `*.Windows.cs`) → 0. Exit: compat off by default, 0 errors, hea ### Phase 6 — Desktop integration & packaging - `org.freedesktop.FileManager1` D-Bus service (ShowFolders/ShowItems/ShowItemProperties): the Linux equivalent of - `Files.App.Launcher`. + `legacy Windows launcher`. - `.desktop` entry, `inode/directory` MIME association, AppStream metainfo, icons. - Packages: Flatpak (primary; needs `--filesystem=host`, `org.freedesktop.Flatpak` spawn for launching host apps carefully considered), AppImage, AUR `PKGBUILD`. @@ -336,7 +340,7 @@ files (outside `*.Windows.cs`) → 0. Exit: compat off by default, 0 errors, hea | NTFS ACL Security tab / object picker | Replace with POSIX owner/group/permissions editor | | `.lnk` / `.url` shortcuts | Read-only support optional; create symlinks / `.desktop` Link entries | | Jump lists, Start-menu pinning, taskbar progress | Drop (taskbar progress could use Unity LauncherEntry D-Bus later) | -| Files.App.Server, BackgroundTasks, MSIX update task | Drop | +| legacy Windows COM server, BackgroundTasks, MSIX update task | Drop | | Open/Save dialog replacement (C++ COM) | Defer; portal backend in Phase 6 | | WSL distro listing, PowerShell helpers | Drop | | Format drive dialog | Replace with `gnome-disks` launch if present, else hide | @@ -362,7 +366,7 @@ files (outside `*.Windows.cs`) → 0. Exit: compat off by default, 0 errors, hea capped log. 4. **Opus** reviews the diff (correctness, CRLF, `.editorconfig`, AOT rules, no scope creep), then merges into `main` in dependency order. -5. **Haiku** merges `upstream/main` into `main` (via a sync PR) weekly and reports conflicts. **Opus** resolves non-trivial ones. +5. Review upstream fixes selectively and cherry-pick with attribution. No weekly upstream merges or sync PRs. Windows builds can't run locally on Linux. Validate them through GitHub Actions on `windows-2025-vs2026`, with a Haiku agent polling `gh run` results. @@ -397,7 +401,7 @@ Phase 1. ``` WP-ID: W2-a Goal: Introduce IFileOperationsService; Windows impl wraps ShellFilesystemOperations -Owns: src/Files.App/Utils/Storage/Operations/**, src/Files.Platform.Windows/FileOperations/** +Owns: src/Files.App/Utils/Storage/Operations/**, the former Windows file-operations backend Must not edit: ShellViewModel.cs, Actions/**, AppLifecycleHelper.cs Contract: (interface signature pasted here by Opus) Acceptance: - Windows CI green @@ -411,7 +415,7 @@ Runner checks: dotnet build src/Files.Platform.Abstractions; dotnet test tests/F | Risk | Impact | Mitigation | |---|---|---| | Uno gaps (InteractionTracker, title bar, TabView tear-out, InputKeyboardSource) | UI features missing | Phase 0 spike; degrade behind capability flags | -| Upstream churn in hot files (`ShellViewModel`, layout pages) | Painful merges | Weekly upstream merges; additive/partial-class style; keep moved code byte-identical where possible | +| Upstream churn in hot files (`ShellViewModel`, layout pages) | Painful merges | Selective, reviewed cherry-picks; clear platform boundaries | | Windows build can't be verified locally | Silent Windows breakage | Mandatory Windows CI on every `linux/*` PR | | File-operation correctness (data loss) | Critical | Extensive temp-dir unit tests; cross-device move, conflict, cancel, permission-denied, symlink cases | | Performance of managed enumeration / thumbnails | Sluggish large folders | Benchmarks against 100k entries; batch `stat`; async thumbnail queue with XDG cache | diff --git a/docs/linux-port/investigations/remove-windows-code.md b/docs/linux-port/investigations/remove-windows-code.md index ff6c2dab8c5f..a6ae87a6c975 100644 --- a/docs/linux-port/investigations/remove-windows-code.md +++ b/docs/linux-port/investigations/remove-windows-code.md @@ -1,3 +1,5 @@ +> Historical investigation. The [independent-fork policy](../upstream-policy.md) supersedes the sync-preservation recommendation below; Windows leaf projects and sync/pruning automation have since been removed. + **Recommend option 1: retain the upstream tree, tighten Linux publish exclusions, then investigate trimming.** Deleting sources already excluded from compilation offers essentially **zero binary-size or startup gain**. Read-only investigation completed; no edits, builds, app launches, commits or external comments. Counts use `git ls-files`, `wc` and targeted `rg`. MSBuild item queries timed out, so compilation counts below are **static estimates**, excluding generated code. @@ -10,7 +12,7 @@ Read-only investigation completed; no edits, builds, app launches, commits or ex | App Shell / Taskbar / Signatures / Services.Windows | 33 / 6,813 | Excluded except `ShellHelpers.cs` | | Files.App.Storage C# | 50 / 4,439 | Approximately 23 / 1,815 included; 27 / 2,624 excluded | | CsWin32 / BackgroundTasks / Server C# | 12 / 550; 1 / 63; 3 / 152 | Projects excluded | -| Files.Platform.Windows C# | 2 / 77 | Project excluded | +| legacy Windows platform project C# | 2 / 77 | Project excluded | | Files.Core.SourceGenerator C# | 16 / 2,172 | Built as an analyzer, not shipped | | App XAML | 99 / 21,056 | 9 / 1,677 excluded; 90 / 19,379 retained | | Localisation | 49 files / 232,436 LOC; 9.11 MiB | Shared Linux resources | @@ -46,7 +48,7 @@ Trimming can remove unreachable managed members/framework assemblies; it does no | 3. Hard delete with sync automation | L ongoing | Feasible only with explicit path policy and conflict-aware processing | | 4. Permanent hard fork | L ongoing | Simplifies the visible tree; assumes ownership of upstream fixes and abandons routine reintegration | -Daily sync **attempts a merge and opens a PR**; it aborts on conflicts ([sync-upstream.yml:14](.github/workflows/sync-upstream.yml:14), [71](.github/workflows/sync-upstream.yml:71)). Deletion causes modify/delete conflicts when upstream changes deleted paths—not necessarily every merge. New files can reappear. +The former daily sync attempted a merge and opened a PR; it has been retired under the independent-fork policy. The conflict analysis below is historical. `-X ours` favours conflicting content hunks; it is not a deletion policy. A `merge=ours` custom driver needs Git configuration and handles file contents, not structural deletion conflicts. [Git strategy documentation](https://git-scm.com/docs/merge-strategies), [attribute documentation](https://git-scm.com/docs/gitattributes). A viable deletion script must resolve only allowlisted conflicts, re-delete matching additions, reject other conflicts and retain merge ancestry; a post-success script alone is insufficient. Broad `ours` handling risks silently losing useful upstream changes. diff --git a/docs/linux-port/spikes.md b/docs/linux-port/spikes.md index a57c045016ec..9ea42471b5f5 100644 --- a/docs/linux-port/spikes.md +++ b/docs/linux-port/spikes.md @@ -33,7 +33,7 @@ Changes: - `global.json`: `"msbuild-sdks": { "Uno.Sdk": "6.7.30" }`. Only projects that opt in to `Sdk="Uno.Sdk"` resolve it. - `Directory.Build.props`: **renamed the repo's `TargetFrameworkVersion` property to `BaseTargetFramework`** (and the 4 csproj - files that use it: Files.Shared, Files.Core.Storage, Files.InteractionTests, Files.App.Controls). `TargetFrameworkVersion` + files that use it: Files.Shared, Files.Core.Storage, legacy Windows interaction tests, Files.App.Controls). `TargetFrameworkVersion` is a built-in MSBuild property (`v10.0`); Uno.Sdk pulls in .NET workload manifests that evaluate `VersionGreaterThanOrEquals($(TargetFrameworkVersion), 8.0)` and crash on the repo's `net10.0` value (`MSB4184`). Added `DesktopTargetFramework` = `$(BaseTargetFramework)-desktop`. diff --git a/docs/linux-port/upstream-policy.md b/docs/linux-port/upstream-policy.md new file mode 100644 index 000000000000..209636a4de45 --- /dev/null +++ b/docs/linux-port/upstream-policy.md @@ -0,0 +1,11 @@ +# Upstream policy + +LinuxFiles is now an independent Linux fork of [Files](https://github.com/files-community/Files). `main` is the integration branch. We no longer merge upstream branches or run an automatic sync workflow. + +The `upstream` remote for `files-community/Files` stays read-only: fetch and inspect its history, but never push to it, target it with pull requests, or post comments there as part of work on this fork. + +Bring over individual fixes selectively with `git cherry-pick -x `, on a fork branch. Review each change for Linux compatibility, keep its upstream attribution, and verify the affected build and tests before merging into this fork. Do not restore removed Windows projects or packaging as a side effect. + +Preserve `LICENSE-MIT`, `LICENSE-MPL`, `NOTICE.md`, `.github/NOTICE.md`, applicable file headers, and Files Community contributor credit. MIT notices continue to apply to inherited MIT code; MPL terms continue to apply to files bearing MPL headers. Independence does not change those licenses or imply endorsement by the Files Community. + +Stage 1 removes the Windows leaf projects and their build references, Windows CI and MSIX packaging, and the former sync/pruning automation. Windows code inside `Files.App`, including `#if WINDOWS` branches, remains for later stages. diff --git a/docs/linux-port/windows-prune.md b/docs/linux-port/windows-prune.md deleted file mode 100644 index 3be0b76fe32f..000000000000 --- a/docs/linux-port/windows-prune.md +++ /dev/null @@ -1,123 +0,0 @@ -# Track 2(a) + (b-prep): Windows leaf pruning - -This stage prepares deletion; **no Windows sources are deleted in this PR**. -`windows-paths.txt` is an explicit allowlist, not a platform-name heuristic. -The default Linux graph uses `FilesWin32Compat=false` and `net10.0-desktop`. -Stage (a)'s existing compile/asset exclusions stay in place; stage (b)'s leaf -removals are simulated only in a disposable copy. App-internal deletion (c) -remains deferred until two clean upstream syncs. - -## Reference audit (2026-10-10) - -Each entry was searched by its directory/project name across `Files.slnx`, -all source/test project files and MSBuild props/targets, workflows, scripts, -Linux packaging and `flake.nix`. Then the remaining Linux graph was built -and tested with all candidates absent. The solution is the retained Windows -inventory; Linux CI, publishing and Nix target individual projects instead. -Windows solution entries and Windows workflow references are intentionally -retained here. A later deletion PR must address them if those tools are needed. - -| Allowlisted directory | Tracked files | References outside the directory; Linux assessment | -|---|---:|---| -| `src/Files.App.BackgroundTasks/` | 2 | `Files.slnx`; app ProjectReference in the Windows-only ItemGroup. | -| `src/Files.App.Launcher/` | 6 | Windows solution project/dependency; Windows release workflows; app's Windows-only packaged launcher Content item. | -| `src/Files.App.OpenDialog/` | 20 | Windows solution projects/dependencies only; C++/Win32 dialogs. | -| `src/Files.App.SaveDialog/` | 22 | Windows solution projects/dependencies only; C++/Win32 dialogs. | -| `src/Files.App.Server/` | 8 | Windows solution/dependency; app's Windows-only CsWinRT inputs and `BuildFilesAppServer` target. | -| `src/Files.Platform.Windows/` | 3 | Windows solution; app ProjectReference in the Windows-only ItemGroup. | -| `tests/Files.App.UITests/` | 37 | Windows solution and the Windows-only Format XAML workflow. | -| `tests/Files.InteractionTests/` | 12 | Windows solution, CI and sideload workflows; Appium/Axe.Windows tests, Windows RIDs. | - -Total: **110 files, 388,950 tracked bytes** at the audited base `4f24a930d`. -No candidate is referenced by Linux build/test/publish scripts or Linux -workflows. The platform test project's explicit linked source files and its -project references remain outside the allowlist. Linux test discovery's -`*.Platform.Tests` / `*.Linux.Tests` globs exclude both Windows test projects. - -Reproduce the static search for each entry (also inspect the enclosing -MSBuild conditions and workflow runner, rather than treating hits as active): - -```bash -for path in $(sed -e 's/\r$//' -e '/^#/d' -e '/^$/d' scripts/linux/windows-paths.txt); do - name=$(basename "$path") - rg -n -F "$name" Files.slnx src tests .github/workflows scripts packaging flake.nix \ - -g '*.sln*' -g '*proj' -g '*.props' -g '*.targets' -g '*.yml' \ - -g '*.sh' -g '*.ps1' -g '*.py' -g '*.nix' -g '!**/bin/**' -g '!**/obj/**' -done -``` - -Conservatively retained: CsWin32 (Linux opt-in compat inventory still builds -it), Controls/Storage/Shared/Core/Uno projects, all app-internal Windows files, -manifests/installers, shared project/solution/package files, local NuGet -archives and all assets. Windows file names alone do not establish exclusion. - -## Pruning and sync behavior - -Run from anywhere inside the checkout: - -```bash -scripts/linux/prune-windows.sh # reports tracked candidates; changes nothing -scripts/linux/prune-windows.sh --apply # future deletion stage only: stages git rm -``` - -Paths are literal, repository-relative, one per line; a trailing slash denotes -a directory. Blank lines, comment lines and CRLF are accepted. Absolute paths, -traversal, globs and `.git` paths are rejected before any removal. Normal -pruning preflights the complete operation and refuses modified/staged files; -already absent paths are harmless. Untracked files are not removed. The CRLF -shell script normalizes its own input before execution on Linux. - -The sync workflow snapshots the main-side allowlist and helper before merging, -so upstream cannot change the policy during that merge. On failure it invokes -`--apply --conflicts-only --paths-file `: only allowlisted `DU` -conflicts (deleted by us, modified by them) get `git rm`. Matching is exact for -files or bounded by the directory slash, and Git paths are read NUL-delimited. -If none remain, `git commit --no-edit` finishes the merge with both parents. -Any remaining conflict aborts the merge and enters the existing tracking-issue -flow. Reverse modify/delete (`UD`), content, add/add and non-allowlisted -conflicts stay for review. Clean merges retain the existing behavior; -upstream additions are not automatically pruned in this preparation stage. - -## Disposable validation - -Validation uses a fresh `git archive HEAD` copy initialized as its own Git -repository, with this PR's helper/list/workflow copied in. Baseline and pruned -publishes use the same temporary path and HEAD. Only that copy runs `--apply`. -Every build/test/publish runs under -`flock ~/.cache/linuxfiles-agents/build.lock`, at low priority, with MSBuild -node reuse disabled and at most two build workers. No real display is used. - -Commands exercised in that copy: - -1. `scripts/linux/publish.sh --rid linux-x64 --tarball` before removal. -2. Pruner dry run, then `--apply` in the temporary repository only. -3. Release x64 builds of Shared, Core.Storage, Core.SourceGenerator and - Platform.Linux with warnings as errors; Controls, Storage and App for - `net10.0-desktop` with compat off; platform tests with warnings as errors. -4. `scripts/linux/headless-run.sh` launches the rebuilt App with a sandbox HOME; - its `run` action executes `dotnet test --test-modules Files.Platform.Tests.dll --root-directory ` on - the same private Xvfb display, avoiding solution/Windows project discovery. - The compiled test bundle and pruned source tree are copied beneath a private - cache directory (source-reading tests locate `Files.slnx` beside it): the - native-library trust tests correctly reject a world-writable `/tmp` ancestor. -5. `python3 -m unittest discover -s scripts/linux/tests -p test_prune_windows.py -v` - and the existing `test_compare_publish.py` suite. -6. Repeat the self-contained publish, compare both tarballs using - `scripts/linux/compare-publish.py --json `, and verify that - CsWin32 has no `bin` or `obj` output. - -The new Git regression tests exercise dry-run/apply/idempotence, complete -preflight protection, invalid lists, and the actual workflow merge shell -block in isolated repositories: clean, allowlisted deletion, mixed, -non-allowlisted deletion, reverse deletion, content, add/add, and an upstream -policy change. They verify abort/review behavior and merge ancestry. - -## Validation results (2026-10-10, merged with main at PR #152) - -In a disposable `git archive` copy with all eight allowlisted directories removed (`prune-windows.sh --apply`): - -- `dotnet build src/Files.App -f net10.0-desktop -c Debug -p:FilesWin32Compat=false`: succeeded, 0 errors. -- `Files.Platform.Tests` under Xvfb (no real display): 1252 passed, 0 failed. The trust tests need a non-world-writable ancestor, so the copy was run from `~/.cache`, not `/tmp`. -- `test_prune_windows.py`: 4 passed, including the real workflow merge step against a stubbed `gh`. - -The tarball size comparison and the headless launch from the earlier plan were not repeated; no source in the repository was deleted. diff --git a/scripts/linux/prune-windows.sh b/scripts/linux/prune-windows.sh deleted file mode 100755 index c857be406f84..000000000000 --- a/scripts/linux/prune-windows.sh +++ /dev/null @@ -1,114 +0,0 @@ -#!/usr/bin/env -S bash -# Copyright (c) Files Community. Licensed under the MIT License. -# Re-enter with normalized input so the checked-in CRLF script runs on Linux. -[[ "${BASH_SOURCE[0]}" == /dev/fd/* ]] || exec bash <(sed 's/\r$//' "${BASH_SOURCE[0]}") "$@" # CRLF bootstrap -set -euo pipefail - -apply=false -conflicts_only=false -paths_file="" -while [[ $# -gt 0 ]]; do - case "$1" in - --apply) apply=true; shift ;; - --conflicts-only) conflicts_only=true; shift ;; - --paths-file) - [[ $# -ge 2 ]] || { echo "--paths-file requires a file" >&2; exit 2; } - paths_file="$2"; shift 2 ;; - -h|--help) - echo "Usage: prune-windows.sh [--apply] [--conflicts-only] [--paths-file FILE]" - echo "Dry-run by default. Conflict mode keeps only allowlisted deletions made by ours." - exit 0 ;; - *) echo "Unknown argument: $1" >&2; exit 2 ;; - esac -done - -root="$(git rev-parse --show-toplevel)" -paths_file="${paths_file:-$root/scripts/linux/windows-paths.txt}" -# Resolve an explicit list relative to the caller before moving to the repository root. -paths_file="$(realpath "$paths_file")" -cd "$root" - -paths=() -while IFS= read -r path || [[ -n "$path" ]]; do - path="${path%$'\r'}" - [[ -z "$path" || "$path" == \#* ]] && continue - if [[ ! "$path" =~ ^[A-Za-z0-9_.-]+(/[A-Za-z0-9_.-]+)*/?$ || - "/$path/" == */../* || "/$path/" == */./* || - "$path" == .git || "$path" == .git/* ]]; then - echo "Unsafe or non-literal path in list: $path" >&2 - exit 2 - fi - paths+=("$path") -done < "$paths_file" -[[ ${#paths[@]} -gt 0 ]] || { echo "Empty Windows path list" >&2; exit 2; } - -allowed() { - local entry - for entry in "${paths[@]}"; do - if [[ "$1" == "$entry" || ( "$entry" == */ && "$1" == "$entry"* ) ]]; then - return 0 - fi - done - return 1 -} - -selected=() -if [[ "$conflicts_only" == true ]]; then - git rev-parse -q --verify MERGE_HEAD >/dev/null || { echo "No merge in progress" >&2; exit 2; } - # DU means deleted by us, modified by them; UD and every other conflict stay unresolved. - while IFS= read -r -d '' record; do - status="${record:0:2}" - path="${record:3}" - if [[ "$status" == DU ]] && allowed "$path"; then - selected+=("$path") - fi - # Porcelain -z adds a second pathname for renames/copies. - if [[ "$status" == *R* || "$status" == *C* ]]; then - IFS= read -r -d '' _ || true - fi - done < <(git status --porcelain=v1 -z --untracked-files=no) -else - git rev-parse -q --verify MERGE_HEAD >/dev/null && { echo "Use --conflicts-only during a merge" >&2; exit 2; } - for path in "${paths[@]}"; do - files=() - mapfile -d '' -t files < <(git --literal-pathspecs ls-files -z -- "$path") - count=0 - for file in "${files[@]}"; do - if allowed "$file"; then - selected+=("$file") - count=$((count + 1)) - fi - done - if [[ "$count" -gt 0 ]]; then - printf '%s: %d tracked file(s)\n' "$path" "$count" - fi - done -fi - -if [[ ${#selected[@]} -eq 0 ]]; then - echo "No eligible tracked paths." - exit 0 -fi - -# Git's unlink follows parent symlinks, even when its preflight sees clean files. -for path in "${selected[@]}"; do - ancestor="$path" - while [[ "$ancestor" == */* ]]; do - ancestor="${ancestor%/*}" - if [[ -L "$ancestor" ]]; then - echo "Symlinked ancestor of tracked path: $path ($ancestor)" >&2 - exit 2 - fi - done -done - -flags=(-r) -[[ "$conflicts_only" == true ]] && flags+=(-f) -# Preflight the entire operation; normal pruning refuses local/staged modifications. -git --literal-pathspecs rm --dry-run "${flags[@]}" -- "${selected[@]}" >/dev/null -if [[ "$apply" == true ]]; then - git --literal-pathspecs rm "${flags[@]}" -- "${selected[@]}" -else - printf 'Would git rm: %s\n' "${selected[@]}" - echo "Dry run only; pass --apply to stage these deletions." -fi diff --git a/scripts/linux/tests/test_prune_windows.py b/scripts/linux/tests/test_prune_windows.py deleted file mode 100644 index 7ae9eeebcb0a..000000000000 --- a/scripts/linux/tests/test_prune_windows.py +++ /dev/null @@ -1,177 +0,0 @@ -# Copyright (c) Files Community. Licensed under the MIT License. -"""Exercise pruning and the actual merge step in throwaway Git repositories.""" -import os -from pathlib import Path -import subprocess -import tempfile -import unittest - -ROOT = Path(__file__).resolve().parents[3] -SCRIPT = ROOT / "scripts/linux/prune-windows.sh" -WORKFLOW = (ROOT / ".github/workflows/sync-upstream.yml").read_text() -MERGE = WORKFLOW.split(" - name: Merge upstream\n", 1)[1].split(" run: |\n", 1)[1] -MERGE = "\n".join(line[8:] for line in MERGE.split(" - name: Update or open the sync PR", 1)[0].splitlines()) - - -class PruneWindowsTests(unittest.TestCase): - def setUp(self): - self.temp = tempfile.TemporaryDirectory(prefix="files-prune-test-") - self.addCleanup(self.temp.cleanup) - self.repo = Path(self.temp.name) - self.git("init", "-b", "main") - self.git("config", "user.name", "Prune test") - self.git("config", "user.email", "prune@example.invalid") - self.write("scripts/linux/prune-windows.sh", SCRIPT.read_bytes()) - (self.repo / "scripts/linux/prune-windows.sh").chmod(0o755) - self.write("scripts/linux/windows-paths.txt", b"# test\r\nwin/\r\nexact.txt\r\n") - for path in ("win/space name.txt", "win/content.txt", "windows/keep.txt", "exact.txt", "shared.txt"): - self.write(path, b"base\n") - self.commit("base") - - def run_command(self, *args, check=True, env=None): - return subprocess.run(args, cwd=self.repo, check=check, capture_output=True, text=True, env=env) - - def git(self, *args, check=True): - return self.run_command("git", *args, check=check) - - def write(self, path, content): - target = self.repo / path - target.parent.mkdir(parents=True, exist_ok=True) - target.write_bytes(content) - - def commit(self, message): - self.git("add", ".") - self.git("commit", "-m", message) - - def prune(self, *args, check=True): - # Invoke the executable directly to verify its CRLF bootstrap. - script = self.repo / "scripts/linux/prune-windows.sh" - script.chmod(0o755) - return self.run_command(str(script), *args, check=check) - - def test_dry_run_apply_and_idempotence(self): - before = self.git("status", "--porcelain").stdout - self.prune() - self.assertEqual(before, self.git("status", "--porcelain").stdout) - self.assertTrue((self.repo / "win/space name.txt").exists()) - self.prune("--apply") - self.assertFalse((self.repo / "win").exists()) - self.assertFalse((self.repo / "exact.txt").exists()) - self.assertTrue((self.repo / "windows/keep.txt").exists()) - self.prune("--apply") - - def test_modified_files_block_all_deletions(self): - self.write("exact.txt", b"local edit\n") - self.assertNotEqual(0, self.prune("--apply", check=False).returncode) - self.assertTrue((self.repo / "win/space name.txt").exists()) - self.assertEqual("", self.git("diff", "--cached", "--name-only").stdout) - - def test_symlinked_ancestors_block_all_deletions(self): - self.write("win/nested/content.txt", b"base\n") - self.commit("nested file") - self.git("update-index", "--refresh") - for ancestor in ("win/nested", "win"): - with self.subTest(ancestor=ancestor), tempfile.TemporaryDirectory() as outside: - original = self.repo / ancestor - moved = Path(outside) / "moved" - original.rename(moved) - original.symlink_to(moved, target_is_directory=True) - try: - result = self.prune("--apply", check=False) - self.assertNotEqual(0, result.returncode) - self.assertIn("Symlinked ancestor", result.stderr) - self.assertEqual(b"base\n", (moved / "content.txt").read_bytes()) - self.assertTrue((self.repo / "exact.txt").exists()) - self.assertEqual("", self.git("diff", "--cached", "--name-only").stdout) - finally: - original.unlink() - moved.rename(original) - - def test_exact_file_entries_do_not_select_descendants(self): - self.write("foo/bar.txt", b"keep\n") - self.commit("directory named like exact entry") - self.write("custom-paths.txt", b"foo\r\nexact.txt\r\n") - self.assertEqual("foo/bar.txt\n", self.git("--literal-pathspecs", "ls-files", "--", "foo").stdout) - self.prune("--apply", "--paths-file", "custom-paths.txt") - self.assertEqual(b"keep\n", (self.repo / "foo/bar.txt").read_bytes()) - self.assertEqual("exact.txt\n", self.git("diff", "--cached", "--name-only").stdout) - - def test_reject_unsafe_lists(self): - for entry in ("../shared.txt", "/tmp/file", "win/*", ".git/", "win/../shared.txt", "./win/", "."): - with self.subTest(entry=entry): - self.write("scripts/linux/windows-paths.txt", (entry + "\r\n").encode()) - self.assertNotEqual(0, self.prune("--apply", check=False).returncode) - self.assertTrue((self.repo / "shared.txt").exists()) - - def test_workflow_merge_cases(self): - cases = ("clean", "allowed", "mixed", "outside", "reverse", "content", "add-add", "policy") - # Each case needs its own independent repository and merge state. - for case in cases: - with self.subTest(case=case): - fixture = PruneWindowsTests() - fixture.setUp() - try: - fixture.check_merge(case) - finally: - fixture.doCleanups() - - def check_merge(self, case): - self.git("switch", "-c", "upstream/main") - if case == "reverse": - self.git("rm", "win/content.txt") - elif case == "clean": - self.write("new.txt", b"upstream\n") - else: - self.write("win/content.txt", b"upstream\n") - if case in ("mixed", "outside", "content"): - self.write("shared.txt", b"upstream\n") - if case == "add-add": - self.write("win/new.txt", b"upstream\n") - if case == "policy": - self.write("scripts/linux/windows-paths.txt", b"shared.txt\n") - self.commit("upstream") - self.git("switch", "main") - if case in ("allowed", "mixed", "policy"): - self.git("rm", "win/content.txt") - if case in ("mixed", "outside"): - self.git("rm", "shared.txt") - if case in ("reverse", "content"): - self.write("win/content.txt", b"ours\n") - if case == "content": - self.write("shared.txt", b"ours\n") - if case == "add-add": - self.write("win/new.txt", b"ours\n") - if case != "clean": - self.commit("ours") - ours = self.git("rev-parse", "HEAD").stdout.strip() - runner = self.repo / "runner" - runner.mkdir() - self.git("update-ref", "refs/remotes/origin/main", "HEAD") - # The workflow asks gh for an open sync PR; none exists in the fixture. - fake = runner / "bin" - fake.mkdir() - (fake / "gh").write_text("#!/bin/sh\nexit 0\n") - (fake / "gh").chmod(0o755) - env_file = runner / "env" - env = dict(os.environ, RUNNER_TEMP=str(runner), GITHUB_ENV=str(env_file), - PATH=f"{fake}:{os.environ['PATH']}") - self.run_command("bash", "-e", "-o", "pipefail", "-c", MERGE, env=env) - success = case in ("clean", "allowed", "policy") - self.assertIn("CONFLICTS=" + str(not success).lower(), env_file.read_text()) - self.assertEqual("", self.git("diff", "--name-only", "--diff-filter=U").stdout) - self.assertNotEqual(0, self.git("rev-parse", "-q", "--verify", "MERGE_HEAD", check=False).returncode) - if success: - self.assertEqual(2 if case == "clean" else 3, - len(self.git("rev-list", "--parents", "-n", "1", "HEAD").stdout.split())) - if case != "clean": - self.assertFalse((self.repo / "win/content.txt").exists()) - else: - self.assertEqual(ours, self.git("rev-parse", "HEAD").stdout.strip()) - conflicts = (runner / "conflicts.txt").read_text() - self.assertIn("shared.txt" if case in ("mixed", "outside", "content") else "win/", conflicts) - if case == "mixed": - self.assertNotIn("win/content.txt", conflicts) - - -if __name__ == "__main__": - unittest.main() diff --git a/scripts/linux/windows-paths.txt b/scripts/linux/windows-paths.txt deleted file mode 100644 index 12702a9bfd22..000000000000 --- a/scripts/linux/windows-paths.txt +++ /dev/null @@ -1,11 +0,0 @@ -# Track 2 leaf candidates; literal repository-relative paths, directories end in /. -# Audited in docs/linux-port/windows-prune.md. Default Linux/desktop graph only. -# CsWin32, shared projects, app internals, assets and Windows workflows stay. -src/Files.App.BackgroundTasks/ -src/Files.App.Launcher/ -src/Files.App.OpenDialog/ -src/Files.App.SaveDialog/ -src/Files.App.Server/ -src/Files.Platform.Windows/ -tests/Files.App.UITests/ -tests/Files.InteractionTests/ diff --git a/src/Files.App.BackgroundTasks/Files.App.BackgroundTasks.csproj b/src/Files.App.BackgroundTasks/Files.App.BackgroundTasks.csproj deleted file mode 100644 index d3cc7cccad1b..000000000000 --- a/src/Files.App.BackgroundTasks/Files.App.BackgroundTasks.csproj +++ /dev/null @@ -1,28 +0,0 @@ - - - - - $(WindowsTargetFramework) - en-US - $(MinimalWindowsVersion) - true - Debug;Release - x86;x64;ARM64 - win-x86;win-x64;win-arm64 - true - true - true - true - - - - true - $(TargetWindowsVersion) - $(MSBuildProjectDirectory)\bin\$(Platform)\$(Configuration) - - - - - - - diff --git a/src/Files.App.BackgroundTasks/UpdateTask.cs b/src/Files.App.BackgroundTasks/UpdateTask.cs deleted file mode 100644 index ab7e1f9317d0..000000000000 --- a/src/Files.App.BackgroundTasks/UpdateTask.cs +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright (c) Files Community -// Licensed under the MIT License. - -using System; -using System.IO; -using System.Linq; -using System.Threading.Tasks; -using Windows.ApplicationModel.Background; -using Windows.Storage; -using Windows.UI.StartScreen; - -namespace Files.App.BackgroundTasks -{ - public sealed class UpdateTask : IBackgroundTask - { - public async void Run(IBackgroundTaskInstance taskInstance) => await RunAsync(taskInstance); - - private async Task RunAsync(IBackgroundTaskInstance taskInstance) - { - var deferral = taskInstance.GetDeferral(); - - // Refresh jump list to update string resources - try { await RefreshJumpListAsync(); } catch { } - - // Delete previous version log files - try { DeleteLogFiles(); } catch { } - - deferral.Complete(); - } - - private void DeleteLogFiles() - { - File.Delete(Path.Combine(ApplicationData.Current.LocalFolder.Path, "debug.log")); - File.Delete(Path.Combine(ApplicationData.Current.LocalFolder.Path, "debug_fulltrust.log")); - } - - private async Task RefreshJumpListAsync() - { - if (JumpList.IsSupported()) - { - var instance = await JumpList.LoadCurrentAsync(); - // Disable automatic jumplist. It doesn't work with Files UWP. - instance.SystemGroupKind = JumpListSystemGroupKind.None; - - var jumpListItems = instance.Items.ToList(); - - // Clear all items to avoid localization issues - instance.Items.Clear(); - - foreach (var temp in jumpListItems) - { - var jumplistItem = JumpListItem.CreateWithArguments(temp.Arguments, temp.DisplayName); - jumplistItem.Description = jumplistItem.Arguments; - jumplistItem.GroupName = "ms-resource:///Resources/JumpListRecentGroupHeader"; - jumplistItem.Logo = new Uri("ms-appx:///Assets/FolderIcon.png"); - instance.Items.Add(jumplistItem); - } - - await instance.SaveAsync(); - } - } - } -} diff --git a/src/Files.App.Launcher/Files.App.Launcher.filters b/src/Files.App.Launcher/Files.App.Launcher.filters deleted file mode 100644 index a33090deb425..000000000000 --- a/src/Files.App.Launcher/Files.App.Launcher.filters +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx - - - - - - Headers - - - - - - Sources - - - Sources - - - - - - - - - \ No newline at end of file diff --git a/src/Files.App.Launcher/Files.App.Launcher.vcxproj b/src/Files.App.Launcher/Files.App.Launcher.vcxproj deleted file mode 100644 index 8a11cb6cc8d4..000000000000 --- a/src/Files.App.Launcher/Files.App.Launcher.vcxproj +++ /dev/null @@ -1,149 +0,0 @@ - - - - - - Debug - arm64 - - - Debug - Win32 - - - Release - arm64 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 16.0 - Win32Proj - {25fd5045-6d4c-4dd0-b3ac-613ab59cbb07} - FilesAppLauncher - 10.0 - - - Application - true - v145 - Unicode - true - ..\..\artifacts\$(Configuration)\$(Platform)\$(MSBuildProjectName)\ - - - Application - false - v145 - true - Unicode - false - ..\..\artifacts\$(Configuration)\$(Platform)\$(MSBuildProjectName)\ - - - - - Level3 - true - true - stdcpp20 - - - Windows - true - $(OutDir)Files.App.Launcher$(TargetExt) - - - - xcopy /s /y "$(ProjectDir)$(OutDir)*.exe" "$(ProjectDir)..\..\src\Files.App\Assets\FilesOpenDialog" - - - - - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDebug - - - - - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreaded - - - true - true - - - - - _DEBUG;_CONSOLE;%(PreprocessorDefinitions);_SILENCE_EXPERIMENTAL_COROUTINE_DEPRECATION_WARNINGS - MultiThreadedDebug - - - - - _DEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDebug - - - - - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions);_SILENCE_EXPERIMENTAL_COROUTINE_DEPRECATION_WARNINGS - MultiThreaded - - - true - true - - - - - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreaded - - - true - true - - - - - - - - - - - - - - - - - - - - This project references a NuGet package that is not on this computer. To download those packages, use Restore NuGet Packages. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - - \ No newline at end of file diff --git a/src/Files.App.Launcher/FilesLauncher.cpp b/src/Files.App.Launcher/FilesLauncher.cpp deleted file mode 100644 index 29d0357dd1f6..000000000000 --- a/src/Files.App.Launcher/FilesLauncher.cpp +++ /dev/null @@ -1,580 +0,0 @@ -// Copyright (c) Files Community -// Licensed under the MIT License. - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "OpenInFolder.h" - -// Link additional libraries -#pragma comment(lib, "ole32.lib") -#pragma comment(lib, "Propsys.lib") -#pragma comment(lib, "user32.lib") -#pragma comment(lib, "uuid.lib") -#pragma comment(lib, "dwmapi.lib") - -constexpr auto ID_TIMEREXPIRED = 101; - -LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); -bool OpenInExistingShellWindow(const TCHAR* folderPath); -bool IsLaunchedByExplorer(); -void WaitForProtocolActivation(HANDLE hProcess); -void RunFileExplorer(const TCHAR* openDirectory); -size_t strifind(const std::wstring& strHaystack, const std::wstring& strNeedle); -bool comparei(std::wstring stringA, std::wstring stringB); -std::string wstring_to_utf8_hex(const std::wstring& input); -std::wstring str2wstr(const std::string& str); - -int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int cmdShow) -{ - auto oleCleanup = wil::OleInitialize_failfast(); - - FILE* _debugStream = NULL; - PWSTR pszPath = NULL; - HRESULT hr = SHGetKnownFolderPath(FOLDERID_Desktop, 0, NULL, &pszPath); - - if (SUCCEEDED(hr)) - { - TCHAR debugPath[MAX_PATH]; - swprintf(debugPath, _countof(debugPath) - 1, L"%s\\%s", pszPath, L"open_in_folder.txt"); - //_wfreopen_s(&_debugStream, debugPath, L"w", stdout); - CoTaskMemFree(pszPath); - } - - //Uncomment to attach debugger - //Sleep(10 * 1000); - - int numArgs = 0; - bool withArgs = false; - LPWSTR* szArglist = CommandLineToArgvW(GetCommandLine(), &numArgs); - WCHAR openDirectory[MAX_PATH]; - - if (numArgs > 1 && wcsnlen(szArglist[1], 1)) - { - swprintf(openDirectory, _countof(openDirectory) - 1, L"%s", szArglist[1]); - std::wcout << openDirectory << std::endl; - withArgs = true; - } - - LocalFree(szArglist); - - WCHAR szBuf[MAX_PATH]; - ExpandEnvironmentStringsW(L"%LOCALAPPDATA%\\Microsoft\\WindowsApps\\files-dev.exe", szBuf, MAX_PATH - 1); - std::wcout << szBuf << std::endl; - if (_waccess(szBuf, 0) == -1) - { - std::cout << "Files has been uninstalled" << std::endl; - - MessageBox( - NULL, - (LPCWSTR)L"Files has been uninstalled. Restoring File Explorer.", - (LPCWSTR)L"Files", - (UINT)(MB_OK) - ); - - // Uninstall launcher - TCHAR szCmd[MAX_PATH]; - swprintf(szCmd, _countof(szCmd) - 1, L"/c reg.exe import \"%s\"", L"%LocalAppData%\\Files\\UnsetFilesAsDefault.reg"); - if (((int)ShellExecute(0, L"runas", L"cmd.exe", szCmd, 0, SW_HIDE) > 32)) - { - std::cout << "Launcher unset as default" << std::endl; - swprintf(szCmd, _countof(szCmd) - 1, L"-command \"Start-Sleep -Seconds 5; $lfp = [System.Environment]::ExpandEnvironmentVariables('%%LocalAppData%%\\Files'); Remove-Item -Path $lfp -Recurse -Force\""); - if ((int)ShellExecute(0, 0, L"powershell.exe", szCmd, 0, SW_HIDE) > 32) - { - std::cout << "Launcher uninstalled" << std::endl; - } - } - - // Run explorer - RunFileExplorer(withArgs ? openDirectory : NULL); - - if (_debugStream) - fclose(_debugStream); - - return 0; - } - - if (withArgs) - { - if (IsLaunchedByExplorer() && OpenInExistingShellWindow(openDirectory)) - { - if (_debugStream) - fclose(_debugStream); - - return 0; - } - - // Register the window class. - const wchar_t CLASS_NAME[] = L"Files Window Class"; - - WNDCLASSEX wcex = { }; - wcex.cbSize = sizeof(wcex); - wcex.lpfnWndProc = WindowProc; - wcex.cbWndExtra = sizeof(OpenInFolder*); - wcex.hInstance = hInstance; - wcex.lpszClassName = CLASS_NAME; - RegisterClassEx(&wcex); - - winrt::com_ptr openInFolder; - openInFolder.attach(new OpenInFolder()); - - // Create the window. - HWND hwnd = CreateWindowEx( - WS_EX_TOOLWINDOW | WS_EX_NOACTIVATE, - CLASS_NAME, - L"Files Launcher", - 0, - 0, 0, 0, 0, - NULL, - NULL, - hInstance, - openInFolder.get() - ); - - if (hwnd == NULL) - { - if (_debugStream) - fclose(_debugStream); - - return 0; - } - - SetTimer(hwnd, ID_TIMEREXPIRED, 500, NULL); - - MSG msg = { }; - while (GetMessage(&msg, NULL, 0, 0) > 0) - { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - - auto item = openInFolder->GetResult(); - if (IsWindow(hwnd)) - KillTimer(hwnd, ID_TIMEREXPIRED); - - auto launchFiles = [&](const wchar_t* verb, const std::wstring& target, bool waitForActivation) -> bool - { - TCHAR args[1024]; - swprintf(args, _countof(args) - 1, L"\"%s\" %s \"%s\"", szBuf, verb, target.c_str()); - - std::wstring uriWithArgs = L"files-dev:?cmd=" + str2wstr(wstring_to_utf8_hex(args)); - - std::wcout << L"Invoking: " << args << L" = " << uriWithArgs << std::endl; - - SHELLEXECUTEINFO ShExecInfo = { 0 }; - ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO); - ShExecInfo.fMask = SEE_MASK_NOASYNC | SEE_MASK_FLAG_NO_UI | SEE_MASK_NOCLOSEPROCESS; - ShExecInfo.lpFile = uriWithArgs.c_str(); - ShExecInfo.lpDirectory = openDirectory; - ShExecInfo.nShow = SW_SHOW; - - if (!ShellExecuteEx(&ShExecInfo)) - { - std::wcout << L"Protocol error: " << GetLastError() << std::endl; - return false; - } - - if (waitForActivation) - WaitForProtocolActivation(ShExecInfo.hProcess); - else if (ShExecInfo.hProcess) - CloseHandle(ShExecInfo.hProcess); - - return true; - }; - - if (!item.empty()) - { - openInFolder->RevokeShellWindow(); - if (IsWindow(hwnd)) - DestroyWindow(hwnd); - - std::wcout << L"Item: " << item << std::endl; - launchFiles(L"-select", item, true); - } - else if (OpenInExistingShellWindow(openDirectory)) - { - openInFolder->RevokeShellWindow(); - if (IsWindow(hwnd)) - DestroyWindow(hwnd); - - if (_debugStream) - fclose(_debugStream); - - return 0; - } - else - { - // Open the folder right away, but keep the shell window registered and the - // message pump running: a SHOpenFolderAndSelectItems caller that is still - // probing IShellWindows can deliver its selection after the first timeout, - // in which case it is forwarded with a follow-up -select activation. - // Pumping here also keeps the process alive while the asynchronous - // -directory protocol activation is delivered (#18818). - std::wcout << L"No item selected" << std::endl; - - if (launchFiles(L"-directory", openDirectory, false) && IsWindow(hwnd)) - { - SetTimer(hwnd, ID_TIMEREXPIRED, 10000, NULL); - - MSG graceMsg = { }; - while (GetMessage(&graceMsg, NULL, 0, 0) > 0) - { - TranslateMessage(&graceMsg); - DispatchMessage(&graceMsg); - } - - item = openInFolder->GetResult(); - } - - openInFolder->RevokeShellWindow(); - if (IsWindow(hwnd)) - DestroyWindow(hwnd); - - if (!item.empty()) - { - std::wcout << L"Item: " << item << std::endl; - launchFiles(L"-select", item, true); - } - } - } - else - { - std::wcout << L"Invoking: no arguments" << std::endl; - - SHELLEXECUTEINFO ShExecInfo = { 0 }; - ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO); - ShExecInfo.fMask = SEE_MASK_NOASYNC | SEE_MASK_FLAG_NO_UI | SEE_MASK_NOCLOSEPROCESS; - ShExecInfo.lpFile = L"files-dev:"; - ShExecInfo.nShow = SW_SHOW; - - if (!ShellExecuteEx(&ShExecInfo)) - { - std::wcout << L"Protocol error: " << GetLastError() << std::endl; - //ShExecInfo.lpFile = L"files-dev.exe"; - //if (!ShellExecuteEx(&ShExecInfo)) - //{ - //std::wcout << L"Command line error: " << GetLastError() << std::endl; - //} - } - else - { - WaitForProtocolActivation(ShExecInfo.hProcess); - } - } - - if (_debugStream) - fclose(_debugStream); - - return 0; -} - -LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - auto* pContainer = (OpenInFolder*)GetWindowLongPtr(hwnd, GWLP_USERDATA); - - switch (uMsg) - { - case WM_NCCREATE: - { - CREATESTRUCT* pCreate = reinterpret_cast(lParam); - pContainer = reinterpret_cast(pCreate->lpCreateParams); - - if (!pContainer) - { - PostQuitMessage(0); - return 0; - } - - pContainer->SetWindow(hwnd); - SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)pContainer); - - BOOL cloak = TRUE; - DwmSetWindowAttribute(hwnd, DWMWA_CLOAK, &cloak, sizeof(cloak)); - break; - } - - case WM_NCDESTROY: - SetWindowLongPtr(hwnd, GWLP_USERDATA, 0); - return 0; - - case WM_TIMER: - switch (wParam) - { - case ID_TIMEREXPIRED: - PostQuitMessage(0); - return 0; - } - break; - } - - // Jump across to the member window function (will handle all requests). - if (pContainer != nullptr) - return pContainer->WindowProcedure(hwnd, uMsg, wParam, lParam); - else - return DefWindowProc(hwnd, uMsg, wParam, lParam); -} - -size_t strifind(const std::wstring& strHaystack, const std::wstring& strNeedle) -{ - auto it = std::search( - strHaystack.begin(), strHaystack.end(), - strNeedle.begin(), strNeedle.end(), - [](wchar_t ch1, wchar_t ch2) { return std::toupper(ch1) == std::toupper(ch2); } - ); - - return it != strHaystack.end() ? it - strHaystack.begin() : std::wstring::npos; -} - -bool comparei(std::wstring stringA, std::wstring stringB) -{ - auto toUpperW = [](wchar_t c) { return static_cast(std::toupper(c)); }; - transform(stringA.begin(), stringA.end(), stringA.begin(), toUpperW); - transform(stringB.begin(), stringB.end(), stringB.begin(), toUpperW); - - return (stringA == stringB); -} - -std::string wstring_to_utf8_hex(const std::wstring& input) -{ - std::string output; - - int cbNeeded = WideCharToMultiByte(CP_UTF8, 0, input.c_str(), -1, NULL, 0, NULL, NULL); - if (cbNeeded > 0) - { - char* utf8 = new char[cbNeeded]; - if (WideCharToMultiByte(CP_UTF8, 0, input.c_str(), -1, utf8, cbNeeded, NULL, NULL) != 0) - { - for (char* p = utf8; *p; p++) - { - char onehex[5]; - sprintf_s(onehex, sizeof(onehex), "%%%02.2X", (unsigned char)*p); - output.append(onehex); - } - } - - delete[] utf8; - } - - return output; -} - -std::wstring str2wstr(const std::string& str) -{ - int cbNeeded = MultiByteToWideChar(CP_UTF8, 0, &str[0], (int)str.size(), NULL, 0); - if (cbNeeded > 0) - { - std::wstring wstrTo(cbNeeded, 0); - MultiByteToWideChar(CP_UTF8, 0, &str[0], (int)str.size(), &wstrTo[0], cbNeeded); - return wstrTo; - } - - return L""; -} - -// Packaged-app protocol activations are delivered asynchronously even with -// SEE_MASK_NOASYNC; exiting before delivery completes discards the activation -// and Files never opens (#18818). Wait on the activated process when the shell -// provides one, otherwise give the activation broker a grace period. -void WaitForProtocolActivation(HANDLE hProcess) -{ - if (hProcess) - { - WaitForInputIdle(hProcess, 5000); - CloseHandle(hProcess); - } - else - { - Sleep(2000); - } -} - -void RunFileExplorer(const TCHAR* openDirectory) -{ - // Run explorer - SHELLEXECUTEINFO ShExecInfo = { 0 }; - ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO); - ShExecInfo.lpFile = L"explorer.exe"; - - if (openDirectory != NULL) - { - TCHAR args[1024]; - swprintf(args, _countof(args) - 1, L"\"%s\"", openDirectory); - ShExecInfo.lpParameters = args; - } - - ShExecInfo.nShow = SW_SHOW; - ShellExecuteEx(&ShExecInfo); -} - -bool IsLaunchedByExplorer() -{ - DWORD explorerProcessId = 0; - GetWindowThreadProcessId(GetShellWindow(), &explorerProcessId); - if (!explorerProcessId) - return false; - - wil::unique_handle snapshot(CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0)); - if (!snapshot) - return false; - - PROCESSENTRY32 processEntry{ sizeof(processEntry) }; - if (!Process32First(snapshot.get(), &processEntry)) - return false; - - do - { - if (processEntry.th32ProcessID == GetCurrentProcessId()) - return processEntry.th32ParentProcessID == explorerProcessId; - } while (Process32Next(snapshot.get(), &processEntry)); - - return false; -} - -bool OpenInExistingShellWindow(const TCHAR* folderPath) -{ - std::wstring openDirectory(folderPath); - bool mustOpenInExplorer = false; - constexpr auto godModeClsid = L"{ED7BA470-8E54-465E-825C-99712043E01C}"; - - if (strifind(openDirectory, L"::{") == 0) - openDirectory = L"shell:" + openDirectory; - - // Exclude this shell address so that it opens in File Explorer - if (strifind(openDirectory, godModeClsid) != std::wstring::npos) - mustOpenInExplorer = true; - - if (strifind(openDirectory, L"shell:") == 0) - { - std::vector supportedShellFolders{ - L"shell:::{645FF040-5081-101B-9F08-00AA002F954E}", - L"shell:::{5E5F29CE-E0A8-49D3-AF32-7A7BDC173478}", - L"shell:::{20D04FE0-3AEA-1069-A2D8-08002B30309D}", - L"shell:::{F02C1A0D-BE21-4350-88B0-7367FC96EF3C}", - L"shell:::{208D2C60-3AEA-1069-A2D7-08002B30309D}", - L"Shell:RecycleBinFolder", L"Shell:NetworkPlacesFolder", L"Shell:MyComputerFolder" - }; - - auto it = std::find_if( - supportedShellFolders.begin(), supportedShellFolders.end(), - [openDirectory](std::wstring it) { return comparei(it, openDirectory); } - ); - - mustOpenInExplorer = it == supportedShellFolders.end(); - } - - IShellItem* psi; - PIDLIST_ABSOLUTE controlPanelCategoryViewPidl; - - if (!SUCCEEDED(SHCreateItemFromParsingName(L"::{26EE0668-A00A-44D7-9371-BEB064C98683}", NULL, IID_IShellItem, (void**)&psi))) - { - if (mustOpenInExplorer) - RunFileExplorer(openDirectory.c_str()); - - return mustOpenInExplorer; - } - - if (!SUCCEEDED(SHGetIDListFromObject(psi, &controlPanelCategoryViewPidl))) - { - psi->Release(); - if (mustOpenInExplorer) - RunFileExplorer(openDirectory.c_str()); - - return mustOpenInExplorer; - } - - psi->Release(); - - PIDLIST_ABSOLUTE targetFolderPidl; - - if (!SUCCEEDED(SHCreateItemFromParsingName(openDirectory.c_str(), NULL, IID_IShellItem, (void**)&psi))) - { - if (mustOpenInExplorer) - RunFileExplorer(openDirectory.c_str()); - - return mustOpenInExplorer; - } - - if (!SUCCEEDED(SHGetIDListFromObject(psi, &targetFolderPidl))) - { - psi->Release(); - if (mustOpenInExplorer) - RunFileExplorer(openDirectory.c_str()); - - return mustOpenInExplorer; - } - - psi->Release(); - - bool opened = false; - IShellWindows* shellWindows; - if (SUCCEEDED(CoCreateInstance(CLSID_ShellWindows, NULL, CLSCTX_LOCAL_SERVER, IID_IShellWindows, (void**)&shellWindows))) - { - VARIANT v; - V_VT(&v) = VT_I4; - IDispatch* item; - for (V_I4(&v) = 0; SUCCEEDED(shellWindows->Item(v, &item)) && item != NULL; V_I4(&v)++) - { - IServiceProvider* serv; - if (SUCCEEDED(item->QueryInterface(IID_IServiceProvider, (void**)&serv))) - { - IShellBrowser* shellBrowser; - if (SUCCEEDED(serv->QueryService(SID_STopLevelBrowser, IID_IShellBrowser, (void**)&shellBrowser))) - { - IShellView* shellView; - if (SUCCEEDED(shellBrowser->QueryActiveShellView(&shellView))) - { - IFolderView* folderView; - if (SUCCEEDED(shellView->QueryInterface(IID_IFolderView, (void**)&folderView))) - { - IPersistFolder2* folder; - if (SUCCEEDED(folderView->GetFolder(IID_IPersistFolder2, (void**)&folder))) - { - PIDLIST_ABSOLUTE folderPidl; - if (SUCCEEDED(folder->GetCurFolder(&folderPidl))) - { - if (ILIsParent(folderPidl, targetFolderPidl, true) || - ILIsEqual(folderPidl, controlPanelCategoryViewPidl)) - { - if (SUCCEEDED(shellBrowser->BrowseObject(targetFolderPidl, SBSP_SAMEBROWSER | SBSP_ABSOLUTE))) - { - opened = true; - break; - } - } - CoTaskMemFree(folderPidl); - } - folder->Release(); - } - folderView->Release(); - } - shellView->Release(); - } - shellBrowser->Release(); - } - serv->Release(); - } - item->Release(); - } - - shellWindows->Release(); - } - - CoTaskMemFree(targetFolderPidl); - CoTaskMemFree(controlPanelCategoryViewPidl); - - if (!opened && mustOpenInExplorer) - RunFileExplorer(openDirectory.c_str()); - - return opened || mustOpenInExplorer; -} diff --git a/src/Files.App.Launcher/OpenInFolder.cpp b/src/Files.App.Launcher/OpenInFolder.cpp deleted file mode 100644 index e4b01c86f723..000000000000 --- a/src/Files.App.Launcher/OpenInFolder.cpp +++ /dev/null @@ -1,541 +0,0 @@ -// Copyright (c) Files Community -// Licensed under the MIT License. - -#include "OpenInFolder.h" - -#pragma comment(lib, "oleaut32.lib") - -OpenInFolder::OpenInFolder() -{ - m_shellWindows = winrt::create_instance(CLSID_ShellWindows, CLSCTX_ALL); -} - -HRESULT STDMETHODCALLTYPE OpenInFolder::QueryInterface(REFIID riid, void** ppvObject) -{ - RETURN_HR_IF_NULL(E_POINTER, ppvObject); - *ppvObject = nullptr; - - if (riid == IID_IUnknown || riid == IID_IDispatch || riid == IID_IWebBrowser || riid == IID_IWebBrowserApp) - *ppvObject = static_cast(this); - else if (riid == IID_IServiceProvider) - *ppvObject = static_cast(this); - else if (riid == IID_IShellView || riid == IID_IOleWindow) - *ppvObject = static_cast(this); - else - return E_NOINTERFACE; - - AddRef(); - return S_OK; -} - -ULONG STDMETHODCALLTYPE OpenInFolder::AddRef() -{ - return ++m_referenceCount; -} - -ULONG STDMETHODCALLTYPE OpenInFolder::Release() -{ - ULONG referenceCount = --m_referenceCount; - if (!referenceCount) - delete this; - - return referenceCount; -} - -HRESULT STDMETHODCALLTYPE OpenInFolder::GetTypeInfoCount(UINT* pctinfo) -{ - RETURN_HR_IF_NULL(E_POINTER, pctinfo); - *pctinfo = 0; - return S_OK; -} - -HRESULT STDMETHODCALLTYPE OpenInFolder::GetTypeInfo(UINT, LCID, ITypeInfo** ppTInfo) -{ - if (ppTInfo) - *ppTInfo = nullptr; - - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE OpenInFolder::GetIDsOfNames(REFIID, LPOLESTR*, UINT, LCID, DISPID*) -{ - return DISP_E_UNKNOWNNAME; -} - -HRESULT STDMETHODCALLTYPE OpenInFolder::Invoke(DISPID, REFIID, LCID, WORD, DISPPARAMS*, VARIANT*, EXCEPINFO*, UINT*) -{ - return DISP_E_MEMBERNOTFOUND; -} - -HRESULT STDMETHODCALLTYPE OpenInFolder::GoBack() -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE OpenInFolder::GoForward() -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE OpenInFolder::GoHome() -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE OpenInFolder::GoSearch() -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE OpenInFolder::Navigate(BSTR, VARIANT*, VARIANT*, VARIANT*, VARIANT*) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE OpenInFolder::Refresh2(VARIANT*) -{ - return S_OK; -} - -HRESULT STDMETHODCALLTYPE OpenInFolder::Stop() -{ - return S_OK; -} - -HRESULT STDMETHODCALLTYPE OpenInFolder::get_Application(IDispatch** ppDisp) -{ - RETURN_HR_IF_NULL(E_POINTER, ppDisp); - *ppDisp = static_cast(this); - AddRef(); - return S_OK; -} - -HRESULT STDMETHODCALLTYPE OpenInFolder::get_Parent(IDispatch** ppDisp) -{ - return get_Application(ppDisp); -} - -HRESULT STDMETHODCALLTYPE OpenInFolder::get_Container(IDispatch** ppDisp) -{ - return get_Application(ppDisp); -} - -HRESULT STDMETHODCALLTYPE OpenInFolder::get_Document(IDispatch** ppDisp) -{ - return get_Application(ppDisp); -} - -HRESULT STDMETHODCALLTYPE OpenInFolder::get_TopLevelContainer(VARIANT_BOOL* pBool) -{ - RETURN_HR_IF_NULL(E_POINTER, pBool); - *pBool = VARIANT_TRUE; - return S_OK; -} - -HRESULT STDMETHODCALLTYPE OpenInFolder::get_Type(BSTR* type) -{ - RETURN_HR_IF_NULL(E_POINTER, type); - *type = SysAllocString(L"Files"); - return *type ? S_OK : E_OUTOFMEMORY; -} - -HRESULT STDMETHODCALLTYPE OpenInFolder::get_Left(long* value) -{ - RETURN_HR_IF_NULL(E_POINTER, value); - *value = 0; - return S_OK; -} - -HRESULT STDMETHODCALLTYPE OpenInFolder::put_Left(long) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE OpenInFolder::get_Top(long* value) -{ - return get_Left(value); -} - -HRESULT STDMETHODCALLTYPE OpenInFolder::put_Top(long) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE OpenInFolder::get_Width(long* value) -{ - return get_Left(value); -} - -HRESULT STDMETHODCALLTYPE OpenInFolder::put_Width(long) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE OpenInFolder::get_Height(long* value) -{ - return get_Left(value); -} - -HRESULT STDMETHODCALLTYPE OpenInFolder::put_Height(long) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE OpenInFolder::get_LocationName(BSTR* locationName) -{ - RETURN_HR_IF_NULL(E_POINTER, locationName); - *locationName = SysAllocString(L""); - return *locationName ? S_OK : E_OUTOFMEMORY; -} - -HRESULT STDMETHODCALLTYPE OpenInFolder::get_LocationURL(BSTR* locationUrl) -{ - return get_LocationName(locationUrl); -} - -HRESULT STDMETHODCALLTYPE OpenInFolder::get_Busy(VARIANT_BOOL* pBool) -{ - RETURN_HR_IF_NULL(E_POINTER, pBool); - *pBool = VARIANT_FALSE; - return S_OK; -} - -HRESULT STDMETHODCALLTYPE OpenInFolder::Quit() -{ - PostMessage(m_hwnd, WM_CLOSE, 0, 0); - return S_OK; -} - -HRESULT STDMETHODCALLTYPE OpenInFolder::ClientToWindow(int* width, int* height) -{ - return width && height ? S_OK : E_POINTER; -} - -HRESULT STDMETHODCALLTYPE OpenInFolder::PutProperty(BSTR, VARIANT) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE OpenInFolder::GetProperty(BSTR, VARIANT* value) -{ - RETURN_HR_IF_NULL(E_POINTER, value); - VariantInit(value); - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE OpenInFolder::get_Name(BSTR* name) -{ - return get_Type(name); -} - -HRESULT STDMETHODCALLTYPE OpenInFolder::get_HWND(SHANDLE_PTR* hwnd) -{ - RETURN_HR_IF_NULL(E_POINTER, hwnd); - *hwnd = reinterpret_cast(m_hwnd); - return S_OK; -} - -HRESULT STDMETHODCALLTYPE OpenInFolder::get_FullName(BSTR* fullName) -{ - RETURN_HR_IF_NULL(E_POINTER, fullName); - wchar_t modulePath[MAX_PATH]; - if (!GetModuleFileNameW(nullptr, modulePath, _countof(modulePath))) - return HRESULT_FROM_WIN32(GetLastError()); - - *fullName = SysAllocString(modulePath); - return *fullName ? S_OK : E_OUTOFMEMORY; -} - -HRESULT STDMETHODCALLTYPE OpenInFolder::get_Path(BSTR* path) -{ - return get_FullName(path); -} - -HRESULT STDMETHODCALLTYPE OpenInFolder::get_Visible(VARIANT_BOOL* value) -{ - RETURN_HR_IF_NULL(E_POINTER, value); - *value = VARIANT_FALSE; - return S_OK; -} - -HRESULT STDMETHODCALLTYPE OpenInFolder::put_Visible(VARIANT_BOOL) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE OpenInFolder::get_StatusBar(VARIANT_BOOL* value) -{ - return get_Visible(value); -} - -HRESULT STDMETHODCALLTYPE OpenInFolder::put_StatusBar(VARIANT_BOOL) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE OpenInFolder::get_StatusText(BSTR* statusText) -{ - return get_LocationName(statusText); -} - -HRESULT STDMETHODCALLTYPE OpenInFolder::put_StatusText(BSTR) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE OpenInFolder::get_ToolBar(int* value) -{ - RETURN_HR_IF_NULL(E_POINTER, value); - *value = 0; - return S_OK; -} - -HRESULT STDMETHODCALLTYPE OpenInFolder::put_ToolBar(int) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE OpenInFolder::get_MenuBar(VARIANT_BOOL* value) -{ - return get_Visible(value); -} - -HRESULT STDMETHODCALLTYPE OpenInFolder::put_MenuBar(VARIANT_BOOL) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE OpenInFolder::get_FullScreen(VARIANT_BOOL* value) -{ - return get_Visible(value); -} - -HRESULT STDMETHODCALLTYPE OpenInFolder::put_FullScreen(VARIANT_BOOL) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE OpenInFolder::QueryService(REFGUID, REFIID riid, void** ppvObject) -{ - RETURN_HR_IF_NULL(E_POINTER, ppvObject); - *ppvObject = nullptr; - return QueryInterface(riid, ppvObject); -} - -HRESULT STDMETHODCALLTYPE OpenInFolder::GetWindow(HWND* phwnd) -{ - RETURN_HR_IF_NULL(E_POINTER, phwnd); - *phwnd = m_hwnd; - return m_hwnd ? S_OK : E_FAIL; -} - -HRESULT STDMETHODCALLTYPE OpenInFolder::ContextSensitiveHelp(BOOL) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE OpenInFolder::TranslateAccelerator(MSG*) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE OpenInFolder::EnableModeless(BOOL) -{ - return S_OK; -} - -HRESULT STDMETHODCALLTYPE OpenInFolder::UIActivate(UINT) -{ - return S_OK; -} - -HRESULT STDMETHODCALLTYPE OpenInFolder::Refresh() -{ - return S_OK; -} - -HRESULT STDMETHODCALLTYPE OpenInFolder::CreateViewWindow(IShellView*, LPCFOLDERSETTINGS, IShellBrowser*, RECT*, HWND* phWnd) -{ - if (phWnd) - *phWnd = NULL; - - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE OpenInFolder::DestroyViewWindow() -{ - return S_OK; -} - -HRESULT STDMETHODCALLTYPE OpenInFolder::GetCurrentInfo(LPFOLDERSETTINGS pfs) -{ - RETURN_HR_IF_NULL(E_POINTER, pfs); - *pfs = {}; - return S_OK; -} - -HRESULT STDMETHODCALLTYPE OpenInFolder::AddPropertySheetPages(DWORD, LPFNSVADDPROPSHEETPAGE, LPARAM) -{ - return E_NOTIMPL; -} - -HRESULT STDMETHODCALLTYPE OpenInFolder::SaveViewState() -{ - return S_OK; -} - -HRESULT OpenInFolder::GetSelectedItem(PCUITEMID_CHILD pidlItem, PIDLIST_ABSOLUTE* pidlAbsolute) -{ - RETURN_HR_IF_NULL(E_INVALIDARG, pidlItem); - RETURN_HR_IF_NULL(E_POINTER, pidlAbsolute); - *pidlAbsolute = nullptr; - RETURN_HR_IF_NULL(E_UNEXPECTED, m_folderPidl); - - *pidlAbsolute = ILCombine(m_folderPidl, pidlItem); - return *pidlAbsolute ? S_OK : E_OUTOFMEMORY; -} - -HRESULT STDMETHODCALLTYPE OpenInFolder::SelectItem(PCUITEMID_CHILD pidlItem, SVSIF uFlags) -{ - if (!pidlItem || !(uFlags & (SVSI_SELECT | SVSI_FOCUSED | SVSI_ENSUREVISIBLE | SVSI_EDIT))) - return S_OK; - - PIDLIST_ABSOLUTE pidlAbsolute = nullptr; - RETURN_IF_FAILED(GetSelectedItem(pidlItem, &pidlAbsolute)); - - OnItemSelected(pidlAbsolute); - CoTaskMemFree(pidlAbsolute); - return S_OK; -} - -HRESULT STDMETHODCALLTYPE OpenInFolder::GetItemObject(UINT, REFIID, void** ppv) -{ - if (ppv) - *ppv = nullptr; - - return E_NOINTERFACE; -} - -void OpenInFolder::SetWindow(HWND hwnd) -{ - m_hwnd = hwnd; -} - -void OpenInFolder::OnCreate() -{ - int numArgs = 0; - LPWSTR* szArglist = CommandLineToArgvW(GetCommandLine(), &numArgs); - WCHAR openDirectory[MAX_PATH]; - - if (numArgs < 2) - { - LocalFree(szArglist); - return; - } - else - { - wsprintf(openDirectory, L"%s", szArglist[1]); - } - - LocalFree(szArglist); - - winrt::com_ptr desktop; - if (FAILED(SHGetDesktopFolder(desktop.put()))) - return; - - if (FAILED(desktop->ParseDisplayName( - nullptr, - nullptr, - openDirectory, - nullptr, - &m_folderPidl, - nullptr))) - return; - - if (!SUCCEEDED(NotifyShellOfNavigation(m_folderPidl))) - return; -} - -LRESULT CALLBACK OpenInFolder::WindowProcedure(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam) -{ - switch (Msg) - { - case WM_CREATE: - OnCreate(); - break; - - case WM_CLOSE: - DestroyWindow(hwnd); - break; - - case WM_DESTROY: - PostQuitMessage(0); - break; - } - - return DefWindowProc(hwnd, Msg, wParam, lParam); -} - -HRESULT OpenInFolder::NotifyShellOfNavigation(PCIDLIST_ABSOLUTE pidl) -{ - wil::unique_variant pidlVariant; - RETURN_IF_FAILED(InitVariantFromBuffer(pidl, ILGetSize(pidl), &pidlVariant)); - - wil::unique_variant empty; - RETURN_IF_FAILED(m_shellWindows->RegisterPending(GetCurrentThreadId(), &pidlVariant, &empty, SWC_BROWSER, &m_pendingCookie)); - m_isPendingRegistered = true; - RETURN_IF_FAILED(m_shellWindows->Register(static_cast(this), HandleToLong(m_hwnd), SWC_BROWSER, &m_shellWindowCookie)); - m_isRegistered = true; - - RETURN_IF_FAILED(m_shellWindows->OnNavigate(m_shellWindowCookie, &pidlVariant)); - - return S_OK; -} - -void OpenInFolder::OnItemSelected(PIDLIST_ABSOLUTE pidl) -{ - IShellItem* item = NULL; - if (SUCCEEDED(SHCreateItemFromIDList(pidl, IID_IShellItem, (void**)&item))) - { - PWSTR pszPath = NULL; - if (SUCCEEDED(item->GetDisplayName(SIGDN_DESKTOPABSOLUTEPARSING, &pszPath))) - { - m_selectedItem = pszPath; - PostMessage(m_hwnd, WM_CLOSE, 0, 0); - CoTaskMemFree(pszPath); - } - - item->Release(); - } -} - -std::wstring OpenInFolder::GetResult() -{ - return m_selectedItem; -} - -void OpenInFolder::RevokeShellWindow() -{ - if (!m_shellWindows) - return; - - if (m_isRegistered) - { - m_isRegistered = false; - m_shellWindows->Revoke(m_shellWindowCookie); - } - - if (m_isPendingRegistered) - { - m_isPendingRegistered = false; - - // Register may complete the pending registration under the same cookie - if (m_pendingCookie != m_shellWindowCookie) - m_shellWindows->Revoke(m_pendingCookie); - } -} - -OpenInFolder::~OpenInFolder() -{ - CoTaskMemFree(m_folderPidl); -} diff --git a/src/Files.App.Launcher/OpenInFolder.h b/src/Files.App.Launcher/OpenInFolder.h deleted file mode 100644 index 72667f4c8e03..000000000000 --- a/src/Files.App.Launcher/OpenInFolder.h +++ /dev/null @@ -1,120 +0,0 @@ -// Copyright (c) Files Community -// Licensed under the MIT License. - -#pragma once - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -class OpenInFolder final : public IWebBrowserApp, public IServiceProvider, public IShellView -{ - std::atomic m_referenceCount{ 1 }; - HWND m_hwnd = NULL; - winrt::com_ptr m_shellWindows; - PIDLIST_ABSOLUTE m_folderPidl = NULL; - long m_pendingCookie = 0; - long m_shellWindowCookie = 0; - bool m_isPendingRegistered = false; - bool m_isRegistered = false; - - HRESULT NotifyShellOfNavigation(PCIDLIST_ABSOLUTE pidl); - HRESULT GetSelectedItem(PCUITEMID_CHILD pidlItem, PIDLIST_ABSOLUTE* pidlAbsolute); - - std::wstring m_selectedItem; - -public: - OpenInFolder(); - ~OpenInFolder(); - - // IUnknown - HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject) override; - ULONG STDMETHODCALLTYPE AddRef() override; - ULONG STDMETHODCALLTYPE Release() override; - - // IDispatch - HRESULT STDMETHODCALLTYPE GetTypeInfoCount(UINT* pctinfo) override; - HRESULT STDMETHODCALLTYPE GetTypeInfo(UINT iTInfo, LCID lcid, ITypeInfo** ppTInfo) override; - HRESULT STDMETHODCALLTYPE GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames, UINT cNames, LCID lcid, DISPID* rgDispId) override; - HRESULT STDMETHODCALLTYPE Invoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr) override; - - // IWebBrowserApp - HRESULT STDMETHODCALLTYPE GoBack() override; - HRESULT STDMETHODCALLTYPE GoForward() override; - HRESULT STDMETHODCALLTYPE GoHome() override; - HRESULT STDMETHODCALLTYPE GoSearch() override; - HRESULT STDMETHODCALLTYPE Navigate(BSTR url, VARIANT* flags, VARIANT* targetFrameName, VARIANT* postData, VARIANT* headers) override; - HRESULT STDMETHODCALLTYPE Refresh2(VARIANT* level) override; - HRESULT STDMETHODCALLTYPE Stop() override; - HRESULT STDMETHODCALLTYPE get_Application(IDispatch** ppDisp) override; - HRESULT STDMETHODCALLTYPE get_Parent(IDispatch** ppDisp) override; - HRESULT STDMETHODCALLTYPE get_Container(IDispatch** ppDisp) override; - HRESULT STDMETHODCALLTYPE get_Document(IDispatch** ppDisp) override; - HRESULT STDMETHODCALLTYPE get_TopLevelContainer(VARIANT_BOOL* pBool) override; - HRESULT STDMETHODCALLTYPE get_Type(BSTR* type) override; - HRESULT STDMETHODCALLTYPE get_Left(long* value) override; - HRESULT STDMETHODCALLTYPE put_Left(long value) override; - HRESULT STDMETHODCALLTYPE get_Top(long* value) override; - HRESULT STDMETHODCALLTYPE put_Top(long value) override; - HRESULT STDMETHODCALLTYPE get_Width(long* value) override; - HRESULT STDMETHODCALLTYPE put_Width(long value) override; - HRESULT STDMETHODCALLTYPE get_Height(long* value) override; - HRESULT STDMETHODCALLTYPE put_Height(long value) override; - HRESULT STDMETHODCALLTYPE get_LocationName(BSTR* locationName) override; - HRESULT STDMETHODCALLTYPE get_LocationURL(BSTR* locationUrl) override; - HRESULT STDMETHODCALLTYPE get_Busy(VARIANT_BOOL* pBool) override; - HRESULT STDMETHODCALLTYPE Quit() override; - HRESULT STDMETHODCALLTYPE ClientToWindow(int* width, int* height) override; - HRESULT STDMETHODCALLTYPE PutProperty(BSTR property, VARIANT value) override; - HRESULT STDMETHODCALLTYPE GetProperty(BSTR property, VARIANT* value) override; - HRESULT STDMETHODCALLTYPE get_Name(BSTR* name) override; - HRESULT STDMETHODCALLTYPE get_HWND(SHANDLE_PTR* hwnd) override; - HRESULT STDMETHODCALLTYPE get_FullName(BSTR* fullName) override; - HRESULT STDMETHODCALLTYPE get_Path(BSTR* path) override; - HRESULT STDMETHODCALLTYPE get_Visible(VARIANT_BOOL* value) override; - HRESULT STDMETHODCALLTYPE put_Visible(VARIANT_BOOL value) override; - HRESULT STDMETHODCALLTYPE get_StatusBar(VARIANT_BOOL* value) override; - HRESULT STDMETHODCALLTYPE put_StatusBar(VARIANT_BOOL value) override; - HRESULT STDMETHODCALLTYPE get_StatusText(BSTR* statusText) override; - HRESULT STDMETHODCALLTYPE put_StatusText(BSTR statusText) override; - HRESULT STDMETHODCALLTYPE get_ToolBar(int* value) override; - HRESULT STDMETHODCALLTYPE put_ToolBar(int value) override; - HRESULT STDMETHODCALLTYPE get_MenuBar(VARIANT_BOOL* value) override; - HRESULT STDMETHODCALLTYPE put_MenuBar(VARIANT_BOOL value) override; - HRESULT STDMETHODCALLTYPE get_FullScreen(VARIANT_BOOL* value) override; - HRESULT STDMETHODCALLTYPE put_FullScreen(VARIANT_BOOL value) override; - - // IServiceProvider - HRESULT STDMETHODCALLTYPE QueryService(REFGUID guidService, REFIID riid, void** ppvObject) override; - - // IOleWindow - HRESULT STDMETHODCALLTYPE GetWindow(HWND* phwnd) override; - HRESULT STDMETHODCALLTYPE ContextSensitiveHelp(BOOL fEnterMode) override; - - // IShellView - HRESULT STDMETHODCALLTYPE TranslateAccelerator(MSG* pmsg) override; - HRESULT STDMETHODCALLTYPE EnableModeless(BOOL fEnable) override; - HRESULT STDMETHODCALLTYPE UIActivate(UINT uState) override; - HRESULT STDMETHODCALLTYPE Refresh() override; - HRESULT STDMETHODCALLTYPE CreateViewWindow(IShellView* psvPrevious, LPCFOLDERSETTINGS pfs, IShellBrowser* psb, RECT* prcView, HWND* phWnd) override; - HRESULT STDMETHODCALLTYPE DestroyViewWindow() override; - HRESULT STDMETHODCALLTYPE GetCurrentInfo(LPFOLDERSETTINGS pfs) override; - HRESULT STDMETHODCALLTYPE AddPropertySheetPages(DWORD dwReserved, LPFNSVADDPROPSHEETPAGE pfn, LPARAM lparam) override; - HRESULT STDMETHODCALLTYPE SaveViewState() override; - HRESULT STDMETHODCALLTYPE SelectItem(PCUITEMID_CHILD pidlItem, SVSIF uFlags) override; - HRESULT STDMETHODCALLTYPE GetItemObject(UINT uItem, REFIID riid, void** ppv) override; - - LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam); - void SetWindow(HWND hwnd); - void OnItemSelected(PIDLIST_ABSOLUTE pidl); - void OnCreate(); - void RevokeShellWindow(); - std::wstring GetResult(); -}; diff --git a/src/Files.App.Launcher/packages.config b/src/Files.App.Launcher/packages.config deleted file mode 100644 index f3255c961719..000000000000 --- a/src/Files.App.Launcher/packages.config +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/src/Files.App.OpenDialog/CustomOpenDialog.cpp b/src/Files.App.OpenDialog/CustomOpenDialog.cpp deleted file mode 100644 index c2a17467526b..000000000000 --- a/src/Files.App.OpenDialog/CustomOpenDialog.cpp +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright (c) Files Community -// Licensed under the MIT License. - -// Abstract: -// Implementation of DLL exports. - -#include "pch.h" -#include "framework.h" -#include "resource.h" -#include "CustomOpenDialog_i.h" -#include "dllmain.h" - -using namespace ATL; - -// Used to determine if the DLL can be downloaded by OLE. -_Use_decl_annotations_ -STDAPI DllCanUnloadNow(void) -{ - return _AtlModule.DllCanUnloadNow(); -} - -// Returns a class factory to create an object of the requested type. -_Use_decl_annotations_ -STDAPI DllGetClassObject(_In_ REFCLSID rclsid, _In_ REFIID riid, _Outptr_ LPVOID* ppv) -{ - return _AtlModule.DllGetClassObject(rclsid, riid, ppv); -} - -// DllRegisterServer: Add entries to the registry. -_Use_decl_annotations_ -STDAPI DllRegisterServer(void) -{ - // Registers objects, type libraries, and all type library interfaces - HRESULT hr = _AtlModule.DllRegisterServer(); - return hr; -} - -// DllUnregisterServer - Remove entries from the registry. -_Use_decl_annotations_ -STDAPI DllUnregisterServer(void) -{ - HRESULT hr = _AtlModule.DllUnregisterServer(); - return hr; -} - -// DllInstall - Add/Remove entries in the registry for each user on each computer. -STDAPI DllInstall(BOOL bInstall, _In_opt_ LPCWSTR pszCmdLine) -{ - HRESULT hr = E_FAIL; - static const wchar_t szUserSwitch[] = L"user"; - - if (pszCmdLine != nullptr) - { - if (_wcsnicmp(pszCmdLine, szUserSwitch, _countof(szUserSwitch)) == 0) - ATL::AtlSetPerUserRegistration(true); - } - - if (bInstall) - { - hr = DllRegisterServer(); - if (FAILED(hr)) - DllUnregisterServer(); - } - else - { - hr = DllUnregisterServer(); - } - - return hr; -} diff --git a/src/Files.App.OpenDialog/CustomOpenDialog.def b/src/Files.App.OpenDialog/CustomOpenDialog.def deleted file mode 100644 index 7ae8bf3744eb..000000000000 --- a/src/Files.App.OpenDialog/CustomOpenDialog.def +++ /dev/null @@ -1,14 +0,0 @@ -; Copyright (c) Files Community -; Licensed under the MIT License. - -; Abstract: -; Declaration the parameters of the module. - -LIBRARY - -EXPORTS - DllCanUnloadNow PRIVATE - DllGetClassObject PRIVATE - DllRegisterServer PRIVATE - DllUnregisterServer PRIVATE - DllInstall PRIVATE diff --git a/src/Files.App.OpenDialog/CustomOpenDialog.idl b/src/Files.App.OpenDialog/CustomOpenDialog.idl deleted file mode 100644 index 61b4cfa48fba..000000000000 --- a/src/Files.App.OpenDialog/CustomOpenDialog.idl +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) Files Community -// Licensed under the MIT License. - -// Abstract: -// IDL source for CustomOpenDialog. - -// Note: -// This file will be processed by the MIDL tool for -// produces the type library (CustomOpenDialog.tlb) and marshaling code. - -import "oaidl.idl"; -import "ocidl.idl"; - -[uuid(14533360-0b0c-44e6-9e5f-8ec8a478158d), version(1.0)] -library CustomOpenDialogLib -{ - importlib("stdole2.tlb"); - - [uuid(DC1C5A9C-E88A-4DDE-A5A1-60F82A20AEF7)] - coclass FilesOpenDialog - { - [default] interface IFileOpenDialog; - interface IFileDialog; - interface IFileDialogCustomize; - interface IFileDialog2; - interface IObjectWithSite; - //interface IFileDialogPrivate; - }; -}; - -import "shobjidl.idl"; diff --git a/src/Files.App.OpenDialog/CustomOpenDialog.rc b/src/Files.App.OpenDialog/CustomOpenDialog.rc deleted file mode 100644 index 290906c6d978..000000000000 Binary files a/src/Files.App.OpenDialog/CustomOpenDialog.rc and /dev/null differ diff --git a/src/Files.App.OpenDialog/CustomOpenDialog.rgs b/src/Files.App.OpenDialog/CustomOpenDialog.rgs deleted file mode 100644 index e7d37400e19a..000000000000 --- a/src/Files.App.OpenDialog/CustomOpenDialog.rgs +++ /dev/null @@ -1,3 +0,0 @@ -HKCR -{ -} diff --git a/src/Files.App.OpenDialog/CustomOpenDialogps.def b/src/Files.App.OpenDialog/CustomOpenDialogps.def deleted file mode 100644 index 2a4265afa9fb..000000000000 --- a/src/Files.App.OpenDialog/CustomOpenDialogps.def +++ /dev/null @@ -1,8 +0,0 @@ - -LIBRARY - -EXPORTS - DllGetClassObject PRIVATE - DllCanUnloadNow PRIVATE - DllRegisterServer PRIVATE - DllUnregisterServer PRIVATE diff --git a/src/Files.App.OpenDialog/Files.App.OpenDialog.Win32.vcxproj b/src/Files.App.OpenDialog/Files.App.OpenDialog.Win32.vcxproj deleted file mode 100644 index d072282809f8..000000000000 --- a/src/Files.App.OpenDialog/Files.App.OpenDialog.Win32.vcxproj +++ /dev/null @@ -1,205 +0,0 @@ - - - - - Debug - arm64 - - - Debug - Win32 - - - Release - arm64 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 16.0 - {B3FE3F3B-CECC-4918-B72B-5488C3774125} - AtlProj - 10.0 - DynamicLibrary - true - v145 - Unicode - - - - - - true - true - ..\..\artifacts\$(Configuration)\$(Platform)\$(MSBuildProjectName)\ - ..\..\artifacts\intermediates\$(Platform)\$(MSBuildProjectName)\ - Files.App.OpenDialog$(PlatformArchitecture) - - - true - false - false - ..\..\artifacts\$(Configuration)\$(Platform)\$(MSBuildProjectName)\ - ..\..\artifacts\intermediates\$(Platform)\$(MSBuildProjectName)\ - Files.App.OpenDialog$(PlatformArchitecture) - - - - Use - Level3 - pch.h - true - - - false - CustomOpenDialog_i.h - CustomOpenDialog_i.c - CustomOpenDialog_p.c - true - $(IntDir)CustomOpenDialog.tlb - true - - - 0x0410 - $(IntDir);%(AdditionalIncludeDirectories) - - - Windows - .\CustomOpenDialog.def - false - true - $(OutDir)Files.App.OpenDialog$(PlatformArchitecture)$(TargetExt) - - - xcopy /s /y "$(ProjectDir)$(OutDir)*.dll" "$(ProjectDir)..\..\src\Files.App\Assets\FilesOpenDialog" - - - - - Disabled - WIN32;_WINDOWS;_DEBUG;_USRDLL;%(PreprocessorDefinitions) - - - Win32 - _DEBUG;%(PreprocessorDefinitions) - - - _DEBUG;%(PreprocessorDefinitions) - - - - - Disabled - _WINDOWS;_DEBUG;_USRDLL;%(PreprocessorDefinitions) - - - _DEBUG;%(PreprocessorDefinitions) - - - _DEBUG;%(PreprocessorDefinitions) - - - - - Disabled - _WINDOWS;_DEBUG;_USRDLL;%(PreprocessorDefinitions) - - - _DEBUG;%(PreprocessorDefinitions) - - - _DEBUG;%(PreprocessorDefinitions) - - - - - MaxSpeed - WIN32;_WINDOWS;NDEBUG;_USRDLL;%(PreprocessorDefinitions) - - - Win32 - NDEBUG;%(PreprocessorDefinitions) - - - NDEBUG;%(PreprocessorDefinitions) - - - true - true - - - - - MaxSpeed - _WINDOWS;NDEBUG;_USRDLL;%(PreprocessorDefinitions) - - - NDEBUG;%(PreprocessorDefinitions) - - - NDEBUG;%(PreprocessorDefinitions) - - - true - true - - - - - MaxSpeed - _WINDOWS;NDEBUG;_USRDLL;%(PreprocessorDefinitions) - - - NDEBUG;%(PreprocessorDefinitions) - - - NDEBUG;%(PreprocessorDefinitions) - - - true - true - - - - - - - - - - - - - - false - - - - - false - - - - - - Create - - - - - - - - - \ No newline at end of file diff --git a/src/Files.App.OpenDialog/Files.App.OpenDialog.filters b/src/Files.App.OpenDialog/Files.App.OpenDialog.filters deleted file mode 100644 index 903ad78668dc..000000000000 --- a/src/Files.App.OpenDialog/Files.App.OpenDialog.filters +++ /dev/null @@ -1,90 +0,0 @@ - - - - - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - {abc5c222-f2d9-4149-b7c5-c26f1a437824} - False - - - - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - - - - Sources - - - Sources - - - Generated - - - Sources - - - Sources - - - Sources - - - - - - Resources - - - Resources - - - Sources - - - Resources - - - - - - Generated - - - - diff --git a/src/Files.App.OpenDialog/Files.App.OpenDialog.vcxproj b/src/Files.App.OpenDialog/Files.App.OpenDialog.vcxproj deleted file mode 100644 index d77c8863ef63..000000000000 --- a/src/Files.App.OpenDialog/Files.App.OpenDialog.vcxproj +++ /dev/null @@ -1,205 +0,0 @@ - - - - - Debug - arm64 - - - Debug - Win32 - - - Release - arm64 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 16.0 - {A2FF3F3B-8EBC-4108-B99D-1476B7876656} - AtlProj - 10.0 - DynamicLibrary - true - v145 - Unicode - - - - - - true - true - ..\..\artifacts\$(Configuration)\$(Platform)\$(MSBuildProjectName)\ - ..\..\artifacts\intermediates\$(Platform)\$(MSBuildProjectName)\ - Files.App.OpenDialog$(PlatformArchitecture) - - - true - false - false - ..\..\artifacts\$(Configuration)\$(Platform)\$(MSBuildProjectName)\ - ..\..\artifacts\intermediates\$(Platform)\$(MSBuildProjectName)\ - Files.App.OpenDialog$(PlatformArchitecture) - - - - Use - Level3 - pch.h - true - - - false - CustomOpenDialog_i.h - CustomOpenDialog_i.c - CustomOpenDialog_p.c - true - $(IntDir)CustomOpenDialog.tlb - true - - - 0x0410 - $(IntDir);%(AdditionalIncludeDirectories) - - - Windows - .\CustomOpenDialog.def - false - true - $(OutDir)Files.App.OpenDialog$(PlatformArchitecture)$(TargetExt) - - - xcopy /s /y "$(ProjectDir)$(OutDir)*.dll" "$(ProjectDir)..\..\src\Files.App\Assets\FilesOpenDialog" - - - - - Disabled - WIN32;_WINDOWS;_DEBUG;_USRDLL;%(PreprocessorDefinitions) - - - Win32 - _DEBUG;%(PreprocessorDefinitions) - - - _DEBUG;%(PreprocessorDefinitions) - - - - - Disabled - _WINDOWS;_DEBUG;_USRDLL;%(PreprocessorDefinitions) - - - _DEBUG;%(PreprocessorDefinitions) - - - _DEBUG;%(PreprocessorDefinitions) - - - - - Disabled - _WINDOWS;_DEBUG;_USRDLL;%(PreprocessorDefinitions) - - - _DEBUG;%(PreprocessorDefinitions) - - - _DEBUG;%(PreprocessorDefinitions) - - - - - MaxSpeed - WIN32;_WINDOWS;NDEBUG;_USRDLL;%(PreprocessorDefinitions) - - - Win32 - NDEBUG;%(PreprocessorDefinitions) - - - NDEBUG;%(PreprocessorDefinitions) - - - true - true - - - - - MaxSpeed - _WINDOWS;NDEBUG;_USRDLL;%(PreprocessorDefinitions) - - - NDEBUG;%(PreprocessorDefinitions) - - - NDEBUG;%(PreprocessorDefinitions) - - - true - true - - - - - MaxSpeed - _WINDOWS;NDEBUG;_USRDLL;%(PreprocessorDefinitions) - - - NDEBUG;%(PreprocessorDefinitions) - - - NDEBUG;%(PreprocessorDefinitions) - - - true - true - - - - - - - - - - - - - - false - - - - - false - - - - - - Create - - - - - - - - - \ No newline at end of file diff --git a/src/Files.App.OpenDialog/FilesOpenDialog.cpp b/src/Files.App.OpenDialog/FilesOpenDialog.cpp deleted file mode 100644 index b82daab42fae..000000000000 --- a/src/Files.App.OpenDialog/FilesOpenDialog.cpp +++ /dev/null @@ -1,1050 +0,0 @@ -// Copyright (c) Files Community -// Licensed under the MIT License. - -// Abstract: -// Implementation of CFilesOpenDialog. - -#include "pch.h" -#include -#include -#include -#include -#include -#include -#include "FilesOpenDialog.h" - -//#define SYSTEMDIALOG - -using std::cout; -using std::wcout; -using std::endl; - -CComPtr GetSystemDialog() -{ - WCHAR comdlg32Path[MAX_PATH]; - ExpandEnvironmentStringsW(L"%WINDIR%\\System32\\comdlg32.dll", comdlg32Path, MAX_PATH - 1); - - HINSTANCE lib = CoLoadLibrary(comdlg32Path, false); - BOOL(WINAPI* dllGetClassObject)(REFCLSID, REFIID, LPVOID*) = - (BOOL(WINAPI*)(REFCLSID, REFIID, LPVOID*))GetProcAddress(lib, "DllGetClassObject"); - CComPtr pClassFactory; - dllGetClassObject(CLSID_FileOpenDialog, IID_IClassFactory, (void**)&pClassFactory); - CComPtr systemDialog; - pClassFactory->CreateInstance(NULL, IID_IFileOpenDialog, (void**)&systemDialog); - //CoFreeLibrary(lib); - return systemDialog; -} - -std::string wstring_to_utf8_hex(const std::wstring& input) -{ - std::string output; - - int cbNeeded = WideCharToMultiByte(CP_UTF8, 0, input.c_str(), -1, NULL, 0, NULL, NULL); - if (cbNeeded > 0) - { - char* utf8 = new char[cbNeeded]; - if (WideCharToMultiByte(CP_UTF8, 0, input.c_str(), -1, utf8, cbNeeded, NULL, NULL) != 0) - { - for (char* p = utf8; *p; p++) - { - char onehex[5]; - sprintf_s(onehex, sizeof(onehex), "%%%02.2X", (unsigned char)*p); - output.append(onehex); - } - } - - delete[] utf8; - } - - return output; -} - -std::wstring str2wstr(const std::string& str) -{ - int cbNeeded = MultiByteToWideChar(CP_UTF8, 0, &str[0], (int)str.size(), NULL, 0); - if (cbNeeded > 0) - { - std::wstring wstrTo(cbNeeded, 0); - MultiByteToWideChar(CP_UTF8, 0, &str[0], (int)str.size(), &wstrTo[0], cbNeeded); - return wstrTo; - } - - return L""; -} - -template -CComPtr AsInterface(CComPtr dialog) -{ - CComPtr dialogInterface; - dialog->QueryInterface(&dialogInterface); - - return dialogInterface; -} - -CFilesOpenDialog::CFilesOpenDialog() -{ - _fos = FOS_FILEMUSTEXIST | FOS_PATHMUSTEXIST; - _systemDialog = nullptr; - _debugStream = NULL; - _dialogEvents = NULL; - - PWSTR pszPath = NULL; - HRESULT hr = SHGetKnownFolderPath(FOLDERID_Desktop, 0, NULL, &pszPath); - if (SUCCEEDED(hr)) - { - TCHAR debugPath[MAX_PATH]; - wsprintf(debugPath, L"%s\\%s", pszPath, L"open_dialog.txt"); -#ifdef DEBUGLOG - _wfreopen_s(&_debugStream, debugPath, L"w", stdout); -#endif - CoTaskMemFree(pszPath); - } - - cout << "Create" << endl; - - TCHAR tempPath[MAX_PATH]; - GetTempPath(MAX_PATH, tempPath); - TCHAR tempName[MAX_PATH]; - GetTempFileName(tempPath, L"fsd", 0, tempName); - _outputPath = tempName; - - (void)SHGetKnownFolderItem(FOLDERID_Documents, KF_FLAG_DEFAULT_PATH, NULL, IID_PPV_ARGS(&_initFolder)); - - if (_initFolder && SUCCEEDED(_initFolder->GetDisplayName(SIGDN_NORMALDISPLAY, &pszPath))) - { - wcout << L"_outputPath: " << _outputPath << L", _initFolder: " << pszPath << endl; - CoTaskMemFree(pszPath); - } - -#ifdef SYSTEMDIALOG - _systemDialog = GetSystemDialog(); -#endif -} - -void CFilesOpenDialog::FinalRelease() -{ - if (_systemDialog) - _systemDialog.Release(); - - _initFolder.Release(); - _dialogEvents.Release(); - DeleteFile(_outputPath.c_str()); - - if (_debugStream) - fclose(_debugStream); -} - -STDAPICALL CFilesOpenDialog::Show(HWND hwndOwner) -{ - cout << "Show, hwndOwner: " << hwndOwner << endl; - _selectedItems.clear(); - -#ifdef SYSTEMDIALOG - return _systemDialog->Show(hwndOwner); -#endif - - SHELLEXECUTEINFO ShExecInfo = { 0 }; - ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO); - ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS; - - PWSTR pszPath = NULL; - WCHAR szBuf[MAX_PATH]; - TCHAR args[1024] = { 0 }; - ExpandEnvironmentStringsW(L"%LOCALAPPDATA%\\Microsoft\\WindowsApps\\files-dev.exe", szBuf, MAX_PATH - 1); - - HANDLE closeEvent = CreateEvent(NULL, FALSE, FALSE, TEXT("FILEDIALOG")); - - if (_initFolder && SUCCEEDED(_initFolder->GetDisplayName(SIGDN_DESKTOPABSOLUTEPARSING, &pszPath))) - { - swprintf(args, _countof(args) - 1, L"\"%s\" -directory \"%s\" -outputpath \"%s\"", szBuf, pszPath, _outputPath.c_str()); - wcout << L"Invoking: " << args << endl; - CoTaskMemFree(pszPath); - } - else - { - swprintf(args, _countof(args) - 1, L"\"%s\" -outputpath \"%s\"", szBuf, _outputPath.c_str()); - } - - std::wstring uriWithArgs = L"files-dev:?cmd=" + str2wstr(wstring_to_utf8_hex(args)); - ShExecInfo.lpFile = uriWithArgs.c_str(); - ShExecInfo.nShow = SW_SHOW; - ShellExecuteEx(&ShExecInfo); - - if (hwndOwner) - EnableWindow(hwndOwner, FALSE); - - MSG msg; - while (ShExecInfo.hProcess) - { - switch (MsgWaitForMultipleObjectsEx(1, &closeEvent, INFINITE, QS_ALLINPUT, 0)) - { - case WAIT_OBJECT_0: - CloseHandle(ShExecInfo.hProcess); - ShExecInfo.hProcess = NULL; - break; - case WAIT_OBJECT_0 + 1: - while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) - { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - continue; - default: __debugbreak(); - } - } - - if (closeEvent) - CloseHandle(closeEvent); - - if (hwndOwner) - { - EnableWindow(hwndOwner, TRUE); - SetForegroundWindow(hwndOwner); - } - - std::ifstream file(_outputPath); - if (file.good()) - { - std::string str; - std::wstring_convert> converter; - - while (std::getline(file, str)) - { - std::wstring wide = converter.from_bytes(str); - _selectedItems.push_back(wide); - } - } - - DeleteFile(_outputPath.c_str()); - - if (!_selectedItems.empty()) - { - if (_dialogEvents) - _dialogEvents->OnFileOk(this); - } - - return !_selectedItems.empty() ? S_OK : HRESULT_FROM_WIN32(ERROR_CANCELLED); -} - -STDAPICALL CFilesOpenDialog::SetFileTypes(UINT cFileTypes, const COMDLG_FILTERSPEC* rgFilterSpec) -{ - cout << "SetFileTypes, cFileTypes: " << cFileTypes << endl; -#ifdef SYSTEMDIALOG - return _systemDialog->SetFileTypes(cFileTypes, rgFilterSpec); -#endif - return S_OK; -} - -STDAPICALL CFilesOpenDialog::SetFileTypeIndex(UINT iFileType) -{ - cout << "SetFileTypeIndex, iFileType: " << iFileType << endl; -#ifdef SYSTEMDIALOG - return _systemDialog->SetFileTypeIndex(iFileType); -#endif - return S_OK; -} - -STDAPICALL CFilesOpenDialog::GetFileTypeIndex(UINT* piFileType) -{ - cout << "GetFileTypeIndex" << endl; -#ifdef SYSTEMDIALOG - return _systemDialog->GetFileTypeIndex(piFileType); -#endif - * piFileType = 1; - return S_OK; -} - -STDAPICALL CFilesOpenDialog::Advise(IFileDialogEvents* pfde, DWORD* pdwCookie) -{ - cout << "Advise" << endl; -#ifdef SYSTEMDIALOG - return _systemDialog->Advise(pfde, pdwCookie); -#endif - _dialogEvents = pfde; - *pdwCookie = 1; - return S_OK; -} - -STDAPICALL CFilesOpenDialog::Unadvise(DWORD dwCookie) -{ - cout << "Unadvise, dwCookie: " << dwCookie << endl; -#ifdef SYSTEMDIALOG - return _systemDialog->Unadvise(dwCookie); -#endif - _dialogEvents.Release(); - return S_OK; -} - -STDAPICALL CFilesOpenDialog::SetOptions(FILEOPENDIALOGOPTIONS fos) -{ - cout << "SetOptions, fos: " << fos << endl; -#ifdef SYSTEMDIALOG - return _systemDialog->SetOptions(fos); -#endif - _fos = fos; - return S_OK; -} - -STDAPICALL CFilesOpenDialog::GetOptions(FILEOPENDIALOGOPTIONS* pfos) -{ - cout << "GetOptions, fos: " << _fos << endl; -#ifdef SYSTEMDIALOG - return _systemDialog->GetOptions(pfos); -#endif - * pfos = _fos; - return S_OK; -} - -STDAPICALL CFilesOpenDialog::SetDefaultFolder(IShellItem* psi) -{ - PWSTR pszPath = NULL; - if (SUCCEEDED(psi->GetDisplayName(SIGDN_DESKTOPABSOLUTEPARSING, &pszPath))) - { - wcout << L"SetDefaultFolder, psi: " << pszPath << endl; - CoTaskMemFree(pszPath); - } -#ifdef SYSTEMDIALOG - return _systemDialog->SetDefaultFolder(psi); -#endif - _initFolder = psi; - return S_OK; -} - -STDAPICALL CFilesOpenDialog::SetFolder(IShellItem* psi) -{ - PWSTR pszPath = NULL; - if (SUCCEEDED(psi->GetDisplayName(SIGDN_DESKTOPABSOLUTEPARSING, &pszPath))) - { - wcout << L"SetFolder, psi: " << pszPath << endl; - CoTaskMemFree(pszPath); - } -#ifdef SYSTEMDIALOG - return _systemDialog->SetFolder(psi); -#endif - _initFolder = psi; - return S_OK; -} - -STDAPICALL CFilesOpenDialog::GetFolder(IShellItem** ppsi) -{ - cout << "GetFolder" << endl; -#ifdef SYSTEMDIALOG - return _systemDialog->GetFolder(ppsi); -#endif - * ppsi = NULL; - return E_NOTIMPL; -} - -STDAPICALL CFilesOpenDialog::GetCurrentSelection(IShellItem** ppsi) -{ - cout << "GetCurrentSelection" << endl; -#ifdef SYSTEMDIALOG - return _systemDialog->GetCurrentSelection(ppsi); -#endif - return GetResult(ppsi); -} - -STDAPICALL CFilesOpenDialog::SetFileName(LPCWSTR pszName) -{ - wcout << L"SetFileName, pszName: " << pszName << endl; -#ifdef SYSTEMDIALOG - return _systemDialog->SetFileName(pszName); -#endif - return S_OK; -} - -STDAPICALL CFilesOpenDialog::GetFileName(LPWSTR* pszName) -{ - cout << "GetFileName" << endl; -#ifdef SYSTEMDIALOG - return _systemDialog->GetFileName(pszName); -#endif - return SHStrDupW(_selectedItems.empty() ? L"" : _selectedItems[0].c_str(), pszName); -} - -STDAPICALL CFilesOpenDialog::SetTitle(LPCWSTR pszTitle) -{ - cout << "SetTitle, title: " << pszTitle << endl; -#ifdef SYSTEMDIALOG - return _systemDialog->SetTitle(pszTitle); -#endif - return S_OK; -} - -STDAPICALL CFilesOpenDialog::SetOkButtonLabel(LPCWSTR pszText) -{ - cout << "SetOkButtonLabel, pszText: " << pszText << endl; -#ifdef SYSTEMDIALOG - return _systemDialog->SetOkButtonLabel(pszText); -#endif - return S_OK; -} - -STDAPICALL CFilesOpenDialog::SetFileNameLabel(LPCWSTR pszLabel) -{ - cout << "SetFileNameLabel, pszLabel: " << pszLabel << endl; -#ifdef SYSTEMDIALOG - return _systemDialog->SetFileNameLabel(pszLabel); -#endif - return S_OK; -} - -STDAPICALL CFilesOpenDialog::GetResult(IShellItem** ppsi) -{ - cout << "GetResult" << endl; -#ifdef SYSTEMDIALOG - return _systemDialog->GetResult(ppsi); -#endif - *ppsi = NULL; - if (!_selectedItems.empty()) - return SHCreateItemFromParsingName(_selectedItems[0].c_str(), NULL, IID_IShellItem, (void**)ppsi); - return E_NOTIMPL; -} - -STDAPICALL CFilesOpenDialog::AddPlace(IShellItem* psi, FDAP fdap) -{ - PWSTR pszPath = NULL; - if (SUCCEEDED(psi->GetDisplayName(SIGDN_DESKTOPABSOLUTEPARSING, &pszPath))) - { - wcout << L"AddPlace, psi: " << pszPath << endl; - CoTaskMemFree(pszPath); - } -#ifdef SYSTEMDIALOG - return _systemDialog->AddPlace(psi, fdap); -#endif - return S_OK; -} - -STDAPICALL CFilesOpenDialog::SetDefaultExtension(LPCWSTR pszDefaultExtension) -{ - cout << "SetDefaultExtension, pszDefaultExtension: " << pszDefaultExtension << endl; -#ifdef SYSTEMDIALOG - return _systemDialog->SetDefaultExtension(pszDefaultExtension); -#endif - return S_OK; -} - -STDAPICALL CFilesOpenDialog::Close(HRESULT hr) -{ - cout << "Close, hr: " << hr << endl; -#ifdef SYSTEMDIALOG - return _systemDialog->Close(hr); -#endif - return E_NOTIMPL; -} - -STDAPICALL CFilesOpenDialog::SetClientGuid(REFGUID guid) -{ - cout << "SetClientGuid" << endl; -#ifdef SYSTEMDIALOG - return _systemDialog->SetClientGuid(guid); -#endif - return S_OK; -} - -STDAPICALL CFilesOpenDialog::ClearClientData(void) -{ - cout << "ClearClientData" << endl; -#ifdef SYSTEMDIALOG - return _systemDialog->ClearClientData(); -#endif - return S_OK; -} - -STDAPICALL CFilesOpenDialog::SetFilter(IShellItemFilter* pFilter) -{ - cout << "SetFilter" << endl; -#ifdef SYSTEMDIALOG - return _systemDialog->SetFilter(pFilter); -#endif - return S_OK; -} - -STDAPICALL CFilesOpenDialog::GetResults(IShellItemArray** ppenum) -{ - cout << "GetResults, results: " << _selectedItems.size() << endl; -#ifdef SYSTEMDIALOG - return _systemDialog->GetResults(ppenum); -#endif - *ppenum = NULL; - if (!_selectedItems.empty()) - { - std::vector pidls; - for (const std::wstring& ipath : _selectedItems) - { - CComPtr psi; - if (SUCCEEDED(SHCreateItemFromParsingName(ipath.c_str(), NULL, IID_PPV_ARGS(&psi)))) - { - PIDLIST_ABSOLUTE pidl = NULL; - if (SUCCEEDED(SHGetIDListFromObject(psi, &pidl))) - pidls.push_back(pidl); - } - } - - if (pidls.empty()) - return E_FAIL; - - HRESULT hr = SHCreateShellItemArrayFromIDLists((UINT)pidls.size(), (LPCITEMIDLIST*)pidls.data(), ppenum); - for (PIDLIST_ABSOLUTE item : pidls) - { - CoTaskMemFree(item); - } - return hr; - } - return E_NOTIMPL; -} - -STDAPICALL CFilesOpenDialog::GetSelectedItems(IShellItemArray** ppsai) -{ - cout << "GetSelectedItems" << endl; -#ifdef SYSTEMDIALOG - return _systemDialog->GetSelectedItems(ppsai); -#endif - return GetResults(ppsai); -} - -STDAPICALL CFilesOpenDialog::EnableOpenDropDown(DWORD dwIDCtl) -{ - cout << "EnableOpenDropDown" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->EnableOpenDropDown(dwIDCtl); -#endif - return S_OK; -} - -STDAPICALL CFilesOpenDialog::AddMenu(DWORD dwIDCtl, LPCWSTR pszLabel) -{ - cout << "AddMenu" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->AddMenu(dwIDCtl, pszLabel); -#endif - return S_OK; -} - -STDAPICALL CFilesOpenDialog::AddPushButton(DWORD dwIDCtl, LPCWSTR pszLabel) -{ - cout << "AddPushButton" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->AddPushButton(dwIDCtl, pszLabel); -#endif - return S_OK; -} - -STDAPICALL CFilesOpenDialog::AddComboBox(DWORD dwIDCtl) -{ - cout << "AddComboBox" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->AddComboBox(dwIDCtl); -#endif - return S_OK; -} - -STDAPICALL CFilesOpenDialog::AddRadioButtonList(DWORD dwIDCtl) -{ - cout << "AddRadioButtonList" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->AddRadioButtonList(dwIDCtl); -#endif - return S_OK; -} - -STDAPICALL CFilesOpenDialog::AddCheckButton(DWORD dwIDCtl, LPCWSTR pszLabel, BOOL bChecked) -{ - cout << "AddCheckButton" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->AddCheckButton(dwIDCtl, pszLabel, bChecked); -#endif - return S_OK; -} - -STDAPICALL CFilesOpenDialog::AddEditBox(DWORD dwIDCtl, LPCWSTR pszText) -{ - cout << "AddEditBox" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->AddEditBox(dwIDCtl, pszText); -#endif - return S_OK; -} - -STDAPICALL CFilesOpenDialog::AddSeparator(DWORD dwIDCtl) -{ - cout << "AddSeparator" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->AddSeparator(dwIDCtl); -#endif - return S_OK; -} - -STDAPICALL CFilesOpenDialog::AddText(DWORD dwIDCtl, LPCWSTR pszText) -{ - cout << "AddText" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->AddText(dwIDCtl, pszText); -#endif - return S_OK; -} - -STDAPICALL CFilesOpenDialog::SetControlLabel(DWORD dwIDCtl, LPCWSTR pszLabel) -{ - cout << "SetControlLabel" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->SetControlLabel(dwIDCtl, pszLabel); -#endif - return S_OK; -} - -STDAPICALL CFilesOpenDialog::GetControlState(DWORD dwIDCtl, CDCONTROLSTATEF* pdwState) -{ - cout << "GetControlState" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->GetControlState(dwIDCtl, pdwState); -#endif - * pdwState = CDCS_ENABLEDVISIBLE; - return S_OK; -} - -STDAPICALL CFilesOpenDialog::SetControlState(DWORD dwIDCtl, CDCONTROLSTATEF dwState) -{ - cout << "SetControlState" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->SetControlState(dwIDCtl, dwState); -#endif - return S_OK; -} - -STDAPICALL CFilesOpenDialog::GetEditBoxText(DWORD dwIDCtl, WCHAR** ppszText) -{ - cout << "GetEditBoxText" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->GetEditBoxText(dwIDCtl, ppszText); -#endif - SHStrDupW(L"", ppszText); - return S_OK; -} - -STDAPICALL CFilesOpenDialog::SetEditBoxText(DWORD dwIDCtl, LPCWSTR pszText) -{ - cout << "SetEditBoxText" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->SetEditBoxText(dwIDCtl, pszText); -#endif - return S_OK; -} - -STDAPICALL CFilesOpenDialog::GetCheckButtonState(DWORD dwIDCtl, BOOL* pbChecked) -{ - cout << "GetCheckButtonState" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->GetCheckButtonState(dwIDCtl, pbChecked); -#endif - * pbChecked = false; - return S_OK; -} - -STDAPICALL CFilesOpenDialog::SetCheckButtonState(DWORD dwIDCtl, BOOL bChecked) -{ - cout << "SetCheckButtonState" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->SetCheckButtonState(dwIDCtl, bChecked); -#endif - return S_OK; -} - -STDAPICALL CFilesOpenDialog::AddControlItem(DWORD dwIDCtl, DWORD dwIDItem, LPCWSTR pszLabel) -{ - cout << "AddControlItem" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->AddControlItem(dwIDCtl, dwIDItem, pszLabel); -#endif - return S_OK; -} - -STDAPICALL CFilesOpenDialog::RemoveControlItem(DWORD dwIDCtl, DWORD dwIDItem) -{ - cout << "RemoveControlItem" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->RemoveControlItem(dwIDCtl, dwIDItem); -#endif - return S_OK; -} - -STDAPICALL CFilesOpenDialog::RemoveAllControlItems(DWORD dwIDCtl) -{ - cout << "RemoveAllControlItems" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->RemoveAllControlItems(dwIDCtl); -#endif - return S_OK; -} - -STDAPICALL CFilesOpenDialog::GetControlItemState(DWORD dwIDCtl, DWORD dwIDItem, CDCONTROLSTATEF* pdwState) -{ - cout << "GetControlItemState" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->GetControlItemState(dwIDCtl, dwIDItem, pdwState); -#endif - * pdwState = CDCS_ENABLEDVISIBLE; - return S_OK; -} - -STDAPICALL CFilesOpenDialog::SetControlItemState(DWORD dwIDCtl, DWORD dwIDItem, CDCONTROLSTATEF dwState) -{ - cout << "SetControlItemState" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->SetControlItemState(dwIDCtl, dwIDItem, dwState); -#endif - return S_OK; -} - -STDAPICALL CFilesOpenDialog::GetSelectedControlItem(DWORD dwIDCtl, DWORD* pdwIDItem) -{ - cout << "GetSelectedControlItem" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->GetSelectedControlItem(dwIDCtl, pdwIDItem); -#endif - * pdwIDItem = 0; - return S_OK; -} - -STDAPICALL CFilesOpenDialog::SetSelectedControlItem(DWORD dwIDCtl, DWORD dwIDItem) -{ - cout << "SetSelectedControlItem" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->SetSelectedControlItem(dwIDCtl, dwIDItem); -#endif - return S_OK; -} - -STDAPICALL CFilesOpenDialog::StartVisualGroup(DWORD dwIDCtl, LPCWSTR pszLabel) -{ - cout << "StartVisualGroup" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->StartVisualGroup(dwIDCtl, pszLabel); -#endif - return S_OK; -} - -STDAPICALL CFilesOpenDialog::EndVisualGroup(void) -{ - cout << "EndVisualGroup" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->EndVisualGroup(); -#endif - return S_OK; -} - -STDAPICALL CFilesOpenDialog::MakeProminent(DWORD dwIDCtl) -{ - cout << "MakeProminent" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->MakeProminent(dwIDCtl); -#endif - return S_OK; -} - -STDAPICALL CFilesOpenDialog::SetControlItemText(DWORD dwIDCtl, DWORD dwIDItem, LPCWSTR pszLabel) -{ - cout << "SetControlItemText" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->SetControlItemText(dwIDCtl, dwIDItem, pszLabel); -#endif - return S_OK; -} - -STDAPICALL CFilesOpenDialog::SetCancelButtonLabel(LPCWSTR pszLabel) -{ - cout << "SetCancelButtonLabel" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->SetCancelButtonLabel(pszLabel); -#endif - return S_OK; -} - -STDAPICALL CFilesOpenDialog::SetNavigationRoot(IShellItem* psi) -{ - cout << "SetNavigationRoot" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->SetNavigationRoot(psi); -#endif - return S_OK; -} - -STDAPICALL CFilesOpenDialog::SetSite(IUnknown* pUnkSite) -{ - cout << "SetSite" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->SetSite(pUnkSite); -#endif - return S_OK; -} - -STDAPICALL CFilesOpenDialog::GetSite(REFIID riid, void** ppvSite) -{ - cout << "GetSite" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->GetSite(riid, ppvSite); -#endif - return E_NOTIMPL; -} - -STDAPICALL CFilesOpenDialog::HideControlsForHostedPickerProviderApp(void) -{ - cout << "HideControlsForHostedPickerProviderApp" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->HideControlsForHostedPickerProviderApp(); -#endif - return E_NOTIMPL; -} - -STDAPICALL CFilesOpenDialog::EnableControlsForHostedPickerProviderApp(void) -{ - cout << "EnableControlsForHostedPickerProviderApp" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->EnableControlsForHostedPickerProviderApp(); -#endif - return E_NOTIMPL; -} - -STDAPICALL CFilesOpenDialog::GetPrivateOptions(unsigned long* pfos) -{ - cout << "GetPrivateOptions" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->GetPrivateOptions(pfos); -#endif - * pfos = 0; - return S_OK; -} - -STDAPICALL CFilesOpenDialog::SetPrivateOptions(unsigned long fos) -{ - cout << "SetPrivateOptions" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->SetPrivateOptions(fos); -#endif - return S_OK; -} - -STDAPICALL CFilesOpenDialog::SetPersistenceKey(unsigned short const* pkey) -{ - cout << "SetPersistenceKey" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->SetPersistenceKey(pkey); -#endif - return E_NOTIMPL; -} - -STDAPICALL CFilesOpenDialog::HasPlaces(void) -{ - cout << "HasPlaces" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->HasPlaces(); -#endif - return E_NOTIMPL; -} - -STDAPICALL CFilesOpenDialog::EnumPlaces(int plc, _GUID const& riid, void** ppv) -{ - cout << "EnumPlaces" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->EnumPlaces(plc, riid, ppv); -#endif - return E_NOTIMPL; -} - -STDAPICALL CFilesOpenDialog::EnumControls(void** ppv) -{ - cout << "EnumControls" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->EnumControls(ppv); -#endif - return E_NOTIMPL; -} - -STDAPICALL CFilesOpenDialog::GetPersistRegkey(unsigned short** preg) -{ - cout << "GetPersistRegkey" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->GetPersistRegkey(preg); -#endif - return E_NOTIMPL; -} - -STDAPICALL CFilesOpenDialog::GetSavePropertyStore(IPropertyStore** ppstore, IPropertyDescriptionList** ppdesclist) -{ - cout << "GetSavePropertyStore" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->GetSavePropertyStore(ppstore, ppdesclist); -#endif - return E_NOTIMPL; -} - -STDAPICALL CFilesOpenDialog::GetSaveExtension(unsigned short** pext) -{ - cout << "GetSaveExtension" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->GetSaveExtension(pext); -#endif - return E_NOTIMPL; -} - -STDAPICALL CFilesOpenDialog::GetFileTypeControl(void** ftp) -{ - cout << "GetFileTypeControl" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->GetFileTypeControl(ftp); -#endif - return E_NOTIMPL; -} - -STDAPICALL CFilesOpenDialog::GetFileNameControl(void** pctrl) -{ - cout << "GetFileNameControl" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->GetFileNameControl(pctrl); -#endif - return E_NOTIMPL; -} - -STDAPICALL CFilesOpenDialog::GetFileProtectionControl(void** pfctrl) -{ - cout << "GetFileProtectionControl" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->GetFileProtectionControl(pfctrl); -#endif - return E_NOTIMPL; -} - -STDAPICALL CFilesOpenDialog::SetFolderPrivate(IShellItem* psi, int arg) -{ - cout << "SetFolderPrivate" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->SetFolderPrivate(psi, arg); -#endif - return E_NOTIMPL; -} - -STDAPICALL CFilesOpenDialog::SetCustomControlAreaHeight(unsigned int height) -{ - cout << "SetCustomControlAreaHeight" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->SetCustomControlAreaHeight(height); -#endif - return E_NOTIMPL; -} - -STDAPICALL CFilesOpenDialog::GetDialogState(unsigned long arg, unsigned long* pstate) -{ - cout << "GetDialogState" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->GetDialogState(arg, pstate); -#endif - return E_NOTIMPL; -} - -STDAPICALL CFilesOpenDialog::SetAppControlsModule(void* papp) -{ - cout << "SetAppControlsModule" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->SetAppControlsModule(papp); -#endif - return E_NOTIMPL; -} - -STDAPICALL CFilesOpenDialog::SetUserEditedSaveProperties(void) -{ - cout << "SetUserEditedSaveProperties" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->SetUserEditedSaveProperties(); -#endif - return E_NOTIMPL; -} - -STDAPICALL CFilesOpenDialog::ShouldShowStandardNavigationRoots(void) -{ - cout << "ShouldShowStandardNavigationRoots" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->ShouldShowStandardNavigationRoots(); -#endif - return E_NOTIMPL; -} - -STDAPICALL CFilesOpenDialog::GetNavigationRoot(_GUID const& riid, void** ppv) -{ - cout << "GetNavigationRoot" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->GetNavigationRoot(riid, ppv); -#endif - return E_NOTIMPL; -} - -STDAPICALL CFilesOpenDialog::ShouldShowFileProtectionControl(int* pfpc) -{ - cout << "ShouldShowFileProtectionControl" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->ShouldShowFileProtectionControl(pfpc); -#endif - return E_NOTIMPL; -} - -STDAPICALL CFilesOpenDialog::GetCurrentDialogView(_GUID const& riid, void** ppv) -{ - cout << "GetCurrentDialogView" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->GetCurrentDialogView(riid, ppv); -#endif - return E_NOTIMPL; -} - -STDAPICALL CFilesOpenDialog::SetSaveDialogEditBoxTextAndFileType(int arg, unsigned short const* pargb) -{ - cout << "SetSaveDialogEditBoxTextAndFileType" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->SetSaveDialogEditBoxTextAndFileType(arg, pargb); -#endif - return E_NOTIMPL; -} - -STDAPICALL CFilesOpenDialog::MoveFocusFromBrowser(int arg) -{ - cout << "MoveFocusFromBrowser" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->MoveFocusFromBrowser(arg); -#endif - return E_NOTIMPL; -} - -STDAPICALL CFilesOpenDialog::EnableOkButton(int enbl) -{ - cout << "EnableOkButton" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->EnableOkButton(enbl); -#endif - return E_NOTIMPL; -} - -STDAPICALL CFilesOpenDialog::InitEnterpriseId(unsigned short const* pid) -{ - cout << "InitEnterpriseId" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->InitEnterpriseId(pid); -#endif - return E_NOTIMPL; -} - -STDAPICALL CFilesOpenDialog::AdviseFirst(IFileDialogEvents* pfde, unsigned long* pdwCookie) -{ - cout << "AdviseFirst" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->AdviseFirst(pfde, pdwCookie); -#endif - return E_NOTIMPL; -} - -STDAPICALL CFilesOpenDialog::HandleTab(void) -{ - cout << "HandleTab" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->HandleTab(); -#endif - return E_NOTIMPL; -} diff --git a/src/Files.App.OpenDialog/FilesOpenDialog.h b/src/Files.App.OpenDialog/FilesOpenDialog.h deleted file mode 100644 index ec2040c5d998..000000000000 --- a/src/Files.App.OpenDialog/FilesOpenDialog.h +++ /dev/null @@ -1,170 +0,0 @@ -// Copyright (c) Files Community -// Licensed under the MIT License. - -// Abstract: -// Declaration of CFilesOpenDialog. - -#pragma once - -#define DEBUGLOG - -#include -#include -#include - -// Main symbols -#include "resource.h" -#include "CustomOpenDialog_i.h" -#include "UndefInterfaces.h" - -#if defined(_WIN32_WCE) && !defined(_CE_DCOM) && !defined(_CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA) -#error "Single-threaded COM objects are not supported properly on the Windows CE platform, for example Windows Mobile platforms do not include full DCOM support. Define _CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA to make ATL support the creation of single-threaded COM objects and allow implementations with single-threaded COM objects. The threading model in the RGS file has been set to 'Free' as it is the only threading model supported on non-DCOM Windows CE platforms." -#endif - -#define STDAPICALL HRESULT __stdcall - -using namespace ATL; - -class ATL_NO_VTABLE CFilesOpenDialog : - public CComObjectRootEx, - public CComCoClass, - public IFileDialog, - public IFileDialog2, - public IFileOpenDialog, - public IFileDialogCustomize, - public IObjectWithSite, - public IFileDialogPrivate -{ -public: - CFilesOpenDialog(); - -DECLARE_REGISTRY_RESOURCEID(106) - -CUSTOM_BEGIN_COM_MAP(CFilesOpenDialog) - COM_INTERFACE_ENTRY(IFileDialog) - COM_INTERFACE_ENTRY(IFileDialog2) - COM_INTERFACE_ENTRY(IFileOpenDialog) - COM_INTERFACE_ENTRY(IFileDialogCustomize) - COM_INTERFACE_ENTRY(IObjectWithSite) - COM_INTERFACE_ENTRY(IFileDialogPrivate) -END_COM_MAP() - - DECLARE_PROTECT_FINAL_CONSTRUCT() - - HRESULT FinalConstruct() - { - return S_OK; - } - - void FinalRelease(); - - CComPtr _systemDialog; - - FILEOPENDIALOGOPTIONS _fos; - - std::vector _selectedItems; - std::wstring _outputPath; - CComPtr _initFolder; - CComPtr _dialogEvents; - - FILE* _debugStream; - -public: - // Inherited through IFileOpenDialog - STDAPICALL Show(HWND hwndOwner) override; - STDAPICALL SetFileTypes(UINT cFileTypes, const COMDLG_FILTERSPEC* rgFilterSpec) override; - STDAPICALL SetFileTypeIndex(UINT iFileType) override; - STDAPICALL GetFileTypeIndex(UINT* piFileType) override; - STDAPICALL Advise(IFileDialogEvents* pfde, DWORD* pdwCookie) override; - STDAPICALL Unadvise(DWORD dwCookie) override; - STDAPICALL SetOptions(FILEOPENDIALOGOPTIONS fos) override; - STDAPICALL GetOptions(FILEOPENDIALOGOPTIONS* pfos) override; - STDAPICALL SetDefaultFolder(IShellItem* psi) override; - STDAPICALL SetFolder(IShellItem* psi) override; - STDAPICALL GetFolder(IShellItem** ppsi) override; - STDAPICALL GetCurrentSelection(IShellItem** ppsi) override; - STDAPICALL SetFileName(LPCWSTR pszName) override; - STDAPICALL GetFileName(LPWSTR* pszName) override; - STDAPICALL SetTitle(LPCWSTR pszTitle) override; - STDAPICALL SetOkButtonLabel(LPCWSTR pszText) override; - STDAPICALL SetFileNameLabel(LPCWSTR pszLabel) override; - STDAPICALL GetResult(IShellItem** ppsi) override; - STDAPICALL AddPlace(IShellItem* psi, FDAP fdap) override; - STDAPICALL SetDefaultExtension(LPCWSTR pszDefaultExtension) override; - STDAPICALL Close(HRESULT hr) override; - STDAPICALL SetClientGuid(REFGUID guid) override; - STDAPICALL ClearClientData(void) override; - STDAPICALL SetFilter(IShellItemFilter* pFilter) override; - STDAPICALL GetResults(IShellItemArray** ppenum) override; - STDAPICALL GetSelectedItems(IShellItemArray** ppsai) override; - - // Inherited through IFileDialogCustomize - STDAPICALL EnableOpenDropDown(DWORD dwIDCtl) override; - STDAPICALL AddMenu(DWORD dwIDCtl, LPCWSTR pszLabel) override; - STDAPICALL AddPushButton(DWORD dwIDCtl, LPCWSTR pszLabel) override; - STDAPICALL AddComboBox(DWORD dwIDCtl) override; - STDAPICALL AddRadioButtonList(DWORD dwIDCtl) override; - STDAPICALL AddCheckButton(DWORD dwIDCtl, LPCWSTR pszLabel, BOOL bChecked) override; - STDAPICALL AddEditBox(DWORD dwIDCtl, LPCWSTR pszText) override; - STDAPICALL AddSeparator(DWORD dwIDCtl) override; - STDAPICALL AddText(DWORD dwIDCtl, LPCWSTR pszText) override; - STDAPICALL SetControlLabel(DWORD dwIDCtl, LPCWSTR pszLabel) override; - STDAPICALL GetControlState(DWORD dwIDCtl, CDCONTROLSTATEF* pdwState) override; - STDAPICALL SetControlState(DWORD dwIDCtl, CDCONTROLSTATEF dwState) override; - STDAPICALL GetEditBoxText(DWORD dwIDCtl, WCHAR** ppszText) override; - STDAPICALL SetEditBoxText(DWORD dwIDCtl, LPCWSTR pszText) override; - STDAPICALL GetCheckButtonState(DWORD dwIDCtl, BOOL* pbChecked) override; - STDAPICALL SetCheckButtonState(DWORD dwIDCtl, BOOL bChecked) override; - STDAPICALL AddControlItem(DWORD dwIDCtl, DWORD dwIDItem, LPCWSTR pszLabel) override; - STDAPICALL RemoveControlItem(DWORD dwIDCtl, DWORD dwIDItem) override; - STDAPICALL RemoveAllControlItems(DWORD dwIDCtl) override; - STDAPICALL GetControlItemState(DWORD dwIDCtl, DWORD dwIDItem, CDCONTROLSTATEF* pdwState) override; - STDAPICALL SetControlItemState(DWORD dwIDCtl, DWORD dwIDItem, CDCONTROLSTATEF dwState) override; - STDAPICALL GetSelectedControlItem(DWORD dwIDCtl, DWORD* pdwIDItem) override; - STDAPICALL SetSelectedControlItem(DWORD dwIDCtl, DWORD dwIDItem) override; - STDAPICALL StartVisualGroup(DWORD dwIDCtl, LPCWSTR pszLabel) override; - STDAPICALL EndVisualGroup(void) override; - STDAPICALL MakeProminent(DWORD dwIDCtl) override; - STDAPICALL SetControlItemText(DWORD dwIDCtl, DWORD dwIDItem, LPCWSTR pszLabel) override; - - // Inherited through IFileDialog2 - STDAPICALL SetCancelButtonLabel(LPCWSTR pszLabel) override; - STDAPICALL SetNavigationRoot(IShellItem* psi) override; - - // Inherited through IObjectWithSite - STDAPICALL SetSite(IUnknown* pUnkSite) override; - STDAPICALL GetSite(REFIID riid, void** ppvSite) override; - - // Inherited through IFileDialogPrivate - STDAPICALL HideControlsForHostedPickerProviderApp(void) override; - STDAPICALL EnableControlsForHostedPickerProviderApp(void) override; - STDAPICALL GetPrivateOptions(unsigned long*) override; - STDAPICALL SetPrivateOptions(unsigned long) override; - STDAPICALL SetPersistenceKey(unsigned short const*) override; - STDAPICALL HasPlaces(void) override; - STDAPICALL EnumPlaces(int, _GUID const&, void**) override; - STDAPICALL EnumControls(void**) override; - STDAPICALL GetPersistRegkey(unsigned short**) override; - STDAPICALL GetSavePropertyStore(IPropertyStore**, IPropertyDescriptionList**) override; - STDAPICALL GetSaveExtension(unsigned short**) override; - STDAPICALL GetFileTypeControl(void**) override; - STDAPICALL GetFileNameControl(void**) override; - STDAPICALL GetFileProtectionControl(void**) override; - STDAPICALL SetFolderPrivate(IShellItem*, int) override; - STDAPICALL SetCustomControlAreaHeight(unsigned int) override; - STDAPICALL GetDialogState(unsigned long, unsigned long*) override; - STDAPICALL SetAppControlsModule(void*) override; - STDAPICALL SetUserEditedSaveProperties(void) override; - STDAPICALL ShouldShowStandardNavigationRoots(void) override; - STDAPICALL GetNavigationRoot(_GUID const&, void**) override; - STDAPICALL ShouldShowFileProtectionControl(int*) override; - STDAPICALL GetCurrentDialogView(_GUID const&, void**) override; - STDAPICALL SetSaveDialogEditBoxTextAndFileType(int, unsigned short const*) override; - STDAPICALL MoveFocusFromBrowser(int) override; - STDAPICALL EnableOkButton(int) override; - STDAPICALL InitEnterpriseId(unsigned short const*) override; - STDAPICALL AdviseFirst(IFileDialogEvents*, unsigned long*) override; - STDAPICALL HandleTab(void) override; -}; - -OBJECT_ENTRY_AUTO(__uuidof(FilesOpenDialog), CFilesOpenDialog) diff --git a/src/Files.App.OpenDialog/FilesOpenDialog.rgs b/src/Files.App.OpenDialog/FilesOpenDialog.rgs deleted file mode 100644 index 9381f46c6962..000000000000 --- a/src/Files.App.OpenDialog/FilesOpenDialog.rgs +++ /dev/null @@ -1,16 +0,0 @@ -HKCR -{ - NoRemove CLSID - { - ForceRemove {DC1C5A9C-E88A-4DDE-A5A1-60F82A20AEF7} = s 'FilesOpenDialog class' - { - ForceRemove Programmable - InprocServer32 = s '%MODULE%' - { - val ThreadingModel = s 'Apartment' - } - TypeLib = s '{14533360-0b0c-44e6-9e5f-8ec8a478158d}' - Version = s '1.0' - } - } -} diff --git a/src/Files.App.OpenDialog/UndefInterfaces.h b/src/Files.App.OpenDialog/UndefInterfaces.h deleted file mode 100644 index c6346261b4e6..000000000000 --- a/src/Files.App.OpenDialog/UndefInterfaces.h +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright (c) Files Community -// Licensed under the MIT License. - -// Abstract: -// Declaration of Undocumented interfaces and helpers. - -#pragma once - -#include "framework.h" -#include "shobjidl.h" - -using namespace ATL; - -#ifdef DEBUGLOG - -#define CUSTOM_BEGIN_COM_MAP(x) public: \ - typedef x _ComMapClass; \ - static HRESULT WINAPI _Cache(_In_ void* pv, _In_ REFIID iid, _COM_Outptr_result_maybenull_ void** ppvObject, _In_ DWORD_PTR dw) throw() \ - { \ - _ComMapClass* p = (_ComMapClass*)pv;\ - p->Lock();\ - HRESULT hRes = E_FAIL; \ - __try \ - { \ - hRes = ATL::CComObjectRootBase::_Cache(pv, iid, ppvObject, dw);\ - } \ - __finally \ - { \ - p->Unlock();\ - } \ - return hRes;\ - } \ - IUnknown* _GetRawUnknown() throw() \ - { ATLASSERT(_GetEntries()[0].pFunc == _ATL_SIMPLEMAPENTRY); return (IUnknown*)((INT_PTR)this+_GetEntries()->dw); } \ - _ATL_DECLARE_GET_UNKNOWN(x) \ - HRESULT _InternalQueryInterface( \ - _In_ REFIID iid, \ - _COM_Outptr_ void** ppvObject) throw() \ - { \ - HRESULT res = this->InternalQueryInterface(this, _GetEntries(), iid, ppvObject); \ - OLECHAR* guidString; \ - (void)StringFromCLSID(iid, &guidString); \ - std::wcout << L"QueryInterface: " << guidString << L" = " << res << std::endl; \ - ::CoTaskMemFree(guidString); \ - return res; \ - } \ - const static ATL::_ATL_INTMAP_ENTRY* WINAPI _GetEntries() throw() { \ - static const ATL::_ATL_INTMAP_ENTRY _entries[] = { DEBUG_QI_ENTRY(x) - -#else - -#define CUSTOM_BEGIN_COM_MAP(x) BEGIN_COM_MAP(x) - -#endif // DEBUGLOG - - -MIDL_INTERFACE("9EA5491C-89C8-4BEF-93D3-7F665FB82A33") -IFileDialogPrivate : public IUnknown -{ -public: - virtual HRESULT STDMETHODCALLTYPE HideControlsForHostedPickerProviderApp(void) = 0; - virtual HRESULT STDMETHODCALLTYPE EnableControlsForHostedPickerProviderApp(void) = 0; - virtual HRESULT STDMETHODCALLTYPE GetPrivateOptions(unsigned long*) = 0; - virtual HRESULT STDMETHODCALLTYPE SetPrivateOptions(unsigned long) = 0; - virtual HRESULT STDMETHODCALLTYPE SetPersistenceKey(unsigned short const*) = 0; - virtual HRESULT STDMETHODCALLTYPE HasPlaces(void) = 0; - virtual HRESULT STDMETHODCALLTYPE EnumPlaces(int, _GUID const&, void**) = 0; //tagFDPEPLACES - virtual HRESULT STDMETHODCALLTYPE EnumControls(void**) = 0; //IEnumAppControl - virtual HRESULT STDMETHODCALLTYPE GetPersistRegkey(unsigned short**) = 0; - virtual HRESULT STDMETHODCALLTYPE GetSavePropertyStore(IPropertyStore**, IPropertyDescriptionList**) = 0; - virtual HRESULT STDMETHODCALLTYPE GetSaveExtension(unsigned short**) = 0; - virtual HRESULT STDMETHODCALLTYPE GetFileTypeControl(void**) = 0; //IAppControl - virtual HRESULT STDMETHODCALLTYPE GetFileNameControl(void**) = 0; //IAppControl - virtual HRESULT STDMETHODCALLTYPE GetFileProtectionControl(void**) = 0;// IAppControl - virtual HRESULT STDMETHODCALLTYPE SetFolderPrivate(IShellItem*, int) = 0; - virtual HRESULT STDMETHODCALLTYPE SetCustomControlAreaHeight(unsigned int) = 0; - virtual HRESULT STDMETHODCALLTYPE GetDialogState(unsigned long, unsigned long*) = 0; - virtual HRESULT STDMETHODCALLTYPE SetAppControlsModule(void*) = 0;// IAppControlsModule - virtual HRESULT STDMETHODCALLTYPE SetUserEditedSaveProperties(void) = 0; - virtual HRESULT STDMETHODCALLTYPE ShouldShowStandardNavigationRoots(void) = 0; - virtual HRESULT STDMETHODCALLTYPE GetNavigationRoot(_GUID const&, void**) = 0; - virtual HRESULT STDMETHODCALLTYPE ShouldShowFileProtectionControl(int*) = 0; - virtual HRESULT STDMETHODCALLTYPE GetCurrentDialogView(_GUID const&, void**) = 0; - virtual HRESULT STDMETHODCALLTYPE SetSaveDialogEditBoxTextAndFileType(int, unsigned short const*) = 0; - virtual HRESULT STDMETHODCALLTYPE MoveFocusFromBrowser(int) = 0; - virtual HRESULT STDMETHODCALLTYPE EnableOkButton(int) = 0; - virtual HRESULT STDMETHODCALLTYPE InitEnterpriseId(unsigned short const*) = 0; - virtual HRESULT STDMETHODCALLTYPE AdviseFirst(IFileDialogEvents*, unsigned long*) = 0; - virtual HRESULT STDMETHODCALLTYPE HandleTab(void) = 0; -}; diff --git a/src/Files.App.OpenDialog/dllmain.cpp b/src/Files.App.OpenDialog/dllmain.cpp deleted file mode 100644 index 111e4f1b153d..000000000000 --- a/src/Files.App.OpenDialog/dllmain.cpp +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) Files Community -// Licensed under the MIT License. - -// Abstract: -// Implementation of module class. - -#include "pch.h" -#include "framework.h" -#include "resource.h" -#include "CustomOpenDialog_i.h" -#include "dllmain.h" - -CCustomOpenDialogModule _AtlModule; - -// DLL entry point -EXTERN_C BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved) -{ - return _AtlModule.DllMain(dwReason, lpReserved); -} diff --git a/src/Files.App.OpenDialog/dllmain.h b/src/Files.App.OpenDialog/dllmain.h deleted file mode 100644 index e5d52517b234..000000000000 --- a/src/Files.App.OpenDialog/dllmain.h +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) Files Community -// Licensed under the MIT License. - -// Abstract: -// declaration of module class. - -class CCustomOpenDialogModule : - public ATL::CAtlDllModuleT -{ -public : - DECLARE_LIBID(LIBID_CustomOpenDialogLib) - DECLARE_REGISTRY_APPID_RESOURCEID(IDR_CUSTOMOPENDIALOG, "{14533360-0b0c-44e6-9e5f-8ec8a478158d}") -}; - -extern class CCustomOpenDialogModule _AtlModule; diff --git a/src/Files.App.OpenDialog/framework.h b/src/Files.App.OpenDialog/framework.h deleted file mode 100644 index 608961a075fd..000000000000 --- a/src/Files.App.OpenDialog/framework.h +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (c) Files Community -// Licensed under the MIT License. - -#pragma once - -#ifndef STRICT -#define STRICT -#endif - -#include "targetver.h" - -#define _ATL_APARTMENT_THREADED - -#define _ATL_NO_AUTOMATIC_NAMESPACE - -// Some CString constructors will be explicit -#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS - -#define ATL_NO_ASSERT_ON_DESTROY_NONEXISTENT_WINDOW - -#include "resource.h" -#include -#include -#include diff --git a/src/Files.App.OpenDialog/pch.cpp b/src/Files.App.OpenDialog/pch.cpp deleted file mode 100644 index 7efeb320e2a1..000000000000 --- a/src/Files.App.OpenDialog/pch.cpp +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright (c) Files Community -// SPDX-License-Identifier: MPL-2.0 - -// Abstract: -// Source file pch.h corresponding to pch.h precompiled header. - -// Note: -// Do not Rename. -// When using precompiled headers, this file is required for successful compilation. - -#include "pch.h" diff --git a/src/Files.App.OpenDialog/pch.h b/src/Files.App.OpenDialog/pch.h deleted file mode 100644 index 11839799b4d9..000000000000 --- a/src/Files.App.OpenDialog/pch.h +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) Files Community -// Licensed under the MIT License. - -// Abstract: -// pch.h is the precompiled header file named pch.h. - -// Note: -// Do not Rename. -// The files listed below are compiled only once, which improves performance for subsequent compilations. -// This setting also affects the performance of IntelliSense, including code completion and many other code browsing features. -// However, the files listed here are ALL recompiled if one of them is updated from one build to another. -// Don't add frequently updated files here; otherwise the benefits offered in terms of performance will be lost. - -#ifndef PCH_H -#define PCH_H - -// Add the headers to be precompiled here -#include "framework.h" - -#endif //PCH_H diff --git a/src/Files.App.OpenDialog/resource.h b/src/Files.App.OpenDialog/resource.h deleted file mode 100644 index 81fb17596918..000000000000 --- a/src/Files.App.OpenDialog/resource.h +++ /dev/null @@ -1,18 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Include file generated with Microsoft Visual C++. -// Used by CustomOpenDialog.rc - -#define IDS_PROJNAME 100 -#define IDR_CUSTOMOPENDIALOG 101 -#define IDR_FILESOPENDIALOG 106 -#define IDR_FILESOPENDIALOG1 108 - -// Next default values for new objects -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 201 -#define _APS_NEXT_COMMAND_VALUE 32768 -#define _APS_NEXT_CONTROL_VALUE 201 -#define _APS_NEXT_SYMED_VALUE 109 -#endif -#endif diff --git a/src/Files.App.OpenDialog/targetver.h b/src/Files.App.OpenDialog/targetver.h deleted file mode 100644 index 64b2576e7cea..000000000000 --- a/src/Files.App.OpenDialog/targetver.h +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright (c) Files Community -// Licensed under the MIT License. - -// Note: -// Including SDKDDKVer.h defines the latest Windows platform available. -// If you want to compile the application for an older Windows platform, include WinSDKVer.h and -// set the _WIN32_WINNT macro to the platform to support before including SDKDDKVer.h. - -#pragma once - -#include diff --git a/src/Files.App.SaveDialog/CustomSaveDialog.cpp b/src/Files.App.SaveDialog/CustomSaveDialog.cpp deleted file mode 100644 index 2f9ccaf5f861..000000000000 --- a/src/Files.App.SaveDialog/CustomSaveDialog.cpp +++ /dev/null @@ -1,74 +0,0 @@ -// CustomSaveDialog.cpp: implementazione delle esportazioni DLL. - - -#include "pch.h" -#include "framework.h" -#include "resource.h" -#include "CustomSaveDialog_i.h" -#include "dllmain.h" - - -using namespace ATL; - -// Utilizzato per determinare se la DLL può essere scaricata da OLE. -_Use_decl_annotations_ -STDAPI DllCanUnloadNow(void) -{ - return _AtlModule.DllCanUnloadNow(); -} - -// Restituisce una class factory per creare un oggetto del tipo richiesto. -_Use_decl_annotations_ -STDAPI DllGetClassObject(_In_ REFCLSID rclsid, _In_ REFIID riid, _Outptr_ LPVOID* ppv) -{ - return _AtlModule.DllGetClassObject(rclsid, riid, ppv); -} - -// DllRegisterServer: aggiunge voci al Registro di sistema. -_Use_decl_annotations_ -STDAPI DllRegisterServer(void) -{ - // registra gli oggetti, le librerie dei tipi e tutte le interfacce della libreria dei tipi - HRESULT hr = _AtlModule.DllRegisterServer(); - return hr; -} - -// DllUnregisterServer: rimuove voci dal Registro di sistema. -_Use_decl_annotations_ -STDAPI DllUnregisterServer(void) -{ - HRESULT hr = _AtlModule.DllUnregisterServer(); - return hr; -} - -// DllInstall: aggiunge/rimuove voci nel Registro di sistema per ogni utente di ciascun computer. -STDAPI DllInstall(BOOL bInstall, _In_opt_ LPCWSTR pszCmdLine) -{ - HRESULT hr = E_FAIL; - static const wchar_t szUserSwitch[] = L"user"; - - if (pszCmdLine != nullptr) - { - if (_wcsnicmp(pszCmdLine, szUserSwitch, _countof(szUserSwitch)) == 0) - { - ATL::AtlSetPerUserRegistration(true); - } - } - - if (bInstall) - { - hr = DllRegisterServer(); - if (FAILED(hr)) - { - DllUnregisterServer(); - } - } - else - { - hr = DllUnregisterServer(); - } - - return hr; -} - - diff --git a/src/Files.App.SaveDialog/CustomSaveDialog.def b/src/Files.App.SaveDialog/CustomSaveDialog.def deleted file mode 100644 index 127dec0267e2..000000000000 --- a/src/Files.App.SaveDialog/CustomSaveDialog.def +++ /dev/null @@ -1,10 +0,0 @@ -; CustomSaveDialog.def: dichiara i parametri del modulo. - -LIBRARY - -EXPORTS - DllCanUnloadNow PRIVATE - DllGetClassObject PRIVATE - DllRegisterServer PRIVATE - DllUnregisterServer PRIVATE - DllInstall PRIVATE diff --git a/src/Files.App.SaveDialog/CustomSaveDialog.idl b/src/Files.App.SaveDialog/CustomSaveDialog.idl deleted file mode 100644 index d2b45059fdfa..000000000000 --- a/src/Files.App.SaveDialog/CustomSaveDialog.idl +++ /dev/null @@ -1,32 +0,0 @@ -// CustomSaveDialog.idl: origine IDL per CustomSaveDialog -// - -// Questo file verrà elaborato dallo strumento MIDL per -// produce la libreria dei tipi (CustomSaveDialog.tlb) e il codice di marshalling. - -import "oaidl.idl"; -import "ocidl.idl"; - -[ - uuid(21533617-c1cd-4d33-a190-21fb069b55f4), - version(1.0), -] -library CustomSaveDialogLib -{ - importlib("stdole2.tlb"); - [ - uuid(C0B4E2F3-BA21-4773-8DBA-335EC946EB8B) - ] - coclass FilesSaveDialog - { - [default] interface IFileSaveDialog; - interface IFileDialog; - interface IFileDialogCustomize; - interface IFileDialog2; - interface IObjectWithSite; - //interface IFileDialogPrivate; - interface IOleWindow; - }; -}; - -import "shobjidl.idl"; diff --git a/src/Files.App.SaveDialog/CustomSaveDialog.rc b/src/Files.App.SaveDialog/CustomSaveDialog.rc deleted file mode 100644 index deda272e17a1..000000000000 Binary files a/src/Files.App.SaveDialog/CustomSaveDialog.rc and /dev/null differ diff --git a/src/Files.App.SaveDialog/CustomSaveDialog.rgs b/src/Files.App.SaveDialog/CustomSaveDialog.rgs deleted file mode 100644 index e7d37400e19a..000000000000 --- a/src/Files.App.SaveDialog/CustomSaveDialog.rgs +++ /dev/null @@ -1,3 +0,0 @@ -HKCR -{ -} diff --git a/src/Files.App.SaveDialog/CustomSaveDialogps.def b/src/Files.App.SaveDialog/CustomSaveDialogps.def deleted file mode 100644 index 2a4265afa9fb..000000000000 --- a/src/Files.App.SaveDialog/CustomSaveDialogps.def +++ /dev/null @@ -1,8 +0,0 @@ - -LIBRARY - -EXPORTS - DllGetClassObject PRIVATE - DllCanUnloadNow PRIVATE - DllRegisterServer PRIVATE - DllUnregisterServer PRIVATE diff --git a/src/Files.App.SaveDialog/Files.App.SaveDialog.Win32.vcxproj b/src/Files.App.SaveDialog/Files.App.SaveDialog.Win32.vcxproj deleted file mode 100644 index 3cb9077c6b9e..000000000000 --- a/src/Files.App.SaveDialog/Files.App.SaveDialog.Win32.vcxproj +++ /dev/null @@ -1,207 +0,0 @@ - - - - - Debug - arm64 - - - Debug - Win32 - - - Release - arm64 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 16.0 - {7756A1A4-17B5-4E6B-9B12-F19AA868A225} - AtlProj - 10.0 - DynamicLibrary - true - v145 - Unicode - - - - - - true - true - ..\..\artifacts\$(Configuration)\$(Platform)\$(MSBuildProjectName)\ - ..\..\artifacts\intermediates\$(Platform)\$(MSBuildProjectName)\ - Files.App.SaveDialog$(PlatformArchitecture) - - - true - false - false - ..\..\artifacts\$(Configuration)\$(Platform)\$(MSBuildProjectName)\ - ..\..\artifacts\intermediates\$(Platform)\$(MSBuildProjectName)\ - Files.App.SaveDialog$(PlatformArchitecture) - - - - Use - Level3 - pch.h - true - - - false - CustomSaveDialog_i.h - CustomSaveDialog_i.c - CustomSaveDialog_p.c - true - $(IntDir)CustomSaveDialog.tlb - true - - - 0x0410 - $(IntDir);%(AdditionalIncludeDirectories) - - - Windows - .\CustomSaveDialog.def - false - true - $(OutDir)Files.App.SaveDialog$(PlatformArchitecture)$(TargetExt) - - - xcopy /s /y "$(ProjectDir)$(OutDir)*.dll" "$(ProjectDir)..\..\src\Files.App\Assets\FilesOpenDialog" - - - - - Disabled - WIN32;_WINDOWS;_DEBUG;_USRDLL;%(PreprocessorDefinitions) - - - Win32 - _DEBUG;%(PreprocessorDefinitions) - - - _DEBUG;%(PreprocessorDefinitions) - - - - - Disabled - _WINDOWS;_DEBUG;_USRDLL;%(PreprocessorDefinitions) - - - _DEBUG;%(PreprocessorDefinitions) - - - _DEBUG;%(PreprocessorDefinitions) - - - - - Disabled - _WINDOWS;_DEBUG;_USRDLL;%(PreprocessorDefinitions) - - - _DEBUG;%(PreprocessorDefinitions) - - - _DEBUG;%(PreprocessorDefinitions) - - - - - MaxSpeed - WIN32;_WINDOWS;NDEBUG;_USRDLL;%(PreprocessorDefinitions) - - - Win32 - NDEBUG;%(PreprocessorDefinitions) - - - NDEBUG;%(PreprocessorDefinitions) - - - true - true - - - - - MaxSpeed - _WINDOWS;NDEBUG;_USRDLL;%(PreprocessorDefinitions) - - - NDEBUG;%(PreprocessorDefinitions) - - - NDEBUG;%(PreprocessorDefinitions) - - - true - true - - - - - MaxSpeed - _WINDOWS;NDEBUG;_USRDLL;%(PreprocessorDefinitions) - - - NDEBUG;%(PreprocessorDefinitions) - - - NDEBUG;%(PreprocessorDefinitions) - - - true - true - - - - - - - - - - - - - - - false - - - - - false - - - - - - - Create - - - - - - - - - \ No newline at end of file diff --git a/src/Files.App.SaveDialog/Files.App.SaveDialog.vcxproj b/src/Files.App.SaveDialog/Files.App.SaveDialog.vcxproj deleted file mode 100644 index 098d63c7cbd8..000000000000 --- a/src/Files.App.SaveDialog/Files.App.SaveDialog.vcxproj +++ /dev/null @@ -1,206 +0,0 @@ - - - - Debug - arm64 - - - Debug - Win32 - - - Release - arm64 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 16.0 - {EBFA367F-CBDB-4CD0-B838-D6B95F61D1F6} - AtlProj - 10.0 - DynamicLibrary - true - v145 - Unicode - - - - - - true - true - ..\..\artifacts\$(Configuration)\$(Platform)\$(MSBuildProjectName)\ - ..\..\artifacts\intermediates\$(Platform)\$(MSBuildProjectName)\ - Files.App.SaveDialog$(PlatformArchitecture) - - - true - false - false - ..\..\artifacts\$(Configuration)\$(Platform)\$(MSBuildProjectName)\ - ..\..\artifacts\intermediates\$(Platform)\$(MSBuildProjectName)\ - Files.App.SaveDialog$(PlatformArchitecture) - - - - Use - Level3 - pch.h - true - - - false - CustomSaveDialog_i.h - CustomSaveDialog_i.c - CustomSaveDialog_p.c - true - $(IntDir)CustomSaveDialog.tlb - true - - - 0x0410 - $(IntDir);%(AdditionalIncludeDirectories) - - - Windows - .\CustomSaveDialog.def - false - true - $(OutDir)Files.App.SaveDialog$(PlatformArchitecture)$(TargetExt) - - - xcopy /s /y "$(ProjectDir)$(OutDir)*.dll" "$(ProjectDir)..\..\src\Files.App\Assets\FilesOpenDialog" - - - - - Disabled - WIN32;_WINDOWS;_DEBUG;_USRDLL;%(PreprocessorDefinitions) - - - Win32 - _DEBUG;%(PreprocessorDefinitions) - - - _DEBUG;%(PreprocessorDefinitions) - - - - - Disabled - _WINDOWS;_DEBUG;_USRDLL;%(PreprocessorDefinitions) - - - _DEBUG;%(PreprocessorDefinitions) - - - _DEBUG;%(PreprocessorDefinitions) - - - - - Disabled - _WINDOWS;_DEBUG;_USRDLL;%(PreprocessorDefinitions) - - - _DEBUG;%(PreprocessorDefinitions) - - - _DEBUG;%(PreprocessorDefinitions) - - - - - MaxSpeed - WIN32;_WINDOWS;NDEBUG;_USRDLL;%(PreprocessorDefinitions) - - - Win32 - NDEBUG;%(PreprocessorDefinitions) - - - NDEBUG;%(PreprocessorDefinitions) - - - true - true - - - - - MaxSpeed - _WINDOWS;NDEBUG;_USRDLL;%(PreprocessorDefinitions) - - - NDEBUG;%(PreprocessorDefinitions) - - - NDEBUG;%(PreprocessorDefinitions) - - - true - true - - - - - MaxSpeed - _WINDOWS;NDEBUG;_USRDLL;%(PreprocessorDefinitions) - - - NDEBUG;%(PreprocessorDefinitions) - - - NDEBUG;%(PreprocessorDefinitions) - - - true - true - - - - - - - - - - - - - - - false - - - - - false - - - - - - - Create - - - - - - - - - \ No newline at end of file diff --git a/src/Files.App.SaveDialog/Files.App.SaveDialog.vcxproj.filters b/src/Files.App.SaveDialog/Files.App.SaveDialog.vcxproj.filters deleted file mode 100644 index a3c5c5a147aa..000000000000 --- a/src/Files.App.SaveDialog/Files.App.SaveDialog.vcxproj.filters +++ /dev/null @@ -1,91 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - {487d0712-ae0c-468f-9ef2-12da6ffc5361} - False - - - - - File di intestazione - - - File di intestazione - - - File di intestazione - - - File di intestazione - - - File di intestazione - - - File di intestazione - - - File di intestazione - - - File generati - - - File di intestazione - - - - - File di origine - - - File di origine - - - File di origine - - - File di origine - - - File generati - - - File di origine - - - - - File di risorse - - - - - File di risorse - - - File di origine - - - File di risorse - - - - - File di origine - - - \ No newline at end of file diff --git a/src/Files.App.SaveDialog/FilesDialogEvents.cpp b/src/Files.App.SaveDialog/FilesDialogEvents.cpp deleted file mode 100644 index 527c45efe244..000000000000 --- a/src/Files.App.SaveDialog/FilesDialogEvents.cpp +++ /dev/null @@ -1,84 +0,0 @@ -#include "pch.h" -#include "FilesDialogEvents.h" -#include - -using std::cout; -using std::wcout; -using std::endl; - -FilesDialogEvents::FilesDialogEvents(IFileDialogEvents* evt, IFileDialog* cust) -{ - _evt = evt; - _cust = cust; -} - -HRESULT __stdcall FilesDialogEvents::QueryInterface(REFIID riid, void** ppvObject) -{ - HRESULT res = _evt->QueryInterface(riid, ppvObject); - OLECHAR* guidString; - (void)StringFromCLSID(riid, &guidString); - std::wcout << L"Event: QueryInterface: " << guidString << L" = " << res << std::endl; - ::CoTaskMemFree(guidString); - return res; -} - -ULONG __stdcall FilesDialogEvents::AddRef(void) -{ - cout << "Event: AddRef" << endl; - return _evt->AddRef(); -} - -ULONG __stdcall FilesDialogEvents::Release(void) -{ - cout << "Event: Release" << endl; - return _evt->Release(); -} - -HRESULT __stdcall FilesDialogEvents::OnFileOk(IFileDialog* pfd) -{ - cout << "Event: PRE OnFileOk" << endl; - HRESULT res = _evt->OnFileOk(_cust); - cout << "Event: OnFileOk = " << res << endl; - return res; -} - -HRESULT __stdcall FilesDialogEvents::OnFolderChanging(IFileDialog* pfd, IShellItem* psiFolder) -{ - HRESULT res = _evt->OnFolderChanging(_cust, psiFolder); - cout << "Event: OnFolderChanging = " << res << endl; - return res; -} - -HRESULT __stdcall FilesDialogEvents::OnFolderChange(IFileDialog* pfd) -{ - HRESULT res = _evt->OnFolderChange(_cust); - cout << "Event: OnFolderChange = " << res << endl; - return res; -} - -HRESULT __stdcall FilesDialogEvents::OnSelectionChange(IFileDialog* pfd) -{ - HRESULT res = _evt->OnSelectionChange(_cust); - cout << "Event: OnSelectionChange = " << res << endl; - return res; -} - -HRESULT __stdcall FilesDialogEvents::OnShareViolation(IFileDialog* pfd, IShellItem* psi, FDE_SHAREVIOLATION_RESPONSE* pResponse) -{ - cout << "Event: OnShareViolation" << endl; - return E_NOTIMPL; -} - -HRESULT __stdcall FilesDialogEvents::OnTypeChange(IFileDialog* pfd) -{ - HRESULT res = _evt->OnTypeChange(_cust); - cout << "Event: OnTypeChange = " << res << endl; - return res; -} - -HRESULT __stdcall FilesDialogEvents::OnOverwrite(IFileDialog* pfd, IShellItem* psi, FDE_OVERWRITE_RESPONSE* pResponse) -{ - HRESULT res = _evt->OnOverwrite(_cust, psi, pResponse); - cout << "Event: OnOverwrite = " << res << ", " << *pResponse << endl; - return res; -} diff --git a/src/Files.App.SaveDialog/FilesDialogEvents.h b/src/Files.App.SaveDialog/FilesDialogEvents.h deleted file mode 100644 index 26a4a72208ef..000000000000 --- a/src/Files.App.SaveDialog/FilesDialogEvents.h +++ /dev/null @@ -1,27 +0,0 @@ -#pragma once -#include "resource.h" // simboli principali - -#include "oaidl.h" -#include "ocidl.h" -#include "shobjidl.h" - -class FilesDialogEvents : public IFileDialogEvents -{ - IFileDialogEvents* _evt; - IFileDialog* _cust; - -public: - FilesDialogEvents(IFileDialogEvents* evt, IFileDialog *cust); - - // Ereditato tramite IFileDialogEvents - HRESULT __stdcall QueryInterface(REFIID riid, void** ppvObject) override; - ULONG __stdcall AddRef(void) override; - ULONG __stdcall Release(void) override; - HRESULT __stdcall OnFileOk(IFileDialog* pfd) override; - HRESULT __stdcall OnFolderChanging(IFileDialog* pfd, IShellItem* psiFolder) override; - HRESULT __stdcall OnFolderChange(IFileDialog* pfd) override; - HRESULT __stdcall OnSelectionChange(IFileDialog* pfd) override; - HRESULT __stdcall OnShareViolation(IFileDialog* pfd, IShellItem* psi, FDE_SHAREVIOLATION_RESPONSE* pResponse) override; - HRESULT __stdcall OnTypeChange(IFileDialog* pfd) override; - HRESULT __stdcall OnOverwrite(IFileDialog* pfd, IShellItem* psi, FDE_OVERWRITE_RESPONSE* pResponse) override; -}; diff --git a/src/Files.App.SaveDialog/FilesSaveDialog.cpp b/src/Files.App.SaveDialog/FilesSaveDialog.cpp deleted file mode 100644 index 9a5f55e756a1..000000000000 --- a/src/Files.App.SaveDialog/FilesSaveDialog.cpp +++ /dev/null @@ -1,1116 +0,0 @@ -// FilesSaveDialog.cpp: implementazione di CFilesSaveDialog - -#include "pch.h" -#include "FilesSaveDialog.h" -#include -#include -#include -#include -#include -#include - -//#define SYSTEMDIALOG - -using std::cout; -using std::wcout; -using std::endl; - -// CFilesSaveDialog - -CComPtr GetSystemDialog() -{ - WCHAR comdlg32Path[MAX_PATH]; - ExpandEnvironmentStringsW(L"%WINDIR%\\System32\\comdlg32.dll", comdlg32Path, MAX_PATH - 1); - - HINSTANCE lib = CoLoadLibrary(comdlg32Path, false); - BOOL(WINAPI* dllGetClassObject)(REFCLSID, REFIID, LPVOID*) = - (BOOL(WINAPI*)(REFCLSID, REFIID, LPVOID*))GetProcAddress(lib, "DllGetClassObject"); - CComPtr pClassFactory; - dllGetClassObject(CLSID_FileSaveDialog, IID_IClassFactory, (void**)&pClassFactory); - CComPtr systemDialog; - pClassFactory->CreateInstance(NULL, IID_IFileSaveDialog, (void**)&systemDialog); - //CoFreeLibrary(lib); - return systemDialog; -} - -std::string wstring_to_utf8_hex(const std::wstring& input) -{ - std::string output; - - int cbNeeded = WideCharToMultiByte(CP_UTF8, 0, input.c_str(), -1, NULL, 0, NULL, NULL); - if (cbNeeded > 0) - { - char* utf8 = new char[cbNeeded]; - if (WideCharToMultiByte(CP_UTF8, 0, input.c_str(), -1, utf8, cbNeeded, NULL, NULL) != 0) - { - for (char* p = utf8; *p; p++) - { - char onehex[5]; - sprintf_s(onehex, sizeof(onehex), "%%%02.2X", (unsigned char)*p); - output.append(onehex); - } - } - - delete[] utf8; - } - - return output; -} - -std::wstring str2wstr(const std::string& str) -{ - int cbNeeded = MultiByteToWideChar(CP_UTF8, 0, &str[0], (int)str.size(), NULL, 0); - if (cbNeeded > 0) - { - std::wstring wstrTo(cbNeeded, 0); - MultiByteToWideChar(CP_UTF8, 0, &str[0], (int)str.size(), &wstrTo[0], cbNeeded); - return wstrTo; - } - - return L""; -} - -template -CComPtr AsInterface(CComPtr dialog) -{ - CComPtr dialogInterface; - dialog->QueryInterface(&dialogInterface); - return dialogInterface; -} - -CFilesSaveDialog::CFilesSaveDialog() -{ - _fos = FOS_PATHMUSTEXIST; - _systemDialog = nullptr; - _debugStream = NULL; - _dialogEvents = NULL; - - PWSTR pszPath = NULL; - HRESULT hr = SHGetKnownFolderPath(FOLDERID_Desktop, 0, NULL, &pszPath); - if (SUCCEEDED(hr)) - { - TCHAR debugPath[MAX_PATH]; - wsprintf(debugPath, L"%s\\%s", pszPath, L"save_dialog.txt"); -#ifdef DEBUGLOG - _wfreopen_s(&_debugStream, debugPath, L"w", stdout); -#endif - CoTaskMemFree(pszPath); - } - cout << "Create" << endl; - - TCHAR tempPath[MAX_PATH]; - GetTempPath(MAX_PATH, tempPath); - TCHAR tempName[MAX_PATH]; - GetTempFileName(tempPath, L"fsd", 0, tempName); - _outputPath = tempName; - - (void)SHGetKnownFolderItem(FOLDERID_Documents, KF_FLAG_DEFAULT_PATH, NULL, IID_PPV_ARGS(&_initFolder)); - if (_initFolder && SUCCEEDED(_initFolder->GetDisplayName(SIGDN_NORMALDISPLAY, &pszPath))) - { - wcout << L"_outputPath: " << _outputPath << L", _initFolder: " << pszPath << endl; - CoTaskMemFree(pszPath); - } - -#ifdef SYSTEMDIALOG - _systemDialog = GetSystemDialog(); -#endif -} - -void CFilesSaveDialog::FinalRelease() -{ - if (_systemDialog) - { - _systemDialog.Release(); - } - _initFolder.Release(); - _dialogEvents.Release(); - DeleteFile(_outputPath.c_str()); - if (_debugStream) - { - fclose(_debugStream); - } -} - -HRESULT __stdcall CFilesSaveDialog::SetSite(IUnknown* pUnkSite) -{ - cout << "SetSite" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->SetSite(pUnkSite); -#endif - return S_OK; -} - -HRESULT __stdcall CFilesSaveDialog::GetSite(REFIID riid, void** ppvSite) -{ - cout << "GetSite" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->GetSite(riid, ppvSite); -#endif - return E_NOTIMPL; -} - -HRESULT __stdcall CFilesSaveDialog::EnableOpenDropDown(DWORD dwIDCtl) -{ - cout << "EnableOpenDropDown" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->EnableOpenDropDown(dwIDCtl); -#endif - return S_OK; -} - -HRESULT __stdcall CFilesSaveDialog::AddMenu(DWORD dwIDCtl, LPCWSTR pszLabel) -{ - cout << "AddMenu" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->AddMenu(dwIDCtl, pszLabel); -#endif - return S_OK; -} - -HRESULT __stdcall CFilesSaveDialog::AddPushButton(DWORD dwIDCtl, LPCWSTR pszLabel) -{ - cout << "AddPushButton" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->AddPushButton(dwIDCtl, pszLabel); -#endif - return S_OK; -} - -HRESULT __stdcall CFilesSaveDialog::AddComboBox(DWORD dwIDCtl) -{ - cout << "AddComboBox" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->AddComboBox(dwIDCtl); -#endif - return S_OK; -} - -HRESULT __stdcall CFilesSaveDialog::AddRadioButtonList(DWORD dwIDCtl) -{ - cout << "AddRadioButtonList" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->AddRadioButtonList(dwIDCtl); -#endif - return S_OK; -} - -HRESULT __stdcall CFilesSaveDialog::AddCheckButton(DWORD dwIDCtl, LPCWSTR pszLabel, BOOL bChecked) -{ - cout << "AddCheckButton" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->AddCheckButton(dwIDCtl, pszLabel, bChecked); -#endif - return S_OK; -} - -HRESULT __stdcall CFilesSaveDialog::AddEditBox(DWORD dwIDCtl, LPCWSTR pszText) -{ - cout << "AddEditBox" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->AddEditBox(dwIDCtl, pszText); -#endif - return S_OK; -} - -HRESULT __stdcall CFilesSaveDialog::AddSeparator(DWORD dwIDCtl) -{ - cout << "AddSeparator" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->AddSeparator(dwIDCtl); -#endif - return S_OK; -} - -HRESULT __stdcall CFilesSaveDialog::AddText(DWORD dwIDCtl, LPCWSTR pszText) -{ - cout << "AddText" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->AddText(dwIDCtl, pszText); -#endif - return S_OK; -} - -HRESULT __stdcall CFilesSaveDialog::SetControlLabel(DWORD dwIDCtl, LPCWSTR pszLabel) -{ - cout << "SetControlLabel" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->SetControlLabel(dwIDCtl, pszLabel); -#endif - return S_OK; -} - -HRESULT __stdcall CFilesSaveDialog::GetControlState(DWORD dwIDCtl, CDCONTROLSTATEF* pdwState) -{ - cout << "GetControlState" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->GetControlState(dwIDCtl, pdwState); -#endif - * pdwState = CDCS_ENABLEDVISIBLE; - return S_OK; -} - -HRESULT __stdcall CFilesSaveDialog::SetControlState(DWORD dwIDCtl, CDCONTROLSTATEF dwState) -{ - cout << "SetControlState" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->SetControlState(dwIDCtl, dwState); -#endif - return S_OK; -} - -HRESULT __stdcall CFilesSaveDialog::GetEditBoxText(DWORD dwIDCtl, WCHAR** ppszText) -{ - cout << "GetEditBoxText" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->GetEditBoxText(dwIDCtl, ppszText); -#endif - SHStrDupW(L"", ppszText); - return S_OK; -} - -HRESULT __stdcall CFilesSaveDialog::SetEditBoxText(DWORD dwIDCtl, LPCWSTR pszText) -{ - cout << "SetEditBoxText" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->SetEditBoxText(dwIDCtl, pszText); -#endif - return S_OK; -} - -HRESULT __stdcall CFilesSaveDialog::GetCheckButtonState(DWORD dwIDCtl, BOOL* pbChecked) -{ - cout << "GetCheckButtonState" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->GetCheckButtonState(dwIDCtl, pbChecked); -#endif - * pbChecked = false; - return S_OK; -} - -HRESULT __stdcall CFilesSaveDialog::SetCheckButtonState(DWORD dwIDCtl, BOOL bChecked) -{ - cout << "SetCheckButtonState" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->SetCheckButtonState(dwIDCtl, bChecked); -#endif - return S_OK; -} - -HRESULT __stdcall CFilesSaveDialog::AddControlItem(DWORD dwIDCtl, DWORD dwIDItem, LPCWSTR pszLabel) -{ - cout << "AddControlItem" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->AddControlItem(dwIDCtl, dwIDItem, pszLabel); -#endif - _ctrlItems.push_back(dwIDItem); - return S_OK; -} - -HRESULT __stdcall CFilesSaveDialog::RemoveControlItem(DWORD dwIDCtl, DWORD dwIDItem) -{ - cout << "RemoveControlItem" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->RemoveControlItem(dwIDCtl, dwIDItem); -#endif - return S_OK; -} - -HRESULT __stdcall CFilesSaveDialog::RemoveAllControlItems(DWORD dwIDCtl) -{ - cout << "RemoveAllControlItems" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->RemoveAllControlItems(dwIDCtl); -#endif - return S_OK; -} - -HRESULT __stdcall CFilesSaveDialog::GetControlItemState(DWORD dwIDCtl, DWORD dwIDItem, CDCONTROLSTATEF* pdwState) -{ - cout << "GetControlItemState" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->GetControlItemState(dwIDCtl, dwIDItem, pdwState); -#endif - * pdwState = CDCS_ENABLEDVISIBLE; - return S_OK; -} - -HRESULT __stdcall CFilesSaveDialog::SetControlItemState(DWORD dwIDCtl, DWORD dwIDItem, CDCONTROLSTATEF dwState) -{ - cout << "SetControlItemState" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->SetControlItemState(dwIDCtl, dwIDItem, dwState); -#endif - return S_OK; -} - -HRESULT __stdcall CFilesSaveDialog::GetSelectedControlItem(DWORD dwIDCtl, DWORD* pdwIDItem) -{ - cout << "GetSelectedControlItem" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->GetSelectedControlItem(dwIDCtl, pdwIDItem); -#endif - if (!_ctrlItems.empty()) { - *pdwIDItem = _ctrlItems.back(); - return S_OK; - } - return E_NOTIMPL; -} - -HRESULT __stdcall CFilesSaveDialog::SetSelectedControlItem(DWORD dwIDCtl, DWORD dwIDItem) -{ - cout << "SetSelectedControlItem" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->SetSelectedControlItem(dwIDCtl, dwIDItem); -#endif - _ctrlItems.push_back(dwIDItem); - return S_OK; -} - -HRESULT __stdcall CFilesSaveDialog::StartVisualGroup(DWORD dwIDCtl, LPCWSTR pszLabel) -{ - cout << "StartVisualGroup" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->StartVisualGroup(dwIDCtl, pszLabel); -#endif - return S_OK; -} - -HRESULT __stdcall CFilesSaveDialog::EndVisualGroup(void) -{ - cout << "EndVisualGroup" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->EndVisualGroup(); -#endif - return S_OK; -} - -HRESULT __stdcall CFilesSaveDialog::MakeProminent(DWORD dwIDCtl) -{ - cout << "MakeProminent" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->MakeProminent(dwIDCtl); -#endif - return S_OK; -} - -HRESULT __stdcall CFilesSaveDialog::SetControlItemText(DWORD dwIDCtl, DWORD dwIDItem, LPCWSTR pszLabel) -{ - cout << "SetControlItemText" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->SetControlItemText(dwIDCtl, dwIDItem, pszLabel); -#endif - return S_OK; -} - -HRESULT __stdcall CFilesSaveDialog::Show(HWND hwndOwner) -{ - wchar_t wnd_title[1024]; - GetWindowText(hwndOwner, wnd_title, 1024); - wcout << L"Show, ID: " << GetCurrentProcessId() << endl; - _selectedItem.clear(); - -#ifdef SYSTEMDIALOG - HRESULT res = _systemDialog->Show(NULL); - cout << "Show, DONE: " << res << endl; - return res; -#endif - - SHELLEXECUTEINFO ShExecInfo = { 0 }; - ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO); - ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS; - - PWSTR pszPath = NULL; - WCHAR szBuf[MAX_PATH]; - TCHAR args[1024] = { 0 }; - ExpandEnvironmentStringsW(L"%LOCALAPPDATA%\\Microsoft\\WindowsApps\\files-dev.exe", szBuf, MAX_PATH - 1); - - HANDLE closeEvent = CreateEvent(NULL, FALSE, FALSE, TEXT("FILEDIALOG")); - - if (_initFolder && SUCCEEDED(_initFolder->GetDisplayName(SIGDN_DESKTOPABSOLUTEPARSING, &pszPath))) - { - if (!_initName.empty()) - { - swprintf(args, _countof(args) - 1, L"\"%s\" -directory \"%s\" -outputpath \"%s\" -select \"%s\"", szBuf, pszPath, _outputPath.c_str(), _initName.c_str()); - } - else - { - swprintf(args, _countof(args) - 1, L"\"%s\" -directory \"%s\" -outputpath \"%s\"", szBuf, pszPath, _outputPath.c_str()); - } - wcout << L"Invoking: " << args << endl; - CoTaskMemFree(pszPath); - } - else - { - swprintf(args, _countof(args) - 1, L"\"%s\" -outputpath \"%s\"", szBuf, _outputPath.c_str()); - } - - std::wstring uriWithArgs = L"files-dev:?cmd=" + str2wstr(wstring_to_utf8_hex(args)); - ShExecInfo.lpFile = uriWithArgs.c_str(); - ShExecInfo.nShow = SW_SHOW; - ShellExecuteEx(&ShExecInfo); - - if (hwndOwner) - EnableWindow(hwndOwner, FALSE); - - MSG msg; - while (ShExecInfo.hProcess) - { - switch (MsgWaitForMultipleObjectsEx(1, &closeEvent, INFINITE, QS_ALLINPUT, 0)) - { - case WAIT_OBJECT_0: - CloseHandle(ShExecInfo.hProcess); - ShExecInfo.hProcess = NULL; - break; - case WAIT_OBJECT_0 + 1: - while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) - { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - continue; - default: __debugbreak(); - } - } - - if (closeEvent) - CloseHandle(closeEvent); - - if (hwndOwner) - { - EnableWindow(hwndOwner, TRUE); - SetForegroundWindow(hwndOwner); - } - - std::ifstream file(_outputPath); - if (file.good()) - { - std::string str; - std::wstring_convert> converter; - while (std::getline(file, str)) - { - std::wstring wide = converter.from_bytes(str); - _selectedItem = wide; - } - } - DeleteFile(_outputPath.c_str()); - - if (!_selectedItem.empty()) - { - // Create destination file if not existing - HANDLE hFile = CreateFile(_selectedItem.c_str(), GENERIC_WRITE, 0, 0, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); - if (hFile != INVALID_HANDLE_VALUE) - { - CloseHandle(hFile); - } - else - { - _selectedItem = L""; - } - } - if (!_selectedItem.empty()) - { - if (_dialogEvents) - { - _dialogEvents->OnFileOk(this); - } - } - - return !_selectedItem.empty() ? S_OK : HRESULT_FROM_WIN32(ERROR_CANCELLED); -} - -HRESULT __stdcall CFilesSaveDialog::SetFileTypes(UINT cFileTypes, const COMDLG_FILTERSPEC* rgFilterSpec) -{ - cout << "SetFileTypes, cFileTypes: " << cFileTypes << endl; -#ifdef SYSTEMDIALOG - return _systemDialog->SetFileTypes(cFileTypes, rgFilterSpec); -#endif - return S_OK; -} - -HRESULT __stdcall CFilesSaveDialog::SetFileTypeIndex(UINT iFileType) -{ - cout << "SetFileTypeIndex, iFileType: " << iFileType << endl; -#ifdef SYSTEMDIALOG - return _systemDialog->SetFileTypeIndex(iFileType); -#endif - return S_OK; -} - -HRESULT __stdcall CFilesSaveDialog::GetFileTypeIndex(UINT* piFileType) -{ - cout << "GetFileTypeIndex" << endl; -#ifdef SYSTEMDIALOG - return _systemDialog->GetFileTypeIndex(piFileType); -#endif - * piFileType = 1; - return S_OK; -} - -HRESULT __stdcall CFilesSaveDialog::Advise(IFileDialogEvents* pfde, DWORD* pdwCookie) -{ - cout << "Advise" << endl; -#ifdef SYSTEMDIALOG - return _systemDialog->Advise(pfde, pdwCookie); -#endif - _dialogEvents = pfde; - *pdwCookie = 4; - return S_OK; -} - -HRESULT __stdcall CFilesSaveDialog::Unadvise(DWORD dwCookie) -{ - cout << "Unadvise, dwCookie: " << dwCookie << endl; -#ifdef SYSTEMDIALOG - return _systemDialog->Unadvise(dwCookie); -#endif - _dialogEvents.Release(); - return S_OK; -} - -HRESULT __stdcall CFilesSaveDialog::SetOptions(FILEOPENDIALOGOPTIONS fos) -{ - cout << "SetOptions, fos: " << fos << endl; -#ifdef SYSTEMDIALOG - return _systemDialog->SetOptions(fos); -#endif - _fos = fos; - return S_OK; -} - -HRESULT __stdcall CFilesSaveDialog::GetOptions(FILEOPENDIALOGOPTIONS* pfos) -{ - cout << "GetOptions, fos: " << _fos << endl; -#ifdef SYSTEMDIALOG - return _systemDialog->GetOptions(pfos); -#endif - * pfos = _fos; - return S_OK; -} - -HRESULT __stdcall CFilesSaveDialog::SetDefaultFolder(IShellItem* psi) -{ - PWSTR pszPath = NULL; - if (SUCCEEDED(psi->GetDisplayName(SIGDN_DESKTOPABSOLUTEPARSING, &pszPath))) - { - wcout << L"SetDefaultFolder, psi: " << pszPath << endl; - CoTaskMemFree(pszPath); - } -#ifdef SYSTEMDIALOG - return _systemDialog->SetDefaultFolder(psi); -#endif - _initFolder = psi; - return S_OK; -} - -HRESULT __stdcall CFilesSaveDialog::SetFolder(IShellItem* psi) -{ - PWSTR pszPath = NULL; - if (SUCCEEDED(psi->GetDisplayName(SIGDN_DESKTOPABSOLUTEPARSING, &pszPath))) - { - wcout << L"SetFolder, psi: " << pszPath << endl; - CoTaskMemFree(pszPath); - } -#ifdef SYSTEMDIALOG - return _systemDialog->SetFolder(psi); -#endif - _initFolder = psi; - return S_OK; -} - -HRESULT __stdcall CFilesSaveDialog::GetFolder(IShellItem** ppsi) -{ - cout << "GetFolder" << endl; -#ifdef SYSTEMDIALOG - return _systemDialog->GetFolder(ppsi); -#endif - * ppsi = NULL; - return E_NOTIMPL; -} - -HRESULT __stdcall CFilesSaveDialog::GetCurrentSelection(IShellItem** ppsi) -{ - cout << "GetCurrentSelection" << endl; -#ifdef SYSTEMDIALOG - return _systemDialog->GetCurrentSelection(ppsi); -#endif - return GetResult(ppsi); -} - -HRESULT __stdcall CFilesSaveDialog::SetFileName(LPCWSTR pszName) -{ - wcout << L"SetFileName, pszName: " << pszName << endl; -#ifdef SYSTEMDIALOG - return _systemDialog->SetFileName(pszName); -#endif - std::wstring absPath = std::wstring(pszName); - _initName = absPath.substr(absPath.find_last_of(L"/\\") + 1); - return S_OK; -} - -HRESULT __stdcall CFilesSaveDialog::GetFileName(LPWSTR* pszName) -{ - cout << "GetFileName" << endl; -#ifdef SYSTEMDIALOG - return _systemDialog->GetFileName(pszName); -#endif - return SHStrDupW(_selectedItem.empty() ? L"" : _selectedItem.c_str(), pszName); -} - -HRESULT __stdcall CFilesSaveDialog::SetTitle(LPCWSTR pszTitle) -{ - wcout << L"SetTitle, title: " << pszTitle << endl; -#ifdef SYSTEMDIALOG - return _systemDialog->SetTitle(pszTitle); -#endif - return S_OK; -} - -HRESULT __stdcall CFilesSaveDialog::SetOkButtonLabel(LPCWSTR pszText) -{ - wcout << L"SetOkButtonLabel, pszText: " << pszText << endl; -#ifdef SYSTEMDIALOG - return _systemDialog->SetOkButtonLabel(pszText); -#endif - return S_OK; -} - -HRESULT __stdcall CFilesSaveDialog::SetFileNameLabel(LPCWSTR pszLabel) -{ - wcout << L"SetFileNameLabel, pszLabel: " << pszLabel << endl; -#ifdef SYSTEMDIALOG - return _systemDialog->SetFileNameLabel(pszLabel); -#endif - return S_OK; -} - -HRESULT __stdcall CFilesSaveDialog::GetResult(IShellItem** ppsi) -{ - cout << "GetResult" << endl; -#ifdef SYSTEMDIALOG - return _systemDialog->GetResult(ppsi); -#endif - *ppsi = NULL; - if (!_selectedItem.empty()) - return SHCreateItemFromParsingName(_selectedItem.c_str(), NULL, IID_IShellItem, (void**)ppsi); - return E_NOTIMPL; -} - -HRESULT __stdcall CFilesSaveDialog::AddPlace(IShellItem* psi, FDAP fdap) -{ - PWSTR pszPath = NULL; - if (SUCCEEDED(psi->GetDisplayName(SIGDN_DESKTOPABSOLUTEPARSING, &pszPath))) - { - wcout << L"AddPlace, psi: " << pszPath << endl; - CoTaskMemFree(pszPath); - } -#ifdef SYSTEMDIALOG - return _systemDialog->AddPlace(psi, fdap); -#endif - return S_OK; -} - -HRESULT __stdcall CFilesSaveDialog::SetDefaultExtension(LPCWSTR pszDefaultExtension) -{ - wcout << L"SetDefaultExtension, pszDefaultExtension: " << pszDefaultExtension << endl; -#ifdef SYSTEMDIALOG - return _systemDialog->SetDefaultExtension(pszDefaultExtension); -#endif - return S_OK; -} - -HRESULT __stdcall CFilesSaveDialog::Close(HRESULT hr) -{ - cout << "Close, hr: " << hr << endl; -#ifdef SYSTEMDIALOG - return _systemDialog->Close(hr); -#endif - return E_NOTIMPL; -} - -HRESULT __stdcall CFilesSaveDialog::SetClientGuid(REFGUID guid) -{ - cout << "SetClientGuid" << endl; -#ifdef SYSTEMDIALOG - return _systemDialog->SetClientGuid(guid); -#endif - return S_OK; -} - -HRESULT __stdcall CFilesSaveDialog::ClearClientData(void) -{ - cout << "ClearClientData" << endl; -#ifdef SYSTEMDIALOG - return _systemDialog->ClearClientData(); -#endif - return S_OK; -} - -HRESULT __stdcall CFilesSaveDialog::SetFilter(IShellItemFilter* pFilter) -{ - cout << "SetFilter" << endl; -#ifdef SYSTEMDIALOG - return _systemDialog->SetFilter(pFilter); -#endif - return S_OK; -} - -HRESULT __stdcall CFilesSaveDialog::SetCancelButtonLabel(LPCWSTR pszLabel) -{ - cout << "SetCancelButtonLabel" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->SetCancelButtonLabel(pszLabel); -#endif - return S_OK; -} - -HRESULT __stdcall CFilesSaveDialog::SetNavigationRoot(IShellItem* psi) -{ - cout << "SetNavigationRoot" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->SetNavigationRoot(psi); -#endif - return S_OK; -} - -HRESULT __stdcall CFilesSaveDialog::HideControlsForHostedPickerProviderApp(void) -{ - cout << "HideControlsForHostedPickerProviderApp" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->HideControlsForHostedPickerProviderApp(); -#endif - return E_NOTIMPL; -} - -HRESULT __stdcall CFilesSaveDialog::EnableControlsForHostedPickerProviderApp(void) -{ - cout << "EnableControlsForHostedPickerProviderApp" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->EnableControlsForHostedPickerProviderApp(); -#endif - return E_NOTIMPL; -} - -HRESULT __stdcall CFilesSaveDialog::GetPrivateOptions(unsigned long* pfos) -{ - cout << "GetPrivateOptions" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->GetPrivateOptions(pfos); -#endif - * pfos = 0; - return S_OK; -} - -HRESULT __stdcall CFilesSaveDialog::SetPrivateOptions(unsigned long fos) -{ - cout << "SetPrivateOptions" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->SetPrivateOptions(fos); -#endif - return S_OK; -} - -HRESULT __stdcall CFilesSaveDialog::SetPersistenceKey(unsigned short const* pkey) -{ - cout << "SetPersistenceKey" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->SetPersistenceKey(pkey); -#endif - return E_NOTIMPL; -} - -HRESULT __stdcall CFilesSaveDialog::HasPlaces(void) -{ - cout << "HasPlaces" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->HasPlaces(); -#endif - return E_NOTIMPL; -} - -HRESULT __stdcall CFilesSaveDialog::EnumPlaces(int plc, _GUID const& riid, void** ppv) -{ - cout << "EnumPlaces" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->EnumPlaces(plc, riid, ppv); -#endif - return E_NOTIMPL; -} - -HRESULT __stdcall CFilesSaveDialog::EnumControls(void** ppv) -{ - cout << "EnumControls" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->EnumControls(ppv); -#endif - return E_NOTIMPL; -} - -HRESULT __stdcall CFilesSaveDialog::GetPersistRegkey(unsigned short** preg) -{ - cout << "GetPersistRegkey" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->GetPersistRegkey(preg); -#endif - return E_NOTIMPL; -} - -HRESULT __stdcall CFilesSaveDialog::GetSavePropertyStore(IPropertyStore** ppstore, IPropertyDescriptionList** ppdesclist) -{ - cout << "GetSavePropertyStore" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->GetSavePropertyStore(ppstore, ppdesclist); -#endif - return E_NOTIMPL; -} - -HRESULT __stdcall CFilesSaveDialog::GetSaveExtension(unsigned short** pext) -{ - cout << "GetSaveExtension" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->GetSaveExtension(pext); -#endif - return E_NOTIMPL; -} - -HRESULT __stdcall CFilesSaveDialog::GetFileTypeControl(void** ftp) -{ - cout << "GetFileTypeControl" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->GetFileTypeControl(ftp); -#endif - return E_NOTIMPL; -} - -HRESULT __stdcall CFilesSaveDialog::GetFileNameControl(void** pctrl) -{ - cout << "GetFileNameControl" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->GetFileNameControl(pctrl); -#endif - return E_NOTIMPL; -} - -HRESULT __stdcall CFilesSaveDialog::GetFileProtectionControl(void** pfctrl) -{ - cout << "GetFileProtectionControl" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->GetFileProtectionControl(pfctrl); -#endif - return E_NOTIMPL; -} - -HRESULT __stdcall CFilesSaveDialog::SetFolderPrivate(IShellItem* psi, int arg) -{ - cout << "SetFolderPrivate" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->SetFolderPrivate(psi, arg); -#endif - return E_NOTIMPL; -} - -HRESULT __stdcall CFilesSaveDialog::SetCustomControlAreaHeight(unsigned int height) -{ - cout << "SetCustomControlAreaHeight" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->SetCustomControlAreaHeight(height); -#endif - return E_NOTIMPL; -} - -HRESULT __stdcall CFilesSaveDialog::GetDialogState(unsigned long arg, unsigned long* pstate) -{ - cout << "GetDialogState" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->GetDialogState(arg, pstate); -#endif - return E_NOTIMPL; -} - -HRESULT __stdcall CFilesSaveDialog::SetAppControlsModule(void* papp) -{ - cout << "SetAppControlsModule" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->SetAppControlsModule(papp); -#endif - return E_NOTIMPL; -} - -HRESULT __stdcall CFilesSaveDialog::SetUserEditedSaveProperties(void) -{ - cout << "SetUserEditedSaveProperties" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->SetUserEditedSaveProperties(); -#endif - return E_NOTIMPL; -} - -HRESULT __stdcall CFilesSaveDialog::ShouldShowStandardNavigationRoots(void) -{ - cout << "ShouldShowStandardNavigationRoots" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->ShouldShowStandardNavigationRoots(); -#endif - return E_NOTIMPL; -} - -HRESULT __stdcall CFilesSaveDialog::GetNavigationRoot(_GUID const& riid, void** ppv) -{ - cout << "GetNavigationRoot" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->GetNavigationRoot(riid, ppv); -#endif - return E_NOTIMPL; -} - -HRESULT __stdcall CFilesSaveDialog::ShouldShowFileProtectionControl(int* pfpc) -{ - cout << "ShouldShowFileProtectionControl" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->ShouldShowFileProtectionControl(pfpc); -#endif - return E_NOTIMPL; -} - -HRESULT __stdcall CFilesSaveDialog::GetCurrentDialogView(_GUID const& riid, void** ppv) -{ - cout << "GetCurrentDialogView" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->GetCurrentDialogView(riid, ppv); -#endif - return E_NOTIMPL; -} - -HRESULT __stdcall CFilesSaveDialog::SetSaveDialogEditBoxTextAndFileType(int arg, unsigned short const* pargb) -{ - cout << "SetSaveDialogEditBoxTextAndFileType" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->SetSaveDialogEditBoxTextAndFileType(arg, pargb); -#endif - return E_NOTIMPL; -} - -HRESULT __stdcall CFilesSaveDialog::MoveFocusFromBrowser(int arg) -{ - cout << "MoveFocusFromBrowser" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->MoveFocusFromBrowser(arg); -#endif - return E_NOTIMPL; -} - -HRESULT __stdcall CFilesSaveDialog::EnableOkButton(int enbl) -{ - cout << "EnableOkButton" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->EnableOkButton(enbl); -#endif - return E_NOTIMPL; -} - -HRESULT __stdcall CFilesSaveDialog::InitEnterpriseId(unsigned short const* pid) -{ - cout << "InitEnterpriseId" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->InitEnterpriseId(pid); -#endif - return E_NOTIMPL; -} - -HRESULT __stdcall CFilesSaveDialog::AdviseFirst(IFileDialogEvents* pfde, unsigned long* pdwCookie) -{ - cout << "AdviseFirst" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->AdviseFirst(pfde, pdwCookie); -#endif - return E_NOTIMPL; -} - -HRESULT __stdcall CFilesSaveDialog::HandleTab(void) -{ - cout << "HandleTab" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->HandleTab(); -#endif - return E_NOTIMPL; -} - -HRESULT __stdcall CFilesSaveDialog::SetSaveAsItem(IShellItem* psi) -{ - PWSTR pszPath = NULL; - if (SUCCEEDED(psi->GetDisplayName(SIGDN_DESKTOPABSOLUTEPARSING, &pszPath))) - { - wcout << L"SetSaveAsItem, psi: " << pszPath << endl; - CoTaskMemFree(pszPath); - } -#ifdef SYSTEMDIALOG - return _systemDialog->SetSaveAsItem(psi); -#endif - _initFolder.Release(); - psi->GetParent(&_initFolder); - if (SUCCEEDED(psi->GetDisplayName(SIGDN_NORMALDISPLAY, &pszPath))) - { - _initName = pszPath; - CoTaskMemFree(pszPath); - } - return S_OK; -} - -HRESULT __stdcall CFilesSaveDialog::SetProperties(IPropertyStore* pStore) -{ - cout << "SetProperties" << endl; -#ifdef SYSTEMDIALOG - return _systemDialog->SetProperties(pStore); -#endif - return S_OK; -} - -HRESULT __stdcall CFilesSaveDialog::SetCollectedProperties(IPropertyDescriptionList* pList, BOOL fAppendDefault) -{ - cout << "SetCollectedProperties" << endl; -#ifdef SYSTEMDIALOG - return _systemDialog->SetCollectedProperties(pList, fAppendDefault); -#endif - return S_OK; -} - -HRESULT __stdcall CFilesSaveDialog::GetProperties(IPropertyStore** ppStore) -{ - cout << "GetProperties" << endl; -#ifdef SYSTEMDIALOG - return _systemDialog->GetProperties(ppStore); -#endif - if (!_selectedItem.empty()) - { - return SHGetPropertyStoreFromParsingName(_selectedItem.c_str(), - NULL, GPS_DEFAULT, __uuidof(IPropertyStore), (void**)ppStore); - } - return E_NOTIMPL; -} - -HRESULT __stdcall CFilesSaveDialog::ApplyProperties(IShellItem* psi, IPropertyStore* pStore, HWND hwnd, IFileOperationProgressSink* pSink) -{ - cout << "ApplyProperties" << endl; -#ifdef SYSTEMDIALOG - return _systemDialog->ApplyProperties(psi, pStore, hwnd, pSink); -#endif - return S_OK; -} - -HRESULT __stdcall CFilesSaveDialog::GetWindow(HWND* phwnd) -{ - cout << "GetWindow" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->GetWindow(phwnd); -#endif - * phwnd = NULL; - return S_OK; -} - -HRESULT __stdcall CFilesSaveDialog::ContextSensitiveHelp(BOOL fEnterMode) -{ - cout << "ContextSensitiveHelp" << endl; -#ifdef SYSTEMDIALOG - return AsInterface(_systemDialog)->ContextSensitiveHelp(fEnterMode); -#endif - return S_OK; -} diff --git a/src/Files.App.SaveDialog/FilesSaveDialog.h b/src/Files.App.SaveDialog/FilesSaveDialog.h deleted file mode 100644 index cde34560911c..000000000000 --- a/src/Files.App.SaveDialog/FilesSaveDialog.h +++ /dev/null @@ -1,273 +0,0 @@ -// FilesSaveDialog.h: dichiarazione di CFilesSaveDialog - -#pragma once -#include "resource.h" // simboli principali - - -#define DEBUGLOG - - -#include "CustomSaveDialog_i.h" -#include "UndefInterfaces.h" -#include -#include -#include - - -#if defined(_WIN32_WCE) && !defined(_CE_DCOM) && !defined(_CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA) -#error "Gli oggetti COM a thread singolo non sono supportati correttamente sulla piattaforma Windows CE, ad esempio le piattaforme Windows Mobile non includono un supporto DCOM completo. Definire _CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA per fare in modo che ATL supporti la creazione di oggetti COM a thread singolo e consenta l'utilizzo di implementazioni con oggetti COM a thread singolo. Il modello di threading nel file RGS è stato impostato su 'Free' poiché è l'unico modello di threading supportato sulle piattaforme Windows CE non DCOM." -#endif - -using namespace ATL; - - -// CFilesSaveDialog - -class ATL_NO_VTABLE CFilesSaveDialog : - public CComObjectRootEx, - public CComCoClass, - public IFileDialog, - public IFileDialog2, - public IFileSaveDialog, - public IFileDialogCustomize, - public IObjectWithSite, - public IFileDialogPrivate, - public IOleWindow -{ -public: - CFilesSaveDialog(); - -DECLARE_REGISTRY_RESOURCEID(106) - -CUSTOM_BEGIN_COM_MAP(CFilesSaveDialog) - COM_INTERFACE_ENTRY(IFileDialog) - COM_INTERFACE_ENTRY(IFileDialog2) - COM_INTERFACE_ENTRY(IFileSaveDialog) - COM_INTERFACE_ENTRY(IFileDialogCustomize) - COM_INTERFACE_ENTRY(IObjectWithSite) - COM_INTERFACE_ENTRY(IFileDialogPrivate) - COM_INTERFACE_ENTRY(IOleWindow) -END_COM_MAP() - - DECLARE_PROTECT_FINAL_CONSTRUCT() - - HRESULT FinalConstruct() - { - return S_OK; - } - - void FinalRelease(); - - CComPtr _systemDialog; - - FILEOPENDIALOGOPTIONS _fos; - - std::vector _ctrlItems; - - std::wstring _selectedItem; - std::wstring _outputPath; - std::wstring _initName; - CComPtr _initFolder; - CComPtr _dialogEvents; - - FILE* _debugStream; - -public: - // Ereditato tramite IObjectWithSite - HRESULT __stdcall SetSite(IUnknown* pUnkSite) override; - - HRESULT __stdcall GetSite(REFIID riid, void** ppvSite) override; - - - // Ereditato tramite IFileDialogCustomize - HRESULT __stdcall EnableOpenDropDown(DWORD dwIDCtl) override; - - HRESULT __stdcall AddMenu(DWORD dwIDCtl, LPCWSTR pszLabel) override; - - HRESULT __stdcall AddPushButton(DWORD dwIDCtl, LPCWSTR pszLabel) override; - - HRESULT __stdcall AddComboBox(DWORD dwIDCtl) override; - - HRESULT __stdcall AddRadioButtonList(DWORD dwIDCtl) override; - - HRESULT __stdcall AddCheckButton(DWORD dwIDCtl, LPCWSTR pszLabel, BOOL bChecked) override; - - HRESULT __stdcall AddEditBox(DWORD dwIDCtl, LPCWSTR pszText) override; - - HRESULT __stdcall AddSeparator(DWORD dwIDCtl) override; - - HRESULT __stdcall AddText(DWORD dwIDCtl, LPCWSTR pszText) override; - - HRESULT __stdcall SetControlLabel(DWORD dwIDCtl, LPCWSTR pszLabel) override; - - HRESULT __stdcall GetControlState(DWORD dwIDCtl, CDCONTROLSTATEF* pdwState) override; - - HRESULT __stdcall SetControlState(DWORD dwIDCtl, CDCONTROLSTATEF dwState) override; - - HRESULT __stdcall GetEditBoxText(DWORD dwIDCtl, WCHAR** ppszText) override; - - HRESULT __stdcall SetEditBoxText(DWORD dwIDCtl, LPCWSTR pszText) override; - - HRESULT __stdcall GetCheckButtonState(DWORD dwIDCtl, BOOL* pbChecked) override; - - HRESULT __stdcall SetCheckButtonState(DWORD dwIDCtl, BOOL bChecked) override; - - HRESULT __stdcall AddControlItem(DWORD dwIDCtl, DWORD dwIDItem, LPCWSTR pszLabel) override; - - HRESULT __stdcall RemoveControlItem(DWORD dwIDCtl, DWORD dwIDItem) override; - - HRESULT __stdcall RemoveAllControlItems(DWORD dwIDCtl) override; - - HRESULT __stdcall GetControlItemState(DWORD dwIDCtl, DWORD dwIDItem, CDCONTROLSTATEF* pdwState) override; - - HRESULT __stdcall SetControlItemState(DWORD dwIDCtl, DWORD dwIDItem, CDCONTROLSTATEF dwState) override; - - HRESULT __stdcall GetSelectedControlItem(DWORD dwIDCtl, DWORD* pdwIDItem) override; - - HRESULT __stdcall SetSelectedControlItem(DWORD dwIDCtl, DWORD dwIDItem) override; - - HRESULT __stdcall StartVisualGroup(DWORD dwIDCtl, LPCWSTR pszLabel) override; - - HRESULT __stdcall EndVisualGroup(void) override; - - HRESULT __stdcall MakeProminent(DWORD dwIDCtl) override; - - HRESULT __stdcall SetControlItemText(DWORD dwIDCtl, DWORD dwIDItem, LPCWSTR pszLabel) override; - - - // Ereditato tramite IFileDialog - HRESULT __stdcall Show(HWND hwndOwner) override; - - HRESULT __stdcall SetFileTypes(UINT cFileTypes, const COMDLG_FILTERSPEC* rgFilterSpec) override; - - HRESULT __stdcall SetFileTypeIndex(UINT iFileType) override; - - HRESULT __stdcall GetFileTypeIndex(UINT* piFileType) override; - - HRESULT __stdcall Advise(IFileDialogEvents* pfde, DWORD* pdwCookie) override; - - HRESULT __stdcall Unadvise(DWORD dwCookie) override; - - HRESULT __stdcall SetOptions(FILEOPENDIALOGOPTIONS fos) override; - - HRESULT __stdcall GetOptions(FILEOPENDIALOGOPTIONS* pfos) override; - - HRESULT __stdcall SetDefaultFolder(IShellItem* psi) override; - - HRESULT __stdcall SetFolder(IShellItem* psi) override; - - HRESULT __stdcall GetFolder(IShellItem** ppsi) override; - - HRESULT __stdcall GetCurrentSelection(IShellItem** ppsi) override; - - HRESULT __stdcall SetFileName(LPCWSTR pszName) override; - - HRESULT __stdcall GetFileName(LPWSTR* pszName) override; - - HRESULT __stdcall SetTitle(LPCWSTR pszTitle) override; - - HRESULT __stdcall SetOkButtonLabel(LPCWSTR pszText) override; - - HRESULT __stdcall SetFileNameLabel(LPCWSTR pszLabel) override; - - HRESULT __stdcall GetResult(IShellItem** ppsi) override; - - HRESULT __stdcall AddPlace(IShellItem* psi, FDAP fdap) override; - - HRESULT __stdcall SetDefaultExtension(LPCWSTR pszDefaultExtension) override; - - HRESULT __stdcall Close(HRESULT hr) override; - - HRESULT __stdcall SetClientGuid(REFGUID guid) override; - - HRESULT __stdcall ClearClientData(void) override; - - HRESULT __stdcall SetFilter(IShellItemFilter* pFilter) override; - - - // Ereditato tramite IFileDialog2 - HRESULT __stdcall SetCancelButtonLabel(LPCWSTR pszLabel) override; - - HRESULT __stdcall SetNavigationRoot(IShellItem* psi) override; - - - // Ereditato tramite IFileDialogPrivate - HRESULT __stdcall HideControlsForHostedPickerProviderApp(void) override; - - HRESULT __stdcall EnableControlsForHostedPickerProviderApp(void) override; - - HRESULT __stdcall GetPrivateOptions(unsigned long*) override; - - HRESULT __stdcall SetPrivateOptions(unsigned long) override; - - HRESULT __stdcall SetPersistenceKey(unsigned short const*) override; - - HRESULT __stdcall HasPlaces(void) override; - - HRESULT __stdcall EnumPlaces(int, _GUID const&, void**) override; - - HRESULT __stdcall EnumControls(void**) override; - - HRESULT __stdcall GetPersistRegkey(unsigned short**) override; - - HRESULT __stdcall GetSavePropertyStore(IPropertyStore**, IPropertyDescriptionList**) override; - - HRESULT __stdcall GetSaveExtension(unsigned short**) override; - - HRESULT __stdcall GetFileTypeControl(void**) override; - - HRESULT __stdcall GetFileNameControl(void**) override; - - HRESULT __stdcall GetFileProtectionControl(void**) override; - - HRESULT __stdcall SetFolderPrivate(IShellItem*, int) override; - - HRESULT __stdcall SetCustomControlAreaHeight(unsigned int) override; - - HRESULT __stdcall GetDialogState(unsigned long, unsigned long*) override; - - HRESULT __stdcall SetAppControlsModule(void*) override; - - HRESULT __stdcall SetUserEditedSaveProperties(void) override; - - HRESULT __stdcall ShouldShowStandardNavigationRoots(void) override; - - HRESULT __stdcall GetNavigationRoot(_GUID const&, void**) override; - - HRESULT __stdcall ShouldShowFileProtectionControl(int*) override; - - HRESULT __stdcall GetCurrentDialogView(_GUID const&, void**) override; - - HRESULT __stdcall SetSaveDialogEditBoxTextAndFileType(int, unsigned short const*) override; - - HRESULT __stdcall MoveFocusFromBrowser(int) override; - - HRESULT __stdcall EnableOkButton(int) override; - - HRESULT __stdcall InitEnterpriseId(unsigned short const*) override; - - HRESULT __stdcall AdviseFirst(IFileDialogEvents*, unsigned long*) override; - - HRESULT __stdcall HandleTab(void) override; - - - // Ereditato tramite IFileSaveDialog - HRESULT __stdcall SetSaveAsItem(IShellItem* psi) override; - - HRESULT __stdcall SetProperties(IPropertyStore* pStore) override; - - HRESULT __stdcall SetCollectedProperties(IPropertyDescriptionList* pList, BOOL fAppendDefault) override; - - HRESULT __stdcall GetProperties(IPropertyStore** ppStore) override; - - HRESULT __stdcall ApplyProperties(IShellItem* psi, IPropertyStore* pStore, HWND hwnd, IFileOperationProgressSink* pSink) override; - - - // Ereditato tramite IOleWindow - virtual HRESULT __stdcall GetWindow(HWND* phwnd) override; - - virtual HRESULT __stdcall ContextSensitiveHelp(BOOL fEnterMode) override; - -}; - -OBJECT_ENTRY_AUTO(__uuidof(FilesSaveDialog), CFilesSaveDialog) diff --git a/src/Files.App.SaveDialog/FilesSaveDialog.rgs b/src/Files.App.SaveDialog/FilesSaveDialog.rgs deleted file mode 100644 index fc0a4b6e4351..000000000000 --- a/src/Files.App.SaveDialog/FilesSaveDialog.rgs +++ /dev/null @@ -1,16 +0,0 @@ -HKCR -{ - NoRemove CLSID - { - ForceRemove {C0B4E2F3-BA21-4773-8DBA-335EC946EB8B} = s 'FilesSaveDialog class' - { - ForceRemove Programmable - InprocServer32 = s '%MODULE%' - { - val ThreadingModel = s 'Apartment' - } - TypeLib = s '{21533617-c1cd-4d33-a190-21fb069b55f4}' - Version = s '1.0' - } - } -} diff --git a/src/Files.App.SaveDialog/UndefInterfaces.h b/src/Files.App.SaveDialog/UndefInterfaces.h deleted file mode 100644 index 75dba8b174cd..000000000000 --- a/src/Files.App.SaveDialog/UndefInterfaces.h +++ /dev/null @@ -1,89 +0,0 @@ -// UndefInterfaces.h: undocumented interfaces declarations & helpers - -#pragma once - - -#include "framework.h" -#include "shobjidl.h" - - -using namespace ATL; - - -#ifdef DEBUGLOG - -#define CUSTOM_BEGIN_COM_MAP(x) public: \ - typedef x _ComMapClass; \ - static HRESULT WINAPI _Cache(_In_ void* pv, _In_ REFIID iid, _COM_Outptr_result_maybenull_ void** ppvObject, _In_ DWORD_PTR dw) throw()\ - {\ - _ComMapClass* p = (_ComMapClass*)pv;\ - p->Lock();\ - HRESULT hRes = E_FAIL; \ - __try \ - { \ - hRes = ATL::CComObjectRootBase::_Cache(pv, iid, ppvObject, dw);\ - } \ - __finally \ - { \ - p->Unlock();\ - } \ - return hRes;\ - }\ - IUnknown* _GetRawUnknown() throw() \ - { ATLASSERT(_GetEntries()[0].pFunc == _ATL_SIMPLEMAPENTRY); return (IUnknown*)((INT_PTR)this+_GetEntries()->dw); } \ - _ATL_DECLARE_GET_UNKNOWN(x)\ - HRESULT _InternalQueryInterface( \ - _In_ REFIID iid, \ - _COM_Outptr_ void** ppvObject) throw() \ - { \ - HRESULT res = this->InternalQueryInterface(this, _GetEntries(), iid, ppvObject); \ - OLECHAR* guidString; \ - (void)StringFromCLSID(iid, &guidString); \ - std::wcout << L"QueryInterface: " << guidString << L" = " << res << std::endl; \ - ::CoTaskMemFree(guidString); \ - return res; \ - } \ - const static ATL::_ATL_INTMAP_ENTRY* WINAPI _GetEntries() throw() { \ - static const ATL::_ATL_INTMAP_ENTRY _entries[] = { DEBUG_QI_ENTRY(x) - -#else - -#define CUSTOM_BEGIN_COM_MAP(x) BEGIN_COM_MAP(x) - -#endif // DEBUGLOG - - -MIDL_INTERFACE("9EA5491C-89C8-4BEF-93D3-7F665FB82A33") -IFileDialogPrivate : public IUnknown -{ -public: - virtual HRESULT STDMETHODCALLTYPE HideControlsForHostedPickerProviderApp(void) = 0; - virtual HRESULT STDMETHODCALLTYPE EnableControlsForHostedPickerProviderApp(void) = 0; - virtual HRESULT STDMETHODCALLTYPE GetPrivateOptions(unsigned long*) = 0; - virtual HRESULT STDMETHODCALLTYPE SetPrivateOptions(unsigned long) = 0; - virtual HRESULT STDMETHODCALLTYPE SetPersistenceKey(unsigned short const*) = 0; - virtual HRESULT STDMETHODCALLTYPE HasPlaces(void) = 0; - virtual HRESULT STDMETHODCALLTYPE EnumPlaces(int, _GUID const&, void**) = 0;//tagFDPEPLACES - virtual HRESULT STDMETHODCALLTYPE EnumControls(void**) = 0;//IEnumAppControl - virtual HRESULT STDMETHODCALLTYPE GetPersistRegkey(unsigned short**) = 0; - virtual HRESULT STDMETHODCALLTYPE GetSavePropertyStore(IPropertyStore**, IPropertyDescriptionList**) = 0; - virtual HRESULT STDMETHODCALLTYPE GetSaveExtension(unsigned short**) = 0; - virtual HRESULT STDMETHODCALLTYPE GetFileTypeControl(void**) = 0;//IAppControl - virtual HRESULT STDMETHODCALLTYPE GetFileNameControl(void**) = 0;//IAppControl - virtual HRESULT STDMETHODCALLTYPE GetFileProtectionControl(void**) = 0;//IAppControl - virtual HRESULT STDMETHODCALLTYPE SetFolderPrivate(IShellItem*, int) = 0; - virtual HRESULT STDMETHODCALLTYPE SetCustomControlAreaHeight(unsigned int) = 0; - virtual HRESULT STDMETHODCALLTYPE GetDialogState(unsigned long, unsigned long*) = 0; - virtual HRESULT STDMETHODCALLTYPE SetAppControlsModule(void*) = 0;//IAppControlsModule - virtual HRESULT STDMETHODCALLTYPE SetUserEditedSaveProperties(void) = 0; - virtual HRESULT STDMETHODCALLTYPE ShouldShowStandardNavigationRoots(void) = 0; - virtual HRESULT STDMETHODCALLTYPE GetNavigationRoot(_GUID const&, void**) = 0; - virtual HRESULT STDMETHODCALLTYPE ShouldShowFileProtectionControl(int*) = 0; - virtual HRESULT STDMETHODCALLTYPE GetCurrentDialogView(_GUID const&, void**) = 0; - virtual HRESULT STDMETHODCALLTYPE SetSaveDialogEditBoxTextAndFileType(int, unsigned short const*) = 0; - virtual HRESULT STDMETHODCALLTYPE MoveFocusFromBrowser(int) = 0; - virtual HRESULT STDMETHODCALLTYPE EnableOkButton(int) = 0; - virtual HRESULT STDMETHODCALLTYPE InitEnterpriseId(unsigned short const*) = 0; - virtual HRESULT STDMETHODCALLTYPE AdviseFirst(IFileDialogEvents*, unsigned long*) = 0; - virtual HRESULT STDMETHODCALLTYPE HandleTab(void) = 0; -}; diff --git a/src/Files.App.SaveDialog/dllmain.cpp b/src/Files.App.SaveDialog/dllmain.cpp deleted file mode 100644 index e3b584168b34..000000000000 --- a/src/Files.App.SaveDialog/dllmain.cpp +++ /dev/null @@ -1,16 +0,0 @@ -// dllmain.cpp: implementazione di DllMain. - -#include "pch.h" -#include "framework.h" -#include "resource.h" -#include "CustomSaveDialog_i.h" -#include "dllmain.h" - -CCustomSaveDialogModule _AtlModule; - -// Punto di ingresso DLL -extern "C" BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved) -{ - hInstance; - return _AtlModule.DllMain(dwReason, lpReserved); -} diff --git a/src/Files.App.SaveDialog/dllmain.h b/src/Files.App.SaveDialog/dllmain.h deleted file mode 100644 index 284a990fe6d1..000000000000 --- a/src/Files.App.SaveDialog/dllmain.h +++ /dev/null @@ -1,10 +0,0 @@ -// dllmain.h: dichiarazione della classe del modulo. - -class CCustomSaveDialogModule : public ATL::CAtlDllModuleT< CCustomSaveDialogModule > -{ -public : - DECLARE_LIBID(LIBID_CustomSaveDialogLib) - DECLARE_REGISTRY_APPID_RESOURCEID(IDR_CUSTOMSAVEDIALOG, "{21533617-c1cd-4d33-a190-21fb069b55f4}") -}; - -extern class CCustomSaveDialogModule _AtlModule; diff --git a/src/Files.App.SaveDialog/framework.h b/src/Files.App.SaveDialog/framework.h deleted file mode 100644 index 9ac7cffd8ddd..000000000000 --- a/src/Files.App.SaveDialog/framework.h +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once - -#ifndef STRICT -#define STRICT -#endif - -#include "targetver.h" - -#define _ATL_APARTMENT_THREADED - -#define _ATL_NO_AUTOMATIC_NAMESPACE - -#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // alcuni costruttori CString saranno espliciti - - -#define ATL_NO_ASSERT_ON_DESTROY_NONEXISTENT_WINDOW - -#include "resource.h" -#include -#include -#include diff --git a/src/Files.App.SaveDialog/pch.cpp b/src/Files.App.SaveDialog/pch.cpp deleted file mode 100644 index 69046d3e1dc0..000000000000 --- a/src/Files.App.SaveDialog/pch.cpp +++ /dev/null @@ -1,5 +0,0 @@ -// pch.cpp: file di origine corrispondente all'intestazione precompilata - -#include "pch.h" - -// Quando si usano intestazioni precompilate, questo file è necessario per la riuscita della compilazione. diff --git a/src/Files.App.SaveDialog/pch.h b/src/Files.App.SaveDialog/pch.h deleted file mode 100644 index aa5d1c5a0950..000000000000 --- a/src/Files.App.SaveDialog/pch.h +++ /dev/null @@ -1,13 +0,0 @@ -// pch.h: questo è un file di intestazione precompilata. -// I file elencati di seguito vengono compilati una sola volta, in modo da migliorare le prestazioni per le compilazioni successive. -// Questa impostazione influisce anche sulle prestazioni di IntelliSense, incluso il completamento codice e molte altre funzionalità di esplorazione del codice. -// I file elencati qui vengono però TUTTI ricompilati se uno di essi viene aggiornato da una compilazione all'altra. -// Non aggiungere qui file soggetti a frequenti aggiornamenti; in caso contrario si perderanno i vantaggi offerti in termini di prestazioni. - -#ifndef PCH_H -#define PCH_H - -// aggiungere qui le intestazioni da precompilare -#include "framework.h" - -#endif //PCH_H diff --git a/src/Files.App.SaveDialog/resource.h b/src/Files.App.SaveDialog/resource.h deleted file mode 100644 index fbb30dbffe4e..000000000000 --- a/src/Files.App.SaveDialog/resource.h +++ /dev/null @@ -1,18 +0,0 @@ -//{{NO_DEPENDENCIES}} -// File di inclusione generato con Microsoft Visual C++. -// Utilizzato da CustomSaveDialog.rc -// -#define IDS_PROJNAME 100 -#define IDR_CUSTOMSAVEDIALOG 101 -#define IDR_FILESSAVEDIALOG 106 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 201 -#define _APS_NEXT_COMMAND_VALUE 32768 -#define _APS_NEXT_CONTROL_VALUE 201 -#define _APS_NEXT_SYMED_VALUE 107 -#endif -#endif diff --git a/src/Files.App.SaveDialog/targetver.h b/src/Files.App.SaveDialog/targetver.h deleted file mode 100644 index 7672c2eee3bc..000000000000 --- a/src/Files.App.SaveDialog/targetver.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once - -// L'inclusione di SDKDDKVer.h definisce la piattaforma Windows più recente disponibile. - -// Se si desidera compilare l'applicazione per una piattaforma Windows precedente, includere WinSDKVer.h e -// impostare la macro _WIN32_WINNT sulla piattaforma da supportare prima di includere SDKDDKVer.h. - -#include diff --git a/src/Files.App.Server/AppInstanceMonitor.cs b/src/Files.App.Server/AppInstanceMonitor.cs deleted file mode 100644 index 5dd99bbec054..000000000000 --- a/src/Files.App.Server/AppInstanceMonitor.cs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) Files Community -// SPDX-License-Identifier: MPL-2.0 - -using System.Diagnostics; - -namespace Files.App.Server; - -public sealed class AppInstanceMonitor -{ - private static int processCount = 0; - - public static void StartMonitor(int processId) - { - var process = Process.GetProcessById(processId); - Interlocked.Increment(ref processCount); - process.EnableRaisingEvents = true; - process.Exited += Process_Exited; - } - - private static void Process_Exited(object? sender, EventArgs e) - { - if (sender is Process process) - { - process.Dispose(); - - if (Interlocked.Decrement(ref processCount) == 0) - { - Program.ExitSignal.TrySetResult(true); - } - } - } -} diff --git a/src/Files.App.Server/Files.App.Server.csproj b/src/Files.App.Server/Files.App.Server.csproj deleted file mode 100644 index 72378d41495a..000000000000 --- a/src/Files.App.Server/Files.App.Server.csproj +++ /dev/null @@ -1,51 +0,0 @@ - - - - - WinExe - en-US - Scale|DXFeatureLevel - Language=en-US;af;ar;be-BY;bg;ca;cs-CZ;da;de-DE;el;en-GB;es-ES;es-419;fa-IR;fi-FI;fil-PH;fr-FR;he-IL;hi-IN;hr-HR;hu-HU;hy-AM;id-ID;it-IT;ja-JP;ka;km-KH;ko-KR;lt-LT;lv-LV;ms-MY;nb-NO;nl-NL;pl-PL;pt-BR;pt-PT;ro-RO;ru-RU;sk-SK;sq-AL;sr-Cyrl;sv-SE;ta;th-TH;tr-TR;uk-UA;vi;zh-Hans;zh-Hant - $(WindowsTargetFramework) - $(MinimalWindowsVersion) - enable - enable - Debug;Release - x86;x64;arm64 - win-x86;win-x64;win-arm64 - win-x86 - win-x64 - win-arm64 - true - true - $(TargetWindowsVersion) - app.manifest - False - True - True - False - True - true - true - true - - - - - - - - - - - PreserveNewest - Files.App.Server.winmd - false - - - - - - - - diff --git a/src/Files.App.Server/Helpers.cs b/src/Files.App.Server/Helpers.cs deleted file mode 100644 index 86f58f9e04bb..000000000000 --- a/src/Files.App.Server/Helpers.cs +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (c) Files Community -// Licensed under the MIT License. - -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using Windows.Win32.Foundation; -using Windows.Win32.System.WinRT; -using WinRT; - -namespace Files.App.Server; - -unsafe partial class Helpers -{ - [UnmanagedCallersOnly(CallConvs = [typeof(CallConvStdcall)])] - public static HRESULT GetActivationFactory(HSTRING activatableClassId, IActivationFactory_unmanaged** factory) - { - if (activatableClassId.IsNull || factory is null) - { - return HRESULT.E_INVALIDARG; - } - - try - { - *factory = (IActivationFactory_unmanaged*)Module.GetActivationFactory(MarshalString.FromAbi((IntPtr)activatableClassId)); - return *factory is null ? HRESULT.CLASS_E_CLASSNOTAVAILABLE : HRESULT.S_OK; - } - catch (Exception e) - { - ExceptionHelpers.SetErrorInfo(e); - return (HRESULT)ExceptionHelpers.GetHRForException(e); - } - } -} diff --git a/src/Files.App.Server/Program.cs b/src/Files.App.Server/Program.cs deleted file mode 100644 index fe06dfc4867e..000000000000 --- a/src/Files.App.Server/Program.cs +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright (c) Files Community -// Licensed under the MIT License. - -using System.Runtime.ExceptionServices; -using System.Runtime.InteropServices; -using Windows.Storage; -using Windows.Win32; -using Windows.Win32.Foundation; -using Windows.Win32.System.WinRT; - -namespace Files.App.Server; - -class Program -{ - internal static readonly TaskCompletionSource ExitSignal = new(TaskCreationOptions.RunContinuationsAsynchronously); - private static readonly CancellationTokenSource cancellationTokenSource = new(); - private static readonly StreamWriter logWriter = new(Path.Combine(ApplicationData.Current.LocalFolder.Path, "debug_server.log"), append: true) { AutoFlush = true }; - - static Type[] GetActivatableTypes() => [typeof(AppInstanceMonitor)]; - - static async Task Main() - { - AppDomain.CurrentDomain.FirstChanceException += OnFirstChanceException; - - RO_REGISTRATION_COOKIE cookie = default; - - _ = PInvoke.RoInitialize(RO_INIT_TYPE.RO_INIT_MULTITHREADED); - - var classIds = GetActivatableTypes() - .Select(t => - { - var name = t.FullName!; - if (PInvoke.WindowsCreateString(name, (uint)name.Length, out var classId) is HRESULT hr && hr.Value is not 0) - { - Marshal.ThrowExceptionForHR(hr); - } - - return new HSTRING(classId.DangerousGetHandle()); - }) - .ToArray(); - - unsafe - { - delegate* unmanaged[Stdcall][] callbacks = new delegate* unmanaged[Stdcall][classIds.Length]; - for (int i = 0; i < callbacks.Length; i++) - { - callbacks[i] = &Helpers.GetActivationFactory; - } - - fixed (delegate* unmanaged[Stdcall]* pCallbacks = callbacks) - { - if (PInvoke.RoRegisterActivationFactories(classIds, pCallbacks, out cookie) is HRESULT hr && hr.Value != 0) - { - Marshal.ThrowExceptionForHR(hr); - } - } - } - - foreach (var str in classIds) - { - _ = PInvoke.WindowsDeleteString(str); - } - - AppDomain.CurrentDomain.ProcessExit += (_, _) => cancellationTokenSource.Cancel(); - - try - { - await ExitSignal.Task.WaitAsync(cancellationTokenSource.Token); - } - catch (OperationCanceledException) - { - return; - } - finally - { - if (cookie != 0) - { - PInvoke.RoRevokeActivationFactories(cookie); - } - } - } - - private static void OnFirstChanceException(object? sender, FirstChanceExceptionEventArgs e) - { - logWriter.WriteLine($"{DateTime.Now}|{e.Exception}"); - } -} diff --git a/src/Files.App.Server/Properties/PublishProfiles/win-arm64.pubxml b/src/Files.App.Server/Properties/PublishProfiles/win-arm64.pubxml deleted file mode 100644 index b83d7b610734..000000000000 --- a/src/Files.App.Server/Properties/PublishProfiles/win-arm64.pubxml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - FileSystem - arm64 - win-arm64 - true - true - - \ No newline at end of file diff --git a/src/Files.App.Server/Properties/PublishProfiles/win-x64.pubxml b/src/Files.App.Server/Properties/PublishProfiles/win-x64.pubxml deleted file mode 100644 index 9a4f8958bb62..000000000000 --- a/src/Files.App.Server/Properties/PublishProfiles/win-x64.pubxml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - FileSystem - x64 - win-x64 - true - true - - \ No newline at end of file diff --git a/src/Files.App.Server/Properties/PublishProfiles/win-x86.pubxml b/src/Files.App.Server/Properties/PublishProfiles/win-x86.pubxml deleted file mode 100644 index e5a15fee76ce..000000000000 --- a/src/Files.App.Server/Properties/PublishProfiles/win-x86.pubxml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - FileSystem - x86 - win-x86 - true - true - - \ No newline at end of file diff --git a/src/Files.App.Server/app.manifest b/src/Files.App.Server/app.manifest deleted file mode 100644 index a33d575914a8..000000000000 --- a/src/Files.App.Server/app.manifest +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - true/PM - PerMonitorV2, PerMonitor - - - - diff --git a/src/Files.App/Files.App.csproj b/src/Files.App/Files.App.csproj index 0693d885df30..a2ac71e96b40 100644 --- a/src/Files.App/Files.App.csproj +++ b/src/Files.App/Files.App.csproj @@ -24,7 +24,6 @@ true - Properties\PublishProfiles\win-$(Platform).pubxml WinExe Scale|DXFeatureLevel Language=en-US;af;ar;be-BY;bg;ca;cs-CZ;da;de-DE;el;en-GB;es-ES;es-419;fa-IR;fi-FI;fil-PH;fr-FR;he-IL;hi-IN;hr-HR;hu-HU;hy-AM;id-ID;it-IT;ja-JP;ka;km-KH;ko-KR;lt-LT;lv-LV;ms-MY;nb-NO;nl-NL;pl-PL;pt-BR;pt-PT;ro-RO;ru-RU;sk-SK;sq-AL;sr-Cyrl;sv-SE;ta;th-TH;tr-TR;uk-UA;vi;zh-Hans;zh-Hant @@ -42,7 +41,7 @@ true true false - Files.App.Server;Microsoft.UI.Content.ContentExternalOutputLink;Microsoft.UI.Content.IContentExternalOutputLink + Microsoft.UI.Content.ContentExternalOutputLink;Microsoft.UI.Content.IContentExternalOutputLink bin\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\publish\ False True @@ -104,15 +103,6 @@ - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - PreserveNewest @@ -188,18 +178,10 @@ - - - PreserveNewest - Files.App.Server.winmd - false - - - @@ -326,11 +308,4 @@ - - - - diff --git a/src/Files.App/Package.appxmanifest b/src/Files.App/Package.appxmanifest deleted file mode 100644 index 54653e46b095..000000000000 --- a/src/Files.App/Package.appxmanifest +++ /dev/null @@ -1,207 +0,0 @@ - - - - - - - - Files - Dev - Yair A - Assets\AppTiles\Dev\StoreLogo.png - disabled - - - HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\CLSID\{645FF040-5081-101B-9F08-00AA002F954E}\DefaultIcon - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - com.files.filepreview - - - - - - - - - - - - - - - - - - - - - - - - - .zip - .7z - .rar - .tar - .jar - .mrpack - .gz - - assets\archives\ExtensionIcon.png - - - - - - - - - - - - - WinRT.Host.dll - - - - - - Files.App.Server\Files.App.Server.exe - singleInstance - - - - - - - - - - - - - - - - - - - - diff --git a/src/Files.Core.SourceGenerator/Properties/launchSettings.json b/src/Files.Core.SourceGenerator/Properties/launchSettings.json index 2804cd5078a4..af0878faca69 100644 --- a/src/Files.Core.SourceGenerator/Properties/launchSettings.json +++ b/src/Files.Core.SourceGenerator/Properties/launchSettings.json @@ -8,10 +8,6 @@ "commandName": "DebugRoslynComponent", "targetProject": "..\\Files.App.Controls\\Files.App.Controls.csproj" }, - "Files.App.Server": { - "commandName": "DebugRoslynComponent", - "targetProject": "..\\Files.App.Server\\Files.App.Server.csproj" - }, "Files.App": { "commandName": "DebugRoslynComponent", "targetProject": "..\\Files.App\\Files.App.csproj" diff --git a/src/Files.Platform.Windows/Files.Platform.Windows.csproj b/src/Files.Platform.Windows/Files.Platform.Windows.csproj deleted file mode 100644 index ebd2ecd28437..000000000000 --- a/src/Files.Platform.Windows/Files.Platform.Windows.csproj +++ /dev/null @@ -1,24 +0,0 @@ - - - - - $(WindowsTargetFramework) - $(MinimalWindowsVersion) - enable - true - Debug;Release - x86;x64;arm64 - win-x86;win-x64;win-arm64 - true - true - - - - - - - - - - - diff --git a/src/Files.Platform.Windows/PlatformServiceCollectionExtensions.cs b/src/Files.Platform.Windows/PlatformServiceCollectionExtensions.cs deleted file mode 100644 index 8fc7341e9873..000000000000 --- a/src/Files.Platform.Windows/PlatformServiceCollectionExtensions.cs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) Files Community -// Licensed under the MIT License. - -using Files.Platform.Abstractions; -using Microsoft.Extensions.DependencyInjection; - -namespace Files.Platform.Windows -{ - /// - /// Provides extension methods for registering the Windows platform services. - /// - public static class PlatformServiceCollectionExtensions - { - /// - /// Registers the Windows platform services. - /// - public static IServiceCollection AddWindowsPlatform(this IServiceCollection services) - { - return services.AddSingleton(); - } - } -} diff --git a/src/Files.Platform.Windows/WindowsPlatformCapabilities.cs b/src/Files.Platform.Windows/WindowsPlatformCapabilities.cs deleted file mode 100644 index fa71b2b25002..000000000000 --- a/src/Files.Platform.Windows/WindowsPlatformCapabilities.cs +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (c) Files Community -// Licensed under the MIT License. - -using Files.Platform.Abstractions; - -namespace Files.Platform.Windows -{ - /// - /// Describes the features available on Windows. - /// - public sealed class WindowsPlatformCapabilities : IPlatformCapabilities - { - /// - public PlatformKind Kind => PlatformKind.Windows; - - /// - public bool SupportsShellContextMenuExtensions => true; - - /// - public bool SupportsPreviewHandlers => true; - - /// - public bool SupportsLibraries => true; - - /// - public bool SupportsAclSecurity => true; - - /// - public bool SupportsDigitalSignatures => true; - - /// - public bool SupportsCompatibilityProperties => true; - - /// - public bool SupportsJumpLists => true; - - /// - public bool SupportsSystemBackdrop => true; - - /// - public bool SupportsCustomTitleBar => true; - - /// - public bool SupportsTabTearOut => true; - - /// - public bool SupportsWsl => true; - - /// - public bool SupportsDriveFormatting => true; - - /// - public bool SupportsShortcutFiles => true; - } -} diff --git a/tests/Files.App.UITests/App.xaml b/tests/Files.App.UITests/App.xaml deleted file mode 100644 index cb0022c590f9..000000000000 --- a/tests/Files.App.UITests/App.xaml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - - - - - 36,40,0,36 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/Files.App.UITests/App.xaml.cs b/tests/Files.App.UITests/App.xaml.cs deleted file mode 100644 index cb50600c6ba5..000000000000 --- a/tests/Files.App.UITests/App.xaml.cs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) Files Community -// Licensed under the MIT License. - -using Microsoft.UI.Xaml; - -namespace Files.App.UITests -{ - public partial class App : Application - { - public App() - { - InitializeComponent(); - } - - protected override void OnLaunched(LaunchActivatedEventArgs args) - { - MainWindow.Instance.Activate(); - } - } -} diff --git a/tests/Files.App.UITests/Assets/LockScreenLogo.scale-200.png b/tests/Files.App.UITests/Assets/LockScreenLogo.scale-200.png deleted file mode 100644 index 7440f0d4bf7c..000000000000 Binary files a/tests/Files.App.UITests/Assets/LockScreenLogo.scale-200.png and /dev/null differ diff --git a/tests/Files.App.UITests/Assets/SplashScreen.scale-200.png b/tests/Files.App.UITests/Assets/SplashScreen.scale-200.png deleted file mode 100644 index 041faddc656a..000000000000 Binary files a/tests/Files.App.UITests/Assets/SplashScreen.scale-200.png and /dev/null differ diff --git a/tests/Files.App.UITests/Assets/Square150x150Logo.scale-200.png b/tests/Files.App.UITests/Assets/Square150x150Logo.scale-200.png deleted file mode 100644 index 53ee3777ea27..000000000000 Binary files a/tests/Files.App.UITests/Assets/Square150x150Logo.scale-200.png and /dev/null differ diff --git a/tests/Files.App.UITests/Assets/Square44x44Logo.scale-200.png b/tests/Files.App.UITests/Assets/Square44x44Logo.scale-200.png deleted file mode 100644 index f713bba67f55..000000000000 Binary files a/tests/Files.App.UITests/Assets/Square44x44Logo.scale-200.png and /dev/null differ diff --git a/tests/Files.App.UITests/Assets/Square44x44Logo.targetsize-24_altform-unplated.png b/tests/Files.App.UITests/Assets/Square44x44Logo.targetsize-24_altform-unplated.png deleted file mode 100644 index dc9f5bea0c3b..000000000000 Binary files a/tests/Files.App.UITests/Assets/Square44x44Logo.targetsize-24_altform-unplated.png and /dev/null differ diff --git a/tests/Files.App.UITests/Assets/StoreLogo.png b/tests/Files.App.UITests/Assets/StoreLogo.png deleted file mode 100644 index a4586f26bdf7..000000000000 Binary files a/tests/Files.App.UITests/Assets/StoreLogo.png and /dev/null differ diff --git a/tests/Files.App.UITests/Assets/Wide310x150Logo.scale-200.png b/tests/Files.App.UITests/Assets/Wide310x150Logo.scale-200.png deleted file mode 100644 index 65be1c2353c8..000000000000 Binary files a/tests/Files.App.UITests/Assets/Wide310x150Logo.scale-200.png and /dev/null differ diff --git a/tests/Files.App.UITests/Data/BreadcrumbBarItemModel.cs b/tests/Files.App.UITests/Data/BreadcrumbBarItemModel.cs deleted file mode 100644 index f6ecbee88add..000000000000 --- a/tests/Files.App.UITests/Data/BreadcrumbBarItemModel.cs +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright (c) Files Community -// SPDX-License-Identifier: MPL-2.0 - -using System.Collections.ObjectModel; - -namespace Files.App.UITests.Data -{ - internal record BreadcrumbBarItemModel(string Text, ObservableCollection? Children = null); -} diff --git a/tests/Files.App.UITests/Data/DummyIcon1.png b/tests/Files.App.UITests/Data/DummyIcon1.png deleted file mode 100644 index b6121308740e..000000000000 Binary files a/tests/Files.App.UITests/Data/DummyIcon1.png and /dev/null differ diff --git a/tests/Files.App.UITests/Data/OmnibarPaletteSuggestionItem.cs b/tests/Files.App.UITests/Data/OmnibarPaletteSuggestionItem.cs deleted file mode 100644 index f5d2a4d913a0..000000000000 --- a/tests/Files.App.UITests/Data/OmnibarPaletteSuggestionItem.cs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (c) Files Community -// SPDX-License-Identifier: MPL-2.0 - -using Files.App.Controls; -using System; - -namespace Files.App.UITests.Data -{ - public partial record OmnibarPaletteSuggestionItem(string Title, string Description, string HotKeys) - : IOmnibarTextMemberPathProvider - { - /// - public string GetTextMemberPath(string textMemberPath) - { - return textMemberPath switch - { - nameof(Title) => Title, - nameof(Description) => Description, - nameof(HotKeys) => HotKeys, - _ => throw new ArgumentOutOfRangeException(nameof(textMemberPath), textMemberPath, null), - }; - } - } -} diff --git a/tests/Files.App.UITests/Files.App.UITests.csproj b/tests/Files.App.UITests/Files.App.UITests.csproj deleted file mode 100644 index dbdc7bc326db..000000000000 --- a/tests/Files.App.UITests/Files.App.UITests.csproj +++ /dev/null @@ -1,40 +0,0 @@ - - - - - WinExe - $(WindowsTargetFramework) - $(MinimalWindowsVersion) - win-$(Platform).pubxml - true - true - app.manifest - enable - true - Debug;Release - x86;x64;arm64 - win-x86;win-x64;win-arm64 - - - - - - - - - - - - - - - - - - - - - true - - - diff --git a/tests/Files.App.UITests/MainWindow.xaml b/tests/Files.App.UITests/MainWindow.xaml deleted file mode 100644 index 0d4f9d61d21e..000000000000 --- a/tests/Files.App.UITests/MainWindow.xaml +++ /dev/null @@ -1,110 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/Files.App.UITests/MainWindow.xaml.cs b/tests/Files.App.UITests/MainWindow.xaml.cs deleted file mode 100644 index 1201a0915d61..000000000000 --- a/tests/Files.App.UITests/MainWindow.xaml.cs +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright (c) Files Community -// Licensed under the MIT License. - -using Files.App.UITests.Views; -using Microsoft.UI.Xaml; -using Microsoft.UI.Xaml.Controls; -using Microsoft.UI.Xaml.Controls.Primitives; -using System; -using WinRT; - -namespace Files.App.UITests -{ - public sealed partial class MainWindow : Window - { - private static MainWindow? _Instance; - public static MainWindow Instance => _Instance ??= new(); - - [DynamicWindowsRuntimeCast(typeof(FrameworkElement))] - private MainWindow() - { - InitializeComponent(); - - ExtendsContentIntoTitleBar = true; - MainFrame.Navigate(typeof(MainPage)); - - // Set the toggle state for theme change button - if (Content is FrameworkElement element) - { - if (element.ActualTheme is ElementTheme.Light) - { - AppThemeChangeToggleButton.IsChecked = true; - AppThemeGlyph.Glyph = "\uE706"; // Sun - } - else - { - AppThemeChangeToggleButton.IsChecked = false; - AppThemeGlyph.Glyph = "\uE708"; // Moon - } - } - } - - [DynamicWindowsRuntimeCast(typeof(NavigationViewItem))] - private void NavigationView_SelectionChanged(NavigationView sender, NavigationViewSelectionChangedEventArgs args) - { - if (args.SelectedItem is not NavigationViewItem item || item.Tag is not string tag) - return; - - MainFrame.Navigate( - tag switch - { - nameof(ThemedIconPage) => typeof(ThemedIconPage), - nameof(ToolbarPage) => typeof(ToolbarPage), - nameof(ThemedIconGalleryPage) => typeof(ThemedIconGalleryPage), - nameof(StorageControlsPage) => typeof(StorageControlsPage), - nameof(SidebarViewPage) => typeof(SidebarViewPage), - nameof(OmnibarPage) => typeof(OmnibarPage), - nameof(BreadcrumbBarPage) => typeof(BreadcrumbBarPage), - _ => throw new InvalidOperationException("There's no applicable page associated with the given key."), - }); - - MainNavigationView.Header = item.Content.ToString(); - } - - [DynamicWindowsRuntimeCast(typeof(ToggleButton))] - [DynamicWindowsRuntimeCast(typeof(FrameworkElement))] - private void AppThemeChangeToggleButton_Click(object sender, RoutedEventArgs e) - { - if (sender is not ToggleButton toggleButton || - Content is not FrameworkElement element) - return; - - if (toggleButton.IsChecked is true) - { - element.RequestedTheme = ElementTheme.Light; - AppThemeGlyph.Glyph = "\uE706"; // Sun - } - else - { - element.RequestedTheme = ElementTheme.Dark; - AppThemeGlyph.Glyph = "\uE708"; // Moon - } - } - } -} diff --git a/tests/Files.App.UITests/Package.appxmanifest b/tests/Files.App.UITests/Package.appxmanifest deleted file mode 100644 index 9fdc7726ad6a..000000000000 --- a/tests/Files.App.UITests/Package.appxmanifest +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - Files UI tests app - Files - Assets\StoreLogo.png - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/Files.App.UITests/Properties/PublishProfiles/win-arm64.pubxml b/tests/Files.App.UITests/Properties/PublishProfiles/win-arm64.pubxml deleted file mode 100644 index 06da89e11fb6..000000000000 --- a/tests/Files.App.UITests/Properties/PublishProfiles/win-arm64.pubxml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - FileSystem - ARM64 - win-arm64 - win10-arm64 - bin\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\publish\ - true - False - False - True - False - True - - \ No newline at end of file diff --git a/tests/Files.App.UITests/Properties/PublishProfiles/win-x64.pubxml b/tests/Files.App.UITests/Properties/PublishProfiles/win-x64.pubxml deleted file mode 100644 index 3568f8d8ddc9..000000000000 --- a/tests/Files.App.UITests/Properties/PublishProfiles/win-x64.pubxml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - FileSystem - x64 - win-x64 - win10-x64 - bin\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\publish\ - true - False - False - True - False - True - - \ No newline at end of file diff --git a/tests/Files.App.UITests/Properties/PublishProfiles/win-x86.pubxml b/tests/Files.App.UITests/Properties/PublishProfiles/win-x86.pubxml deleted file mode 100644 index 4ed30a5eed4f..000000000000 --- a/tests/Files.App.UITests/Properties/PublishProfiles/win-x86.pubxml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - FileSystem - x86 - win-x86 - win10-x86 - bin\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\publish\ - true - False - False - True - False - True - - \ No newline at end of file diff --git a/tests/Files.App.UITests/Properties/launchSettings.json b/tests/Files.App.UITests/Properties/launchSettings.json deleted file mode 100644 index 339d01721d10..000000000000 --- a/tests/Files.App.UITests/Properties/launchSettings.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "profiles": { - "Files.App.UITests (Package)": { - "commandName": "MsixPackage" - }, - "Files.App.UITests (Unpackaged)": { - "commandName": "Project" - } - } -} \ No newline at end of file diff --git a/tests/Files.App.UITests/Views/BreadcrumbBarPage.xaml b/tests/Files.App.UITests/Views/BreadcrumbBarPage.xaml deleted file mode 100644 index 81fda946d9c0..000000000000 --- a/tests/Files.App.UITests/Views/BreadcrumbBarPage.xaml +++ /dev/null @@ -1,75 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/Files.App.UITests/Views/BreadcrumbBarPage.xaml.cs b/tests/Files.App.UITests/Views/BreadcrumbBarPage.xaml.cs deleted file mode 100644 index d447c5d1dee4..000000000000 --- a/tests/Files.App.UITests/Views/BreadcrumbBarPage.xaml.cs +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright (c) Files Community -// SPDX-License-Identifier: MPL-2.0 - -using CommunityToolkit.WinUI; -using Files.App.Controls; -using Files.App.UITests.Data; -using Microsoft.UI.Xaml; -using Microsoft.UI.Xaml.Controls; -using System.Collections.ObjectModel; - -namespace Files.App.UITests.Views -{ - public sealed partial class BreadcrumbBarPage : Page - { - private readonly ObservableCollection DummyItems; - - [GeneratedDependencyProperty] - private partial string? ClickedItemName { get; set; } - - [GeneratedDependencyProperty] - private partial string? ClickedItemIndex { get; set; } - - [GeneratedDependencyProperty] - private partial bool IsRTLEnabled { get; set; } - - [GeneratedDependencyProperty] - private partial FlowDirection BreadcrumbBar1FlowDirection { get; set; } - - public BreadcrumbBarPage() - { - InitializeComponent(); - - DummyItems = - [ - new("Local Disk (C:)"), - new("Users"), - new("me"), - new("OneDrive"), - new("Desktop"), - new("Folder1"), - new("Folder2"), - ]; - } - - private void BreadcrumbBar1_ItemClicked(Controls.BreadcrumbBar sender, Controls.BreadcrumbBarItemClickedEventArgs args) - { - if (args.IsRootItem) - { - ClickedItemName = "Home"; - ClickedItemIndex = "Root"; - } - else - { - ClickedItemName = DummyItems[args.Index].Text; - ClickedItemIndex = $"{args.Index}"; - } - } - - private void BreadcrumbBar1_ItemDropDownFlyoutOpening(object sender, BreadcrumbBarItemDropDownFlyoutEventArgs e) - { - e.Flyout.Items.Add(new MenuFlyoutItem { Icon = new FontIcon() { Glyph = "\uE8B7" }, Text = "Item 1" }); - e.Flyout.Items.Add(new MenuFlyoutItem { Icon = new FontIcon() { Glyph = "\uE8B7" }, Text = "Item 2" }); - e.Flyout.Items.Add(new MenuFlyoutItem { Icon = new FontIcon() { Glyph = "\uE8B7" }, Text = "Item 3" }); - } - - private void BreadcrumbBar1_ItemDropDownFlyoutClosed(object sender, BreadcrumbBarItemDropDownFlyoutEventArgs e) - { - e.Flyout.Items.Clear(); - } - - partial void OnIsRTLEnabledChanged(bool newValue) - { - BreadcrumbBar1FlowDirection = IsRTLEnabled ? FlowDirection.RightToLeft : FlowDirection.LeftToRight; - } - } -} diff --git a/tests/Files.App.UITests/Views/MainPage.xaml b/tests/Files.App.UITests/Views/MainPage.xaml deleted file mode 100644 index 44b76623d425..000000000000 --- a/tests/Files.App.UITests/Views/MainPage.xaml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - diff --git a/tests/Files.App.UITests/Views/MainPage.xaml.cs b/tests/Files.App.UITests/Views/MainPage.xaml.cs deleted file mode 100644 index ca9b51c8b97d..000000000000 --- a/tests/Files.App.UITests/Views/MainPage.xaml.cs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) Files Community -// Licensed under the MIT License. - -using Microsoft.UI.Xaml.Controls; - -namespace Files.App.UITests.Views -{ - public sealed partial class MainPage : Page - { - public MainPage() - { - InitializeComponent(); - } - } -} diff --git a/tests/Files.App.UITests/Views/OmnibarPage.xaml b/tests/Files.App.UITests/Views/OmnibarPage.xaml deleted file mode 100644 index 1e3bae3bd0f7..000000000000 --- a/tests/Files.App.UITests/Views/OmnibarPage.xaml +++ /dev/null @@ -1,148 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/Files.App.UITests/Views/OmnibarPage.xaml.cs b/tests/Files.App.UITests/Views/OmnibarPage.xaml.cs deleted file mode 100644 index 24d4ea48c033..000000000000 --- a/tests/Files.App.UITests/Views/OmnibarPage.xaml.cs +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright (c) Files Community -// SPDX-License-Identifier: MPL-2.0 - -using CommunityToolkit.WinUI; -using Files.App.Controls; -using Files.App.UITests.Data; -using Microsoft.UI.Xaml.Controls; -using System.Collections.ObjectModel; - -namespace Files.App.UITests.Views -{ - public sealed partial class OmnibarPage : Page - { - private readonly string Omnibar1_TextMemberPathForPaletteMode = nameof(OmnibarPaletteSuggestionItem.Title); - - private readonly ObservableCollection Omnibar1_PaletteSuggestions; - private readonly ObservableCollection Omnibar1_BreadcrumbBarItems; - - [GeneratedDependencyProperty(DefaultValue = "")] - private partial string Omnibar1_Text { get; set; } - - [GeneratedDependencyProperty(DefaultValue = "")] - private partial string Omnibar1_TextChangedReason { get; set; } - - [GeneratedDependencyProperty] - private partial int Omnibar1_ChosenSuggestionIndex { get; set; } - - [GeneratedDependencyProperty(DefaultValue = "")] - private partial string Omnibar1_SubmittedQuery { get; set; } - - public OmnibarPage() - { - InitializeComponent(); - - Omnibar1_PaletteSuggestions = - [ - new("Open online help page in browser", "Open online help page in browser", "Control + H"), - new("Toggle full screen", "Toggle full screen", "Control + H"), - new("Enter compact overlay", "Enter compact overlay", "Control + H"), - new("Toggle compact overlay", "Toggle compact overlay", "Control + H"), - new("Go to search box", "Go to search box", "Control + H"), - new("Focus path bar", "Focus path bar", "Control + H"), - new("Redo the last file operation", "Redo the last file operation", "Control + H"), - new("Undo the last file operation", "Undo the last file operation", "Control + H"), - new("Toggle whether to show hidden items", "Toggle whether to show hidden items", "Control + H"), - ]; - - Omnibar1_BreadcrumbBarItems = - [ - new("Local Disk (C:)"), - new("Users"), - new("me"), - new("OneDrive"), - new("Desktop"), - new("Folder1"), - new("Folder2"), - ]; - } - - private void Omnibar1_BreadcrumbBar_ItemDropDownFlyoutOpening(object sender, BreadcrumbBarItemDropDownFlyoutEventArgs e) - { - e.Flyout.Items.Add(new MenuFlyoutItem { Icon = new FontIcon() { Glyph = "\uE8B7" }, Text = "Item 1" }); - e.Flyout.Items.Add(new MenuFlyoutItem { Icon = new FontIcon() { Glyph = "\uE8B7" }, Text = "Item 2" }); - e.Flyout.Items.Add(new MenuFlyoutItem { Icon = new FontIcon() { Glyph = "\uE8B7" }, Text = "Item 3" }); - } - - private void Omnibar1_BreadcrumbBar_ItemDropDownFlyoutClosed(object sender, BreadcrumbBarItemDropDownFlyoutEventArgs e) - { - e.Flyout.Items.Clear(); - } - - private void Omnibar1_QuerySubmitted(Omnibar sender, OmnibarQuerySubmittedEventArgs args) - { - Omnibar1_ChosenSuggestionIndex = args.Item is OmnibarPaletteSuggestionItem item ? Omnibar1_PaletteSuggestions.IndexOf(item) : -1; - Omnibar1_SubmittedQuery = args.Mode.Text ?? string.Empty; - } - - private void Omnibar1_TextChanged(Omnibar sender, OmnibarTextChangedEventArgs args) - { - if (args.Reason is not OmnibarTextChangeReason.SuggestionChosen) - Omnibar1_ChosenSuggestionIndex = -1; - - Omnibar1_Text = args.Mode.Text ?? string.Empty; - Omnibar1_TextChangedReason = args.Reason.ToString(); - } - - private void Omnibar1_SuggestionChosen(Omnibar sender, OmnibarSuggestionChosenEventArgs args) - { - Omnibar1_ChosenSuggestionIndex = args.SelectedItem is OmnibarPaletteSuggestionItem item ? Omnibar1_PaletteSuggestions.IndexOf(item) : -1; - Omnibar1_SubmittedQuery = args.Mode.Text ?? string.Empty; - } - } -} diff --git a/tests/Files.App.UITests/Views/SidebarViewPage.xaml b/tests/Files.App.UITests/Views/SidebarViewPage.xaml deleted file mode 100644 index dd67c2adbc26..000000000000 --- a/tests/Files.App.UITests/Views/SidebarViewPage.xaml +++ /dev/null @@ -1,9 +0,0 @@ - diff --git a/tests/Files.App.UITests/Views/SidebarViewPage.xaml.cs b/tests/Files.App.UITests/Views/SidebarViewPage.xaml.cs deleted file mode 100644 index fd4e70374d35..000000000000 --- a/tests/Files.App.UITests/Views/SidebarViewPage.xaml.cs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) Files Community -// Licensed under the MIT License. - -using Microsoft.UI.Xaml.Controls; -using System.Collections.ObjectModel; - -namespace Files.App.UITests.Views -{ - public sealed partial class SidebarViewPage : Page - { - public SidebarViewPage() - { - InitializeComponent(); - } - } -} diff --git a/tests/Files.App.UITests/Views/StorageControlsPage.xaml b/tests/Files.App.UITests/Views/StorageControlsPage.xaml deleted file mode 100644 index d0acca6f6101..000000000000 --- a/tests/Files.App.UITests/Views/StorageControlsPage.xaml +++ /dev/null @@ -1,334 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/Files.App.UITests/Views/StorageControlsPage.xaml.cs b/tests/Files.App.UITests/Views/StorageControlsPage.xaml.cs deleted file mode 100644 index 85aa38a0769a..000000000000 --- a/tests/Files.App.UITests/Views/StorageControlsPage.xaml.cs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) Files Community -// Licensed under the MIT License. - -using Microsoft.UI.Xaml.Controls; - -namespace Files.App.UITests.Views -{ - public sealed partial class StorageControlsPage : Page - { - public StorageControlsPage() - { - InitializeComponent(); - } - } -} diff --git a/tests/Files.App.UITests/Views/ThemedIconGalleryPage.xaml b/tests/Files.App.UITests/Views/ThemedIconGalleryPage.xaml deleted file mode 100644 index 2a6d4d6198e9..000000000000 --- a/tests/Files.App.UITests/Views/ThemedIconGalleryPage.xaml +++ /dev/null @@ -1,76 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/Files.App.UITests/Views/ThemedIconGalleryPage.xaml.cs b/tests/Files.App.UITests/Views/ThemedIconGalleryPage.xaml.cs deleted file mode 100644 index 5a6a750943b8..000000000000 --- a/tests/Files.App.UITests/Views/ThemedIconGalleryPage.xaml.cs +++ /dev/null @@ -1,119 +0,0 @@ -// Copyright (c) Files Community -// SPDX-License-Identifier: MPL-2.0 - -using Microsoft.UI.Xaml; -using Microsoft.UI.Xaml.Controls; -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using Windows.ApplicationModel.DataTransfer; -using WinRT; - -namespace Files.App.UITests.Views -{ - public sealed class IconGalleryEntry - { - public string Key { get; set; } = string.Empty; - public string ShortName { get; set; } = string.Empty; - public Style? IconStyle { get; set; } - } - - public sealed partial class ThemedIconGalleryPage : Page - { - private const string IconKeyPrefix = "App.ThemedIcons."; - private readonly IReadOnlyList allIcons; - - public ObservableCollection FilteredIcons { get; } = []; - - public ThemedIconGalleryPage() - { - InitializeComponent(); - allIcons = BuildEntries(); - ApplyFilter(string.Empty); - } - - private static IReadOnlyList BuildEntries() - { - var iconStyles = new Dictionary(StringComparer.Ordinal); - CollectIconStyles(Application.Current.Resources, iconStyles); - - return iconStyles - .OrderBy(x => x.Key, StringComparer.OrdinalIgnoreCase) - .Select(x => new IconGalleryEntry - { - Key = x.Key, - ShortName = x.Key[IconKeyPrefix.Length..], - IconStyle = x.Value, - }) - .ToList(); - } - - [DynamicWindowsRuntimeCast(typeof(Style))] - [DynamicWindowsRuntimeCast(typeof(ResourceDictionary))] - private static void CollectIconStyles(ResourceDictionary dictionary, IDictionary iconStyles) - { - foreach (var key in dictionary.Keys) - { - if (key is not string resourceKey || - !resourceKey.StartsWith(IconKeyPrefix, StringComparison.Ordinal) || - !dictionary.TryGetValue(key, out var resourceValue) || - resourceValue is not Style style) - { - continue; - } - - iconStyles[resourceKey] = style; - } - - foreach (var mergedDictionary in dictionary.MergedDictionaries) - { - CollectIconStyles(mergedDictionary, iconStyles); - } - - foreach (var themeDictionary in dictionary.ThemeDictionaries) - { - if (themeDictionary.Value is ResourceDictionary themedResourceDictionary) - { - CollectIconStyles(themedResourceDictionary, iconStyles); - } - } - } - - private void ApplyFilter(string query) - { - FilteredIcons.Clear(); - var trimmed = query.Trim(); - - foreach (var entry in allIcons) - { - if (string.IsNullOrEmpty(trimmed) || - entry.Key.Contains(trimmed, StringComparison.OrdinalIgnoreCase)) - { - FilteredIcons.Add(entry); - } - } - } - - private void SearchBox_TextChanged(object sender, TextChangedEventArgs e) - { - ApplyFilter(SearchBox.Text); - } - - private async void IconButton_Click(object sender, RoutedEventArgs e) - { - if (sender is not Button { Tag: string key }) - return; - - var package = new DataPackage(); - package.SetText(key); - Clipboard.SetContent(package); - - CopiedInfoBar.Message = $"Copied: {key}"; - CopiedInfoBar.IsOpen = true; - - await System.Threading.Tasks.Task.Delay(2500); - CopiedInfoBar.IsOpen = false; - } - } -} diff --git a/tests/Files.App.UITests/Views/ThemedIconPage.xaml b/tests/Files.App.UITests/Views/ThemedIconPage.xaml deleted file mode 100644 index 0c289b5ccd15..000000000000 --- a/tests/Files.App.UITests/Views/ThemedIconPage.xaml +++ /dev/null @@ -1,857 +0,0 @@ - - - - - -