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
+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);
}