diff options
| author | JP Dillingham <jpdillingham@gmail.com> | 2021-09-09 09:01:03 -0500 |
|---|---|---|
| committer | JP Dillingham <jpdillingham@gmail.com> | 2021-09-09 09:01:03 -0500 |
| commit | f56d48890878ff910d9100c77558bf901a58a47b (patch) | |
| tree | f1bf0b506ae54b35da161dfc908ac6541044826b /src/slskd/Application/ApplicationState.cs | |
| parent | d72995333092c7bc31528b23d770024034957137 (diff) | |
| download | slskd-f56d48890878ff910d9100c77558bf901a58a47b.tar.gz | |
group state records
Diffstat (limited to 'src/slskd/Application/ApplicationState.cs')
| -rw-r--r-- | src/slskd/Application/ApplicationState.cs | 68 |
1 files changed, 63 insertions, 5 deletions
diff --git a/src/slskd/Application/ApplicationState.cs b/src/slskd/Application/ApplicationState.cs index e3b41a66..c9322eb3 100644 --- a/src/slskd/Application/ApplicationState.cs +++ b/src/slskd/Application/ApplicationState.cs @@ -17,19 +17,77 @@ namespace slskd { + using System.Net; + using System.Text.Json.Serialization; + using Soulseek; + /// <summary> /// Application service state. /// </summary> - public record ApplicationState() + public record ApplicationState { - public string Version { get; init; } = Program.InformationalVersion; - public string LatestVersion { get; init; } = Program.InformationalVersion; - public bool? UpdateAvailable { get; init; } = null; - public bool IsCanary { get; init; } = Program.IsCanary; + public VersionState Version { get; init; } = new VersionState(); public bool PendingReconnect { get; init; } public bool PendingRestart { get; init; } public bool PendingShareRescan { get; init; } public ServerState Server { get; init; } = new ServerState(); public SharedFileCacheState SharedFileCache { get; init; } = new SharedFileCacheState(); } + + public record VersionState + { + public string Current { get; init; } = Program.InformationalVersion; + public string Latest { get; init; } = null; + public bool? IsUpdateAvailable { get; init; } = null; + public bool IsCanary { get; init; } = Program.IsCanary; + } + + public record ServerState + { + public string Address { get; init; } + + [JsonConverter(typeof(IPEndPointConverter))] + public IPEndPoint IPEndPoint { get; init; } + public SoulseekClientStates State { get; init; } + public string Username { get; init; } + public bool IsConnected => State.HasFlag(SoulseekClientStates.Connected); + public bool IsLoggedIn => State.HasFlag(SoulseekClientStates.LoggedIn); + public bool IsTransitioning => State.HasFlag(SoulseekClientStates.Connecting) || State.HasFlag(SoulseekClientStates.Disconnecting) || State.HasFlag(SoulseekClientStates.LoggingIn); + } + + /// <summary> + /// Share cache state. + /// </summary> + public record SharedFileCacheState + { + /// <summary> + /// Gets a value indicating whether the cache is being filled. + /// </summary> + public bool Filling { get; init; } = false; + + /// <summary> + /// Gets a value indicating whether the cache is faulted. + /// </summary> + public bool Faulted { get; init; } = false; + + /// <summary> + /// Gets the current fill progress. + /// </summary> + public double FillProgress { get; init; } + + /// <summary> + /// Gets the number of cached directories. + /// </summary> + public int Directories { get; init; } + + /// <summary> + /// Gets the number of cached files. + /// </summary> + public int Files { get; init; } + + /// <summary> + /// Gets the number of directories excluded by filters. + /// </summary> + public int ExcludedDirectories { get; init; } + } }
\ No newline at end of file |
