aboutsummaryrefslogtreecommitdiffstats
path: root/src/Instance.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-02-04 19:16:30 +0100
committerMax Kellermann <max@duempel.org>2014-02-04 19:53:37 +0100
commitff665b37cb92e2a1664bbab207030a1eedfbb036 (patch)
tree1325b9260c35080b5140eed90a65211276aa946c /src/Instance.cxx
parentce738430147427b3bb44063a96cedbae4c53a03d (diff)
downloadmpd-ff665b37cb92e2a1664bbab207030a1eedfbb036.tar.gz
mpd-ff665b37cb92e2a1664bbab207030a1eedfbb036.tar.xz
mpd-ff665b37cb92e2a1664bbab207030a1eedfbb036.zip
db/DatabaseListener: add method OnDatabaseSongRemoved()
Decouples db/update/Remove.cpp from global variables.
Diffstat (limited to 'src/Instance.cxx')
-rw-r--r--src/Instance.cxx29
1 files changed, 22 insertions, 7 deletions
diff --git a/src/Instance.cxx b/src/Instance.cxx
index db81a2542..232cd21df 100644
--- a/src/Instance.cxx
+++ b/src/Instance.cxx
@@ -22,9 +22,15 @@
#include "Partition.hxx"
#include "Idle.hxx"
#include "Stats.hxx"
-#include "db/DatabaseError.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)
@@ -34,12 +40,6 @@ Instance::GetDatabase(Error &error)
return database;
}
-void
-Instance::DeleteSong(const char *uri)
-{
- partition->DeleteSong(uri);
-}
-
#endif
void
@@ -68,6 +68,21 @@ Instance::OnDatabaseModified()
idle_add(IDLE_DATABASE);
}
+void
+Instance::OnDatabaseSongRemoved(const LightSong &song)
+{
+ 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