From 45a4fcab1e16834231da4ce363941da0086430ae Mon Sep 17 00:00:00 2001 From: jcorporation Date: Thu, 2 Nov 2023 21:22:48 +0100 Subject: [PATCH] Add support for added attribute to proxy plugin --- src/db/plugins/ProxyDatabasePlugin.cxx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/db/plugins/ProxyDatabasePlugin.cxx b/src/db/plugins/ProxyDatabasePlugin.cxx index f46c95702..18b858cf8 100644 --- a/src/db/plugins/ProxyDatabasePlugin.cxx +++ b/src/db/plugins/ProxyDatabasePlugin.cxx @@ -208,6 +208,11 @@ ProxySong::ProxySong(const mpd_song *song) const auto _mtime = mpd_song_get_last_modified(song); if (_mtime > 0) mtime = std::chrono::system_clock::from_time_t(_mtime); + #if LIBMPDCLIENT_CHECK_VERSION(2,21,0) + const auto _added = mpd_song_get_added(song); + if (added > 0) + added = std::chrono::system_clock::from_time_t(_mtime); + #endif start_time = SongTime::FromS(mpd_song_get_start(song)); end_time = SongTime::FromS(mpd_song_get_end(song)); @@ -328,6 +333,12 @@ SendConstraints(mpd_connection *connection, const DatabaseSelection &selection, if (!mpd_search_add_sort_name(connection, "Last-Modified", selection.descending)) return false; + #if LIBMPDCLIENT_CHECK_VERSION(2,21,0) + } else if (selection.sort == SORT_TAG_ADDED) { + if (!mpd_search_add_sort_name(connection, "Added", + selection.descending)) + return false; + #endif } else { const auto sort = Convert(selection.sort); /* if this is an unsupported tag, the sort @@ -808,6 +819,11 @@ IsSortSupported(TagType tag_type) noexcept if (tag_type == TagType(SORT_TAG_LAST_MODIFIED)) { return true; } + #if LIBMPDCLIENT_CHECK_VERSION(2,21,0) + if (tag_type == TagType(SORT_TAG_ADDED)) { + return true; + } + #endif return Convert(tag_type) != MPD_TAG_COUNT; }