Commit d7d9a59a authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

MediaLibrary: Expose video/audio files listing

parent 7cdba23c
......@@ -60,6 +60,8 @@ class IMediaLibrary
virtual bool deleteLabel( const std::string& label ) = 0;
virtual bool deleteLabel( LabelPtr label ) = 0;
virtual std::vector<FilePtr> files() = 0;
virtual std::vector<FilePtr> audioFiles() = 0;
virtual std::vector<FilePtr> videoFiles() = 0;
virtual AlbumPtr album( const std::string& title ) = 0;
virtual AlbumPtr createAlbum( const std::string& title ) = 0;
virtual ShowPtr show( const std::string& name ) = 0;
......
......@@ -123,6 +123,21 @@ std::vector<FilePtr> MediaLibrary::files()
return File::fetchAll( m_dbConnection );
}
std::vector<FilePtr> MediaLibrary::audioFiles()
{
static const std::string req = "SELECT * FROM " + policy::FileTable::Name + " WHERE type = ?";
//FIXME: Replace this with template magic in sqlite's traits
using type_t = std::underlying_type<IFile::Type>::type;
return sqlite::Tools::fetchAll<File, IFile>( m_dbConnection, req, static_cast<type_t>( IFile::Type::AudioType ) );
}
std::vector<FilePtr> MediaLibrary::videoFiles()
{
static const std::string req = "SELECT * FROM " + policy::FileTable::Name + " WHERE type = ?";
using type_t = std::underlying_type<IFile::Type>::type;
return sqlite::Tools::fetchAll<File, IFile>( m_dbConnection, req, static_cast<type_t>( IFile::Type::VideoType ) );
}
FilePtr MediaLibrary::file( const std::string& path )
{
return File::fetch( m_dbConnection, path );
......
......@@ -18,6 +18,8 @@ class MediaLibrary : public IMediaLibrary, public IDiscovererCb
virtual void setFsFactory( std::shared_ptr<factory::IFileSystem> fsFactory ) override;
virtual std::vector<FilePtr> files() override;
virtual std::vector<FilePtr> audioFiles() override;
virtual std::vector<FilePtr> videoFiles() override;
virtual FilePtr file( const std::string& path ) override;
virtual FilePtr addFile( const std::string& path ) override;
virtual bool deleteFile( const std::string& mrl ) override;
......
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