M6 Windows: composizione condivisa Febe.App per Server e Desktop; Febe per Windows (WPF) con l'interfaccia in WebView2, area di notifica, istanza unica, «Browser di Febe» su WebView2 con CDP filtrato (WebView2CdpSession) e ripieghi di S2 (composizione, Edge), guscio nativo, avvisi, spostamento verificato della cartella dei dati, icona del marchio; un solo Febe.exe, installatore NSIS e zip portabile; guida docs/windows.md e prove dal vivo S1–S3
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Mzbb6zeFTjT6Rp8b92AVkA
This commit is contained in:
73 files changed
+7914
-699
No files matched your search
@@ -0,0 +1,75 @@
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
namespace Febe.Desktop.Core;
|
||||
|
||||
/// <summary>
|
||||
/// One Febe at a time for a Data folder (spec §12, rule 4): the names of the mutex and of the pipe through which a
|
||||
/// second launch asks the first one to show its window. Derived from the Data folder, so that a second account with
|
||||
/// folders of its own (spec §3) is a second instance; the same folder is the same instance whatever the case of its
|
||||
/// letters.
|
||||
/// </summary>
|
||||
public static class InstanceIdentity
|
||||
{
|
||||
/// <summary>A short stable name for a Data folder: «Febe-» and 16 hexadecimal digits of SHA-256 of its full path.</summary>
|
||||
public static string For(string dataFolder)
|
||||
{
|
||||
ArgumentException.ThrowIfNullOrWhiteSpace(dataFolder);
|
||||
var full = Path.TrimEndingDirectorySeparator(Path.GetFullPath(dataFolder)).ToUpperInvariant();
|
||||
var hash = SHA256.HashData(Encoding.UTF8.GetBytes(full));
|
||||
return "Febe-" + Convert.ToHexString(hash, 0, 8).ToLowerInvariant();
|
||||
}
|
||||
|
||||
/// <summary>The named mutex, in the session namespace (one per logged-in user).</summary>
|
||||
public static string MutexName(string dataFolder) => @"Local\" + For(dataFolder);
|
||||
|
||||
/// <summary>The named pipe of the first instance (current user only).</summary>
|
||||
public static string PipeName(string dataFolder) => For(dataFolder);
|
||||
}
|
||||
|
||||
/// <summary>What a second launch asks the running Febe.</summary>
|
||||
public enum InstanceRequest
|
||||
{
|
||||
/// <summary>Show the window (a normal launch: Start menu, desktop shortcut).</summary>
|
||||
Show,
|
||||
|
||||
/// <summary>Nothing visible (a start with the computer while Febe already runs).</summary>
|
||||
StayHidden,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The one-line messages between two launches of Febe, over a pipe that only the current user can open. A message
|
||||
/// carries no path and no secret; anything else than the two known lines is ignored.
|
||||
/// </summary>
|
||||
public static class InstanceMessages
|
||||
{
|
||||
private const string Prefix = "FEBE1 ";
|
||||
|
||||
/// <summary>The longest message read (anything longer is not one of ours).</summary>
|
||||
public const int MaxLength = 64;
|
||||
|
||||
/// <summary>The message a second launch with these options sends.</summary>
|
||||
public static string For(DesktopOptions options)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(options);
|
||||
return Format(options.StartHidden ? InstanceRequest.StayHidden : InstanceRequest.Show);
|
||||
}
|
||||
|
||||
public static string Format(InstanceRequest request) => Prefix + (request == InstanceRequest.StayHidden ? "nascosto" : "mostra");
|
||||
|
||||
/// <summary>The request in a message; null for anything that is not one of ours.</summary>
|
||||
public static InstanceRequest? Parse(string? message)
|
||||
{
|
||||
if (message is null || message.Length > MaxLength)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return message.Trim() switch
|
||||
{
|
||||
"FEBE1 mostra" => InstanceRequest.Show,
|
||||
"FEBE1 nascosto" => InstanceRequest.StayHidden,
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user