aboutsummaryrefslogtreecommitdiffstats
path: root/test/DumpDatabase.cxx
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--test/DumpDatabase.cxx70
1 files changed, 44 insertions, 26 deletions
diff --git a/test/DumpDatabase.cxx b/test/DumpDatabase.cxx
index 21a12d294..d282e9360 100644
--- a/test/DumpDatabase.cxx
+++ b/test/DumpDatabase.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2012 The Music Player Daemon Project
+ * Copyright (C) 2003-2014 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -18,16 +18,18 @@
*/
#include "config.h"
-#include "DatabaseRegistry.hxx"
-#include "DatabasePlugin.hxx"
-#include "DatabaseSelection.hxx"
-#include "Directory.hxx"
-#include "Song.hxx"
-#include "PlaylistVector.hxx"
-#include "ConfigGlobal.hxx"
-#include "ConfigData.hxx"
+#include "db/Registry.hxx"
+#include "db/DatabasePlugin.hxx"
+#include "db/Selection.hxx"
+#include "db/DatabaseListener.hxx"
+#include "db/LightDirectory.hxx"
+#include "db/LightSong.hxx"
+#include "db/PlaylistVector.hxx"
+#include "config/ConfigGlobal.hxx"
+#include "config/ConfigData.hxx"
#include "tag/TagConfig.hxx"
#include "fs/Path.hxx"
+#include "event/Loop.hxx"
#include "util/Error.hxx"
#include <glib.h>
@@ -39,35 +41,49 @@ 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 "input/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;
+ }
+
+ virtual void OnDatabaseSongRemoved(const LightSong &song) override {
+ cout << "SongRemoved " << song.GetURI() << endl;
+ }
+};
static bool
-DumpDirectory(const Directory &directory, Error &)
+DumpDirectory(const LightDirectory &directory, Error &)
{
- cout << "D " << directory.path << endl;
+ cout << "D " << directory.GetPath() << endl;
return true;
}
static bool
-DumpSong(Song &song, Error &)
+DumpSong(const LightSong &song, Error &)
{
- cout << "S " << song.parent->path << "/" << song.uri << endl;
+ cout << "S ";
+ if (song.directory != nullptr)
+ cout << song.directory << "/";
+ cout << song.uri << endl;
return true;
}
static bool
DumpPlaylist(const PlaylistInfo &playlist,
- const Directory &directory, Error &)
+ const LightDirectory &directory, Error &)
{
- cout << "P " << directory.path << "/" << playlist.name.c_str() << endl;
+ cout << "P " << directory.GetPath()
+ << "/" << playlist.name.c_str() << endl;
return true;
}
@@ -94,8 +110,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 +122,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;