aboutsummaryrefslogtreecommitdiffstats
path: root/test/DumpDatabase.cxx
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--test/DumpDatabase.cxx37
1 files changed, 25 insertions, 12 deletions
diff --git a/test/DumpDatabase.cxx b/test/DumpDatabase.cxx
index 21a12d294..ff3464099 100644
--- a/test/DumpDatabase.cxx
+++ b/test/DumpDatabase.cxx
@@ -21,6 +21,7 @@
#include "DatabaseRegistry.hxx"
#include "DatabasePlugin.hxx"
#include "DatabaseSelection.hxx"
+#include "DatabaseListener.hxx"
#include "Directory.hxx"
#include "Song.hxx"
#include "PlaylistVector.hxx"
@@ -28,6 +29,7 @@
#include "ConfigData.hxx"
#include "tag/TagConfig.hxx"
#include "fs/Path.hxx"
+#include "event/Loop.hxx"
#include "util/Error.hxx"
#include <glib.h>
@@ -39,15 +41,21 @@ using std::endl;
#include <stdlib.h>
-static void
-my_log_func(const gchar *log_domain, gcc_unused GLogLevelFlags log_level,
- const gchar *message, gcc_unused gpointer user_data)
+#ifdef HAVE_LIBUPNP
+#include "InputStream.hxx"
+size_t
+InputStream::LockRead(void *, size_t, Error &)
{
- if (log_domain != NULL)
- g_printerr("%s: %s\n", log_domain, message);
- else
- g_printerr("%s\n", message);
+ return 0;
}
+#endif
+
+class MyDatabaseListener final : public DatabaseListener {
+public:
+ virtual void OnDatabaseModified() override {
+ cout << "DatabaseModified" << endl;
+ }
+};
static bool
DumpDirectory(const Directory &directory, Error &)
@@ -59,7 +67,10 @@ DumpDirectory(const Directory &directory, Error &)
static bool
DumpSong(Song &song, Error &)
{
- cout << "S " << song.parent->path << "/" << song.uri << endl;
+ cout << "S ";
+ if (song.parent != nullptr && !song.parent->IsRoot())
+ cout << song.parent->path << "/";
+ cout << song.uri << endl;
return true;
}
@@ -94,8 +105,6 @@ main(int argc, char **argv)
g_thread_init(nullptr);
#endif
- g_log_set_default_handler(my_log_func, nullptr);
-
/* initialize MPD */
config_global_init();
@@ -108,14 +117,18 @@ main(int argc, char **argv)
TagLoadConfig();
+ EventLoop event_loop;
+ MyDatabaseListener database_listener;
+
/* do it */
const struct config_param *path = config_get_param(CONF_DB_FILE);
- config_param param("database", path->line);
+ config_param param("database", path != nullptr ? path->line : -1);
if (path != nullptr)
param.AddBlockParam("path", path->value.c_str(), path->line);
- Database *db = plugin->create(param, error);
+ Database *db = plugin->create(event_loop, database_listener,
+ param, error);
if (db == nullptr) {
cerr << error.GetMessage() << endl;