aboutsummaryrefslogtreecommitdiffstats
path: root/src/Instance.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'src/Instance.cxx')
-rw-r--r--src/Instance.cxx72
1 files changed, 63 insertions, 9 deletions
diff --git a/src/Instance.cxx b/src/Instance.cxx
index daad94212..232cd21df 100644
--- a/src/Instance.cxx
+++ b/src/Instance.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2013 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
@@ -21,28 +21,82 @@
#include "Instance.hxx"
#include "Partition.hxx"
#include "Idle.hxx"
+#include "Stats.hxx"
+
+#ifdef ENABLE_DATABASE
+#include "db/DatabaseError.hxx"
+#include "db/LightSong.hxx"
+
+#ifdef ENABLE_SQLITE
+#include "sticker/StickerDatabase.hxx"
+#include "sticker/SongSticker.hxx"
+#endif
+
+Database *
+Instance::GetDatabase(Error &error)
+{
+ if (database == nullptr)
+ error.Set(db_domain, DB_DISABLED, "No database");
+ return database;
+}
+
+#endif
void
-Instance::DeleteSong(const Song &song)
+Instance::TagModified()
{
- partition->DeleteSong(song);
+ partition->TagModified();
}
void
-Instance::DatabaseModified()
+Instance::SyncWithPlayer()
+{
+ partition->SyncWithPlayer();
+}
+
+#ifdef ENABLE_DATABASE
+
+void
+Instance::OnDatabaseModified()
{
- partition->DatabaseModified();
+ assert(database != nullptr);
+
+ /* propagate the change to all subsystems */
+
+ stats_invalidate();
+ partition->DatabaseModified(*database);
idle_add(IDLE_DATABASE);
}
void
-Instance::TagModified()
+Instance::OnDatabaseSongRemoved(const LightSong &song)
{
- partition->TagModified();
+ assert(database != nullptr);
+
+#ifdef ENABLE_SQLITE
+ /* if the song has a sticker, remove it */
+ if (sticker_enabled())
+ sticker_song_delete(song);
+#endif
+
+ const auto uri = song.GetURI();
+ partition->DeleteSong(uri.c_str());
}
+#endif
+
+#ifdef ENABLE_NEIGHBOR_PLUGINS
+
void
-Instance::SyncWithPlayer()
+Instance::FoundNeighbor(gcc_unused const NeighborInfo &info)
{
- partition->SyncWithPlayer();
+ idle_add(IDLE_NEIGHBOR);
}
+
+void
+Instance::LostNeighbor(gcc_unused const NeighborInfo &info)
+{
+ idle_add(IDLE_NEIGHBOR);
+}
+
+#endif