diff options
author | Max Kellermann <max@duempel.org> | 2014-04-24 10:20:24 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-04-24 11:38:49 +0200 |
commit | ae178c77bdc47c954fd9a4b32ffc07fe6c4a8a49 (patch) | |
tree | fd96f595113e5044be4cf4b18f17c3a1fdbf3ff9 /src/db/plugins | |
parent | 22206512539aa9a888fdba68d60324c560389d5d (diff) | |
download | mpd-ae178c77bdc47c954fd9a4b32ffc07fe6c4a8a49.tar.gz mpd-ae178c77bdc47c954fd9a4b32ffc07fe6c4a8a49.tar.xz mpd-ae178c77bdc47c954fd9a4b32ffc07fe6c4a8a49.zip |
DatabaseCommands: "list" allows grouping
Diffstat (limited to '')
-rw-r--r-- | src/db/plugins/LazyDatabase.cxx | 7 | ||||
-rw-r--r-- | src/db/plugins/LazyDatabase.hxx | 4 | ||||
-rw-r--r-- | src/db/plugins/ProxyDatabasePlugin.cxx | 13 | ||||
-rw-r--r-- | src/db/plugins/simple/SimpleDatabasePlugin.cxx | 7 | ||||
-rw-r--r-- | src/db/plugins/simple/SimpleDatabasePlugin.hxx | 4 | ||||
-rw-r--r-- | src/db/plugins/upnp/UpnpDatabasePlugin.cxx | 19 |
6 files changed, 33 insertions, 21 deletions
diff --git a/src/db/plugins/LazyDatabase.cxx b/src/db/plugins/LazyDatabase.cxx index 2b576b1ee..bc52395c5 100644 --- a/src/db/plugins/LazyDatabase.cxx +++ b/src/db/plugins/LazyDatabase.cxx @@ -85,12 +85,13 @@ LazyDatabase::Visit(const DatabaseSelection &selection, bool LazyDatabase::VisitUniqueTags(const DatabaseSelection &selection, - TagType tag_type, - VisitString visit_string, + TagType tag_type, uint32_t group_mask, + VisitTag visit_tag, Error &error) const { return EnsureOpen(error) && - db->VisitUniqueTags(selection, tag_type, visit_string, error); + db->VisitUniqueTags(selection, tag_type, group_mask, visit_tag, + error); } bool diff --git a/src/db/plugins/LazyDatabase.hxx b/src/db/plugins/LazyDatabase.hxx index 000b63a98..ae1b961d0 100644 --- a/src/db/plugins/LazyDatabase.hxx +++ b/src/db/plugins/LazyDatabase.hxx @@ -52,8 +52,8 @@ public: Error &error) const override; virtual bool VisitUniqueTags(const DatabaseSelection &selection, - TagType tag_type, - VisitString visit_string, + TagType tag_type, uint32_t group_mask, + VisitTag visit_tag, Error &error) const override; virtual bool GetStats(const DatabaseSelection &selection, diff --git a/src/db/plugins/ProxyDatabasePlugin.cxx b/src/db/plugins/ProxyDatabasePlugin.cxx index 0ab25005a..a3cc640cf 100644 --- a/src/db/plugins/ProxyDatabasePlugin.cxx +++ b/src/db/plugins/ProxyDatabasePlugin.cxx @@ -112,8 +112,8 @@ public: Error &error) const override; virtual bool VisitUniqueTags(const DatabaseSelection &selection, - TagType tag_type, - VisitString visit_string, + TagType tag_type, uint32_t group_mask, + VisitTag visit_tag, Error &error) const override; virtual bool GetStats(const DatabaseSelection &selection, @@ -715,7 +715,8 @@ ProxyDatabase::Visit(const DatabaseSelection &selection, bool ProxyDatabase::VisitUniqueTags(const DatabaseSelection &selection, TagType tag_type, - VisitString visit_string, + gcc_unused uint32_t group_mask, + VisitTag visit_tag, Error &error) const { // TODO: eliminate the const_cast @@ -734,6 +735,8 @@ ProxyDatabase::VisitUniqueTags(const DatabaseSelection &selection, if (!SendConstraints(connection, selection)) return CheckError(connection, error); + // TODO: use group_mask + if (!mpd_search_commit(connection)) return CheckError(connection, error); @@ -742,7 +745,9 @@ ProxyDatabase::VisitUniqueTags(const DatabaseSelection &selection, struct mpd_pair *pair; while (result && (pair = mpd_recv_pair_tag(connection, tag_type2)) != nullptr) { - result = visit_string(pair->value, error); + TagBuilder tag; + tag.AddItem(tag_type, pair->value); + result = visit_tag(tag.Commit(), error); mpd_return_pair(connection, pair); } diff --git a/src/db/plugins/simple/SimpleDatabasePlugin.cxx b/src/db/plugins/simple/SimpleDatabasePlugin.cxx index 68101f564..d616c793f 100644 --- a/src/db/plugins/simple/SimpleDatabasePlugin.cxx +++ b/src/db/plugins/simple/SimpleDatabasePlugin.cxx @@ -334,11 +334,12 @@ SimpleDatabase::Visit(const DatabaseSelection &selection, bool SimpleDatabase::VisitUniqueTags(const DatabaseSelection &selection, - TagType tag_type, - VisitString visit_string, + TagType tag_type, uint32_t group_mask, + VisitTag visit_tag, Error &error) const { - return ::VisitUniqueTags(*this, selection, tag_type, visit_string, + return ::VisitUniqueTags(*this, selection, tag_type, group_mask, + visit_tag, error); } diff --git a/src/db/plugins/simple/SimpleDatabasePlugin.hxx b/src/db/plugins/simple/SimpleDatabasePlugin.hxx index a03969f92..e27b3d956 100644 --- a/src/db/plugins/simple/SimpleDatabasePlugin.hxx +++ b/src/db/plugins/simple/SimpleDatabasePlugin.hxx @@ -116,8 +116,8 @@ public: Error &error) const override; virtual bool VisitUniqueTags(const DatabaseSelection &selection, - TagType tag_type, - VisitString visit_string, + TagType tag_type, uint32_t group_mask, + VisitTag visit_tag, Error &error) const override; virtual bool GetStats(const DatabaseSelection &selection, diff --git a/src/db/plugins/upnp/UpnpDatabasePlugin.cxx b/src/db/plugins/upnp/UpnpDatabasePlugin.cxx index abc7638f8..66951f402 100644 --- a/src/db/plugins/upnp/UpnpDatabasePlugin.cxx +++ b/src/db/plugins/upnp/UpnpDatabasePlugin.cxx @@ -94,8 +94,8 @@ public: Error &error) const override; virtual bool VisitUniqueTags(const DatabaseSelection &selection, - TagType tag_type, - VisitString visit_string, + TagType tag_type, uint32_t group_mask, + VisitTag visit_tag, Error &error) const override; virtual bool GetStats(const DatabaseSelection &selection, @@ -721,11 +721,13 @@ UpnpDatabase::Visit(const DatabaseSelection &selection, bool UpnpDatabase::VisitUniqueTags(const DatabaseSelection &selection, - TagType tag, - VisitString visit_string, + TagType tag, gcc_unused uint32_t group_mask, + VisitTag visit_tag, Error &error) const { - if (!visit_string) + // TODO: use group_mask + + if (!visit_tag) return true; std::vector<ContentDirectoryService> servers; @@ -754,9 +756,12 @@ UpnpDatabase::VisitUniqueTags(const DatabaseSelection &selection, } } - for (const auto& value : values) - if (!visit_string(value.c_str(), error)) + for (const auto& value : values) { + TagBuilder builder; + builder.AddItem(tag, value.c_str()); + if (!visit_tag(builder.Commit(), error)) return false; + } return true; } |