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

IFileSystemFactory: Allow start() to return an error

parent 1de5aa98
...@@ -107,11 +107,12 @@ namespace fs ...@@ -107,11 +107,12 @@ namespace fs
/// ///
/// \brief start Starts any potential background operation that would be /// \brief start Starts any potential background operation that would be
/// required by this factory. /// required by this factory.
/// \return False in case of an error.
/// \param cb An instance of IFileSystemFactoryCb to be used to signal device changes /// \param cb An instance of IFileSystemFactoryCb to be used to signal device changes
/// This instance is owned by the medialibrary, and must not /// This instance is owned by the medialibrary, and must not
/// be released /// be released
/// ///
virtual void start( IFileSystemFactoryCb* cb ) = 0; virtual bool start( IFileSystemFactoryCb* cb ) = 0;
/// ///
/// \brief stop stops any potential background operation that would be /// \brief stop stops any potential background operation that would be
/// required by this factory. /// required by this factory.
......
...@@ -1379,8 +1379,8 @@ bool MediaLibrary::setDiscoverNetworkEnabled( bool enabled ) ...@@ -1379,8 +1379,8 @@ bool MediaLibrary::setDiscoverNetworkEnabled( bool enabled )
auto previousSize = m_fsFactories.size(); auto previousSize = m_fsFactories.size();
for ( auto fsFactory : m_externalNetworkFsFactories ) for ( auto fsFactory : m_externalNetworkFsFactories )
{ {
fsFactory->start( &m_fsFactoryCb ); if ( fsFactory->start( &m_fsFactoryCb ) == true )
m_fsFactories.push_back( std::move( fsFactory ) ); m_fsFactories.push_back( std::move( fsFactory ) );
} }
std::copy( begin( m_externalNetworkFsFactories ), end( m_externalNetworkFsFactories ), std::copy( begin( m_externalNetworkFsFactories ), end( m_externalNetworkFsFactories ),
std::back_inserter( m_fsFactories ) ); std::back_inserter( m_fsFactories ) );
......
...@@ -148,8 +148,9 @@ const std::string&FileSystemFactory::scheme() const ...@@ -148,8 +148,9 @@ const std::string&FileSystemFactory::scheme() const
return s; return s;
} }
void FileSystemFactory::start( fs::IFileSystemFactoryCb* ) bool FileSystemFactory::start( fs::IFileSystemFactoryCb* )
{ {
return true;
} }
void FileSystemFactory::stop() void FileSystemFactory::stop()
......
...@@ -48,7 +48,7 @@ namespace factory ...@@ -48,7 +48,7 @@ namespace factory
virtual bool isMrlSupported( const std::string& path ) const override; virtual bool isMrlSupported( const std::string& path ) const override;
virtual bool isNetworkFileSystem() const override; virtual bool isNetworkFileSystem() const override;
virtual const std::string& scheme() const override; virtual const std::string& scheme() const override;
virtual void start( fs::IFileSystemFactoryCb* cb ) override; virtual bool start( fs::IFileSystemFactoryCb* cb ) override;
virtual void stop() override; virtual void stop() override;
private: private:
......
...@@ -112,10 +112,10 @@ const std::string& NetworkFileSystemFactory::scheme() const ...@@ -112,10 +112,10 @@ const std::string& NetworkFileSystemFactory::scheme() const
return m_protocol; return m_protocol;
} }
void NetworkFileSystemFactory::start( fs::IFileSystemFactoryCb* cb ) bool NetworkFileSystemFactory::start( fs::IFileSystemFactoryCb* cb )
{ {
m_cb = cb; m_cb = cb;
m_discoverer.start(); return m_discoverer.start();
} }
void NetworkFileSystemFactory::stop() void NetworkFileSystemFactory::stop()
......
...@@ -50,7 +50,7 @@ public: ...@@ -50,7 +50,7 @@ public:
virtual bool isMrlSupported( const std::string& path ) const override; virtual bool isMrlSupported( const std::string& path ) const override;
virtual bool isNetworkFileSystem() const override; virtual bool isNetworkFileSystem() const override;
virtual const std::string& scheme() const override; virtual const std::string& scheme() const override;
virtual void start( fs::IFileSystemFactoryCb* cb ) override; virtual bool start( fs::IFileSystemFactoryCb* cb ) override;
virtual void stop() override; virtual void stop() override;
private: private:
......
...@@ -219,7 +219,7 @@ struct FileSystemFactory : public fs::IFileSystemFactory ...@@ -219,7 +219,7 @@ struct FileSystemFactory : public fs::IFileSystemFactory
return s; return s;
} }
virtual void start( fs::IFileSystemFactoryCb* ) override {} virtual bool start( fs::IFileSystemFactoryCb* ) override { return true; }
virtual void stop() override {} virtual void stop() override {}
std::vector<std::shared_ptr<Device>> devices; std::vector<std::shared_ptr<Device>> devices;
...@@ -393,7 +393,7 @@ public: ...@@ -393,7 +393,7 @@ public:
{ {
return false; return false;
} }
virtual void start( fs::IFileSystemFactoryCb* ) override {} virtual bool start( fs::IFileSystemFactoryCb* ) override { return true; }
virtual void stop() override {} virtual void stop() 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