From 61b6e33b7919d30473619c8d576f53f2d2a68a71 Mon Sep 17 00:00:00 2001 From: Difegue Date: Sun, 3 Oct 2021 18:08:47 +0200 Subject: [PATCH] Clean up --- README.md | 5 +- .../MpcNET/Commands/Database/FindCommand.cs | 72 ---------------- .../MpcNET/Commands/Playlist/AddCommand.cs | 48 ----------- .../MpcNET/Commands/Playlist/AddIdCommand.cs | 48 ----------- .../MpcNET/Commands/Playlist/ClearCommand.cs | 37 -------- .../MpcNET/Commands/Playlist/DeleteCommand.cs | 48 ----------- .../Commands/Playlist/DeleteIdCommand.cs | 48 ----------- .../MpcNET/Commands/Playlist/MoveIdCommand.cs | 52 ------------ .../Commands/Playlist/PlaylistCommand.cs | 41 --------- .../Commands/Playlist/PlaylistIdCommand.cs | 49 ----------- .../Commands/Playlist/PlaylistInfoCommand.cs | 38 --------- Sources/MpcNET/IMpcConnectionReporter.cs | 80 ------------------ Sources/MpcNET/MpcNET.csproj | 6 +- Sources/MpcNET/icon.png => icon.png | Bin 14 files changed, 8 insertions(+), 564 deletions(-) delete mode 100644 Sources/MpcNET/Commands/Database/FindCommand.cs delete mode 100644 Sources/MpcNET/Commands/Playlist/AddCommand.cs delete mode 100644 Sources/MpcNET/Commands/Playlist/AddIdCommand.cs delete mode 100644 Sources/MpcNET/Commands/Playlist/ClearCommand.cs delete mode 100644 Sources/MpcNET/Commands/Playlist/DeleteCommand.cs delete mode 100644 Sources/MpcNET/Commands/Playlist/DeleteIdCommand.cs delete mode 100644 Sources/MpcNET/Commands/Playlist/MoveIdCommand.cs delete mode 100644 Sources/MpcNET/Commands/Playlist/PlaylistCommand.cs delete mode 100644 Sources/MpcNET/Commands/Playlist/PlaylistIdCommand.cs delete mode 100644 Sources/MpcNET/Commands/Playlist/PlaylistInfoCommand.cs delete mode 100644 Sources/MpcNET/IMpcConnectionReporter.cs rename Sources/MpcNET/icon.png => icon.png (100%) diff --git a/README.md b/README.md index a014b9d..da53e03 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,9 @@ - + MpcNET =========== -Pure .NET Client Library for [**Music Player Daemon**](https://www.musicpd.org/) Servers. +Pure .NET Client Library for [**Music Player Daemon**](https://www.musicpd.org/) Servers. +The heart and soul of [Stylophone](https://github.com/Difegue/Stylophone). ## Usage ### Connection diff --git a/Sources/MpcNET/Commands/Database/FindCommand.cs b/Sources/MpcNET/Commands/Database/FindCommand.cs deleted file mode 100644 index 954c14e..0000000 --- a/Sources/MpcNET/Commands/Database/FindCommand.cs +++ /dev/null @@ -1,72 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) MpcNET. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. -// -// -------------------------------------------------------------------------------------------------------------------- -namespace MpcNET.Commands.Database -{ - using System.Collections.Generic; - using System.Linq; - using MpcNET.Tags; - using MpcNET.Types; - - /// - /// Finds songs in the database that is exactly "searchText". - /// https://www.musicpd.org/doc/protocol/database.html. - /// - public class FindCommand : IMpcCommand> - { - private readonly List> filters; - - /// - /// Initializes a new instance of the class. - /// - /// The tag. - /// The search text. - public FindCommand(ITag tag, string searchText) - { - this.filters = new List>(); - this.filters.Add(new KeyValuePair(tag, searchText)); - } - - /// - /// Initializes a new instance of the class. - /// - /// List of key/value filters - public FindCommand(List> filters) - { - this.filters = filters; - } - - /// - /// Serializes the command. - /// - /// - /// The serialize command. - /// - public string Serialize() => - string.Join(" ", - "find", - string.Join(" ", - this.filters - .Select(x => string.Join(" ", - x.Key.Value, escape(x.Value))) - .ToArray())); - - /// - /// Deserializes the specified response text pairs. - /// - /// The response. - /// - /// The deserialized response. - /// - public IEnumerable Deserialize(IReadOnlyList> response) - { - return MpdFile.CreateList(response); - } - - private string escape(string value) => string.Format("\"{0}\"", value.Replace("\\", "\\\\").Replace("\"", "\\\"")); - } - // TODO: rescan -} diff --git a/Sources/MpcNET/Commands/Playlist/AddCommand.cs b/Sources/MpcNET/Commands/Playlist/AddCommand.cs deleted file mode 100644 index 27c3766..0000000 --- a/Sources/MpcNET/Commands/Playlist/AddCommand.cs +++ /dev/null @@ -1,48 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) MpcNET. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. -// -// -------------------------------------------------------------------------------------------------------------------- -namespace MpcNET.Commands.Playlist -{ - using System.Collections.Generic; - - /// - /// Adds the file URI to the playlist (directories add recursively). URI can also be a single file. - /// https://www.musicpd.org/doc/protocol/queue.html. - /// - public class AddCommand : IMpcCommand - { - private readonly string uri; - - /// - /// Initializes a new instance of the class. - /// - /// The URI. - public AddCommand(string uri) - { - this.uri = uri; - } - - /// - /// Serializes the command. - /// - /// - /// The serialize command. - /// - public string Serialize() => string.Join(" ", "add", $"\"{this.uri}\""); - - /// - /// Deserializes the specified response text pairs. - /// - /// The response. - /// - /// The deserialized response. - /// - public string Deserialize(IReadOnlyList> response) - { - return string.Join(", ", response); - } - } -} diff --git a/Sources/MpcNET/Commands/Playlist/AddIdCommand.cs b/Sources/MpcNET/Commands/Playlist/AddIdCommand.cs deleted file mode 100644 index 0643ca3..0000000 --- a/Sources/MpcNET/Commands/Playlist/AddIdCommand.cs +++ /dev/null @@ -1,48 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) MpcNET. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. -// -// -------------------------------------------------------------------------------------------------------------------- -namespace MpcNET.Commands.Playlist -{ - using System.Collections.Generic; - - /// - /// Adds a song to the playlist (non-recursive) and returns the song id. - /// https://www.musicpd.org/doc/protocol/queue.html. - /// - public class AddIdCommand : IMpcCommand - { - private readonly string uri; - - /// - /// Initializes a new instance of the class. - /// - /// The URI. - public AddIdCommand(string uri) - { - this.uri = uri; - } - - /// - /// Serializes the command. - /// - /// - /// The serialize command. - /// - public string Serialize() => string.Join(" ", "addid", $"\"{this.uri}\""); - - /// - /// Deserializes the specified response text pairs. - /// - /// The response. - /// - /// The deserialized response. - /// - public string Deserialize(IReadOnlyList> response) - { - return string.Join(", ", response); - } - } -} \ No newline at end of file diff --git a/Sources/MpcNET/Commands/Playlist/ClearCommand.cs b/Sources/MpcNET/Commands/Playlist/ClearCommand.cs deleted file mode 100644 index a9ef8a4..0000000 --- a/Sources/MpcNET/Commands/Playlist/ClearCommand.cs +++ /dev/null @@ -1,37 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) MpcNET. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. -// -// -------------------------------------------------------------------------------------------------------------------- -namespace MpcNET.Commands.Playlist -{ - using System.Collections.Generic; - - /// - /// Clears the current playlist. - /// https://www.musicpd.org/doc/protocol/queue.html. - /// - public class ClearCommand : IMpcCommand - { - /// - /// Serializes the command. - /// - /// - /// The serialize command. - /// - public string Serialize() => "clear"; - - /// - /// Deserializes the specified response text pairs. - /// - /// The response. - /// - /// The deserialized response. - /// - public string Deserialize(IReadOnlyList> response) - { - return string.Join(", ", response); - } - } -} \ No newline at end of file diff --git a/Sources/MpcNET/Commands/Playlist/DeleteCommand.cs b/Sources/MpcNET/Commands/Playlist/DeleteCommand.cs deleted file mode 100644 index 0f19bed..0000000 --- a/Sources/MpcNET/Commands/Playlist/DeleteCommand.cs +++ /dev/null @@ -1,48 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) MpcNET. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. -// -// -------------------------------------------------------------------------------------------------------------------- -namespace MpcNET.Commands.Playlist -{ - using System.Collections.Generic; - - /// - /// Deletes a song from the playlist. - /// https://www.musicpd.org/doc/protocol/queue.html. - /// - public class DeleteCommand : IMpcCommand - { - private readonly int position; - - /// - /// Initializes a new instance of the class. - /// - /// The position. - public DeleteCommand(int position) - { - this.position = position; - } - - /// - /// Serializes the command. - /// - /// - /// The serialize command. - /// - public string Serialize() => string.Join(" ", "delete", this.position); - - /// - /// Deserializes the specified response text pairs. - /// - /// The response. - /// - /// The deserialized response. - /// - public string Deserialize(IReadOnlyList> response) - { - return string.Join(", ", response); - } - } -} \ No newline at end of file diff --git a/Sources/MpcNET/Commands/Playlist/DeleteIdCommand.cs b/Sources/MpcNET/Commands/Playlist/DeleteIdCommand.cs deleted file mode 100644 index ea4a4bd..0000000 --- a/Sources/MpcNET/Commands/Playlist/DeleteIdCommand.cs +++ /dev/null @@ -1,48 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) MpcNET. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. -// -// -------------------------------------------------------------------------------------------------------------------- -namespace MpcNET.Commands.Playlist -{ - using System.Collections.Generic; - - /// - /// Deletes the song SONGID from the playlist. - /// https://www.musicpd.org/doc/protocol/queue.html. - /// - public class DeleteIdCommand : IMpcCommand - { - private readonly int songId; - - /// - /// Initializes a new instance of the class. - /// - /// The song identifier. - public DeleteIdCommand(int songId) - { - this.songId = songId; - } - - /// - /// Serializes the command. - /// - /// - /// The serialize command. - /// - public string Serialize() => string.Join(" ", "deleteid", this.songId); - - /// - /// Deserializes the specified response text pairs. - /// - /// The response. - /// - /// The deserialized response. - /// - public string Deserialize(IReadOnlyList> response) - { - return string.Join(", ", response); - } - } -} \ No newline at end of file diff --git a/Sources/MpcNET/Commands/Playlist/MoveIdCommand.cs b/Sources/MpcNET/Commands/Playlist/MoveIdCommand.cs deleted file mode 100644 index bdfdb10..0000000 --- a/Sources/MpcNET/Commands/Playlist/MoveIdCommand.cs +++ /dev/null @@ -1,52 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) MpcNET. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. -// -// -------------------------------------------------------------------------------------------------------------------- -namespace MpcNET.Commands.Playlist -{ - using System.Collections.Generic; - - /// - /// Moves the song with FROM (songid) to TO (playlist index) in the playlist. - /// If TO is negative, it is relative to the current song in the playlist (if there is one) - /// https://www.musicpd.org/doc/protocol/queue.html. - /// - public class MoveIdCommand : IMpcCommand - { - private readonly int from; - private readonly int to; - - /// - /// Initializes a new instance of the class. - /// - /// From (songid) - /// To (playlist index) - public MoveIdCommand(int from, int to) - { - this.from = from; - this.to = to; - } - - /// - /// Serializes the command. - /// - /// - /// The serialize command. - /// - public string Serialize() => string.Join(" ", "moveid", from, to); - - /// - /// Deserializes the specified response text pairs. - /// - /// The response. - /// - /// The deserialized response. - /// - public string Deserialize(IReadOnlyList> response) - { - return string.Join(", ", response); - } - } -} diff --git a/Sources/MpcNET/Commands/Playlist/PlaylistCommand.cs b/Sources/MpcNET/Commands/Playlist/PlaylistCommand.cs deleted file mode 100644 index 4ce6fe8..0000000 --- a/Sources/MpcNET/Commands/Playlist/PlaylistCommand.cs +++ /dev/null @@ -1,41 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) MpcNET. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. -// -// -------------------------------------------------------------------------------------------------------------------- -namespace MpcNET.Commands.Playlist -{ - using System.Collections.Generic; - using System.Linq; - using MpcNET.Types; - - /// - /// Displays the current playlist. - /// https://www.musicpd.org/doc/protocol/queue.html. - /// - public class PlaylistCommand : IMpcCommand> - { - /// - /// Serializes the command. - /// - /// - /// The serialize command. - /// - public string Serialize() => "playlist"; - - /// - /// Deserializes the specified response text pairs. - /// - /// The response. - /// - /// The deserialized response. - /// - public IEnumerable Deserialize(IReadOnlyList> response) - { - var results = response.Select(line => MpdFile.Create(line.Value, int.Parse(line.Key))); - - return results; - } - } -} \ No newline at end of file diff --git a/Sources/MpcNET/Commands/Playlist/PlaylistIdCommand.cs b/Sources/MpcNET/Commands/Playlist/PlaylistIdCommand.cs deleted file mode 100644 index 6716e5e..0000000 --- a/Sources/MpcNET/Commands/Playlist/PlaylistIdCommand.cs +++ /dev/null @@ -1,49 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) MpcNET. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. -// -// -------------------------------------------------------------------------------------------------------------------- -namespace MpcNET.Commands.Playlist -{ - using System.Collections.Generic; - using MpcNET.Types; - - /// - /// Displays song ID in the playlist. - /// https://www.musicpd.org/doc/protocol/queue.html. - /// - public class PlaylistIdCommand : IMpcCommand> - { - private readonly int songId; - - /// - /// Initializes a new instance of the class. - /// - /// The song identifier. - public PlaylistIdCommand(int songId) - { - this.songId = songId; - } - - /// - /// Serializes the command. - /// - /// - /// The serialize command. - /// - public string Serialize() => string.Join(" ", new[] { "playlistid" }, this.songId); - - /// - /// Deserializes the specified response text pairs. - /// - /// The response. - /// - /// The deserialized response. - /// - public IEnumerable Deserialize(IReadOnlyList> response) - { - return MpdFile.CreateList(response); - } - } -} \ No newline at end of file diff --git a/Sources/MpcNET/Commands/Playlist/PlaylistInfoCommand.cs b/Sources/MpcNET/Commands/Playlist/PlaylistInfoCommand.cs deleted file mode 100644 index c1aecea..0000000 --- a/Sources/MpcNET/Commands/Playlist/PlaylistInfoCommand.cs +++ /dev/null @@ -1,38 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) MpcNET. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. -// -// -------------------------------------------------------------------------------------------------------------------- -namespace MpcNET.Commands.Playlist -{ - using System.Collections.Generic; - using MpcNET.Types; - - /// - /// Displays a list of all songs in the playlist. - /// https://www.musicpd.org/doc/protocol/queue.html. - /// - public class PlaylistInfoCommand : IMpcCommand> - { - /// - /// Serializes the command. - /// - /// - /// The serialize command. - /// - public string Serialize() => "playlistinfo"; - - /// - /// Deserializes the specified response text pairs. - /// - /// The response. - /// - /// The deserialized response. - /// - public IEnumerable Deserialize(IReadOnlyList> response) - { - return MpdFile.CreateList(response); - } - } -} \ No newline at end of file diff --git a/Sources/MpcNET/IMpcConnectionReporter.cs b/Sources/MpcNET/IMpcConnectionReporter.cs deleted file mode 100644 index 59d67f7..0000000 --- a/Sources/MpcNET/IMpcConnectionReporter.cs +++ /dev/null @@ -1,80 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) MpcNET. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace MpcNET -{ - using System; - using Sundew.Base.Reporting; - - /// - /// Interface for implementing an observer for . - /// - public interface IMpcConnectionReporter : IReporter - { - /// - /// Called when connecting. - /// - /// if set to true [is reconnect]. - /// The connect attempt. - void Connecting(bool isReconnect, int connectAttempt); - - /// - /// Called when connection is accepted. - /// - /// if set to true [is reconnect]. - /// The connect attempt. - void ConnectionAccepted(bool isReconnect, int connectAttempt); - - /// - /// Called when connected. - /// - /// if set to true [is reconnect]. - /// The connect attempt. - /// The connection information. - void Connected(bool isReconnect, int connectAttempt, string connectionInfo); - - /// - /// Called when sending command. - /// - /// The command. - void Sending(string command); - - /// - /// Called when send exception occured. - /// - /// The command text. - /// The send attempt. - /// The exception. - void SendException(string commandText, int sendAttempt, Exception exception); - - /// - /// Called when send is retried. - /// - /// The command. - /// The send attempt. - void RetrySend(string command, int sendAttempt); - - /// - /// Called when response is read. - /// - /// The response line. - /// The command text. - void ReadResponse(string responseLine, string commandText); - - /// - /// Called when disconnecting. - /// - /// if set to true the disconnect was explicitly called. - void Disconnecting(bool isExplicitDisconnect); - - /// - /// Called when disconnected. - /// - /// if set to true the disconnect was explicitly called. - void Disconnected(bool isExplicitDisconnect); - } -} \ No newline at end of file diff --git a/Sources/MpcNET/MpcNET.csproj b/Sources/MpcNET/MpcNET.csproj index 4116083..3e9840c 100644 --- a/Sources/MpcNET/MpcNET.csproj +++ b/Sources/MpcNET/MpcNET.csproj @@ -22,7 +22,7 @@ README.md https://github.com/Difegue/MpcNET mpd;client;mpcNET - D:\Projects\LibMpcNETNuGet\LICENSE + MIT True @@ -55,6 +55,10 @@ + + True + + True diff --git a/Sources/MpcNET/icon.png b/icon.png similarity index 100% rename from Sources/MpcNET/icon.png rename to icon.png