diff --git a/src/libs/image/CMakeLists.txt b/src/libs/image/CMakeLists.txt
index 015feaac..53435e19 100644
--- a/src/libs/image/CMakeLists.txt
+++ b/src/libs/image/CMakeLists.txt
@@ -26,11 +26,17 @@ if (${LMS_IMAGE_BACKEND} STREQUAL "stb")
target_sources(lmsimage PRIVATE
impl/stb/Image.cpp
+ impl/stb/Exception.cpp
impl/stb/RawImage.cpp
impl/stb/StbImage.cpp
impl/stb/StbImageResize.cpp
impl/stb/StbImageWrite.cpp
)
+
+ set_property(SOURCE impl/stb/StbImage.cpp PROPERTY SKIP_UNITY_BUILD_INCLUSION ON)
+ set_property(SOURCE impl/stb/StbImageResize.cpp PROPERTY SKIP_UNITY_BUILD_INCLUSION ON)
+ set_property(SOURCE impl/stb/StbImageWrite.cpp PROPERTY SKIP_UNITY_BUILD_INCLUSION ON)
+
target_compile_options(lmsimage PRIVATE "-DSTB_IMAGE_RESIZE_VERSION=${STB_IMAGE_RESIZE_VERSION}")
target_include_directories(lmsimage PRIVATE ${STB_IMAGE_INCLUDE_DIR})
diff --git a/src/libs/image/impl/stb/Exception.cpp b/src/libs/image/impl/stb/Exception.cpp
new file mode 100644
index 00000000..4554e39e
--- /dev/null
+++ b/src/libs/image/impl/stb/Exception.cpp
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2020 Emeric Poupon
+ *
+ * This file is part of LMS.
+ *
+ * LMS is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * LMS is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with LMS. If not, see .
+ */
+
+#include "Exception.hpp"
+
+#include "StbImage.hpp"
+
+namespace lms::image
+{
+ StbiException::StbiException(std::string_view desc)
+ : Exception{ std::string{ desc } + ": " + getLastFailureReason() }
+ {
+ }
+
+ std::string StbiException::getLastFailureReason()
+ {
+ const char* failureReason{ ::stbi_failure_reason() };
+ return failureReason ? failureReason : "unknown reason";
+ }
+} // namespace lms::image
\ No newline at end of file
diff --git a/src/libs/image/impl/stb/Exception.hpp b/src/libs/image/impl/stb/Exception.hpp
new file mode 100644
index 00000000..0de16d49
--- /dev/null
+++ b/src/libs/image/impl/stb/Exception.hpp
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2020 Emeric Poupon
+ *
+ * This file is part of LMS.
+ *
+ * LMS is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * LMS is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with LMS. If not, see .
+ */
+
+#pragma once
+
+#include
+
+#include "image/Exception.hpp"
+
+namespace lms::image
+{
+ class StbiException : public Exception
+ {
+ public:
+ StbiException(std::string_view desc);
+
+ private:
+ static std::string getLastFailureReason();
+ };
+} // namespace lms::image
\ No newline at end of file
diff --git a/src/libs/image/impl/stb/Image.cpp b/src/libs/image/impl/stb/Image.cpp
index 5638cb69..89a90f2f 100644
--- a/src/libs/image/impl/stb/Image.cpp
+++ b/src/libs/image/impl/stb/Image.cpp
@@ -21,6 +21,7 @@
#include
+#include "Exception.hpp"
#include "StbImage.hpp"
#include "StbImageWrite.hpp"
diff --git a/src/libs/image/impl/stb/RawImage.cpp b/src/libs/image/impl/stb/RawImage.cpp
index f4c420af..b06d3be0 100644
--- a/src/libs/image/impl/stb/RawImage.cpp
+++ b/src/libs/image/impl/stb/RawImage.cpp
@@ -19,6 +19,7 @@
#include "RawImage.hpp"
+#include "Exception.hpp"
#include "StbImage.hpp"
#include "StbImageResize.hpp"
diff --git a/src/libs/image/impl/stb/StbImage.cpp b/src/libs/image/impl/stb/StbImage.cpp
index 7432daad..9c8ec3e3 100644
--- a/src/libs/image/impl/stb/StbImage.cpp
+++ b/src/libs/image/impl/stb/StbImage.cpp
@@ -19,17 +19,3 @@
#define STB_IMAGE_IMPLEMENTATION
#include "StbImage.hpp"
-
-namespace lms::image
-{
- StbiException::StbiException(std::string_view desc)
- : Exception{ std::string{ desc } + ": " + getLastFailureReason() }
- {
- }
-
- std::string StbiException::getLastFailureReason()
- {
- const char* failureReason{ ::stbi_failure_reason() };
- return failureReason ? failureReason : "unknown reason";
- }
-} // namespace lms::image
\ No newline at end of file
diff --git a/src/libs/image/impl/stb/StbImage.hpp b/src/libs/image/impl/stb/StbImage.hpp
index 09bc88ac..18c90eb3 100644
--- a/src/libs/image/impl/stb/StbImage.hpp
+++ b/src/libs/image/impl/stb/StbImage.hpp
@@ -16,6 +16,7 @@
* You should have received a copy of the GNU General Public License
* along with LMS. If not, see .
*/
+
#pragma once
#define STBI_ONLY_JPEG
@@ -24,19 +25,3 @@
#define STBI_FAILURE_USERMSG
#include
-
-#include
-
-#include "image/Exception.hpp"
-
-namespace lms::image
-{
- class StbiException : public Exception
- {
- public:
- StbiException(std::string_view desc);
-
- private:
- static std::string getLastFailureReason();
- };
-} // namespace lms::image
\ No newline at end of file
diff --git a/src/libs/metadata/impl/AvFormatTagReader.cpp b/src/libs/metadata/impl/AvFormatTagReader.cpp
index 9bcb6574..aa3feb0f 100644
--- a/src/libs/metadata/impl/AvFormatTagReader.cpp
+++ b/src/libs/metadata/impl/AvFormatTagReader.cpp
@@ -30,7 +30,7 @@ namespace lms::metadata
namespace
{
// Mapping to internal avformat names and/or common alternative custom names
- static const std::unordered_map> tagMapping{
+ static const std::unordered_map> avFormatTagMapping{
{ TagType::AcoustID, { "ACOUSTID_ID", "ACOUSTID ID" } },
{ TagType::Advisory, { "ITUNESADVISORY" } },
{ TagType::Album, { "ALBUM", "TALB", "WM/ALBUMTITLE" } },
@@ -171,8 +171,8 @@ namespace lms::metadata
void AvFormatTagReader::visitTagValues(TagType tag, TagValueVisitor visitor) const
{
- auto itTagNames{ tagMapping.find(tag) };
- if (itTagNames == std::cend(tagMapping))
+ auto itTagNames{ avFormatTagMapping.find(tag) };
+ if (itTagNames == std::cend(avFormatTagMapping))
return;
for (const std::string& tagName : itTagNames->second)
diff --git a/src/libs/metadata/impl/TagLibImageReader.cpp b/src/libs/metadata/impl/TagLibImageReader.cpp
index fcbc2eca..8dba0b9b 100644
--- a/src/libs/metadata/impl/TagLibImageReader.cpp
+++ b/src/libs/metadata/impl/TagLibImageReader.cpp
@@ -48,7 +48,7 @@ namespace lms::metadata
{
namespace
{
- class ParsingFailedException : public Exception
+ class ImageParsingFailedException : public Exception
{
};
@@ -362,7 +362,7 @@ namespace lms::metadata
if (_file.isNull())
{
LMS_LOG(METADATA, ERROR, "File " << p << ": parsing failed");
- throw ParsingFailedException{};
+ throw ImageParsingFailedException{};
}
}
diff --git a/src/libs/metadata/impl/TagLibTagReader.cpp b/src/libs/metadata/impl/TagLibTagReader.cpp
index 307b412b..1ea6e8ea 100644
--- a/src/libs/metadata/impl/TagLibTagReader.cpp
+++ b/src/libs/metadata/impl/TagLibTagReader.cpp
@@ -55,12 +55,12 @@ namespace lms::metadata
{
namespace
{
- class ParsingFailedException : public Exception
+ class TagParsingFailedException : public Exception
{
};
// Mapping to internal taglib names and/or common alternative custom names
- const std::unordered_map> tagMapping{
+ const std::unordered_map> tagLibTagMapping{
{ TagType::AcoustID, { "ACOUSTID_ID", "ACOUSTID ID" } },
{ TagType::Advisory, { "ITUNESADVISORY" } },
{ TagType::Album, { "ALBUM" } },
@@ -228,13 +228,13 @@ namespace lms::metadata
if (_file.isNull())
{
LMS_LOG(METADATA, ERROR, "File " << p << ": parsing failed");
- throw ParsingFailedException{};
+ throw TagParsingFailedException{};
}
if (!_file.audioProperties())
{
LMS_LOG(METADATA, ERROR, "File " << p << ": no audio properties");
- throw ParsingFailedException{};
+ throw TagParsingFailedException{};
}
computeAudioProperties();
@@ -465,8 +465,8 @@ namespace lms::metadata
void TagLibTagReader::visitTagValues(TagType tag, TagValueVisitor visitor) const
{
- auto itTagNames{ tagMapping.find(tag) };
- if (itTagNames == std::cend(tagMapping))
+ auto itTagNames{ tagLibTagMapping.find(tag) };
+ if (itTagNames == std::cend(tagLibTagMapping))
return;
for (const std::string& tagName : itTagNames->second)
diff --git a/src/libs/services/scanner/impl/steps/ScanStepAssociateArtistImages.cpp b/src/libs/services/scanner/impl/steps/ScanStepAssociateArtistImages.cpp
index aa92af77..e770f089 100644
--- a/src/libs/services/scanner/impl/steps/ScanStepAssociateArtistImages.cpp
+++ b/src/libs/services/scanner/impl/steps/ScanStepAssociateArtistImages.cpp
@@ -51,7 +51,7 @@ namespace lms::scanner
};
using ArtistImageAssociationContainer = std::deque;
- struct SearchImageContext
+ struct SearchArtistImageContext
{
db::Session& session;
db::ArtistId lastRetrievedArtistId;
@@ -59,7 +59,7 @@ namespace lms::scanner
std::span artistFileNames;
};
- db::Image::pointer findImageInDirectory(SearchImageContext& searchContext, const std::filesystem::path& directoryPath, std::span fileStemsToSearch)
+ db::Image::pointer findImageInDirectory(SearchArtistImageContext& searchContext, const std::filesystem::path& directoryPath, std::span fileStemsToSearch)
{
db::Image::pointer image;
@@ -85,7 +85,7 @@ namespace lms::scanner
return image;
}
- db::Image::pointer getImageFromMbid(SearchImageContext& searchContext, const core::UUID& mbid)
+ db::Image::pointer getImageFromMbid(SearchArtistImageContext& searchContext, const core::UUID& mbid)
{
db::Image::pointer image;
@@ -98,7 +98,7 @@ namespace lms::scanner
return image;
}
- db::Image::pointer searchImageInArtistInfoDirectory(SearchImageContext& searchContext, db::ArtistId artistId)
+ db::Image::pointer searchImageInArtistInfoDirectory(SearchArtistImageContext& searchContext, db::ArtistId artistId)
{
db::Image::pointer image;
@@ -116,7 +116,7 @@ namespace lms::scanner
return image;
}
- db::Image::pointer searchImageInDirectories(SearchImageContext& searchContext, db::ArtistId artistId)
+ db::Image::pointer searchImageInDirectories(SearchArtistImageContext& searchContext, db::ArtistId artistId)
{
db::Image::pointer image;
@@ -169,7 +169,7 @@ namespace lms::scanner
return image;
}
- db::Image::pointer computeBestArtistImage(SearchImageContext& searchContext, const db::Artist::pointer& artist)
+ db::Image::pointer computeBestArtistImage(SearchArtistImageContext& searchContext, const db::Artist::pointer& artist)
{
db::Image::pointer image;
@@ -185,7 +185,7 @@ namespace lms::scanner
return image;
}
- bool fetchNextArtistImagesToUpdate(SearchImageContext& searchContext, ArtistImageAssociationContainer& artistImageAssociations)
+ bool fetchNextArtistImagesToUpdate(SearchArtistImageContext& searchContext, ArtistImageAssociationContainer& artistImageAssociations)
{
const db::ArtistId artistId{ searchContext.lastRetrievedArtistId };
@@ -271,7 +271,7 @@ namespace lms::scanner
context.currentStepStats.totalElems = db::Artist::getCount(session);
}
- SearchImageContext searchContext{
+ SearchArtistImageContext searchContext{
.session = session,
.lastRetrievedArtistId = {},
.artistFileNames = _artistFileNames,
diff --git a/src/libs/services/scanner/impl/steps/ScanStepAssociateExternalLyrics.cpp b/src/libs/services/scanner/impl/steps/ScanStepAssociateExternalLyrics.cpp
index d065e8f7..19f4a1f3 100644
--- a/src/libs/services/scanner/impl/steps/ScanStepAssociateExternalLyrics.cpp
+++ b/src/libs/services/scanner/impl/steps/ScanStepAssociateExternalLyrics.cpp
@@ -32,9 +32,6 @@ namespace lms::scanner
{
namespace
{
- constexpr std::size_t readBatchSize{ 100 };
- constexpr std::size_t writeBatchSize{ 20 };
-
struct TrackLyricsAssociation
{
db::TrackLyricsId trackLyricsId;
@@ -83,6 +80,8 @@ namespace lms::scanner
bool fetchNextTrackLyricsToUpdate(SearchTrackLyricsContext& searchContext, TrackLyricsAssociationContainer& trackLyricsAssociations)
{
+ constexpr std::size_t readBatchSize{ 100 };
+
const db::TrackLyricsId trackLyricsId{ searchContext.lastRetrievedTrackLyricsId };
{
@@ -125,6 +124,8 @@ namespace lms::scanner
void updateTrackLyrics(db::Session& session, TrackLyricsAssociationContainer& lyricsAssociations)
{
+ constexpr std::size_t writeBatchSize{ 20 };
+
while (!lyricsAssociations.empty())
{
auto transaction{ session.createWriteTransaction() };
diff --git a/src/libs/services/scanner/impl/steps/ScanStepAssociatePlayListTracks.cpp b/src/libs/services/scanner/impl/steps/ScanStepAssociatePlayListTracks.cpp
index 4b1e410e..628363e4 100644
--- a/src/libs/services/scanner/impl/steps/ScanStepAssociatePlayListTracks.cpp
+++ b/src/libs/services/scanner/impl/steps/ScanStepAssociatePlayListTracks.cpp
@@ -37,9 +37,6 @@ namespace lms::scanner
{
namespace
{
- constexpr std::size_t readBatchSize{ 20 };
- constexpr std::size_t writeBatchSize{ 5 };
-
struct TrackInfo
{
db::TrackId trackId;
@@ -118,6 +115,8 @@ namespace lms::scanner
const db::PlayListFileId playListFileIdId{ searchContext.lastRetrievedPlayListFileId };
{
+ constexpr std::size_t readBatchSize{ 20 };
+
auto transaction{ searchContext.session.createReadTransaction() };
db::PlayListFile::find(searchContext.session, searchContext.lastRetrievedPlayListFileId, readBatchSize, [&](const db::PlayListFile::pointer& playListFile) {
@@ -199,6 +198,8 @@ namespace lms::scanner
void updatePlayListFiles(db::Session& session, PlayListFileAssociationContainer& playListFileAssociations)
{
+ constexpr std::size_t writeBatchSize{ 5 };
+
while (!playListFileAssociations.empty())
{
auto transaction{ session.createWriteTransaction() };
diff --git a/src/libs/services/scanner/impl/steps/ScanStepAssociateReleaseImages.cpp b/src/libs/services/scanner/impl/steps/ScanStepAssociateReleaseImages.cpp
index c384fab8..4ec18e89 100644
--- a/src/libs/services/scanner/impl/steps/ScanStepAssociateReleaseImages.cpp
+++ b/src/libs/services/scanner/impl/steps/ScanStepAssociateReleaseImages.cpp
@@ -38,9 +38,6 @@ namespace lms::scanner
{
namespace
{
- constexpr std::size_t readBatchSize{ 100 };
- constexpr std::size_t writeBatchSize{ 20 };
-
struct ReleaseImageAssociation
{
db::ReleaseId releaseId;
@@ -48,7 +45,7 @@ namespace lms::scanner
};
using ReleaseImageAssociationContainer = std::deque;
- struct SearchImageContext
+ struct SearchReleaseImageContext
{
db::Session& session;
db::ReleaseId lastRetrievedReleaseId;
@@ -56,7 +53,7 @@ namespace lms::scanner
const std::vector& releaseFileNames;
};
- db::Image::pointer findImageInDirectory(SearchImageContext& searchContext, const std::filesystem::path& directoryPath)
+ db::Image::pointer findImageInDirectory(SearchReleaseImageContext& searchContext, const std::filesystem::path& directoryPath)
{
db::Image::pointer image;
@@ -82,7 +79,7 @@ namespace lms::scanner
return image;
}
- db::Image::pointer computeBestReleaseImage(SearchImageContext& searchContext, const db::Release::pointer& release)
+ db::Image::pointer computeBestReleaseImage(SearchReleaseImageContext& searchContext, const db::Release::pointer& release)
{
db::Image::pointer image;
@@ -130,11 +127,13 @@ namespace lms::scanner
return image;
}
- bool fetchNextReleaseImagesToUpdate(SearchImageContext& searchContext, ReleaseImageAssociationContainer& releaseImageAssociations)
+ bool fetchNextReleaseImagesToUpdate(SearchReleaseImageContext& searchContext, ReleaseImageAssociationContainer& releaseImageAssociations)
{
const db::ReleaseId releaseId{ searchContext.lastRetrievedReleaseId };
{
+ constexpr std::size_t readBatchSize{ 100 };
+
auto transaction{ searchContext.session.createReadTransaction() };
db::Release::find(searchContext.session, searchContext.lastRetrievedReleaseId, readBatchSize, [&](const db::Release::pointer& release) {
@@ -166,6 +165,8 @@ namespace lms::scanner
void updateReleaseImages(db::Session& session, ReleaseImageAssociationContainer& imageAssociations)
{
+ constexpr std::size_t writeBatchSize{ 20 };
+
while (!imageAssociations.empty())
{
auto transaction{ session.createWriteTransaction() };
@@ -216,7 +217,7 @@ namespace lms::scanner
context.currentStepStats.totalElems = db::Release::getCount(session);
}
- SearchImageContext searchContext{
+ SearchReleaseImageContext searchContext{
.session = session,
.lastRetrievedReleaseId = {},
.releaseFileNames = _releaseFileNames,
diff --git a/src/libs/subsonic/impl/endpoints/MediaAnnotation.cpp b/src/libs/subsonic/impl/endpoints/MediaAnnotation.cpp
index bada0099..55749da6 100644
--- a/src/libs/subsonic/impl/endpoints/MediaAnnotation.cpp
+++ b/src/libs/subsonic/impl/endpoints/MediaAnnotation.cpp
@@ -62,7 +62,7 @@ namespace lms::api::subsonic
return res;
}
- ReleaseId getReleaseFromDirectory(Session& session, DirectoryId directory)
+ ReleaseId getReleaseIdFromDirectory(Session& session, DirectoryId directory)
{
auto transaction{ session.createReadTransaction() };
@@ -117,7 +117,7 @@ namespace lms::api::subsonic
for (const DirectoryId id : params.directoryIds)
{
- if (const ReleaseId releaseId{ getReleaseFromDirectory(context.dbSession, id) }; releaseId.isValid())
+ if (const ReleaseId releaseId{ getReleaseIdFromDirectory(context.dbSession, id) }; releaseId.isValid())
core::Service::get()->star(context.user->getId(), releaseId);
}
@@ -139,7 +139,7 @@ namespace lms::api::subsonic
for (const DirectoryId id : params.directoryIds)
{
- if (const ReleaseId releaseId{ getReleaseFromDirectory(context.dbSession, id) }; releaseId.isValid())
+ if (const ReleaseId releaseId{ getReleaseIdFromDirectory(context.dbSession, id) }; releaseId.isValid())
core::Service::get()->unstar(context.user->getId(), releaseId);
}
@@ -163,7 +163,7 @@ namespace lms::api::subsonic
core::Service::get()->setRating(context.user->getId(), *artistId, params.rating);
else if (const DirectoryId * directoryId{ std::get_if(¶ms.id) })
{
- if (const ReleaseId releaseId{ getReleaseFromDirectory(context.dbSession, *directoryId) }; releaseId.isValid())
+ if (const ReleaseId releaseId{ getReleaseIdFromDirectory(context.dbSession, *directoryId) }; releaseId.isValid())
core::Service::get()->setRating(context.user->getId(), releaseId, params.rating);
}
else if (const ReleaseId * releaseId{ std::get_if(¶ms.id) })
diff --git a/src/lms/ui/admin/ScannerController.cpp b/src/lms/ui/admin/ScannerController.cpp
index bcfc424e..dff32263 100644
--- a/src/lms/ui/admin/ScannerController.cpp
+++ b/src/lms/ui/admin/ScannerController.cpp
@@ -45,16 +45,16 @@ namespace lms::ui
}
} // namespace
- class ReportResource : public Wt::WResource
+ class ScannerReportResource : public Wt::WResource
{
public:
- ReportResource() = default;
- ~ReportResource() override
+ ScannerReportResource() = default;
+ ~ScannerReportResource() override
{
beingDeleted();
}
- ReportResource(const ReportResource&) = delete;
- ReportResource& operator=(const ReportResource&) = delete;
+ ScannerReportResource(const ScannerReportResource&) = delete;
+ ScannerReportResource& operator=(const ScannerReportResource&) = delete;
void setScanStats(const scanner::ScanStats& stats)
{
@@ -160,7 +160,7 @@ namespace lms::ui
{
_reportBtn = bindNew("report-btn", Wt::WString::tr("Lms.Admin.ScannerController.get-report"));
- auto reportResource{ std::make_shared() };
+ auto reportResource{ std::make_shared() };
reportResource->setTakesUpdateLock(true);
_reportResource = reportResource.get();
diff --git a/src/lms/ui/admin/ScannerController.hpp b/src/lms/ui/admin/ScannerController.hpp
index e394f573..ade8b4ea 100644
--- a/src/lms/ui/admin/ScannerController.hpp
+++ b/src/lms/ui/admin/ScannerController.hpp
@@ -42,6 +42,6 @@ namespace lms::ui
Wt::WLineEdit* _lastScanStatus;
Wt::WLineEdit* _status;
Wt::WLineEdit* _stepStatus;
- class ReportResource* _reportResource;
+ class ScannerReportResource* _reportResource;
};
} // namespace lms::ui
diff --git a/src/lms/ui/admin/TracingView.cpp b/src/lms/ui/admin/TracingView.cpp
index 81021263..948e32c6 100644
--- a/src/lms/ui/admin/TracingView.cpp
+++ b/src/lms/ui/admin/TracingView.cpp
@@ -34,18 +34,20 @@ namespace lms::ui
{
namespace
{
- class ReportResource : public Wt::WResource
+ class TracingReportResource : public Wt::WResource
{
public:
- ReportResource(core::tracing::ITraceLogger& traceLogger)
+ TracingReportResource(core::tracing::ITraceLogger& traceLogger)
: _traceLogger{ traceLogger }
{
}
- ~ReportResource()
+ ~TracingReportResource()
{
beingDeleted();
}
+ TracingReportResource(const TracingReportResource&) = delete;
+ TracingReportResource& operator=(const TracingReportResource&) = delete;
void handleRequest(const Wt::Http::Request&, Wt::Http::Response& response)
{
@@ -80,7 +82,7 @@ namespace lms::ui
if (auto traceLogger{ core::Service::get() })
{
- Wt::WLink link{ std::make_shared(*traceLogger) };
+ Wt::WLink link{ std::make_shared(*traceLogger) };
link.setTarget(Wt::LinkTarget::NewWindow);
dumpBtn->setLink(link);
}
diff --git a/src/lms/ui/explore/ArtistsView.cpp b/src/lms/ui/explore/ArtistsView.cpp
index 0d85feab..630d1f4f 100644
--- a/src/lms/ui/explore/ArtistsView.cpp
+++ b/src/lms/ui/explore/ArtistsView.cpp
@@ -36,8 +36,6 @@
namespace lms::ui
{
- using namespace db;
-
Artists::Artists(Filters& filters)
: Template{ Wt::WString::tr("Lms.Explore.Artists.template") }
, _artistCollector{ filters, _defaultSortMode, _maxCount }
@@ -63,12 +61,12 @@ namespace lms::ui
}
{
- const std::optional linkType{ state::readValue("artists_link_type") };
+ const std::optional linkType{ state::readValue("artists_link_type") };
_artistCollector.setArtistLinkType(linkType);
TrackArtistLinkTypeSelector* linkTypeSelector{ bindNew("link-type", linkType) };
- linkTypeSelector->itemSelected.connect([this](std::optional newLinkType) {
- state::writeValue("artists_link_type", newLinkType);
+ linkTypeSelector->itemSelected.connect([this](std::optional newLinkType) {
+ state::writeValue("artists_link_type", newLinkType);
refreshView(newLinkType);
});
}
@@ -97,7 +95,7 @@ namespace lms::ui
refreshView();
}
- void Artists::refreshView(std::optional linkType)
+ void Artists::refreshView(std::optional linkType)
{
_artistCollector.setArtistLinkType(linkType);
refreshView();
@@ -111,14 +109,14 @@ namespace lms::ui
void Artists::addSome()
{
- const auto artistIds{ _artistCollector.get(Range{ static_cast(_container->getCount()), _batchSize }) };
+ const auto artistIds{ _artistCollector.get(db::Range{ static_cast(_container->getCount()), _batchSize }) };
{
auto transaction{ LmsApp->getDbSession().createReadTransaction() };
- for (const ArtistId artistId : artistIds.results)
+ for (const db::ArtistId artistId : artistIds.results)
{
- if (const auto artist{ Artist::find(LmsApp->getDbSession(), artistId) })
+ if (const auto artist{ db::Artist::find(LmsApp->getDbSession(), artistId) })
_container->add(ArtistListHelpers::createEntry(artist));
}
}
diff --git a/src/lms/ui/explore/Explore.hpp b/src/lms/ui/explore/Explore.hpp
index 090404f4..ce97c41d 100644
--- a/src/lms/ui/explore/Explore.hpp
+++ b/src/lms/ui/explore/Explore.hpp
@@ -38,6 +38,5 @@ namespace lms::ui
private:
PlayQueueController _playQueueController;
- SearchView* _search{};
};
} // namespace lms::ui
diff --git a/src/lms/ui/explore/ReleaseCollector.cpp b/src/lms/ui/explore/ReleaseCollector.cpp
index 828b38d3..b4e25cc7 100644
--- a/src/lms/ui/explore/ReleaseCollector.cpp
+++ b/src/lms/ui/explore/ReleaseCollector.cpp
@@ -31,16 +31,14 @@
namespace lms::ui
{
- using namespace db;
-
- RangeResults ReleaseCollector::get(std::optional requestedRange)
+ db::RangeResults ReleaseCollector::get(std::optional requestedRange)
{
feedback::IFeedbackService& feedbackService{ *core::Service::get() };
scrobbling::IScrobblingService& scrobblingService{ *core::Service::get() };
- const Range range{ getActualRange(requestedRange) };
+ const db::Range range{ getActualRange(requestedRange) };
- RangeResults releases;
+ db::RangeResults releases;
switch (getMode())
{
@@ -85,45 +83,45 @@ namespace lms::ui
case Mode::RecentlyAdded:
{
- Release::FindParameters params;
+ db::Release::FindParameters params;
params.setFilters(getDbFilters());
params.setKeywords(getSearchKeywords());
- params.setSortMethod(ReleaseSortMethod::AddedDesc);
+ params.setSortMethod(db::ReleaseSortMethod::AddedDesc);
params.setRange(range);
{
auto transaction{ LmsApp->getDbSession().createReadTransaction() };
- releases = Release::findIds(LmsApp->getDbSession(), params);
+ releases = db::Release::findIds(LmsApp->getDbSession(), params);
}
break;
}
case Mode::RecentlyModified:
{
- Release::FindParameters params;
+ db::Release::FindParameters params;
params.setFilters(getDbFilters());
params.setKeywords(getSearchKeywords());
- params.setSortMethod(ReleaseSortMethod::LastWrittenDesc);
+ params.setSortMethod(db::ReleaseSortMethod::LastWrittenDesc);
params.setRange(range);
{
auto transaction{ LmsApp->getDbSession().createReadTransaction() };
- releases = Release::findIds(LmsApp->getDbSession(), params);
+ releases = db::Release::findIds(LmsApp->getDbSession(), params);
}
break;
}
case Mode::All:
{
- Release::FindParameters params;
+ db::Release::FindParameters params;
params.setFilters(getDbFilters());
- params.setSortMethod(ReleaseSortMethod::SortName);
+ params.setSortMethod(db::ReleaseSortMethod::SortName);
params.setKeywords(getSearchKeywords());
params.setRange(range);
{
auto transaction{ LmsApp->getDbSession().createReadTransaction() };
- releases = Release::findIds(LmsApp->getDbSession(), params);
+ releases = db::Release::findIds(LmsApp->getDbSession(), params);
}
break;
}
@@ -135,21 +133,21 @@ namespace lms::ui
return releases;
}
- RangeResults ReleaseCollector::getRandomReleases(Range range)
+ db::RangeResults ReleaseCollector::getRandomReleases(Range range)
{
assert(getMode() == Mode::Random);
if (!_randomReleases)
{
- Release::FindParameters params;
+ db::Release::FindParameters params;
params.setFilters(getDbFilters());
params.setKeywords(getSearchKeywords());
- params.setSortMethod(ReleaseSortMethod::Random);
- params.setRange(Range{ 0, getMaxCount() });
+ params.setSortMethod(db::ReleaseSortMethod::Random);
+ params.setRange(db::Range{ 0, getMaxCount() });
{
auto transaction{ LmsApp->getDbSession().createReadTransaction() };
- _randomReleases = Release::findIds(LmsApp->getDbSession(), params);
+ _randomReleases = db::Release::findIds(LmsApp->getDbSession(), params);
}
}
diff --git a/src/lms/ui/explore/TrackListHelpers.cpp b/src/lms/ui/explore/TrackListHelpers.cpp
index 3093c5ac..6e967580 100644
--- a/src/lms/ui/explore/TrackListHelpers.cpp
+++ b/src/lms/ui/explore/TrackListHelpers.cpp
@@ -47,26 +47,24 @@
namespace lms::ui::TrackListHelpers
{
- using namespace db;
-
- std::map> getArtistsByRole(db::TrackId trackId, core::EnumSet artistLinkTypes)
+ std::map> getArtistsByRole(db::TrackId trackId, core::EnumSet artistLinkTypes)
{
- std::map> artistMap;
+ std::map> artistMap;
- auto addArtists = [&](TrackArtistLinkType linkType, const char* type) {
+ auto addArtists = [&](db::TrackArtistLinkType linkType, const char* type) {
if (!artistLinkTypes.contains(linkType))
return;
- Artist::FindParameters params;
+ db::Artist::FindParameters params;
params.setTrack(trackId);
params.setLinkType(linkType);
- const auto artistIds{ Artist::findIds(LmsApp->getDbSession(), params) };
+ const auto artistIds{ db::Artist::findIds(LmsApp->getDbSession(), params) };
if (artistIds.results.empty())
return;
Wt::WString typeStr{ Wt::WString::trn(type, artistIds.results.size()) };
- for (ArtistId artistId : artistIds.results)
+ for (db::ArtistId artistId : artistIds.results)
artistMap[typeStr].insert(artistId);
};
@@ -74,21 +72,21 @@ namespace lms::ui::TrackListHelpers
if (!artistLinkTypes.contains(db::TrackArtistLinkType::Performer))
return;
- TrackArtistLink::FindParameters params;
+ db::TrackArtistLink::FindParameters params;
params.setTrack(trackId);
- params.setLinkType(TrackArtistLinkType::Performer);
+ params.setLinkType(db::TrackArtistLinkType::Performer);
- TrackArtistLink::find(LmsApp->getDbSession(), params, [&](const TrackArtistLink::pointer& link) {
+ db::TrackArtistLink::find(LmsApp->getDbSession(), params, [&](const db::TrackArtistLink::pointer& link) {
artistMap[std::string{ link->getSubType() }].insert(link->getArtist()->getId());
});
};
- addArtists(TrackArtistLinkType::Composer, "Lms.Explore.Artists.linktype-composer");
- addArtists(TrackArtistLinkType::Conductor, "Lms.Explore.Artists.linktype-conductor");
- addArtists(TrackArtistLinkType::Lyricist, "Lms.Explore.Artists.linktype-lyricist");
- addArtists(TrackArtistLinkType::Mixer, "Lms.Explore.Artists.linktype-mixer");
- addArtists(TrackArtistLinkType::Remixer, "Lms.Explore.Artists.linktype-remixer");
- addArtists(TrackArtistLinkType::Producer, "Lms.Explore.Artists.linktype-producer");
+ addArtists(db::TrackArtistLinkType::Composer, "Lms.Explore.Artists.linktype-composer");
+ addArtists(db::TrackArtistLinkType::Conductor, "Lms.Explore.Artists.linktype-conductor");
+ addArtists(db::TrackArtistLinkType::Lyricist, "Lms.Explore.Artists.linktype-lyricist");
+ addArtists(db::TrackArtistLinkType::Mixer, "Lms.Explore.Artists.linktype-mixer");
+ addArtists(db::TrackArtistLinkType::Remixer, "Lms.Explore.Artists.linktype-remixer");
+ addArtists(db::TrackArtistLinkType::Producer, "Lms.Explore.Artists.linktype-producer");
addPerformerArtists();
if (auto itRolelessPerformers{ artistMap.find("") }; itRolelessPerformers != std::cend(artistMap))
@@ -105,7 +103,7 @@ namespace lms::ui::TrackListHelpers
{
auto transaction{ LmsApp->getDbSession().createReadTransaction() };
- const db::Track::pointer track{ Track::find(LmsApp->getDbSession(), trackId) };
+ const db::Track::pointer track{ db::Track::find(LmsApp->getDbSession(), trackId) };
if (!track)
return;
@@ -113,7 +111,7 @@ namespace lms::ui::TrackListHelpers
Wt::WWidget* trackInfoPtr{ trackInfo.get() };
trackInfo->addFunction("tr", &Wt::WTemplate::Functions::tr);
- std::map> artistMap{ getArtistsByRole(trackId) };
+ std::map> artistMap{ getArtistsByRole(trackId) };
if (!artistMap.empty())
{
trackInfo->setCondition("if-has-artist", true);
@@ -219,10 +217,10 @@ namespace lms::ui::TrackListHelpers
entry->bindString("name", Wt::WString::fromUTF8(track->getName()), Wt::TextFormat::Plain);
- const Release::pointer release{ track->getRelease() };
- const TrackId trackId{ track->getId() };
+ const db::Release::pointer release{ track->getRelease() };
+ const db::TrackId trackId{ track->getId() };
- const auto artists{ track->getArtistIds({ TrackArtistLinkType::Artist }) };
+ const auto artists{ track->getArtistIds({ db::TrackArtistLinkType::Artist }) };
if (!artists.empty())
{
entry->setCondition("if-has-artists", true);
diff --git a/src/lms/ui/explore/TrackListsView.cpp b/src/lms/ui/explore/TrackListsView.cpp
index 7d49ae7b..4ed2bf22 100644
--- a/src/lms/ui/explore/TrackListsView.cpp
+++ b/src/lms/ui/explore/TrackListsView.cpp
@@ -35,8 +35,6 @@
namespace lms::ui
{
- using namespace db;
-
TrackLists::TrackLists(Filters& filters)
: Template{ Wt::WString::tr("Lms.Explore.TrackLists.template") }
, _filters{ filters }
@@ -111,17 +109,17 @@ namespace lms::ui
void TrackLists::addSome()
{
- const Range range{ static_cast(_container->getCount()), _batchSize };
+ const db::Range range{ static_cast(_container->getCount()), _batchSize };
- Session& session{ LmsApp->getDbSession() };
+ db::Session& session{ LmsApp->getDbSession() };
auto transaction{ session.createReadTransaction() };
- TrackList::FindParameters params;
+ db::TrackList::FindParameters params;
if (!_searchText.empty())
params.setKeywords(core::stringUtils::splitString(_searchText, ' '));
params.setFilters(_filters.getDbFilters());
- params.setType(TrackListType::PlayList);
+ params.setType(db::TrackListType::PlayList);
params.setRange(range);
switch (_type)
@@ -139,26 +137,26 @@ namespace lms::ui
switch (_sortMode)
{
case SortMode::All:
- params.setSortMethod(TrackListSortMethod::Name);
+ params.setSortMethod(db::TrackListSortMethod::Name);
break;
case SortMode::RecentlyModified:
- params.setSortMethod(TrackListSortMethod::LastModifiedDesc);
+ params.setSortMethod(db::TrackListSortMethod::LastModifiedDesc);
break;
}
- const auto trackListIds{ TrackList::find(session, params) };
- for (const TrackListId trackListId : trackListIds.results)
+ const auto trackListIds{ db::TrackList::find(session, params) };
+ for (const db::TrackListId trackListId : trackListIds.results)
{
- if (const TrackList::pointer trackList{ TrackList::find(LmsApp->getDbSession(), trackListId) })
+ if (const db::TrackList::pointer trackList{ db::TrackList::find(LmsApp->getDbSession(), trackListId) })
addTracklist(trackList);
}
_container->setHasMore(trackListIds.moreResults);
}
- void TrackLists::addTracklist(const ObjectPtr& trackList)
+ void TrackLists::addTracklist(const db::ObjectPtr& trackList)
{
- const TrackListId trackListId{ trackList->getId() };
+ const db::TrackListId trackListId{ trackList->getId() };
WTemplate* entry{ _container->addNew(Wt::WString::tr("Lms.Explore.TrackLists.template.entry")) };
entry->bindWidget("name", utils::createTrackListAnchor(trackList));
diff --git a/src/lms/ui/explore/TrackListsView.hpp b/src/lms/ui/explore/TrackListsView.hpp
index 71ebf6ad..37cf3f40 100644
--- a/src/lms/ui/explore/TrackListsView.hpp
+++ b/src/lms/ui/explore/TrackListsView.hpp
@@ -71,7 +71,6 @@ namespace lms::ui
Type _type{ _defaultType };
std::string _searchText;
Filters& _filters;
- Wt::WWidget* _currentActiveItem{};
InfiniteScrollingContainer* _container{};
std::unordered_map _trackListWidgets;
};
diff --git a/src/lms/ui/resource/ArtworkResource.cpp b/src/lms/ui/resource/ArtworkResource.cpp
index fb550db5..1e5951b2 100644
--- a/src/lms/ui/resource/ArtworkResource.cpp
+++ b/src/lms/ui/resource/ArtworkResource.cpp
@@ -37,7 +37,7 @@
#include "LmsApplication.hpp"
-#define LOG(severity, message) LMS_LOG(UI, severity, "Image resource: " << message)
+#define ARTWORK_RESOURCE_LOG(severity, message) LMS_LOG(UI, severity, "Image resource: " << message)
namespace lms::ui
{
@@ -190,7 +190,7 @@ namespace lms::ui
const auto size{ sizeStr ? core::stringUtils::readAs(*sizeStr) : std::nullopt };
if (size && *size > maxSize)
{
- LOG(DEBUG, "invalid size provided!");
+ ARTWORK_RESOURCE_LOG(DEBUG, "invalid size provided!");
return;
}
diff --git a/src/lms/ui/resource/AudioFileResource.cpp b/src/lms/ui/resource/AudioFileResource.cpp
index cefc5ea7..2ab9d51d 100644
--- a/src/lms/ui/resource/AudioFileResource.cpp
+++ b/src/lms/ui/resource/AudioFileResource.cpp
@@ -32,7 +32,7 @@
namespace lms::ui
{
-#define LOG(severity, message) LMS_LOG(UI, severity, "Audio file resource: " << message)
+#define AUDIO_RESOURCE_LOG(severity, message) LMS_LOG(UI, severity, "Audio file resource: " << message)
namespace
{
@@ -43,7 +43,7 @@ namespace lms::ui
const db::Track::pointer track{ db::Track::find(LmsApp->getDbSession(), trackId) };
if (!track)
{
- LOG(ERROR, "Missing track");
+ AUDIO_RESOURCE_LOG(ERROR, "Missing track");
return std::nullopt;
}
@@ -55,14 +55,14 @@ namespace lms::ui
const std::string* trackIdParameter{ request.getParameter("trackid") };
if (!trackIdParameter)
{
- LOG(ERROR, "Missing trackid URL parameter!");
+ AUDIO_RESOURCE_LOG(ERROR, "Missing trackid URL parameter!");
return std::nullopt;
}
const std::optional trackId{ core::stringUtils::readAs(*trackIdParameter) };
if (!trackId)
{
- LOG(ERROR, "Bad trackid URL parameter!");
+ AUDIO_RESOURCE_LOG(ERROR, "Bad trackid URL parameter!");
return std::nullopt;
}
diff --git a/src/lms/ui/resource/AudioTranscodingResource.cpp b/src/lms/ui/resource/AudioTranscodingResource.cpp
index 558ce55e..37498a47 100644
--- a/src/lms/ui/resource/AudioTranscodingResource.cpp
+++ b/src/lms/ui/resource/AudioTranscodingResource.cpp
@@ -34,7 +34,7 @@
#include "LmsApplication.hpp"
-#define LOG(severity, message) LMS_LOG(UI, severity, "Audio transcode resource: " << message)
+#define TRANSCODE_LOG(severity, message) LMS_LOG(UI, severity, "Audio transcode resource: " << message)
namespace lms::core::stringUtils
{
@@ -62,7 +62,7 @@ namespace lms::core::stringUtils
return format;
}
- LOG(ERROR, "Cannot determine audio format from value '" << str << "'");
+ TRANSCODE_LOG(ERROR, "Cannot determine audio format from value '" << str << "'");
return std::nullopt;
}
@@ -88,7 +88,7 @@ namespace lms::ui
return av::transcoding::OutputFormat::WEBM_VORBIS;
}
- LOG(ERROR, "Cannot convert from audio format to AV format");
+ TRANSCODE_LOG(ERROR, "Cannot convert from audio format to AV format");
return std::nullopt;
}
@@ -99,13 +99,13 @@ namespace lms::ui
auto paramStr{ request.getParameter(parameterName) };
if (!paramStr)
{
- LOG(DEBUG, "Missing parameter '" << parameterName << "'");
+ TRANSCODE_LOG(DEBUG, "Missing parameter '" << parameterName << "'");
return std::nullopt;
}
auto res{ core::stringUtils::readAs(*paramStr) };
if (!res)
- LOG(ERROR, "Cannot parse parameter '" << parameterName << "' from value '" << *paramStr << "'");
+ TRANSCODE_LOG(ERROR, "Cannot parse parameter '" << parameterName << "' from value '" << *paramStr << "'");
return res;
}
@@ -130,7 +130,7 @@ namespace lms::ui
if (!db::isAudioBitrateAllowed(*bitrate))
{
- LOG(ERROR, "Bitrate '" << *bitrate << "' is not allowed");
+ TRANSCODE_LOG(ERROR, "Bitrate '" << *bitrate << "' is not allowed");
return std::nullopt;
}
@@ -148,7 +148,7 @@ namespace lms::ui
const db::Track::pointer track{ db::Track::find(LmsApp->getDbSession(), *trackId) };
if (!track)
{
- LOG(ERROR, "Missing track");
+ TRANSCODE_LOG(ERROR, "Missing track");
return std::nullopt;
}
@@ -201,7 +201,7 @@ namespace lms::ui
}
catch (const av::Exception& e)
{
- LOG(ERROR, "Caught Av exception: " << e.what());
+ TRANSCODE_LOG(ERROR, "Caught Av exception: " << e.what());
}
}
diff --git a/src/lms/ui/resource/DownloadResource.cpp b/src/lms/ui/resource/DownloadResource.cpp
index ec64147b..3dec9d7f 100644
--- a/src/lms/ui/resource/DownloadResource.cpp
+++ b/src/lms/ui/resource/DownloadResource.cpp
@@ -31,7 +31,7 @@
#include "LmsApplication.hpp"
-#define LOG(severity, message) LMS_LOG(UI, severity, "Download resource: " << message)
+#define DL_RESOURCE_LOG(severity, message) LMS_LOG(UI, severity, "Download resource: " << message)
namespace lms::ui
{
@@ -71,7 +71,7 @@ namespace lms::ui
}
catch (zip::Exception& exception)
{
- LOG(ERROR, "Zipper exception: " << exception.what());
+ DL_RESOURCE_LOG(ERROR, "Zipper exception: " << exception.what());
}
}
@@ -220,7 +220,7 @@ namespace lms::ui
const db::Track::pointer track{ db::Track::find(LmsApp->getDbSession(), _trackId) };
if (!track)
{
- LOG(DEBUG, "Cannot find track");
+ DL_RESOURCE_LOG(DEBUG, "Cannot find track");
return {};
}