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
@@ -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);