aboutsummaryrefslogtreecommitdiffstats
path: root/src/command/DatabaseCommands.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-04-24 10:20:24 +0200
committerMax Kellermann <max@duempel.org>2014-04-24 11:38:49 +0200
commitae178c77bdc47c954fd9a4b32ffc07fe6c4a8a49 (patch)
treefd96f595113e5044be4cf4b18f17c3a1fdbf3ff9 /src/command/DatabaseCommands.cxx
parent22206512539aa9a888fdba68d60324c560389d5d (diff)
downloadmpd-ae178c77bdc47c954fd9a4b32ffc07fe6c4a8a49.tar.gz
mpd-ae178c77bdc47c954fd9a4b32ffc07fe6c4a8a49.tar.xz
mpd-ae178c77bdc47c954fd9a4b32ffc07fe6c4a8a49.zip
DatabaseCommands: "list" allows grouping
Diffstat (limited to 'src/command/DatabaseCommands.cxx')
-rw-r--r--src/command/DatabaseCommands.cxx21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/command/DatabaseCommands.cxx b/src/command/DatabaseCommands.cxx
index 71ae3ec8a..23ff593a4 100644
--- a/src/command/DatabaseCommands.cxx
+++ b/src/command/DatabaseCommands.cxx
@@ -32,6 +32,8 @@
#include "SongFilter.hxx"
#include "protocol/Result.hxx"
+#include <string.h>
+
CommandResult
handle_listfiles_db(Client &client, const char *uri)
{
@@ -191,6 +193,7 @@ handle_list(Client &client, int argc, char *argv[])
}
SongFilter *filter = nullptr;
+ uint32_t group_mask = 0;
if (args.size == 1) {
/* for compatibility with < 0.12.0 */
@@ -204,6 +207,22 @@ handle_list(Client &client, int argc, char *argv[])
filter = new SongFilter((unsigned)TAG_ARTIST, args.shift());
}
+ while (args.size >= 2 &&
+ strcmp(args[args.size - 2], "group") == 0) {
+ const char *s = args[args.size - 1];
+ TagType gt = tag_name_parse_i(s);
+ if (gt == TAG_NUM_OF_ITEM_TYPES) {
+ command_error(client, ACK_ERROR_ARG,
+ "Unknown tag type: %s", s);
+ return CommandResult::ERROR;
+ }
+
+ group_mask |= 1u << unsigned(gt);
+
+ args.pop_back();
+ args.pop_back();
+ }
+
if (!args.IsEmpty()) {
filter = new SongFilter();
if (!filter->Parse(args, false)) {
@@ -216,7 +235,7 @@ handle_list(Client &client, int argc, char *argv[])
Error error;
CommandResult ret =
- listAllUniqueTags(client, tagType, filter, error)
+ listAllUniqueTags(client, tagType, group_mask, filter, error)
? CommandResult::OK
: print_error(client, error);