Reduce database include dependencies

This commit is contained in:
emeric
2018-05-16 13:47:00 +02:00
parent 7e6bf57e75
commit 9a44fb838d
43 changed files with 179 additions and 135 deletions
+7 -2
View File
@@ -17,8 +17,13 @@
* along with LMS. If not, see <http://www.gnu.org/licenses/>. * along with LMS. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <boost/filesystem.hpp>
#include "av/AvInfo.hpp" #include "av/AvInfo.hpp"
#include "database/Release.hpp"
#include "database/Track.hpp"
#include "utils/Logger.hpp" #include "utils/Logger.hpp"
#include "CoverArtGrabber.hpp" #include "CoverArtGrabber.hpp"
@@ -145,7 +150,7 @@ Grabber::getFromTrack(const boost::filesystem::path& p, std::size_t nbMaxCovers)
} }
std::vector<Image::Image> std::vector<Image::Image>
Grabber::getFromTrack(Wt::Dbo::Session& session, Database::Track::id_type trackId, std::size_t nbMaxCovers) const Grabber::getFromTrack(Wt::Dbo::Session& session, Database::IdType trackId, std::size_t nbMaxCovers) const
{ {
using namespace Database; using namespace Database;
@@ -173,7 +178,7 @@ Grabber::getFromTrack(Wt::Dbo::Session& session, Database::Track::id_type trackI
std::vector<Image::Image> std::vector<Image::Image>
Grabber::getFromRelease(Wt::Dbo::Session& session, Database::Release::id_type releaseId, std::size_t nbMaxCovers) const Grabber::getFromRelease(Wt::Dbo::Session& session, Database::IdType releaseId, std::size_t nbMaxCovers) const
{ {
using namespace Database; using namespace Database;
+2 -2
View File
@@ -38,8 +38,8 @@ class Grabber
std::vector<boost::filesystem::path> getCoverPaths(const boost::filesystem::path& directoryPath, std::size_t nbMaxCovers = 1) const; std::vector<boost::filesystem::path> getCoverPaths(const boost::filesystem::path& directoryPath, std::size_t nbMaxCovers = 1) const;
std::vector<Image::Image> getFromDirectory(const boost::filesystem::path& path, std::size_t nbMaxCovers = 1) const; std::vector<Image::Image> getFromDirectory(const boost::filesystem::path& path, std::size_t nbMaxCovers = 1) const;
std::vector<Image::Image> getFromTrack(const boost::filesystem::path& path, std::size_t nbMaxCovers = 1) const; std::vector<Image::Image> getFromTrack(const boost::filesystem::path& path, std::size_t nbMaxCovers = 1) const;
std::vector<Image::Image> getFromTrack(Wt::Dbo::Session& session, Database::Track::id_type trackId, std::size_t nbMaxCovers = 1) const; std::vector<Image::Image> getFromTrack(Wt::Dbo::Session& session, Database::IdType trackId, std::size_t nbMaxCovers = 1) const;
std::vector<Image::Image> getFromRelease(Wt::Dbo::Session& session, Database::Release::id_type releaseId, std::size_t nbMaxCovers = 1) const; std::vector<Image::Image> getFromRelease(Wt::Dbo::Session& session, Database::IdType releaseId, std::size_t nbMaxCovers = 1) const;
private: private:
Grabber(); Grabber();
+6
View File
@@ -33,6 +33,12 @@
#include "utils/Logger.hpp" #include "utils/Logger.hpp"
#include "DbArtist.hpp"
#include "MediaDirectory.hpp"
#include "Playlist.hpp"
#include "Release.hpp"
#include "Track.hpp"
#include "DatabaseHandler.hpp" #include "DatabaseHandler.hpp"
namespace Database { namespace Database {
+3 -6
View File
@@ -17,8 +17,7 @@
* along with LMS. If not, see <http://www.gnu.org/licenses/>. * along with LMS. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef DATABASE_HANDLER_HPP #pragma once
#define DATABASE_HANDLER_HPP
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>
#include <memory> #include <memory>
@@ -30,12 +29,11 @@
#include <Wt/Auth/Login.h> #include <Wt/Auth/Login.h>
#include <Wt/Auth/PasswordService.h> #include <Wt/Auth/PasswordService.h>
#include "Types.hpp" #include "User.hpp"
namespace Database { namespace Database {
typedef Wt::Dbo::dbo_default_traits::IdType id_type; using UserDatabase = Wt::Auth::Dbo::UserDatabase<AuthInfo>;
typedef Wt::Auth::Dbo::UserDatabase<AuthInfo> UserDatabase;
// Session living class handling the database and the login // Session living class handling the database and the login
class Handler class Handler
@@ -72,5 +70,4 @@ class Handler
} // namespace Database } // namespace Database
#endif
+9 -6
View File
@@ -17,11 +17,14 @@
* along with LMS. If not, see <http://www.gnu.org/licenses/>. * along with LMS. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "Types.hpp"
#include "SqlQuery.hpp" #include "SqlQuery.hpp"
#include "utils/Logger.hpp" #include "utils/Logger.hpp"
#include "Release.hpp"
#include "DbArtist.hpp"
#include "Track.hpp"
namespace Database namespace Database
{ {
@@ -46,7 +49,7 @@ Artist::getByMBID(Wt::Dbo::Session& session, const std::string& mbid)
} }
Artist::pointer Artist::pointer
Artist::getById(Wt::Dbo::Session& session, Artist::id_type id) Artist::getById(Wt::Dbo::Session& session, IdType id)
{ {
return session.find<Artist>().where("id = ?").bind(id); return session.find<Artist>().where("id = ?").bind(id);
} }
@@ -75,7 +78,7 @@ Artist::getAllOrphans(Wt::Dbo::Session& session)
static static
Wt::Dbo::Query<Artist::pointer> Wt::Dbo::Query<Artist::pointer>
getQuery(Wt::Dbo::Session& session, getQuery(Wt::Dbo::Session& session,
const std::set<Artist::id_type>& clusterIds, const std::set<IdType>& clusterIds,
const std::vector<std::string>& keywords) const std::vector<std::string>& keywords)
{ {
WhereClause where; WhereClause where;
@@ -116,7 +119,7 @@ getQuery(Wt::Dbo::Session& session,
std::vector<Artist::pointer> std::vector<Artist::pointer>
Artist::getByFilter(Wt::Dbo::Session& session, Artist::getByFilter(Wt::Dbo::Session& session,
const std::set<id_type>& clusters, const std::set<IdType>& clusters,
const std::vector<std::string> keywords, const std::vector<std::string> keywords,
int offset, int size, bool& moreResults) int offset, int size, bool& moreResults)
{ {
@@ -138,7 +141,7 @@ Artist::getByFilter(Wt::Dbo::Session& session,
} }
std::vector<Wt::Dbo::ptr<Release>> std::vector<Wt::Dbo::ptr<Release>>
Artist::getReleases(const std::set<id_type>& clusterIds) const Artist::getReleases(const std::set<IdType>& clusterIds) const
{ {
assert(self()); assert(self());
assert(self()->id() != Wt::Dbo::dbo_traits<Artist>::invalidId() ); assert(self()->id() != Wt::Dbo::dbo_traits<Artist>::invalidId() );
@@ -212,7 +215,7 @@ Artist::getClusterGroups(std::vector<ClusterType::pointer> clusterTypes, std::si
Wt::Dbo::collection<Cluster::pointer> queryRes = query; Wt::Dbo::collection<Cluster::pointer> queryRes = query;
std::map<ClusterType::id_type, std::vector<Cluster::pointer>> clusters; std::map<IdType, std::vector<Cluster::pointer>> clusters;
for (auto cluster : queryRes) for (auto cluster : queryRes)
{ {
if (clusters[cluster->getType().id()].size() < size) if (clusters[cluster->getType().id()].size() < size)
+6 -7
View File
@@ -17,8 +17,7 @@
* along with LMS. If not, see <http://www.gnu.org/licenses/>. * along with LMS. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef _DB_ARTIST_HPP_ #pragma once
#define _DB_ARTIST_HPP_
#include <string> #include <string>
#include <vector> #include <vector>
@@ -26,6 +25,8 @@
#include <Wt/Dbo/Dbo.h> #include <Wt/Dbo/Dbo.h>
#include <Wt/Dbo/QueryModel.h> #include <Wt/Dbo/QueryModel.h>
#include "Types.hpp"
namespace Database namespace Database
{ {
@@ -39,17 +40,16 @@ class Artist : public Wt::Dbo::Dbo<Artist>
public: public:
typedef Wt::Dbo::ptr<Artist> pointer; typedef Wt::Dbo::ptr<Artist> pointer;
typedef Wt::Dbo::dbo_traits<Artist>::IdType id_type;
Artist() {} Artist() {}
Artist(const std::string& name, const std::string& MBID = ""); Artist(const std::string& name, const std::string& MBID = "");
// Accessors // Accessors
static pointer getByMBID(Wt::Dbo::Session& session, const std::string& MBID); static pointer getByMBID(Wt::Dbo::Session& session, const std::string& MBID);
static pointer getById(Wt::Dbo::Session& session, id_type id); static pointer getById(Wt::Dbo::Session& session, IdType id);
static std::vector<pointer> getByName(Wt::Dbo::Session& session, const std::string& name); static std::vector<pointer> getByName(Wt::Dbo::Session& session, const std::string& name);
static std::vector<pointer> getByFilter(Wt::Dbo::Session& session, static std::vector<pointer> getByFilter(Wt::Dbo::Session& session,
const std::set<id_type>& clusters, // at least one track that belongs to these clusters const std::set<IdType>& clusters, // at least one track that belongs to these clusters
const std::vector<std::string> keywords, // name must match all of these keywords const std::vector<std::string> keywords, // name must match all of these keywords
int offset, int offset,
int size, int size,
@@ -63,7 +63,7 @@ class Artist : public Wt::Dbo::Dbo<Artist>
std::string getMBID(void) const { return _MBID; } std::string getMBID(void) const { return _MBID; }
// Get the releases that have at least one track for this artist that belongs to optional cluster filters // Get the releases that have at least one track for this artist that belongs to optional cluster filters
std::vector<Wt::Dbo::ptr<Release>> getReleases(const std::set<id_type>& clusterIds = std::set<id_type>()) const; std::vector<Wt::Dbo::ptr<Release>> getReleases(const std::set<IdType>& clusterIds = std::set<IdType>()) const;
// Get the cluster of the tracks made by this artist // Get the cluster of the tracks made by this artist
// Each clusters are grouped by cluster type, sorted by the number of occurence // Each clusters are grouped by cluster type, sorted by the number of occurence
@@ -97,4 +97,3 @@ class Artist : public Wt::Dbo::Dbo<Artist>
} // namespace Database } // namespace Database
#endif
+1 -1
View File
@@ -19,7 +19,7 @@
#include "utils/Utils.hpp" #include "utils/Utils.hpp"
#include "Types.hpp" #include "MediaDirectory.hpp"
namespace Database { namespace Database {
+1 -4
View File
@@ -17,8 +17,7 @@
* along with LMS. If not, see <http://www.gnu.org/licenses/>. * along with LMS. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef DATABASE_MEDIA_DIRECTORY_HPP #pragma once
#define DATABASE_MEDIA_DIRECTORY_HPP
#include <vector> #include <vector>
@@ -59,5 +58,3 @@ class MediaDirectory
} // namespace Database } // namespace Database
#endif
+5 -1
View File
@@ -16,8 +16,12 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with LMS. If not, see <http://www.gnu.org/licenses/>. * along with LMS. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <cassert>
#include "Types.hpp" #include "User.hpp"
#include "Track.hpp"
#include "Playlist.hpp"
namespace Database { namespace Database {
+1 -3
View File
@@ -17,8 +17,7 @@
* along with LMS. If not, see <http://www.gnu.org/licenses/>. * along with LMS. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef DATABASE_PLAYLIST_HPP #pragma once
#define DATABASE_PLAYLIST_HPP
#include <Wt/Dbo/Dbo.h> #include <Wt/Dbo/Dbo.h>
@@ -108,4 +107,3 @@ class PlaylistEntry
} // namespace Database } // namespace Database
#endif
+10 -6
View File
@@ -17,9 +17,13 @@
* along with LMS. If not, see <http://www.gnu.org/licenses/>. * along with LMS. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "Types.hpp"
#include "SqlQuery.hpp" #include "SqlQuery.hpp"
#include "DbArtist.hpp"
#include "Track.hpp"
#include "Release.hpp"
namespace Database namespace Database
{ {
@@ -44,7 +48,7 @@ Release::getByMBID(Wt::Dbo::Session& session, const std::string& mbid)
} }
Release::pointer Release::pointer
Release::getById(Wt::Dbo::Session& session, Release::id_type id) Release::getById(Wt::Dbo::Session& session, IdType id)
{ {
return session.find<Release>().where("id = ?").bind(id); return session.find<Release>().where("id = ?").bind(id);
} }
@@ -73,7 +77,7 @@ Release::getAllOrphans(Wt::Dbo::Session& session)
static static
Wt::Dbo::Query<Release::pointer> Wt::Dbo::Query<Release::pointer>
getQuery(Wt::Dbo::Session& session, getQuery(Wt::Dbo::Session& session,
const std::set<Release::id_type>& clusterIds, const std::set<IdType>& clusterIds,
const std::vector<std::string> keywords) const std::vector<std::string> keywords)
{ {
WhereClause where; WhereClause where;
@@ -113,7 +117,7 @@ getQuery(Wt::Dbo::Session& session,
std::vector<Release::pointer> std::vector<Release::pointer>
Release::getByFilter(Wt::Dbo::Session& session, Release::getByFilter(Wt::Dbo::Session& session,
const std::set<id_type>& clusterIds, const std::set<IdType>& clusterIds,
const std::vector<std::string> keywords, const std::vector<std::string> keywords,
int offset, int size, bool& moreResults) int offset, int size, bool& moreResults)
{ {
@@ -182,7 +186,7 @@ Release::hasVariousArtists() const
} }
std::vector<Wt::Dbo::ptr<Track>> std::vector<Wt::Dbo::ptr<Track>>
Release::getTracks(const std::set<id_type>& clusterIds) const Release::getTracks(const std::set<IdType>& clusterIds) const
{ {
assert(self()); assert(self());
assert(self()->id() != Wt::Dbo::dbo_traits<Release>::invalidId() ); assert(self()->id() != Wt::Dbo::dbo_traits<Release>::invalidId() );
@@ -256,7 +260,7 @@ Release::getClusterGroups(std::vector<ClusterType::pointer> clusterTypes, std::s
Wt::Dbo::collection<Cluster::pointer> queryRes = query; Wt::Dbo::collection<Cluster::pointer> queryRes = query;
std::map<ClusterType::id_type, std::vector<Cluster::pointer>> clusters; std::map<IdType, std::vector<Cluster::pointer>> clusters;
for (auto cluster : queryRes) for (auto cluster : queryRes)
{ {
if (clusters[cluster->getType().id()].size() < size) if (clusters[cluster->getType().id()].size() < size)
+7 -4
View File
@@ -23,19 +23,22 @@
#include <Wt/Dbo/Dbo.h> #include <Wt/Dbo/Dbo.h>
#include "Types.hpp"
namespace Database namespace Database
{ {
class Track; class Track;
class Release; class Release;
class Artist; class Artist;
class Cluster;
class ClusterType;
class Release : public Wt::Dbo::Dbo<Release> class Release : public Wt::Dbo::Dbo<Release>
{ {
public: public:
typedef Wt::Dbo::ptr<Release> pointer; typedef Wt::Dbo::ptr<Release> pointer;
typedef Wt::Dbo::dbo_traits<Release>::IdType id_type;
Release() {} Release() {}
Release(const std::string& name, const std::string& MBID = ""); Release(const std::string& name, const std::string& MBID = "");
@@ -43,18 +46,18 @@ class Release : public Wt::Dbo::Dbo<Release>
// Accessors // Accessors
static pointer getByMBID(Wt::Dbo::Session& session, const std::string& MBID); static pointer getByMBID(Wt::Dbo::Session& session, const std::string& MBID);
static std::vector<pointer> getByName(Wt::Dbo::Session& session, const std::string& name); static std::vector<pointer> getByName(Wt::Dbo::Session& session, const std::string& name);
static pointer getById(Wt::Dbo::Session& session, id_type id); static pointer getById(Wt::Dbo::Session& session, IdType id);
static std::vector<pointer> getAllOrphans(Wt::Dbo::Session& session); // no track related static std::vector<pointer> getAllOrphans(Wt::Dbo::Session& session); // no track related
static std::vector<pointer> getAll(Wt::Dbo::Session& session, int offset, int size); static std::vector<pointer> getAll(Wt::Dbo::Session& session, int offset, int size);
static std::vector<pointer> getByFilter(Wt::Dbo::Session& session, static std::vector<pointer> getByFilter(Wt::Dbo::Session& session,
const std::set<id_type>& clusters, // at least one track that belongs to these clusters const std::set<IdType>& clusters, // at least one track that belongs to these clusters
const std::vector<std::string> keywords, // name must match all of these keywords const std::vector<std::string> keywords, // name must match all of these keywords
int offset, int offset,
int size, int size,
bool& moreExpected); bool& moreExpected);
std::vector<Wt::Dbo::ptr<Track>> getTracks(const std::set<id_type>& clusters = std::set<id_type>()) const; std::vector<Wt::Dbo::ptr<Track>> getTracks(const std::set<IdType>& clusters = std::set<IdType>()) const;
// Get the cluster of the tracks that belong to this release // Get the cluster of the tracks that belong to this release
// Each clusters are grouped by cluster type, sorted by the number of occurence // Each clusters are grouped by cluster type, sorted by the number of occurence
// size is the max number of cluster per cluster type // size is the max number of cluster per cluster type
+1 -4
View File
@@ -17,8 +17,7 @@
* along with LMS. If not, see <http://www.gnu.org/licenses/>. * along with LMS. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef SQL_QUERY_HPP___ #pragma once
#define SQL_QUERY_HPP___
#include <list> #include <list>
#include <string> #include <string>
@@ -134,5 +133,3 @@ class SqlQuery
GroupByStatement _groupByStatement; // GROUP BY statement GroupByStatement _groupByStatement; // GROUP BY statement
}; };
#endif
+19 -10
View File
@@ -21,7 +21,10 @@
#include "SqlQuery.hpp" #include "SqlQuery.hpp"
#include "Types.hpp" #include "DbArtist.hpp"
#include "Release.hpp"
#include "Track.hpp"
namespace Database { namespace Database {
@@ -37,12 +40,12 @@ Track::getAll(Wt::Dbo::Session& session)
return session.find<Track>(); return session.find<Track>();
} }
std::vector<Track::id_type> std::vector<IdType>
Track::getAllIds(Wt::Dbo::Session& session) Track::getAllIds(Wt::Dbo::Session& session)
{ {
Wt::Dbo::Transaction transaction(session); Wt::Dbo::Transaction transaction(session);
Wt::Dbo::collection<Track::id_type> res = session.query<Track::id_type>("SELECT id from track"); Wt::Dbo::collection<IdType> res = session.query<IdType>("SELECT id from track");
return std::vector<Track::id_type>(res.begin(), res.end()); return std::vector<IdType>(res.begin(), res.end());
} }
Track::pointer Track::pointer
@@ -52,7 +55,7 @@ Track::getByPath(Wt::Dbo::Session& session, const boost::filesystem::path& p)
} }
Track::pointer Track::pointer
Track::getById(Wt::Dbo::Session& session, id_type id) Track::getById(Wt::Dbo::Session& session, IdType id)
{ {
return session.find<Track>().where("id = ?").bind(id); return session.find<Track>().where("id = ?").bind(id);
} }
@@ -102,7 +105,7 @@ Track::getClusters(void) const
static static
Wt::Dbo::Query< Track::pointer > Wt::Dbo::Query< Track::pointer >
getQuery(Wt::Dbo::Session& session, getQuery(Wt::Dbo::Session& session,
const std::set<Cluster::id_type>& clusterIds, const std::set<IdType>& clusterIds,
const std::vector<std::string> keywords) const std::vector<std::string> keywords)
{ {
WhereClause where; WhereClause where;
@@ -142,7 +145,7 @@ getQuery(Wt::Dbo::Session& session,
std::vector<Track::pointer> std::vector<Track::pointer>
Track::getByFilter(Wt::Dbo::Session& session, Track::getByFilter(Wt::Dbo::Session& session,
const std::set<id_type>& clusterIds, const std::set<IdType>& clusterIds,
const std::vector<std::string> keywords, const std::vector<std::string> keywords,
int offset, int size, bool& moreResults) int offset, int size, bool& moreResults)
{ {
@@ -165,7 +168,7 @@ Track::getByFilter(Wt::Dbo::Session& session,
std::vector<Track::pointer> std::vector<Track::pointer>
Track::getByFilter(Wt::Dbo::Session& session, Track::getByFilter(Wt::Dbo::Session& session,
const std::set<id_type>& clusters) const std::set<IdType>& clusters)
{ {
bool moreResults; bool moreResults;
@@ -233,7 +236,7 @@ Cluster::getAll(Wt::Dbo::Session& session)
} }
Cluster::pointer Cluster::pointer
Cluster::getById(Wt::Dbo::Session& session, id_type id) Cluster::getById(Wt::Dbo::Session& session, IdType id)
{ {
return session.find<Cluster>().where("id = ?").bind(id); return session.find<Cluster>().where("id = ?").bind(id);
} }
@@ -288,7 +291,7 @@ std::vector<Cluster::pointer>
ClusterType::getClusters() const ClusterType::getClusters() const
{ {
assert(self()); assert(self());
assert(self()->id() != Wt::Dbo::dbo_traits<Release>::invalidId() ); assert(self()->id() != Wt::Dbo::dbo_traits<ClusterType>::invalidId() );
assert(session()); assert(session());
Wt::Dbo::collection<Cluster::pointer> res = session()->find<Cluster>() Wt::Dbo::collection<Cluster::pointer> res = session()->find<Cluster>()
@@ -298,5 +301,11 @@ ClusterType::getClusters() const
return std::vector<Cluster::pointer>(res.begin(), res.end()); return std::vector<Cluster::pointer>(res.begin(), res.end());
} }
void
Cluster::addTrack(Wt::Dbo::ptr<Track> track)
{
_tracks.insert(track);
}
} // namespace Database } // namespace Database
+8 -9
View File
@@ -31,6 +31,8 @@
#include <Wt/WDateTime.h> #include <Wt/WDateTime.h>
#include "Types.hpp"
namespace Database { namespace Database {
@@ -44,14 +46,13 @@ class Cluster : public Wt::Dbo::Dbo<Cluster>
{ {
public: public:
typedef Wt::Dbo::ptr<Cluster> pointer; typedef Wt::Dbo::ptr<Cluster> pointer;
typedef Wt::Dbo::dbo_traits<Cluster>::IdType id_type;
Cluster(); Cluster();
Cluster(Wt::Dbo::ptr<ClusterType> type, std::string name); Cluster(Wt::Dbo::ptr<ClusterType> type, std::string name);
// Find utility // Find utility
static std::vector<pointer> getAll(Wt::Dbo::Session& session); static std::vector<pointer> getAll(Wt::Dbo::Session& session);
static pointer getById(Wt::Dbo::Session& session, id_type id); static pointer getById(Wt::Dbo::Session& session, IdType id);
// Create utility // Create utility
static pointer create(Wt::Dbo::Session& session, Wt::Dbo::ptr<ClusterType> type, std::string name); static pointer create(Wt::Dbo::Session& session, Wt::Dbo::ptr<ClusterType> type, std::string name);
@@ -61,7 +62,7 @@ class Cluster : public Wt::Dbo::Dbo<Cluster>
Wt::Dbo::ptr<ClusterType> getType() const { return _clusterType; } Wt::Dbo::ptr<ClusterType> getType() const { return _clusterType; }
const Wt::Dbo::collection<Wt::Dbo::ptr<Track>>& getTracks() const { return _tracks; } const Wt::Dbo::collection<Wt::Dbo::ptr<Track>>& getTracks() const { return _tracks; }
void addTrack(Wt::Dbo::ptr<Track> track) { _tracks.insert(track); } void addTrack(Wt::Dbo::ptr<Track> track);
template<class Action> template<class Action>
void persist(Action& a) void persist(Action& a)
@@ -88,7 +89,6 @@ class ClusterType : public Wt::Dbo::Dbo<ClusterType>
public: public:
using pointer = Wt::Dbo::ptr<ClusterType>; using pointer = Wt::Dbo::ptr<ClusterType>;
using id_type = Wt::Dbo::dbo_traits<ClusterType>::IdType;
ClusterType() {} ClusterType() {}
ClusterType(std::string name); ClusterType(std::string name);
@@ -126,7 +126,6 @@ class Track
public: public:
typedef Wt::Dbo::ptr<Track> pointer; typedef Wt::Dbo::ptr<Track> pointer;
typedef Wt::Dbo::dbo_traits<Track>::IdType id_type;
Track() {} Track() {}
Track(const boost::filesystem::path& p); Track(const boost::filesystem::path& p);
@@ -139,19 +138,19 @@ class Track
// Find utility functions // Find utility functions
static pointer getByPath(Wt::Dbo::Session& session, const boost::filesystem::path& p); static pointer getByPath(Wt::Dbo::Session& session, const boost::filesystem::path& p);
static pointer getById(Wt::Dbo::Session& session, id_type id); static pointer getById(Wt::Dbo::Session& session, IdType id);
static pointer getByMBID(Wt::Dbo::Session& session, const std::string& MBID); static pointer getByMBID(Wt::Dbo::Session& session, const std::string& MBID);
static std::vector<pointer> getByFilter(Wt::Dbo::Session& session, static std::vector<pointer> getByFilter(Wt::Dbo::Session& session,
const std::set<id_type>& clusters); // tracks that belong to these clusters const std::set<IdType>& clusters); // tracks that belong to these clusters
static std::vector<pointer> getByFilter(Wt::Dbo::Session& session, static std::vector<pointer> getByFilter(Wt::Dbo::Session& session,
const std::set<id_type>& clusters, // tracks that belong to these clusters const std::set<IdType>& clusters, // tracks that belong to these clusters
const std::vector<std::string> keywords, // name must match all of these keywords const std::vector<std::string> keywords, // name must match all of these keywords
int offset, int offset,
int size, int size,
bool& moreExpected); bool& moreExpected);
static Wt::Dbo::collection< pointer > getAll(Wt::Dbo::Session& session); static Wt::Dbo::collection< pointer > getAll(Wt::Dbo::Session& session);
static std::vector<id_type> getAllIds(Wt::Dbo::Session& session); // nested transaction static std::vector<IdType> getAllIds(Wt::Dbo::Session& session); // nested transaction
static std::vector<boost::filesystem::path> getAllPaths(Wt::Dbo::Session& session); // nested transaction static std::vector<boost::filesystem::path> getAllPaths(Wt::Dbo::Session& session); // nested transaction
static std::vector<pointer> getMBIDDuplicates(Wt::Dbo::Session& session); static std::vector<pointer> getMBIDDuplicates(Wt::Dbo::Session& session);
static std::vector<pointer> getChecksumDuplicates(Wt::Dbo::Session& session); static std::vector<pointer> getChecksumDuplicates(Wt::Dbo::Session& session);
+6 -7
View File
@@ -17,12 +17,11 @@
* along with LMS. If not, see <http://www.gnu.org/licenses/>. * along with LMS. If not, see <http://www.gnu.org/licenses/>.
*/ */
// header file aimed to ease database class declarations #pragma once
#include "DbArtist.hpp" #include <Wt/Dbo/Dbo.h>
#include "Track.hpp"
#include "Playlist.hpp" namespace Database {
#include "Release.hpp" using IdType = Wt::Dbo::dbo_default_traits::IdType;
#include "MediaDirectory.hpp" }
#include "User.hpp"
+1 -1
View File
@@ -17,7 +17,7 @@
* along with LMS. If not, see <http://www.gnu.org/licenses/>. * along with LMS. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "Types.hpp" #include "User.hpp"
namespace Database { namespace Database {
+2 -4
View File
@@ -17,8 +17,7 @@
* along with LMS. If not, see <http://www.gnu.org/licenses/>. * along with LMS. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef DATABASE_USER_HPP #pragma once
#define DATABASE_USER_HPP
#include <vector> #include <vector>
@@ -28,7 +27,7 @@
namespace Database { namespace Database {
class User; class User;
typedef Wt::Auth::Dbo::AuthInfo<User> AuthInfo; using AuthInfo = Wt::Auth::Dbo::AuthInfo<User>;
class Playlist; class Playlist;
@@ -109,4 +108,3 @@ class User : public Wt::Dbo::Dbo<User>
} // namespace Databas' } // namespace Databas'
#endif
+4 -1
View File
@@ -26,8 +26,11 @@
#include "cover/CoverArtGrabber.hpp" #include "cover/CoverArtGrabber.hpp"
#include "database/DbArtist.hpp"
#include "database/Release.hpp"
#include "database/MediaDirectory.hpp"
#include "database/Track.hpp"
#include "database/Setting.hpp" #include "database/Setting.hpp"
#include "database/Types.hpp"
#include "utils/Logger.hpp" #include "utils/Logger.hpp"
#include "utils/Path.hpp" #include "utils/Path.hpp"
+3
View File
@@ -29,6 +29,9 @@
#include "metadata/TagLibParser.hpp" #include "metadata/TagLibParser.hpp"
#include "database/DatabaseHandler.hpp" #include "database/DatabaseHandler.hpp"
#include "database/Track.hpp"
#include "database/DbArtist.hpp"
#include "database/Release.hpp"
namespace Scanner { namespace Scanner {
+1 -1
View File
@@ -45,7 +45,7 @@ static std::string escape(const std::string& str)
} }
void void
MediaPlayer::playTrack(Database::Track::id_type trackId) MediaPlayer::playTrack(Database::IdType trackId)
{ {
LMS_LOG(UI, DEBUG) << "Playing track ID = " << trackId; LMS_LOG(UI, DEBUG) << "Playing track ID = " << trackId;
+1 -1
View File
@@ -32,7 +32,7 @@ class MediaPlayer : public Wt::WTemplate
MediaPlayer(); MediaPlayer();
void stop(); void stop();
void playTrack(Database::Track::id_type); void playTrack(Database::IdType trackId);
// Signals // Signals
Wt::JSignal<> playbackEnded; Wt::JSignal<> playbackEnded;
+3 -1
View File
@@ -23,6 +23,8 @@
#include "utils/Logger.hpp" #include "utils/Logger.hpp"
#include "database/Playlist.hpp"
#include "LmsApplication.hpp" #include "LmsApplication.hpp"
#include "PlayQueueView.hpp" #include "PlayQueueView.hpp"
@@ -91,7 +93,7 @@ PlayQueue::play(std::size_t pos)
{ {
updateCurrentTrack(false); updateCurrentTrack(false);
Database::Track::id_type trackId; Database::IdType trackId;
{ {
Wt::Dbo::Transaction transaction(LmsApp->getDboSession()); Wt::Dbo::Transaction transaction(LmsApp->getDboSession());
+2 -2
View File
@@ -26,7 +26,7 @@
#include <boost/optional.hpp> #include <boost/optional.hpp>
#include "database/Types.hpp" #include "database/Track.hpp"
namespace UserInterface { namespace UserInterface {
@@ -45,7 +45,7 @@ class PlayQueue : public Wt::WTemplate
void playPrevious(); void playPrevious();
// Signal emitted when a track is to be played // 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 // Signal emitted when play has to be stopped
Wt::Signal<> playbackStop; Wt::Signal<> playbackStop;
+1 -1
View File
@@ -20,7 +20,7 @@
#include <Wt/WTemplate.h> #include <Wt/WTemplate.h>
#include <Wt/WPushButton.h> #include <Wt/WPushButton.h>
#include "database/Types.hpp" #include "database/User.hpp"
#include "utils/Logger.hpp" #include "utils/Logger.hpp"
#include "LmsApplication.hpp" #include "LmsApplication.hpp"
+2 -2
View File
@@ -22,8 +22,8 @@
#include <Wt/WTemplate.h> #include <Wt/WTemplate.h>
#include <Wt/WText.h> #include <Wt/WText.h>
#include "database/DbArtist.hpp"
#include "database/Setting.hpp" #include "database/Setting.hpp"
#include "database/Types.hpp"
#include "utils/Logger.hpp" #include "utils/Logger.hpp"
#include "utils/Utils.hpp" #include "utils/Utils.hpp"
@@ -92,7 +92,7 @@ Artist::refresh()
clear(); clear();
auto artistId = readAs<Database::Artist::id_type>(wApp->internalPathNextPart("/artist/")); auto artistId = readAs<Database::IdType>(wApp->internalPathNextPart("/artist/"));
if (!artistId) if (!artistId)
return; return;
+6 -4
View File
@@ -22,6 +22,8 @@
#include <Wt/WContainerWidget.h> #include <Wt/WContainerWidget.h>
#include <Wt/WSignal.h> #include <Wt/WSignal.h>
#include "database/Types.hpp"
namespace UserInterface { namespace UserInterface {
class Filters; class Filters;
@@ -31,11 +33,11 @@ class Artist : public Wt::WContainerWidget
public: public:
Artist(Filters* filters); Artist(Filters* filters);
Wt::Signal<Database::id_type> artistAdd; Wt::Signal<Database::IdType> artistAdd;
Wt::Signal<Database::id_type> artistPlay; Wt::Signal<Database::IdType> artistPlay;
Wt::Signal<Database::id_type> releaseAdd; Wt::Signal<Database::IdType> releaseAdd;
Wt::Signal<Database::id_type> releasePlay; Wt::Signal<Database::IdType> releasePlay;
private: private:
void refresh(); void refresh();
+1 -1
View File
@@ -21,8 +21,8 @@
#include <Wt/WTemplate.h> #include <Wt/WTemplate.h>
#include <Wt/WLineEdit.h> #include <Wt/WLineEdit.h>
#include "database/DbArtist.hpp"
#include "database/Setting.hpp" #include "database/Setting.hpp"
#include "database/Types.hpp"
#include "utils/Logger.hpp" #include "utils/Logger.hpp"
#include "utils/Utils.hpp" #include "utils/Utils.hpp"
+4 -2
View File
@@ -24,6 +24,8 @@
#include <Wt/WLineEdit.h> #include <Wt/WLineEdit.h>
#include <Wt/WSignal.h> #include <Wt/WSignal.h>
#include "database/Types.hpp"
namespace UserInterface { namespace UserInterface {
class Filters; class Filters;
@@ -33,8 +35,8 @@ class Artists : public Wt::WTemplate
public: public:
Artists(Filters* filters); Artists(Filters* filters);
Wt::Signal<Database::id_type> artistAdd; Wt::Signal<Database::IdType> artistAdd;
Wt::Signal<Database::id_type> artistPlay; Wt::Signal<Database::IdType> artistPlay;
private: private:
void refresh(); void refresh();
+9 -9
View File
@@ -118,7 +118,7 @@ Explore::Explore()
} }
// TODO SQL this? // 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; std::vector<Database::Track::pointer> res;
@@ -140,7 +140,7 @@ static std::vector<Database::Track::pointer> getArtistTracks(Wt::Dbo::Session& s
return res; 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; std::vector<Database::Track::pointer> res;
@@ -151,7 +151,7 @@ static std::vector<Database::Track::pointer> getReleaseTracks(Wt::Dbo::Session&
return release->getTracks(clusters); 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; std::vector<Database::Track::pointer> res;
@@ -163,7 +163,7 @@ static std::vector<Database::Track::pointer> getTrack(Wt::Dbo::Session& session,
} }
void void
Explore::handleArtistAdd(Database::id_type id) Explore::handleArtistAdd(Database::IdType id)
{ {
Wt::Dbo::Transaction transaction(LmsApp->getDboSession()); Wt::Dbo::Transaction transaction(LmsApp->getDboSession());
@@ -171,7 +171,7 @@ Explore::handleArtistAdd(Database::id_type id)
} }
void void
Explore::handleArtistPlay(Database::id_type id) Explore::handleArtistPlay(Database::IdType id)
{ {
Wt::Dbo::Transaction transaction(LmsApp->getDboSession()); Wt::Dbo::Transaction transaction(LmsApp->getDboSession());
@@ -179,7 +179,7 @@ Explore::handleArtistPlay(Database::id_type id)
} }
void void
Explore::handleReleaseAdd(Database::id_type id) Explore::handleReleaseAdd(Database::IdType id)
{ {
Wt::Dbo::Transaction transaction(LmsApp->getDboSession()); Wt::Dbo::Transaction transaction(LmsApp->getDboSession());
@@ -187,7 +187,7 @@ Explore::handleReleaseAdd(Database::id_type id)
} }
void void
Explore::handleReleasePlay(Database::id_type id) Explore::handleReleasePlay(Database::IdType id)
{ {
Wt::Dbo::Transaction transaction(LmsApp->getDboSession()); Wt::Dbo::Transaction transaction(LmsApp->getDboSession());
@@ -195,7 +195,7 @@ Explore::handleReleasePlay(Database::id_type id)
} }
void void
Explore::handleTrackAdd(Database::id_type id) Explore::handleTrackAdd(Database::IdType id)
{ {
Wt::Dbo::Transaction transaction(LmsApp->getDboSession()); Wt::Dbo::Transaction transaction(LmsApp->getDboSession());
@@ -203,7 +203,7 @@ Explore::handleTrackAdd(Database::id_type id)
} }
void void
Explore::handleTrackPlay(Database::id_type id) Explore::handleTrackPlay(Database::IdType id)
{ {
Wt::Dbo::Transaction transaction(LmsApp->getDboSession()); Wt::Dbo::Transaction transaction(LmsApp->getDboSession());
+7 -6
View File
@@ -21,6 +21,7 @@
#include <Wt/WTemplate.h> #include <Wt/WTemplate.h>
#include "database/Track.hpp"
#include "database/Types.hpp" #include "database/Types.hpp"
namespace UserInterface { namespace UserInterface {
@@ -37,12 +38,12 @@ class Explore : public Wt::WTemplate
private: private:
void handleArtistAdd(Database::Artist::id_type id); void handleArtistAdd(Database::IdType id);
void handleArtistPlay(Database::Artist::id_type id); void handleArtistPlay(Database::IdType id);
void handleReleaseAdd(Database::Release::id_type id); void handleReleaseAdd(Database::IdType id);
void handleReleasePlay(Database::Release::id_type id); void handleReleasePlay(Database::IdType id);
void handleTrackAdd(Database::Track::id_type id); void handleTrackAdd(Database::IdType id);
void handleTrackPlay(Database::Track::id_type id); void handleTrackPlay(Database::IdType id);
void handleTracksAdd(std::vector<Database::Track::pointer> tracks); void handleTracksAdd(std::vector<Database::Track::pointer> tracks);
void handleTracksPlay(std::vector<Database::Track::pointer> tracks); void handleTracksPlay(std::vector<Database::Track::pointer> tracks);
+1 -1
View File
@@ -116,7 +116,7 @@ Filters::showDialog()
} }
void void
Filters::add(Database::Cluster::id_type clusterId) Filters::add(Database::IdType clusterId)
{ {
Wt::Dbo::Transaction transaction(LmsApp->getDboSession()); Wt::Dbo::Transaction transaction(LmsApp->getDboSession());
+3 -3
View File
@@ -34,9 +34,9 @@ class Filters : public Wt::WTemplate
public: public:
Filters(); 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; } Wt::Signal<>& updated() { return _sigUpdated; }
@@ -46,7 +46,7 @@ class Filters : public Wt::WTemplate
Wt::WContainerWidget *_filters; Wt::WContainerWidget *_filters;
Wt::Signal<> _sigUpdated; Wt::Signal<> _sigUpdated;
std::set<Database::Cluster::id_type> _filterIds; std::set<Database::IdType> _filterIds;
}; };
} // namespace UserInterface } // namespace UserInterface
+2 -2
View File
@@ -23,7 +23,7 @@
#include <Wt/WTemplate.h> #include <Wt/WTemplate.h>
#include <Wt/WText.h> #include <Wt/WText.h>
#include "database/Types.hpp" #include "database/Release.hpp"
#include "database/Setting.hpp" #include "database/Setting.hpp"
#include "utils/Logger.hpp" #include "utils/Logger.hpp"
@@ -92,7 +92,7 @@ Release::refresh()
clear(); clear();
auto releaseId = readAs<Database::Release::id_type>(wApp->internalPathNextPart("/release/")); auto releaseId = readAs<Database::IdType>(wApp->internalPathNextPart("/release/"));
if (!releaseId) if (!releaseId)
return; return;
+6 -4
View File
@@ -21,6 +21,8 @@
#include <Wt/WSignal.h> #include <Wt/WSignal.h>
#include "database/Types.hpp"
namespace UserInterface { namespace UserInterface {
class Filters; class Filters;
@@ -29,11 +31,11 @@ class Release : public Wt::WContainerWidget
public: public:
Release(Filters* filters); Release(Filters* filters);
Wt::Signal<Database::id_type> releaseAdd; Wt::Signal<Database::IdType> releaseAdd;
Wt::Signal<Database::id_type> releasePlay; Wt::Signal<Database::IdType> releasePlay;
Wt::Signal<Database::id_type> trackAdd; Wt::Signal<Database::IdType> trackAdd;
Wt::Signal<Database::id_type> trackPlay; Wt::Signal<Database::IdType> trackPlay;
private: private:
void refresh(); void refresh();
+1 -1
View File
@@ -23,7 +23,7 @@
#include <Wt/WText.h> #include <Wt/WText.h>
#include <Wt/WTemplate.h> #include <Wt/WTemplate.h>
#include "database/Types.hpp" #include "database/Release.hpp"
#include "utils/Logger.hpp" #include "utils/Logger.hpp"
#include "utils/Utils.hpp" #include "utils/Utils.hpp"
+4 -2
View File
@@ -24,6 +24,8 @@
#include <Wt/WText.h> #include <Wt/WText.h>
#include <Wt/WTemplate.h> #include <Wt/WTemplate.h>
#include "database/Types.hpp"
namespace UserInterface { namespace UserInterface {
class Filters; class Filters;
@@ -33,8 +35,8 @@ class Releases : public Wt::WTemplate
public: public:
Releases(Filters* filters); Releases(Filters* filters);
Wt::Signal<Database::id_type> releaseAdd; Wt::Signal<Database::IdType> releaseAdd;
Wt::Signal<Database::id_type> releasePlay; Wt::Signal<Database::IdType> releasePlay;
private: private:
void refresh(); void refresh();
+3 -1
View File
@@ -22,7 +22,9 @@
#include <Wt/WLineEdit.h> #include <Wt/WLineEdit.h>
#include <Wt/WText.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/Logger.hpp"
#include "utils/Utils.hpp" #include "utils/Utils.hpp"
+5 -2
View File
@@ -23,6 +23,9 @@
#include <Wt/WLineEdit.h> #include <Wt/WLineEdit.h>
#include <Wt/WTemplate.h> #include <Wt/WTemplate.h>
#include "database/Types.hpp"
#include "database/Track.hpp"
namespace UserInterface { namespace UserInterface {
class Filters; class Filters;
@@ -31,8 +34,8 @@ class Tracks : public Wt::WTemplate
public: public:
Tracks(Filters* filters); Tracks(Filters* filters);
Wt::Signal<Database::id_type> trackAdd; Wt::Signal<Database::IdType> trackAdd;
Wt::Signal<Database::id_type> trackPlay; Wt::Signal<Database::IdType> trackPlay;
Wt::Signal<std::vector<Database::Track::pointer>> tracksAdd; Wt::Signal<std::vector<Database::Track::pointer>> tracksAdd;
Wt::Signal<std::vector<Database::Track::pointer>> tracksPlay; Wt::Signal<std::vector<Database::Track::pointer>> tracksPlay;
+5 -5
View File
@@ -90,19 +90,19 @@ ImageResource::getDefaultArtistImage(std::size_t size)
} }
std::string 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); return url() + "&releaseid=" + std::to_string(releaseId) + "&size=" + std::to_string(size);
} }
std::string 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); return url() + "&trackid=" + std::to_string(trackId) + "&size=" + std::to_string(size);
} }
std::string 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); 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) if (trackIdStr)
{ {
auto trackId = readAs<Database::Track::id_type>(*trackIdStr); auto trackId = readAs<Database::IdType>(*trackIdStr);
if (!trackId) if (!trackId)
return; return;
@@ -202,7 +202,7 @@ ImageResource::handleRequest(const Wt::Http::Request& request, Wt::Http::Respons
} }
else if (releaseIdStr) else if (releaseIdStr)
{ {
auto releaseId = readAs<Database::Release::id_type>(*releaseIdStr); auto releaseId = readAs<Database::IdType>(*releaseIdStr);
if (!releaseId) if (!releaseId)
return; return;
+5 -3
View File
@@ -25,6 +25,8 @@
#include <Wt/WResource.h> #include <Wt/WResource.h>
#include "database/DatabaseHandler.hpp" #include "database/DatabaseHandler.hpp"
#include "database/Types.hpp"
#include "image/Image.hpp" #include "image/Image.hpp"
namespace UserInterface { namespace UserInterface {
@@ -38,9 +40,9 @@ class ImageResource : public Wt::WResource
ImageResource(Database::Handler& db); ImageResource(Database::Handler& db);
~ImageResource(); ~ImageResource();
std::string getReleaseUrl(Database::Release::id_type releaseId, size_t size) const; std::string getReleaseUrl(Database::IdType releaseId, size_t size) const;
std::string getTrackUrl(Database::Track::id_type trackId, size_t size) const; std::string getTrackUrl(Database::IdType trackId, size_t size) const;
std::string getArtistUrl(Database::Artist::id_type artistId, size_t size) const; std::string getArtistUrl(Database::IdType artistId, size_t size) const;
std::string getUnknownTrackUrl(size_t size) const; std::string getUnknownTrackUrl(size_t size) const;
void handleRequest(const Wt::Http::Request& request, Wt::Http::Response& response); void handleRequest(const Wt::Http::Request& request, Wt::Http::Response& response);
+2 -2
View File
@@ -40,7 +40,7 @@ TranscodeResource:: ~TranscodeResource()
} }
std::string 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)); 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 else
{ {
Database::Track::id_type trackId; Database::IdType trackId;
Av::TranscodeParameters parameters; Av::TranscodeParameters parameters;
LMS_LOG(UI, DEBUG) << "No continuation yet"; LMS_LOG(UI, DEBUG) << "No continuation yet";
+3 -1
View File
@@ -26,6 +26,8 @@
#include "av/AvTranscoder.hpp" #include "av/AvTranscoder.hpp"
#include "database/DatabaseHandler.hpp" #include "database/DatabaseHandler.hpp"
#include "database/Types.hpp"
namespace UserInterface { namespace UserInterface {
@@ -35,7 +37,7 @@ class TranscodeResource : public Wt::WResource
TranscodeResource(Database::Handler& db); TranscodeResource(Database::Handler& db);
~TranscodeResource(); ~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, void handleRequest(const Wt::Http::Request& request,
Wt::Http::Response& response); Wt::Http::Response& response);