Reduce database include dependencies
This commit is contained in:
@@ -45,7 +45,7 @@ static std::string escape(const std::string& str)
|
||||
}
|
||||
|
||||
void
|
||||
MediaPlayer::playTrack(Database::Track::id_type trackId)
|
||||
MediaPlayer::playTrack(Database::IdType trackId)
|
||||
{
|
||||
LMS_LOG(UI, DEBUG) << "Playing track ID = " << trackId;
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ class MediaPlayer : public Wt::WTemplate
|
||||
MediaPlayer();
|
||||
|
||||
void stop();
|
||||
void playTrack(Database::Track::id_type);
|
||||
void playTrack(Database::IdType trackId);
|
||||
|
||||
// Signals
|
||||
Wt::JSignal<> playbackEnded;
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
|
||||
#include "utils/Logger.hpp"
|
||||
|
||||
#include "database/Playlist.hpp"
|
||||
|
||||
#include "LmsApplication.hpp"
|
||||
#include "PlayQueueView.hpp"
|
||||
|
||||
@@ -91,7 +93,7 @@ PlayQueue::play(std::size_t pos)
|
||||
{
|
||||
updateCurrentTrack(false);
|
||||
|
||||
Database::Track::id_type trackId;
|
||||
Database::IdType trackId;
|
||||
{
|
||||
Wt::Dbo::Transaction transaction(LmsApp->getDboSession());
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
#include "database/Types.hpp"
|
||||
#include "database/Track.hpp"
|
||||
|
||||
namespace UserInterface {
|
||||
|
||||
@@ -45,7 +45,7 @@ class PlayQueue : public Wt::WTemplate
|
||||
void playPrevious();
|
||||
|
||||
// Signal emitted when a track is to be played
|
||||
Wt::Signal<Database::Track::id_type> playTrack;
|
||||
Wt::Signal<Database::IdType> playTrack;
|
||||
|
||||
// Signal emitted when play has to be stopped
|
||||
Wt::Signal<> playbackStop;
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#include <Wt/WTemplate.h>
|
||||
#include <Wt/WPushButton.h>
|
||||
|
||||
#include "database/Types.hpp"
|
||||
#include "database/User.hpp"
|
||||
#include "utils/Logger.hpp"
|
||||
|
||||
#include "LmsApplication.hpp"
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
#include <Wt/WTemplate.h>
|
||||
#include <Wt/WText.h>
|
||||
|
||||
#include "database/DbArtist.hpp"
|
||||
#include "database/Setting.hpp"
|
||||
#include "database/Types.hpp"
|
||||
|
||||
#include "utils/Logger.hpp"
|
||||
#include "utils/Utils.hpp"
|
||||
@@ -92,7 +92,7 @@ Artist::refresh()
|
||||
|
||||
clear();
|
||||
|
||||
auto artistId = readAs<Database::Artist::id_type>(wApp->internalPathNextPart("/artist/"));
|
||||
auto artistId = readAs<Database::IdType>(wApp->internalPathNextPart("/artist/"));
|
||||
if (!artistId)
|
||||
return;
|
||||
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
#include <Wt/WContainerWidget.h>
|
||||
#include <Wt/WSignal.h>
|
||||
|
||||
#include "database/Types.hpp"
|
||||
|
||||
namespace UserInterface {
|
||||
|
||||
class Filters;
|
||||
@@ -31,11 +33,11 @@ class Artist : public Wt::WContainerWidget
|
||||
public:
|
||||
Artist(Filters* filters);
|
||||
|
||||
Wt::Signal<Database::id_type> artistAdd;
|
||||
Wt::Signal<Database::id_type> artistPlay;
|
||||
Wt::Signal<Database::IdType> artistAdd;
|
||||
Wt::Signal<Database::IdType> artistPlay;
|
||||
|
||||
Wt::Signal<Database::id_type> releaseAdd;
|
||||
Wt::Signal<Database::id_type> releasePlay;
|
||||
Wt::Signal<Database::IdType> releaseAdd;
|
||||
Wt::Signal<Database::IdType> releasePlay;
|
||||
|
||||
private:
|
||||
void refresh();
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
#include <Wt/WTemplate.h>
|
||||
#include <Wt/WLineEdit.h>
|
||||
|
||||
#include "database/DbArtist.hpp"
|
||||
#include "database/Setting.hpp"
|
||||
#include "database/Types.hpp"
|
||||
|
||||
#include "utils/Logger.hpp"
|
||||
#include "utils/Utils.hpp"
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
#include <Wt/WLineEdit.h>
|
||||
#include <Wt/WSignal.h>
|
||||
|
||||
#include "database/Types.hpp"
|
||||
|
||||
namespace UserInterface {
|
||||
|
||||
class Filters;
|
||||
@@ -33,8 +35,8 @@ class Artists : public Wt::WTemplate
|
||||
public:
|
||||
Artists(Filters* filters);
|
||||
|
||||
Wt::Signal<Database::id_type> artistAdd;
|
||||
Wt::Signal<Database::id_type> artistPlay;
|
||||
Wt::Signal<Database::IdType> artistAdd;
|
||||
Wt::Signal<Database::IdType> artistPlay;
|
||||
|
||||
private:
|
||||
void refresh();
|
||||
|
||||
@@ -118,7 +118,7 @@ Explore::Explore()
|
||||
}
|
||||
|
||||
// TODO SQL this?
|
||||
static std::vector<Database::Track::pointer> getArtistTracks(Wt::Dbo::Session& session, Database::id_type artistId, std::set<Database::id_type> clusters)
|
||||
static std::vector<Database::Track::pointer> getArtistTracks(Wt::Dbo::Session& session, Database::IdType artistId, std::set<Database::IdType> clusters)
|
||||
{
|
||||
std::vector<Database::Track::pointer> res;
|
||||
|
||||
@@ -140,7 +140,7 @@ static std::vector<Database::Track::pointer> getArtistTracks(Wt::Dbo::Session& s
|
||||
return res;
|
||||
}
|
||||
|
||||
static std::vector<Database::Track::pointer> getReleaseTracks(Wt::Dbo::Session& session, Database::id_type releaseId, std::set<Database::id_type> clusters)
|
||||
static std::vector<Database::Track::pointer> getReleaseTracks(Wt::Dbo::Session& session, Database::IdType releaseId, std::set<Database::IdType> clusters)
|
||||
{
|
||||
std::vector<Database::Track::pointer> res;
|
||||
|
||||
@@ -151,7 +151,7 @@ static std::vector<Database::Track::pointer> getReleaseTracks(Wt::Dbo::Session&
|
||||
return release->getTracks(clusters);
|
||||
}
|
||||
|
||||
static std::vector<Database::Track::pointer> getTrack(Wt::Dbo::Session& session, Database::id_type trackId)
|
||||
static std::vector<Database::Track::pointer> getTrack(Wt::Dbo::Session& session, Database::IdType trackId)
|
||||
{
|
||||
std::vector<Database::Track::pointer> res;
|
||||
|
||||
@@ -163,7 +163,7 @@ static std::vector<Database::Track::pointer> getTrack(Wt::Dbo::Session& session,
|
||||
}
|
||||
|
||||
void
|
||||
Explore::handleArtistAdd(Database::id_type id)
|
||||
Explore::handleArtistAdd(Database::IdType id)
|
||||
{
|
||||
Wt::Dbo::Transaction transaction(LmsApp->getDboSession());
|
||||
|
||||
@@ -171,7 +171,7 @@ Explore::handleArtistAdd(Database::id_type id)
|
||||
}
|
||||
|
||||
void
|
||||
Explore::handleArtistPlay(Database::id_type id)
|
||||
Explore::handleArtistPlay(Database::IdType id)
|
||||
{
|
||||
Wt::Dbo::Transaction transaction(LmsApp->getDboSession());
|
||||
|
||||
@@ -179,7 +179,7 @@ Explore::handleArtistPlay(Database::id_type id)
|
||||
}
|
||||
|
||||
void
|
||||
Explore::handleReleaseAdd(Database::id_type id)
|
||||
Explore::handleReleaseAdd(Database::IdType id)
|
||||
{
|
||||
Wt::Dbo::Transaction transaction(LmsApp->getDboSession());
|
||||
|
||||
@@ -187,7 +187,7 @@ Explore::handleReleaseAdd(Database::id_type id)
|
||||
}
|
||||
|
||||
void
|
||||
Explore::handleReleasePlay(Database::id_type id)
|
||||
Explore::handleReleasePlay(Database::IdType id)
|
||||
{
|
||||
Wt::Dbo::Transaction transaction(LmsApp->getDboSession());
|
||||
|
||||
@@ -195,7 +195,7 @@ Explore::handleReleasePlay(Database::id_type id)
|
||||
}
|
||||
|
||||
void
|
||||
Explore::handleTrackAdd(Database::id_type id)
|
||||
Explore::handleTrackAdd(Database::IdType id)
|
||||
{
|
||||
Wt::Dbo::Transaction transaction(LmsApp->getDboSession());
|
||||
|
||||
@@ -203,7 +203,7 @@ Explore::handleTrackAdd(Database::id_type id)
|
||||
}
|
||||
|
||||
void
|
||||
Explore::handleTrackPlay(Database::id_type id)
|
||||
Explore::handleTrackPlay(Database::IdType id)
|
||||
{
|
||||
Wt::Dbo::Transaction transaction(LmsApp->getDboSession());
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
#include <Wt/WTemplate.h>
|
||||
|
||||
#include "database/Track.hpp"
|
||||
#include "database/Types.hpp"
|
||||
|
||||
namespace UserInterface {
|
||||
@@ -37,12 +38,12 @@ class Explore : public Wt::WTemplate
|
||||
|
||||
private:
|
||||
|
||||
void handleArtistAdd(Database::Artist::id_type id);
|
||||
void handleArtistPlay(Database::Artist::id_type id);
|
||||
void handleReleaseAdd(Database::Release::id_type id);
|
||||
void handleReleasePlay(Database::Release::id_type id);
|
||||
void handleTrackAdd(Database::Track::id_type id);
|
||||
void handleTrackPlay(Database::Track::id_type id);
|
||||
void handleArtistAdd(Database::IdType id);
|
||||
void handleArtistPlay(Database::IdType id);
|
||||
void handleReleaseAdd(Database::IdType id);
|
||||
void handleReleasePlay(Database::IdType id);
|
||||
void handleTrackAdd(Database::IdType id);
|
||||
void handleTrackPlay(Database::IdType id);
|
||||
void handleTracksAdd(std::vector<Database::Track::pointer> tracks);
|
||||
void handleTracksPlay(std::vector<Database::Track::pointer> tracks);
|
||||
|
||||
|
||||
@@ -116,7 +116,7 @@ Filters::showDialog()
|
||||
}
|
||||
|
||||
void
|
||||
Filters::add(Database::Cluster::id_type clusterId)
|
||||
Filters::add(Database::IdType clusterId)
|
||||
{
|
||||
Wt::Dbo::Transaction transaction(LmsApp->getDboSession());
|
||||
|
||||
|
||||
@@ -34,9 +34,9 @@ class Filters : public Wt::WTemplate
|
||||
public:
|
||||
Filters();
|
||||
|
||||
void add(Database::Cluster::id_type clusterId);
|
||||
void add(Database::IdType clusterId);
|
||||
|
||||
std::set<Database::Cluster::id_type> getClusterIds() const { return _filterIds; }
|
||||
std::set<Database::IdType> getClusterIds() const { return _filterIds; }
|
||||
|
||||
Wt::Signal<>& updated() { return _sigUpdated; }
|
||||
|
||||
@@ -46,7 +46,7 @@ class Filters : public Wt::WTemplate
|
||||
|
||||
Wt::WContainerWidget *_filters;
|
||||
Wt::Signal<> _sigUpdated;
|
||||
std::set<Database::Cluster::id_type> _filterIds;
|
||||
std::set<Database::IdType> _filterIds;
|
||||
};
|
||||
|
||||
} // namespace UserInterface
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include <Wt/WTemplate.h>
|
||||
#include <Wt/WText.h>
|
||||
|
||||
#include "database/Types.hpp"
|
||||
#include "database/Release.hpp"
|
||||
#include "database/Setting.hpp"
|
||||
|
||||
#include "utils/Logger.hpp"
|
||||
@@ -92,7 +92,7 @@ Release::refresh()
|
||||
|
||||
clear();
|
||||
|
||||
auto releaseId = readAs<Database::Release::id_type>(wApp->internalPathNextPart("/release/"));
|
||||
auto releaseId = readAs<Database::IdType>(wApp->internalPathNextPart("/release/"));
|
||||
if (!releaseId)
|
||||
return;
|
||||
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
|
||||
#include <Wt/WSignal.h>
|
||||
|
||||
#include "database/Types.hpp"
|
||||
|
||||
namespace UserInterface {
|
||||
|
||||
class Filters;
|
||||
@@ -29,11 +31,11 @@ class Release : public Wt::WContainerWidget
|
||||
public:
|
||||
Release(Filters* filters);
|
||||
|
||||
Wt::Signal<Database::id_type> releaseAdd;
|
||||
Wt::Signal<Database::id_type> releasePlay;
|
||||
Wt::Signal<Database::IdType> releaseAdd;
|
||||
Wt::Signal<Database::IdType> releasePlay;
|
||||
|
||||
Wt::Signal<Database::id_type> trackAdd;
|
||||
Wt::Signal<Database::id_type> trackPlay;
|
||||
Wt::Signal<Database::IdType> trackAdd;
|
||||
Wt::Signal<Database::IdType> trackPlay;
|
||||
|
||||
private:
|
||||
void refresh();
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include <Wt/WText.h>
|
||||
#include <Wt/WTemplate.h>
|
||||
|
||||
#include "database/Types.hpp"
|
||||
#include "database/Release.hpp"
|
||||
|
||||
#include "utils/Logger.hpp"
|
||||
#include "utils/Utils.hpp"
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
#include <Wt/WText.h>
|
||||
#include <Wt/WTemplate.h>
|
||||
|
||||
#include "database/Types.hpp"
|
||||
|
||||
namespace UserInterface {
|
||||
|
||||
class Filters;
|
||||
@@ -33,8 +35,8 @@ class Releases : public Wt::WTemplate
|
||||
public:
|
||||
Releases(Filters* filters);
|
||||
|
||||
Wt::Signal<Database::id_type> releaseAdd;
|
||||
Wt::Signal<Database::id_type> releasePlay;
|
||||
Wt::Signal<Database::IdType> releaseAdd;
|
||||
Wt::Signal<Database::IdType> releasePlay;
|
||||
|
||||
private:
|
||||
void refresh();
|
||||
|
||||
@@ -22,7 +22,9 @@
|
||||
#include <Wt/WLineEdit.h>
|
||||
#include <Wt/WText.h>
|
||||
|
||||
#include "database/Types.hpp"
|
||||
#include "database/DbArtist.hpp"
|
||||
#include "database/Track.hpp"
|
||||
#include "database/Release.hpp"
|
||||
|
||||
#include "utils/Logger.hpp"
|
||||
#include "utils/Utils.hpp"
|
||||
|
||||
@@ -23,6 +23,9 @@
|
||||
#include <Wt/WLineEdit.h>
|
||||
#include <Wt/WTemplate.h>
|
||||
|
||||
#include "database/Types.hpp"
|
||||
#include "database/Track.hpp"
|
||||
|
||||
namespace UserInterface {
|
||||
|
||||
class Filters;
|
||||
@@ -31,8 +34,8 @@ class Tracks : public Wt::WTemplate
|
||||
public:
|
||||
Tracks(Filters* filters);
|
||||
|
||||
Wt::Signal<Database::id_type> trackAdd;
|
||||
Wt::Signal<Database::id_type> trackPlay;
|
||||
Wt::Signal<Database::IdType> trackAdd;
|
||||
Wt::Signal<Database::IdType> trackPlay;
|
||||
|
||||
Wt::Signal<std::vector<Database::Track::pointer>> tracksAdd;
|
||||
Wt::Signal<std::vector<Database::Track::pointer>> tracksPlay;
|
||||
|
||||
@@ -90,19 +90,19 @@ ImageResource::getDefaultArtistImage(std::size_t size)
|
||||
}
|
||||
|
||||
std::string
|
||||
ImageResource::getReleaseUrl(Database::Release::id_type releaseId, std::size_t size) const
|
||||
ImageResource::getReleaseUrl(Database::IdType releaseId, std::size_t size) const
|
||||
{
|
||||
return url() + "&releaseid=" + std::to_string(releaseId) + "&size=" + std::to_string(size);
|
||||
}
|
||||
|
||||
std::string
|
||||
ImageResource::getTrackUrl(Database::Track::id_type trackId, std::size_t size) const
|
||||
ImageResource::getTrackUrl(Database::IdType trackId, std::size_t size) const
|
||||
{
|
||||
return url() + "&trackid=" + std::to_string(trackId) + "&size=" + std::to_string(size);
|
||||
}
|
||||
|
||||
std::string
|
||||
ImageResource::getArtistUrl(Database::Artist::id_type artistId, std::size_t size) const
|
||||
ImageResource::getArtistUrl(Database::IdType artistId, std::size_t size) const
|
||||
{
|
||||
return url() + "&artistid=" + std::to_string(artistId) + "&size=" + std::to_string(size);
|
||||
}
|
||||
@@ -159,7 +159,7 @@ ImageResource::handleRequest(const Wt::Http::Request& request, Wt::Http::Respons
|
||||
|
||||
if (trackIdStr)
|
||||
{
|
||||
auto trackId = readAs<Database::Track::id_type>(*trackIdStr);
|
||||
auto trackId = readAs<Database::IdType>(*trackIdStr);
|
||||
if (!trackId)
|
||||
return;
|
||||
|
||||
@@ -202,7 +202,7 @@ ImageResource::handleRequest(const Wt::Http::Request& request, Wt::Http::Respons
|
||||
}
|
||||
else if (releaseIdStr)
|
||||
{
|
||||
auto releaseId = readAs<Database::Release::id_type>(*releaseIdStr);
|
||||
auto releaseId = readAs<Database::IdType>(*releaseIdStr);
|
||||
if (!releaseId)
|
||||
return;
|
||||
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
#include <Wt/WResource.h>
|
||||
|
||||
#include "database/DatabaseHandler.hpp"
|
||||
#include "database/Types.hpp"
|
||||
|
||||
#include "image/Image.hpp"
|
||||
|
||||
namespace UserInterface {
|
||||
@@ -38,9 +40,9 @@ class ImageResource : public Wt::WResource
|
||||
ImageResource(Database::Handler& db);
|
||||
~ImageResource();
|
||||
|
||||
std::string getReleaseUrl(Database::Release::id_type releaseId, size_t size) const;
|
||||
std::string getTrackUrl(Database::Track::id_type trackId, size_t size) const;
|
||||
std::string getArtistUrl(Database::Artist::id_type artistId, size_t size) const;
|
||||
std::string getReleaseUrl(Database::IdType releaseId, size_t size) const;
|
||||
std::string getTrackUrl(Database::IdType trackId, size_t size) const;
|
||||
std::string getArtistUrl(Database::IdType artistId, size_t size) const;
|
||||
std::string getUnknownTrackUrl(size_t size) const;
|
||||
|
||||
void handleRequest(const Wt::Http::Request& request, Wt::Http::Response& response);
|
||||
|
||||
@@ -40,7 +40,7 @@ TranscodeResource:: ~TranscodeResource()
|
||||
}
|
||||
|
||||
std::string
|
||||
TranscodeResource::getUrl(Database::Track::id_type trackId, Av::Encoding encoding) const
|
||||
TranscodeResource::getUrl(Database::IdType trackId, Av::Encoding encoding) const
|
||||
{
|
||||
std::string res = url()+ "&trackid=" + std::to_string(trackId) + "&encoding=" + std::to_string(Av::encodingToInt(encoding));
|
||||
|
||||
@@ -64,7 +64,7 @@ TranscodeResource::handleRequest(const Wt::Http::Request& request,
|
||||
}
|
||||
else
|
||||
{
|
||||
Database::Track::id_type trackId;
|
||||
Database::IdType trackId;
|
||||
Av::TranscodeParameters parameters;
|
||||
|
||||
LMS_LOG(UI, DEBUG) << "No continuation yet";
|
||||
|
||||
@@ -26,6 +26,8 @@
|
||||
#include "av/AvTranscoder.hpp"
|
||||
|
||||
#include "database/DatabaseHandler.hpp"
|
||||
#include "database/Types.hpp"
|
||||
|
||||
|
||||
namespace UserInterface {
|
||||
|
||||
@@ -35,7 +37,7 @@ class TranscodeResource : public Wt::WResource
|
||||
TranscodeResource(Database::Handler& db);
|
||||
~TranscodeResource();
|
||||
|
||||
std::string getUrl(Database::Track::id_type trackId, Av::Encoding encoding) const;
|
||||
std::string getUrl(Database::IdType trackId, Av::Encoding encoding) const;
|
||||
|
||||
void handleRequest(const Wt::Http::Request& request,
|
||||
Wt::Http::Response& response);
|
||||
|
||||
Reference in New Issue
Block a user