Refactored namespaces

This commit is contained in:
emeric
2024-03-12 08:32:08 +01:00
parent 487960b413
commit 4b7c4295ec
501 changed files with 12605 additions and 12631 deletions
+1 -1
View File
@@ -22,7 +22,7 @@
#include <string>
#include "ProtocolVersion.hpp"
namespace API::Subsonic
namespace lms::api::subsonic
{
struct ClientInfo
{
+2 -2
View File
@@ -19,7 +19,7 @@
#include "ParameterParsing.hpp"
namespace API::Subsonic
namespace lms::api::subsonic
{
bool hasParameter(const Wt::Http::ParameterMap& parameterMap, const std::string& param)
{
@@ -30,7 +30,7 @@ namespace API::Subsonic
{
if (password.find("enc:") == 0)
{
auto decodedPassword{ StringUtils::stringFromHex(password.substr(4)) };
auto decodedPassword{ core::stringUtils::stringFromHex(password.substr(4)) };
if (!decodedPassword)
return password; // fallback on plain password
+3 -3
View File
@@ -26,10 +26,10 @@
#include <string>
#include "database/Types.hpp"
#include "utils/String.hpp"
#include "core/String.hpp"
#include "SubsonicResponse.hpp"
namespace API::Subsonic
namespace lms::api::subsonic
{
template<typename T>
@@ -43,7 +43,7 @@ namespace API::Subsonic
for (const std::string& param : it->second)
{
auto value{ StringUtils::readAs<T>(param) };
auto value{ core::stringUtils::readAs<T>(param) };
if (value)
res.emplace_back(std::move(*value));
}
+7 -7
View File
@@ -19,31 +19,31 @@
#include "ProtocolVersion.hpp"
namespace StringUtils
namespace lms::core::stringUtils
{
template<>
std::optional<API::Subsonic::ProtocolVersion> readAs(std::string_view str)
std::optional<api::subsonic::ProtocolVersion> readAs(std::string_view str)
{
// Expects "X.Y.Z"
const auto numbers{ StringUtils::splitString(str, '.') };
const auto numbers{ core::stringUtils::splitString(str, '.') };
if (numbers.size() < 2 || numbers.size() > 3)
return std::nullopt;
API::Subsonic::ProtocolVersion version;
api::subsonic::ProtocolVersion version;
auto number{ StringUtils::readAs<unsigned>(numbers[0]) };
auto number{ core::stringUtils::readAs<unsigned>(numbers[0]) };
if (!number)
return std::nullopt;
version.major = *number;
number = { StringUtils::readAs<unsigned>(numbers[1]) };
number = { core::stringUtils::readAs<unsigned>(numbers[1]) };
if (!number)
return std::nullopt;
version.minor = *number;
if (numbers.size() == 3)
{
number = { StringUtils::readAs<unsigned>(numbers[2]) };
number = { core::stringUtils::readAs<unsigned>(numbers[2]) };
if (!number)
return std::nullopt;
version.patch = *number;
+4 -4
View File
@@ -19,9 +19,9 @@
#pragma once
#include "utils/String.hpp"
#include "core/String.hpp"
namespace API::Subsonic
namespace lms::api::subsonic
{
struct ProtocolVersion
{
@@ -34,9 +34,9 @@ namespace API::Subsonic
static inline constexpr std::string_view serverVersion{ "6" };
}
namespace StringUtils
namespace lms::core::stringUtils
{
template<>
std::optional<API::Subsonic::ProtocolVersion> readAs(std::string_view str);
std::optional<api::subsonic::ProtocolVersion> readAs(std::string_view str);
}
+4 -4
View File
@@ -27,18 +27,18 @@
#include "ClientInfo.hpp"
#include "ProtocolVersion.hpp"
namespace Database
namespace lms::db
{
class Session;
}
namespace API::Subsonic
namespace lms::api::subsonic
{
struct RequestContext
{
const Wt::Http::ParameterMap& parameters;
Database::Session& dbSession;
Database::UserId userId;
db::Session& dbSession;
db::UserId userId;
ClientInfo clientInfo;
ProtocolVersion serverProtocolVersion;
bool enableOpenSubsonic{ true };
+31 -31
View File
@@ -21,23 +21,23 @@
#include "SubsonicResponse.hpp"
#include "utils/ILogger.hpp"
#include "utils/String.hpp"
#include "core/ILogger.hpp"
#include "core/String.hpp"
namespace API::Subsonic
namespace lms::api::subsonic
{
std::string idToString(Database::ArtistId id)
std::string idToString(db::ArtistId id)
{
return "ar-" + id.toString();
}
std::string idToString(Database::MediaLibraryId id)
std::string idToString(db::MediaLibraryId id)
{
// No need to prefix as this is only used at well known places
return id.toString();
}
std::string idToString(Database::ReleaseId id)
std::string idToString(db::ReleaseId id)
{
return "al-" + id.toString();
}
@@ -47,97 +47,97 @@ namespace API::Subsonic
return "root";
}
std::string idToString(Database::TrackId id)
std::string idToString(db::TrackId id)
{
return "tr-" + id.toString();
}
std::string idToString(Database::TrackListId id)
std::string idToString(db::TrackListId id)
{
return "pl-" + id.toString();
}
} // namespace API::Subsonic
} // namespace lms::api::subsonic
namespace StringUtils
namespace lms::core::stringUtils
{
template<>
std::optional<Database::ArtistId> readAs(std::string_view str)
std::optional<db::ArtistId> readAs(std::string_view str)
{
std::vector<std::string_view> values{ StringUtils::splitString(str, '-') };
std::vector<std::string_view> values{ core::stringUtils::splitString(str, '-') };
if (values.size() != 2)
return std::nullopt;
if (values[0] != "ar")
return std::nullopt;
if (const auto value{ StringUtils::readAs<Database::ArtistId::ValueType>(values[1]) })
return Database::ArtistId{ *value };
if (const auto value{ core::stringUtils::readAs<db::ArtistId::ValueType>(values[1]) })
return db::ArtistId{ *value };
return std::nullopt;
}
template<>
std::optional<Database::MediaLibraryId> readAs(std::string_view str)
std::optional<db::MediaLibraryId> readAs(std::string_view str)
{
if (const auto value{ StringUtils::readAs<Database::MediaLibraryId::ValueType>(str) })
return Database::MediaLibraryId{ *value };
if (const auto value{ core::stringUtils::readAs<db::MediaLibraryId::ValueType>(str) })
return db::MediaLibraryId{ *value };
return std::nullopt;
}
template<>
std::optional<Database::ReleaseId> readAs(std::string_view str)
std::optional<db::ReleaseId> readAs(std::string_view str)
{
std::vector<std::string_view> values{ StringUtils::splitString(str, '-') };
std::vector<std::string_view> values{ core::stringUtils::splitString(str, '-') };
if (values.size() != 2)
return std::nullopt;
if (values[0] != "al")
return std::nullopt;
if (const auto value{ StringUtils::readAs<Database::ReleaseId::ValueType>(values[1]) })
return Database::ReleaseId{ *value };
if (const auto value{ core::stringUtils::readAs<db::ReleaseId::ValueType>(values[1]) })
return db::ReleaseId{ *value };
return std::nullopt;
}
template<>
std::optional<API::Subsonic::RootId> readAs(std::string_view str)
std::optional<api::subsonic::RootId> readAs(std::string_view str)
{
if (str == "root")
return API::Subsonic::RootId{};
return api::subsonic::RootId{};
return std::nullopt;
}
template<>
std::optional<Database::TrackId> readAs(std::string_view str)
std::optional<db::TrackId> readAs(std::string_view str)
{
std::vector<std::string_view> values{ StringUtils::splitString(str, '-') };
std::vector<std::string_view> values{ core::stringUtils::splitString(str, '-') };
if (values.size() != 2)
return std::nullopt;
if (values[0] != "tr")
return std::nullopt;
if (const auto value{ StringUtils::readAs<Database::TrackId::ValueType>(values[1]) })
return Database::TrackId{ *value };
if (const auto value{ core::stringUtils::readAs<db::TrackId::ValueType>(values[1]) })
return db::TrackId{ *value };
return std::nullopt;
}
template<>
std::optional<Database::TrackListId> readAs(std::string_view str)
std::optional<db::TrackListId> readAs(std::string_view str)
{
std::vector<std::string_view> values{ StringUtils::splitString(str, '-') };
std::vector<std::string_view> values{ core::stringUtils::splitString(str, '-') };
if (values.size() != 2)
return std::nullopt;
if (values[0] != "pl")
return std::nullopt;
if (const auto value{ StringUtils::readAs<Database::TrackListId::ValueType>(values[1]) })
return Database::TrackListId{ *value };
if (const auto value{ core::stringUtils::readAs<db::TrackListId::ValueType>(values[1]) })
return db::TrackListId{ *value };
return std::nullopt;
}
+15 -15
View File
@@ -24,39 +24,39 @@
#include "database/ReleaseId.hpp"
#include "database/TrackId.hpp"
#include "database/TrackListId.hpp"
#include "utils/String.hpp"
#include "core/String.hpp"
namespace API::Subsonic
namespace lms::api::subsonic
{
struct RootId {};
std::string idToString(Database::ArtistId id);
std::string idToString(Database::MediaLibraryId id);
std::string idToString(Database::ReleaseId id);
std::string idToString(Database::TrackId id);
std::string idToString(Database::TrackListId id);
std::string idToString(db::ArtistId id);
std::string idToString(db::MediaLibraryId id);
std::string idToString(db::ReleaseId id);
std::string idToString(db::TrackId id);
std::string idToString(db::TrackListId id);
std::string idToString(RootId);
} // namespace API::Subsonic
} // namespace lms::api::subsonic
// Used to parse parameters
namespace StringUtils
namespace lms::core::stringUtils
{
template<>
std::optional<API::Subsonic::RootId> readAs(std::string_view str);
std::optional<api::subsonic::RootId> readAs(std::string_view str);
template<>
std::optional<Database::ArtistId> readAs(std::string_view str);
std::optional<db::ArtistId> readAs(std::string_view str);
template<>
std::optional<Database::MediaLibraryId> readAs(std::string_view str);
std::optional<db::MediaLibraryId> readAs(std::string_view str);
template<>
std::optional<Database::ReleaseId> readAs(std::string_view str);
std::optional<db::ReleaseId> readAs(std::string_view str);
template<>
std::optional<Database::TrackId> readAs(std::string_view str);
std::optional<db::TrackId> readAs(std::string_view str);
template<>
std::optional<Database::TrackListId> readAs(std::string_view str);
std::optional<db::TrackListId> readAs(std::string_view str);
}
+38 -40
View File
@@ -27,14 +27,14 @@
#include "database/Db.hpp"
#include "database/Session.hpp"
#include "database/User.hpp"
#include "utils/EnumSet.hpp"
#include "utils/LiteralString.hpp"
#include "utils/IConfig.hpp"
#include "utils/ILogger.hpp"
#include "utils/ITraceLogger.hpp"
#include "utils/Service.hpp"
#include "utils/String.hpp"
#include "utils/Utils.hpp"
#include "core/EnumSet.hpp"
#include "core/LiteralString.hpp"
#include "core/IConfig.hpp"
#include "core/ILogger.hpp"
#include "core/ITraceLogger.hpp"
#include "core/Service.hpp"
#include "core/String.hpp"
#include "core/Utils.hpp"
#include "entrypoints/AlbumSongLists.hpp"
#include "entrypoints/Browsing.hpp"
@@ -53,11 +53,9 @@
#include "SubsonicResponse.hpp"
#include "Utils.hpp"
using namespace Database;
namespace API::Subsonic
namespace lms::api::subsonic
{
std::unique_ptr<Wt::WResource> createSubsonicResource(Database::Db& db)
std::unique_ptr<Wt::WResource> createSubsonicResource(db::Db& db)
{
return std::make_unique<SubsonicResource>(db);
}
@@ -68,7 +66,7 @@ namespace API::Subsonic
{
std::unordered_map<std::string, ProtocolVersion> res;
Service<IConfig>::get()->visitStrings("api-subsonic-old-server-protocol-clients",
core::Service<core::IConfig>::get()->visitStrings("api-subsonic-old-server-protocol-clients",
[&](std::string_view client)
{
res.emplace(std::string{ client }, ProtocolVersion{ 1, 12, 0 });
@@ -81,7 +79,7 @@ namespace API::Subsonic
{
std::unordered_set<std::string> res;
Service<IConfig>::get()->visitStrings("api-open-subsonic-disabled-clients",
core::Service<core::IConfig>::get()->visitStrings("api-open-subsonic-disabled-clients",
[&](std::string_view client)
{
res.emplace(std::string{ client });
@@ -94,7 +92,7 @@ namespace API::Subsonic
{
std::unordered_set<std::string> res;
Service<IConfig>::get()->visitStrings("api-subsonic-default-cover-clients",
core::Service<core::IConfig>::get()->visitStrings("api-subsonic-default-cover-clients",
[&](std::string_view client)
{
res.emplace(std::string{ client });
@@ -135,11 +133,11 @@ namespace API::Subsonic
return res;
}
void checkUserTypeIsAllowed(RequestContext& context, EnumSet<Database::UserType> allowedUserTypes)
void checkUserTypeIsAllowed(RequestContext& context, core::EnumSet<db::UserType> allowedUserTypes)
{
auto transaction{ context.dbSession.createReadTransaction() };
User::pointer currentUser{ User::find(context.dbSession, context.userId) };
db::User::pointer currentUser{ db::User::find(context.dbSession, context.userId) };
if (!currentUser)
throw RequestedDataNotFoundError{};
@@ -157,11 +155,11 @@ namespace API::Subsonic
struct RequestEntryPointInfo
{
RequestHandlerFunc func;
EnumSet<UserType> allowedUserTypes{ UserType::DEMO, UserType::REGULAR, UserType::ADMIN };
core::EnumSet<db::UserType> allowedUserTypes{ db::UserType::DEMO, db::UserType::REGULAR, db::UserType::ADMIN };
CheckImplementedFunc checkFunc{};
};
static const std::unordered_map<LiteralString, RequestEntryPointInfo, LiteralStringHash, LiteralStringEqual> requestEntryPoints
static const std::unordered_map<core::LiteralString, RequestEntryPointInfo, core::LiteralStringHash, core::LiteralStringEqual> requestEntryPoints
{
// System
{"/ping", {handlePingRequest}},
@@ -249,11 +247,11 @@ namespace API::Subsonic
// User management
{"/getUser", {handleGetUserRequest}},
{"/getUsers", {handleGetUsersRequest, {UserType::ADMIN}}},
{"/createUser", {handleCreateUserRequest, {UserType::ADMIN}, &Utils::checkSetPasswordImplemented}},
{"/updateUser", {handleUpdateUserRequest, {UserType::ADMIN}}},
{"/deleteUser", {handleDeleteUserRequest, {UserType::ADMIN}}},
{"/changePassword", {handleChangePassword, {UserType::REGULAR, UserType::ADMIN}, &Utils::checkSetPasswordImplemented}},
{"/getUsers", {handleGetUsersRequest, {db::UserType::ADMIN}}},
{"/createUser", {handleCreateUserRequest, {db::UserType::ADMIN}, &utils::checkSetPasswordImplemented}},
{"/updateUser", {handleUpdateUserRequest, {db::UserType::ADMIN}}},
{"/deleteUser", {handleDeleteUserRequest, {db::UserType::ADMIN}}},
{"/changePassword", {handleChangePassword, {db::UserType::REGULAR, db::UserType::ADMIN}, &utils::checkSetPasswordImplemented}},
// Bookmarks
{"/getBookmarks", {handleGetBookmarks}},
@@ -263,12 +261,12 @@ namespace API::Subsonic
{"/savePlayQueue", {handleNotImplemented}},
// Media library scanning
{"/getScanStatus", {Scan::handleGetScanStatus, {UserType::ADMIN}}},
{"/startScan", {Scan::handleStartScan, {UserType::ADMIN}}},
{"/getScanStatus", {Scan::handleGetScanStatus, {db::UserType::ADMIN}}},
{"/startScan", {Scan::handleStartScan, {db::UserType::ADMIN}}},
};
using MediaRetrievalHandlerFunc = std::function<void(RequestContext&, const Wt::Http::Request&, Wt::Http::Response&)>;
static std::unordered_map<LiteralString, MediaRetrievalHandlerFunc, LiteralStringHash, LiteralStringEqual> mediaRetrievalHandlers
static std::unordered_map<core::LiteralString, MediaRetrievalHandlerFunc, core::LiteralStringHash, core::LiteralStringEqual> mediaRetrievalHandlers
{
// Media retrieval
{"/download", handleDownload},
@@ -277,7 +275,7 @@ namespace API::Subsonic
};
}
SubsonicResource::SubsonicResource(Db& db)
SubsonicResource::SubsonicResource(db::Db& db)
: _serverProtocolVersionsByClient{ readConfigProtocolVersions() }
, _openSubsonicDisabledClients{ readOpenSubsonicDisabledClients() }
, _defaultCoverClients{ readDefaultCoverClients() }
@@ -294,7 +292,7 @@ namespace API::Subsonic
LMS_LOG(API_SUBSONIC, DEBUG, "Handling request " << requestId << " '" << request.pathInfo() << "', continuation = " << (request.continuation() ? "true" : "false") << ", params = " << parameterMapToDebugString(request.getParameterMap()));
std::string requestPath{ request.pathInfo() };
if (StringUtils::stringEndsWith(requestPath, ".view"))
if (core::stringUtils::stringEndsWith(requestPath, ".view"))
requestPath.resize(requestPath.length() - 5);
// Optional parameters
@@ -402,48 +400,48 @@ namespace API::Subsonic
{
const Wt::Http::ParameterMap& parameters{ request.getParameterMap() };
const ClientInfo clientInfo{ getClientInfo(parameters) };
const Database::UserId userId{ authenticateUser(request, clientInfo) };
const db::UserId userId{ authenticateUser(request, clientInfo) };
bool enableOpenSubsonic{ _openSubsonicDisabledClients.find(clientInfo.name) == std::cend(_openSubsonicDisabledClients) };
bool enableDefaultCover{ _defaultCoverClients.find(clientInfo.name) != std::cend(_openSubsonicDisabledClients) };
return { parameters, _db.getTLSSession(), userId, clientInfo, getServerProtocolVersion(clientInfo.name), enableOpenSubsonic, enableDefaultCover };
}
Database::UserId SubsonicResource::authenticateUser(const Wt::Http::Request& request, const ClientInfo& clientInfo)
db::UserId SubsonicResource::authenticateUser(const Wt::Http::Request& request, const ClientInfo& clientInfo)
{
// if the request if a continuation, the user is already authenticated
if (request.continuation())
{
Database::Session& session{ _db.getTLSSession() };
db::Session& session{ _db.getTLSSession() };
auto transaction{ session.createReadTransaction() };
const auto user{ Database::User::find(session, clientInfo.user) };
const auto user{ db::User::find(session, clientInfo.user) };
if (!user)
throw UserNotAuthorizedError{};
return user->getId();
}
if (auto * authEnvService{ Service<::Auth::IEnvService>::get() })
if (auto * authEnvService{ core::Service<auth::IEnvService>::get() })
{
const auto checkResult{ authEnvService->processRequest(request) };
if (checkResult.state != ::Auth::IEnvService::CheckResult::State::Granted)
if (checkResult.state != auth::IEnvService::CheckResult::State::Granted)
throw UserNotAuthorizedError{};
return *checkResult.userId;
}
else if (auto * authPasswordService{ Service<::Auth::IPasswordService>::get() })
else if (auto * authPasswordService{ core::Service<auth::IPasswordService>::get() })
{
const auto checkResult{ authPasswordService->checkUserPassword(boost::asio::ip::address::from_string(request.clientAddress()), clientInfo.user, clientInfo.password) };
switch (checkResult.state)
{
case Auth::IPasswordService::CheckResult::State::Granted:
case auth::IPasswordService::CheckResult::State::Granted:
return *checkResult.userId;
break;
case Auth::IPasswordService::CheckResult::State::Denied:
case auth::IPasswordService::CheckResult::State::Denied:
throw WrongUsernameOrPasswordError{};
case Auth::IPasswordService::CheckResult::State::Throttled:
case auth::IPasswordService::CheckResult::State::Throttled:
throw LoginThrottledGenericError{};
}
}
@@ -451,5 +449,5 @@ namespace API::Subsonic
throw InternalErrorGenericError{ "No service available to authenticate user" };
}
} // namespace api::subsonic
} // namespace lms::api::subsonic
+5 -5
View File
@@ -29,18 +29,18 @@
#include "ClientInfo.hpp"
#include "RequestContext.hpp"
namespace Database
namespace lms::db
{
class Db;
}
namespace API::Subsonic
namespace lms::api::subsonic
{
class SubsonicResource final : public Wt::WResource
{
public:
SubsonicResource(Database::Db& db);
SubsonicResource(db::Db& db);
private:
void handleRequest(const Wt::Http::Request &request, Wt::Http::Response &response) override;
@@ -49,13 +49,13 @@ namespace API::Subsonic
static void checkProtocolVersion(ProtocolVersion client, ProtocolVersion server);
ClientInfo getClientInfo(const Wt::Http::ParameterMap& parameters);
RequestContext buildRequestContext(const Wt::Http::Request& request);
Database::UserId authenticateUser(const Wt::Http::Request& request, const ClientInfo& clientInfo);
db::UserId authenticateUser(const Wt::Http::Request& request, const ClientInfo& clientInfo);
const std::unordered_map<std::string, ProtocolVersion> _serverProtocolVersionsByClient;
const std::unordered_set<std::string> _openSubsonicDisabledClients;
const std::unordered_set<std::string> _defaultCoverClients;
Database::Db& _db;
db::Db& _db;
};
} // namespace
+4 -4
View File
@@ -24,11 +24,11 @@
#include <climits>
#include <boost/property_tree/xml_parser.hpp>
#include "utils/Exception.hpp"
#include "utils/String.hpp"
#include "core/Exception.hpp"
#include "core/String.hpp"
#include "ProtocolVersion.hpp"
namespace API::Subsonic
namespace lms::api::subsonic
{
std::string_view ResponseFormatToMimeType(ResponseFormat format)
{
@@ -366,7 +366,7 @@ namespace API::Subsonic
void Response::JsonSerializer::serializeEscapedString(std::ostream& os, std::string_view str)
{
os << '\"';
StringUtils::writeJsonEscapedString(os, str);
core::stringUtils::writeJsonEscapedString(os, str);
os << '\"';
}
+3 -3
View File
@@ -25,10 +25,10 @@
#include <variant>
#include <vector>
#include "utils/LiteralString.hpp"
#include "core/LiteralString.hpp"
#include "RequestContext.hpp"
namespace API::Subsonic
namespace lms::api::subsonic
{
// Max count expected from all API methods that expose a count
static inline constexpr std::size_t defaultMaxCountSize{ 1000 };
@@ -206,7 +206,7 @@ namespace API::Subsonic
class Node
{
public:
using Key = LiteralString;
using Key = core::LiteralString;
void setAttribute(Key key, std::string_view value);
+5 -5
View File
@@ -19,23 +19,23 @@
#include "Utils.hpp"
#include "utils/Service.hpp"
#include "utils/String.hpp"
#include "core/Service.hpp"
#include "core/String.hpp"
#include "services/auth/IPasswordService.hpp"
#include "SubsonicResponse.hpp"
namespace API::Subsonic::Utils
namespace lms::api::subsonic::utils
{
void checkSetPasswordImplemented()
{
Auth::IPasswordService* passwordService{ Service<Auth::IPasswordService>::get() };
auth::IPasswordService* passwordService{ core::Service<auth::IPasswordService>::get() };
if (!passwordService || !passwordService->canSetPasswords())
throw NotImplementedGenericError{};
}
std::string makeNameFilesystemCompatible(std::string_view name)
{
return StringUtils::replaceInString(name, "/", "_");
return core::stringUtils::replaceInString(name, "/", "_");
}
}
+1 -1
View File
@@ -22,7 +22,7 @@
#include <string>
#include <string_view>
namespace API::Subsonic::Utils
namespace lms::api::subsonic::utils
{
void checkSetPasswordImplemented();
std::string makeNameFilesystemCompatible(std::string_view name);
@@ -30,13 +30,13 @@
#include "responses/Album.hpp"
#include "responses/Artist.hpp"
#include "responses/Song.hpp"
#include "utils/Service.hpp"
#include "core/Service.hpp"
#include "ParameterParsing.hpp"
#include "SubsonicId.hpp"
namespace API::Subsonic
namespace lms::api::subsonic
{
using namespace Database;
using namespace db;
namespace
{
@@ -55,8 +55,8 @@ namespace API::Subsonic
const Range range{ offset, size };
RangeResults<ReleaseId> releases;
Scrobbling::IScrobblingService& scrobblingService{ *Service<Scrobbling::IScrobblingService>::get() };
Feedback::IFeedbackService& feedbackService{ *Service<Feedback::IFeedbackService>::get() };
scrobbling::IScrobblingService& scrobblingService{ *core::Service<scrobbling::IScrobblingService>::get() };
feedback::IFeedbackService& feedbackService{ *core::Service<feedback::IFeedbackService>::get() };
auto transaction{ context.dbSession.createReadTransaction() };
@@ -116,7 +116,7 @@ namespace API::Subsonic
}
else if (type == "frequent")
{
Scrobbling::IScrobblingService::FindParameters params;
scrobbling::IScrobblingService::FindParameters params;
params.setUser(context.userId);
params.setRange(range);
params.setMediaLibrary(mediaLibraryId);
@@ -145,7 +145,7 @@ namespace API::Subsonic
}
else if (type == "recent")
{
Scrobbling::IScrobblingService::FindParameters params;
scrobbling::IScrobblingService::FindParameters params;
params.setUser(context.userId);
params.setRange(range);
params.setMediaLibrary(mediaLibraryId);
@@ -154,7 +154,7 @@ namespace API::Subsonic
}
else if (type == "starred")
{
Feedback::IFeedbackService::FindParameters params;
feedback::IFeedbackService::FindParameters params;
params.setUser(context.userId);
params.setRange(range);
params.setMediaLibrary(mediaLibraryId);
@@ -192,10 +192,10 @@ namespace API::Subsonic
Response response{ Response::createOkResponse(context.serverProtocolVersion) };
Response::Node& starredNode{ response.createNode(id3 ? Response::Node::Key{ "starred2" } : Response::Node::Key{ "starred" }) };
Feedback::IFeedbackService& feedbackService{ *Service<Feedback::IFeedbackService>::get() };
feedback::IFeedbackService& feedbackService{ *core::Service<feedback::IFeedbackService>::get() };
{
Feedback::IFeedbackService::ArtistFindParameters artistFindParams;
feedback::IFeedbackService::ArtistFindParameters artistFindParams;
artistFindParams.setUser(context.userId);
artistFindParams.setSortMethod(ArtistSortMethod::BySortName);
for (const ArtistId artistId : feedbackService.findStarredArtists(artistFindParams).results)
@@ -205,7 +205,7 @@ namespace API::Subsonic
}
}
Feedback::IFeedbackService::FindParameters findParameters;
feedback::IFeedbackService::FindParameters findParameters;
findParameters.setUser(context.userId);
findParameters.setMediaLibrary(mediaLibrary);
@@ -22,7 +22,7 @@
#include "RequestContext.hpp"
#include "SubsonicResponse.hpp"
namespace API::Subsonic
namespace lms::api::subsonic
{
Response handleGetAlbumListRequest(RequestContext& context);
Response handleGetAlbumList2Request(RequestContext& context);
@@ -28,9 +28,9 @@
#include "ParameterParsing.hpp"
#include "SubsonicId.hpp"
namespace API::Subsonic
namespace lms::api::subsonic
{
using namespace Database;
using namespace db;
Response handleGetBookmarks(RequestContext& context)
{
@@ -22,7 +22,7 @@
#include "RequestContext.hpp"
#include "SubsonicResponse.hpp"
namespace API::Subsonic
namespace lms::api::subsonic
{
Response handleGetBookmarks(RequestContext& context);
Response handleCreateBookmark(RequestContext& context);
+16 -16
View File
@@ -28,9 +28,9 @@
#include "database/User.hpp"
#include "services/recommendation/IRecommendationService.hpp"
#include "services/scrobbling/IScrobblingService.hpp"
#include "utils/ILogger.hpp"
#include "utils/Random.hpp"
#include "utils/Service.hpp"
#include "core/ILogger.hpp"
#include "core/Random.hpp"
#include "core/Service.hpp"
#include "responses/Album.hpp"
#include "responses/Artist.hpp"
#include "responses/Genre.hpp"
@@ -39,9 +39,9 @@
#include "SubsonicId.hpp"
#include "Utils.hpp"
namespace API::Subsonic
namespace lms::api::subsonic
{
using namespace Database;
using namespace db;
static const std::string_view reportedDummyDate{ "2000-01-01T00:00:00" };
static const unsigned long long reportedDummyDateULong{ 946684800000ULL }; // 2000-01-01T00:00:00 UTC
@@ -66,12 +66,12 @@ namespace API::Subsonic
if (!artist)
throw RequestedDataNotFoundError{};
std::optional<UUID> artistMBID{ artist->getMBID() };
std::optional<core::UUID> artistMBID{ artist->getMBID() };
if (artistMBID)
artistInfoNode.createChild("musicBrainzId").setValue(artistMBID->getAsString());
}
auto similarArtistsId{ Service<Recommendation::IRecommendationService>::get()->getSimilarArtists(id, {TrackArtistLinkType::Artist, TrackArtistLinkType::ReleaseArtist}, count) };
auto similarArtistsId{ core::Service<recommendation::IRecommendationService>::get()->getSimilarArtists(id, {TrackArtistLinkType::Artist, TrackArtistLinkType::ReleaseArtist}, count) };
{
auto transaction{ context.dbSession.createReadTransaction() };
@@ -182,7 +182,7 @@ namespace API::Subsonic
{
// API says: "Returns a random collection of songs from the given artist and similar artists"
const std::size_t similarArtistCount{ count / 5 };
std::vector<ArtistId> artistIds{ Service<Recommendation::IRecommendationService>::get()->getSimilarArtists(artistId, {TrackArtistLinkType::Artist, TrackArtistLinkType::ReleaseArtist}, similarArtistCount) };
std::vector<ArtistId> artistIds{ core::Service<recommendation::IRecommendationService>::get()->getSimilarArtists(artistId, {TrackArtistLinkType::Artist, TrackArtistLinkType::ReleaseArtist}, similarArtistCount) };
artistIds.push_back(artistId);
const std::size_t meanTrackCountPerArtist{ (count / artistIds.size()) + 1 };
@@ -213,7 +213,7 @@ namespace API::Subsonic
// API says: "Returns a random collection of songs from the given artist and similar artists"
// so let's extend this for release
const std::size_t similarReleaseCount{ count / 5 };
std::vector<ReleaseId> releaseIds{ Service<Recommendation::IRecommendationService>::get()->getSimilarReleases(releaseId, similarReleaseCount) };
std::vector<ReleaseId> releaseIds{ core::Service<recommendation::IRecommendationService>::get()->getSimilarReleases(releaseId, similarReleaseCount) };
releaseIds.push_back(releaseId);
const std::size_t meanTrackCountPerRelease{ (count / releaseIds.size()) + 1 };
@@ -241,7 +241,7 @@ namespace API::Subsonic
std::vector<TrackId> findSimilarSongs(RequestContext&, TrackId trackId, std::size_t count)
{
return Service<Recommendation::IRecommendationService>::get()->findSimilarTracks({ trackId }, count);
return core::Service<recommendation::IRecommendationService>::get()->findSimilarTracks({ trackId }, count);
}
Response handleGetSimilarSongsRequestCommon(RequestContext& context, bool id3)
@@ -262,7 +262,7 @@ namespace API::Subsonic
else
throw BadParameterGenericError{ "id" };
Random::shuffleContainer(tracks);
core::random::shuffleContainer(tracks);
auto transaction{ context.dbSession.createReadTransaction() };
@@ -343,7 +343,7 @@ namespace API::Subsonic
if (!artist)
throw RequestedDataNotFoundError{};
directoryNode.setAttribute("name", Utils::makeNameFilesystemCompatible(artist->getName()));
directoryNode.setAttribute("name", utils::makeNameFilesystemCompatible(artist->getName()));
Release::find(context.dbSession, Release::FindParameters{}.setArtist(*artistId), [&](const Release::pointer& release)
{
@@ -358,7 +358,7 @@ namespace API::Subsonic
if (!release)
throw RequestedDataNotFoundError{};
directoryNode.setAttribute("name", Utils::makeNameFilesystemCompatible(release->getName()));
directoryNode.setAttribute("name", utils::makeNameFilesystemCompatible(release->getName()));
Track::find(context.dbSession, Track::FindParameters{}.setRelease(*releaseId).setSortMethod(TrackSortMethod::Release), [&](const Track::pointer& track)
{
@@ -512,12 +512,12 @@ namespace API::Subsonic
Response response{ Response::createOkResponse(context.serverProtocolVersion) };
Response::Node& topSongs{ response.createNode("topSongs") };
Scrobbling::IScrobblingService::FindParameters params;
scrobbling::IScrobblingService::FindParameters params;
params.setUser(context.userId);
params.setRange(Database::Range{ 0, count });
params.setRange(db::Range{ 0, count });
params.setArtist(artists.front()->getId());
const auto trackIds{ Service<Scrobbling::IScrobblingService>::get()->getTopTracks(params) };
const auto trackIds{ core::Service<scrobbling::IScrobblingService>::get()->getTopTracks(params) };
for (const TrackId trackId : trackIds.results)
{
if (Track::pointer track{ Track::find(context.dbSession, trackId) })
@@ -22,7 +22,7 @@
#include "RequestContext.hpp"
#include "SubsonicResponse.hpp"
namespace API::Subsonic
namespace lms::api::subsonic
{
Response handleGetMusicFoldersRequest(RequestContext& context);
Response handleGetIndexesRequest(RequestContext& context);
@@ -26,13 +26,13 @@
#include "database/TrackId.hpp"
#include "services/feedback/IFeedbackService.hpp"
#include "services/scrobbling/IScrobblingService.hpp"
#include "utils/Service.hpp"
#include "core/Service.hpp"
#include "ParameterParsing.hpp"
#include "SubsonicId.hpp"
namespace API::Subsonic
namespace lms::api::subsonic
{
using namespace Database;
using namespace db;
namespace
{
@@ -61,13 +61,13 @@ namespace API::Subsonic
StarParameters params{ getStarParameters(context.parameters) };
for (const ArtistId id : params.artistIds)
Service<Feedback::IFeedbackService>::get()->star(context.userId, id);
core::Service<feedback::IFeedbackService>::get()->star(context.userId, id);
for (const ReleaseId id : params.releaseIds)
Service<Feedback::IFeedbackService>::get()->star(context.userId, id);
core::Service<feedback::IFeedbackService>::get()->star(context.userId, id);
for (const TrackId id : params.trackIds)
Service<Feedback::IFeedbackService>::get()->star(context.userId, id);
core::Service<feedback::IFeedbackService>::get()->star(context.userId, id);
return Response::createOkResponse(context.serverProtocolVersion);
}
@@ -77,13 +77,13 @@ namespace API::Subsonic
StarParameters params{ getStarParameters(context.parameters) };
for (const ArtistId id : params.artistIds)
Service<Feedback::IFeedbackService>::get()->unstar(context.userId, id);
core::Service<feedback::IFeedbackService>::get()->unstar(context.userId, id);
for (const ReleaseId id : params.releaseIds)
Service<Feedback::IFeedbackService>::get()->unstar(context.userId, id);
core::Service<feedback::IFeedbackService>::get()->unstar(context.userId, id);
for (const TrackId id : params.trackIds)
Service<Feedback::IFeedbackService>::get()->unstar(context.userId, id);
core::Service<feedback::IFeedbackService>::get()->unstar(context.userId, id);
return Response::createOkResponse(context.serverProtocolVersion);
}
@@ -108,13 +108,13 @@ namespace API::Subsonic
if (!submission)
{
Service<Scrobbling::IScrobblingService>::get()->listenStarted({ context.userId, ids.front() });
core::Service<scrobbling::IScrobblingService>::get()->listenStarted({ context.userId, ids.front() });
}
else
{
if (times.empty())
{
Service<Scrobbling::IScrobblingService>::get()->listenFinished({ context.userId, ids.front() });
core::Service<scrobbling::IScrobblingService>::get()->listenFinished({ context.userId, ids.front() });
}
else
{
@@ -122,7 +122,7 @@ namespace API::Subsonic
{
const TrackId trackId{ ids[i] };
const unsigned long time{ times[i] };
Service<Scrobbling::IScrobblingService>::get()->addTimedListen({ {context.userId, trackId}, Wt::WDateTime::fromTime_t(static_cast<std::time_t>(time / 1000)) });
core::Service<scrobbling::IScrobblingService>::get()->addTimedListen({ {context.userId, trackId}, Wt::WDateTime::fromTime_t(static_cast<std::time_t>(time / 1000)) });
}
}
}
@@ -22,7 +22,7 @@
#include "RequestContext.hpp"
#include "SubsonicResponse.hpp"
namespace API::Subsonic
namespace lms::api::subsonic
{
Response handleStarRequest(RequestContext& context);
Response handleUnstarRequest(RequestContext& context);
@@ -20,11 +20,11 @@
#include "MediaLibraryScanning.hpp"
#include "services/scanner/IScannerService.hpp"
#include "utils/Service.hpp"
#include "core/Service.hpp"
namespace API::Subsonic::Scan
namespace lms::api::subsonic::Scan
{
using namespace Scanner;
using namespace scanner;
namespace
{
@@ -32,7 +32,7 @@ namespace API::Subsonic::Scan
{
Response::Node statusResponse;
const IScannerService::Status scanStatus{ Service<IScannerService>::get()->getStatus() };
const IScannerService::Status scanStatus{ core::Service<IScannerService>::get()->getStatus() };
statusResponse.setAttribute("scanning", scanStatus.currentState == IScannerService::State::InProgress);
if (scanStatus.currentState == IScannerService::State::InProgress)
@@ -59,7 +59,7 @@ namespace API::Subsonic::Scan
Response handleStartScan(RequestContext& context)
{
Service<IScannerService>::get()->requestImmediateScan(false);
core::Service<IScannerService>::get()->requestImmediateScan(false);
Response response{ Response::createOkResponse(context.serverProtocolVersion) };
response.addNode("scanStatus", createStatusResponseNode());
@@ -22,7 +22,7 @@
#include "RequestContext.hpp"
#include "SubsonicResponse.hpp"
namespace API::Subsonic::Scan
namespace lms::api::subsonic::Scan
{
Response handleGetScanStatus(RequestContext& context);
Response handleStartScan(RequestContext& context);
@@ -28,61 +28,61 @@
#include "database/Session.hpp"
#include "database/Track.hpp"
#include "database/User.hpp"
#include "utils/IResourceHandler.hpp"
#include "utils/ILogger.hpp"
#include "utils/FileResourceHandlerCreator.hpp"
#include "utils/Utils.hpp"
#include "utils/String.hpp"
#include "core/IResourceHandler.hpp"
#include "core/ILogger.hpp"
#include "core/FileResourceHandlerCreator.hpp"
#include "core/Utils.hpp"
#include "core/String.hpp"
#include "ParameterParsing.hpp"
#include "SubsonicId.hpp"
namespace API::Subsonic
namespace lms::api::subsonic
{
using namespace Database;
using namespace db;
namespace
{
std::optional<Av::Transcoding::OutputFormat> subsonicStreamFormatToAvOutputFormat(std::string_view format)
std::optional<av::transcoding::OutputFormat> subsonicStreamFormatToAvOutputFormat(std::string_view format)
{
for (const auto& [str, avFormat] : std::initializer_list<std::pair<std::string_view, Av::Transcoding::OutputFormat>>{
{"mp3", Av::Transcoding::OutputFormat::MP3},
{"opus", Av::Transcoding::OutputFormat::OGG_OPUS},
{"vorbis", Av::Transcoding::OutputFormat::OGG_VORBIS},
for (const auto& [str, avFormat] : std::initializer_list<std::pair<std::string_view, av::transcoding::OutputFormat>>{
{"mp3", av::transcoding::OutputFormat::MP3},
{"opus", av::transcoding::OutputFormat::OGG_OPUS},
{"vorbis", av::transcoding::OutputFormat::OGG_VORBIS},
})
{
if (StringUtils::stringCaseInsensitiveEqual(str, format))
if (core::stringUtils::stringCaseInsensitiveEqual(str, format))
return avFormat;
}
return std::nullopt;
}
Av::Transcoding::OutputFormat userTranscodeFormatToAvFormat(Database::TranscodingOutputFormat format)
av::transcoding::OutputFormat userTranscodeFormatToAvFormat(db::TranscodingOutputFormat format)
{
switch (format)
{
case Database::TranscodingOutputFormat::MP3: return Av::Transcoding::OutputFormat::MP3;
case Database::TranscodingOutputFormat::OGG_OPUS: return Av::Transcoding::OutputFormat::OGG_OPUS;
case Database::TranscodingOutputFormat::MATROSKA_OPUS: return Av::Transcoding::OutputFormat::MATROSKA_OPUS;
case Database::TranscodingOutputFormat::OGG_VORBIS: return Av::Transcoding::OutputFormat::OGG_VORBIS;
case Database::TranscodingOutputFormat::WEBM_VORBIS: return Av::Transcoding::OutputFormat::WEBM_VORBIS;
case db::TranscodingOutputFormat::MP3: return av::transcoding::OutputFormat::MP3;
case db::TranscodingOutputFormat::OGG_OPUS: return av::transcoding::OutputFormat::OGG_OPUS;
case db::TranscodingOutputFormat::MATROSKA_OPUS: return av::transcoding::OutputFormat::MATROSKA_OPUS;
case db::TranscodingOutputFormat::OGG_VORBIS: return av::transcoding::OutputFormat::OGG_VORBIS;
case db::TranscodingOutputFormat::WEBM_VORBIS: return av::transcoding::OutputFormat::WEBM_VORBIS;
}
return Av::Transcoding::OutputFormat::OGG_OPUS;
return av::transcoding::OutputFormat::OGG_OPUS;
}
bool isCodecCompatibleWithOutputFormat(Av::DecodingCodec codec, Av::Transcoding::OutputFormat outputFormat)
bool isCodecCompatibleWithOutputFormat(av::DecodingCodec codec, av::transcoding::OutputFormat outputFormat)
{
switch (outputFormat)
{
case Av::Transcoding::OutputFormat::MP3:
return codec == Av::DecodingCodec::MP3;
case av::transcoding::OutputFormat::MP3:
return codec == av::DecodingCodec::MP3;
case Av::Transcoding::OutputFormat::OGG_OPUS:
case Av::Transcoding::OutputFormat::MATROSKA_OPUS:
return codec == Av::DecodingCodec::OPUS;
case av::transcoding::OutputFormat::OGG_OPUS:
case av::transcoding::OutputFormat::MATROSKA_OPUS:
return codec == av::DecodingCodec::OPUS;
case Av::Transcoding::OutputFormat::OGG_VORBIS:
case Av::Transcoding::OutputFormat::WEBM_VORBIS:
return codec == Av::DecodingCodec::VORBIS;
case av::transcoding::OutputFormat::OGG_VORBIS:
case av::transcoding::OutputFormat::WEBM_VORBIS:
return codec == av::DecodingCodec::VORBIS;
}
return true;
@@ -90,16 +90,16 @@ namespace API::Subsonic
struct StreamParameters
{
Av::Transcoding::InputParameters inputParameters;
std::optional<Av::Transcoding::OutputParameters> outputParameters;
av::transcoding::InputParameters inputParameters;
std::optional<av::transcoding::OutputParameters> outputParameters;
bool estimateContentLength{};
};
bool isOutputFormatCompatible(const std::filesystem::path& trackPath, Av::Transcoding::OutputFormat outputFormat)
bool isOutputFormatCompatible(const std::filesystem::path& trackPath, av::transcoding::OutputFormat outputFormat)
{
try
{
const auto audioFile{ Av::parseAudioFile(trackPath) };
const auto audioFile{ av::parseAudioFile(trackPath) };
const auto streamInfo{ audioFile->getBestStreamInfo() };
if (!streamInfo)
@@ -107,7 +107,7 @@ namespace API::Subsonic
return isCodecCompatibleWithOutputFormat(streamInfo->codec, outputFormat);
}
catch (const Av::Exception& e)
catch (const av::Exception& e)
{
// TODO 404?
throw RequestedDataNotFoundError{};
@@ -144,7 +144,7 @@ namespace API::Subsonic
if (format == "raw") // raw => no transcoding
return parameters;
std::optional<Av::Transcoding::OutputFormat> requestedFormat{ subsonicStreamFormatToAvOutputFormat(format) };
std::optional<av::transcoding::OutputFormat> requestedFormat{ subsonicStreamFormatToAvOutputFormat(format) };
if (!requestedFormat)
{
if (user->getSubsonicEnableTranscodingByDefault())
@@ -176,7 +176,7 @@ namespace API::Subsonic
if (!bitrate)
bitrate = std::min<std::size_t>(user->getSubsonicDefaultTranscodingOutputBitrate(), maxBitRate);
Av::Transcoding::OutputParameters& outputParameters{ parameters.outputParameters.emplace() };
av::transcoding::OutputParameters& outputParameters{ parameters.outputParameters.emplace() };
outputParameters.stripMetadata = false; // We want clients to use metadata (offline use, replay gain, etc.)
outputParameters.offset = std::chrono::seconds{ timeOffset };
@@ -195,7 +195,7 @@ namespace API::Subsonic
if (!continuation)
{
// Mandatory params
Database::TrackId id{ getMandatoryParameterAs<Database::TrackId>(context.parameters, "id") };
db::TrackId id{ getMandatoryParameterAs<db::TrackId>(context.parameters, "id") };
std::filesystem::path trackPath;
{
@@ -208,7 +208,7 @@ namespace API::Subsonic
trackPath = track->getPath();
}
resourceHandler = Av::createRawResourceHandler(trackPath);
resourceHandler = av::createRawResourceHandler(trackPath);
}
else
{
@@ -231,9 +231,9 @@ namespace API::Subsonic
{
StreamParameters streamParameters{ getStreamParameters(context) };
if (streamParameters.outputParameters)
resourceHandler = Av::Transcoding::createResourceHandler(streamParameters.inputParameters, *streamParameters.outputParameters, streamParameters.estimateContentLength);
resourceHandler = av::transcoding::createResourceHandler(streamParameters.inputParameters, *streamParameters.outputParameters, streamParameters.estimateContentLength);
else
resourceHandler = Av::createRawResourceHandler(streamParameters.inputParameters.trackPath);
resourceHandler = av::createRawResourceHandler(streamParameters.inputParameters.trackPath);
}
else
{
@@ -244,7 +244,7 @@ namespace API::Subsonic
if (continuation)
continuation->setData(resourceHandler);
}
catch (const Av::Exception& e)
catch (const av::Exception& e)
{
LMS_LOG(API_SUBSONIC, ERROR, "Caught Av exception: " << e.what());
}
@@ -261,18 +261,18 @@ namespace API::Subsonic
throw BadParameterGenericError{ "id" };
std::size_t size{ getParameterAs<std::size_t>(context.parameters, "size").value_or(1024) };
size = ::Utils::clamp(size, std::size_t{ 32 }, std::size_t{ 2048 });
size = core::utils::clamp(size, std::size_t{ 32 }, std::size_t{ 2048 });
std::shared_ptr<Image::IEncodedImage> cover;
std::shared_ptr<image::IEncodedImage> cover;
if (trackId)
cover = Service<Cover::ICoverService>::get()->getFromTrack(*trackId, size);
cover = core::Service<cover::ICoverService>::get()->getFromTrack(*trackId, size);
else if (releaseId)
cover = Service<Cover::ICoverService>::get()->getFromRelease(*releaseId, size);
cover = core::Service<cover::ICoverService>::get()->getFromRelease(*releaseId, size);
else if (artistId)
cover = Service<Cover::ICoverService>::get()->getFromArtist(*artistId, size);
cover = core::Service<cover::ICoverService>::get()->getFromArtist(*artistId, size);
if (!cover && context.enableDefaultCover && !artistId)
cover = Service<Cover::ICoverService>::get()->getDefault(size);
cover = core::Service<cover::ICoverService>::get()->getDefault(size);
if (!cover)
{
@@ -284,4 +284,4 @@ namespace API::Subsonic
response.setMimeType(std::string{ cover->getMimeType() });
}
} // namespace API::Subsonic
} // namespace lms::api::subsonic
@@ -24,7 +24,7 @@
#include "RequestContext.hpp"
namespace API::Subsonic
namespace lms::api::subsonic
{
void handleDownload(RequestContext& context, const Wt::Http::Request& request, Wt::Http::Response& response);
void handleStream(RequestContext& context, const Wt::Http::Request& request, Wt::Http::Response& response);
@@ -28,9 +28,9 @@
#include "ParameterParsing.hpp"
#include "SubsonicId.hpp"
namespace API::Subsonic
namespace lms::api::subsonic
{
using namespace Database;
using namespace db;
Response handleGetPlaylistsRequest(RequestContext& context)
{
@@ -22,7 +22,7 @@
#include "RequestContext.hpp"
#include "SubsonicResponse.hpp"
namespace API::Subsonic
namespace lms::api::subsonic
{
Response handleGetPlaylistsRequest(RequestContext& context);
Response handleGetPlaylistRequest(RequestContext& context);
@@ -30,9 +30,9 @@
#include "ParameterParsing.hpp"
#include "SubsonicId.hpp"
namespace API::Subsonic
namespace lms::api::subsonic
{
using namespace Database;
using namespace db;
namespace
{
@@ -47,9 +47,9 @@ namespace API::Subsonic
// Symfonium adds extra ""
if (context.clientInfo.name == "Symfonium")
query = StringUtils::stringTrim(query, "\"");
query = core::stringUtils::stringTrim(query, "\"");
std::vector<std::string_view> keywords{ StringUtils::splitString(query, ' ') };
std::vector<std::string_view> keywords{ core::stringUtils::splitString(query, ' ') };
// Optional params
std::size_t artistCount{ getParameterAs<std::size_t>(context.parameters, "artistCount").value_or(20) };
@@ -22,7 +22,7 @@
#include "RequestContext.hpp"
#include "SubsonicResponse.hpp"
namespace API::Subsonic
namespace lms::api::subsonic
{
Response handleSearch2Request(RequestContext& context);
Response handleSearch3Request(RequestContext& context);
@@ -1,6 +1,6 @@
#include "entrypoints/System.hpp"
namespace API::Subsonic
namespace lms::api::subsonic
{
Response handlePingRequest(RequestContext& context)
{
@@ -22,7 +22,7 @@
#include "RequestContext.hpp"
#include "SubsonicResponse.hpp"
namespace API::Subsonic
namespace lms::api::subsonic
{
Response handlePingRequest(RequestContext& context);
Response handleGetLicenseRequest(RequestContext& context);
@@ -3,14 +3,14 @@
#include "database/Session.hpp"
#include "database/User.hpp"
#include "services/auth/IPasswordService.hpp"
#include "utils/Service.hpp"
#include "core/Service.hpp"
#include "responses/User.hpp"
#include "ParameterParsing.hpp"
#include "Utils.hpp"
namespace API::Subsonic
namespace lms::api::subsonic
{
using namespace Database;
using namespace db;
namespace {
void checkUserIsMySelfOrAdmin(RequestContext& context, const std::string& username)
@@ -65,7 +65,7 @@ namespace API::Subsonic
std::string password{ decodePasswordIfNeeded(getMandatoryParameterAs<std::string>(context.parameters, "password")) };
// Just ignore all the other fields as we don't handle them
Database::UserId userId;
db::UserId userId;
{
auto transaction{ context.dbSession.createWriteTransaction() };
@@ -87,19 +87,19 @@ namespace API::Subsonic
try
{
Service<Auth::IPasswordService>::get()->setPassword(userId, password);
core::Service<auth::IPasswordService>::get()->setPassword(userId, password);
}
catch (const Auth::PasswordMustMatchLoginNameException&)
catch (const auth::PasswordMustMatchLoginNameException&)
{
removeCreatedUser();
throw PasswordMustMatchLoginNameGenericError{};
}
catch (const Auth::PasswordTooWeakException&)
catch (const auth::PasswordTooWeakException&)
{
removeCreatedUser();
throw PasswordTooWeakGenericError{};
}
catch (const Auth::Exception& exception)
catch (const auth::Exception& exception)
{
removeCreatedUser();
throw UserNotAuthorizedError{};
@@ -145,21 +145,21 @@ namespace API::Subsonic
if (password)
{
Utils::checkSetPasswordImplemented();
utils::checkSetPasswordImplemented();
try
{
Service<::Auth::IPasswordService>()->setPassword(userId, decodePasswordIfNeeded(*password));
core::Service<auth::IPasswordService>()->setPassword(userId, decodePasswordIfNeeded(*password));
}
catch (const Auth::PasswordMustMatchLoginNameException&)
catch (const auth::PasswordMustMatchLoginNameException&)
{
throw PasswordMustMatchLoginNameGenericError{};
}
catch (const Auth::PasswordTooWeakException&)
catch (const auth::PasswordTooWeakException&)
{
throw PasswordTooWeakGenericError{};
}
catch (const Auth::Exception&)
catch (const auth::Exception&)
{
throw UserNotAuthorizedError{};
}
@@ -175,7 +175,7 @@ namespace API::Subsonic
try
{
Database::UserId userId;
db::UserId userId;
{
auto transaction{ context.dbSession.createReadTransaction() };
@@ -188,17 +188,17 @@ namespace API::Subsonic
userId = user->getId();
}
Service<Auth::IPasswordService>::get()->setPassword(userId, password);
core::Service<auth::IPasswordService>::get()->setPassword(userId, password);
}
catch (const Auth::PasswordMustMatchLoginNameException&)
catch (const auth::PasswordMustMatchLoginNameException&)
{
throw PasswordMustMatchLoginNameGenericError{};
}
catch (const Auth::PasswordTooWeakException&)
catch (const auth::PasswordTooWeakException&)
{
throw PasswordTooWeakGenericError{};
}
catch (const Auth::Exception& authException)
catch (const auth::Exception& authException)
{
throw UserNotAuthorizedError{};
}
@@ -22,7 +22,7 @@
#include "RequestContext.hpp"
#include "SubsonicResponse.hpp"
namespace API::Subsonic
namespace lms::api::subsonic
{
Response handleGetUserRequest(RequestContext& context);
Response handleGetUsersRequest(RequestContext& context);
+14 -14
View File
@@ -25,9 +25,9 @@
#include "database/User.hpp"
#include "services/feedback/IFeedbackService.hpp"
#include "services/scrobbling/IScrobblingService.hpp"
#include "utils/ITraceLogger.hpp"
#include "utils/Service.hpp"
#include "utils/String.hpp"
#include "core/ITraceLogger.hpp"
#include "core/Service.hpp"
#include "core/String.hpp"
#include "responses/Artist.hpp"
#include "responses/DiscTitle.hpp"
@@ -35,9 +35,9 @@
#include "responses/ItemGenre.hpp"
#include "SubsonicId.hpp"
namespace API::Subsonic
namespace lms::api::subsonic
{
using namespace Database;
using namespace db;
Response::Node createAlbumNode(RequestContext& context, const Release::pointer& release, const User::pointer& user, bool id3)
{
@@ -59,7 +59,7 @@ namespace API::Subsonic
albumNode.setAttribute("isDir", true);
}
albumNode.setAttribute("created", StringUtils::toISO8601String(release->getLastWritten()));
albumNode.setAttribute("created", core::stringUtils::toISO8601String(release->getLastWritten()));
albumNode.setAttribute("id", idToString(release->getId()));
albumNode.setAttribute("coverArt", idToString(release->getId()));
if (const auto year{ release->getYear() })
@@ -78,7 +78,7 @@ namespace API::Subsonic
if (!release->getArtistDisplayName().empty())
albumNode.setAttribute("artist", release->getArtistDisplayName());
else
albumNode.setAttribute("artist", Utils::joinArtistNames(artists));
albumNode.setAttribute("artist", utils::joinArtistNames(artists));
if (artists.size() == 1)
{
@@ -91,7 +91,7 @@ namespace API::Subsonic
}
}
albumNode.setAttribute("playCount", Service<Scrobbling::IScrobblingService>::get()->getCount(user->getId(), release->getId()));
albumNode.setAttribute("playCount", core::Service<scrobbling::IScrobblingService>::get()->getCount(user->getId(), release->getId()));
// Report the first GENRE for this track
const ClusterType::pointer genreClusterType{ ClusterType::find(context.dbSession, "GENRE") };
@@ -102,8 +102,8 @@ namespace API::Subsonic
albumNode.setAttribute("genre", clusters.front().front()->getName());
}
if (const Wt::WDateTime dateTime{ Service<Feedback::IFeedbackService>::get()->getStarredDateTime(user->getId(), release->getId()) }; dateTime.isValid())
albumNode.setAttribute("starred", StringUtils::toISO8601String(dateTime));
if (const Wt::WDateTime dateTime{ core::Service<feedback::IFeedbackService>::get()->getStarredDateTime(user->getId(), release->getId()) }; dateTime.isValid())
albumNode.setAttribute("starred", core::stringUtils::toISO8601String(dateTime));
if (!context.enableOpenSubsonic)
return albumNode;
@@ -115,12 +115,12 @@ namespace API::Subsonic
albumNode.setAttribute("mediaType", "album");
{
const Wt::WDateTime dateTime{ Service<Scrobbling::IScrobblingService>::get()->getLastListenDateTime(user->getId(), release->getId()) };
albumNode.setAttribute("played", dateTime.isValid() ? StringUtils::toISO8601String(dateTime) : std::string{ "" });
const Wt::WDateTime dateTime{ core::Service<scrobbling::IScrobblingService>::get()->getLastListenDateTime(user->getId(), release->getId()) };
albumNode.setAttribute("played", dateTime.isValid() ? core::stringUtils::toISO8601String(dateTime) : std::string{ "" });
}
{
std::optional<UUID> mbid{ release->getMBID() };
std::optional<core::UUID> mbid{ release->getMBID() };
albumNode.setAttribute("musicBrainzId", mbid ? mbid->getAsString() : "");
}
@@ -162,7 +162,7 @@ namespace API::Subsonic
albumNode.createEmptyArrayValue("releaseTypes");
for (std::string_view releaseType : release->getReleaseTypeNames())
{
if (StringUtils::stringCaseInsensitiveEqual(releaseType, "compilation"))
if (core::stringUtils::stringCaseInsensitiveEqual(releaseType, "compilation"))
isCompilation = true;
albumNode.addArrayValue("releaseTypes", releaseType);
+3 -3
View File
@@ -22,14 +22,14 @@
#include "database/Object.hpp"
#include "SubsonicResponse.hpp"
namespace Database
namespace lms::db
{
class Release;
class User;
class Session;
}
namespace API::Subsonic
namespace lms::api::subsonic
{
Response::Node createAlbumNode(RequestContext& context, const Database::ObjectPtr<Database::Release>& release, const Database::ObjectPtr<Database::User>& user, bool id3);
Response::Node createAlbumNode(RequestContext& context, const db::ObjectPtr<db::Release>& release, const db::ObjectPtr<db::User>& user, bool id3);
}
+11 -11
View File
@@ -24,17 +24,17 @@
#include "database/TrackArtistLink.hpp"
#include "database/User.hpp"
#include "services/feedback/IFeedbackService.hpp"
#include "utils/ITraceLogger.hpp"
#include "utils/Service.hpp"
#include "utils/String.hpp"
#include "core/ITraceLogger.hpp"
#include "core/Service.hpp"
#include "core/String.hpp"
#include "SubsonicId.hpp"
namespace API::Subsonic
namespace lms::api::subsonic
{
using namespace Database;
using namespace db;
namespace Utils
namespace utils
{
std::string joinArtistNames(const std::vector<Artist::pointer>& artists)
{
@@ -50,7 +50,7 @@ namespace API::Subsonic
return artist->getName();
});
return StringUtils::joinStrings(names, ", ");
return core::stringUtils::joinStrings(names, ", ");
}
std::string_view toString(TrackArtistLinkType type)
@@ -90,8 +90,8 @@ namespace API::Subsonic
artistNode.setAttribute("albumCount", count);
}
if (const Wt::WDateTime dateTime{ Service<Feedback::IFeedbackService>::get()->getStarredDateTime(user->getId(), artist->getId()) }; dateTime.isValid())
artistNode.setAttribute("starred", StringUtils::toISO8601String(dateTime));
if (const Wt::WDateTime dateTime{ core::Service<feedback::IFeedbackService>::get()->getStarredDateTime(user->getId(), artist->getId()) }; dateTime.isValid())
artistNode.setAttribute("starred", core::stringUtils::toISO8601String(dateTime));
// OpenSubsonic specific fields (must always be set)
if (context.enableOpenSubsonic)
@@ -100,7 +100,7 @@ namespace API::Subsonic
artistNode.setAttribute("mediaType", "artist");
{
std::optional<UUID> mbid{ artist->getMBID() };
std::optional<core::UUID> mbid{ artist->getMBID() };
artistNode.setAttribute("musicBrainzId", mbid ? mbid->getAsString() : "");
}
@@ -110,7 +110,7 @@ namespace API::Subsonic
Response::Node roles;
artistNode.createEmptyArrayValue("roles");
for (const TrackArtistLinkType linkType : TrackArtistLink::findUsedTypes(context.dbSession, artist->getId()))
artistNode.addArrayValue("roles", Utils::toString(linkType));
artistNode.addArrayValue("roles", utils::toString(linkType));
}
return artistNode;
+7 -7
View File
@@ -25,20 +25,20 @@
#include "database/Types.hpp"
#include "SubsonicResponse.hpp"
namespace Database
namespace lms::db
{
class Artist;
class User;
class Session;
}
namespace API::Subsonic
namespace lms::api::subsonic
{
namespace Utils
namespace utils
{
std::string joinArtistNames(const std::vector<Database::ObjectPtr<Database::Artist>>& artists);
std::string_view toString(Database::TrackArtistLinkType type);
std::string joinArtistNames(const std::vector<db::ObjectPtr<db::Artist>>& artists);
std::string_view toString(db::TrackArtistLinkType type);
}
Response::Node createArtistNode(RequestContext& context, const Database::ObjectPtr<Database::Artist>& artist, const Database::ObjectPtr<Database::User>& user, bool id3);
Response::Node createArtistNode(const Database::ObjectPtr<Database::Artist>& artist); // only minimal info
Response::Node createArtistNode(RequestContext& context, const db::ObjectPtr<db::Artist>& artist, const db::ObjectPtr<db::User>& user, bool id3);
Response::Node createArtistNode(const db::ObjectPtr<db::Artist>& artist); // only minimal info
}
@@ -22,11 +22,11 @@
#include "database/TrackBookmark.hpp"
#include "database/User.hpp"
namespace API::Subsonic
namespace lms::api::subsonic
{
static const std::string_view reportedDummyDate{ "2000-01-01T00:00:00" };
Response::Node createBookmarkNode(const Database::ObjectPtr<Database::TrackBookmark>& trackBookmark)
Response::Node createBookmarkNode(const db::ObjectPtr<db::TrackBookmark>& trackBookmark)
{
Response::Node trackBookmarkNode;
@@ -22,12 +22,12 @@
#include "database/Object.hpp"
#include "SubsonicResponse.hpp"
namespace Database
namespace lms::db
{
class TrackBookmark;
}
namespace API::Subsonic
namespace lms::api::subsonic
{
Response::Node createBookmarkNode(const Database::ObjectPtr<Database::TrackBookmark>& bookmark);
Response::Node createBookmarkNode(const db::ObjectPtr<db::TrackBookmark>& bookmark);
}
@@ -24,13 +24,13 @@
#include "SubsonicResponse.hpp"
#include "responses/Artist.hpp"
namespace API::Subsonic
namespace lms::api::subsonic
{
Response::Node createContributorNode(const Database::ObjectPtr<Database::TrackArtistLink>& trackArtistLink)
Response::Node createContributorNode(const db::ObjectPtr<db::TrackArtistLink>& trackArtistLink)
{
Response::Node contributorNode;
contributorNode.setAttribute("role", Utils::toString(trackArtistLink->getType()));
contributorNode.setAttribute("role", utils::toString(trackArtistLink->getType()));
if (!trackArtistLink->getSubType().empty())
contributorNode.setAttribute("subRole", trackArtistLink->getSubType());
contributorNode.addChild("artist", createArtistNode(trackArtistLink->getArtist()));
@@ -22,12 +22,12 @@
#include "database/Object.hpp"
#include "SubsonicResponse.hpp"
namespace Database
namespace lms::db
{
class TrackArtistLink;
}
namespace API::Subsonic
namespace lms::api::subsonic
{
Response::Node createContributorNode(const Database::ObjectPtr<Database::TrackArtistLink>& trackArtistLink);
Response::Node createContributorNode(const db::ObjectPtr<db::TrackArtistLink>& trackArtistLink);
}
@@ -19,9 +19,9 @@
#include "responses/DiscTitle.hpp"
namespace API::Subsonic
namespace lms::api::subsonic
{
Response::Node createDiscTitle(const Database::DiscInfo& discInfo)
Response::Node createDiscTitle(const db::DiscInfo& discInfo)
{
Response::Node discTitleNode;
@@ -22,7 +22,7 @@
#include "database/Types.hpp"
#include "SubsonicResponse.hpp"
namespace API::Subsonic
namespace lms::api::subsonic
{
Response::Node createDiscTitle(const Database::DiscInfo& discInfo);
Response::Node createDiscTitle(const db::DiscInfo& discInfo);
}
+2 -2
View File
@@ -21,9 +21,9 @@
#include "database/Cluster.hpp"
namespace API::Subsonic
namespace lms::api::subsonic
{
Response::Node createGenreNode(const Database::Cluster::pointer& cluster)
Response::Node createGenreNode(const db::Cluster::pointer& cluster)
{
Response::Node clusterNode;
+3 -3
View File
@@ -22,12 +22,12 @@
#include "database/Object.hpp"
#include "SubsonicResponse.hpp"
namespace Database
namespace lms::db
{
class Cluster;
}
namespace API::Subsonic
namespace lms::api::subsonic
{
Response::Node createGenreNode(const Database::ObjectPtr<Database::Cluster>& cluster);
Response::Node createGenreNode(const db::ObjectPtr<db::Cluster>& cluster);
}
@@ -21,7 +21,7 @@
#include "database/Cluster.hpp"
namespace API::Subsonic
namespace lms::api::subsonic
{
Response::Node createItemDateNode(const Wt::WDate& date, std::optional<int> year)
{
@@ -22,7 +22,7 @@
#include <Wt/WDate.h>
#include "SubsonicResponse.hpp"
namespace API::Subsonic
namespace lms::api::subsonic
{
Response::Node createItemDateNode(const Wt::WDate& date, std::optional<int> year);
}
@@ -21,7 +21,7 @@
#include "database/Cluster.hpp"
namespace API::Subsonic
namespace lms::api::subsonic
{
Response::Node createItemGenreNode(std::string_view name)
{
@@ -22,12 +22,12 @@
#include <string_view>
#include "SubsonicResponse.hpp"
namespace Database
namespace lms::db
{
class Cluster;
}
namespace API::Subsonic
namespace lms::api::subsonic
{
Response::Node createItemGenreNode(std::string_view name);
}
@@ -24,9 +24,9 @@
#include "database/User.hpp"
#include "SubsonicId.hpp"
namespace API::Subsonic
namespace lms::api::subsonic
{
using namespace Database;
using namespace db;
static const std::string_view reportedDummyDate{ "2000-01-01T00:00:00" };
@@ -22,13 +22,13 @@
#include "database/Object.hpp"
#include "SubsonicResponse.hpp"
namespace Database
namespace lms::db
{
class TrackList;
class Session;
}
namespace API::Subsonic
namespace lms::api::subsonic
{
Response::Node createPlaylistNode(const Database::ObjectPtr<Database::TrackList>& tracklist, Database::Session& session);
Response::Node createPlaylistNode(const db::ObjectPtr<db::TrackList>& tracklist, db::Session& session);
}
@@ -21,9 +21,9 @@
#include "database/Track.hpp"
namespace API::Subsonic
namespace lms::api::subsonic
{
Response::Node createReplayGainNode(const Database::ObjectPtr<Database::Track>& track)
Response::Node createReplayGainNode(const db::ObjectPtr<db::Track>& track)
{
Response::Node replayGainNode;
@@ -22,12 +22,12 @@
#include "database/Object.hpp"
#include "SubsonicResponse.hpp"
namespace Database
namespace lms::db
{
class Track;
}
namespace API::Subsonic
namespace lms::api::subsonic
{
Response::Node createReplayGainNode(const Database::ObjectPtr<Database::Track>& track);
Response::Node createReplayGainNode(const db::ObjectPtr<db::Track>& track);
}
+18 -18
View File
@@ -30,9 +30,9 @@
#include "database/User.hpp"
#include "services/feedback/IFeedbackService.hpp"
#include "services/scrobbling/IScrobblingService.hpp"
#include "utils/ITraceLogger.hpp"
#include "utils/Service.hpp"
#include "utils/String.hpp"
#include "core/ITraceLogger.hpp"
#include "core/Service.hpp"
#include "core/String.hpp"
#include "responses/Artist.hpp"
#include "responses/Contributor.hpp"
#include "responses/ItemGenre.hpp"
@@ -40,9 +40,9 @@
#include "SubsonicId.hpp"
#include "Utils.hpp"
namespace API::Subsonic
namespace lms::api::subsonic
{
using namespace Database;
using namespace db;
namespace
{
@@ -76,9 +76,9 @@ namespace API::Subsonic
if (artists.size() > 1)
path = "Various Artists/";
else if (artists.size() == 1)
path = Utils::makeNameFilesystemCompatible(artists.front()->getName()) + "/";
path = utils::makeNameFilesystemCompatible(artists.front()->getName()) + "/";
path += Utils::makeNameFilesystemCompatible(track->getRelease()->getName()) + "/";
path += utils::makeNameFilesystemCompatible(track->getRelease()->getName()) + "/";
}
if (track->getDiscNumber())
@@ -86,7 +86,7 @@ namespace API::Subsonic
if (track->getTrackNumber())
path += std::to_string(*track->getTrackNumber()) + "-";
path += Utils::makeNameFilesystemCompatible(track->getName());
path += utils::makeNameFilesystemCompatible(track->getName());
if (track->getPath().has_extension())
path += track->getPath().extension();
@@ -110,7 +110,7 @@ namespace API::Subsonic
trackResponse.setAttribute("discNumber", *track->getDiscNumber());
if (track->getYear())
trackResponse.setAttribute("year", *track->getYear());
trackResponse.setAttribute("playCount", Service<Scrobbling::IScrobblingService>::get()->getCount(user->getId(), track->getId()));
trackResponse.setAttribute("playCount", core::Service<scrobbling::IScrobblingService>::get()->getCount(user->getId(), track->getId()));
trackResponse.setAttribute("path", getTrackPath(track));
{
// TODO, store this in DB
@@ -129,7 +129,7 @@ namespace API::Subsonic
{
const std::string fileSuffix{ formatToSuffix(user->getSubsonicDefaultTranscodingOutputFormat()) };
trackResponse.setAttribute("transcodedSuffix", fileSuffix);
trackResponse.setAttribute("transcodedContentType", Av::getMimeType(std::filesystem::path{ "." + fileSuffix }));
trackResponse.setAttribute("transcodedContentType", av::getMimeType(std::filesystem::path{ "." + fileSuffix }));
}
trackResponse.setAttribute("coverArt", idToString(track->getId()));
@@ -140,7 +140,7 @@ namespace API::Subsonic
if (!track->getArtistDisplayName().empty())
trackResponse.setAttribute("artist", track->getArtistDisplayName());
else
trackResponse.setAttribute("artist", Utils::joinArtistNames(artists));
trackResponse.setAttribute("artist", utils::joinArtistNames(artists));
if (artists.size() == 1)
trackResponse.setAttribute("artistId", idToString(artists.front()->getId()));
@@ -157,11 +157,11 @@ namespace API::Subsonic
trackResponse.setAttribute("duration", std::chrono::duration_cast<std::chrono::seconds>(track->getDuration()).count());
trackResponse.setAttribute("bitRate", (track->getBitrate() / 1000));
trackResponse.setAttribute("type", "music");
trackResponse.setAttribute("created", StringUtils::toISO8601String(track->getLastWritten()));
trackResponse.setAttribute("contentType", Av::getMimeType(track->getPath().extension()));
trackResponse.setAttribute("created", core::stringUtils::toISO8601String(track->getLastWritten()));
trackResponse.setAttribute("contentType", av::getMimeType(track->getPath().extension()));
if (const Wt::WDateTime dateTime{ Service<Feedback::IFeedbackService>::get()->getStarredDateTime(user->getId(), track->getId()) }; dateTime.isValid())
trackResponse.setAttribute("starred", StringUtils::toISO8601String(dateTime));
if (const Wt::WDateTime dateTime{ core::Service<feedback::IFeedbackService>::get()->getStarredDateTime(user->getId(), track->getId()) }; dateTime.isValid())
trackResponse.setAttribute("starred", core::stringUtils::toISO8601String(dateTime));
// Report the first GENRE for this track
std::vector<Cluster::pointer> genres;
@@ -182,12 +182,12 @@ namespace API::Subsonic
trackResponse.setAttribute("mediaType", "song");
{
const Wt::WDateTime dateTime{ Service<Scrobbling::IScrobblingService>::get()->getLastListenDateTime(user->getId(), track->getId()) };
trackResponse.setAttribute("played", dateTime.isValid() ? StringUtils::toISO8601String(dateTime) : "");
const Wt::WDateTime dateTime{ core::Service<scrobbling::IScrobblingService>::get()->getLastListenDateTime(user->getId(), track->getId()) };
trackResponse.setAttribute("played", dateTime.isValid() ? core::stringUtils::toISO8601String(dateTime) : "");
}
{
std::optional<UUID> mbid{ track->getRecordingMBID() };
std::optional<core::UUID> mbid{ track->getRecordingMBID() };
trackResponse.setAttribute("musicBrainzId", mbid ? mbid->getAsString() : "");
}
+3 -3
View File
@@ -22,14 +22,14 @@
#include "database/Object.hpp"
#include "SubsonicResponse.hpp"
namespace Database
namespace lms::db
{
class Track;
class User;
class Session;
}
namespace API::Subsonic
namespace lms::api::subsonic
{
Response::Node createSongNode(RequestContext& context, const Database::ObjectPtr<Database::Track>& track, const Database::ObjectPtr<Database::User>& user);
Response::Node createSongNode(RequestContext& context, const db::ObjectPtr<db::Track>& track, const db::ObjectPtr<db::User>& user);
}
+2 -2
View File
@@ -21,9 +21,9 @@
#include "database/User.hpp"
namespace API::Subsonic
namespace lms::api::subsonic
{
using namespace Database;
using namespace db;
Response::Node createUserNode(const User::pointer& user)
{
+3 -3
View File
@@ -22,12 +22,12 @@
#include "database/Object.hpp"
#include "SubsonicResponse.hpp"
namespace Database
namespace lms::db
{
class User;
}
namespace API::Subsonic
namespace lms::api::subsonic
{
Response::Node createUserNode(const Database::ObjectPtr<Database::User>& user);
Response::Node createUserNode(const db::ObjectPtr<db::User>& user);
}