aboutsummaryrefslogtreecommitdiffstats
path: root/src/slskd/Application
diff options
context:
space:
mode:
authorJP Dillingham <jpdillingham@gmail.com>2021-09-12 21:19:58 -0500
committerJP Dillingham <jpdillingham@gmail.com>2021-09-12 21:19:58 -0500
commitfbe4be554fb16ca4cd37288171c2e086c6f7ee20 (patch)
treebd2db13de253a69be26f2060505a0da4b462a280 /src/slskd/Application
parent8970760edc057ee5f8841aeb6fca312168bd5c8a (diff)
downloadslskd-fbe4be554fb16ca4cd37288171c2e086c6f7ee20.tar.gz
rename ApplicationState to State
Diffstat (limited to 'src/slskd/Application')
-rw-r--r--src/slskd/Application/Application.cs8
-rw-r--r--src/slskd/Application/ApplicationState.cs93
-rw-r--r--src/slskd/Application/Management/API/Controllers/ApplicationController.cs4
-rw-r--r--src/slskd/Application/Management/API/Controllers/ConfigurationController.cs4
-rw-r--r--src/slskd/Application/Management/API/Controllers/ServerController.cs4
-rw-r--r--src/slskd/Application/Messaging/API/Controllers/ConversationsController.cs4
-rw-r--r--src/slskd/Application/Messaging/API/Controllers/RoomsController.cs4
7 files changed, 14 insertions, 107 deletions
diff --git a/src/slskd/Application/Application.cs b/src/slskd/Application/Application.cs
index 73c82d11..1e5f3584 100644
--- a/src/slskd/Application/Application.cs
+++ b/src/slskd/Application/Application.cs
@@ -45,7 +45,7 @@ namespace slskd
public Application(
OptionsAtStartup optionsAtStartup,
IOptionsMonitor<Options> optionsMonitor,
- IManagedState<ApplicationState> state,
+ IManagedState<State> state,
ITransferTracker transferTracker,
IBrowseTracker browseTracker,
IConversationTracker conversationTracker,
@@ -154,7 +154,7 @@ namespace slskd
private IRoomTracker RoomTracker { get; set; }
private ISharedFileCache SharedFileCache { get; set; }
private DateTime SharesRefreshStarted { get; set; }
- private IManagedState<ApplicationState> State { get; }
+ private IManagedState<State> State { get; }
private ITransferTracker TransferTracker { get; set; }
public Task AcknowledgePrivateMessageAsync(int id) => SoulseekClient.AcknowledgePrivateMessageAsync(id);
@@ -502,7 +502,7 @@ namespace slskd
private void Client_StateChanged(object sender, SoulseekClientStateChangedEventArgs e)
{
- State.SetValue(state => state with { Server = new ServerState() { Address = Client.Address, IPEndPoint = Client.IPEndPoint, State = Client.State, Username = Client.Username } });
+ State.SetValue(state => state with { Server = state.Server with { Address = Client.Address, IPEndPoint = Client.IPEndPoint, State = Client.State, Username = Client.Username } });
}
private void Client_TransferProgressUpdated(object sender, TransferProgressUpdatedEventArgs args)
@@ -844,7 +844,7 @@ namespace slskd
}
}
- private void State_OnChange((ApplicationState Previous, ApplicationState Current) state)
+ private void State_OnChange((State Previous, State Current) state)
{
Logger.Debug("State changed from {Previous} to {Current}", state.Previous.ToJson(), state.Current.ToJson());
}
diff --git a/src/slskd/Application/ApplicationState.cs b/src/slskd/Application/ApplicationState.cs
deleted file mode 100644
index c9322eb3..00000000
--- a/src/slskd/Application/ApplicationState.cs
+++ /dev/null
@@ -1,93 +0,0 @@
-// <copyright file="ApplicationState.cs" company="slskd Team">
-// Copyright (c) slskd Team. All rights reserved.
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU Affero General Public License as published
-// by the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU Affero General Public License for more details.
-//
-// You should have received a copy of the GNU Affero General Public License
-// along with this program. If not, see https://www.gnu.org/licenses/.
-// </copyright>
-
-namespace slskd
-{
- using System.Net;
- using System.Text.Json.Serialization;
- using Soulseek;
-
- /// <summary>
- /// Application service state.
- /// </summary>
- 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
diff --git a/src/slskd/Application/Management/API/Controllers/ApplicationController.cs b/src/slskd/Application/Management/API/Controllers/ApplicationController.cs
index 8115b3fc..470e5a30 100644
--- a/src/slskd/Application/Management/API/Controllers/ApplicationController.cs
+++ b/src/slskd/Application/Management/API/Controllers/ApplicationController.cs
@@ -37,7 +37,7 @@ namespace slskd.Management.API
public ApplicationController(
IHostApplicationLifetime lifetime,
IApplication application,
- IStateMonitor<ApplicationState> applicationStateMonitor)
+ IStateMonitor<State> applicationStateMonitor)
{
Lifetime = lifetime;
Application = application;
@@ -45,7 +45,7 @@ namespace slskd.Management.API
}
private IApplication Application { get; }
- private IStateMonitor<ApplicationState> ApplicationStateMonitor { get; }
+ private IStateMonitor<State> ApplicationStateMonitor { get; }
private IHostApplicationLifetime Lifetime { get; }
/// <summary>
diff --git a/src/slskd/Application/Management/API/Controllers/ConfigurationController.cs b/src/slskd/Application/Management/API/Controllers/ConfigurationController.cs
index b8c81f84..c28c5c7e 100644
--- a/src/slskd/Application/Management/API/Controllers/ConfigurationController.cs
+++ b/src/slskd/Application/Management/API/Controllers/ConfigurationController.cs
@@ -36,7 +36,7 @@ namespace slskd.Management.API
public ConfigurationController(
IApplication application,
IOptionsSnapshot<Options> optionsShapshot,
- IStateMonitor<ApplicationState> applicationStateMonitor)
+ IStateMonitor<State> applicationStateMonitor)
{
Application = application;
OptionsShapshot = optionsShapshot;
@@ -45,7 +45,7 @@ namespace slskd.Management.API
private IApplication Application { get; }
private IOptionsSnapshot<Options> OptionsShapshot { get; }
- private IStateMonitor<ApplicationState> ApplicationStateMonitor { get; }
+ private IStateMonitor<State> ApplicationStateMonitor { get; }
[HttpGet]
[Route("")]
diff --git a/src/slskd/Application/Management/API/Controllers/ServerController.cs b/src/slskd/Application/Management/API/Controllers/ServerController.cs
index 127b59c0..f929b46e 100644
--- a/src/slskd/Application/Management/API/Controllers/ServerController.cs
+++ b/src/slskd/Application/Management/API/Controllers/ServerController.cs
@@ -33,14 +33,14 @@ namespace slskd.Management.API
{
public ServerController(
IApplication application,
- IStateMonitor<ApplicationState> applicationStateMonitor)
+ IStateMonitor<State> applicationStateMonitor)
{
Application = application;
ApplicationStateMonitor = applicationStateMonitor;
}
private IApplication Application { get; }
- private IStateMonitor<ApplicationState> ApplicationStateMonitor { get; }
+ private IStateMonitor<State> ApplicationStateMonitor { get; }
/// <summary>
/// Connects the client.
diff --git a/src/slskd/Application/Messaging/API/Controllers/ConversationsController.cs b/src/slskd/Application/Messaging/API/Controllers/ConversationsController.cs
index b3c07690..961b8ca8 100644
--- a/src/slskd/Application/Messaging/API/Controllers/ConversationsController.cs
+++ b/src/slskd/Application/Messaging/API/Controllers/ConversationsController.cs
@@ -42,7 +42,7 @@ namespace slskd.Messaging.API
/// <param name="tracker"></param>
public ConversationsController(
IApplication application,
- IStateMonitor<ApplicationState> applicationStateMonotor,
+ IStateMonitor<State> applicationStateMonotor,
IConversationTracker tracker)
{
Application = application;
@@ -51,7 +51,7 @@ namespace slskd.Messaging.API
}
private IApplication Application { get; }
- private IStateMonitor<ApplicationState> ApplicationStateMonitor { get; }
+ private IStateMonitor<State> ApplicationStateMonitor { get; }
private IConversationTracker Tracker { get; }
/// <summary>
diff --git a/src/slskd/Application/Messaging/API/Controllers/RoomsController.cs b/src/slskd/Application/Messaging/API/Controllers/RoomsController.cs
index d7b605d1..07b58f6f 100644
--- a/src/slskd/Application/Messaging/API/Controllers/RoomsController.cs
+++ b/src/slskd/Application/Messaging/API/Controllers/RoomsController.cs
@@ -38,7 +38,7 @@ namespace slskd.Messaging.API
{
public RoomsController(
IApplication application,
- IStateMonitor<ApplicationState> applicationStateMonitor,
+ IStateMonitor<State> applicationStateMonitor,
IRoomTracker tracker)
{
Application = application;
@@ -47,7 +47,7 @@ namespace slskd.Messaging.API
}
private IApplication Application { get; }
- private IStateMonitor<ApplicationState> ApplicationStateMonitor { get; }
+ private IStateMonitor<State> ApplicationStateMonitor { get; }
private IRoomTracker Tracker { get; }
/// <summary>