diff --git a/NEWS b/NEWS index 7a87dd67fb..e0c7d17177 100644 --- a/NEWS +++ b/NEWS @@ -10,7 +10,7 @@ ver 0.24 (not yet released) - show PCRE support in "config" response - apply Unicode normalization to case-insensitive filter expressions - stickers on playlists and some tag types - - new commands "stickernames" and "playlistlength" + - new commands "stickernames", "stickertypes" and "playlistlength" - new "search"/"find" filter "added-since" - allow range in listplaylist and listplaylistinfo - "sticker find" supports sort and window parameter and new sticker compare operators "eq", "lt" and "gt" diff --git a/doc/protocol.rst b/doc/protocol.rst index d46c4d9a21..7260135994 100644 --- a/doc/protocol.rst +++ b/doc/protocol.rst @@ -1579,6 +1579,9 @@ Examples: :command:`stickernames` Gets a list of uniq sticker names. +:command:`stickertypes` + Shows a list of available sticker types. + Connection settings =================== diff --git a/src/command/AllCommands.cxx b/src/command/AllCommands.cxx index 1e7b1c4fb2..40b844af3c 100644 --- a/src/command/AllCommands.cxx +++ b/src/command/AllCommands.cxx @@ -188,6 +188,7 @@ static constexpr struct command commands[] = { #ifdef ENABLE_SQLITE { "sticker", PERMISSION_ADMIN, 3, -1, handle_sticker }, { "stickernames", PERMISSION_ADMIN, 0, 0, handle_sticker_names }, + { "stickertypes", PERMISSION_ADMIN, 0, 0, handle_sticker_types }, #endif { "stop", PERMISSION_PLAYER, 0, 0, handle_stop }, { "subscribe", PERMISSION_READ, 1, 1, handle_subscribe }, diff --git a/src/command/StickerCommands.cxx b/src/command/StickerCommands.cxx index 33e843b0bc..9a2944322c 100644 --- a/src/command/StickerCommands.cxx +++ b/src/command/StickerCommands.cxx @@ -17,6 +17,7 @@ #include "Instance.hxx" #include "util/StringAPI.hxx" #include "util/ScopeExit.hxx" +#include "tag/Settings.hxx" #include "tag/ParseName.hxx" #include "tag/Names.hxx" #include "sticker/TagSticker.hxx" @@ -25,6 +26,7 @@ #include "db/PlaylistInfo.hxx" #include "db/PlaylistVector.hxx" #include "db/DatabaseLock.hxx" +#include #include "song/Filter.hxx" namespace { @@ -454,3 +456,20 @@ handle_sticker(Client &client, Request args, Response &r) r.Error(ACK_ERROR_ARG, "bad request"); return CommandResult::ERROR; } + +CommandResult +handle_sticker_types(Client &client, Request args, Response &r) +{ + (void) client; + (void) args; + const auto tag_mask = global_tag_mask & r.GetTagMask(); + + r.Fmt("stickertype: filter\n"); + r.Fmt("stickertype: playlist\n"); + r.Fmt("stickertype: song\n"); + for (unsigned i = 0; i < TAG_NUM_OF_ITEM_TYPES; i++) + if (sticker_allowed_tags.Test(TagType(i)) && + tag_mask.Test(TagType(i))) + r.Fmt(FMT_STRING("stickertype: {}\n"), tag_item_names[i]); + return CommandResult::OK; +} diff --git a/src/command/StickerCommands.hxx b/src/command/StickerCommands.hxx index aa3aeef2cd..8b5d4efa14 100644 --- a/src/command/StickerCommands.hxx +++ b/src/command/StickerCommands.hxx @@ -14,5 +14,7 @@ CommandResult handle_sticker(Client &client, Request request, Response &response); CommandResult handle_sticker_names(Client &client, Request request, Response &response); +CommandResult +handle_sticker_types(Client &client, Request request, Response &response); #endif