Native iCloud apps for Windows and Linux, built in Rust. Notes, Reminders, Calendar, Contacts, Drive and Photos, offline and in sync with your iPhone.
Rust apple-notesapple-reminderscloudkitcrdtdesktop-appicloudicloud-calendaricloud-driveicloud-notesicloud-photosiphonelinuxlinux-desktoplocal-firstoffline-firstprivacyrusttauritauri-appwindows
Windows: an MSIX package for the Microsoft Store, which never updates itself
Yashwanth Kamireddi2a0b5463ac2e
diff --git a/.github/workflows/msix.yml b/.github/workflows/msix.ymlnew file mode 100644index 0000000..db9c2f6--- /dev/null+++ b/.github/workflows/msix.yml@@ -0,0 +1,268 @@+# Skykeep for the Microsoft Store: an unsigned .msix, packed from the program the .msi installs.+# build — the Windows pipeline (windows.yml), as a release builds it: the .msi and the .exe,+# the .exe's install-and-launch check;+# msix — the program taken out of the .msi and packed (packaging/windows/msix/pack.ps1) with+# the identity Partner Center gives; kept as the `skykeep-msix` artifact, unsigned, for+# the Store to sign. Then a copy is signed with a certificate made for this run only,+# installed, its seven Start-menu entries and their app IDs checked, Skykeep started+# from its entry and seen still running 15 s later, Notes opened from its own, Open at+# Login (the package's startup task) turned on inside the package, read back as Enabled+# and turned off, and the package removed. Nothing is uploaded to the Store and nothing+# is published.+#+# The identity (Partner Center → the app → Product identity) is taken from this run's inputs,+# else from the repository variables MSIX_IDENTITY_NAME, MSIX_PUBLISHER and+# MSIX_PUBLISHER_DISPLAY_NAME, else from stand-ins that make a package fit only for the test+# install here — never for the Store.+name: MSIX for the Microsoft Store++on:+ # TEMPORARY: GitHub dispatches only workflows on the default branch; this proves the+ # workflow from its own branch before it reaches main. Removed before merging.+ push:+ branches: [msix]+ workflow_dispatch:+ inputs:+ identity_name:+ description: "Package/Identity/Name (Partner Center, Product identity)"+ type: string+ default: ""+ publisher:+ description: "Package/Identity/Publisher, as CN=…"+ type: string+ default: ""+ publisher_display_name:+ description: "Package/Properties/PublisherDisplayName"+ type: string+ default: ""+ tag:+ description: "Release tag to build, such as v0.1.3 (empty: this branch)"+ type: string+ default: ""++permissions:+ contents: read++jobs:+ build:+ uses: ./.github/workflows/windows.yml+ with:+ test_first: false+ ref: ${{ inputs.tag }}++ msix:+ needs: build+ runs-on: windows-latest+ timeout-minutes: 30+ env:+ IDENTITY_NAME: ${{ inputs.identity_name || vars.MSIX_IDENTITY_NAME || 'SkykeepTest.Skykeep' }}+ PUBLISHER: ${{ inputs.publisher || vars.MSIX_PUBLISHER || 'CN=Skykeep Test' }}+ PUBLISHER_DISPLAY_NAME: ${{ inputs.publisher_display_name || vars.MSIX_PUBLISHER_DISPLAY_NAME || 'Skykeep Test' }}+ steps:+ - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0+ - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0+ with:+ name: skykeep-windows+ path: dist+ - name: Pack the .msix from the .msi's program+ shell: pwsh+ run: |+ $msi = Get-ChildItem dist -Recurse -Filter *.msi | Select-Object -First 1+ if ($msi.Name -notmatch '^Skykeep_(\d+\.\d+\.\d+)_x64') { throw "no version in '$($msi.Name)'" }+ $version = $Matches[1]+ # An administrative install only unpacks the .msi's files: nothing is installed.+ $unpacked = Join-Path $env:RUNNER_TEMP "msi"+ $p = Start-Process msiexec.exe -ArgumentList "/a `"$($msi.FullName)`" /qn TARGETDIR=`"$unpacked`"" -Wait -PassThru+ if ($p.ExitCode) { throw "msiexec /a failed ($($p.ExitCode))" }+ $exe = Get-ChildItem $unpacked -Recurse -Filter skykeep.exe | Select-Object -First 1+ if (-not $exe) { throw "no skykeep.exe in the .msi" }+ "from the .msi: $((Get-ChildItem $exe.DirectoryName -File).Name -join ', ')"+ $out = "out\Skykeep_${version}_x64.msix"+ ./packaging/windows/msix/pack.ps1 -Payload $exe.DirectoryName -Out $out -Version $version `+ -Name $env:IDENTITY_NAME -Publisher $env:PUBLISHER -PublisherDisplayName $env:PUBLISHER_DISPLAY_NAME+ "MSIX=$((Resolve-Path $out).Path)" >> $env:GITHUB_ENV+ - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2+ with:+ name: skykeep-msix+ path: out/*.msix+ if-no-files-found: error+ - name: A signed copy installs, starts and stays up, and comes off again+ shell: pwsh+ run: |+ # A certificate for this run alone, named as the package's publisher (Windows installs+ # a package only when the two match), trusted on this machine only.+ $sdk = Get-ChildItem "${env:ProgramFiles(x86)}\Windows Kits\10\bin\10.*\x64\signtool.exe" |+ Sort-Object { [version]($_.Directory.Parent.Name) } | Select-Object -Last 1+ $cert = New-SelfSignedCertificate -Type Custom -Subject $env:PUBLISHER -KeyUsage DigitalSignature `+ -FriendlyName "Skykeep MSIX test" -CertStoreLocation Cert:\CurrentUser\My `+ -TextExtension @("2.5.29.37={text}1.3.6.1.5.5.7.3.3", "2.5.29.19={text}")+ $pw = ConvertTo-SecureString ([guid]::NewGuid().ToString()) -AsPlainText -Force+ $pfx = Join-Path $env:RUNNER_TEMP "test.pfx"+ Export-PfxCertificate -Cert $cert -FilePath $pfx -Password $pw | Out-Null+ Import-PfxCertificate -FilePath $pfx -CertStoreLocation Cert:\LocalMachine\TrustedPeople -Password $pw | Out-Null+ $copy = Join-Path $env:RUNNER_TEMP "signed-copy.msix"+ Copy-Item $env:MSIX $copy+ & $sdk.FullName sign /fd SHA256 /f $pfx /p ([System.Net.NetworkCredential]::new("", $pw).Password) $copy+ if ($LASTEXITCODE) { throw "signtool failed ($LASTEXITCODE)" }++ Add-AppxPackage -Path $copy+ $pkg = Get-AppxPackage -Name $env:IDENTITY_NAME+ if (-not $pkg) { throw "installed, but Windows lists no $env:IDENTITY_NAME package" }+ $pfn = $pkg.PackageFamilyName+ "installed: $($pkg.PackageFullName) at $($pkg.InstallLocation)"+ $installed = Join-Path $pkg.InstallLocation "skykeep.exe"+ $text = [System.Text.Encoding]::Latin1.GetString([System.IO.File]::ReadAllBytes($installed))+ if ($text.Contains("__TAURI_BUNDLE_TYPE_VAR_MSI") -or $text.Contains("__TAURI_BUNDLE_TYPE_VAR_NSS")) {+ throw "the packaged program still says it is the .msi's or the .exe's, which update themselves"+ }++ # The seven entries, each under its own app ID.+ $ids = [ordered]@{ "Skykeep" = "io.github.yashwanthkamireddi.Skykeep" }+ foreach ($n in "Notes", "Reminders", "Calendar", "Contacts", "Drive", "Photos") { $ids["Skykeep $n"] = "io.github.yashwanthkamireddi.Skykeep.$n" }+ $wrong = @()+ for ($i = 0; $i -lt 30; $i++) {+ $listed = @(Get-StartApps | Where-Object { $_.AppID -like "$pfn!*" })+ $wrong = @($ids.Keys | Where-Object { $n = $_; -not ($listed | Where-Object { $_.Name -eq $n -and $_.AppID -eq "$pfn!$($ids[$n])" }) })+ if (-not $wrong) { break }+ Start-Sleep -Seconds 2+ }+ $listed | Format-Table -AutoSize | Out-String | Write-Host+ if ($wrong) { throw "the Start menu does not list, with its own app ID: $($wrong -join ', ')" }+ "start menu: $($listed.Count) entries"++ # An app ID as the shell reads it from a window.+ Add-Type -TypeDefinition '+ using System; using System.Runtime.InteropServices;+ namespace WinShell {+ [StructLayout(LayoutKind.Sequential)] public struct PropKey { public Guid fmtid; public uint pid; }+ [StructLayout(LayoutKind.Sequential)] public struct PropVar { public ushort vt, r1, r2, r3; public IntPtr p, p2; }+ [ComImport, Guid("886D8EEB-8CF2-4446-8D02-CDBA1DBDCF99"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]+ public interface IPropertyStore {+ void GetCount(out uint count); void GetAt(uint i, out PropKey key); void GetValue(ref PropKey key, out PropVar v);+ void SetValue(ref PropKey key, ref PropVar v); void Commit();+ }+ public static class Aumid {+ [DllImport("shell32.dll")] static extern int SHGetPropertyStoreForWindow(IntPtr hwnd, ref Guid iid, [MarshalAs(UnmanagedType.Interface)] out IPropertyStore store);+ public static string Of(IntPtr hwnd) {+ Guid iid = typeof(IPropertyStore).GUID; IPropertyStore store;+ if (SHGetPropertyStoreForWindow(hwnd, ref iid, out store) != 0) return null;+ PropKey key = new PropKey { fmtid = new Guid("9F4C2855-9F79-4B39-A8D0-E1D42DE1D5F3"), pid = 5 };+ PropVar v; store.GetValue(ref key, out v); Marshal.ReleaseComObject(store);+ return (v.vt == 31 || v.vt == 8) ? Marshal.PtrToStringUni(v.p) : null;+ }+ }+ }'+ Add-Type -Namespace Win -Name U -MemberDefinition '+ public delegate bool EnumProc(System.IntPtr h, System.IntPtr l);+ [System.Runtime.InteropServices.DllImport("user32.dll")] public static extern bool EnumWindows(EnumProc f, System.IntPtr l);+ [System.Runtime.InteropServices.DllImport("user32.dll")] public static extern bool IsWindowVisible(System.IntPtr h);+ [System.Runtime.InteropServices.DllImport("user32.dll")] public static extern uint GetWindowThreadProcessId(System.IntPtr h, out uint pid);+ [System.Runtime.InteropServices.DllImport("user32.dll", CharSet = System.Runtime.InteropServices.CharSet.Unicode)] public static extern int GetWindowText(System.IntPtr h, System.Text.StringBuilder s, int n);+ '+ function Get-Windows([int]$procId) {+ $found = New-Object System.Collections.Generic.List[object]+ [Win.U]::EnumWindows({ param($h, $l)+ $owner = 0; [void][Win.U]::GetWindowThreadProcessId($h, [ref]$owner)+ if ($owner -eq $procId -and [Win.U]::IsWindowVisible($h)) {+ $sb = New-Object System.Text.StringBuilder 256; [void][Win.U]::GetWindowText($h, $sb, 256)+ $found.Add([pscustomobject]@{ Handle = $h; Title = $sb.ToString() })+ }+ $true }, [System.IntPtr]::Zero) | Out-Null+ $found+ }++ # Started as a person starts it: its Start-menu entry.+ Start-Process "shell:AppsFolder\$pfn!io.github.yashwanthkamireddi.Skykeep"+ $p = $null+ for ($i = 0; $i -lt 30 -and -not $p; $i++) {+ Start-Sleep -Seconds 1+ $p = Get-Process skykeep -ErrorAction SilentlyContinue | Where-Object { $_.Path -like "$($pkg.InstallLocation)*" } | Select-Object -First 1+ }+ if (-not $p) { throw "Skykeep did not start from its Start-menu entry" }+ "started: $($p.Path) (pid $($p.Id))"+ Start-Sleep -Seconds 15+ $p.Refresh()+ if ($p.HasExited) { throw "Skykeep exited within 15 s (code $($p.ExitCode))" }+ "still running after 15 s; windows: '$((Get-Windows $p.Id).Title -join "', '")'"+ Add-Type -AssemblyName System.Windows.Forms, System.Drawing+ $b = [System.Windows.Forms.Screen]::PrimaryScreen.Bounds+ $bmp = New-Object System.Drawing.Bitmap $b.Width, $b.Height+ [System.Drawing.Graphics]::FromImage($bmp).CopyFromScreen($b.Location, [System.Drawing.Point]::Empty, $b.Size)+ $bmp.Save("$PWD\skykeep-msix-on-windows.png")++ # Notes from its own entry: handed to the Skykeep running, a window under Notes' ID.+ Start-Process "shell:AppsFolder\$pfn!io.github.yashwanthkamireddi.Skykeep.Notes"+ $w = $null+ for ($i = 0; $i -lt 15 -and -not $w; $i++) {+ Start-Sleep -Seconds 2+ $w = Get-Windows $p.Id | Where-Object { $_.Title -eq "Notes" } | Select-Object -First 1+ }+ if (-not $w) { throw "no Notes window after 30 s (visible: '$((Get-Windows $p.Id).Title -join "', '")')" }+ $id = [WinShell.Aumid]::Of($w.Handle)+ $want = "$pfn!io.github.yashwanthkamireddi.Skykeep.Notes"+ if ($id -ne $want) { throw "the Notes window has app ID '$id', not $want" }+ "Notes window: app ID $id"+ $p.Refresh()+ if ($p.HasExited) { throw "Skykeep closed by itself" }++ # Open at Login in a package: its startup task, through the StartupTask calls Skykeep+ # makes (login.rs), made inside the package as Skykeep makes them — the API answers+ # only a process with the package's identity. Turned on, then read back afresh as+ # Enabled, as Windows records it for Task Manager, then turned off.+ $probe = Join-Path $env:RUNNER_TEMP "startup-task.ps1"+ Set-Content $probe @'+ param([string]$Do, [string]$Out)+ try {+ Add-Type -AssemblyName System.Runtime.WindowsRuntime+ $asTask = [System.WindowsRuntimeSystemExtensions].GetMethods() | Where-Object {+ $_.Name -eq "AsTask" -and $_.GetParameters().Count -eq 1 -and $_.GetParameters()[0].ParameterType.Name -eq 'IAsyncOperation`1' } | Select-Object -First 1+ function Wait-Op($op, [Type]$type) { $t = $asTask.MakeGenericMethod($type).Invoke($null, @($op)); $t.Wait(-1) | Out-Null; $t.Result }+ $null = [Windows.ApplicationModel.StartupTask, Windows.ApplicationModel, ContentType = WindowsRuntime]+ $task = Wait-Op ([Windows.ApplicationModel.StartupTask]::GetAsync("SkykeepStartup")) ([Windows.ApplicationModel.StartupTask])+ switch ($Do) {+ "on" { $state = Wait-Op ($task.RequestEnableAsync()) ([Windows.ApplicationModel.StartupTaskState]) }+ "off" { $task.Disable(); $state = $task.State }+ default { $state = $task.State }+ }+ Set-Content $Out "$state"+ } catch { Set-Content $Out "ERROR $_" }+ '@+ function Invoke-StartupTask([string]$do) {+ $out = Join-Path $env:RUNNER_TEMP "startup-task-$do-$([guid]::NewGuid()).txt"+ Invoke-CommandInDesktopPackage -PackageFamilyName $pfn -AppId "io.github.yashwanthkamireddi.Skykeep" `+ -Command "$env:SystemRoot\System32\WindowsPowerShell\v1.0\powershell.exe" `+ -Args "-NoProfile -ExecutionPolicy Bypass -File `"$probe`" -Do $do -Out `"$out`""+ for ($i = 0; $i -lt 30 -and -not (Test-Path $out); $i++) { Start-Sleep -Seconds 1 }+ if (-not (Test-Path $out)) { throw "the startup task gave no answer to '$do'" }+ $answer = (Get-Content $out -Raw).Trim()+ if ($answer.StartsWith("ERROR")) { throw "the startup task, asked '$do': $answer" }+ $answer+ }+ $taskKey = "HKCU:\Software\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\SystemAppData\$pfn\SkykeepStartup"+ $before = Invoke-StartupTask "read"+ "startup task as installed: $before"+ if ($before -ne "Disabled") { throw "the startup task is '$before' before anyone turned it on" }+ $on = Invoke-StartupTask "on"+ "turned on: $on"+ if ($on -ne "Enabled") { throw "turned on, Windows says '$on'" }+ $read = Invoke-StartupTask "read"+ "read back: $read"+ if ($read -ne "Enabled") { throw "read back, the startup task is '$read', not Enabled" }+ $recorded = (Get-ItemProperty $taskKey -Name State -ErrorAction SilentlyContinue).State+ "Windows' own record for Task Manager: State=$recorded"+ $off = Invoke-StartupTask "off"+ "turned off: $off"+ if ($off -ne "Disabled") { throw "turned off, Windows says '$off'" }++ Stop-Process -Id $p.Id+ Start-Sleep -Seconds 2+ Remove-AppxPackage -Package $pkg.PackageFullName+ if (Get-AppxPackage -Name $env:IDENTITY_NAME) { throw "removed, but the package is still installed" }+ if (Get-StartApps | Where-Object { $_.AppID -like "$pfn!*" }) { throw "removed, but the Start menu still lists it" }+ "removed: no Skykeep entries left"+ - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2+ if: always()+ with:+ name: skykeep-msix-on-windows+ path: skykeep-msix-on-windows.png+ if-no-files-found: ignorediff --git a/.github/workflows/windows.yml b/.github/workflows/windows.ymlindex cdb0e11..06f0667 100644--- a/.github/workflows/windows.yml+++ b/.github/workflows/windows.yml@@ -36,6 +36,10 @@ on:updater:type: booleandefault: false+ # What to build, when not the caller's own commit: a tag, for the Store's package (msix.yml).+ ref:+ type: string+ default: ""secrets:TAURI_SIGNING_PRIVATE_KEY:required: false@@ -55,6 +59,8 @@ jobs:timeout-minutes: 75steps:- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1+ with:+ ref: ${{ inputs.ref }}- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0with:node-version: 22diff --git a/packaging/README.md b/packaging/README.mdindex bf7220e..53d7ecf 100644--- a/packaging/README.md+++ b/packaging/README.md@@ -14,6 +14,7 @@ Everything that turns a build into something people install.| `*.desktop.in`, `*.metainfo.xml` | The main launcher entry and the AppStream data software centres show. || `*.search-provider.ini`, `*.SearchProvider.service`, `*.krunner.desktop` | Results in GNOME Shell and KRunner search. || `icons/` | The app, tray and notification icons. |+| `windows/msix/` | The Microsoft Store's MSIX package: its manifest and `pack.ps1`. || `linux-compat/` | `check.sh`: installs a package in a clean distribution container and checks it runs. |## Arch, CachyOS, EndeavourOS, Manjaro@@ -166,3 +167,26 @@ What the per-app `.desktop` files and `Actions=` are on Linux:`.github/workflows/windows.yml` checks all of this after a silent install: each entry's app IDand command line, each app window's app ID, every jump-list task, and that uninstalling leaves noentry behind.++## The Microsoft Store (MSIX)++`.github/workflows/msix.yml` (Actions → MSIX for the Microsoft Store → Run workflow) builds+Windows as a release does, takes the program out of the `.msi` and packs it with+`windows/msix/pack.ps1` into an unsigned `.msix` — the `skykeep-msix` artifact. The Store signs+it. Then a signed copy is installed on the runner, started from its Start-menu entry, seen still+running 15 s later, and removed.++The package's identity comes from Partner Center (the app → Product management → Product+identity): `Package/Identity/Name`, `Package/Identity/Publisher` and+`Package/Properties/PublisherDisplayName`, given as the run's inputs or kept as the repository+variables `MSIX_IDENTITY_NAME`, `MSIX_PUBLISHER` and `MSIX_PUBLISHER_DISPLAY_NAME`. The package's+display name is "Skykeep", the name reserved there. A tag input builds that release's code.++The package has the same seven Start-menu entries as the installers, each entry's ID the+installers' app ID, so Windows knows them as `<package family name>!io.github.yashwanthkamireddi.Skykeep`,+`…!io.github.yashwanthkamireddi.Skykeep.Notes` and so on, and the windows, toasts and jump lists+use those (`src-tauri/src/package.rs`, `taskbar.rs`). It opens `.ics` and `.vcf` files. Open at+Login is the package's startup task (`SkykeepStartup`, listed in Task Manager's Startup apps),+turned on and off through Windows' StartupTask API (`login.rs`), not the `Run` key. It never+updates itself: a copy running from a package is the Store's to update (`updates.rs`,+`Install::Store`), and the packed program's bundle mark says neither `.msi` nor `.exe`.diff --git a/packaging/windows/msix/AppxManifest.xml b/packaging/windows/msix/AppxManifest.xmlnew file mode 100644index 0000000..ea46ad2--- /dev/null+++ b/packaging/windows/msix/AppxManifest.xml@@ -0,0 +1,124 @@+<?xml version="1.0" encoding="utf-8"?>+<!--+ Skykeep as an MSIX package, for the Microsoft Store: filled in and packed by pack.ps1+ (.github/workflows/msix.yml). The double-underscored values are filled at pack time — the+ identity from Partner Center (Product identity), the version from tauri.conf.json.++ Seven Start-menu entries, as the .exe and the .msi make them (packaging/windows): Skykeep, and+ each app on its own, started with the same app argument as the shortcuts (uap10:Parameters,+ Windows 10 2004 and later). Each entry's Id is the+ AppUserModelID the installers use, so Windows knows it as `<family name>!<that ID>` and each+ app's window (src-tauri/src/taskbar.rs) is matched to its own entry. Never change an Id once+ published: Windows keeps pinned tiles by it.+-->+<Package+ xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"+ xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"+ xmlns:uap10="http://schemas.microsoft.com/appx/manifest/uap/windows10/10"+ xmlns:desktop="http://schemas.microsoft.com/appx/manifest/desktop/windows10"+ xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"+ IgnorableNamespaces="uap uap10 desktop rescap">++ <Identity+ Name="__IDENTITY_NAME__"+ Publisher="__PUBLISHER__"+ Version="__VERSION__"+ ProcessorArchitecture="x64" />++ <Properties>+ <DisplayName>Skykeep</DisplayName>+ <PublisherDisplayName>__PUBLISHER_DISPLAY_NAME__</PublisherDisplayName>+ <Description>Your iCloud notes, reminders, calendar, contacts, Drive and photos, on this computer. Not affiliated with Apple.</Description>+ <Logo>Assets\StoreLogo.png</Logo>+ </Properties>++ <Dependencies>+ <TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.19041.0" MaxVersionTested="10.0.26100.0" />+ </Dependencies>++ <Resources>+ <Resource Language="en-us" />+ </Resources>++ <Capabilities>+ <Capability Name="internetClient" />+ <rescap:Capability Name="runFullTrust" />+ </Capabilities>++ <Applications>+ <Application Id="io.github.yashwanthkamireddi.Skykeep" Executable="skykeep.exe" EntryPoint="Windows.FullTrustApplication">+ <uap:VisualElements DisplayName="Skykeep" Description="Your iCloud, on this computer" BackgroundColor="transparent"+ Square150x150Logo="Assets\Square150x150Logo.png" Square44x44Logo="Assets\Square44x44Logo.png">+ <uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png" Square71x71Logo="Assets\Square71x71Logo.png" Square310x310Logo="Assets\Square310x310Logo.png" />+ </uap:VisualElements>+ <Extensions>+ <!-- Open at Login: off until turned on in Settings (src-tauri/src/login.rs), then+ listed in Task Manager's Startup apps. Started hidden, as the Run key starts it. -->+ <desktop:Extension Category="windows.startupTask" Executable="skykeep.exe" EntryPoint="Windows.FullTrustApplication" uap10:Parameters="--background">+ <desktop:StartupTask TaskId="SkykeepStartup" Enabled="false" DisplayName="Skykeep" />+ </desktop:Extension>+ <uap:Extension Category="windows.fileTypeAssociation">+ <uap:FileTypeAssociation Name="icalendar">+ <uap:DisplayName>Calendar events</uap:DisplayName>+ <uap:SupportedFileTypes>+ <uap:FileType ContentType="text/calendar">.ics</uap:FileType>+ <uap:FileType ContentType="text/calendar">.ical</uap:FileType>+ <uap:FileType ContentType="text/calendar">.icalendar</uap:FileType>+ </uap:SupportedFileTypes>+ </uap:FileTypeAssociation>+ </uap:Extension>+ <uap:Extension Category="windows.fileTypeAssociation">+ <uap:FileTypeAssociation Name="vcard">+ <uap:DisplayName>Contact card</uap:DisplayName>+ <uap:SupportedFileTypes>+ <uap:FileType ContentType="text/vcard">.vcf</uap:FileType>+ <uap:FileType ContentType="text/vcard">.vcard</uap:FileType>+ </uap:SupportedFileTypes>+ </uap:FileTypeAssociation>+ </uap:Extension>+ </Extensions>+ </Application>++ <Application Id="io.github.yashwanthkamireddi.Skykeep.Notes" Executable="skykeep.exe" EntryPoint="Windows.FullTrustApplication" uap10:Parameters="--app notes">+ <uap:VisualElements DisplayName="Skykeep Notes" Description="Notes from iCloud, on this computer" BackgroundColor="transparent"+ Square150x150Logo="Assets\Square150x150Logo.png" Square44x44Logo="Assets\Square44x44Logo.png">+ <uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png" Square71x71Logo="Assets\Square71x71Logo.png" Square310x310Logo="Assets\Square310x310Logo.png" />+ </uap:VisualElements>+ </Application>++ <Application Id="io.github.yashwanthkamireddi.Skykeep.Reminders" Executable="skykeep.exe" EntryPoint="Windows.FullTrustApplication" uap10:Parameters="--app reminders">+ <uap:VisualElements DisplayName="Skykeep Reminders" Description="Reminders from iCloud, on this computer" BackgroundColor="transparent"+ Square150x150Logo="Assets\Square150x150Logo.png" Square44x44Logo="Assets\Square44x44Logo.png">+ <uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png" Square71x71Logo="Assets\Square71x71Logo.png" Square310x310Logo="Assets\Square310x310Logo.png" />+ </uap:VisualElements>+ </Application>++ <Application Id="io.github.yashwanthkamireddi.Skykeep.Calendar" Executable="skykeep.exe" EntryPoint="Windows.FullTrustApplication" uap10:Parameters="--app calendar">+ <uap:VisualElements DisplayName="Skykeep Calendar" Description="Your iCloud calendars, on this computer" BackgroundColor="transparent"+ Square150x150Logo="Assets\Square150x150Logo.png" Square44x44Logo="Assets\Square44x44Logo.png">+ <uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png" Square71x71Logo="Assets\Square71x71Logo.png" Square310x310Logo="Assets\Square310x310Logo.png" />+ </uap:VisualElements>+ </Application>++ <Application Id="io.github.yashwanthkamireddi.Skykeep.Contacts" Executable="skykeep.exe" EntryPoint="Windows.FullTrustApplication" uap10:Parameters="--app contacts">+ <uap:VisualElements DisplayName="Skykeep Contacts" Description="Your iCloud contacts, on this computer" BackgroundColor="transparent"+ Square150x150Logo="Assets\Square150x150Logo.png" Square44x44Logo="Assets\Square44x44Logo.png">+ <uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png" Square71x71Logo="Assets\Square71x71Logo.png" Square310x310Logo="Assets\Square310x310Logo.png" />+ </uap:VisualElements>+ </Application>++ <Application Id="io.github.yashwanthkamireddi.Skykeep.Drive" Executable="skykeep.exe" EntryPoint="Windows.FullTrustApplication" uap10:Parameters="--app drive">+ <uap:VisualElements DisplayName="Skykeep Drive" Description="iCloud Drive, on this computer" BackgroundColor="transparent"+ Square150x150Logo="Assets\Square150x150Logo.png" Square44x44Logo="Assets\Square44x44Logo.png">+ <uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png" Square71x71Logo="Assets\Square71x71Logo.png" Square310x310Logo="Assets\Square310x310Logo.png" />+ </uap:VisualElements>+ </Application>++ <Application Id="io.github.yashwanthkamireddi.Skykeep.Photos" Executable="skykeep.exe" EntryPoint="Windows.FullTrustApplication" uap10:Parameters="--app photos">+ <uap:VisualElements DisplayName="Skykeep Photos" Description="iCloud Photos, on this computer" BackgroundColor="transparent"+ Square150x150Logo="Assets\Square150x150Logo.png" Square44x44Logo="Assets\Square44x44Logo.png">+ <uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png" Square71x71Logo="Assets\Square71x71Logo.png" Square310x310Logo="Assets\Square310x310Logo.png" />+ </uap:VisualElements>+ </Application>+ </Applications>+</Package>diff --git a/packaging/windows/msix/pack.ps1 b/packaging/windows/msix/pack.ps1new file mode 100644index 0000000..85ab0c7--- /dev/null+++ b/packaging/windows/msix/pack.ps1@@ -0,0 +1,131 @@+# Skykeep's MSIX package for the Microsoft Store, from the program the .msi installs.+#+# pack.ps1 -Payload <folder with skykeep.exe> -Out <file.msix> -Version 0.1.2 `+# -Name <Package/Identity/Name> -Publisher <Package/Identity/Publisher> `+# -PublisherDisplayName <Package/Properties/PublisherDisplayName>+#+# The three identity values are Partner Center's (the app → Product identity). The package is+# left unsigned: the Store signs what it publishes. Needs the Windows SDK (makeappx, makepri),+# which GitHub's Windows runners have.+#+# 1. The program, with its bundle mark set back to "unknown": taken from the .msi it says+# "msi", and a copy that says neither .msi nor .exe is never one the in-app updater replaces+# (src-tauri/src/updates.rs) — beside the package identity check that already rules it out.+# 2. The manifest (AppxManifest.xml) filled in.+# 3. The Start menu's and the Store's images, drawn from packaging/icons/skykeep-1024.png at+# each scale and taskbar size Windows asks for, and indexed in resources.pri.+# 4. makeappx pack, which validates the manifest against Windows' schema as it packs.+param(+ [Parameter(Mandatory)] [string] $Payload,+ [Parameter(Mandatory)] [string] $Out,+ [Parameter(Mandatory)] [string] $Version,+ [Parameter(Mandatory)] [string] $Name,+ [Parameter(Mandatory)] [string] $Publisher,+ [Parameter(Mandatory)] [string] $PublisherDisplayName+)+$ErrorActionPreference = "Stop"+$here = $PSScriptRoot+$icon = Join-Path $here "..\..\icons\skykeep-1024.png" | Resolve-Path++# The newest SDK's tools.+$bin = Get-ChildItem "${env:ProgramFiles(x86)}\Windows Kits\10\bin\10.*\x64\makeappx.exe" |+ Sort-Object { [version]($_.Directory.Parent.Name) } | Select-Object -Last 1+if (-not $bin) { throw "no Windows SDK makeappx.exe found" }+$makeappx = $bin.FullName+$makepri = Join-Path $bin.DirectoryName "makepri.exe"+"Windows SDK: $($bin.DirectoryName)"++# The Store takes a.b.c.0: the fourth part is its own.+if ($Version -notmatch '^\d+\.\d+\.\d+$') { throw "version '$Version' is not major.minor.patch" }+$packageVersion = "$Version.0"++$stage = Join-Path ([System.IO.Path]::GetTempPath()) "skykeep-msix-$([guid]::NewGuid())"+New-Item -ItemType Directory $stage | Out-Null+try {+ # 1. The program and what lies beside it.+ Get-ChildItem $Payload -File | Where-Object { $_.Extension -ne ".msi" } | Copy-Item -Destination $stage+ $exe = Join-Path $stage "skykeep.exe"+ if (-not (Test-Path $exe)) { throw "no skykeep.exe in $Payload" }+ $bytes = [System.IO.File]::ReadAllBytes($exe)+ $latin = [System.Text.Encoding]::Latin1+ $text = $latin.GetString($bytes)+ $marks = 0+ foreach ($kind in "MSI", "NSS") {+ $from = "__TAURI_BUNDLE_TYPE_VAR_$kind"+ for ($at = $text.IndexOf($from); $at -ge 0; $at = $text.IndexOf($from, $at + 1)) {+ $latin.GetBytes("__TAURI_BUNDLE_TYPE_VAR_UNK").CopyTo($bytes, $at)+ $marks+++ }+ }+ if ($marks -eq 0 -and -not $text.Contains("__TAURI_BUNDLE_TYPE_VAR_UNK")) { throw "skykeep.exe has no bundle mark" }+ [System.IO.File]::WriteAllBytes($exe, $bytes)+ "program: skykeep.exe, bundle mark set to unknown ($marks replaced)"++ # 2. The manifest.+ $esc = { param($v) [System.Security.SecurityElement]::Escape($v) }+ $manifest = (Get-Content (Join-Path $here "AppxManifest.xml") -Raw).+ Replace("__IDENTITY_NAME__", (& $esc $Name)).+ Replace("__PUBLISHER_DISPLAY_NAME__", (& $esc $PublisherDisplayName)).+ Replace("__PUBLISHER__", (& $esc $Publisher)).+ Replace("__VERSION__", $packageVersion)+ if ($manifest -match "__[A-Z_]+__") { throw "the manifest still has $($Matches[0])" }+ [xml]$manifest | Out-Null+ Set-Content (Join-Path $stage "AppxManifest.xml") $manifest -Encoding utf8NoBOM++ # 3. The images: the icon centred on a transparent canvas, at `share` of its shorter side.+ Add-Type -AssemblyName System.Drawing+ $source = [System.Drawing.Image]::FromFile($icon)+ $assets = Join-Path $stage "Assets"+ New-Item -ItemType Directory $assets | Out-Null+ function Draw([string]$file, [int]$w, [int]$h, [double]$share) {+ $bmp = New-Object System.Drawing.Bitmap $w, $h, ([System.Drawing.Imaging.PixelFormat]::Format32bppArgb)+ $g = [System.Drawing.Graphics]::FromImage($bmp)+ $g.InterpolationMode = [System.Drawing.Drawing2D.InterpolationMode]::HighQualityBicubic+ $g.SmoothingMode = [System.Drawing.Drawing2D.SmoothingMode]::HighQuality+ $g.PixelOffsetMode = [System.Drawing.Drawing2D.PixelOffsetMode]::HighQuality+ $g.Clear([System.Drawing.Color]::Transparent)+ $side = [math]::Round([math]::Min($w, $h) * $share)+ $g.DrawImage($source, [int](($w - $side) / 2), [int](($h - $side) / 2), [int]$side, [int]$side)+ $g.Dispose()+ $bmp.Save((Join-Path $assets $file), [System.Drawing.Imaging.ImageFormat]::Png)+ $bmp.Dispose()+ }+ $scales = 100, 125, 150, 200, 400+ # name, width, height at scale 100, and the icon's share of the shorter side.+ $tiles = @(+ @("Square44x44Logo", 44, 44, 1.0),+ @("Square71x71Logo", 71, 71, 0.75),+ @("Square150x150Logo", 150, 150, 0.66),+ @("Wide310x150Logo", 310, 150, 0.66),+ @("Square310x310Logo", 310, 310, 0.6),+ @("StoreLogo", 50, 50, 1.0)+ )+ foreach ($t in $tiles) {+ foreach ($s in $scales) {+ Draw "$($t[0]).scale-$s.png" ([math]::Round($t[1] * $s / 100)) ([math]::Round($t[2] * $s / 100)) $t[3]+ }+ }+ # The taskbar's, the Start menu list's and Explorer's: each pixel size, on no plate.+ foreach ($size in 16, 20, 24, 30, 32, 36, 40, 48, 60, 64, 72, 80, 96, 256) {+ foreach ($form in "", "_altform-unplated", "_altform-lightunplated") {+ Draw "Square44x44Logo.targetsize-$size$form.png" $size $size 1.0+ }+ }+ $source.Dispose()+ "images: $((Get-ChildItem $assets).Count) files"++ $pri = Join-Path ([System.IO.Path]::GetTempPath()) "skykeep-priconfig-$([guid]::NewGuid()).xml"+ & $makepri createconfig /cf $pri /dq en-US /pv 10.0.0 /o+ if ($LASTEXITCODE) { throw "makepri createconfig failed ($LASTEXITCODE)" }+ & $makepri new /pr $stage /cf $pri /mn (Join-Path $stage "AppxManifest.xml") /of (Join-Path $stage "resources.pri") /o+ if ($LASTEXITCODE) { throw "makepri new failed ($LASTEXITCODE)" }+ Remove-Item $pri++ # 4. The package.+ New-Item -ItemType Directory -Force (Split-Path $Out -Parent) | Out-Null+ & $makeappx pack /d $stage /p $Out /o+ if ($LASTEXITCODE) { throw "makeappx pack failed ($LASTEXITCODE)" }+ "packed: $Out ($([math]::Round((Get-Item $Out).Length / 1MB, 1)) MB), version $packageVersion"+} finally {+ Remove-Item -Recurse -Force $stage -ErrorAction SilentlyContinue+}diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.tomlindex 9ed49a5..e98715f 100644--- a/src-tauri/Cargo.toml+++ b/src-tauri/Cargo.toml@@ -53,11 +53,14 @@ tauri = { version = "2", features = ["tray-icon"] }# Toasts with buttons on Windows (notify-rust sends none there): the same crate notify-rust uses.[target.'cfg(windows)'.dependencies]tauri-winrt-notification = "0.8"-# Each app its own taskbar button and the jump list's tasks (taskbar.rs): the shell's own calls,+# Each app its own taskbar button and the jump list's tasks (taskbar.rs), and whether this copy+# is an MSIX package's (package.rs) and its startup task (login.rs): the shell's own calls,# from the same build of the crate Tauri and the toasts already compile.windows = { version = "0.62", features = [+ "ApplicationModel","Win32_Foundation","Win32_Storage_EnhancedStorage",+ "Win32_Storage_Packaging_Appx","Win32_System_Com","Win32_System_Com_StructuredStorage","Win32_System_DataExchange",diff --git a/src-tauri/src/alerts.rs b/src-tauri/src/alerts.rsindex 474fc7f6..86cc1d3 100644--- a/src-tauri/src/alerts.rs+++ b/src-tauri/src/alerts.rs@@ -110,7 +110,7 @@ pub fn tell(app: &AppHandle, title: &str, body: &str) {std::thread::spawn(move || {let mut notice = notify_rust::Notification::new();#[cfg(windows)]- notice.app_id(&app.config().identifier);+ notice.app_id(&crate::taskbar::own_id(&app.config().identifier));notice.appname("Skykeep").summary(&title)@@ -328,7 +328,7 @@ fn show(app: AppHandle, due: DueAlarm) {use tauri_winrt_notification::{Duration as Shown, Scenario, Sound, Toast};let answering = app.clone();let due_answered = due.clone();- let mut toast = Toast::new(&app.config().identifier)+ let mut toast = Toast::new(&crate::taskbar::own_id(&app.config().identifier)).title(&due.title).text1(&body).sound(Some(Sound::Reminder))@@ -491,7 +491,7 @@ fn show_event(app: AppHandle, event: quince_core::calendar::Event, minutes: i64)// menu shortcut the installer stamps with the same ID; without it every alert// came from "Windows PowerShell".#[cfg(windows)]- toast.app_id(&app.config().identifier);+ toast.app_id(&crate::taskbar::own_id(&app.config().identifier));// Windows' own reminder chime; without a sound named the toast was silent.#[cfg(windows)]toast.sound_name("Reminder");diff --git a/src-tauri/src/login.rs b/src-tauri/src/login.rsindex f724e6f..522e8c9 100644--- a/src-tauri/src/login.rs+++ b/src-tauri/src/login.rs@@ -9,7 +9,11 @@//!//! On Windows it is the standard place too: a value under the user's own `Run` key, which//! Windows reads at sign-in (and lists in Task Manager's Startup apps, where it can be turned-//! off as any other).+//! off as any other). From an MSIX package (the Microsoft Store, package.rs) the registry is+//! the package's own, which Windows never reads at sign-in: there it is the package's startup+//! task (`SkykeepStartup` in packaging/windows/msix/AppxManifest.xml, started with+//! `--background`), turned on and off through Windows' StartupTask API, and its state —+//! including turned off in Task Manager or by an organization's policy — is what Settings shows.use serde::Serialize;use std::path::PathBuf;@@ -100,6 +104,58 @@ pub struct LoginItem {/// sandbox's own config folder, which the desktop never reads, and the switch said "on"/// over nothing at all. There Settings says how to add it instead.pub available: bool,+ /// Why the switch cannot change it here: Windows holds the package's startup task turned+ /// off in Task Manager, or on or off by policy. `None` anywhere else.+ pub elsewhere: Option<String>,+}++/// What Windows says of a package's startup task: its `StartupTaskState`.+#[cfg(any(windows, test))]+#[derive(Clone, Copy, Debug, PartialEq, Eq)]+pub enum Startup {+ Disabled,+ DisabledByUser,+ Enabled,+ DisabledByPolicy,+ EnabledByPolicy,+}++#[cfg(any(windows, test))]+impl Startup {+ /// From `StartupTaskState`'s value; `None` for one this build does not know.+ pub fn from_state(state: i32) -> Option<Self> {+ Some(match state {+ 0 => Self::Disabled,+ 1 => Self::DisabledByUser,+ 2 => Self::Enabled,+ 3 => Self::DisabledByPolicy,+ 4 => Self::EnabledByPolicy,+ _ => return None,+ })+ }++ /// Whether Skykeep opens at login, and why the switch cannot change that, if it cannot. A+ /// task turned off in Task Manager can only be turned on there again: Windows refuses the+ /// app's own request.+ pub fn item(self) -> (bool, Option<&'static str>) {+ match self {+ Self::Disabled => (false, None),+ Self::Enabled => (true, None),+ Self::DisabledByUser => (+ false,+ Some("Turned off in Task Manager. To open Skykeep at login, turn it on in Task Manager’s Startup apps."),+ ),+ Self::DisabledByPolicy => (false, Some("Turned off by your organization.")),+ Self::EnabledByPolicy => (true, Some("Turned on by your organization.")),+ }+ }+}++/// How this copy opens at login on Windows: the package's startup task when it runs with a+/// package identity (only then does the StartupTask API answer), else the `Run` key.+#[cfg(any(windows, test))]+fn uses_startup_task(package_identity: bool) -> bool {+ package_identity}/// Running inside a Flatpak.@@ -219,9 +275,72 @@ fn reg(args: &[&str]) -> std::io::Result<std::process::ExitStatus> {.status()}+/// The package's startup task, through Windows' own API. Each call blocks on Windows' answer,+/// so it is made off the async runtime.+#[cfg(windows)]+mod startup_task {+ use super::Startup;+ use windows::core::HSTRING;+ use windows::ApplicationModel::{StartupTask, StartupTaskState};++ /// The TaskId in the package's manifest.+ const ID: &str = "SkykeepStartup";++ fn task() -> windows::core::Result<StartupTask> {+ StartupTask::GetAsync(&HSTRING::from(ID))?.join()+ }++ fn known(state: StartupTaskState) -> Result<Startup, String> {+ Startup::from_state(state.0)+ .ok_or_else(|| format!("Windows says the startup task is in state {}.", state.0))+ }++ pub fn state() -> Result<Startup, String> {+ let task = task().map_err(|e| e.message())?;+ known(task.State().map_err(|e| e.message())?)+ }++ /// Asked on or off; what Windows then says, which may be other than asked (turned off in+ /// Task Manager, or held by policy).+ pub fn set(on: bool) -> Result<Startup, String> {+ let task = task().map_err(|e| e.message())?;+ if on {+ let state = task+ .RequestEnableAsync()+ .and_then(|op| op.join())+ .map_err(|e| e.message())?;+ return known(state);+ }+ // Held on by policy, Disable is refused; the state read next says why.+ if let Err(e) = task.Disable() {+ quiet!("the startup task was not turned off: {e}");+ }+ known(task.State().map_err(|e| e.message())?)+ }+}++/// The item Settings shows for the package's startup task in `state`.+#[cfg(windows)]+fn startup_item(state: Startup) -> LoginItem {+ let (on, elsewhere) = state.item();+ LoginItem {+ on,+ command: command(),+ honoured: true,+ available: true,+ elsewhere: elsewhere.map(str::to_string),+ }+}+#[cfg(windows)]#[tauri::command]pub async fn login_item_status(_app: AppHandle) -> Result<LoginItem, String> {+ if uses_startup_task(crate::package::family_name().is_some()) {+ let state = tauri::async_runtime::spawn_blocking(startup_task::state)+ .await+ .map_err(|e| e.to_string())??;+ return Ok(startup_item(state));+ }let on = tauri::async_runtime::spawn_blocking(|| {reg(&["query", RUN_KEY, "/v", RUN_VALUE]).is_ok_and(|s| s.success())})@@ -232,12 +351,19 @@ pub async fn login_item_status(_app: AppHandle) -> Result<LoginItem, String> {command: command(),honoured: true,available: true,+ elsewhere: None,})}#[cfg(windows)]#[tauri::command]pub async fn login_item_set(on: bool, app: AppHandle) -> Result<LoginItem, String> {+ if uses_startup_task(crate::package::family_name().is_some()) {+ let state = tauri::async_runtime::spawn_blocking(move || startup_task::set(on))+ .await+ .map_err(|e| e.to_string())??;+ return Ok(startup_item(state));+ }let line = command();let done = tauri::async_runtime::spawn_blocking(move || {if on {@@ -267,6 +393,7 @@ pub async fn login_item_status(app: AppHandle) -> Result<LoginItem, String> {command: format!("flatpak run {}", app.config().identifier),honoured: true,available: false,+ elsewhere: None,});}let on = entry(&app).is_some_and(|p| p.exists());@@ -278,6 +405,7 @@ pub async fn login_item_status(app: AppHandle) -> Result<LoginItem, String> {command: command(),honoured,available: true,+ elsewhere: None,})}@@ -324,6 +452,41 @@ mod tests {mod search_launch_tests {use super::*;+ /// Every state Windows reports for the package's startup task, as Settings shows it: on or+ /// off, and — when Task Manager or a policy holds it — why the switch cannot change it.+ #[test]+ fn the_startup_task_state_as_settings_shows_it() {+ let states: Vec<_> = (0..5).map(|i| Startup::from_state(i).unwrap()).collect();+ assert_eq!(+ states,+ [+ Startup::Disabled,+ Startup::DisabledByUser,+ Startup::Enabled,+ Startup::DisabledByPolicy,+ Startup::EnabledByPolicy+ ]+ );+ assert_eq!(Startup::from_state(5), None);+ assert_eq!(Startup::from_state(-1), None);+ assert_eq!(Startup::Enabled.item(), (true, None));+ assert_eq!(Startup::Disabled.item(), (false, None));+ let (on, why) = Startup::DisabledByUser.item();+ assert!(!on && why.unwrap().contains("Task Manager"));+ let (on, why) = Startup::DisabledByPolicy.item();+ assert!(!on && why.unwrap().contains("organization"));+ let (on, why) = Startup::EnabledByPolicy.item();+ assert!(on && why.unwrap().contains("organization"));+ }++ /// Only a copy with a package identity uses the startup task; the .exe and the .msi keep+ /// the Run key.+ #[test]+ fn only_a_package_uses_the_startup_task() {+ assert!(uses_startup_task(true));+ assert!(!uses_startup_task(false));+ }+/// Started by a search on GNOME (no tray): no window, signed in or not. It used to show/// the main window — or the sign-in screen — on every search after a quit.#[test]diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rsindex c933c6f..5afe650 100644--- a/src-tauri/src/main.rs+++ b/src-tauri/src/main.rs@@ -33,6 +33,8 @@ mod notes_cmds;#[cfg(target_os = "linux")]mod notices;mod outbox;+// Whether this copy is an MSIX package's (the Microsoft Store), and its app IDs if so.+mod package;mod photo_cache;mod photos;#[cfg(target_os = "linux")]diff --git a/src-tauri/src/package.rs b/src-tauri/src/package.rsnew file mode 100644index 0000000..20ab99b--- /dev/null+++ b/src-tauri/src/package.rs@@ -0,0 +1,103 @@+//! Skykeep installed as an MSIX package — from the Microsoft Store, or a test install of the same+//! package (packaging/windows/msix). Such a copy has a package identity: Windows knows it by its+//! package family name, updates it through the Store, and knows each of its seven Start-menu+//! entries by `<family name>!<application id>` alone. The manifest gives each entry the ID the+//! installers already use — `io.github.yashwanthkamireddi.Skykeep`, `….Skykeep.Notes` and so on —+//! so inside a package every app ID is the usual one with the family name in front.+//!+//! Elsewhere (Linux, the .exe and the .msi) there is no package and nothing here changes a thing.++use std::path::Path;++/// The package family name this process runs under, if it runs from a package.+#[cfg(windows)]+pub fn family_name() -> Option<String> {+ use std::sync::OnceLock;+ static FAMILY: OnceLock<Option<String>> = OnceLock::new();+ FAMILY+ .get_or_init(|| {+ use windows::Win32::Foundation::ERROR_INSUFFICIENT_BUFFER;+ use windows::Win32::Storage::Packaging::Appx::GetCurrentPackageFamilyName;+ let mut len = 0u32;+ // SAFETY: a length query with no buffer; Windows writes only `len`. A process with+ // no package answers APPMODEL_ERROR_NO_PACKAGE.+ if unsafe { GetCurrentPackageFamilyName(&mut len, None) } != ERROR_INSUFFICIENT_BUFFER {+ return None;+ }+ let mut buf = vec![0u16; len as usize];+ // SAFETY: a buffer of the `len` units Windows asked for, NUL included.+ let done = unsafe {+ GetCurrentPackageFamilyName(&mut len, Some(windows::core::PWSTR(buf.as_mut_ptr())))+ };+ if done.is_err() {+ return None;+ }+ let end = buf.iter().position(|&c| c == 0).unwrap_or(buf.len());+ let name = String::from_utf16_lossy(&buf[..end]);+ (!name.is_empty()).then_some(name)+ })+ .clone()+}++#[cfg(not(windows))]+pub fn family_name() -> Option<String> {+ None+}++/// The app ID Windows knows an entry by: `<family>!<id>` in a package, `id` itself otherwise.+#[cfg(any(windows, test))]+pub fn app_id(family: Option<&str>, id: &str) -> String {+ match family {+ Some(f) => format!("{f}!{id}"),+ None => id.to_string(),+ }+}++/// Whether a program at `exe` sits where Windows keeps installed packages+/// (`C:\Program Files\WindowsApps\<package>\skykeep.exe`, or an app execution alias under+/// `…\Microsoft\WindowsApps`): a copy only the Store, or whoever installed the package, may+/// replace — even started some way that left it without its package identity.+pub fn in_package_folder(exe: &Path) -> bool {+ exe.to_string_lossy()+ .split(['\\', '/'])+ .any(|part| part.eq_ignore_ascii_case("WindowsApps"))+}++/// Whether this copy is an MSIX package's: it runs with a package identity, or from where+/// packages are installed.+pub fn packaged() -> bool {+ family_name().is_some()+ || std::env::current_exe().is_ok_and(|exe| cfg!(windows) && in_package_folder(&exe))+}++#[cfg(test)]+mod tests {+ use super::*;++ #[test]+ fn app_ids_in_and_out_of_a_package() {+ let id = "io.github.yashwanthkamireddi.Skykeep.Notes";+ assert_eq!(app_id(None, id), id);+ assert_eq!(+ app_id(Some("Skykeep_8wekyb3d8bbwe"), id),+ "Skykeep_8wekyb3d8bbwe!io.github.yashwanthkamireddi.Skykeep.Notes"+ );+ }++ #[test]+ fn where_packages_are_installed() {+ let store = Path::new(+ r"C:\Program Files\WindowsApps\Skykeep_0.1.2.0_x64__8wekyb3d8bbwe\skykeep.exe",+ );+ assert!(in_package_folder(store));+ let alias = Path::new(r"C:\Users\a\AppData\Local\Microsoft\WindowsApps\skykeep.exe");+ assert!(in_package_folder(alias));+ let nsis = Path::new(r"C:\Users\a\AppData\Local\Skykeep\skykeep.exe");+ assert!(!in_package_folder(nsis));+ let msi = Path::new(r"C:\Program Files\Skykeep\skykeep.exe");+ assert!(!in_package_folder(msi));+ // A folder merely named like it is not the one.+ let lookalike = Path::new(r"C:\Users\a\MyWindowsAppsBackup\skykeep.exe");+ assert!(!in_package_folder(lookalike));+ }+}diff --git a/src-tauri/src/taskbar.rs b/src-tauri/src/taskbar.rsindex 453f4f8..7e14a8d 100644--- a/src-tauri/src/taskbar.rs+++ b/src-tauri/src/taskbar.rs@@ -9,6 +9,11 @@//! (packaging/windows). A window with the same ID as a shortcut is pinned as that shortcut;//! one with none to match is pinned by the relaunch command it carries here.//!+//! From an MSIX package (the Microsoft Store, package.rs) Windows knows the package's entries+//! only as `<family name>!<application id>`, and a process may claim no other ID; the manifest+//! (packaging/windows/msix) gives the entries the same IDs as above, so there each ID is the+//! usual one with the family name in front.+//!//! A jump list's tasks are written by the running app; no installer can declare them. Each is//! a command line the app already takes (`--new note`, `--app notes`), handed by the single//! instance to the Skykeep already running.@@ -38,13 +43,23 @@ use windows::Win32::UI::Shell::{use crate::apps::{launch_name, APPS, NEW};/// Skykeep's AppUserModelID: the identifier the installer was built with, so it is the one on-/// its shortcuts even in a launch run under the old identifier (migrate.rs).+/// its shortcuts even in a launch run under the old identifier (migrate.rs) — in a package,+/// with the package's family name in front.static APP_ID: OnceLock<String> = OnceLock::new();+/// The ID Skykeep's toasts are sent as: the one claimed, or `identifier` before any claim.+pub fn own_id(identifier: &str) -> String {+ APP_ID.get().cloned().unwrap_or_else(|| {+ crate::package::app_id(crate::package::family_name().as_deref(), identifier)+ })+}+/// Said before any window is made: every window, toast and jump list after it is Skykeep's./// The jump lists are written meanwhile, off the startup path.pub fn claim(identifier: &str) {- let id = APP_ID.get_or_init(|| identifier.to_string());+ let id = APP_ID.get_or_init(|| {+ crate::package::app_id(crate::package::family_name().as_deref(), identifier)+ });// SAFETY: a plain call with a valid, NUL-terminated string the shell copies.if let Err(e) = unsafe { SetCurrentProcessExplicitAppUserModelID(&HSTRING::from(id.as_str())) }{diff --git a/src-tauri/src/updates.rs b/src-tauri/src/updates.rsindex 646d3e3..a5e24e5 100644--- a/src-tauri/src/updates.rs+++ b/src-tauri/src/updates.rs@@ -2,7 +2,8 @@//!//! Only a copy installed from the AppImage, the Windows installer (.exe) or the .msi updates//! itself. A .deb, an .rpm, the AUR, a distribution's own package, Scoop or the Flatpak is-//! updated by its package manager and is never offered an update here ([`install_kind`]).+//! updated by its package manager and is never offered an update here ([`install_kind`]); nor+//! is the Microsoft Store's MSIX package, which the Store updates (package.rs).//!//! Shortly after launch, and about once a day after that, the latest release's `latest.json`//! is read through a client that can reach GitHub's release servers and nothing else@@ -53,6 +54,8 @@ pub enum Install {PackageManager,/// Flatpak updates it.Flatpak,+ /// An MSIX package, from the Microsoft Store: the Store updates it.+ Store,/// A development build, run from the source.Development,/// Anything else, such as a program copied by hand: nothing here can replace it safely.@@ -62,19 +65,25 @@ pub enum Install {/// Who updates this copy. `bundle` is what Tauri's bundler wrote into the program when it/// packaged it (none for a `cargo build`, which is how the AUR and the Flatpak build it);/// `appimage` whether it runs as an AppImage now, which is the file the update replaces;-/// `scoop` whether Scoop unpacked it (packaging/scoop): its installer, run here, would put a-/// second copy beside Scoop's.+/// `msix` whether it is an MSIX package's — whatever bundle its program was taken from, a+/// package's files are Windows' to replace, never this program's; `scoop` whether Scoop+/// unpacked it (packaging/scoop): its installer, run here, would put a second copy beside+/// Scoop's.pub fn install_kind(os: &str,bundle: Option<BundleType>,appimage: bool,flatpak: bool,+ msix: bool,scoop: bool,debug: bool,) -> Install {if debug {return Install::Development;}+ if msix {+ return Install::Store;+ }if flatpak {return Install::Flatpak;}@@ -116,6 +125,7 @@ pub fn this_install(app: &AppHandle) -> Install {tauri::utils::platform::bundle_type(),appimage,flatpak,+ crate::package::packaged(),scoop,cfg!(debug_assertions),)@@ -1007,6 +1017,7 @@ fn refuse_unless_here(app: &AppHandle) -> Result<(), String> {Install::Here => Ok(()),Install::PackageManager => Err("Updates come through your package manager.".into()),Install::Flatpak => Err("Updates come through Flatpak.".into()),+ Install::Store => Err("Updates come through the Microsoft Store.".into()),Install::Development => {Err("This is a development build, so it doesn't update itself.".into())}@@ -1042,7 +1053,8 @@ mod tests {#[test]fn who_updates_each_kind_of_install() {use BundleType::*;- let here = |os, b, ai| install_kind(os, b, ai, false, false, false);+ // Arguments after `appimage`: flatpak, msix, scoop, debug.+ let here = |os, b, ai| install_kind(os, b, ai, false, false, false, false);assert_eq!(here("linux", Some(AppImage), true), Install::Here);assert_eq!(here("linux", Some(AppImage), false), Install::Manual);assert_eq!(here("linux", Some(Deb), false), Install::PackageManager);@@ -1054,28 +1066,41 @@ mod tests {assert_eq!(here("windows", Some(Nsis), false), Install::Here);assert_eq!(here("windows", Some(Msi), false), Install::Here);assert_eq!(here("windows", None, false), Install::Manual);- // Unpacked by Scoop, which updates it.+ // Unpacked by Scoop, which updates it; the same files seen on Linux mean nothing.assert_eq!(- install_kind("windows", Some(Nsis), false, false, true, false),+ install_kind("windows", Some(Nsis), false, false, false, true, false),Install::PackageManager);assert_eq!(- install_kind("linux", Some(AppImage), true, false, true, false),+ install_kind("linux", Some(AppImage), true, false, false, true, false),Install::Here);assert_eq!(here("macos", Some(App), false), Install::Manual);assert_eq!(- install_kind("linux", Some(AppImage), true, true, false, false),+ install_kind("linux", Some(AppImage), true, true, false, false, false),Install::Flatpak);assert_eq!(- install_kind("linux", None, false, true, false, false),+ install_kind("linux", None, false, true, false, false, false),Install::Flatpak);assert_eq!(- install_kind("windows", Some(Nsis), false, false, false, true),+ install_kind("windows", Some(Nsis), false, false, false, false, true),Install::Development);+ // The Store's package never updates itself: its program is the .msi's, bundle type and+ // all, but the Store replaces it — and it wins over anything Scoop-like beside it.+ for bundle in [Some(Msi), Some(Nsis), None] {+ let bundle = || bundle.clone();+ assert_eq!(+ install_kind("windows", bundle(), false, false, true, false, false),+ Install::Store+ );+ assert_eq!(+ install_kind("windows", bundle(), false, false, true, true, false),+ Install::Store+ );+ }}#[test]diff --git a/src/lib/ipc.ts b/src/lib/ipc.tsindex bc2f4c3..2d90ae0 100644--- a/src/lib/ipc.ts+++ b/src/lib/ipc.ts@@ -88,7 +88,7 @@ export type UploadEvent = {export const UPDATE = "quince://update";/** Who updates this copy of Skykeep: itself, or the package manager it came from. */-export type UpdateInstall = "here" | "packageManager" | "flatpak" | "development" | "manual";+export type UpdateInstall = "here" | "packageManager" | "flatpak" | "store" | "development" | "manual";export type UpdateStatus = {install: UpdateInstall;/** Check for Updates Automatically. */@@ -1019,6 +1019,9 @@ export type LoginItem = {honoured: boolean;/** Whether Skykeep keeps the login entry itself (not in the Flatpak). */available?: boolean;+ /** Why the switch can't change it: Windows holds the Store install's startup task off in+ * Task Manager, or on or off by policy. */+ elsewhere?: string | null;};export type DriveFolder = {diff --git a/src/screens/SettingsView.tsx b/src/screens/SettingsView.tsxindex 4c26c20..3a43ea7 100644--- a/src/screens/SettingsView.tsx+++ b/src/screens/SettingsView.tsx@@ -750,9 +750,11 @@ export function SettingsView({ onSignOut }: { onSignOut: (keep: boolean) => Prom<span className="settings-label settings-stack">Open at Login<span className="settings-hint">- {login?.on && !login.honoured- ? "This desktop doesn't open apps at login by itself. Add this to its startup:"- : "Starts in the background, so alerts ring and changes sync"}+ {login?.elsewhere+ ? login.elsewhere+ : login?.on && !login.honoured+ ? "This desktop doesn't open apps at login by itself. Add this to its startup:"+ : "Starts in the background, so alerts ring and changes sync"}</span>{login?.on && !login.honoured && <code className="settings-command">{login.command}</code>}</span>@@ -761,7 +763,7 @@ export function SettingsView({ onSignOut }: { onSignOut: (keep: boolean) => Promrole="switch"aria-checked={login?.on ?? false}aria-label="Open at Login"- disabled={!login || loginBusy}+ disabled={!login || loginBusy || Boolean(login.elsewhere)}onClick={() => {if (!login) return;const was = login;@@ -978,6 +980,7 @@ function UpdatesGroup() {const elsewhere: Record<string, string> = {packageManager: "Updates come through your package manager.",flatpak: "Updates come through Flatpak.",+ store: "Updates come through the Microsoft Store.",development: "This is a development build, so it doesn’t update itself.",manual: "This copy wasn’t installed by Skykeep’s installer, so it doesn’t update itself.",};