blob: 821ac20e8d678f776fd896abb9ddeb70fb949e9e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
// <copyright file="IShareService.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>
using System.IO;
namespace slskd.Shares
{
using System.Collections.Generic;
using System.Threading.Tasks;
using Soulseek;
/// <summary>
/// Provides control and interactions with configured shares and shared files.
/// </summary>
public interface IShareService
{
/// <summary>
/// Gets the list of share hosts.
/// </summary>
IReadOnlyList<Host> Hosts { get; }
/// <summary>
/// Gets the state monitor for the service.
/// </summary>
public IStateMonitor<ShareState> StateMonitor { get; }
/// <summary>
/// Returns the entire contents of the share.
/// </summary>
/// <returns>The entire contents of the share.</returns>
Task<IEnumerable<Directory>> BrowseAsync(Share share = null);
/// <summary>
/// Returns the contents of the specified <paramref name="directory"/>.
/// </summary>
/// <param name="directory">The directory for which the contents are to be listed.</param>
/// <returns>The contents of the directory.</returns>
Task<Directory> ListDirectoryAsync(string directory);
/// <summary>
/// Resolves the local filename of the specified <paramref name="remoteFilename"/>, if the mask is associated with a
/// configured share.
/// </summary>
/// <param name="remoteFilename">The fully qualified filename to resolve.</param>
/// <returns>The resolved local filename.</returns>
/// <exception cref="NotFoundException">
/// Thrown when the specified remote filename can not be associated with a configured share.
/// </exception>
Task<FileInfo> ResolveFileAsync(string remoteFilename);
/// <summary>
/// Searches the cache for the specified <paramref name="query"/> and returns the matching files.
/// </summary>
/// <param name="query">The query for which to search.</param>
/// <returns>The matching files.</returns>
Task<IEnumerable<File>> SearchAsync(SearchQuery query);
/// <summary>
/// Scans the configured shares on the local host.
/// </summary>
/// <returns>The operation context.</returns>
/// <exception cref="ShareScanInProgressException">Thrown when a scan is already in progress.</exception>
Task ScanAsync();
/// <summary>
/// Gets summary information for the specified <paramref name="share"/>.
/// </summary>
/// <param name="share">The share to summarize.</param>
/// <returns>The summary information.</returns>
Task<(int Directories, int Files)> SummarizeShareAsync(Share share);
/// <summary>
/// Cancels the currently running scan on the local host, if one is running.
/// </summary>
/// <returns>A value indicating whether a scan was cancelled.</returns>
bool TryCancelScan();
/// <summary>
/// Initializes the service and shares.
/// </summary>
/// <param name="forceRescan">A value indicating whether a full re-scan of shares should be performed.</param>
/// <returns>The operation context.</returns>
Task InitializeAsync(bool forceRescan = false);
}
}
|