diff --git a/configure.ac b/configure.ac index fe932bb4..41173572 100644 --- a/configure.ac +++ b/configure.ac @@ -8,14 +8,6 @@ AC_LANG_CPLUSPLUS # Checks for programs AC_PROG_CXX -AC_ARG_ENABLE([video], AS_HELP_STRING([--enable-video], - [Enable Video support. Default to no.])], - [enable_video="$enableval"], - [enable_video="no"]) - -AM_CONDITIONAL([VIDEO], [test x$enable_video = xyes]) -AS_IF([test x$enable_video = xyes], [AC_DEFINE(HAVE_VIDEO, [1], [Enable Video support])]) - PKG_CHECK_MODULES(IMAGEMAGICKXX, "ImageMagick++", [ HAVE_IMAGEMAGICKXX=yes ], [ ]) if test -n "$HAVE_IMAGEMAGICKXX"; then MAGICKXX_CFLAGS="$IMAGEMAGICKXX_CFLAGS" diff --git a/src/Makefile.am b/src/Makefile.am index 02bd8c3b..5bcbc8a6 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -15,7 +15,6 @@ lms_SOURCES = \ $(srcdir)/database/SqlQuery.cpp \ $(srcdir)/database/Track.cpp \ $(srcdir)/database/User.cpp \ - $(srcdir)/database/Video.cpp \ $(srcdir)/database/updater/DatabaseUpdater.cpp \ $(srcdir)/database/updater/DatabaseFeatureExtractor.cpp \ $(srcdir)/database/updater/DatabaseHighLevelCluster.cpp \ @@ -45,14 +44,6 @@ lms_SOURCES = \ $(srcdir)/utils/Path.cpp \ $(srcdir)/utils/Utils.cpp -if VIDEO -lms_SOURCES += \ - $(srcdir)/ui/video/VideoWidget.cpp \ - $(srcdir)/ui/video/VideoDatabaseWidget.cpp \ - $(srcdir)/ui/video/VideoMediaPlayerWidget.cpp \ - $(srcdir)/ui/video/VideoParametersDialog.cpp -endif - lms_CXXFLAGS=-std=c++11 -Wall -I$(srcdir)/third-party -I$(srcdir)/ui $(MAGICKXX_CFLAGS) -D_REENTRANT -DBOOST_SPIRIT_THREADSAFE lms_LDADD=$(MAGICKXX_LIBS) diff --git a/src/cover/CoverArtGrabber.cpp b/src/cover/CoverArtGrabber.cpp index a73a502c..56967cda 100644 --- a/src/cover/CoverArtGrabber.cpp +++ b/src/cover/CoverArtGrabber.cpp @@ -173,9 +173,9 @@ Grabber::getFromRelease(Wt::Dbo::Session& session, Database::Release::id_type re Wt::Dbo::Transaction transaction(session); - // If the release does not exist or is the special release "None", do nothing + // If the release does not exist, do nothing Release::pointer release = Release::getById(session, releaseId); - if (!release || release->isNone()) + if (!release) return std::vector(); std::vector tracks = release->getTracks(); diff --git a/src/database/Artist.cpp b/src/database/Artist.cpp deleted file mode 100644 index 67f4f340..00000000 --- a/src/database/Artist.cpp +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Copyright (C) 2015 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 "Types.hpp" -#include "SqlQuery.hpp" - -#include "utils/Logger.hpp" - -namespace Database -{ - -Artist::Artist(const std::string& name, const std::string& MBID) -: _name(std::string(name, 0 , _maxNameLength)), -_MBID(MBID) -{ - -} - -std::vector -Artist::getByName(Wt::Dbo::Session& session, const std::string& name) -{ - Wt::Dbo::collection res = session.find().where("name = ?").bind( std::string(name, 0, _maxNameLength) ); - return std::vector(res.begin(), res.end()); -} - -Artist::pointer -Artist::getByMBID(Wt::Dbo::Session& session, const std::string& mbid) -{ - return session.find().where("mbid = ?").bind(mbid); -} - -Artist::pointer -Artist::getById(Wt::Dbo::Session& session, Artist::id_type id) -{ - return session.find().where("id = ?").bind(id); -} - -Artist::pointer -Artist::create(Wt::Dbo::Session& session, const std::string& name, const std::string& MBID) -{ - return session.add(new Artist(name, MBID)); -} - -Artist::pointer -Artist::getNone(Wt::Dbo::Session& session) -{ - std::vector res = getByName(session, ""); - if (res.empty()) - return create(session, ""); - - return res.front(); -} - -std::vector -Artist::getAll(Wt::Dbo::Session& session, int offset, int size) -{ - Wt::Dbo::collection res = session.find().offset(offset).limit(size); - return std::vector(res.begin(), res.end()); -} - -std::vector -Artist::getAllOrphans(Wt::Dbo::Session& session) -{ - Wt::Dbo::collection res = session.query< Wt::Dbo::ptr >("select a from artist a LEFT OUTER JOIN Track t ON a.id = t.artist_id WHERE t.id IS NULL"); - - return std::vector(res.begin(), res.end()); -} - -std::vector -Artist::getByFilter(Wt::Dbo::Session& session, SearchFilter filter, int offset, int size) -{ - Wt::Dbo::collection res = getQuery(session, filter).limit(size).offset(offset); - - return std::vector(res.begin(), res.end()); -} - -std::vector -Artist::getByFilter(Wt::Dbo::Session& session, SearchFilter filter, int offset, int size, bool& moreResults) -{ - auto res = getByFilter(session, filter, offset, size + 1); - - if (size != -1 && res.size() == static_cast(size) + 1) - { - moreResults = true; - res.pop_back(); - } - else - moreResults = false; - - return res; -} - - - -std::vector > -Artist::getReleases() const -{ - assert(self()); - assert(self()->id() != Wt::Dbo::dbo_traits::invalidId() ); - assert(session()); - - Wt::Dbo::collection< Wt::Dbo::ptr > res = session()->query >("SELECT r FROM release r INNER JOIN artist a ON t.artist_id = a.id INNER JOIN track t ON t.release_id = r.id").where("a.id = ?").bind(id()); - - return std::vector< Wt::Dbo::ptr > (res.begin(), res.end()); -} - -Wt::Dbo::Query -Artist::getQuery(Wt::Dbo::Session& session, SearchFilter filter) -{ - SqlQuery sqlQuery = generatePartialQuery(filter); - - Wt::Dbo::Query query - = session.query( "SELECT a FROM artist a INNER JOIN track t ON t.artist_id = a.id INNER JOIN release r ON r.id = t.release_id INNER JOIN cluster c ON c.id = t_c.cluster_id INNER JOIN track_cluster t_c ON t_c.track_id = t.id " + sqlQuery.where().get()).groupBy("a.id").orderBy("a.name"); - - for (const std::string& bindArg : sqlQuery.where().getBindArgs()) - query.bind(bindArg); - - return query; -} - -Wt::Dbo::Query -Artist::getUIQuery(Wt::Dbo::Session& session, SearchFilter filter) -{ - SqlQuery sqlQuery = generatePartialQuery(filter); - - Wt::Dbo::Query query - = session.query( "SELECT a.id, a.name, COUNT(DISTINCT r.id), COUNT(DISTINCT t.id) FROM artist a INNER JOIN track t ON t.artist_id = a.id INNER JOIN release r ON r.id = t.release_id INNER JOIN cluster c ON c.id = t_c.cluster_id INNER JOIN track_cluster t_c ON t_c.track_id = t.id " + sqlQuery.where().get()).groupBy("a.id").orderBy("a.name"); - - for (const std::string& bindArg : sqlQuery.where().getBindArgs()) - query.bind(bindArg); - - return query; -} - -void -Artist::updateUIQueryModel(Wt::Dbo::Session& session, Wt::Dbo::QueryModel& model, SearchFilter filter, const std::vector& columnNames) -{ - Wt::Dbo::Query query = getUIQuery(session, filter); - - model.setQuery(query, columnNames.empty() ? true : false); - - // TODO do something better - if (columnNames.size() == 3) - { - model.addColumn( "a.name", columnNames.at(0)); - model.addColumn( "COUNT(DISTINCT r.id)", columnNames.at(1) ); - model.addColumn( "COUNT(DISTINCT t.id)", columnNames.at(2) ); - } -} - - -} // namespace Database diff --git a/src/database/Artist.hpp b/src/database/Artist.hpp deleted file mode 100644 index 638a0847..00000000 --- a/src/database/Artist.hpp +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (C) 2015 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 . - */ - -#ifndef _DB_ARTIST_HPP_ -#define _DB_ARTIST_HPP_ - -#include -#include - -#include -#include - -#include "SearchFilter.hpp" - -namespace Database -{ - -class Track; -class Cluster; -class Release; - -class Artist : public Wt::Dbo::Dbo -{ - public: - - typedef Wt::Dbo::ptr pointer; - typedef Wt::Dbo::dbo_traits::IdType id_type; - - Artist() {} - Artist(const std::string& name, const std::string& MBID = ""); - - // Accessors - static pointer getByMBID(Wt::Dbo::Session& session, const std::string& MBID); - static pointer getById(Wt::Dbo::Session& session, id_type id); - static pointer getNone(Wt::Dbo::Session& session); // Special entry - static std::vector getByName(Wt::Dbo::Session& session, const std::string& name); - static std::vector getByFilter(Wt::Dbo::Session& session, SearchFilter filter, int offset = -1, int size = -1); - static std::vector getByFilter(Wt::Dbo::Session& session, SearchFilter filter, int offset, int size, bool& moreExpected); - - static std::vector getAll(Wt::Dbo::Session& session, int offset = -1, int size = -1); - static std::vector getAllOrphans(Wt::Dbo::Session& session); - - // Accessors - std::string getName(void) const { return _name; } - std::string getMBID(void) const { return _MBID; } - - // Get the releases that have at least one track for this artist - std::vector > getReleases() const; - - void setMBID(std::string mbid) { _MBID = mbid; } - - // Create - static pointer create(Wt::Dbo::Session& session, const std::string& name, const std::string& MBID = ""); - - // MVC models for the user interface - // ID, Artist name, albums, tracks - typedef boost::tuple UIQueryResult; - static Wt::Dbo::Query getUIQuery(Wt::Dbo::Session& session, SearchFilter filter); - static void updateUIQueryModel(Wt::Dbo::Session& session, Wt::Dbo::QueryModel& model, SearchFilter filter, const std::vector& columnNames = std::vector()); - - bool isNone(void) const; - - template - void persist(Action& a) - { - Wt::Dbo::field(a, _name, "name"); - Wt::Dbo::field(a, _MBID, "mbid"); - - Wt::Dbo::hasMany(a, _tracks, Wt::Dbo::ManyToOne, "artist"); - } - - private: - - static Wt::Dbo::Query getQuery(Wt::Dbo::Session& session, SearchFilter filter); - - static const std::size_t _maxNameLength = 128; - - std::string _name; - std::string _MBID; // Musicbrainz Identifier - - Wt::Dbo::collection< Wt::Dbo::ptr > _tracks; // Tracks of this artist -}; - -} // namespace Database - -#endif diff --git a/src/database/DatabaseHandler.cpp b/src/database/DatabaseHandler.cpp index 1aedb3b8..85164449 100644 --- a/src/database/DatabaseHandler.cpp +++ b/src/database/DatabaseHandler.cpp @@ -87,7 +87,6 @@ Handler::Handler(Wt::Dbo::SqlConnectionPool& connectionPool) _session.mapClass("playlist"); _session.mapClass("playlist_entry"); _session.mapClass("release"); - _session.mapClass("video"); _session.mapClass("media_directory"); _session.mapClass("setting"); diff --git a/src/database/DbArtist.cpp b/src/database/DbArtist.cpp index 413e40c4..7c65b231 100644 --- a/src/database/DbArtist.cpp +++ b/src/database/DbArtist.cpp @@ -57,22 +57,6 @@ Artist::create(Wt::Dbo::Session& session, const std::string& name, const std::st return session.add(new Artist(name, MBID)); } -Artist::pointer -Artist::getNone(Wt::Dbo::Session& session) -{ - std::vector res = getByName(session, ""); - if (res.empty()) - return create(session, ""); - - return res.front(); -} - -bool -Artist::isNone() const -{ - return _name == ""; -} - std::vector Artist::getAll(Wt::Dbo::Session& session, int offset, int size) { diff --git a/src/database/DbArtist.hpp b/src/database/DbArtist.hpp index 47c7d24f..a22360dc 100644 --- a/src/database/DbArtist.hpp +++ b/src/database/DbArtist.hpp @@ -48,7 +48,6 @@ class Artist : public Wt::Dbo::Dbo // Accessors static pointer getByMBID(Wt::Dbo::Session& session, const std::string& MBID); static pointer getById(Wt::Dbo::Session& session, id_type id); - static pointer getNone(Wt::Dbo::Session& session); // Special entry static std::vector getByName(Wt::Dbo::Session& session, const std::string& name); static std::vector getByFilter(Wt::Dbo::Session& session, const std::set& clusters, // at least one track that belongs to these clusters @@ -72,7 +71,6 @@ class Artist : public Wt::Dbo::Dbo // Create static pointer create(Wt::Dbo::Session& session, const std::string& name, const std::string& MBID = ""); - bool isNone(void) const; template void persist(Action& a) diff --git a/src/database/MediaDirectory.hpp b/src/database/MediaDirectory.hpp index c77b6b0c..e00892dd 100644 --- a/src/database/MediaDirectory.hpp +++ b/src/database/MediaDirectory.hpp @@ -36,7 +36,6 @@ class MediaDirectory enum Type { Audio = 1, - Video = 2, }; MediaDirectory() {} diff --git a/src/database/Release.cpp b/src/database/Release.cpp index 2b338e34..d3d73732 100644 --- a/src/database/Release.cpp +++ b/src/database/Release.cpp @@ -56,22 +56,6 @@ Release::create(Wt::Dbo::Session& session, const std::string& name, const std::s return session.add(new Release(name, MBID)); } -bool -Release::isNone() const -{ - return _name == ""; -} - -Release::pointer -Release::getNone(Wt::Dbo::Session& session) -{ - std::vector res = getByName(session, ""); - if (res.empty()) - return create(session, ""); - - return res.front(); -} - std::vector Release::getAll(Wt::Dbo::Session& session, int offset, int size) { diff --git a/src/database/Release.hpp b/src/database/Release.hpp index 3feb0100..b9d8acac 100644 --- a/src/database/Release.hpp +++ b/src/database/Release.hpp @@ -46,7 +46,6 @@ class Release : public Wt::Dbo::Dbo static pointer getByMBID(Wt::Dbo::Session& session, const std::string& MBID); static std::vector getByName(Wt::Dbo::Session& session, const std::string& name); static pointer getById(Wt::Dbo::Session& session, id_type id); - static pointer getNone(Wt::Dbo::Session& session); // Special entry static std::vector getAllOrphans(Wt::Dbo::Session& session); // no track related static std::vector getAll(Wt::Dbo::Session& session, int offset, int size); @@ -68,7 +67,6 @@ class Release : public Wt::Dbo::Dbo // Accessors std::string getName() const { return _name; } std::string getMBID() const { return _MBID; } - bool isNone(void) const; boost::posix_time::time_duration getDuration(void) const; // Get the artists of this release diff --git a/src/database/Track.cpp b/src/database/Track.cpp index 50c16a4d..a7d5ab9c 100644 --- a/src/database/Track.cpp +++ b/src/database/Track.cpp @@ -240,21 +240,6 @@ Cluster::getByType(Wt::Dbo::Session& session, std::string type) return std::vector(res.begin(), res.end()); } -Cluster::pointer -Cluster::getNone(Wt::Dbo::Session& session) -{ - pointer res = get(session, "", ""); - if (!res) - res = create(session, "", ""); - return res; -} - -bool -Cluster::isNone(void) const -{ - return (_type == "" && _name == ""); -} - Cluster::pointer Cluster::create(Wt::Dbo::Session& session, std::string type, std::string name) { diff --git a/src/database/Track.hpp b/src/database/Track.hpp index 0d81a36d..01a1566c 100644 --- a/src/database/Track.hpp +++ b/src/database/Track.hpp @@ -59,7 +59,6 @@ class Cluster // Find utility static pointer get(Wt::Dbo::Session& session, std::string type, std::string name); - static pointer getNone(Wt::Dbo::Session& session); static std::vector getByFilter(Wt::Dbo::Session& session, SearchFilter filter, int offset = -1, int size = -1); static Wt::Dbo::collection getAll(Wt::Dbo::Session& session); static std::vector getAllTypes(Wt::Dbo::Session& session); @@ -74,7 +73,6 @@ class Cluster // Accessors const std::string& getName(void) const { return _name; } const std::string& getType(void) const { return _type; } - bool isNone(void) const; const Wt::Dbo::collection< Wt::Dbo::ptr >& getTracks() const { return _tracks;} void addTrack(Wt::Dbo::Session& session, Wt::Dbo::dbo_traits::IdType trackId); diff --git a/src/database/Types.hpp b/src/database/Types.hpp index 681e4c97..0518cbe5 100644 --- a/src/database/Types.hpp +++ b/src/database/Types.hpp @@ -23,7 +23,6 @@ #include "Track.hpp" #include "Playlist.hpp" #include "Release.hpp" -#include "Video.hpp" #include "MediaDirectory.hpp" #include "User.hpp" diff --git a/src/database/Video.cpp b/src/database/Video.cpp deleted file mode 100644 index 6568604d..00000000 --- a/src/database/Video.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (C) 2013 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 "Types.hpp" - -namespace Database { - -Video::Video() -{ -} - -Video::Video(const boost::filesystem::path& p) -: _filePath(p.string()) -{ -} - -Video::pointer -Video::create(Wt::Dbo::Session& session, const boost::filesystem::path& p) -{ - return session.add(new Video(p)); -} - -Wt::Dbo::collection< Video::pointer > -Video::getAll(Wt::Dbo::Session& session) -{ - return session.find