aboutsummaryrefslogtreecommitdiffstats
path: root/src/dbUtils.c
diff options
context:
space:
mode:
authorgeneticdrift <geneticdrift@iotide.com>2012-06-27 09:26:00 +0200
committerMax Kellermann <max@duempel.org>2012-06-27 09:41:15 +0200
commit16e91baa799e579aa0bad78d7f4291aec8ab7a05 (patch)
tree9e9fc0fa73b9683f3321a559fb7bfdccfbbe1f01 /src/dbUtils.c
parentf2536445f78389da0a3c68f3526968e47d658e98 (diff)
downloadmpd-16e91baa799e579aa0bad78d7f4291aec8ab7a05.tar.gz
mpd-16e91baa799e579aa0bad78d7f4291aec8ab7a05.tar.xz
mpd-16e91baa799e579aa0bad78d7f4291aec8ab7a05.zip
New command searchadd similar to command findadd.
Diffstat (limited to 'src/dbUtils.c')
-rw-r--r--src/dbUtils.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/dbUtils.c b/src/dbUtils.c
index 827d0a0c1..5a30c14be 100644
--- a/src/dbUtils.c
+++ b/src/dbUtils.c
@@ -122,3 +122,45 @@ findAddIn(struct player_control *pc, const char *name,
return db_walk(name, &find_add_visitor, &data, error_r);
}
+
+static bool
+searchadd_visitor_song(struct song *song, void *_data, GError **error_r)
+{
+ struct find_add_data *data = _data;
+
+ if (!locate_song_search(song, data->criteria))
+ return true;
+
+ enum playlist_result result =
+ playlist_append_song(&g_playlist, data->pc, song, NULL);
+ if (result != PLAYLIST_RESULT_SUCCESS) {
+ g_set_error(error_r, playlist_quark(), result,
+ "Playlist error");
+ return false;
+ }
+
+ return true;
+}
+
+static const struct db_visitor searchadd_visitor = {
+ .song = searchadd_visitor_song,
+};
+
+bool
+search_add_songs(struct player_control *pc, const char *uri,
+ const struct locate_item_list *criteria,
+ GError **error_r)
+{
+ struct locate_item_list *new_list =
+ locate_item_list_casefold(criteria);
+ struct find_add_data data = {
+ .pc = pc,
+ .criteria = new_list,
+ };
+
+ bool success = db_walk(uri, &searchadd_visitor, &data, error_r);
+
+ locate_item_list_free(new_list);
+
+ return success;
+}