aboutsummaryrefslogtreecommitdiffstats
path: root/src/slskd/Application/ApplicationState.cs
diff options
context:
space:
mode:
authorJP Dillingham <jpdillingham@gmail.com>2021-09-09 21:16:40 -0500
committerGitHub <noreply@github.com>2021-09-09 21:16:40 -0500
commit583325356493c0123a6410e6aa34e60bf148f219 (patch)
treef12cc20285998bbdf5d3313c621429f8096c87ea /src/slskd/Application/ApplicationState.cs
parent3d645132c2613bcd376ec710e6d1d02e9912cf15 (diff)
parenteae8db1aecdae631edc0f2d370d3c704d49c58b9 (diff)
downloadslskd-583325356493c0123a6410e6aa34e60bf148f219.tar.gz
Merge pull request #191 from slskd/version-check
Add a version check on startup, and elements to the UI to indicate when a new version is available
Diffstat (limited to 'src/slskd/Application/ApplicationState.cs')
-rw-r--r--src/slskd/Application/ApplicationState.cs65
1 files changed, 64 insertions, 1 deletions
diff --git a/src/slskd/Application/ApplicationState.cs b/src/slskd/Application/ApplicationState.cs
index 9db79f5c..c9322eb3 100644
--- a/src/slskd/Application/ApplicationState.cs
+++ b/src/slskd/Application/ApplicationState.cs
@@ -17,14 +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 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