aboutsummaryrefslogtreecommitdiffstats
path: root/src/slskd/Application/Management
diff options
context:
space:
mode:
authorJP Dillingham <jpdillingham@gmail.com>2021-08-05 07:53:24 -0500
committerJP Dillingham <jpdillingham@gmail.com>2021-08-05 07:53:24 -0500
commita56bfb47abe33d259ba9d12d492123ab4baa3739 (patch)
tree74a52bed87b31733b79cf8b5c14e33a6c5efa479 /src/slskd/Application/Management
parent86aeebf6a900e44461aa0094b8bf3cf1d81adcbe (diff)
downloadslskd-a56bfb47abe33d259ba9d12d492123ab4baa3739.tar.gz
rename more stuff
Diffstat (limited to 'src/slskd/Application/Management')
-rw-r--r--src/slskd/Application/Management/API/Controllers/ApplicationController.cs2
-rw-r--r--src/slskd/Application/Management/API/Controllers/ConfigurationController.cs8
-rw-r--r--src/slskd/Application/Management/API/Controllers/ServerController.cs6
-rw-r--r--src/slskd/Application/Management/IManagementService.cs27
-rw-r--r--src/slskd/Application/Management/ManagementService.cs61
5 files changed, 55 insertions, 49 deletions
diff --git a/src/slskd/Application/Management/API/Controllers/ApplicationController.cs b/src/slskd/Application/Management/API/Controllers/ApplicationController.cs
index 43029aa5..dd115786 100644
--- a/src/slskd/Application/Management/API/Controllers/ApplicationController.cs
+++ b/src/slskd/Application/Management/API/Controllers/ApplicationController.cs
@@ -50,7 +50,7 @@ namespace slskd.Management.API
[Authorize]
public IActionResult State()
{
- return Ok(Management.GetServiceState());
+ return Ok(Management.ApplicationState);
}
/// <summary>
diff --git a/src/slskd/Application/Management/API/Controllers/ConfigurationController.cs b/src/slskd/Application/Management/API/Controllers/ConfigurationController.cs
index c44cf2f2..f2b90718 100644
--- a/src/slskd/Application/Management/API/Controllers/ConfigurationController.cs
+++ b/src/slskd/Application/Management/API/Controllers/ConfigurationController.cs
@@ -17,12 +17,11 @@
using Microsoft.Extensions.Options;
-namespace slskd.Application.Management.API
+namespace slskd.Management.API
{
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using slskd.Management;
- using slskd.Shares;
/// <summary>
/// Configuration.
@@ -36,17 +35,14 @@ namespace slskd.Application.Management.API
{
public ConfigurationController(
IOptionsSnapshot<Options> optionsShapshot,
- IStateMonitor<SharedFileCacheState> sharedFileCacheMonitor,
IManagementService managementService)
{
OptionsShapshot = optionsShapshot;
- SharedFileCacheMonitor = sharedFileCacheMonitor;
ManagementService = managementService;
}
private IManagementService ManagementService { get; }
private IOptionsSnapshot<Options> OptionsShapshot { get; }
- private IStateMonitor<SharedFileCacheState> SharedFileCacheMonitor { get; }
[HttpGet]
[Route("")]
@@ -62,7 +58,7 @@ namespace slskd.Application.Management.API
[Authorize]
public IActionResult RescanSharesAsync()
{
- if (SharedFileCacheMonitor.CurrentValue.Filling)
+ if (ManagementService.SharedFileCacheState.Filling)
{
return Conflict("A share scan is already in progress.");
}
diff --git a/src/slskd/Application/Management/API/Controllers/ServerController.cs b/src/slskd/Application/Management/API/Controllers/ServerController.cs
index 6468063c..fc47f475 100644
--- a/src/slskd/Application/Management/API/Controllers/ServerController.cs
+++ b/src/slskd/Application/Management/API/Controllers/ServerController.cs
@@ -50,7 +50,7 @@ namespace slskd.Management.API
[ProducesResponseType(403)]
public async Task<IActionResult> Connect()
{
- if (!Management.GetServerState().IsConnected)
+ if (!Management.ServerState.IsConnected)
{
await Management.ConnectServerAsync();
}
@@ -70,7 +70,7 @@ namespace slskd.Management.API
[ProducesResponseType(403)]
public IActionResult Disconnect([FromBody] string message)
{
- if (Management.GetServerState().IsConnected)
+ if (Management.ServerState.IsConnected)
{
Management.DisconnectServer(message);
}
@@ -90,7 +90,7 @@ namespace slskd.Management.API
[ProducesResponseType(403)]
public IActionResult Get()
{
- return Ok(Management.GetServerState());
+ return Ok(Management.ServerState);
}
}
} \ No newline at end of file
diff --git a/src/slskd/Application/Management/IManagementService.cs b/src/slskd/Application/Management/IManagementService.cs
index 6c5f3784..9a06d961 100644
--- a/src/slskd/Application/Management/IManagementService.cs
+++ b/src/slskd/Application/Management/IManagementService.cs
@@ -26,6 +26,21 @@ namespace slskd.Management
public interface IManagementService
{
/// <summary>
+ /// Gets the current state of the slskd service.
+ /// </summary>
+ ApplicationState ApplicationState { get; }
+
+ /// <summary>
+ /// Gets the current state of the connection to the Soulseek server.
+ /// </summary>
+ ServerState ServerState { get; }
+
+ /// <summary>
+ /// Gets the current state of the shared file cache.
+ /// </summary>
+ SharedFileCacheState SharedFileCacheState { get; }
+
+ /// <summary>
/// Connects the Soulseek client to the server using the configured username and password.
/// </summary>
/// <returns>The operation context.</returns>
@@ -39,18 +54,6 @@ namespace slskd.Management
void DisconnectServer(string message = null, Exception exception = null);
/// <summary>
- /// Gets the current state of the connection to the Soulseek server.
- /// </summary>
- /// <returns>The current server state.</returns>
- ServerState GetServerState();
-
- /// <summary>
- /// Gets the current state of the slskd service.
- /// </summary>
- /// <returns></returns>
- ServiceState GetServiceState();
-
- /// <summary>
/// Re-scans shared directories.
/// </summary>
/// <returns>The operation context.</returns>
diff --git a/src/slskd/Application/Management/ManagementService.cs b/src/slskd/Application/Management/ManagementService.cs
index 2f79f496..3d7bd442 100644
--- a/src/slskd/Application/Management/ManagementService.cs
+++ b/src/slskd/Application/Management/ManagementService.cs
@@ -1,13 +1,18 @@
// <copyright file="ManagementService.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 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.
+// 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/.
+// 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>
using Microsoft.Extensions.Options;
@@ -16,7 +21,6 @@ namespace slskd.Management
{
using System;
using System.Threading.Tasks;
- using slskd.Shares;
using Soulseek;
/// <summary>
@@ -33,7 +37,7 @@ namespace slskd.Management
/// <param name="sharedFileCache">The shared file cache.</param>
public ManagementService(
IOptionsMonitor<Options> optionsMonitor,
- IStateMonitor<ServiceState> serviceStateMonitor,
+ IStateMonitor<ApplicationState> serviceStateMonitor,
ISoulseekClient soulseekClient,
ISharedFileCache sharedFileCache)
{
@@ -43,10 +47,32 @@ namespace slskd.Management
SharedFileCache = sharedFileCache;
}
+ /// <summary>
+ /// Gets the current state of the slskd service.
+ /// </summary>
+ public ApplicationState ApplicationState => ServiceStateMonitor.CurrentValue;
+
+ /// <summary>
+ /// Gets the current state of the connection to the Soulseek server.
+ /// </summary>
+ public ServerState ServerState =>
+ new ServerState()
+ {
+ Address = Client.Address,
+ IPEndPoint = Client.IPEndPoint,
+ State = Client.State,
+ Username = Client.Username,
+ };
+
+ /// <summary>
+ /// Gets the current state of the connection to the Soulseek server.
+ /// </summary>
+ public SharedFileCacheState SharedFileCacheState => SharedFileCache.State.CurrentValue;
+
private ISoulseekClient Client { get; }
private Options Options => OptionsMonitor.CurrentValue;
private IOptionsMonitor<Options> OptionsMonitor { get; }
- private IStateMonitor<ServiceState> ServiceStateMonitor { get; }
+ private IStateMonitor<ApplicationState> ServiceStateMonitor { get; }
private ISharedFileCache SharedFileCache { get; }
/// <summary>
@@ -65,25 +91,6 @@ namespace slskd.Management
=> Client.Disconnect(message, exception ?? new IntentionalDisconnectException(message));
/// <summary>
- /// Gets the current state of the connection to the Soulseek server.
- /// </summary>
- /// <returns>The current server state.</returns>
- public ServerState GetServerState() =>
- new ServerState()
- {
- Address = Client.Address,
- IPEndPoint = Client.IPEndPoint,
- State = Client.State,
- Username = Client.Username,
- };
-
- /// <summary>
- /// Gets the current state of the slskd service.
- /// </summary>
- /// <returns></returns>
- public ServiceState GetServiceState() => ServiceStateMonitor.CurrentValue;
-
- /// <summary>
/// Re-scans shared directories.
/// </summary>
/// <returns>The operation context.</returns>