aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--Makefile.am2
-rw-r--r--src/command.c15
-rw-r--r--src/db_print.c17
-rw-r--r--src/db_print.h6
-rw-r--r--src/directory_print.c74
-rw-r--r--src/directory_print.h29
-rw-r--r--src/song_print.c15
-rw-r--r--src/song_print.h3
8 files changed, 27 insertions, 134 deletions
diff --git a/Makefile.am b/Makefile.am
index 0fa75615c..b37799e2d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -78,7 +78,6 @@ mpd_headers = \
src/decoder_internal.h \
src/directory.h \
src/directory_save.h \
- src/directory_print.h \
src/database.h \
src/encoder_plugin.h \
src/encoder_list.h \
@@ -269,7 +268,6 @@ src_mpd_SOURCES = \
src/decoder_print.c \
src/directory.c \
src/directory_save.c \
- src/directory_print.c \
src/database.c \
src/db_error.h \
src/db_save.c src/db_save.h \
diff --git a/src/command.c b/src/command.c
index 13b3d4ca0..eb2b9ae4f 100644
--- a/src/command.c
+++ b/src/command.c
@@ -30,7 +30,6 @@
#include "uri.h"
#include "decoder_print.h"
#include "directory.h"
-#include "directory_print.h"
#include "database.h"
#include "update.h"
#include "volume.h"
@@ -45,6 +44,7 @@
#include "dbUtils.h"
#include "db_error.h"
#include "db_print.h"
+#include "db_selection.h"
#include "tag.h"
#include "client.h"
#include "client_idle.h"
@@ -840,7 +840,6 @@ static enum command_return
handle_lsinfo(struct client *client, int argc, char *argv[])
{
const char *uri;
- const struct directory *directory;
if (argc == 2)
uri = argv[1];
@@ -848,14 +847,12 @@ handle_lsinfo(struct client *client, int argc, char *argv[])
/* default is root directory */
uri = "";
- directory = db_get_directory(uri);
- if (directory == NULL) {
- command_error(client, ACK_ERROR_NO_EXIST,
- "directory not found");
- return COMMAND_RETURN_ERROR;
- }
+ struct db_selection selection;
+ db_selection_init(&selection, uri, false);
- directory_print(client, directory);
+ GError *error = NULL;
+ if (!db_selection_print(client, &selection, true, &error))
+ return print_error(client, error);
if (isRootDirectory(uri)) {
GPtrArray *list = spl_list(NULL);
diff --git a/src/db_print.c b/src/db_print.c
index 8f9bd5b97..f341ca4e8 100644
--- a/src/db_print.c
+++ b/src/db_print.c
@@ -19,6 +19,7 @@
#include "config.h"
#include "db_print.h"
+#include "db_selection.h"
#include "db_visitor.h"
#include "locate.h"
#include "directory.h"
@@ -119,6 +120,14 @@ static const struct db_visitor print_info_visitor = {
.playlist = print_visitor_playlist_info,
};
+bool
+db_selection_print(struct client *client, const struct db_selection *selection,
+ bool full, GError **error_r)
+{
+ return db_visit(selection, full ? &print_info_visitor : &print_visitor,
+ client, error_r);
+}
+
struct search_data {
struct client *client;
const struct locate_item_list *criteria;
@@ -233,14 +242,18 @@ searchStatsForSongsIn(struct client *client, const char *name,
bool
printAllIn(struct client *client, const char *uri_utf8, GError **error_r)
{
- return db_walk(uri_utf8, &print_visitor, client, error_r);
+ struct db_selection selection;
+ db_selection_init(&selection, uri_utf8, true);
+ return db_selection_print(client, &selection, false, error_r);
}
bool
printInfoForAllIn(struct client *client, const char *uri_utf8,
GError **error_r)
{
- return db_walk(uri_utf8, &print_info_visitor, client, error_r);
+ struct db_selection selection;
+ db_selection_init(&selection, uri_utf8, true);
+ return db_selection_print(client, &selection, true, error_r);
}
static ListCommandItem *
diff --git a/src/db_print.h b/src/db_print.h
index 76e43c3a0..1b957da18 100644
--- a/src/db_print.h
+++ b/src/db_print.h
@@ -27,10 +27,16 @@
struct client;
struct locate_item_list;
+struct db_selection;
struct db_visitor;
gcc_nonnull(1,2)
bool
+db_selection_print(struct client *client, const struct db_selection *selection,
+ bool full, GError **error_r);
+
+gcc_nonnull(1,2)
+bool
printAllIn(struct client *client, const char *uri_utf8, GError **error_r);
gcc_nonnull(1,2)
diff --git a/src/directory_print.c b/src/directory_print.c
deleted file mode 100644
index 8cd906b7b..000000000
--- a/src/directory_print.c
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (C) 2003-2011 The Music Player Daemon Project
- * http://www.musicpd.org
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include "config.h"
-#include "directory_print.h"
-#include "directory.h"
-#include "client.h"
-#include "song_print.h"
-#include "mapper.h"
-#include "decoder_list.h"
-#include "path.h"
-#include "uri.h"
-#include "input_stream.h"
-
-#include <sys/types.h>
-#include <dirent.h>
-
-static void
-dirvec_print(struct client *client, const struct dirvec *dv)
-{
- size_t i;
-
- for (i = 0; i < dv->nr; ++i)
- client_printf(client, DIRECTORY_DIR "%s\n",
- directory_get_path(dv->base[i]));
-}
-
-static void
-print_playlist_in_directory(struct client *client,
- const struct directory *directory,
- const char *name_utf8)
-{
- if (directory_is_root(directory))
- client_printf(client, "playlist: %s\n", name_utf8);
- else
- client_printf(client, "playlist: %s/%s\n",
- directory_get_path(directory), name_utf8);
-}
-
-/**
- * Print a list of playlists in the specified directory.
- */
-static void
-directory_print_playlists(struct client *client,
- const struct directory *directory)
-{
- for (const struct playlist_metadata *pm = directory->playlists.head;
- pm != NULL; pm = pm->next)
- print_playlist_in_directory(client, directory, pm->name);
-}
-
-void
-directory_print(struct client *client, const struct directory *directory)
-{
- dirvec_print(client, &directory->children);
- songvec_print(client, &directory->songs);
- directory_print_playlists(client, directory);
-}
diff --git a/src/directory_print.h b/src/directory_print.h
deleted file mode 100644
index 9a10a1fe5..000000000
--- a/src/directory_print.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (C) 2003-2011 The Music Player Daemon Project
- * http://www.musicpd.org
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#ifndef MPD_DIRECTORY_PRINT_H
-#define MPD_DIRECTORY_PRINT_H
-
-struct client;
-struct directory;
-
-void
-directory_print(struct client *client, const struct directory *directory);
-
-#endif
diff --git a/src/song_print.c b/src/song_print.c
index e0a04ddbd..2065b336d 100644
--- a/src/song_print.c
+++ b/src/song_print.c
@@ -94,18 +94,3 @@ song_print_info(struct client *client, struct song *song)
if (song->tag)
tag_print(client, song->tag);
}
-
-static int
-song_print_info_x(struct song *song, void *data)
-{
- struct client *client = data;
- song_print_info(client, song);
-
- return 0;
-}
-
-void
-songvec_print(struct client *client, const struct songvec *sv)
-{
- songvec_for_each(sv, song_print_info_x, client);
-}
diff --git a/src/song_print.h b/src/song_print.h
index 506284ea0..8f1f0cc65 100644
--- a/src/song_print.h
+++ b/src/song_print.h
@@ -28,9 +28,6 @@ void
song_print_info(struct client *client, struct song *song);
void
-songvec_print(struct client *client, const struct songvec *sv);
-
-void
song_print_uri(struct client *client, struct song *song);
#endif