Skip to content

Commit

Permalink
Merge branch 'stickertypes' of https://github.com/jcorporation/MPD
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxKellermann committed Aug 30, 2024
2 parents d207c14 + f94caa9 commit 39937be
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 3 additions & 0 deletions doc/protocol.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
===================

Expand Down
1 change: 1 addition & 0 deletions src/command/AllCommands.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down
19 changes: 19 additions & 0 deletions src/command/StickerCommands.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -25,6 +26,7 @@
#include "db/PlaylistInfo.hxx"
#include "db/PlaylistVector.hxx"
#include "db/DatabaseLock.hxx"
#include <fmt/format.h>
#include "song/Filter.hxx"

namespace {
Expand Down Expand Up @@ -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;
}
2 changes: 2 additions & 0 deletions src/command/StickerCommands.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 39937be

Please sign in to comment.