db/DatabaseListener: add method OnDatabaseSongRemoved()

Decouples db/update/Remove.cpp from global variables.
This commit is contained in:
Max Kellermann
2014-02-04 19:16:30 +01:00
parent ce73843014
commit ff665b37cb
10 changed files with 49 additions and 38 deletions

View File

@@ -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