summaryrefslogtreecommitdiff
path: root/src/mpdpp.cpp
diff options
context:
space:
mode:
authorAndrzej Rybczak <electricityispower@gmail.com>2014-11-02 00:22:02 +0100
committerAndrzej Rybczak <electricityispower@gmail.com>2014-11-02 22:14:29 +0100
commit0457af36fef70d795afaf56c13a105b2016caad6 (patch)
tree7891f7cea36ec7b8c6f1ce0108dd903e9825fe0b /src/mpdpp.cpp
parent30d57afcace02b6347cd5e644bd0a987717237fc (diff)
mpd: redesign Item and adjust browser
Diffstat (limited to 'src/mpdpp.cpp')
-rw-r--r--src/mpdpp.cpp40
1 files changed, 6 insertions, 34 deletions
diff --git a/src/mpdpp.cpp b/src/mpdpp.cpp
index 48241f39..1eeeed36 100644
--- a/src/mpdpp.cpp
+++ b/src/mpdpp.cpp
@@ -336,13 +336,13 @@ SongIterator Connection::GetPlaylistContentNoInfo(const std::string &path)
return result;
}
-void Connection::GetSupportedExtensions(std::set<std::string> &acc)
+void Connection::GetSupportedExtensions(StringConsumer f)
{
prechecksNoCommandsList();
mpd_send_command(m_connection.get(), "decoders", NULL);
while (mpd_pair *pair = mpd_recv_pair_named(m_connection.get(), "suffix"))
{
- acc.insert(pair->value);
+ f(pair->value);
mpd_return_pair(m_connection.get(), pair);
}
mpd_response_finish(m_connection.get());
@@ -677,48 +677,20 @@ void Connection::CommitSearchTags(StringConsumer f)
checkErrors();
}
-void Connection::GetDirectory(const std::string &directory, ItemConsumer f)
+ItemIterator Connection::GetDirectory(const std::string &directory)
{
prechecksNoCommandsList();
mpd_send_list_meta(m_connection.get(), directory.c_str());
- while (mpd_entity *item = mpd_recv_entity(m_connection.get()))
- {
- Item it;
- switch (mpd_entity_get_type(item))
- {
- case MPD_ENTITY_TYPE_DIRECTORY:
- it.name = mpd_directory_get_path(mpd_entity_get_directory(item));
- it.type = MPD::Item::Type::Directory;
- break;
- case MPD_ENTITY_TYPE_SONG:
- it.song = Song(mpd_song_dup(mpd_entity_get_song(item)));
- it.type = MPD::Item::Type::Song;
- break;
- case MPD_ENTITY_TYPE_PLAYLIST:
- it.name = mpd_playlist_get_path(mpd_entity_get_playlist(item));
- it.type = MPD::Item::Type::Playlist;
- break;
- default:
- assert(false);
- }
- mpd_entity_free(item);
- f(std::move(it));
- }
- mpd_response_finish(m_connection.get());
checkErrors();
+ return ItemIterator(m_connection.get(), mpd_recv_entity);
}
-void Connection::GetDirectoryRecursive(const std::string &directory, SongConsumer f)
+ItemIterator Connection::GetDirectoryRecursive(const std::string &directory)
{
prechecksNoCommandsList();
mpd_send_list_all_meta(m_connection.get(), directory.c_str());
- while (mpd_entity *e = mpd_recv_entity(m_connection.get())) {
- if (mpd_entity_get_type(e) == MPD_ENTITY_TYPE_SONG)
- f(Song(mpd_song_dup(mpd_entity_get_song(e))));
- mpd_entity_free(e);
- }
- mpd_response_finish(m_connection.get());
checkErrors();
+ return ItemIterator(m_connection.get(), mpd_recv_entity);
}
void Connection::GetDirectories(const std::string &directory, StringConsumer f)