From acd293a58a8efe20f98d8702d4823fae5ef81316 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Fri, 10 Sep 2021 18:21:23 -0500 Subject: remove I/ManagementService --- .../Application/Management/ManagementService.cs | 102 --------------------- 1 file changed, 102 deletions(-) delete mode 100644 src/slskd/Application/Management/ManagementService.cs (limited to 'src/slskd/Application/Management/ManagementService.cs') diff --git a/src/slskd/Application/Management/ManagementService.cs b/src/slskd/Application/Management/ManagementService.cs deleted file mode 100644 index 4319c9e3..00000000 --- a/src/slskd/Application/Management/ManagementService.cs +++ /dev/null @@ -1,102 +0,0 @@ -// -// 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/. -// - -using Microsoft.Extensions.Options; - -namespace slskd.Management -{ - using System; - using System.Threading.Tasks; - using Serilog; - using Soulseek; - - /// - /// Application and Soulseek client management. - /// - public class ManagementService : IManagementService - { - /// - /// Initializes a new instance of the class. - /// - /// The options monitor used to derive application options. - /// The state monitor for application service state. - /// The Soulseek client. - /// The shared file cache. - public ManagementService( - IOptionsMonitor optionsMonitor, - IStateMonitor applicationStateMonitor, - ISoulseekClient soulseekClient, - ISharedFileCache sharedFileCache) - { - OptionsMonitor = optionsMonitor; - ApplicationStateMonitor = applicationStateMonitor; - Client = soulseekClient; - SharedFileCache = sharedFileCache; - } - - private ILogger Log { get; } = Serilog.Log.ForContext(); - - /// - /// Gets the current state of the slskd service. - /// - public ApplicationState ApplicationState => ApplicationStateMonitor.CurrentValue; - - /// - /// Gets the current state of the connection to the Soulseek server. - /// - public ServerState ServerState => - new ServerState() - { - Address = Client.Address, - IPEndPoint = Client.IPEndPoint, - State = Client.State, - Username = Client.Username, - }; - - /// - /// Gets the current state of the connection to the Soulseek server. - /// - public SharedFileCacheState SharedFileCacheState => SharedFileCache.State.CurrentValue; - - private ISoulseekClient Client { get; } - private Options Options => OptionsMonitor.CurrentValue; - private IOptionsMonitor OptionsMonitor { get; } - private IStateMonitor ApplicationStateMonitor { get; } - private ISharedFileCache SharedFileCache { get; } - - /// - /// Connects the Soulseek client to the server using the configured username and password. - /// - /// The operation context. - public Task ConnectServerAsync() - => Client.ConnectAsync(Options.Soulseek.Username, Options.Soulseek.Password); - - /// - /// Disconnects the Soulseek client from the server. - /// - /// An optional message containing the reason for the disconnect. - /// An optional Exception to associate with the disconnect. - public void DisconnectServer(string message = null, Exception exception = null) - => Client.Disconnect(message, exception ?? new IntentionalDisconnectException(message)); - - /// - /// Re-scans shared directories. - /// - /// The operation context. - public Task RescanSharesAsync() => SharedFileCache.FillAsync(); - } -} \ No newline at end of file -- cgit v1.2.3