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

IMediaLibrary: Add a method to fetch registered entry points

Fix #14
parent 6746b7e6
......@@ -221,6 +221,7 @@ class IMediaLibrary
*/
virtual void discover( const std::string& entryPoint ) = 0;
virtual void setDiscoverNetworkEnabled( bool enable ) = 0;
virtual std::vector<FolderPtr> entryPoints() const = 0;
/**
* @brief banFolder will blacklist a folder for discovery
*/
......
......@@ -46,6 +46,7 @@ class IPlaylist;
class IMediaLibraryCb;
class IDeviceLister;
class IDeviceListerCb;
class IFolder;
using AlbumPtr = std::shared_ptr<IAlbum>;
using AlbumTrackPtr = std::shared_ptr<IAlbumTrack>;
......@@ -62,6 +63,7 @@ using ShowEpisodePtr = std::shared_ptr<IShowEpisode>;
using ShowPtr = std::shared_ptr<IShow>;
using VideoTrackPtr = std::shared_ptr<IVideoTrack>;
using DeviceListerPtr = std::shared_ptr<IDeviceLister>;
using FolderPtr = std::shared_ptr<IFolder>;
}
......@@ -698,6 +698,13 @@ void MediaLibrary::setDiscoverNetworkEnabled( bool enabled )
}
}
std::vector<FolderPtr> MediaLibrary::entryPoints() const
{
static const std::string req = "SELECT * FROM " + policy::FolderTable::Name + " WHERE parent_id IS NULL"
" AND is_blacklisted = 0";
return Folder::fetchAll<IFolder>( this, req );
}
bool MediaLibrary::banFolder( const std::string& path )
{
return Folder::blacklist( this, path );
......
......@@ -115,6 +115,7 @@ class MediaLibrary : public IMediaLibrary, public IDeviceListerCb
virtual void discover( const std::string& entryPoint ) override;
virtual void setDiscoverNetworkEnabled( bool enabled ) override;
virtual std::vector<FolderPtr> entryPoints() const override;
virtual bool banFolder( const std::string& path ) override;
virtual bool unbanFolder( const std::string& path ) override;
......
......@@ -421,3 +421,15 @@ TEST_F( Folders, ReloadSubDir )
files = ml->files();
ASSERT_EQ( 4u, files.size() );
}
TEST_F( Folders, FetchEntryPoints )
{
auto eps = ml->entryPoints();
ASSERT_EQ( 1u, eps.size() );
ASSERT_EQ( mock::FileSystemFactory::Root, eps[0]->path() );
// Check that banned folders don't appear in the results:
ml->banFolder( mock::FileSystemFactory::SubFolder );
eps = ml->entryPoints();
ASSERT_EQ( 1u, eps.size() );
}
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