Commit b87bc12c authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen
Browse files

Add on{Artist|Album|AlbumTrack}Added callbacks

parent 12cc0b5d
......@@ -68,6 +68,16 @@ public:
*/
virtual void onMediaUpdated( MediaPtr media ) = 0;
virtual void onArtistAdded( ArtistPtr artist ) = 0;
virtual void onAlbumAdded( AlbumPtr album ) = 0;
/**
* @brief onTrackAdded Called when a media gets detected as an album track
* and after it has been added to the album representation
* @param media The media, containing most of the informations
* @param track Some track specific informations
*/
virtual void onTrackAdded( MediaPtr media, AlbumTrackPtr track ) = 0;
virtual void onDiscoveryStarted( const std::string& entryPoint ) = 0;
virtual void onDiscoveryCompleted( const std::string& entryPoint ) = 0;
virtual void onReloadStarted( const std::string& entryPoint ) = 0;
......
......@@ -450,7 +450,7 @@ void MediaLibrary::startParser()
m_parser.reset( new Parser( m_dbConnection.get(), this, m_callback ) );
auto vlcService = std::unique_ptr<VLCMetadataService>( new VLCMetadataService );
auto metadataService = std::unique_ptr<MetadataParser>( new MetadataParser( m_dbConnection.get() ) );
auto metadataService = std::unique_ptr<MetadataParser>( new MetadataParser( m_dbConnection.get(), m_callback ) );
auto thumbnailerService = std::unique_ptr<VLCThumbnailer>( new VLCThumbnailer );
m_parser->addService( std::move( vlcService ) );
m_parser->addService( std::move( metadataService ) );
......
......@@ -30,8 +30,9 @@
#include "Show.h"
#include "utils/Filename.h"
MetadataParser::MetadataParser( DBConnection dbConnection )
MetadataParser::MetadataParser( DBConnection dbConnection, IMediaLibraryCb* cb )
: m_dbConn( dbConnection )
, m_cb( cb )
{
}
......@@ -250,6 +251,7 @@ std::shared_ptr<Album> MetadataParser::handleAlbum( parser::Task& task, std::sha
if ( task.artworkMrl.length() != 0 )
album->setArtworkMrl( task.artworkMrl );
}
m_cb->onAlbumAdded( album );
}
}
else
......@@ -291,6 +293,7 @@ std::pair<std::shared_ptr<Artist>, std::shared_ptr<Artist>> MetadataParser::hand
LOG_ERROR( "Failed to create new artist ", task.albumArtist );
return {nullptr, nullptr};
}
m_cb->onArtistAdded( albumArtist );
}
}
if ( task.artist.empty() == false && task.artist != task.albumArtist )
......@@ -304,6 +307,7 @@ std::pair<std::shared_ptr<Artist>, std::shared_ptr<Artist>> MetadataParser::hand
LOG_ERROR( "Failed to create new artist ", task.artist );
return {nullptr, nullptr};
}
m_cb->onArtistAdded( artist );
}
}
return {albumArtist, artist};
......@@ -358,6 +362,7 @@ std::shared_ptr<AlbumTrack> MetadataParser::handleTrack( std::shared_ptr<Album>
// using Album class internals.
album->setReleaseYear( releaseYear, false );
}
m_cb->onTrackAdded( task.media, track );
return track;
}
......
......@@ -30,7 +30,7 @@ class AlbumTrack;
class MetadataParser : public ParserService
{
public:
MetadataParser( DBConnection dbConnection );
MetadataParser( DBConnection dbConnection , IMediaLibraryCb* cb );
protected:
virtual bool initialize() override;
virtual parser::Task::Status run( parser::Task& task ) override;
......@@ -47,6 +47,7 @@ protected:
private:
MediaLibrary* m_ml;
IMediaLibraryCb* m_cb;
std::shared_ptr<Artist> m_unknownArtist;
DBConnection m_dbConn;
};
......@@ -41,6 +41,18 @@ public:
{
}
virtual void onArtistAdded( ArtistPtr ) override
{
}
virtual void onAlbumAdded( AlbumPtr ) override
{
}
virtual void onTrackAdded( MediaPtr, AlbumTrackPtr ) override
{
}
virtual void onDiscoveryStarted( const std::string& ) override
{
}
......
......@@ -28,6 +28,10 @@ private:
virtual void onDiscoveryCompleted(const std::string&) override;
virtual void onReloadStarted( const std::string& ) override {}
virtual void onReloadCompleted( const std::string& ) override {}
virtual void onArtistAdded( ArtistPtr ) override {}
virtual void onAlbumAdded( AlbumPtr ) override {}
virtual void onTrackAdded( MediaPtr, AlbumTrackPtr ) override {}
virtual void onParsingStatsUpdated(uint32_t percent) override;
std::condition_variable m_parsingCompleteVar;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment