Created an interface for the Db class
This commit is contained in:
@@ -17,8 +17,6 @@
|
|||||||
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
|
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "database/Db.hpp"
|
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
@@ -31,6 +29,8 @@
|
|||||||
#include "database/Session.hpp"
|
#include "database/Session.hpp"
|
||||||
#include "database/User.hpp"
|
#include "database/User.hpp"
|
||||||
|
|
||||||
|
#include "Db.hpp"
|
||||||
|
|
||||||
namespace lms::db
|
namespace lms::db
|
||||||
{
|
{
|
||||||
namespace
|
namespace
|
||||||
@@ -134,6 +134,11 @@ namespace lms::db
|
|||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
std::unique_ptr<IDb> createDb(const std::filesystem::path& dbPath, std::size_t connectionCount)
|
||||||
|
{
|
||||||
|
return std::make_unique<Db>(dbPath, connectionCount);
|
||||||
|
}
|
||||||
|
|
||||||
// Session living class handling the database and the login
|
// Session living class handling the database and the login
|
||||||
Db::Db(const std::filesystem::path& dbPath, std::size_t connectionCount)
|
Db::Db(const std::filesystem::path& dbPath, std::size_t connectionCount)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -19,23 +19,25 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <filesystem>
|
#include <mutex>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include <Wt/Dbo/SqlConnectionPool.h>
|
#include <Wt/Dbo/SqlConnectionPool.h>
|
||||||
|
|
||||||
#include "core/RecursiveSharedMutex.hpp"
|
#include "core/RecursiveSharedMutex.hpp"
|
||||||
|
|
||||||
|
#include "database/IDb.hpp"
|
||||||
|
|
||||||
namespace lms::db
|
namespace lms::db
|
||||||
{
|
{
|
||||||
class Session;
|
class Db : public IDb
|
||||||
class Db
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Db(const std::filesystem::path& dbPath, std::size_t connectionCount = 10);
|
Db(const std::filesystem::path& dbPath, std::size_t connectionCount);
|
||||||
|
|
||||||
Session& getTLSSession();
|
Session& getTLSSession() override;
|
||||||
|
|
||||||
void executeSql(const std::string& sql);
|
void executeSql(const std::string& sql) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Db(const Db&) = delete;
|
Db(const Db&) = delete;
|
||||||
@@ -24,11 +24,11 @@
|
|||||||
#include "core/Exception.hpp"
|
#include "core/Exception.hpp"
|
||||||
#include "core/ILogger.hpp"
|
#include "core/ILogger.hpp"
|
||||||
#include "core/ITraceLogger.hpp"
|
#include "core/ITraceLogger.hpp"
|
||||||
#include "database/Db.hpp"
|
|
||||||
#include "database/ScanSettings.hpp"
|
#include "database/ScanSettings.hpp"
|
||||||
#include "database/Session.hpp"
|
#include "database/Session.hpp"
|
||||||
#include "database/User.hpp"
|
#include "database/User.hpp"
|
||||||
|
|
||||||
|
#include "Db.hpp"
|
||||||
#include "Utils.hpp"
|
#include "Utils.hpp"
|
||||||
|
|
||||||
namespace lms::db
|
namespace lms::db
|
||||||
@@ -67,7 +67,7 @@ namespace lms::db::Migration
|
|||||||
class ScopedNoForeignKeys
|
class ScopedNoForeignKeys
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ScopedNoForeignKeys(Db& db)
|
ScopedNoForeignKeys(IDb& db)
|
||||||
: _db{ db }
|
: _db{ db }
|
||||||
{
|
{
|
||||||
_db.executeSql("PRAGMA foreign_keys=OFF");
|
_db.executeSql("PRAGMA foreign_keys=OFF");
|
||||||
@@ -83,7 +83,7 @@ namespace lms::db::Migration
|
|||||||
ScopedNoForeignKeys& operator=(const ScopedNoForeignKeys&) = delete;
|
ScopedNoForeignKeys& operator=(const ScopedNoForeignKeys&) = delete;
|
||||||
ScopedNoForeignKeys& operator=(ScopedNoForeignKeys&&) = delete;
|
ScopedNoForeignKeys& operator=(ScopedNoForeignKeys&&) = delete;
|
||||||
|
|
||||||
Db& _db;
|
IDb& _db;
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
|
|||||||
@@ -26,7 +26,6 @@
|
|||||||
#include "database/Artwork.hpp"
|
#include "database/Artwork.hpp"
|
||||||
#include "database/AuthToken.hpp"
|
#include "database/AuthToken.hpp"
|
||||||
#include "database/Cluster.hpp"
|
#include "database/Cluster.hpp"
|
||||||
#include "database/Db.hpp"
|
|
||||||
#include "database/Directory.hpp"
|
#include "database/Directory.hpp"
|
||||||
#include "database/Image.hpp"
|
#include "database/Image.hpp"
|
||||||
#include "database/Listen.hpp"
|
#include "database/Listen.hpp"
|
||||||
@@ -53,6 +52,7 @@
|
|||||||
#include "database/UIState.hpp"
|
#include "database/UIState.hpp"
|
||||||
#include "database/User.hpp"
|
#include "database/User.hpp"
|
||||||
|
|
||||||
|
#include "Db.hpp"
|
||||||
#include "Migration.hpp"
|
#include "Migration.hpp"
|
||||||
#include "Utils.hpp"
|
#include "Utils.hpp"
|
||||||
#include "traits/EnumSetTraits.hpp"
|
#include "traits/EnumSetTraits.hpp"
|
||||||
@@ -96,10 +96,10 @@ namespace lms::db
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
Session::Session(Db& db)
|
Session::Session(IDb& db)
|
||||||
: _db{ db }
|
: _db{ db }
|
||||||
{
|
{
|
||||||
_session.setConnectionPool(_db.getConnectionPool());
|
_session.setConnectionPool(static_cast<Db&>(_db).getConnectionPool());
|
||||||
|
|
||||||
_session.mapClass<Artist>("artist");
|
_session.mapClass<Artist>("artist");
|
||||||
_session.mapClass<ArtistInfo>("artist_info");
|
_session.mapClass<ArtistInfo>("artist_info");
|
||||||
@@ -140,7 +140,7 @@ namespace lms::db
|
|||||||
|
|
||||||
WriteTransaction Session::createWriteTransaction()
|
WriteTransaction Session::createWriteTransaction()
|
||||||
{
|
{
|
||||||
return WriteTransaction{ _db.getMutex(), _session };
|
return WriteTransaction{ static_cast<Db&>(_db).getMutex(), _session };
|
||||||
}
|
}
|
||||||
|
|
||||||
ReadTransaction Session::createReadTransaction()
|
ReadTransaction Session::createReadTransaction()
|
||||||
@@ -359,7 +359,7 @@ namespace lms::db
|
|||||||
|
|
||||||
// We manually take a lock here since vacuum cannot be inside a transaction
|
// We manually take a lock here since vacuum cannot be inside a transaction
|
||||||
{
|
{
|
||||||
std::unique_lock lock{ _db.getMutex() };
|
std::unique_lock lock{ static_cast<Db&>(_db).getMutex() };
|
||||||
_db.executeSql("VACUUM");
|
_db.executeSql("VACUUM");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2019 Emeric Poupon
|
||||||
|
*
|
||||||
|
* This file is part of LMS.
|
||||||
|
*
|
||||||
|
* LMS is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* LMS is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <filesystem>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
namespace lms::db
|
||||||
|
{
|
||||||
|
class Session;
|
||||||
|
class IDb
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~IDb() = default;
|
||||||
|
|
||||||
|
virtual Session& getTLSSession() = 0;
|
||||||
|
|
||||||
|
virtual void executeSql(const std::string& sql) = 0; // TODO make this private
|
||||||
|
};
|
||||||
|
|
||||||
|
std::unique_ptr<IDb> createDb(const std::filesystem::path& dbPath, std::size_t connectionCount = 10);
|
||||||
|
} // namespace lms::db
|
||||||
@@ -65,11 +65,11 @@ namespace lms::db
|
|||||||
Wt::Dbo::Transaction _transaction;
|
Wt::Dbo::Transaction _transaction;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Db;
|
class IDb;
|
||||||
class Session
|
class Session
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Session(Db& db);
|
Session(IDb& db);
|
||||||
~Session() = default;
|
~Session() = default;
|
||||||
Session(const Session&) = delete;
|
Session(const Session&) = delete;
|
||||||
Session& operator=(const Session&) = delete;
|
Session& operator=(const Session&) = delete;
|
||||||
@@ -111,7 +111,7 @@ namespace lms::db
|
|||||||
{
|
{
|
||||||
return &_session;
|
return &_session;
|
||||||
}
|
}
|
||||||
Db& getDb()
|
IDb& getDb()
|
||||||
{
|
{
|
||||||
return _db;
|
return _db;
|
||||||
}
|
}
|
||||||
@@ -146,7 +146,7 @@ namespace lms::db
|
|||||||
private:
|
private:
|
||||||
void execute(std::string_view query, long long id);
|
void execute(std::string_view query, long long id);
|
||||||
|
|
||||||
Db& _db;
|
IDb& _db;
|
||||||
Wt::Dbo::Session _session;
|
Wt::Dbo::Session _session;
|
||||||
};
|
};
|
||||||
} // namespace lms::db
|
} // namespace lms::db
|
||||||
|
|||||||
@@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
#include "Common.hpp"
|
#include "Common.hpp"
|
||||||
|
|
||||||
#include "database/Db.hpp"
|
|
||||||
#include "database/Release.hpp"
|
#include "database/Release.hpp"
|
||||||
#include "database/Session.hpp"
|
#include "database/Session.hpp"
|
||||||
#include "database/Types.hpp"
|
#include "database/Types.hpp"
|
||||||
@@ -29,13 +28,13 @@ namespace lms::db::tests
|
|||||||
TmpDatabase::TmpDatabase()
|
TmpDatabase::TmpDatabase()
|
||||||
: _tmpFile{ std::tmpnam(nullptr) }
|
: _tmpFile{ std::tmpnam(nullptr) }
|
||||||
, _fileDeleter{ _tmpFile }
|
, _fileDeleter{ _tmpFile }
|
||||||
, _db{ _tmpFile }
|
, _db{ createDb(_tmpFile) }
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
db::Db& TmpDatabase::getDb()
|
db::IDb& TmpDatabase::getDb()
|
||||||
{
|
{
|
||||||
return _db;
|
return *_db;
|
||||||
}
|
}
|
||||||
|
|
||||||
DatabaseFixture::~DatabaseFixture()
|
DatabaseFixture::~DatabaseFixture()
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
#include "database/Artist.hpp"
|
#include "database/Artist.hpp"
|
||||||
#include "database/Cluster.hpp"
|
#include "database/Cluster.hpp"
|
||||||
#include "database/Db.hpp"
|
#include "database/IDb.hpp"
|
||||||
#include "database/Listen.hpp"
|
#include "database/Listen.hpp"
|
||||||
#include "database/MediaLibrary.hpp"
|
#include "database/MediaLibrary.hpp"
|
||||||
#include "database/Release.hpp"
|
#include "database/Release.hpp"
|
||||||
@@ -131,12 +131,12 @@ namespace lms::db::tests
|
|||||||
public:
|
public:
|
||||||
TmpDatabase();
|
TmpDatabase();
|
||||||
|
|
||||||
db::Db& getDb();
|
IDb& getDb();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const std::filesystem::path _tmpFile;
|
const std::filesystem::path _tmpFile;
|
||||||
ScopedFileDeleter _fileDeleter;
|
ScopedFileDeleter _fileDeleter;
|
||||||
db::Db _db;
|
std::unique_ptr<IDb> _db;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DatabaseFixture : public ::testing::Test
|
class DatabaseFixture : public ::testing::Test
|
||||||
|
|||||||
@@ -23,7 +23,6 @@
|
|||||||
#include "database/Artist.hpp"
|
#include "database/Artist.hpp"
|
||||||
#include "database/ArtistInfo.hpp"
|
#include "database/ArtistInfo.hpp"
|
||||||
#include "database/AuthToken.hpp"
|
#include "database/AuthToken.hpp"
|
||||||
#include "database/Db.hpp"
|
|
||||||
#include "database/Directory.hpp"
|
#include "database/Directory.hpp"
|
||||||
#include "database/Image.hpp"
|
#include "database/Image.hpp"
|
||||||
#include "database/PlayListFile.hpp"
|
#include "database/PlayListFile.hpp"
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
#include "core/Utils.hpp"
|
#include "core/Utils.hpp"
|
||||||
#include "database/Artist.hpp"
|
#include "database/Artist.hpp"
|
||||||
#include "database/Artwork.hpp"
|
#include "database/Artwork.hpp"
|
||||||
#include "database/Db.hpp"
|
#include "database/IDb.hpp"
|
||||||
#include "database/Image.hpp"
|
#include "database/Image.hpp"
|
||||||
#include "database/ImageId.hpp"
|
#include "database/ImageId.hpp"
|
||||||
#include "database/Release.hpp"
|
#include "database/Release.hpp"
|
||||||
@@ -40,12 +40,12 @@
|
|||||||
|
|
||||||
namespace lms::artwork
|
namespace lms::artwork
|
||||||
{
|
{
|
||||||
std::unique_ptr<IArtworkService> createArtworkService(db::Db& db, const std::filesystem::path& defaultReleaseCoverSvgPath, const std::filesystem::path& defaultArtistImageSvgPath)
|
std::unique_ptr<IArtworkService> createArtworkService(db::IDb& db, const std::filesystem::path& defaultReleaseCoverSvgPath, const std::filesystem::path& defaultArtistImageSvgPath)
|
||||||
{
|
{
|
||||||
return std::make_unique<ArtworkService>(db, defaultReleaseCoverSvgPath, defaultArtistImageSvgPath);
|
return std::make_unique<ArtworkService>(db, defaultReleaseCoverSvgPath, defaultArtistImageSvgPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
ArtworkService::ArtworkService(db::Db& db,
|
ArtworkService::ArtworkService(db::IDb& db,
|
||||||
const std::filesystem::path& defaultReleaseCoverSvgPath,
|
const std::filesystem::path& defaultReleaseCoverSvgPath,
|
||||||
const std::filesystem::path& defaultArtistImageSvgPath)
|
const std::filesystem::path& defaultArtistImageSvgPath)
|
||||||
: _db{ db }
|
: _db{ db }
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ namespace lms::artwork
|
|||||||
class ArtworkService : public IArtworkService
|
class ArtworkService : public IArtworkService
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ArtworkService(db::Db& db, const std::filesystem::path& defaultReleaseCoverSvgPath, const std::filesystem::path& defaultArtistImageSvgPath);
|
ArtworkService(db::IDb& db, const std::filesystem::path& defaultReleaseCoverSvgPath, const std::filesystem::path& defaultArtistImageSvgPath);
|
||||||
~ArtworkService() override;
|
~ArtworkService() override;
|
||||||
ArtworkService(const ArtworkService&) = delete;
|
ArtworkService(const ArtworkService&) = delete;
|
||||||
ArtworkService& operator=(const ArtworkService&) = delete;
|
ArtworkService& operator=(const ArtworkService&) = delete;
|
||||||
@@ -65,7 +65,7 @@ namespace lms::artwork
|
|||||||
std::unique_ptr<image::IEncodedImage> getFromImageFile(const std::filesystem::path& p, std::optional<image::ImageSize> width) const;
|
std::unique_ptr<image::IEncodedImage> getFromImageFile(const std::filesystem::path& p, std::optional<image::ImageSize> width) const;
|
||||||
std::unique_ptr<image::IEncodedImage> getTrackImage(const std::filesystem::path& path, std::size_t index, std::optional<image::ImageSize> width) const;
|
std::unique_ptr<image::IEncodedImage> getTrackImage(const std::filesystem::path& path, std::size_t index, std::optional<image::ImageSize> width) const;
|
||||||
|
|
||||||
db::Db& _db;
|
db::IDb& _db;
|
||||||
|
|
||||||
std::unique_ptr<metadata::IAudioFileParser> _audioFileParser;
|
std::unique_ptr<metadata::IAudioFileParser> _audioFileParser;
|
||||||
ImageCache _cache;
|
ImageCache _cache;
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
namespace lms::db
|
namespace lms::db
|
||||||
{
|
{
|
||||||
class Db;
|
class IDb;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace lms::artwork
|
namespace lms::artwork
|
||||||
@@ -54,6 +54,6 @@ namespace lms::artwork
|
|||||||
virtual void setJpegQuality(unsigned quality) = 0; // from 1 to 100
|
virtual void setJpegQuality(unsigned quality) = 0; // from 1 to 100
|
||||||
};
|
};
|
||||||
|
|
||||||
std::unique_ptr<IArtworkService> createArtworkService(db::Db& db, const std::filesystem::path& defaultReleaseCoverSvgPath, const std::filesystem::path& defaultArtistImageSvgPath);
|
std::unique_ptr<IArtworkService> createArtworkService(db::IDb& db, const std::filesystem::path& defaultReleaseCoverSvgPath, const std::filesystem::path& defaultArtistImageSvgPath);
|
||||||
|
|
||||||
} // namespace lms::artwork
|
} // namespace lms::artwork
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
#include "AuthServiceBase.hpp"
|
#include "AuthServiceBase.hpp"
|
||||||
|
|
||||||
#include "core/ILogger.hpp"
|
#include "core/ILogger.hpp"
|
||||||
#include "database/Db.hpp"
|
#include "database/IDb.hpp"
|
||||||
#include "database/Session.hpp"
|
#include "database/Session.hpp"
|
||||||
#include "database/User.hpp"
|
#include "database/User.hpp"
|
||||||
|
|
||||||
@@ -28,7 +28,7 @@ namespace lms::auth
|
|||||||
{
|
{
|
||||||
using namespace db;
|
using namespace db;
|
||||||
|
|
||||||
AuthServiceBase::AuthServiceBase(Db& db)
|
AuthServiceBase::AuthServiceBase(db::IDb& db)
|
||||||
: _db{ db }
|
: _db{ db }
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
namespace lms::db
|
namespace lms::db
|
||||||
{
|
{
|
||||||
class Db;
|
class IDb;
|
||||||
class Session;
|
class Session;
|
||||||
} // namespace lms::db
|
} // namespace lms::db
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@ namespace lms::auth
|
|||||||
class AuthServiceBase
|
class AuthServiceBase
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
AuthServiceBase(db::Db& db);
|
AuthServiceBase(db::IDb& db);
|
||||||
~AuthServiceBase() = default;
|
~AuthServiceBase() = default;
|
||||||
AuthServiceBase(const AuthServiceBase&) = delete;
|
AuthServiceBase(const AuthServiceBase&) = delete;
|
||||||
AuthServiceBase& operator=(const AuthServiceBase&) = delete;
|
AuthServiceBase& operator=(const AuthServiceBase&) = delete;
|
||||||
@@ -45,6 +45,6 @@ namespace lms::auth
|
|||||||
db::Session& getDbSession();
|
db::Session& getDbSession();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
db::Db& _db;
|
db::IDb& _db;
|
||||||
};
|
};
|
||||||
} // namespace lms::auth
|
} // namespace lms::auth
|
||||||
|
|||||||
@@ -44,12 +44,12 @@ namespace lms::auth
|
|||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
std::unique_ptr<IAuthTokenService> createAuthTokenService(db::Db& db, std::size_t maxThrottlerEntryCount)
|
std::unique_ptr<IAuthTokenService> createAuthTokenService(db::IDb& db, std::size_t maxThrottlerEntryCount)
|
||||||
{
|
{
|
||||||
return std::make_unique<AuthTokenService>(db, maxThrottlerEntryCount);
|
return std::make_unique<AuthTokenService>(db, maxThrottlerEntryCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
AuthTokenService::AuthTokenService(db::Db& db, std::size_t maxThrottlerEntryCount)
|
AuthTokenService::AuthTokenService(db::IDb& db, std::size_t maxThrottlerEntryCount)
|
||||||
: AuthServiceBase{ db }
|
: AuthServiceBase{ db }
|
||||||
, _loginThrottler{ maxThrottlerEntryCount }
|
, _loginThrottler{ maxThrottlerEntryCount }
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ namespace lms::auth
|
|||||||
class AuthTokenService : public IAuthTokenService, public AuthServiceBase
|
class AuthTokenService : public IAuthTokenService, public AuthServiceBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AuthTokenService(db::Db& db, std::size_t maxThrottlerEntryCount);
|
AuthTokenService(db::IDb& db, std::size_t maxThrottlerEntryCount);
|
||||||
|
|
||||||
~AuthTokenService() override = default;
|
~AuthTokenService() override = default;
|
||||||
AuthTokenService(const AuthTokenService&) = delete;
|
AuthTokenService(const AuthTokenService&) = delete;
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
namespace lms::auth
|
namespace lms::auth
|
||||||
{
|
{
|
||||||
std::unique_ptr<IEnvService> createEnvService(std::string_view backendName, db::Db& db)
|
std::unique_ptr<IEnvService> createEnvService(std::string_view backendName, db::IDb& db)
|
||||||
{
|
{
|
||||||
if (backendName == "http-headers")
|
if (backendName == "http-headers")
|
||||||
return std::make_unique<HttpHeadersEnvService>(db);
|
return std::make_unique<HttpHeadersEnvService>(db);
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ namespace lms::auth
|
|||||||
{
|
{
|
||||||
static const Wt::Auth::SHA1HashFunction sha1Function;
|
static const Wt::Auth::SHA1HashFunction sha1Function;
|
||||||
|
|
||||||
std::unique_ptr<IPasswordService> createPasswordService(std::string_view backend, db::Db& db, std::size_t maxThrottlerEntryCount)
|
std::unique_ptr<IPasswordService> createPasswordService(std::string_view backend, db::IDb& db, std::size_t maxThrottlerEntryCount)
|
||||||
{
|
{
|
||||||
if (backend == "internal")
|
if (backend == "internal")
|
||||||
return std::make_unique<InternalPasswordService>(db, maxThrottlerEntryCount);
|
return std::make_unique<InternalPasswordService>(db, maxThrottlerEntryCount);
|
||||||
@@ -46,7 +46,7 @@ namespace lms::auth
|
|||||||
throw Exception{ "Authentication backend '" + std::string{ backend } + "' not supported!" };
|
throw Exception{ "Authentication backend '" + std::string{ backend } + "' not supported!" };
|
||||||
}
|
}
|
||||||
|
|
||||||
PasswordServiceBase::PasswordServiceBase(db::Db& db, std::size_t maxThrottlerEntries)
|
PasswordServiceBase::PasswordServiceBase(db::IDb& db, std::size_t maxThrottlerEntries)
|
||||||
: AuthServiceBase{ db }
|
: AuthServiceBase{ db }
|
||||||
, _loginThrottler{ maxThrottlerEntries }
|
, _loginThrottler{ maxThrottlerEntries }
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
namespace lms::db
|
namespace lms::db
|
||||||
{
|
{
|
||||||
class Db;
|
class IDb;
|
||||||
class Session;
|
class Session;
|
||||||
} // namespace lms::db
|
} // namespace lms::db
|
||||||
|
|
||||||
@@ -36,7 +36,7 @@ namespace lms::auth
|
|||||||
class PasswordServiceBase : public IPasswordService, public AuthServiceBase
|
class PasswordServiceBase : public IPasswordService, public AuthServiceBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PasswordServiceBase(db::Db& db, std::size_t maxThrottlerEntries);
|
PasswordServiceBase(db::IDb& db, std::size_t maxThrottlerEntries);
|
||||||
|
|
||||||
~PasswordServiceBase() override = default;
|
~PasswordServiceBase() override = default;
|
||||||
PasswordServiceBase(const PasswordServiceBase&) = delete;
|
PasswordServiceBase(const PasswordServiceBase&) = delete;
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
namespace lms::auth
|
namespace lms::auth
|
||||||
{
|
{
|
||||||
HttpHeadersEnvService::HttpHeadersEnvService(db::Db& db)
|
HttpHeadersEnvService::HttpHeadersEnvService(db::IDb& db)
|
||||||
: AuthServiceBase{ db }
|
: AuthServiceBase{ db }
|
||||||
, _fieldName{ core::Service<core::IConfig>::get()->getString("http-headers-login-field", "X-Forwarded-User") }
|
, _fieldName{ core::Service<core::IConfig>::get()->getString("http-headers-login-field", "X-Forwarded-User") }
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ namespace lms::auth
|
|||||||
class HttpHeadersEnvService : public IEnvService, public AuthServiceBase
|
class HttpHeadersEnvService : public IEnvService, public AuthServiceBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
HttpHeadersEnvService(db::Db& db);
|
HttpHeadersEnvService(db::IDb& db);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CheckResult processEnv(const Wt::WEnvironment& env) override;
|
CheckResult processEnv(const Wt::WEnvironment& env) override;
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
namespace lms::auth
|
namespace lms::auth
|
||||||
{
|
{
|
||||||
InternalPasswordService::InternalPasswordService(db::Db& db, std::size_t maxThrottlerEntries)
|
InternalPasswordService::InternalPasswordService(db::IDb& db, std::size_t maxThrottlerEntries)
|
||||||
: PasswordServiceBase{ db, maxThrottlerEntries }
|
: PasswordServiceBase{ db, maxThrottlerEntries }
|
||||||
, _bcryptRoundCount{ static_cast<unsigned>(core::Service<core::IConfig>::get()->getULong("internal-password-bcrypt-round", 12)) }
|
, _bcryptRoundCount{ static_cast<unsigned>(core::Service<core::IConfig>::get()->getULong("internal-password-bcrypt-round", 12)) }
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ namespace lms::auth
|
|||||||
class InternalPasswordService : public PasswordServiceBase
|
class InternalPasswordService : public PasswordServiceBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
InternalPasswordService(db::Db& db, std::size_t maxThrottlerEntries);
|
InternalPasswordService(db::IDb& db, std::size_t maxThrottlerEntries);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool checkUserPassword(std::string_view loginName, std::string_view password) override;
|
bool checkUserPassword(std::string_view loginName, std::string_view password) override;
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
|
|
||||||
namespace lms::db
|
namespace lms::db
|
||||||
{
|
{
|
||||||
class Db;
|
class IDb;
|
||||||
} // namespace lms::db
|
} // namespace lms::db
|
||||||
|
|
||||||
namespace lms::auth
|
namespace lms::auth
|
||||||
@@ -81,5 +81,5 @@ namespace lms::auth
|
|||||||
virtual void clearAuthTokens(core::LiteralString domain, db::UserId userid) = 0;
|
virtual void clearAuthTokens(core::LiteralString domain, db::UserId userid) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::unique_ptr<IAuthTokenService> createAuthTokenService(db::Db& db, std::size_t maxThrottlerEntryCount);
|
std::unique_ptr<IAuthTokenService> createAuthTokenService(db::IDb& db, std::size_t maxThrottlerEntryCount);
|
||||||
} // namespace lms::auth
|
} // namespace lms::auth
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
namespace lms::db
|
namespace lms::db
|
||||||
{
|
{
|
||||||
class Db;
|
class IDb;
|
||||||
class Session;
|
class Session;
|
||||||
} // namespace lms::db
|
} // namespace lms::db
|
||||||
|
|
||||||
@@ -65,5 +65,5 @@ namespace lms::auth
|
|||||||
virtual CheckResult processRequest(const Wt::Http::Request& request) = 0;
|
virtual CheckResult processRequest(const Wt::Http::Request& request) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::unique_ptr<IEnvService> createEnvService(std::string_view backend, db::Db& db);
|
std::unique_ptr<IEnvService> createEnvService(std::string_view backend, db::IDb& db);
|
||||||
} // namespace lms::auth
|
} // namespace lms::auth
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
|
|
||||||
namespace lms::db
|
namespace lms::db
|
||||||
{
|
{
|
||||||
class Db;
|
class IDb;
|
||||||
class User;
|
class User;
|
||||||
} // namespace lms::db
|
} // namespace lms::db
|
||||||
|
|
||||||
@@ -69,5 +69,5 @@ namespace lms::auth
|
|||||||
virtual void setPassword(db::UserId userId, std::string_view newPassword) = 0;
|
virtual void setPassword(db::UserId userId, std::string_view newPassword) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::unique_ptr<IPasswordService> createPasswordService(std::string_view backend, db::Db& db, std::size_t maxThrottlerEntryCount);
|
std::unique_ptr<IPasswordService> createPasswordService(std::string_view backend, db::IDb& db, std::size_t maxThrottlerEntryCount);
|
||||||
} // namespace lms::auth
|
} // namespace lms::auth
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
#include "core/ILogger.hpp"
|
#include "core/ILogger.hpp"
|
||||||
#include "database/Artist.hpp"
|
#include "database/Artist.hpp"
|
||||||
#include "database/Db.hpp"
|
#include "database/IDb.hpp"
|
||||||
#include "database/RatedArtist.hpp"
|
#include "database/RatedArtist.hpp"
|
||||||
#include "database/RatedRelease.hpp"
|
#include "database/RatedRelease.hpp"
|
||||||
#include "database/RatedTrack.hpp"
|
#include "database/RatedTrack.hpp"
|
||||||
@@ -39,12 +39,12 @@
|
|||||||
|
|
||||||
namespace lms::feedback
|
namespace lms::feedback
|
||||||
{
|
{
|
||||||
std::unique_ptr<IFeedbackService> createFeedbackService(boost::asio::io_context& ioContext, Db& db)
|
std::unique_ptr<IFeedbackService> createFeedbackService(boost::asio::io_context& ioContext, db::IDb& db)
|
||||||
{
|
{
|
||||||
return std::make_unique<FeedbackService>(ioContext, db);
|
return std::make_unique<FeedbackService>(ioContext, db);
|
||||||
}
|
}
|
||||||
|
|
||||||
FeedbackService::FeedbackService(boost::asio::io_context& ioContext, Db& db)
|
FeedbackService::FeedbackService(boost::asio::io_context& ioContext, db::IDb& db)
|
||||||
: _db{ db }
|
: _db{ db }
|
||||||
{
|
{
|
||||||
LMS_LOG(SCROBBLING, INFO, "Starting service...");
|
LMS_LOG(SCROBBLING, INFO, "Starting service...");
|
||||||
@@ -58,7 +58,7 @@ namespace lms::feedback
|
|||||||
LMS_LOG(SCROBBLING, INFO, "Service stopped!");
|
LMS_LOG(SCROBBLING, INFO, "Service stopped!");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<db::FeedbackBackend> FeedbackService::getUserFeedbackBackend(UserId userId)
|
std::optional<db::FeedbackBackend> FeedbackService::getUserFeedbackBackend(db::UserId userId)
|
||||||
{
|
{
|
||||||
std::optional<db::FeedbackBackend> feedbackBackend;
|
std::optional<db::FeedbackBackend> feedbackBackend;
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
namespace lms::db
|
namespace lms::db
|
||||||
{
|
{
|
||||||
class Db;
|
class IDb;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace lms::feedback
|
namespace lms::feedback
|
||||||
@@ -36,7 +36,7 @@ namespace lms::feedback
|
|||||||
class FeedbackService : public IFeedbackService
|
class FeedbackService : public IFeedbackService
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FeedbackService(boost::asio::io_context& ioContext, db::Db& db);
|
FeedbackService(boost::asio::io_context& ioContext, db::IDb& db);
|
||||||
~FeedbackService() override;
|
~FeedbackService() override;
|
||||||
FeedbackService(const FeedbackService&) = delete;
|
FeedbackService(const FeedbackService&) = delete;
|
||||||
FeedbackService& operator=(const FeedbackService&) = delete;
|
FeedbackService& operator=(const FeedbackService&) = delete;
|
||||||
@@ -86,7 +86,7 @@ namespace lms::feedback
|
|||||||
template<typename ObjType, typename ObjIdType, typename RatedObjType>
|
template<typename ObjType, typename ObjIdType, typename RatedObjType>
|
||||||
std::optional<db::Rating> getRating(db::UserId userId, ObjIdType objectId);
|
std::optional<db::Rating> getRating(db::UserId userId, ObjIdType objectId);
|
||||||
|
|
||||||
db::Db& _db;
|
db::IDb& _db;
|
||||||
std::unordered_map<db::FeedbackBackend, std::unique_ptr<IFeedbackBackend>> _backends;
|
std::unordered_map<db::FeedbackBackend, std::unique_ptr<IFeedbackBackend>> _backends;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "database/Db.hpp"
|
#include "database/IDb.hpp"
|
||||||
#include "database/Session.hpp"
|
#include "database/Session.hpp"
|
||||||
#include "database/User.hpp"
|
#include "database/User.hpp"
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
#include "InternalBackend.hpp"
|
#include "InternalBackend.hpp"
|
||||||
|
|
||||||
#include "database/Db.hpp"
|
#include "database/IDb.hpp"
|
||||||
#include "database/Session.hpp"
|
#include "database/Session.hpp"
|
||||||
#include "database/StarredArtist.hpp"
|
#include "database/StarredArtist.hpp"
|
||||||
#include "database/StarredRelease.hpp"
|
#include "database/StarredRelease.hpp"
|
||||||
@@ -48,7 +48,7 @@ namespace lms::feedback
|
|||||||
}
|
}
|
||||||
} // namespace details
|
} // namespace details
|
||||||
|
|
||||||
InternalBackend::InternalBackend(db::Db& db)
|
InternalBackend::InternalBackend(db::IDb& db)
|
||||||
: _db{ db }
|
: _db{ db }
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
namespace lms::db
|
namespace lms::db
|
||||||
{
|
{
|
||||||
class Db;
|
class IDb;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace lms::feedback
|
namespace lms::feedback
|
||||||
@@ -31,7 +31,7 @@ namespace lms::feedback
|
|||||||
class InternalBackend final : public IFeedbackBackend
|
class InternalBackend final : public IFeedbackBackend
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
InternalBackend(db::Db& db);
|
InternalBackend(db::IDb& db);
|
||||||
~InternalBackend() override = default;
|
~InternalBackend() override = default;
|
||||||
InternalBackend(const InternalBackend&) = delete;
|
InternalBackend(const InternalBackend&) = delete;
|
||||||
InternalBackend& operator=(const InternalBackend&) = delete;
|
InternalBackend& operator=(const InternalBackend&) = delete;
|
||||||
@@ -44,6 +44,6 @@ namespace lms::feedback
|
|||||||
void onStarred(db::StarredTrackId trackId) override;
|
void onStarred(db::StarredTrackId trackId) override;
|
||||||
void onUnstarred(db::StarredTrackId trackId) override;
|
void onUnstarred(db::StarredTrackId trackId) override;
|
||||||
|
|
||||||
db::Db& _db;
|
db::IDb& _db;
|
||||||
};
|
};
|
||||||
} // namespace lms::feedback
|
} // namespace lms::feedback
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
#include "core/IConfig.hpp"
|
#include "core/IConfig.hpp"
|
||||||
#include "core/Service.hpp"
|
#include "core/Service.hpp"
|
||||||
#include "core/http/IClient.hpp"
|
#include "core/http/IClient.hpp"
|
||||||
#include "database/Db.hpp"
|
#include "database/IDb.hpp"
|
||||||
#include "database/Session.hpp"
|
#include "database/Session.hpp"
|
||||||
#include "database/StarredTrack.hpp"
|
#include "database/StarredTrack.hpp"
|
||||||
#include "database/Track.hpp"
|
#include "database/Track.hpp"
|
||||||
@@ -60,7 +60,7 @@ namespace lms::feedback::listenBrainz
|
|||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
FeedbacksSynchronizer::FeedbacksSynchronizer(boost::asio::io_context& ioContext, db::Db& db, core::http::IClient& client)
|
FeedbacksSynchronizer::FeedbacksSynchronizer(boost::asio::io_context& ioContext, db::IDb& db, core::http::IClient& client)
|
||||||
: _ioContext{ ioContext }
|
: _ioContext{ ioContext }
|
||||||
, _db{ db }
|
, _db{ db }
|
||||||
, _client{ client }
|
, _client{ client }
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ namespace lms
|
|||||||
}
|
}
|
||||||
namespace db
|
namespace db
|
||||||
{
|
{
|
||||||
class Db;
|
class IDb;
|
||||||
}
|
}
|
||||||
} // namespace lms
|
} // namespace lms
|
||||||
|
|
||||||
@@ -48,7 +48,7 @@ namespace lms::feedback::listenBrainz
|
|||||||
class FeedbacksSynchronizer
|
class FeedbacksSynchronizer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FeedbacksSynchronizer(boost::asio::io_context& ioContext, db::Db& db, core::http::IClient& client);
|
FeedbacksSynchronizer(boost::asio::io_context& ioContext, db::IDb& db, core::http::IClient& client);
|
||||||
~FeedbacksSynchronizer() = default;
|
~FeedbacksSynchronizer() = default;
|
||||||
FeedbacksSynchronizer(const FeedbacksSynchronizer&) = delete;
|
FeedbacksSynchronizer(const FeedbacksSynchronizer&) = delete;
|
||||||
FeedbacksSynchronizer& operator=(const FeedbacksSynchronizer&) = delete;
|
FeedbacksSynchronizer& operator=(const FeedbacksSynchronizer&) = delete;
|
||||||
@@ -95,7 +95,7 @@ namespace lms::feedback::listenBrainz
|
|||||||
|
|
||||||
boost::asio::io_context& _ioContext;
|
boost::asio::io_context& _ioContext;
|
||||||
boost::asio::io_context::strand _strand{ _ioContext };
|
boost::asio::io_context::strand _strand{ _ioContext };
|
||||||
db::Db& _db;
|
db::IDb& _db;
|
||||||
boost::asio::steady_timer _syncTimer{ _ioContext };
|
boost::asio::steady_timer _syncTimer{ _ioContext };
|
||||||
core::http::IClient& _client;
|
core::http::IClient& _client;
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
#include "core/IConfig.hpp"
|
#include "core/IConfig.hpp"
|
||||||
#include "core/Service.hpp"
|
#include "core/Service.hpp"
|
||||||
#include "core/http/IClient.hpp"
|
#include "core/http/IClient.hpp"
|
||||||
#include "database/Db.hpp"
|
#include "database/IDb.hpp"
|
||||||
#include "database/Session.hpp"
|
#include "database/Session.hpp"
|
||||||
#include "database/StarredArtist.hpp"
|
#include "database/StarredArtist.hpp"
|
||||||
#include "database/StarredRelease.hpp"
|
#include "database/StarredRelease.hpp"
|
||||||
@@ -56,7 +56,7 @@ namespace lms::feedback::listenBrainz
|
|||||||
}
|
}
|
||||||
} // namespace details
|
} // namespace details
|
||||||
|
|
||||||
ListenBrainzBackend::ListenBrainzBackend(boost::asio::io_context& ioContext, db::Db& db)
|
ListenBrainzBackend::ListenBrainzBackend(boost::asio::io_context& ioContext, db::IDb& db)
|
||||||
: _ioContext{ ioContext }
|
: _ioContext{ ioContext }
|
||||||
, _db{ db }
|
, _db{ db }
|
||||||
, _baseAPIUrl{ core::Service<core::IConfig>::get()->getString("listenbrainz-api-base-url", "https://api.listenbrainz.org") }
|
, _baseAPIUrl{ core::Service<core::IConfig>::get()->getString("listenbrainz-api-base-url", "https://api.listenbrainz.org") }
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
namespace lms::db
|
namespace lms::db
|
||||||
{
|
{
|
||||||
class Db;
|
class IDb;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace lms::feedback::listenBrainz
|
namespace lms::feedback::listenBrainz
|
||||||
@@ -36,7 +36,7 @@ namespace lms::feedback::listenBrainz
|
|||||||
class ListenBrainzBackend final : public IFeedbackBackend
|
class ListenBrainzBackend final : public IFeedbackBackend
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ListenBrainzBackend(boost::asio::io_context& ioContext, db::Db& db);
|
ListenBrainzBackend(boost::asio::io_context& ioContext, db::IDb& db);
|
||||||
~ListenBrainzBackend() override;
|
~ListenBrainzBackend() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -51,7 +51,7 @@ namespace lms::feedback::listenBrainz
|
|||||||
void onUnstarred(db::StarredTrackId starredTrackId) override;
|
void onUnstarred(db::StarredTrackId starredTrackId) override;
|
||||||
|
|
||||||
boost::asio::io_context& _ioContext;
|
boost::asio::io_context& _ioContext;
|
||||||
db::Db& _db;
|
db::IDb& _db;
|
||||||
std::string _baseAPIUrl;
|
std::string _baseAPIUrl;
|
||||||
std::unique_ptr<core::http::IClient> _client;
|
std::unique_ptr<core::http::IClient> _client;
|
||||||
FeedbacksSynchronizer _feedbacksSynchronizer;
|
FeedbacksSynchronizer _feedbacksSynchronizer;
|
||||||
|
|||||||
@@ -34,7 +34,7 @@
|
|||||||
|
|
||||||
namespace lms::db
|
namespace lms::db
|
||||||
{
|
{
|
||||||
class Db;
|
class IDb;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace lms::feedback
|
namespace lms::feedback
|
||||||
@@ -125,6 +125,6 @@ namespace lms::feedback
|
|||||||
virtual std::optional<db::Rating> getRating(db::UserId userId, db::TrackId trackId) = 0;
|
virtual std::optional<db::Rating> getRating(db::UserId userId, db::TrackId trackId) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::unique_ptr<IFeedbackService> createFeedbackService(boost::asio::io_context& ioContext, db::Db& db);
|
std::unique_ptr<IFeedbackService> createFeedbackService(boost::asio::io_context& ioContext, db::IDb& db);
|
||||||
|
|
||||||
} // namespace lms::feedback
|
} // namespace lms::feedback
|
||||||
|
|||||||
@@ -23,11 +23,11 @@
|
|||||||
|
|
||||||
namespace lms::db
|
namespace lms::db
|
||||||
{
|
{
|
||||||
class Db;
|
class IDb;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace lms::recommendation
|
namespace lms::recommendation
|
||||||
{
|
{
|
||||||
class IEngine;
|
class IEngine;
|
||||||
std::unique_ptr<IEngine> createClustersEngine(db::Db& db);
|
std::unique_ptr<IEngine> createClustersEngine(db::IDb& db);
|
||||||
} // namespace lms::recommendation
|
} // namespace lms::recommendation
|
||||||
|
|||||||
@@ -25,10 +25,10 @@
|
|||||||
|
|
||||||
namespace lms::db
|
namespace lms::db
|
||||||
{
|
{
|
||||||
class Db;
|
class IDb;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace lms::recommendation
|
namespace lms::recommendation
|
||||||
{
|
{
|
||||||
std::unique_ptr<IEngine> createFeaturesEngine(db::Db& db);
|
std::unique_ptr<IEngine> createFeaturesEngine(db::IDb& db);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
namespace lms::db
|
namespace lms::db
|
||||||
{
|
{
|
||||||
class Db;
|
class IDb;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace lms::recommendation
|
namespace lms::recommendation
|
||||||
@@ -47,6 +47,6 @@ namespace lms::recommendation
|
|||||||
virtual ArtistContainer getSimilarArtists(db::ArtistId artistId, core::EnumSet<db::TrackArtistLinkType> linkTypes, std::size_t maxCount) const = 0;
|
virtual ArtistContainer getSimilarArtists(db::ArtistId artistId, core::EnumSet<db::TrackArtistLinkType> linkTypes, std::size_t maxCount) const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::unique_ptr<IEngine> createEngine(db::Db& db);
|
std::unique_ptr<IEngine> createEngine(db::IDb& db);
|
||||||
|
|
||||||
} // namespace lms::recommendation
|
} // namespace lms::recommendation
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include "core/ILogger.hpp"
|
#include "core/ILogger.hpp"
|
||||||
#include "database/Db.hpp"
|
#include "database/IDb.hpp"
|
||||||
#include "database/Session.hpp"
|
#include "database/Session.hpp"
|
||||||
#include "database/Track.hpp"
|
#include "database/Track.hpp"
|
||||||
#include "services/recommendation/IRecommendationService.hpp"
|
#include "services/recommendation/IRecommendationService.hpp"
|
||||||
@@ -35,12 +35,12 @@ namespace lms::recommendation
|
|||||||
{
|
{
|
||||||
using namespace db;
|
using namespace db;
|
||||||
|
|
||||||
std::unique_ptr<IPlaylistGeneratorService> createPlaylistGeneratorService(Db& db, IRecommendationService& recommendationService)
|
std::unique_ptr<IPlaylistGeneratorService> createPlaylistGeneratorService(db::IDb& db, IRecommendationService& recommendationService)
|
||||||
{
|
{
|
||||||
return std::make_unique<PlaylistGeneratorService>(db, recommendationService);
|
return std::make_unique<PlaylistGeneratorService>(db, recommendationService);
|
||||||
}
|
}
|
||||||
|
|
||||||
PlaylistGeneratorService::PlaylistGeneratorService(Db& db, IRecommendationService& recommendationService)
|
PlaylistGeneratorService::PlaylistGeneratorService(db::IDb& db, IRecommendationService& recommendationService)
|
||||||
: _db{ db }
|
: _db{ db }
|
||||||
, _recommendationService{ recommendationService }
|
, _recommendationService{ recommendationService }
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -29,14 +29,14 @@ namespace lms::recommendation
|
|||||||
class PlaylistGeneratorService : public IPlaylistGeneratorService
|
class PlaylistGeneratorService : public IPlaylistGeneratorService
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PlaylistGeneratorService(db::Db& db, IRecommendationService& recommendationService);
|
PlaylistGeneratorService(db::IDb& db, IRecommendationService& recommendationService);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TrackContainer extendPlaylist(db::TrackListId tracklistId, std::size_t maxCount) const override;
|
TrackContainer extendPlaylist(db::TrackListId tracklistId, std::size_t maxCount) const override;
|
||||||
|
|
||||||
TrackContainer getTracksFromTrackList(db::TrackListId tracklistId) const;
|
TrackContainer getTracksFromTrackList(db::TrackListId tracklistId) const;
|
||||||
|
|
||||||
db::Db& _db;
|
db::IDb& _db;
|
||||||
IRecommendationService& _recommendationService;
|
IRecommendationService& _recommendationService;
|
||||||
std::vector<std::unique_ptr<PlaylistGeneratorConstraint::IConstraint>> _constraints;
|
std::vector<std::unique_ptr<PlaylistGeneratorConstraint::IConstraint>> _constraints;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "database/Db.hpp"
|
#include "database/IDb.hpp"
|
||||||
#include "database/ScanSettings.hpp"
|
#include "database/ScanSettings.hpp"
|
||||||
#include "database/Session.hpp"
|
#include "database/Session.hpp"
|
||||||
|
|
||||||
@@ -40,12 +40,12 @@ namespace lms::recommendation
|
|||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
std::unique_ptr<IRecommendationService> createRecommendationService(db::Db& db)
|
std::unique_ptr<IRecommendationService> createRecommendationService(db::IDb& db)
|
||||||
{
|
{
|
||||||
return std::make_unique<RecommendationService>(db);
|
return std::make_unique<RecommendationService>(db);
|
||||||
}
|
}
|
||||||
|
|
||||||
RecommendationService::RecommendationService(db::Db& db)
|
RecommendationService::RecommendationService(db::IDb& db)
|
||||||
: _db{ db }
|
: _db{ db }
|
||||||
{
|
{
|
||||||
load();
|
load();
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
namespace lms::db
|
namespace lms::db
|
||||||
{
|
{
|
||||||
class Db;
|
class IDb;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace lms::recommendation
|
namespace lms::recommendation
|
||||||
@@ -41,7 +41,7 @@ namespace lms::recommendation
|
|||||||
class RecommendationService : public IRecommendationService
|
class RecommendationService : public IRecommendationService
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RecommendationService(db::Db& db);
|
RecommendationService(db::IDb& db);
|
||||||
~RecommendationService() override = default;
|
~RecommendationService() override = default;
|
||||||
RecommendationService(const RecommendationService&) = delete;
|
RecommendationService(const RecommendationService&) = delete;
|
||||||
RecommendationService& operator=(const RecommendationService&) = delete;
|
RecommendationService& operator=(const RecommendationService&) = delete;
|
||||||
@@ -58,7 +58,7 @@ namespace lms::recommendation
|
|||||||
void clearEngines();
|
void clearEngines();
|
||||||
void loadPendingEngine(EngineType engineType, std::unique_ptr<IEngine> engine, bool forceReload, const ProgressCallback& progressCallback);
|
void loadPendingEngine(EngineType engineType, std::unique_ptr<IEngine> engine, bool forceReload, const ProgressCallback& progressCallback);
|
||||||
|
|
||||||
db::Db& _db;
|
db::IDb& _db;
|
||||||
std::optional<EngineType> _engineType;
|
std::optional<EngineType> _engineType;
|
||||||
std::unique_ptr<IEngine> _engine;
|
std::unique_ptr<IEngine> _engine;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
#include "database/Artist.hpp"
|
#include "database/Artist.hpp"
|
||||||
#include "database/Cluster.hpp"
|
#include "database/Cluster.hpp"
|
||||||
#include "database/Db.hpp"
|
#include "database/IDb.hpp"
|
||||||
#include "database/Release.hpp"
|
#include "database/Release.hpp"
|
||||||
#include "database/Session.hpp"
|
#include "database/Session.hpp"
|
||||||
#include "database/Track.hpp"
|
#include "database/Track.hpp"
|
||||||
@@ -29,10 +29,9 @@
|
|||||||
|
|
||||||
namespace lms::recommendation
|
namespace lms::recommendation
|
||||||
{
|
{
|
||||||
|
|
||||||
using namespace db;
|
using namespace db;
|
||||||
|
|
||||||
std::unique_ptr<IEngine> createClustersEngine(Db& db)
|
std::unique_ptr<IEngine> createClustersEngine(db::IDb& db)
|
||||||
{
|
{
|
||||||
return std::make_unique<ClusterEngine>(db);
|
return std::make_unique<ClusterEngine>(db);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ namespace lms::recommendation
|
|||||||
class ClusterEngine : public IEngine
|
class ClusterEngine : public IEngine
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ClusterEngine(db::Db& db)
|
ClusterEngine(db::IDb& db)
|
||||||
: _db{ db } {}
|
: _db{ db } {}
|
||||||
|
|
||||||
~ClusterEngine() override = default;
|
~ClusterEngine() override = default;
|
||||||
@@ -45,7 +45,7 @@ namespace lms::recommendation
|
|||||||
ReleaseContainer getSimilarReleases(db::ReleaseId releaseId, std::size_t maxCount) const override;
|
ReleaseContainer getSimilarReleases(db::ReleaseId releaseId, std::size_t maxCount) const override;
|
||||||
ArtistContainer getSimilarArtists(db::ArtistId artistId, core::EnumSet<db::TrackArtistLinkType> linkTypes, std::size_t maxCount) const override;
|
ArtistContainer getSimilarArtists(db::ArtistId artistId, core::EnumSet<db::TrackArtistLinkType> linkTypes, std::size_t maxCount) const override;
|
||||||
|
|
||||||
db::Db& _db;
|
db::IDb& _db;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace lms::recommendation
|
} // namespace lms::recommendation
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
#include "core/ILogger.hpp"
|
#include "core/ILogger.hpp"
|
||||||
#include "core/Random.hpp"
|
#include "core/Random.hpp"
|
||||||
#include "database/Artist.hpp"
|
#include "database/Artist.hpp"
|
||||||
#include "database/Db.hpp"
|
#include "database/IDb.hpp"
|
||||||
#include "database/Release.hpp"
|
#include "database/Release.hpp"
|
||||||
#include "database/Session.hpp"
|
#include "database/Session.hpp"
|
||||||
#include "database/Track.hpp"
|
#include "database/Track.hpp"
|
||||||
@@ -37,7 +37,7 @@ namespace lms::recommendation
|
|||||||
{
|
{
|
||||||
using namespace db;
|
using namespace db;
|
||||||
|
|
||||||
std::unique_ptr<IEngine> createFeaturesEngine(Db& db)
|
std::unique_ptr<IEngine> createFeaturesEngine(db::IDb& db)
|
||||||
{
|
{
|
||||||
return std::make_unique<FeaturesEngine>(db);
|
return std::make_unique<FeaturesEngine>(db);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ namespace lms::recommendation
|
|||||||
class FeaturesEngine : public IEngine
|
class FeaturesEngine : public IEngine
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FeaturesEngine(db::Db& db)
|
FeaturesEngine(db::IDb& db)
|
||||||
: _db{ db } {}
|
: _db{ db } {}
|
||||||
|
|
||||||
FeaturesEngine(const FeaturesEngine&) = delete;
|
FeaturesEngine(const FeaturesEngine&) = delete;
|
||||||
@@ -105,7 +105,7 @@ namespace lms::recommendation
|
|||||||
const ObjectPositions<IdType>& objectPositions,
|
const ObjectPositions<IdType>& objectPositions,
|
||||||
std::size_t maxCount) const;
|
std::size_t maxCount) const;
|
||||||
|
|
||||||
db::Db& _db;
|
db::IDb& _db;
|
||||||
bool _loadCancelled{};
|
bool _loadCancelled{};
|
||||||
std::unique_ptr<som::Network> _network;
|
std::unique_ptr<som::Network> _network;
|
||||||
double _networkRefVectorsDistanceMedian{};
|
double _networkRefVectorsDistanceMedian{};
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include "database/Db.hpp"
|
#include "database/IDb.hpp"
|
||||||
#include "database/Release.hpp"
|
#include "database/Release.hpp"
|
||||||
#include "database/Session.hpp"
|
#include "database/Session.hpp"
|
||||||
#include "database/Track.hpp"
|
#include "database/Track.hpp"
|
||||||
@@ -42,7 +42,7 @@ namespace lms::recommendation::PlaylistGeneratorConstraint
|
|||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
ConsecutiveArtists::ConsecutiveArtists(db::Db& db)
|
ConsecutiveArtists::ConsecutiveArtists(db::IDb& db)
|
||||||
: _db{ db }
|
: _db{ db }
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
namespace lms::db
|
namespace lms::db
|
||||||
{
|
{
|
||||||
class Db;
|
class IDb;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace lms::recommendation::PlaylistGeneratorConstraint
|
namespace lms::recommendation::PlaylistGeneratorConstraint
|
||||||
@@ -31,7 +31,7 @@ namespace lms::recommendation::PlaylistGeneratorConstraint
|
|||||||
class ConsecutiveArtists : public IConstraint
|
class ConsecutiveArtists : public IConstraint
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ConsecutiveArtists(db::Db& db);
|
ConsecutiveArtists(db::IDb& db);
|
||||||
~ConsecutiveArtists() override = default;
|
~ConsecutiveArtists() override = default;
|
||||||
ConsecutiveArtists(const ConsecutiveArtists&) = delete;
|
ConsecutiveArtists(const ConsecutiveArtists&) = delete;
|
||||||
ConsecutiveArtists& operator=(const ConsecutiveArtists&) = delete;
|
ConsecutiveArtists& operator=(const ConsecutiveArtists&) = delete;
|
||||||
@@ -40,6 +40,6 @@ namespace lms::recommendation::PlaylistGeneratorConstraint
|
|||||||
float computeScore(const TrackContainer& trackIds, std::size_t trackIndex) override;
|
float computeScore(const TrackContainer& trackIds, std::size_t trackIndex) override;
|
||||||
ArtistContainer getArtists(db::TrackId trackId);
|
ArtistContainer getArtists(db::TrackId trackId);
|
||||||
|
|
||||||
db::Db& _db;
|
db::IDb& _db;
|
||||||
};
|
};
|
||||||
} // namespace lms::recommendation::PlaylistGeneratorConstraint
|
} // namespace lms::recommendation::PlaylistGeneratorConstraint
|
||||||
|
|||||||
@@ -19,14 +19,14 @@
|
|||||||
|
|
||||||
#include "ConsecutiveReleases.hpp"
|
#include "ConsecutiveReleases.hpp"
|
||||||
|
|
||||||
#include "database/Db.hpp"
|
#include "database/IDb.hpp"
|
||||||
#include "database/Release.hpp"
|
#include "database/Release.hpp"
|
||||||
#include "database/Session.hpp"
|
#include "database/Session.hpp"
|
||||||
#include "database/Track.hpp"
|
#include "database/Track.hpp"
|
||||||
|
|
||||||
namespace lms::recommendation::PlaylistGeneratorConstraint
|
namespace lms::recommendation::PlaylistGeneratorConstraint
|
||||||
{
|
{
|
||||||
ConsecutiveReleases::ConsecutiveReleases(db::Db& db)
|
ConsecutiveReleases::ConsecutiveReleases(db::IDb& db)
|
||||||
: _db{ db }
|
: _db{ db }
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
namespace lms::db
|
namespace lms::db
|
||||||
{
|
{
|
||||||
class Db;
|
class IDb;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace lms::recommendation::PlaylistGeneratorConstraint
|
namespace lms::recommendation::PlaylistGeneratorConstraint
|
||||||
@@ -33,7 +33,7 @@ namespace lms::recommendation::PlaylistGeneratorConstraint
|
|||||||
class ConsecutiveReleases : public IConstraint
|
class ConsecutiveReleases : public IConstraint
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ConsecutiveReleases(db::Db& db);
|
ConsecutiveReleases(db::IDb& db);
|
||||||
~ConsecutiveReleases() override = default;
|
~ConsecutiveReleases() override = default;
|
||||||
ConsecutiveReleases(const ConsecutiveReleases&) = delete;
|
ConsecutiveReleases(const ConsecutiveReleases&) = delete;
|
||||||
ConsecutiveReleases& operator=(const ConsecutiveReleases&) = delete;
|
ConsecutiveReleases& operator=(const ConsecutiveReleases&) = delete;
|
||||||
@@ -43,6 +43,6 @@ namespace lms::recommendation::PlaylistGeneratorConstraint
|
|||||||
|
|
||||||
db::ReleaseId getReleaseId(db::TrackId trackId);
|
db::ReleaseId getReleaseId(db::TrackId trackId);
|
||||||
|
|
||||||
db::Db& _db;
|
db::IDb& _db;
|
||||||
};
|
};
|
||||||
} // namespace lms::recommendation::PlaylistGeneratorConstraint
|
} // namespace lms::recommendation::PlaylistGeneratorConstraint
|
||||||
|
|||||||
+2
-2
@@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
namespace lms::db
|
namespace lms::db
|
||||||
{
|
{
|
||||||
class Db;
|
class IDb;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace lms::recommendation
|
namespace lms::recommendation
|
||||||
@@ -41,5 +41,5 @@ namespace lms::recommendation
|
|||||||
virtual TrackContainer extendPlaylist(db::TrackListId tracklistId, std::size_t maxCount) const = 0;
|
virtual TrackContainer extendPlaylist(db::TrackListId tracklistId, std::size_t maxCount) const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::unique_ptr<IPlaylistGeneratorService> createPlaylistGeneratorService(db::Db& db, IRecommendationService& recommendationService);
|
std::unique_ptr<IPlaylistGeneratorService> createPlaylistGeneratorService(db::IDb& db, IRecommendationService& recommendationService);
|
||||||
} // namespace lms::recommendation
|
} // namespace lms::recommendation
|
||||||
|
|||||||
+2
-2
@@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
namespace lms::db
|
namespace lms::db
|
||||||
{
|
{
|
||||||
class Db;
|
class IDb;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace lms::recommendation
|
namespace lms::recommendation
|
||||||
@@ -49,5 +49,5 @@ namespace lms::recommendation
|
|||||||
virtual ArtistContainer getSimilarArtists(db::ArtistId artistId, core::EnumSet<db::TrackArtistLinkType> linkTypes, std::size_t maxCount) const = 0;
|
virtual ArtistContainer getSimilarArtists(db::ArtistId artistId, core::EnumSet<db::TrackArtistLinkType> linkTypes, std::size_t maxCount) const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::unique_ptr<IRecommendationService> createRecommendationService(db::Db& db);
|
std::unique_ptr<IRecommendationService> createRecommendationService(db::IDb& db);
|
||||||
} // namespace lms::recommendation
|
} // namespace lms::recommendation
|
||||||
|
|||||||
@@ -152,12 +152,12 @@ namespace lms::scanner
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
std::unique_ptr<IScannerService> createScannerService(Db& db)
|
std::unique_ptr<IScannerService> createScannerService(db::IDb& db)
|
||||||
{
|
{
|
||||||
return std::make_unique<ScannerService>(db);
|
return std::make_unique<ScannerService>(db);
|
||||||
}
|
}
|
||||||
|
|
||||||
ScannerService::ScannerService(Db& db)
|
ScannerService::ScannerService(db::IDb& db)
|
||||||
: _db{ db }
|
: _db{ db }
|
||||||
, _jobScheduler{ core::createJobScheduler("Scanner", getScannerThreadCount()) }
|
, _jobScheduler{ core::createJobScheduler("Scanner", getScannerThreadCount()) }
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
#include <Wt/WSignal.h>
|
#include <Wt/WSignal.h>
|
||||||
|
|
||||||
#include "ScannerSettings.hpp"
|
#include "ScannerSettings.hpp"
|
||||||
#include "database/Db.hpp"
|
#include "database/IDb.hpp"
|
||||||
#include "database/Session.hpp"
|
#include "database/Session.hpp"
|
||||||
#include "services/scanner/IScannerService.hpp"
|
#include "services/scanner/IScannerService.hpp"
|
||||||
#include "steps/IScanStep.hpp"
|
#include "steps/IScanStep.hpp"
|
||||||
@@ -52,7 +52,7 @@ namespace lms::scanner
|
|||||||
class ScannerService : public IScannerService
|
class ScannerService : public IScannerService
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ScannerService(db::Db& db);
|
ScannerService(db::IDb& db);
|
||||||
~ScannerService() override;
|
~ScannerService() override;
|
||||||
ScannerService(const ScannerService&) = delete;
|
ScannerService(const ScannerService&) = delete;
|
||||||
ScannerService& operator=(const ScannerService&) = delete;
|
ScannerService& operator=(const ScannerService&) = delete;
|
||||||
@@ -85,7 +85,7 @@ namespace lms::scanner
|
|||||||
void notifyInProgressIfNeeded(const ScanStepStats& stats);
|
void notifyInProgressIfNeeded(const ScanStepStats& stats);
|
||||||
void notifyInProgress(const ScanStepStats& stats);
|
void notifyInProgress(const ScanStepStats& stats);
|
||||||
|
|
||||||
db::Db& _db;
|
db::IDb& _db;
|
||||||
std::unique_ptr<core::IJobScheduler> _jobScheduler;
|
std::unique_ptr<core::IJobScheduler> _jobScheduler;
|
||||||
|
|
||||||
std::vector<std::unique_ptr<IFileScanner>> _fileScanners;
|
std::vector<std::unique_ptr<IFileScanner>> _fileScanners;
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
#include "core/String.hpp"
|
#include "core/String.hpp"
|
||||||
#include "database/Artist.hpp"
|
#include "database/Artist.hpp"
|
||||||
#include "database/ArtistInfo.hpp"
|
#include "database/ArtistInfo.hpp"
|
||||||
#include "database/Db.hpp"
|
#include "database/IDb.hpp"
|
||||||
#include "database/MediaLibrary.hpp"
|
#include "database/MediaLibrary.hpp"
|
||||||
#include "database/Session.hpp"
|
#include "database/Session.hpp"
|
||||||
#include "metadata/ArtistInfo.hpp"
|
#include "metadata/ArtistInfo.hpp"
|
||||||
@@ -137,7 +137,7 @@ namespace lms::scanner
|
|||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
ArtistInfoFileScanner::ArtistInfoFileScanner(db::Db& db, const ScannerSettings& settings)
|
ArtistInfoFileScanner::ArtistInfoFileScanner(db::IDb& db, const ScannerSettings& settings)
|
||||||
: _db{ db }
|
: _db{ db }
|
||||||
, _settings{ settings }
|
, _settings{ settings }
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -21,13 +21,10 @@
|
|||||||
|
|
||||||
#include "IFileScanner.hpp"
|
#include "IFileScanner.hpp"
|
||||||
|
|
||||||
namespace lms
|
namespace lms::db
|
||||||
{
|
{
|
||||||
namespace db
|
class IDb;
|
||||||
{
|
}
|
||||||
class Db;
|
|
||||||
}
|
|
||||||
} // namespace lms
|
|
||||||
|
|
||||||
namespace lms::scanner
|
namespace lms::scanner
|
||||||
{
|
{
|
||||||
@@ -36,7 +33,7 @@ namespace lms::scanner
|
|||||||
class ArtistInfoFileScanner : public IFileScanner
|
class ArtistInfoFileScanner : public IFileScanner
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ArtistInfoFileScanner(db::Db& db, const ScannerSettings& _settings);
|
ArtistInfoFileScanner(db::IDb& db, const ScannerSettings& _settings);
|
||||||
~ArtistInfoFileScanner() override = default;
|
~ArtistInfoFileScanner() override = default;
|
||||||
ArtistInfoFileScanner(const ArtistInfoFileScanner&) = delete;
|
ArtistInfoFileScanner(const ArtistInfoFileScanner&) = delete;
|
||||||
ArtistInfoFileScanner& operator=(const ArtistInfoFileScanner&) = delete;
|
ArtistInfoFileScanner& operator=(const ArtistInfoFileScanner&) = delete;
|
||||||
@@ -48,7 +45,7 @@ namespace lms::scanner
|
|||||||
bool needsScan(const FileToScan& file) const override;
|
bool needsScan(const FileToScan& file) const override;
|
||||||
std::unique_ptr<IFileScanOperation> createScanOperation(FileToScan&& fileToScan) const override;
|
std::unique_ptr<IFileScanOperation> createScanOperation(FileToScan&& fileToScan) const override;
|
||||||
|
|
||||||
db::Db& _db;
|
db::IDb& _db;
|
||||||
const ScannerSettings& _settings;
|
const ScannerSettings& _settings;
|
||||||
};
|
};
|
||||||
} // namespace lms::scanner
|
} // namespace lms::scanner
|
||||||
@@ -27,8 +27,8 @@
|
|||||||
#include "database/Artist.hpp"
|
#include "database/Artist.hpp"
|
||||||
#include "database/Artwork.hpp"
|
#include "database/Artwork.hpp"
|
||||||
#include "database/Cluster.hpp"
|
#include "database/Cluster.hpp"
|
||||||
#include "database/Db.hpp"
|
|
||||||
#include "database/Directory.hpp"
|
#include "database/Directory.hpp"
|
||||||
|
#include "database/IDb.hpp"
|
||||||
#include "database/MediaLibrary.hpp"
|
#include "database/MediaLibrary.hpp"
|
||||||
#include "database/Release.hpp"
|
#include "database/Release.hpp"
|
||||||
#include "database/Session.hpp"
|
#include "database/Session.hpp"
|
||||||
@@ -466,7 +466,7 @@ namespace lms::scanner
|
|||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
AudioFileScanOperation::AudioFileScanOperation(FileToScan&& fileToScan, db::Db& db, const ScannerSettings& settings, metadata::IAudioFileParser& parser)
|
AudioFileScanOperation::AudioFileScanOperation(FileToScan&& fileToScan, db::IDb& db, const ScannerSettings& settings, metadata::IAudioFileParser& parser)
|
||||||
: FileScanOperationBase{ std::move(fileToScan), db, settings }
|
: FileScanOperationBase{ std::move(fileToScan), db, settings }
|
||||||
, _parser{ parser }
|
, _parser{ parser }
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
|
|
||||||
namespace lms::db
|
namespace lms::db
|
||||||
{
|
{
|
||||||
class Db;
|
class IDb;
|
||||||
} // namespace lms::db
|
} // namespace lms::db
|
||||||
|
|
||||||
namespace lms::metadata
|
namespace lms::metadata
|
||||||
@@ -56,7 +56,7 @@ namespace lms::scanner
|
|||||||
class AudioFileScanOperation : public FileScanOperationBase
|
class AudioFileScanOperation : public FileScanOperationBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AudioFileScanOperation(FileToScan&& fileToScan, db::Db& db, const ScannerSettings& settings, metadata::IAudioFileParser& parser);
|
AudioFileScanOperation(FileToScan&& fileToScan, db::IDb& db, const ScannerSettings& settings, metadata::IAudioFileParser& parser);
|
||||||
~AudioFileScanOperation() override;
|
~AudioFileScanOperation() override;
|
||||||
AudioFileScanOperation(const AudioFileScanOperation&) = delete;
|
AudioFileScanOperation(const AudioFileScanOperation&) = delete;
|
||||||
AudioFileScanOperation& operator=(const AudioFileScanOperation&) = delete;
|
AudioFileScanOperation& operator=(const AudioFileScanOperation&) = delete;
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
#include "core/IConfig.hpp"
|
#include "core/IConfig.hpp"
|
||||||
#include "core/Service.hpp"
|
#include "core/Service.hpp"
|
||||||
#include "database/Db.hpp"
|
#include "database/IDb.hpp"
|
||||||
#include "database/MediaLibrary.hpp"
|
#include "database/MediaLibrary.hpp"
|
||||||
#include "database/Session.hpp"
|
#include "database/Session.hpp"
|
||||||
#include "database/Track.hpp"
|
#include "database/Track.hpp"
|
||||||
@@ -64,7 +64,7 @@ namespace lms::scanner
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
AudioFileScanner::AudioFileScanner(db::Db& db, const ScannerSettings& settings)
|
AudioFileScanner::AudioFileScanner(db::IDb& db, const ScannerSettings& settings)
|
||||||
: _db{ db }
|
: _db{ db }
|
||||||
, _settings{ settings }
|
, _settings{ settings }
|
||||||
, _metadataParser{ metadata::createAudioFileParser(createAudioFileParserParameters(settings)) } // For now, always use TagLib
|
, _metadataParser{ metadata::createAudioFileParser(createAudioFileParserParameters(settings)) } // For now, always use TagLib
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ namespace lms
|
|||||||
{
|
{
|
||||||
namespace db
|
namespace db
|
||||||
{
|
{
|
||||||
class Db;
|
class IDb;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace metadata
|
namespace metadata
|
||||||
@@ -41,7 +41,7 @@ namespace lms::scanner
|
|||||||
class AudioFileScanner : public IFileScanner
|
class AudioFileScanner : public IFileScanner
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AudioFileScanner(db::Db& db, const ScannerSettings& settings);
|
AudioFileScanner(db::IDb& db, const ScannerSettings& settings);
|
||||||
~AudioFileScanner() override;
|
~AudioFileScanner() override;
|
||||||
AudioFileScanner(const AudioFileScanner&) = delete;
|
AudioFileScanner(const AudioFileScanner&) = delete;
|
||||||
AudioFileScanner& operator=(const AudioFileScanner&) = delete;
|
AudioFileScanner& operator=(const AudioFileScanner&) = delete;
|
||||||
@@ -53,7 +53,7 @@ namespace lms::scanner
|
|||||||
bool needsScan(const FileToScan& file) const override;
|
bool needsScan(const FileToScan& file) const override;
|
||||||
std::unique_ptr<IFileScanOperation> createScanOperation(FileToScan&& fileToScan) const override;
|
std::unique_ptr<IFileScanOperation> createScanOperation(FileToScan&& fileToScan) const override;
|
||||||
|
|
||||||
db::Db& _db;
|
db::IDb& _db;
|
||||||
const ScannerSettings& _settings;
|
const ScannerSettings& _settings;
|
||||||
std::unique_ptr<metadata::IAudioFileParser> _metadataParser;
|
std::unique_ptr<metadata::IAudioFileParser> _metadataParser;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
namespace lms::scanner
|
namespace lms::scanner
|
||||||
{
|
{
|
||||||
FileScanOperationBase::FileScanOperationBase(FileToScan&& fileToScan, db::Db& db, const ScannerSettings& settings)
|
FileScanOperationBase::FileScanOperationBase(FileToScan&& fileToScan, db::IDb& db, const ScannerSettings& settings)
|
||||||
: _file{ std::move(fileToScan) }
|
: _file{ std::move(fileToScan) }
|
||||||
, _db{ db }
|
, _db{ db }
|
||||||
, _settings{ settings }
|
, _settings{ settings }
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
namespace lms::db
|
namespace lms::db
|
||||||
{
|
{
|
||||||
class Db;
|
class IDb;
|
||||||
} // namespace lms::db
|
} // namespace lms::db
|
||||||
|
|
||||||
namespace lms::scanner
|
namespace lms::scanner
|
||||||
@@ -38,7 +38,7 @@ namespace lms::scanner
|
|||||||
class FileScanOperationBase : public IFileScanOperation
|
class FileScanOperationBase : public IFileScanOperation
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FileScanOperationBase(FileToScan&& fileToScan, db::Db& db, const ScannerSettings& settings);
|
FileScanOperationBase(FileToScan&& fileToScan, db::IDb& db, const ScannerSettings& settings);
|
||||||
~FileScanOperationBase() override;
|
~FileScanOperationBase() override;
|
||||||
FileScanOperationBase(const FileScanOperationBase&) = delete;
|
FileScanOperationBase(const FileScanOperationBase&) = delete;
|
||||||
FileScanOperationBase& operator=(const FileScanOperationBase&) = delete;
|
FileScanOperationBase& operator=(const FileScanOperationBase&) = delete;
|
||||||
@@ -46,7 +46,7 @@ namespace lms::scanner
|
|||||||
protected:
|
protected:
|
||||||
const std::filesystem::path& getFilePath() const override { return _file.filePath; }
|
const std::filesystem::path& getFilePath() const override { return _file.filePath; }
|
||||||
const MediaLibraryInfo& getMediaLibrary() const { return _file.mediaLibrary; }
|
const MediaLibraryInfo& getMediaLibrary() const { return _file.mediaLibrary; }
|
||||||
db::Db& getDb() { return _db; }
|
db::IDb& getDb() { return _db; }
|
||||||
const ScannerSettings& getScannerSettings() const { return _settings; }
|
const ScannerSettings& getScannerSettings() const { return _settings; }
|
||||||
Wt::WDateTime getLastWriteTime() const { return _file.lastWriteTime; }
|
Wt::WDateTime getLastWriteTime() const { return _file.lastWriteTime; }
|
||||||
std::size_t getFileSize() const { return _file.fileSize; }
|
std::size_t getFileSize() const { return _file.fileSize; }
|
||||||
@@ -61,7 +61,7 @@ namespace lms::scanner
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
const FileToScan _file;
|
const FileToScan _file;
|
||||||
db::Db& _db;
|
db::IDb& _db;
|
||||||
const ScannerSettings& _settings;
|
const ScannerSettings& _settings;
|
||||||
ScanErrorVector _errors;
|
ScanErrorVector _errors;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
#include "core/ILogger.hpp"
|
#include "core/ILogger.hpp"
|
||||||
#include "database/Artwork.hpp"
|
#include "database/Artwork.hpp"
|
||||||
#include "database/Db.hpp"
|
#include "database/IDb.hpp"
|
||||||
#include "database/Image.hpp"
|
#include "database/Image.hpp"
|
||||||
#include "database/MediaLibrary.hpp"
|
#include "database/MediaLibrary.hpp"
|
||||||
#include "database/Session.hpp"
|
#include "database/Session.hpp"
|
||||||
@@ -108,7 +108,7 @@ namespace lms::scanner
|
|||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
ImageFileScanner::ImageFileScanner(db::Db& db, ScannerSettings& settings)
|
ImageFileScanner::ImageFileScanner(db::IDb& db, ScannerSettings& settings)
|
||||||
: _db{ db }
|
: _db{ db }
|
||||||
, _settings{ settings }
|
, _settings{ settings }
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -21,13 +21,10 @@
|
|||||||
|
|
||||||
#include "IFileScanner.hpp"
|
#include "IFileScanner.hpp"
|
||||||
|
|
||||||
namespace lms
|
namespace lms::db
|
||||||
{
|
{
|
||||||
namespace db
|
class IDb;
|
||||||
{
|
}
|
||||||
class Db;
|
|
||||||
}
|
|
||||||
} // namespace lms
|
|
||||||
|
|
||||||
namespace lms::scanner
|
namespace lms::scanner
|
||||||
{
|
{
|
||||||
@@ -36,7 +33,7 @@ namespace lms::scanner
|
|||||||
class ImageFileScanner : public IFileScanner
|
class ImageFileScanner : public IFileScanner
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ImageFileScanner(db::Db& db, ScannerSettings& settings);
|
ImageFileScanner(db::IDb& db, ScannerSettings& settings);
|
||||||
~ImageFileScanner() override = default;
|
~ImageFileScanner() override = default;
|
||||||
ImageFileScanner(const ImageFileScanner&) = delete;
|
ImageFileScanner(const ImageFileScanner&) = delete;
|
||||||
ImageFileScanner& operator=(const ImageFileScanner&) = delete;
|
ImageFileScanner& operator=(const ImageFileScanner&) = delete;
|
||||||
@@ -48,7 +45,7 @@ namespace lms::scanner
|
|||||||
bool needsScan(const FileToScan& file) const override;
|
bool needsScan(const FileToScan& file) const override;
|
||||||
std::unique_ptr<IFileScanOperation> createScanOperation(FileToScan&& fileToScan) const override;
|
std::unique_ptr<IFileScanOperation> createScanOperation(FileToScan&& fileToScan) const override;
|
||||||
|
|
||||||
db::Db& _db;
|
db::IDb& _db;
|
||||||
ScannerSettings& _settings;
|
ScannerSettings& _settings;
|
||||||
};
|
};
|
||||||
} // namespace lms::scanner
|
} // namespace lms::scanner
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
#include "FileScanOperationBase.hpp"
|
#include "FileScanOperationBase.hpp"
|
||||||
#include "ScannerSettings.hpp"
|
#include "ScannerSettings.hpp"
|
||||||
#include "core/ILogger.hpp"
|
#include "core/ILogger.hpp"
|
||||||
#include "database/Db.hpp"
|
#include "database/IDb.hpp"
|
||||||
#include "database/MediaLibrary.hpp"
|
#include "database/MediaLibrary.hpp"
|
||||||
#include "database/Session.hpp"
|
#include "database/Session.hpp"
|
||||||
#include "database/TrackLyrics.hpp"
|
#include "database/TrackLyrics.hpp"
|
||||||
@@ -122,7 +122,7 @@ namespace lms::scanner
|
|||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
LyricsFileScanner::LyricsFileScanner(db::Db& db, ScannerSettings& _settings)
|
LyricsFileScanner::LyricsFileScanner(db::IDb& db, ScannerSettings& _settings)
|
||||||
: _db{ db }
|
: _db{ db }
|
||||||
, _settings{ _settings }
|
, _settings{ _settings }
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -21,13 +21,10 @@
|
|||||||
|
|
||||||
#include "IFileScanner.hpp"
|
#include "IFileScanner.hpp"
|
||||||
|
|
||||||
namespace lms
|
namespace lms::db
|
||||||
{
|
{
|
||||||
namespace db
|
class IDb;
|
||||||
{
|
}
|
||||||
class Db;
|
|
||||||
}
|
|
||||||
} // namespace lms
|
|
||||||
|
|
||||||
namespace lms::scanner
|
namespace lms::scanner
|
||||||
{
|
{
|
||||||
@@ -36,7 +33,7 @@ namespace lms::scanner
|
|||||||
class LyricsFileScanner : public IFileScanner
|
class LyricsFileScanner : public IFileScanner
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
LyricsFileScanner(db::Db& db, ScannerSettings& settings);
|
LyricsFileScanner(db::IDb& db, ScannerSettings& settings);
|
||||||
~LyricsFileScanner() override = default;
|
~LyricsFileScanner() override = default;
|
||||||
LyricsFileScanner(const LyricsFileScanner&) = delete;
|
LyricsFileScanner(const LyricsFileScanner&) = delete;
|
||||||
LyricsFileScanner& operator=(const LyricsFileScanner&) = delete;
|
LyricsFileScanner& operator=(const LyricsFileScanner&) = delete;
|
||||||
@@ -48,7 +45,7 @@ namespace lms::scanner
|
|||||||
bool needsScan(const FileToScan& file) const override;
|
bool needsScan(const FileToScan& file) const override;
|
||||||
std::unique_ptr<IFileScanOperation> createScanOperation(FileToScan&& fileToScan) const override;
|
std::unique_ptr<IFileScanOperation> createScanOperation(FileToScan&& fileToScan) const override;
|
||||||
|
|
||||||
db::Db& _db;
|
db::IDb& _db;
|
||||||
ScannerSettings& _settings;
|
ScannerSettings& _settings;
|
||||||
};
|
};
|
||||||
} // namespace lms::scanner
|
} // namespace lms::scanner
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
#include <optional>
|
#include <optional>
|
||||||
|
|
||||||
#include "core/ILogger.hpp"
|
#include "core/ILogger.hpp"
|
||||||
#include "database/Db.hpp"
|
#include "database/IDb.hpp"
|
||||||
#include "database/MediaLibrary.hpp"
|
#include "database/MediaLibrary.hpp"
|
||||||
#include "database/PlayListFile.hpp"
|
#include "database/PlayListFile.hpp"
|
||||||
#include "database/Session.hpp"
|
#include "database/Session.hpp"
|
||||||
@@ -121,7 +121,7 @@ namespace lms::scanner
|
|||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
PlayListFileScanner::PlayListFileScanner(db::Db& db, ScannerSettings& settings)
|
PlayListFileScanner::PlayListFileScanner(db::IDb& db, ScannerSettings& settings)
|
||||||
: _db{ db }
|
: _db{ db }
|
||||||
, _settings{ settings }
|
, _settings{ settings }
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -21,13 +21,10 @@
|
|||||||
|
|
||||||
#include "IFileScanner.hpp"
|
#include "IFileScanner.hpp"
|
||||||
|
|
||||||
namespace lms
|
namespace lms::db
|
||||||
{
|
{
|
||||||
namespace db
|
class IDb;
|
||||||
{
|
}
|
||||||
class Db;
|
|
||||||
}
|
|
||||||
} // namespace lms
|
|
||||||
|
|
||||||
namespace lms::scanner
|
namespace lms::scanner
|
||||||
{
|
{
|
||||||
@@ -36,7 +33,7 @@ namespace lms::scanner
|
|||||||
class PlayListFileScanner : public IFileScanner
|
class PlayListFileScanner : public IFileScanner
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PlayListFileScanner(db::Db& db, ScannerSettings& settings);
|
PlayListFileScanner(db::IDb& db, ScannerSettings& settings);
|
||||||
~PlayListFileScanner() override = default;
|
~PlayListFileScanner() override = default;
|
||||||
PlayListFileScanner(const PlayListFileScanner&) = delete;
|
PlayListFileScanner(const PlayListFileScanner&) = delete;
|
||||||
PlayListFileScanner& operator=(const PlayListFileScanner&) = delete;
|
PlayListFileScanner& operator=(const PlayListFileScanner&) = delete;
|
||||||
@@ -48,7 +45,7 @@ namespace lms::scanner
|
|||||||
bool needsScan(const FileToScan& file) const override;
|
bool needsScan(const FileToScan& file) const override;
|
||||||
std::unique_ptr<IFileScanOperation> createScanOperation(FileToScan&& fileToScan) const override;
|
std::unique_ptr<IFileScanOperation> createScanOperation(FileToScan&& fileToScan) const override;
|
||||||
|
|
||||||
db::Db& _db;
|
db::IDb& _db;
|
||||||
ScannerSettings& _settings;
|
ScannerSettings& _settings;
|
||||||
};
|
};
|
||||||
} // namespace lms::scanner
|
} // namespace lms::scanner
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
#include "core/ILogger.hpp"
|
#include "core/ILogger.hpp"
|
||||||
#include "database/Artist.hpp"
|
#include "database/Artist.hpp"
|
||||||
#include "database/ArtistInfo.hpp"
|
#include "database/ArtistInfo.hpp"
|
||||||
#include "database/Db.hpp"
|
#include "database/IDb.hpp"
|
||||||
#include "database/Session.hpp"
|
#include "database/Session.hpp"
|
||||||
#include "database/Track.hpp"
|
#include "database/Track.hpp"
|
||||||
#include "database/TrackArtistLink.hpp"
|
#include "database/TrackArtistLink.hpp"
|
||||||
|
|||||||
@@ -34,8 +34,8 @@
|
|||||||
#include "database/ArtistInfo.hpp"
|
#include "database/ArtistInfo.hpp"
|
||||||
#include "database/Artwork.hpp"
|
#include "database/Artwork.hpp"
|
||||||
#include "database/ArtworkId.hpp"
|
#include "database/ArtworkId.hpp"
|
||||||
#include "database/Db.hpp"
|
|
||||||
#include "database/Directory.hpp"
|
#include "database/Directory.hpp"
|
||||||
|
#include "database/IDb.hpp"
|
||||||
#include "database/Image.hpp"
|
#include "database/Image.hpp"
|
||||||
#include "database/Release.hpp"
|
#include "database/Release.hpp"
|
||||||
#include "database/Session.hpp"
|
#include "database/Session.hpp"
|
||||||
@@ -270,7 +270,7 @@ namespace lms::scanner
|
|||||||
class ComputeArtistArtworkAssociationsJob : public core::IJob
|
class ComputeArtistArtworkAssociationsJob : public core::IJob
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ComputeArtistArtworkAssociationsJob(db::Db& db, const SearchArtistArtworkParams& searchParams, db::IdRange<db::ArtistId> artistIdRange)
|
ComputeArtistArtworkAssociationsJob(db::IDb& db, const SearchArtistArtworkParams& searchParams, db::IdRange<db::ArtistId> artistIdRange)
|
||||||
: _db{ db }
|
: _db{ db }
|
||||||
, _searchParams{ searchParams }
|
, _searchParams{ searchParams }
|
||||||
, _artistIdRange{ artistIdRange }
|
, _artistIdRange{ artistIdRange }
|
||||||
@@ -304,7 +304,7 @@ namespace lms::scanner
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
db::Db& _db;
|
db::IDb& _db;
|
||||||
const SearchArtistArtworkParams& _searchParams;
|
const SearchArtistArtworkParams& _searchParams;
|
||||||
db::IdRange<db::ArtistId> _artistIdRange;
|
db::IdRange<db::ArtistId> _artistIdRange;
|
||||||
std::vector<ArtistArtworkAssociation> _associations;
|
std::vector<ArtistArtworkAssociation> _associations;
|
||||||
|
|||||||
@@ -22,8 +22,8 @@
|
|||||||
#include <deque>
|
#include <deque>
|
||||||
|
|
||||||
#include "core/ILogger.hpp"
|
#include "core/ILogger.hpp"
|
||||||
#include "database/Db.hpp"
|
|
||||||
#include "database/Directory.hpp"
|
#include "database/Directory.hpp"
|
||||||
|
#include "database/IDb.hpp"
|
||||||
#include "database/Session.hpp"
|
#include "database/Session.hpp"
|
||||||
#include "database/Track.hpp"
|
#include "database/Track.hpp"
|
||||||
#include "database/TrackLyrics.hpp"
|
#include "database/TrackLyrics.hpp"
|
||||||
|
|||||||
@@ -25,8 +25,8 @@
|
|||||||
|
|
||||||
#include "core/IJob.hpp"
|
#include "core/IJob.hpp"
|
||||||
#include "core/ILogger.hpp"
|
#include "core/ILogger.hpp"
|
||||||
#include "database/Db.hpp"
|
|
||||||
#include "database/Directory.hpp"
|
#include "database/Directory.hpp"
|
||||||
|
#include "database/IDb.hpp"
|
||||||
#include "database/PlayListFile.hpp"
|
#include "database/PlayListFile.hpp"
|
||||||
#include "database/ReleaseId.hpp"
|
#include "database/ReleaseId.hpp"
|
||||||
#include "database/Session.hpp"
|
#include "database/Session.hpp"
|
||||||
@@ -174,7 +174,7 @@ namespace lms::scanner
|
|||||||
class ComputePlayListFileAssociationsJob : public core::IJob
|
class ComputePlayListFileAssociationsJob : public core::IJob
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ComputePlayListFileAssociationsJob(db::Db& db, const ScannerSettings& settings, db::IdRange<db::PlayListFileId> playListFileIdRange)
|
ComputePlayListFileAssociationsJob(db::IDb& db, const ScannerSettings& settings, db::IdRange<db::PlayListFileId> playListFileIdRange)
|
||||||
: _db{ db }
|
: _db{ db }
|
||||||
, _settings{ settings }
|
, _settings{ settings }
|
||||||
, _playListFileIdRange{ playListFileIdRange }
|
, _playListFileIdRange{ playListFileIdRange }
|
||||||
@@ -239,7 +239,7 @@ namespace lms::scanner
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
db::Db& _db;
|
db::IDb& _db;
|
||||||
const ScannerSettings& _settings;
|
const ScannerSettings& _settings;
|
||||||
db::IdRange<db::PlayListFileId> _playListFileIdRange;
|
db::IdRange<db::PlayListFileId> _playListFileIdRange;
|
||||||
std::vector<PlayListFileAssociation> _associations;
|
std::vector<PlayListFileAssociation> _associations;
|
||||||
|
|||||||
@@ -29,8 +29,8 @@
|
|||||||
#include "core/ILogger.hpp"
|
#include "core/ILogger.hpp"
|
||||||
#include "core/Path.hpp"
|
#include "core/Path.hpp"
|
||||||
#include "database/Artwork.hpp"
|
#include "database/Artwork.hpp"
|
||||||
#include "database/Db.hpp"
|
|
||||||
#include "database/Directory.hpp"
|
#include "database/Directory.hpp"
|
||||||
|
#include "database/IDb.hpp"
|
||||||
#include "database/Image.hpp"
|
#include "database/Image.hpp"
|
||||||
#include "database/Release.hpp"
|
#include "database/Release.hpp"
|
||||||
#include "database/Session.hpp"
|
#include "database/Session.hpp"
|
||||||
@@ -213,7 +213,7 @@ namespace lms::scanner
|
|||||||
class ComputeReleaseArtworkAssociationsJob : public core::IJob
|
class ComputeReleaseArtworkAssociationsJob : public core::IJob
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ComputeReleaseArtworkAssociationsJob(db::Db& db, const SearchReleaseArtworkParams& searchParams, db::IdRange<db::ReleaseId> artistIdRange)
|
ComputeReleaseArtworkAssociationsJob(db::IDb& db, const SearchReleaseArtworkParams& searchParams, db::IdRange<db::ReleaseId> artistIdRange)
|
||||||
: _db{ db }
|
: _db{ db }
|
||||||
, _searchParams{ searchParams }
|
, _searchParams{ searchParams }
|
||||||
, _artistIdRange{ artistIdRange }
|
, _artistIdRange{ artistIdRange }
|
||||||
@@ -247,7 +247,7 @@ namespace lms::scanner
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
db::Db& _db;
|
db::IDb& _db;
|
||||||
const SearchReleaseArtworkParams& _searchParams;
|
const SearchReleaseArtworkParams& _searchParams;
|
||||||
db::IdRange<db::ReleaseId> _artistIdRange;
|
db::IdRange<db::ReleaseId> _artistIdRange;
|
||||||
std::vector<ReleaseArtworkAssociation> _associations;
|
std::vector<ReleaseArtworkAssociation> _associations;
|
||||||
|
|||||||
@@ -28,8 +28,8 @@
|
|||||||
#include "core/ILogger.hpp"
|
#include "core/ILogger.hpp"
|
||||||
#include "core/LiteralString.hpp"
|
#include "core/LiteralString.hpp"
|
||||||
#include "database/Artwork.hpp"
|
#include "database/Artwork.hpp"
|
||||||
#include "database/Db.hpp"
|
|
||||||
#include "database/Directory.hpp"
|
#include "database/Directory.hpp"
|
||||||
|
#include "database/IDb.hpp"
|
||||||
#include "database/IdRange.hpp"
|
#include "database/IdRange.hpp"
|
||||||
#include "database/Image.hpp"
|
#include "database/Image.hpp"
|
||||||
#include "database/Release.hpp"
|
#include "database/Release.hpp"
|
||||||
@@ -160,7 +160,7 @@ namespace lms::scanner
|
|||||||
class ComputeTrackArtworkAssociationsJob : public core::IJob
|
class ComputeTrackArtworkAssociationsJob : public core::IJob
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ComputeTrackArtworkAssociationsJob(db::Db& db, db::IdRange<db::TrackId> trackIdRange)
|
ComputeTrackArtworkAssociationsJob(db::IDb& db, db::IdRange<db::TrackId> trackIdRange)
|
||||||
: _db{ db }
|
: _db{ db }
|
||||||
, _trackIdRange{ trackIdRange }
|
, _trackIdRange{ trackIdRange }
|
||||||
{
|
{
|
||||||
@@ -209,7 +209,7 @@ namespace lms::scanner
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
db::Db& _db;
|
db::IDb& _db;
|
||||||
db::IdRange<db::TrackId> _trackIdRange;
|
db::IdRange<db::TrackId> _trackIdRange;
|
||||||
std::vector<TrackArtworksAssociation> _trackAssociations;
|
std::vector<TrackArtworksAssociation> _trackAssociations;
|
||||||
std::size_t _processedTrackCount{};
|
std::size_t _processedTrackCount{};
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ namespace lms::core
|
|||||||
|
|
||||||
namespace lms::db
|
namespace lms::db
|
||||||
{
|
{
|
||||||
class Db;
|
class IDb;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace lms::scanner
|
namespace lms::scanner
|
||||||
@@ -56,7 +56,7 @@ namespace lms::scanner
|
|||||||
const ScannerSettings* lastScanSettings{};
|
const ScannerSettings* lastScanSettings{};
|
||||||
ProgressCallback progressCallback;
|
ProgressCallback progressCallback;
|
||||||
bool& abortScan;
|
bool& abortScan;
|
||||||
db::Db& db;
|
db::IDb& db;
|
||||||
std::span<IFileScanner*> fileScanners;
|
std::span<IFileScanner*> fileScanners;
|
||||||
};
|
};
|
||||||
ScanStepBase(InitParams& initParams);
|
ScanStepBase(InitParams& initParams);
|
||||||
@@ -82,7 +82,7 @@ namespace lms::scanner
|
|||||||
const ScannerSettings& _settings;
|
const ScannerSettings& _settings;
|
||||||
ProgressCallback _progressCallback;
|
ProgressCallback _progressCallback;
|
||||||
bool& _abortScan;
|
bool& _abortScan;
|
||||||
db::Db& _db;
|
db::IDb& _db;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
core::IJobScheduler& _jobScheduler;
|
core::IJobScheduler& _jobScheduler;
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
#include "ScanStepCheckForDuplicatedFiles.hpp"
|
#include "ScanStepCheckForDuplicatedFiles.hpp"
|
||||||
|
|
||||||
#include "core/ILogger.hpp"
|
#include "core/ILogger.hpp"
|
||||||
#include "database/Db.hpp"
|
#include "database/IDb.hpp"
|
||||||
#include "database/Session.hpp"
|
#include "database/Session.hpp"
|
||||||
#include "database/Track.hpp"
|
#include "database/Track.hpp"
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
#include "core/ILogger.hpp"
|
#include "core/ILogger.hpp"
|
||||||
#include "core/Path.hpp"
|
#include "core/Path.hpp"
|
||||||
#include "database/ArtistInfo.hpp"
|
#include "database/ArtistInfo.hpp"
|
||||||
#include "database/Db.hpp"
|
#include "database/IDb.hpp"
|
||||||
#include "database/Image.hpp"
|
#include "database/Image.hpp"
|
||||||
#include "database/PlayListFile.hpp"
|
#include "database/PlayListFile.hpp"
|
||||||
#include "database/Session.hpp"
|
#include "database/Session.hpp"
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
#include "ScanStepCompact.hpp"
|
#include "ScanStepCompact.hpp"
|
||||||
|
|
||||||
#include "database/Db.hpp"
|
#include "database/IDb.hpp"
|
||||||
#include "database/Session.hpp"
|
#include "database/Session.hpp"
|
||||||
|
|
||||||
#include "ScanContext.hpp"
|
#include "ScanContext.hpp"
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
#include "ScanStepComputeClusterStats.hpp"
|
#include "ScanStepComputeClusterStats.hpp"
|
||||||
#include "core/ILogger.hpp"
|
#include "core/ILogger.hpp"
|
||||||
#include "database/Cluster.hpp"
|
#include "database/Cluster.hpp"
|
||||||
#include "database/Db.hpp"
|
#include "database/IDb.hpp"
|
||||||
#include "database/Session.hpp"
|
#include "database/Session.hpp"
|
||||||
|
|
||||||
#include "ScanContext.hpp"
|
#include "ScanContext.hpp"
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
#include "ScanStepOptimize.hpp"
|
#include "ScanStepOptimize.hpp"
|
||||||
|
|
||||||
#include "core/ILogger.hpp"
|
#include "core/ILogger.hpp"
|
||||||
#include "database/Db.hpp"
|
#include "database/IDb.hpp"
|
||||||
#include "database/Session.hpp"
|
#include "database/Session.hpp"
|
||||||
|
|
||||||
#include "ScanContext.hpp"
|
#include "ScanContext.hpp"
|
||||||
|
|||||||
@@ -22,8 +22,8 @@
|
|||||||
#include "core/ILogger.hpp"
|
#include "core/ILogger.hpp"
|
||||||
#include "database/Artist.hpp"
|
#include "database/Artist.hpp"
|
||||||
#include "database/Cluster.hpp"
|
#include "database/Cluster.hpp"
|
||||||
#include "database/Db.hpp"
|
|
||||||
#include "database/Directory.hpp"
|
#include "database/Directory.hpp"
|
||||||
|
#include "database/IDb.hpp"
|
||||||
#include "database/Release.hpp"
|
#include "database/Release.hpp"
|
||||||
#include "database/Session.hpp"
|
#include "database/Session.hpp"
|
||||||
#include "database/Track.hpp"
|
#include "database/Track.hpp"
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
#include "core/ILogger.hpp"
|
#include "core/ILogger.hpp"
|
||||||
#include "core/ITraceLogger.hpp"
|
#include "core/ITraceLogger.hpp"
|
||||||
#include "core/Path.hpp"
|
#include "core/Path.hpp"
|
||||||
#include "database/Db.hpp"
|
#include "database/IDb.hpp"
|
||||||
#include "database/Session.hpp"
|
#include "database/Session.hpp"
|
||||||
#include "scanners/FileToScan.hpp"
|
#include "scanners/FileToScan.hpp"
|
||||||
#include "scanners/IFileScanOperation.hpp"
|
#include "scanners/IFileScanOperation.hpp"
|
||||||
|
|||||||
@@ -19,8 +19,8 @@
|
|||||||
|
|
||||||
#include "ScanStepUpdateLibraryFields.hpp"
|
#include "ScanStepUpdateLibraryFields.hpp"
|
||||||
|
|
||||||
#include "database/Db.hpp"
|
|
||||||
#include "database/Directory.hpp"
|
#include "database/Directory.hpp"
|
||||||
|
#include "database/IDb.hpp"
|
||||||
#include "database/MediaLibrary.hpp"
|
#include "database/MediaLibrary.hpp"
|
||||||
#include "database/Session.hpp"
|
#include "database/Session.hpp"
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
namespace lms::db
|
namespace lms::db
|
||||||
{
|
{
|
||||||
class Db;
|
class IDb;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace lms::scanner
|
namespace lms::scanner
|
||||||
@@ -61,5 +61,5 @@ namespace lms::scanner
|
|||||||
virtual Events& getEvents() = 0;
|
virtual Events& getEvents() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::unique_ptr<IScannerService> createScannerService(db::Db& db);
|
std::unique_ptr<IScannerService> createScannerService(db::IDb& db);
|
||||||
} // namespace lms::scanner
|
} // namespace lms::scanner
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
#include "core/ILogger.hpp"
|
#include "core/ILogger.hpp"
|
||||||
#include "database/Artist.hpp"
|
#include "database/Artist.hpp"
|
||||||
#include "database/Db.hpp"
|
#include "database/IDb.hpp"
|
||||||
#include "database/Listen.hpp"
|
#include "database/Listen.hpp"
|
||||||
#include "database/Release.hpp"
|
#include "database/Release.hpp"
|
||||||
#include "database/Session.hpp"
|
#include "database/Session.hpp"
|
||||||
@@ -55,12 +55,12 @@ namespace lms::scrobbling
|
|||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
std::unique_ptr<IScrobblingService> createScrobblingService(boost::asio::io_context& ioContext, Db& db)
|
std::unique_ptr<IScrobblingService> createScrobblingService(boost::asio::io_context& ioContext, db::IDb& db)
|
||||||
{
|
{
|
||||||
return std::make_unique<ScrobblingService>(ioContext, db);
|
return std::make_unique<ScrobblingService>(ioContext, db);
|
||||||
}
|
}
|
||||||
|
|
||||||
ScrobblingService::ScrobblingService(boost::asio::io_context& ioContext, Db& db)
|
ScrobblingService::ScrobblingService(boost::asio::io_context& ioContext, db::IDb& db)
|
||||||
: _db{ db }
|
: _db{ db }
|
||||||
{
|
{
|
||||||
LMS_LOG(SCROBBLING, INFO, "Starting service...");
|
LMS_LOG(SCROBBLING, INFO, "Starting service...");
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ namespace lms::scrobbling
|
|||||||
class ScrobblingService : public IScrobblingService
|
class ScrobblingService : public IScrobblingService
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ScrobblingService(boost::asio::io_context& ioContext, db::Db& db);
|
ScrobblingService(boost::asio::io_context& ioContext, db::IDb& db);
|
||||||
~ScrobblingService();
|
~ScrobblingService();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -56,7 +56,7 @@ namespace lms::scrobbling
|
|||||||
|
|
||||||
std::optional<db::ScrobblingBackend> getUserBackend(db::UserId userId);
|
std::optional<db::ScrobblingBackend> getUserBackend(db::UserId userId);
|
||||||
|
|
||||||
db::Db& _db;
|
db::IDb& _db;
|
||||||
std::unordered_map<db::ScrobblingBackend, std::unique_ptr<IScrobblingBackend>> _scrobblingBackends;
|
std::unordered_map<db::ScrobblingBackend, std::unique_ptr<IScrobblingBackend>> _scrobblingBackends;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
#include "InternalBackend.hpp"
|
#include "InternalBackend.hpp"
|
||||||
|
|
||||||
#include "database/Db.hpp"
|
#include "database/IDb.hpp"
|
||||||
#include "database/Listen.hpp"
|
#include "database/Listen.hpp"
|
||||||
#include "database/Session.hpp"
|
#include "database/Session.hpp"
|
||||||
#include "database/Track.hpp"
|
#include "database/Track.hpp"
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
namespace lms::scrobbling
|
namespace lms::scrobbling
|
||||||
{
|
{
|
||||||
InternalBackend::InternalBackend(db::Db& db)
|
InternalBackend::InternalBackend(db::IDb& db)
|
||||||
: _db{ db }
|
: _db{ db }
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
namespace lms::db
|
namespace lms::db
|
||||||
{
|
{
|
||||||
class Db;
|
class IDb;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace lms::scrobbling
|
namespace lms::scrobbling
|
||||||
@@ -31,13 +31,13 @@ namespace lms::scrobbling
|
|||||||
class InternalBackend final : public IScrobblingBackend
|
class InternalBackend final : public IScrobblingBackend
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
InternalBackend(db::Db& db);
|
InternalBackend(db::IDb& db);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void listenStarted(const Listen& listen) override;
|
void listenStarted(const Listen& listen) override;
|
||||||
void listenFinished(const Listen& listen, std::optional<std::chrono::seconds> duration) override;
|
void listenFinished(const Listen& listen, std::optional<std::chrono::seconds> duration) override;
|
||||||
void addTimedListen(const TimedListen& listen) override;
|
void addTimedListen(const TimedListen& listen) override;
|
||||||
|
|
||||||
db::Db& _db;
|
db::IDb& _db;
|
||||||
};
|
};
|
||||||
} // namespace lms::scrobbling
|
} // namespace lms::scrobbling
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
#include "core/ILogger.hpp"
|
#include "core/ILogger.hpp"
|
||||||
#include "core/Service.hpp"
|
#include "core/Service.hpp"
|
||||||
#include "core/http/IClient.hpp"
|
#include "core/http/IClient.hpp"
|
||||||
#include "database/Db.hpp"
|
#include "database/IDb.hpp"
|
||||||
#include "database/Session.hpp"
|
#include "database/Session.hpp"
|
||||||
#include "database/Track.hpp"
|
#include "database/Track.hpp"
|
||||||
|
|
||||||
@@ -51,7 +51,7 @@ namespace lms::scrobbling::listenBrainz
|
|||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
ListenBrainzBackend::ListenBrainzBackend(boost::asio::io_context& ioContext, Db& db)
|
ListenBrainzBackend::ListenBrainzBackend(boost::asio::io_context& ioContext, db::IDb& db)
|
||||||
: _ioContext{ ioContext }
|
: _ioContext{ ioContext }
|
||||||
, _db{ db }
|
, _db{ db }
|
||||||
, _baseAPIUrl{ core::Service<core::IConfig>::get()->getString("listenbrainz-api-base-url", "https://api.listenbrainz.org") }
|
, _baseAPIUrl{ core::Service<core::IConfig>::get()->getString("listenbrainz-api-base-url", "https://api.listenbrainz.org") }
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
namespace lms::db
|
namespace lms::db
|
||||||
{
|
{
|
||||||
class Db;
|
class IDb;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace lms::scrobbling::listenBrainz
|
namespace lms::scrobbling::listenBrainz
|
||||||
@@ -37,7 +37,7 @@ namespace lms::scrobbling::listenBrainz
|
|||||||
class ListenBrainzBackend final : public IScrobblingBackend
|
class ListenBrainzBackend final : public IScrobblingBackend
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ListenBrainzBackend(boost::asio::io_context& ioContext, db::Db& db);
|
ListenBrainzBackend(boost::asio::io_context& ioContext, db::IDb& db);
|
||||||
~ListenBrainzBackend() override;
|
~ListenBrainzBackend() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -52,7 +52,7 @@ namespace lms::scrobbling::listenBrainz
|
|||||||
void enqueListen(const Listen& listen, const Wt::WDateTime& timePoint);
|
void enqueListen(const Listen& listen, const Wt::WDateTime& timePoint);
|
||||||
|
|
||||||
boost::asio::io_context& _ioContext;
|
boost::asio::io_context& _ioContext;
|
||||||
db::Db& _db;
|
db::IDb& _db;
|
||||||
std::string _baseAPIUrl;
|
std::string _baseAPIUrl;
|
||||||
std::unique_ptr<core::http::IClient> _client;
|
std::unique_ptr<core::http::IClient> _client;
|
||||||
ListensSynchronizer _listensSynchronizer;
|
ListensSynchronizer _listensSynchronizer;
|
||||||
|
|||||||
@@ -31,7 +31,7 @@
|
|||||||
#include "core/Service.hpp"
|
#include "core/Service.hpp"
|
||||||
#include "core/http/IClient.hpp"
|
#include "core/http/IClient.hpp"
|
||||||
#include "database/Artist.hpp"
|
#include "database/Artist.hpp"
|
||||||
#include "database/Db.hpp"
|
#include "database/IDb.hpp"
|
||||||
#include "database/Listen.hpp"
|
#include "database/Listen.hpp"
|
||||||
#include "database/Release.hpp"
|
#include "database/Release.hpp"
|
||||||
#include "database/Session.hpp"
|
#include "database/Session.hpp"
|
||||||
@@ -210,7 +210,7 @@ namespace lms::scrobbling::listenBrainz
|
|||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
ListensSynchronizer::ListensSynchronizer(boost::asio::io_context& ioContext, db::Db& db, core::http::IClient& client)
|
ListensSynchronizer::ListensSynchronizer(boost::asio::io_context& ioContext, db::IDb& db, core::http::IClient& client)
|
||||||
: _ioContext{ ioContext }
|
: _ioContext{ ioContext }
|
||||||
, _db{ db }
|
, _db{ db }
|
||||||
, _client{ client }
|
, _client{ client }
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ namespace lms
|
|||||||
}
|
}
|
||||||
namespace db
|
namespace db
|
||||||
{
|
{
|
||||||
class Db;
|
class IDb;
|
||||||
}
|
}
|
||||||
} // namespace lms
|
} // namespace lms
|
||||||
|
|
||||||
@@ -48,7 +48,7 @@ namespace lms::scrobbling::listenBrainz
|
|||||||
class ListensSynchronizer
|
class ListensSynchronizer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ListensSynchronizer(boost::asio::io_context& ioContext, db::Db& db, core::http::IClient& client);
|
ListensSynchronizer(boost::asio::io_context& ioContext, db::IDb& db, core::http::IClient& client);
|
||||||
|
|
||||||
void enqueListen(const TimedListen& listen);
|
void enqueListen(const TimedListen& listen);
|
||||||
void enqueListenNow(const Listen& listen);
|
void enqueListenNow(const Listen& listen);
|
||||||
@@ -94,7 +94,7 @@ namespace lms::scrobbling::listenBrainz
|
|||||||
|
|
||||||
boost::asio::io_context& _ioContext;
|
boost::asio::io_context& _ioContext;
|
||||||
boost::asio::io_context::strand _strand{ _ioContext };
|
boost::asio::io_context::strand _strand{ _ioContext };
|
||||||
db::Db& _db;
|
db::IDb& _db;
|
||||||
boost::asio::steady_timer _syncTimer{ _ioContext };
|
boost::asio::steady_timer _syncTimer{ _ioContext };
|
||||||
core::http::IClient& _client;
|
core::http::IClient& _client;
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,7 @@
|
|||||||
|
|
||||||
namespace lms::db
|
namespace lms::db
|
||||||
{
|
{
|
||||||
class Db;
|
class IDb;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace lms::scrobbling
|
namespace lms::scrobbling
|
||||||
@@ -126,5 +126,5 @@ namespace lms::scrobbling
|
|||||||
virtual TrackContainer getTopTracks(const FindParameters& params) = 0;
|
virtual TrackContainer getTopTracks(const FindParameters& params) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::unique_ptr<IScrobblingService> createScrobblingService(boost::asio::io_context& ioContext, db::Db& db);
|
std::unique_ptr<IScrobblingService> createScrobblingService(boost::asio::io_context& ioContext, db::IDb& db);
|
||||||
} // namespace lms::scrobbling
|
} // namespace lms::scrobbling
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
#include "av/ITranscoder.hpp"
|
#include "av/ITranscoder.hpp"
|
||||||
#include "core/ILogger.hpp"
|
#include "core/ILogger.hpp"
|
||||||
#include "database/Db.hpp"
|
#include "database/IDb.hpp"
|
||||||
#include "database/Session.hpp"
|
#include "database/Session.hpp"
|
||||||
#include "database/Track.hpp"
|
#include "database/Track.hpp"
|
||||||
|
|
||||||
@@ -43,12 +43,12 @@ namespace lms::transcoding
|
|||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
std::unique_ptr<ITranscodingService> createTranscodingService(db::Db& db, core::IChildProcessManager& childProcessManager)
|
std::unique_ptr<ITranscodingService> createTranscodingService(db::IDb& db, core::IChildProcessManager& childProcessManager)
|
||||||
{
|
{
|
||||||
return std::make_unique<TranscodingService>(db, childProcessManager);
|
return std::make_unique<TranscodingService>(db, childProcessManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
TranscodingService::TranscodingService(db::Db& db, core::IChildProcessManager& childProcessManager)
|
TranscodingService::TranscodingService(db::IDb& db, core::IChildProcessManager& childProcessManager)
|
||||||
: _db{ db }
|
: _db{ db }
|
||||||
, _childProcessManager(childProcessManager)
|
, _childProcessManager(childProcessManager)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ namespace lms::transcoding
|
|||||||
class TranscodingService : public ITranscodingService
|
class TranscodingService : public ITranscodingService
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit TranscodingService(db::Db& db, core::IChildProcessManager& childProcessManager);
|
explicit TranscodingService(db::IDb& db, core::IChildProcessManager& childProcessManager);
|
||||||
~TranscodingService() override;
|
~TranscodingService() override;
|
||||||
|
|
||||||
TranscodingService(const TranscodingService&) = delete;
|
TranscodingService(const TranscodingService&) = delete;
|
||||||
@@ -35,7 +35,7 @@ namespace lms::transcoding
|
|||||||
private:
|
private:
|
||||||
std::unique_ptr<core::IResourceHandler> createResourceHandler(const InputParameters& inputParameters, const OutputParameters& outputParameters, bool estimateContentLength) override;
|
std::unique_ptr<core::IResourceHandler> createResourceHandler(const InputParameters& inputParameters, const OutputParameters& outputParameters, bool estimateContentLength) override;
|
||||||
|
|
||||||
db::Db& _db;
|
db::IDb& _db;
|
||||||
core::IChildProcessManager& _childProcessManager;
|
core::IChildProcessManager& _childProcessManager;
|
||||||
};
|
};
|
||||||
} // namespace lms::transcoding
|
} // namespace lms::transcoding
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ namespace lms
|
|||||||
|
|
||||||
namespace db
|
namespace db
|
||||||
{
|
{
|
||||||
class Db;
|
class IDb;
|
||||||
}
|
}
|
||||||
} // namespace lms
|
} // namespace lms
|
||||||
|
|
||||||
@@ -72,5 +72,5 @@ namespace lms::transcoding
|
|||||||
virtual std::unique_ptr<core::IResourceHandler> createResourceHandler(const InputParameters& inputParameters, const OutputParameters& outputParameters, bool estimateContentLength) = 0;
|
virtual std::unique_ptr<core::IResourceHandler> createResourceHandler(const InputParameters& inputParameters, const OutputParameters& outputParameters, bool estimateContentLength) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::unique_ptr<ITranscodingService> createTranscodingService(db::Db& db, core::IChildProcessManager& childProcessManager);
|
std::unique_ptr<ITranscodingService> createTranscodingService(db::IDb& db, core::IChildProcessManager& childProcessManager);
|
||||||
} // namespace lms::transcoding
|
} // namespace lms::transcoding
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
#include "core/LiteralString.hpp"
|
#include "core/LiteralString.hpp"
|
||||||
#include "core/Service.hpp"
|
#include "core/Service.hpp"
|
||||||
#include "core/String.hpp"
|
#include "core/String.hpp"
|
||||||
#include "database/Db.hpp"
|
#include "database/IDb.hpp"
|
||||||
#include "database/Session.hpp"
|
#include "database/Session.hpp"
|
||||||
#include "database/User.hpp"
|
#include "database/User.hpp"
|
||||||
#include "services/auth/IAuthTokenService.hpp"
|
#include "services/auth/IAuthTokenService.hpp"
|
||||||
@@ -52,7 +52,7 @@
|
|||||||
|
|
||||||
namespace lms::api::subsonic
|
namespace lms::api::subsonic
|
||||||
{
|
{
|
||||||
std::unique_ptr<Wt::WResource> createSubsonicResource(db::Db& db)
|
std::unique_ptr<Wt::WResource> createSubsonicResource(db::IDb& db)
|
||||||
{
|
{
|
||||||
return std::make_unique<SubsonicResource>(db);
|
return std::make_unique<SubsonicResource>(db);
|
||||||
}
|
}
|
||||||
@@ -295,7 +295,7 @@ namespace lms::api::subsonic
|
|||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
SubsonicResource::SubsonicResource(db::Db& db)
|
SubsonicResource::SubsonicResource(db::IDb& db)
|
||||||
: _serverProtocolVersionsByClient{ readConfigProtocolVersions() }
|
: _serverProtocolVersionsByClient{ readConfigProtocolVersions() }
|
||||||
, _openSubsonicDisabledClients{ readOpenSubsonicDisabledClients() }
|
, _openSubsonicDisabledClients{ readOpenSubsonicDisabledClients() }
|
||||||
, _supportUserPasswordAuthentication{ core::Service<core::IConfig>::get()->getBool("api-subsonic-support-user-password-auth", true) }
|
, _supportUserPasswordAuthentication{ core::Service<core::IConfig>::get()->getBool("api-subsonic-support-user-password-auth", true) }
|
||||||
|
|||||||
@@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
namespace lms::db
|
namespace lms::db
|
||||||
{
|
{
|
||||||
class Db;
|
class IDb;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace lms::api::subsonic
|
namespace lms::api::subsonic
|
||||||
@@ -39,7 +39,7 @@ namespace lms::api::subsonic
|
|||||||
class SubsonicResource final : public Wt::WResource
|
class SubsonicResource final : public Wt::WResource
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SubsonicResource(db::Db& db);
|
SubsonicResource(db::IDb& db);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void handleRequest(const Wt::Http::Request& request, Wt::Http::Response& response) override;
|
void handleRequest(const Wt::Http::Request& request, Wt::Http::Response& response) override;
|
||||||
@@ -53,6 +53,6 @@ namespace lms::api::subsonic
|
|||||||
const std::unordered_set<std::string> _openSubsonicDisabledClients;
|
const std::unordered_set<std::string> _openSubsonicDisabledClients;
|
||||||
const bool _supportUserPasswordAuthentication;
|
const bool _supportUserPasswordAuthentication;
|
||||||
|
|
||||||
db::Db& _db;
|
db::IDb& _db;
|
||||||
};
|
};
|
||||||
} // namespace lms::api::subsonic
|
} // namespace lms::api::subsonic
|
||||||
|
|||||||
@@ -24,10 +24,10 @@
|
|||||||
|
|
||||||
namespace lms::db
|
namespace lms::db
|
||||||
{
|
{
|
||||||
class Db;
|
class IDb;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace lms::api::subsonic
|
namespace lms::api::subsonic
|
||||||
{
|
{
|
||||||
std::unique_ptr<Wt::WResource> createSubsonicResource(db::Db& db);
|
std::unique_ptr<Wt::WResource> createSubsonicResource(db::IDb& db);
|
||||||
} // namespace lms::api::subsonic
|
} // namespace lms::api::subsonic
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user