// // 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/. // namespace slskd.Shares { using System.Collections.Generic; using System.Threading.Tasks; using Soulseek; /// /// Provides control and interactions with configured shares and shared files. /// public interface IShareService { /// /// Gets the list of share hosts. /// IReadOnlyList Hosts { get; } /// /// Gets the local share host. /// Host LocalHost { get; } /// /// Gets the state monitor for the service. /// IStateMonitor StateMonitor { get; } /// /// Adds a new, or updates an existing, share host. /// /// The host to add or update. void AddOrUpdateHost(Host host); /// /// Returns the entire contents of the share. /// /// The entire contents of the share. Task> BrowseAsync(Share share = null); /// /// Dumps the local share cache to a file. /// /// The destination file. /// The operation context. Task DumpAsync(string filename); /// /// Initializes the service and shares. /// /// A value indicating whether a full re-scan of shares should be performed. /// The operation context. Task InitializeAsync(bool forceRescan = false); /// /// Returns the contents of the specified . /// /// The directory for which the contents are to be listed. /// The contents of the directory. Task ListDirectoryAsync(string directory); /// /// Returns the list of all started at or after the specified /// unix timestamp. /// /// A unix timestamp that serves as the lower bound of the time-based listing. /// The operation context, including the list of found scans. Task> ListScansAsync(long startedAtOrAfter = 0); /// /// Requests that a share scan is performed. /// void RequestScan(); /// /// Resolves the local filename and size of the specified , if the mask is associated with a /// configured share. /// /// The fully qualified filename to resolve. /// The resolved host and filename. /// /// Thrown when the specified remote filename can not be associated with a configured share. /// Task<(string Host, string Filename, long Size)> ResolveFileAsync(string remoteFilename); /// /// Scans the configured shares on the local host. /// /// The operation context. /// Thrown when a scan is already in progress. Task ScanAsync(); /// /// Searches the cache for the specified and returns the matching files. /// /// The query for which to search. /// The matching files. Task> SearchAsync(SearchQuery query); /// /// Cancels the currently running scan on the local host, if one is running. /// /// A value indicating whether a scan was cancelled. bool TryCancelScan(); /// /// Returns the share host with the specified . /// /// The name of the host. /// The host, if found. /// A value indicating whether the host was found. bool TryGetHost(string name, out Host host); /// /// Removes the share host with the specified . /// /// The name of the host. /// A value indicating whether the host was removed. bool TryRemoveHost(string name); } }