From 851dcdfa4824d6b06287959d89484db16f3a4d91 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 26 Jun 2022 15:37:34 -0500 Subject: move stuff again --- src/slskd/Core/CacheKeys.cs | 24 -------- src/slskd/Core/QueueStrategy.cs | 35 ----------- src/slskd/Core/Types/CacheKeys.cs | 24 ++++++++ src/slskd/Core/Types/QueueStrategy.cs | 35 +++++++++++ src/slskd/Messaging/Domain/PrivateMessage.cs | 71 ---------------------- src/slskd/Messaging/Domain/Room.cs | 75 ----------------------- src/slskd/Messaging/Domain/RoomMessage.cs | 59 ------------------ src/slskd/Messaging/Types/PrivateMessage.cs | 71 ++++++++++++++++++++++ src/slskd/Messaging/Types/Room.cs | 75 +++++++++++++++++++++++ src/slskd/Messaging/Types/RoomMessage.cs | 59 ++++++++++++++++++ src/slskd/Search/Domain/File.cs | 51 ---------------- src/slskd/Search/Domain/Response.cs | 51 ---------------- src/slskd/Search/Domain/Search.cs | 60 ------------------ src/slskd/Search/Types/File.cs | 51 ++++++++++++++++ src/slskd/Search/Types/Response.cs | 51 ++++++++++++++++ src/slskd/Search/Types/Search.cs | 60 ++++++++++++++++++ src/slskd/Shares/Domain/Share.cs | 91 ---------------------------- src/slskd/Shares/Types/Share.cs | 91 ++++++++++++++++++++++++++++ src/slskd/Users/Domain/Info.cs | 29 --------- src/slskd/Users/Domain/Statistics.cs | 42 ------------- src/slskd/Users/Domain/Status.cs | 37 ----------- src/slskd/Users/Domain/User.cs | 42 ------------- src/slskd/Users/Types/Info.cs | 29 +++++++++ src/slskd/Users/Types/Statistics.cs | 42 +++++++++++++ src/slskd/Users/Types/Status.cs | 37 +++++++++++ src/slskd/Users/Types/User.cs | 42 +++++++++++++ 26 files changed, 667 insertions(+), 667 deletions(-) delete mode 100644 src/slskd/Core/CacheKeys.cs delete mode 100644 src/slskd/Core/QueueStrategy.cs create mode 100644 src/slskd/Core/Types/CacheKeys.cs create mode 100644 src/slskd/Core/Types/QueueStrategy.cs delete mode 100644 src/slskd/Messaging/Domain/PrivateMessage.cs delete mode 100644 src/slskd/Messaging/Domain/Room.cs delete mode 100644 src/slskd/Messaging/Domain/RoomMessage.cs create mode 100644 src/slskd/Messaging/Types/PrivateMessage.cs create mode 100644 src/slskd/Messaging/Types/Room.cs create mode 100644 src/slskd/Messaging/Types/RoomMessage.cs delete mode 100644 src/slskd/Search/Domain/File.cs delete mode 100644 src/slskd/Search/Domain/Response.cs delete mode 100644 src/slskd/Search/Domain/Search.cs create mode 100644 src/slskd/Search/Types/File.cs create mode 100644 src/slskd/Search/Types/Response.cs create mode 100644 src/slskd/Search/Types/Search.cs delete mode 100644 src/slskd/Shares/Domain/Share.cs create mode 100644 src/slskd/Shares/Types/Share.cs delete mode 100644 src/slskd/Users/Domain/Info.cs delete mode 100644 src/slskd/Users/Domain/Statistics.cs delete mode 100644 src/slskd/Users/Domain/Status.cs delete mode 100644 src/slskd/Users/Domain/User.cs create mode 100644 src/slskd/Users/Types/Info.cs create mode 100644 src/slskd/Users/Types/Statistics.cs create mode 100644 src/slskd/Users/Types/Status.cs create mode 100644 src/slskd/Users/Types/User.cs (limited to 'src') diff --git a/src/slskd/Core/CacheKeys.cs b/src/slskd/Core/CacheKeys.cs deleted file mode 100644 index b5a335c1..00000000 --- a/src/slskd/Core/CacheKeys.cs +++ /dev/null @@ -1,24 +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/. -// - -namespace slskd -{ - public static class CacheKeys - { - public static readonly string UserStatisticsToken = nameof(UserStatisticsToken); - } -} diff --git a/src/slskd/Core/QueueStrategy.cs b/src/slskd/Core/QueueStrategy.cs deleted file mode 100644 index 50f6cce1..00000000 --- a/src/slskd/Core/QueueStrategy.cs +++ /dev/null @@ -1,35 +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/. -// - -namespace slskd -{ - /// - /// Queue strategies. - /// - public enum QueueStrategy - { - /// - /// Uploads are prioritized based on the time they became ready. - /// - RoundRobin = 0, - - /// - /// Uploads are prioritized based on the time they were enqueued. - /// - FirstInFirstOut = 1, - } -} diff --git a/src/slskd/Core/Types/CacheKeys.cs b/src/slskd/Core/Types/CacheKeys.cs new file mode 100644 index 00000000..b5a335c1 --- /dev/null +++ b/src/slskd/Core/Types/CacheKeys.cs @@ -0,0 +1,24 @@ +// +// 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 +{ + public static class CacheKeys + { + public static readonly string UserStatisticsToken = nameof(UserStatisticsToken); + } +} diff --git a/src/slskd/Core/Types/QueueStrategy.cs b/src/slskd/Core/Types/QueueStrategy.cs new file mode 100644 index 00000000..50f6cce1 --- /dev/null +++ b/src/slskd/Core/Types/QueueStrategy.cs @@ -0,0 +1,35 @@ +// +// 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 +{ + /// + /// Queue strategies. + /// + public enum QueueStrategy + { + /// + /// Uploads are prioritized based on the time they became ready. + /// + RoundRobin = 0, + + /// + /// Uploads are prioritized based on the time they were enqueued. + /// + FirstInFirstOut = 1, + } +} diff --git a/src/slskd/Messaging/Domain/PrivateMessage.cs b/src/slskd/Messaging/Domain/PrivateMessage.cs deleted file mode 100644 index 236632aa..00000000 --- a/src/slskd/Messaging/Domain/PrivateMessage.cs +++ /dev/null @@ -1,71 +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/. -// - -namespace slskd.Messaging -{ - using System; - using Soulseek; - - /// - /// A private message. - /// - public class PrivateMessage - { - /// - /// A value indicating whether the message has been acknowledged. - /// - public bool Acknowledged { get; set; } = false; - - /// - /// The unique message id, used to acknowledge receipt. - /// - public int Id { get; set; } - - /// - /// The message. - /// - public string Message { get; set; } - - /// - /// A value indicating whether the message was replayed. - /// - public bool Replayed { get; set; } - - /// - /// The UTC timestamp of the message. - /// - public DateTime Timestamp { get; set; } = DateTime.UtcNow; - - /// - /// The username of the user who sent the message. - /// - public string Username { get; set; } - - public static PrivateMessage FromEventArgs(PrivateMessageReceivedEventArgs eventArgs) - { - return new PrivateMessage() - { - Id = eventArgs.Id, - Timestamp = eventArgs.Timestamp, - Username = eventArgs.Username, - Message = eventArgs.Message, - Acknowledged = false, - Replayed = eventArgs.Replayed, - }; - } - } -} \ No newline at end of file diff --git a/src/slskd/Messaging/Domain/Room.cs b/src/slskd/Messaging/Domain/Room.cs deleted file mode 100644 index 459dea2c..00000000 --- a/src/slskd/Messaging/Domain/Room.cs +++ /dev/null @@ -1,75 +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/. -// - -namespace slskd.Messaging -{ - using System.Collections.Generic; - using System.Linq; - using Soulseek; - - public class Room - { - /// - /// The room name. - /// - public string Name { get; set; } - - /// - /// A value indicating whether the room is private. - /// - public bool IsPrivate { get; set; } - - /// - /// The number of operators in the room, if private. - /// - public int? OperatorCount { get; set; } - - /// - /// The operators in the room, if private. - /// - public IList Operators { get; set; } - - /// - /// The owner of the room, if private. - /// - public string Owner { get; set; } - - /// - /// The list of users in the room. - /// - public IList Users { get; set; } = new List(); - - /// - /// The list of messages. - /// - public IList Messages { get; set; } = new List(); - - public static Room FromRoomData(RoomData roomData) - { - return new Room() - { - Name = roomData.Name, - IsPrivate = roomData.IsPrivate, - OperatorCount = roomData.OperatorCount, - Operators = roomData.Operators?.ToList(), - Owner = roomData.Owner, - Users = roomData.Users?.ToList(), - Messages = new List(), - }; - } - } -} diff --git a/src/slskd/Messaging/Domain/RoomMessage.cs b/src/slskd/Messaging/Domain/RoomMessage.cs deleted file mode 100644 index 7a06a192..00000000 --- a/src/slskd/Messaging/Domain/RoomMessage.cs +++ /dev/null @@ -1,59 +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/. -// - -namespace slskd.Messaging -{ - using System; - using Soulseek; - - /// - /// A message sent to a room. - /// - public class RoomMessage - { - /// - /// The timestamp of the message. - /// - public DateTime Timestamp { get; set; } = DateTime.UtcNow; - - /// - /// The username of the user who sent the message. - /// - public string Username { get; set; } - - /// - /// The message. - /// - public string Message { get; set; } - - /// - /// The room to which the message pertains. - /// - public string RoomName { get; set; } - - public static RoomMessage FromEventArgs(RoomMessageReceivedEventArgs eventArgs, DateTime? timestamp = null) - { - return new RoomMessage() - { - Timestamp = timestamp ?? DateTime.UtcNow, - Username = eventArgs.Username, - Message = eventArgs.Message, - RoomName = eventArgs.RoomName, - }; - } - } -} diff --git a/src/slskd/Messaging/Types/PrivateMessage.cs b/src/slskd/Messaging/Types/PrivateMessage.cs new file mode 100644 index 00000000..236632aa --- /dev/null +++ b/src/slskd/Messaging/Types/PrivateMessage.cs @@ -0,0 +1,71 @@ +// +// 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.Messaging +{ + using System; + using Soulseek; + + /// + /// A private message. + /// + public class PrivateMessage + { + /// + /// A value indicating whether the message has been acknowledged. + /// + public bool Acknowledged { get; set; } = false; + + /// + /// The unique message id, used to acknowledge receipt. + /// + public int Id { get; set; } + + /// + /// The message. + /// + public string Message { get; set; } + + /// + /// A value indicating whether the message was replayed. + /// + public bool Replayed { get; set; } + + /// + /// The UTC timestamp of the message. + /// + public DateTime Timestamp { get; set; } = DateTime.UtcNow; + + /// + /// The username of the user who sent the message. + /// + public string Username { get; set; } + + public static PrivateMessage FromEventArgs(PrivateMessageReceivedEventArgs eventArgs) + { + return new PrivateMessage() + { + Id = eventArgs.Id, + Timestamp = eventArgs.Timestamp, + Username = eventArgs.Username, + Message = eventArgs.Message, + Acknowledged = false, + Replayed = eventArgs.Replayed, + }; + } + } +} \ No newline at end of file diff --git a/src/slskd/Messaging/Types/Room.cs b/src/slskd/Messaging/Types/Room.cs new file mode 100644 index 00000000..459dea2c --- /dev/null +++ b/src/slskd/Messaging/Types/Room.cs @@ -0,0 +1,75 @@ +// +// 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.Messaging +{ + using System.Collections.Generic; + using System.Linq; + using Soulseek; + + public class Room + { + /// + /// The room name. + /// + public string Name { get; set; } + + /// + /// A value indicating whether the room is private. + /// + public bool IsPrivate { get; set; } + + /// + /// The number of operators in the room, if private. + /// + public int? OperatorCount { get; set; } + + /// + /// The operators in the room, if private. + /// + public IList Operators { get; set; } + + /// + /// The owner of the room, if private. + /// + public string Owner { get; set; } + + /// + /// The list of users in the room. + /// + public IList Users { get; set; } = new List(); + + /// + /// The list of messages. + /// + public IList Messages { get; set; } = new List(); + + public static Room FromRoomData(RoomData roomData) + { + return new Room() + { + Name = roomData.Name, + IsPrivate = roomData.IsPrivate, + OperatorCount = roomData.OperatorCount, + Operators = roomData.Operators?.ToList(), + Owner = roomData.Owner, + Users = roomData.Users?.ToList(), + Messages = new List(), + }; + } + } +} diff --git a/src/slskd/Messaging/Types/RoomMessage.cs b/src/slskd/Messaging/Types/RoomMessage.cs new file mode 100644 index 00000000..7a06a192 --- /dev/null +++ b/src/slskd/Messaging/Types/RoomMessage.cs @@ -0,0 +1,59 @@ +// +// 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.Messaging +{ + using System; + using Soulseek; + + /// + /// A message sent to a room. + /// + public class RoomMessage + { + /// + /// The timestamp of the message. + /// + public DateTime Timestamp { get; set; } = DateTime.UtcNow; + + /// + /// The username of the user who sent the message. + /// + public string Username { get; set; } + + /// + /// The message. + /// + public string Message { get; set; } + + /// + /// The room to which the message pertains. + /// + public string RoomName { get; set; } + + public static RoomMessage FromEventArgs(RoomMessageReceivedEventArgs eventArgs, DateTime? timestamp = null) + { + return new RoomMessage() + { + Timestamp = timestamp ?? DateTime.UtcNow, + Username = eventArgs.Username, + Message = eventArgs.Message, + RoomName = eventArgs.RoomName, + }; + } + } +} diff --git a/src/slskd/Search/Domain/File.cs b/src/slskd/Search/Domain/File.cs deleted file mode 100644 index 0a86eec3..00000000 --- a/src/slskd/Search/Domain/File.cs +++ /dev/null @@ -1,51 +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/. -// - -namespace slskd.Search -{ - using SoulseekFile = Soulseek.File; - - public class File - { - public int? BitDepth { get; init; } - public int? BitRate { get; init; } - public int Code { get; init; } - public string Extension { get; init; } - public string Filename { get; init; } - public bool? IsVariableBitRate { get; init; } - public int? Length { get; init; } - public int? SampleRate { get; init; } - public long Size { get; init; } - public bool IsLocked { get; init; } - - public static File FromSoulseekFile(SoulseekFile file) - { - return new File() - { - BitDepth = file.BitDepth, - BitRate = file.BitRate, - Code = file.Code, - Extension = file.Extension, - Filename = file.Filename, - IsVariableBitRate = file.IsVariableBitRate, - Length = file.Length, - SampleRate = file.SampleRate, - Size = file.Size, - }; - } - } -} \ No newline at end of file diff --git a/src/slskd/Search/Domain/Response.cs b/src/slskd/Search/Domain/Response.cs deleted file mode 100644 index ea2e8993..00000000 --- a/src/slskd/Search/Domain/Response.cs +++ /dev/null @@ -1,51 +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/. -// - -namespace slskd.Search -{ - using System.Collections.Generic; - using System.Linq; - - public class Response - { - public int FileCount { get; init; } - public ICollection Files { get; init; } = new List(); - public int FreeUploadSlots { get; init; } - public int LockedFileCount { get; init; } - public ICollection LockedFiles { get; init; } = new List(); - public long QueueLength { get; init; } - public int Token { get; init; } - public int UploadSpeed { get; init; } - public string Username { get; init; } - - public static Response FromSoulseekSearchResponse(Soulseek.SearchResponse searchResponse) - { - return new Response() - { - FileCount = searchResponse.FileCount, - Files = searchResponse.Files.Select(file => File.FromSoulseekFile(file)).ToList(), - FreeUploadSlots = searchResponse.FreeUploadSlots, - LockedFileCount = searchResponse.LockedFileCount, - LockedFiles = searchResponse.LockedFiles.Select(file => File.FromSoulseekFile(file)).ToList(), - QueueLength = searchResponse.QueueLength, - Token = searchResponse.Token, - UploadSpeed = searchResponse.UploadSpeed, - Username = searchResponse.Username, - }; - } - } -} \ No newline at end of file diff --git a/src/slskd/Search/Domain/Search.cs b/src/slskd/Search/Domain/Search.cs deleted file mode 100644 index 52f97075..00000000 --- a/src/slskd/Search/Domain/Search.cs +++ /dev/null @@ -1,60 +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/. -// - -namespace slskd.Search -{ - using System; - using System.Collections.Generic; - using System.ComponentModel.DataAnnotations; - using System.ComponentModel.DataAnnotations.Schema; - using System.Text.Json; - using System.Text.Json.Serialization; - using Soulseek; - - public class Search - { - public DateTime? EndedAt { get; set; } - public int FileCount { get; set; } - - [Key] - public Guid Id { get; init; } - - [NotMapped] - public bool IsComplete => State.HasFlag(SearchStates.Completed); - - public int LockedFileCount { get; set; } - public int ResponseCount { get; set; } - - [NotMapped] - public IEnumerable Responses { get; set; } = new List(); - - [JsonIgnore] - public string ResponsesJson - { - get => JsonSerializer.Serialize(Responses); - set - { - Responses = JsonSerializer.Deserialize>(value); - } - } - - public string SearchText { get; init; } - public DateTime StartedAt { get; init; } = DateTime.Now; - public SearchStates State { get; set; } - public int Token { get; init; } - } -} \ No newline at end of file diff --git a/src/slskd/Search/Types/File.cs b/src/slskd/Search/Types/File.cs new file mode 100644 index 00000000..0a86eec3 --- /dev/null +++ b/src/slskd/Search/Types/File.cs @@ -0,0 +1,51 @@ +// +// 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.Search +{ + using SoulseekFile = Soulseek.File; + + public class File + { + public int? BitDepth { get; init; } + public int? BitRate { get; init; } + public int Code { get; init; } + public string Extension { get; init; } + public string Filename { get; init; } + public bool? IsVariableBitRate { get; init; } + public int? Length { get; init; } + public int? SampleRate { get; init; } + public long Size { get; init; } + public bool IsLocked { get; init; } + + public static File FromSoulseekFile(SoulseekFile file) + { + return new File() + { + BitDepth = file.BitDepth, + BitRate = file.BitRate, + Code = file.Code, + Extension = file.Extension, + Filename = file.Filename, + IsVariableBitRate = file.IsVariableBitRate, + Length = file.Length, + SampleRate = file.SampleRate, + Size = file.Size, + }; + } + } +} \ No newline at end of file diff --git a/src/slskd/Search/Types/Response.cs b/src/slskd/Search/Types/Response.cs new file mode 100644 index 00000000..ea2e8993 --- /dev/null +++ b/src/slskd/Search/Types/Response.cs @@ -0,0 +1,51 @@ +// +// 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.Search +{ + using System.Collections.Generic; + using System.Linq; + + public class Response + { + public int FileCount { get; init; } + public ICollection Files { get; init; } = new List(); + public int FreeUploadSlots { get; init; } + public int LockedFileCount { get; init; } + public ICollection LockedFiles { get; init; } = new List(); + public long QueueLength { get; init; } + public int Token { get; init; } + public int UploadSpeed { get; init; } + public string Username { get; init; } + + public static Response FromSoulseekSearchResponse(Soulseek.SearchResponse searchResponse) + { + return new Response() + { + FileCount = searchResponse.FileCount, + Files = searchResponse.Files.Select(file => File.FromSoulseekFile(file)).ToList(), + FreeUploadSlots = searchResponse.FreeUploadSlots, + LockedFileCount = searchResponse.LockedFileCount, + LockedFiles = searchResponse.LockedFiles.Select(file => File.FromSoulseekFile(file)).ToList(), + QueueLength = searchResponse.QueueLength, + Token = searchResponse.Token, + UploadSpeed = searchResponse.UploadSpeed, + Username = searchResponse.Username, + }; + } + } +} \ No newline at end of file diff --git a/src/slskd/Search/Types/Search.cs b/src/slskd/Search/Types/Search.cs new file mode 100644 index 00000000..52f97075 --- /dev/null +++ b/src/slskd/Search/Types/Search.cs @@ -0,0 +1,60 @@ +// +// 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.Search +{ + using System; + using System.Collections.Generic; + using System.ComponentModel.DataAnnotations; + using System.ComponentModel.DataAnnotations.Schema; + using System.Text.Json; + using System.Text.Json.Serialization; + using Soulseek; + + public class Search + { + public DateTime? EndedAt { get; set; } + public int FileCount { get; set; } + + [Key] + public Guid Id { get; init; } + + [NotMapped] + public bool IsComplete => State.HasFlag(SearchStates.Completed); + + public int LockedFileCount { get; set; } + public int ResponseCount { get; set; } + + [NotMapped] + public IEnumerable Responses { get; set; } = new List(); + + [JsonIgnore] + public string ResponsesJson + { + get => JsonSerializer.Serialize(Responses); + set + { + Responses = JsonSerializer.Deserialize>(value); + } + } + + public string SearchText { get; init; } + public DateTime StartedAt { get; init; } = DateTime.Now; + public SearchStates State { get; set; } + public int Token { get; init; } + } +} \ No newline at end of file diff --git a/src/slskd/Shares/Domain/Share.cs b/src/slskd/Shares/Domain/Share.cs deleted file mode 100644 index 6a6d1f66..00000000 --- a/src/slskd/Shares/Domain/Share.cs +++ /dev/null @@ -1,91 +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/. -// - -namespace slskd.Shares -{ - using System.Linq; - using System.Text.Json.Serialization; - using System.Text.RegularExpressions; - - /// - /// A file share. - /// - public sealed class Share - { - /// - /// Initializes a new instance of the class. - /// - /// - /// - /// - /// - /// - /// - [JsonConstructor] - public Share (string id, string alias, bool isExcluded, string localPath, string raw, string remotePath) - { - Id = id; - Alias = alias; - IsExcluded = isExcluded; - LocalPath = localPath; - Raw = raw; - RemotePath = remotePath; - } - - /// - /// Initializes a new instance of the class. - /// - /// - public Share(string share) - { - Raw = share; - IsExcluded = share.StartsWith('-') || share.StartsWith('!'); - - if (IsExcluded) - { - share = share[1..]; - } - - // test to see whether an alias has been specified - var matches = Regex.Matches(share, @"^\[(.*)\](.*)$"); - - if (matches.Any()) - { - // split the alias from the path, and validate the alias - var groups = matches[0].Groups; - Alias = groups[1].Value; - LocalPath = groups[2].Value; - } - else - { - Alias = share.Split(new[] { '/', '\\' }).Last(); - LocalPath = share; - } - - RemotePath = Alias; - - Id = Compute.Sha1Hash(RemotePath); - } - - public string Id { get; init; } - public string Alias { get; init; } - public bool IsExcluded { get; init; } - public string LocalPath { get; init; } - public string Raw { get; init; } - public string RemotePath { get; init; } - } -} diff --git a/src/slskd/Shares/Types/Share.cs b/src/slskd/Shares/Types/Share.cs new file mode 100644 index 00000000..6a6d1f66 --- /dev/null +++ b/src/slskd/Shares/Types/Share.cs @@ -0,0 +1,91 @@ +// +// 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.Linq; + using System.Text.Json.Serialization; + using System.Text.RegularExpressions; + + /// + /// A file share. + /// + public sealed class Share + { + /// + /// Initializes a new instance of the class. + /// + /// + /// + /// + /// + /// + /// + [JsonConstructor] + public Share (string id, string alias, bool isExcluded, string localPath, string raw, string remotePath) + { + Id = id; + Alias = alias; + IsExcluded = isExcluded; + LocalPath = localPath; + Raw = raw; + RemotePath = remotePath; + } + + /// + /// Initializes a new instance of the class. + /// + /// + public Share(string share) + { + Raw = share; + IsExcluded = share.StartsWith('-') || share.StartsWith('!'); + + if (IsExcluded) + { + share = share[1..]; + } + + // test to see whether an alias has been specified + var matches = Regex.Matches(share, @"^\[(.*)\](.*)$"); + + if (matches.Any()) + { + // split the alias from the path, and validate the alias + var groups = matches[0].Groups; + Alias = groups[1].Value; + LocalPath = groups[2].Value; + } + else + { + Alias = share.Split(new[] { '/', '\\' }).Last(); + LocalPath = share; + } + + RemotePath = Alias; + + Id = Compute.Sha1Hash(RemotePath); + } + + public string Id { get; init; } + public string Alias { get; init; } + public bool IsExcluded { get; init; } + public string LocalPath { get; init; } + public string Raw { get; init; } + public string RemotePath { get; init; } + } +} diff --git a/src/slskd/Users/Domain/Info.cs b/src/slskd/Users/Domain/Info.cs deleted file mode 100644 index e3969f17..00000000 --- a/src/slskd/Users/Domain/Info.cs +++ /dev/null @@ -1,29 +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/. -// - -namespace slskd.Users -{ - public record Info - { - public string Description { get; init; } - public bool HasFreeUploadSlot { get; init; } - public bool HasPicture { get; init; } - public byte[] Picture { get; init; } - public int QueueLength { get; init; } - public int UploadSlots { get; init; } - } -} diff --git a/src/slskd/Users/Domain/Statistics.cs b/src/slskd/Users/Domain/Statistics.cs deleted file mode 100644 index a415d3d5..00000000 --- a/src/slskd/Users/Domain/Statistics.cs +++ /dev/null @@ -1,42 +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/. -// - -namespace slskd.Users -{ - public record Statistics - { - /// - /// Gets the average upload speed of the user. - /// - public int AverageSpeed { get; init; } - - /// - /// Gets the number of directories shared by the user. - /// - public int DirectoryCount { get; init; } - - /// - /// Gets the number of files shared by the user. - /// - public int FileCount { get; init; } - - /// - /// Gets the number of uploads tracked by the server for this user. - /// - public long UploadCount { get; init; } - } -} diff --git a/src/slskd/Users/Domain/Status.cs b/src/slskd/Users/Domain/Status.cs deleted file mode 100644 index 890afb74..00000000 --- a/src/slskd/Users/Domain/Status.cs +++ /dev/null @@ -1,37 +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/. -// - -namespace slskd.Users -{ - using Soulseek; - - /// - /// User status. - /// - public record Status - { - /// - /// Gets a value indicating whether the user is privileged. - /// - public bool IsPrivileged { get; init; } - - /// - /// Gets the user's presence. - /// - public UserPresence Presence { get; init; } - } -} diff --git a/src/slskd/Users/Domain/User.cs b/src/slskd/Users/Domain/User.cs deleted file mode 100644 index 2913620c..00000000 --- a/src/slskd/Users/Domain/User.cs +++ /dev/null @@ -1,42 +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/. -// - -namespace slskd.Users -{ - public record User - { - /// - /// Gets the username of the user. - /// - public string Username { get; init; } - - /// - /// Gets the user's configured group. - /// - public string Group { get; init; } - - /// - /// Gets the user's statistics. - /// - public Statistics Statistics { get; init; } - - /// - /// Gets the user's status. - /// - public Status Status { get; init; } - } -} diff --git a/src/slskd/Users/Types/Info.cs b/src/slskd/Users/Types/Info.cs new file mode 100644 index 00000000..e3969f17 --- /dev/null +++ b/src/slskd/Users/Types/Info.cs @@ -0,0 +1,29 @@ +// +// 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.Users +{ + public record Info + { + public string Description { get; init; } + public bool HasFreeUploadSlot { get; init; } + public bool HasPicture { get; init; } + public byte[] Picture { get; init; } + public int QueueLength { get; init; } + public int UploadSlots { get; init; } + } +} diff --git a/src/slskd/Users/Types/Statistics.cs b/src/slskd/Users/Types/Statistics.cs new file mode 100644 index 00000000..a415d3d5 --- /dev/null +++ b/src/slskd/Users/Types/Statistics.cs @@ -0,0 +1,42 @@ +// +// 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.Users +{ + public record Statistics + { + /// + /// Gets the average upload speed of the user. + /// + public int AverageSpeed { get; init; } + + /// + /// Gets the number of directories shared by the user. + /// + public int DirectoryCount { get; init; } + + /// + /// Gets the number of files shared by the user. + /// + public int FileCount { get; init; } + + /// + /// Gets the number of uploads tracked by the server for this user. + /// + public long UploadCount { get; init; } + } +} diff --git a/src/slskd/Users/Types/Status.cs b/src/slskd/Users/Types/Status.cs new file mode 100644 index 00000000..890afb74 --- /dev/null +++ b/src/slskd/Users/Types/Status.cs @@ -0,0 +1,37 @@ +// +// 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.Users +{ + using Soulseek; + + /// + /// User status. + /// + public record Status + { + /// + /// Gets a value indicating whether the user is privileged. + /// + public bool IsPrivileged { get; init; } + + /// + /// Gets the user's presence. + /// + public UserPresence Presence { get; init; } + } +} diff --git a/src/slskd/Users/Types/User.cs b/src/slskd/Users/Types/User.cs new file mode 100644 index 00000000..2913620c --- /dev/null +++ b/src/slskd/Users/Types/User.cs @@ -0,0 +1,42 @@ +// +// 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.Users +{ + public record User + { + /// + /// Gets the username of the user. + /// + public string Username { get; init; } + + /// + /// Gets the user's configured group. + /// + public string Group { get; init; } + + /// + /// Gets the user's statistics. + /// + public Statistics Statistics { get; init; } + + /// + /// Gets the user's status. + /// + public Status Status { get; init; } + } +} -- cgit v1.2.3