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

FsHolder: Drop the FsFactoryCb inner class layer

parent d8a3fff2
......@@ -45,7 +45,6 @@ namespace medialibrary
FsHolder::FsHolder( MediaLibrary* ml )
: m_ml( ml )
, m_fsFactoryCb( ml )
, m_networkDiscoveryEnabled( false )
, m_started( false )
{
......@@ -119,7 +118,7 @@ bool FsHolder::setNetworkEnabled( bool enabled )
if ( enabled == true )
{
if ( fsFactory->start( &m_fsFactoryCb ) == true )
if ( fsFactory->start( this ) == true )
{
fsFactory->refreshDevices();
affected = true;
......@@ -169,7 +168,7 @@ void FsHolder::startFsFactoriesAndRefresh()
if ( m_networkDiscoveryEnabled == true ||
fsFactory->isNetworkFileSystem() == false )
{
fsFactory->start( &m_fsFactoryCb );
fsFactory->start( this );
fsFactory->refreshDevices();
}
}
......@@ -237,17 +236,13 @@ void FsHolder::refreshDevice( Device& device, fs::IFileSystemFactory* fsFactory
void FsHolder::startFsFactory( fs::IFileSystemFactory& fsFactory ) const
{
fsFactory.start( &m_fsFactoryCb );
auto fsCb = static_cast<const fs::IFileSystemFactoryCb*>( this );
fsFactory.start( const_cast<fs::IFileSystemFactoryCb*>( fsCb ) );
fsFactory.refreshDevices();
}
FsHolder::FsFactoryCb::FsFactoryCb( MediaLibrary* ml )
: m_ml( ml )
{
}
void FsHolder::FsFactoryCb::onDeviceMounted( const fs::IDevice& deviceFs,
const std::string& newMountpoint )
void FsHolder::onDeviceMounted( const fs::IDevice& deviceFs,
const std::string& newMountpoint )
{
auto device = Device::fromUuid( m_ml, deviceFs.uuid(), deviceFs.scheme() );
if ( device == nullptr )
......@@ -289,8 +284,8 @@ void FsHolder::FsFactoryCb::onDeviceMounted( const fs::IDevice& deviceFs,
}
}
void FsHolder::FsFactoryCb::onDeviceUnmounted( const fs::IDevice& deviceFs,
const std::string& )
void FsHolder::onDeviceUnmounted( const fs::IDevice& deviceFs,
const std::string& )
{
auto device = Device::fromUuid( m_ml, deviceFs.uuid(), deviceFs.scheme() );
if ( device == nullptr )
......
......@@ -38,7 +38,7 @@ namespace medialibrary
class Device;
class FsHolder
class FsHolder : public fs::IFileSystemFactoryCb
{
public:
FsHolder( MediaLibrary* ml );
......@@ -77,18 +77,11 @@ public:
void startFsFactory( fs::IFileSystemFactory& fsFactory ) const;
class FsFactoryCb : public fs::IFileSystemFactoryCb
{
public:
explicit FsFactoryCb( MediaLibrary* ml );
private:
virtual void onDeviceMounted( const fs::IDevice& deviceFs,
const std::string& newMountpoint ) override;
virtual void onDeviceUnmounted( const fs::IDevice& deviceFs,
const std::string& removedMountpoint ) override;
private:
MediaLibrary* m_ml;
};
private:
virtual void onDeviceMounted( const fs::IDevice& deviceFs,
const std::string& newMountpoint ) override;
virtual void onDeviceUnmounted( const fs::IDevice& deviceFs,
const std::string& removedMountpoint ) override;
private:
std::shared_ptr<fs::IFileSystemFactory>
......@@ -100,11 +93,6 @@ private:
MediaLibrary* m_ml;
mutable compat::Mutex m_mutex;
/* All fs factory callbacks must outlive the fs factory itself, since
* it might invoke some of the callback interface methods during teardown
*/
mutable FsFactoryCb m_fsFactoryCb;
std::vector<std::shared_ptr<fs::IFileSystemFactory>> m_fsFactories;
// Device lister will invoke fs factories through IDeviceListerCb so
// the device lister must be destroyed before the fs factories
......
Supports Markdown
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