Merge branch 'develop' into audio-mobile
This commit is contained in:
@@ -21,14 +21,15 @@
|
||||
#include <Wt/WTemplate>
|
||||
#include <Wt/WPushButton>
|
||||
|
||||
#include "LmsApplication.hpp"
|
||||
|
||||
#include "ArtistSearch.hpp"
|
||||
|
||||
namespace UserInterface {
|
||||
namespace Mobile {
|
||||
|
||||
ArtistSearch::ArtistSearch(Database::Handler& db, Wt::WContainerWidget *parent)
|
||||
ArtistSearch::ArtistSearch(Wt::WContainerWidget *parent)
|
||||
: Wt::WContainerWidget(parent),
|
||||
_db(db),
|
||||
_resCount(0)
|
||||
{
|
||||
Wt::WTemplate *title = new Wt::WTemplate(this);
|
||||
@@ -60,10 +61,10 @@ ArtistSearch::addResults(Database::SearchFilter filter, std::size_t nb)
|
||||
std::vector<std::string> artists;
|
||||
|
||||
{
|
||||
Wt::Dbo::Transaction transaction(_db.getSession());
|
||||
Wt::Dbo::Transaction transaction(DboSession());
|
||||
|
||||
// Request one more to see if more results are to be expected
|
||||
artists = Database::Track::getArtists(_db.getSession(), filter, _resCount, nb + 1);
|
||||
artists = Database::Track::getArtists(DboSession(), filter, _resCount, nb + 1);
|
||||
}
|
||||
|
||||
bool expectMoreResults;
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include <boost/algorithm/string/split.hpp>
|
||||
#include <Wt/WContainerWidget>
|
||||
|
||||
#include "database/DatabaseHandler.hpp"
|
||||
#include "database/Types.hpp"
|
||||
|
||||
namespace UserInterface {
|
||||
namespace Mobile {
|
||||
@@ -32,7 +32,7 @@ class ArtistSearch : public Wt::WContainerWidget
|
||||
{
|
||||
public:
|
||||
|
||||
ArtistSearch(Database::Handler& db, Wt::WContainerWidget *parent = 0);
|
||||
ArtistSearch(Wt::WContainerWidget *parent = 0);
|
||||
|
||||
void search(Database::SearchFilter filter, std::size_t nb);
|
||||
|
||||
@@ -48,7 +48,6 @@ class ArtistSearch : public Wt::WContainerWidget
|
||||
void clear(void);
|
||||
void addResults(Database::SearchFilter filter, size_t nb);
|
||||
|
||||
Database::Handler& _db;
|
||||
std::size_t _resCount;
|
||||
};
|
||||
|
||||
|
||||
@@ -27,6 +27,8 @@
|
||||
#include <Wt/WText>
|
||||
#include <Wt/WTable>
|
||||
|
||||
#include "LmsApplication.hpp"
|
||||
|
||||
#include "MobileAudio.hpp"
|
||||
|
||||
#include "ArtistSearch.hpp"
|
||||
@@ -39,9 +41,8 @@
|
||||
namespace UserInterface {
|
||||
namespace Mobile {
|
||||
|
||||
Audio::Audio(Database::Handler& db, Wt::WContainerWidget *parent)
|
||||
: UserInterface::Audio(parent),
|
||||
_db(db)
|
||||
Audio::Audio(Wt::WContainerWidget *parent)
|
||||
: UserInterface::Audio(parent)
|
||||
{
|
||||
// Root div has to be a "container"
|
||||
this->setStyleClass("container-fluid");
|
||||
@@ -56,27 +57,29 @@ _db(db)
|
||||
search->bindWidget("search", edit);
|
||||
search->setMargin(10);
|
||||
|
||||
ArtistSearch* artistSearch = new ArtistSearch(_db, this);
|
||||
ReleaseSearch* releaseSearch = new ReleaseSearch(_db, this);
|
||||
TrackSearch* trackSearch = new TrackSearch(_db, this);
|
||||
ArtistSearch* artistSearch = new ArtistSearch(this);
|
||||
ReleaseSearch* releaseSearch = new ReleaseSearch(this);
|
||||
TrackSearch* trackSearch = new TrackSearch(this);
|
||||
|
||||
Wt::WTemplate* footer = new Wt::WTemplate(this);
|
||||
footer->setTemplateText(Wt::WString::tr("mobile-audio-footer"));
|
||||
|
||||
Wt::Dbo::Transaction transaction(_db.getSession());
|
||||
Database::User::pointer user = _db.getCurrentUser();
|
||||
|
||||
// Determine the encoding to be used
|
||||
Wt::WMediaPlayer::Encoding encoding;
|
||||
switch (user->getAudioEncoding())
|
||||
|
||||
{
|
||||
case Database::AudioEncoding::MP3: encoding = Wt::WMediaPlayer::MP3; break;
|
||||
case Database::AudioEncoding::WEBMA: encoding = Wt::WMediaPlayer::WEBMA; break;
|
||||
case Database::AudioEncoding::OGA: encoding = Wt::WMediaPlayer::OGA; break;
|
||||
case Database::AudioEncoding::FLA: encoding = Wt::WMediaPlayer::FLA; break;
|
||||
case Database::AudioEncoding::AUTO:
|
||||
default:
|
||||
encoding = AudioMediaPlayer::getBestEncoding();
|
||||
Wt::Dbo::Transaction transaction (DboSession());
|
||||
|
||||
switch (CurrentUser()->getAudioEncoding())
|
||||
{
|
||||
case Database::AudioEncoding::MP3: encoding = Wt::WMediaPlayer::MP3; break;
|
||||
case Database::AudioEncoding::WEBMA: encoding = Wt::WMediaPlayer::WEBMA; break;
|
||||
case Database::AudioEncoding::OGA: encoding = Wt::WMediaPlayer::OGA; break;
|
||||
case Database::AudioEncoding::FLA: encoding = Wt::WMediaPlayer::FLA; break;
|
||||
case Database::AudioEncoding::AUTO:
|
||||
default:
|
||||
encoding = AudioMediaPlayer::getBestEncoding();
|
||||
}
|
||||
}
|
||||
|
||||
AudioMediaPlayer* mediaPlayer = new AudioMediaPlayer(db, encoding);
|
||||
@@ -185,9 +188,10 @@ _db(db)
|
||||
trackSearch->trackPlay().connect(std::bind([=] (Database::Track::id_type id)
|
||||
{
|
||||
LMS_LOG(MOD_UI, SEV_DEBUG) << "Playing track id " << id;
|
||||
Wt::Dbo::Transaction transaction(_db.getSession());
|
||||
// TODO reduce transaction scope here
|
||||
Wt::Dbo::Transaction transaction(DboSession());
|
||||
|
||||
Database::Track::pointer track = Database::Track::getById(_db.getSession(), id);
|
||||
Database::Track::pointer track = Database::Track::getById(DboSession(), id);
|
||||
|
||||
if (track)
|
||||
{
|
||||
|
||||
@@ -22,8 +22,6 @@
|
||||
|
||||
#include <Wt/WContainerWidget>
|
||||
|
||||
#include "database/DatabaseHandler.hpp"
|
||||
|
||||
#include "audio/Audio.hpp"
|
||||
|
||||
namespace UserInterface {
|
||||
@@ -32,13 +30,12 @@ namespace Mobile {
|
||||
class Audio : public UserInterface::Audio
|
||||
{
|
||||
public:
|
||||
Audio(Database::Handler& db, Wt::WContainerWidget *parent = 0);
|
||||
Audio(Wt::WContainerWidget *parent = 0);
|
||||
|
||||
void search(std::string text) {}
|
||||
|
||||
private:
|
||||
|
||||
Database::Handler& _db;
|
||||
};
|
||||
|
||||
} // namespace Mobile
|
||||
|
||||
@@ -23,23 +23,21 @@
|
||||
#include <Wt/WTemplate>
|
||||
|
||||
#include "logger/Logger.hpp"
|
||||
#include "LmsApplication.hpp"
|
||||
|
||||
#include "ReleaseSearch.hpp"
|
||||
|
||||
namespace UserInterface {
|
||||
namespace Mobile {
|
||||
|
||||
ReleaseSearch::ReleaseSearch(Database::Handler& db, Wt::WContainerWidget *parent)
|
||||
ReleaseSearch::ReleaseSearch(Wt::WContainerWidget *parent)
|
||||
: Wt::WContainerWidget(parent),
|
||||
_db(db),
|
||||
_resCount(0)
|
||||
{
|
||||
Wt::WTemplate* title = new Wt::WTemplate(this);
|
||||
title->setTemplateText(Wt::WString::tr("mobile-search-title"));
|
||||
|
||||
title->bindWidget("text", new Wt::WText("Releases", Wt::PlainText));
|
||||
|
||||
_coverResource = new CoverResource(db, 56);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -65,10 +63,10 @@ ReleaseSearch::addResults(Database::SearchFilter filter, size_t nb)
|
||||
std::vector<std::string> releases;
|
||||
|
||||
{
|
||||
Wt::Dbo::Transaction transaction(_db.getSession());
|
||||
Wt::Dbo::Transaction transaction(DboSession());
|
||||
|
||||
// Request one more to see if more results are to be expected
|
||||
releases = Database::Track::getReleases(_db.getSession(), filter, _resCount, nb + 1);
|
||||
releases = Database::Track::getReleases(DboSession(), filter, _resCount, nb + 1);
|
||||
}
|
||||
|
||||
bool expectMoreResults;
|
||||
@@ -87,7 +85,7 @@ ReleaseSearch::addResults(Database::SearchFilter filter, size_t nb)
|
||||
|
||||
Wt::WImage *cover = new Wt::WImage();
|
||||
cover->setStyleClass("center-block");
|
||||
cover->setImageLink( Wt::WLink( _coverResource->getReleaseUrl(release)));
|
||||
cover->setImageLink( Wt::WLink( LmsApplication::instance()->getCoverResource()->getReleaseUrl(release, 56)));
|
||||
releaseWidget->bindWidget("cover", cover);
|
||||
|
||||
releaseWidget->bindWidget("name", new Wt::WText(Wt::WString::fromUTF8(release), Wt::PlainText));
|
||||
|
||||
@@ -25,10 +25,6 @@
|
||||
#include <Wt/WContainerWidget>
|
||||
#include <Wt/WSignal>
|
||||
|
||||
#include "resource/CoverResource.hpp"
|
||||
|
||||
#include "database/DatabaseHandler.hpp"
|
||||
|
||||
namespace UserInterface {
|
||||
namespace Mobile {
|
||||
|
||||
@@ -36,7 +32,7 @@ class ReleaseSearch : public Wt::WContainerWidget
|
||||
{
|
||||
public:
|
||||
|
||||
ReleaseSearch(Database::Handler& db, Wt::WContainerWidget *parent = 0);
|
||||
ReleaseSearch(Wt::WContainerWidget *parent = 0);
|
||||
|
||||
void search(Database::SearchFilter filter, size_t nb);
|
||||
|
||||
@@ -52,10 +48,6 @@ class ReleaseSearch : public Wt::WContainerWidget
|
||||
void clear(void);
|
||||
void addResults(Database::SearchFilter filter, size_t nb);
|
||||
|
||||
Database::Handler& _db;
|
||||
|
||||
CoverResource* _coverResource;
|
||||
|
||||
std::size_t _resCount;
|
||||
};
|
||||
|
||||
|
||||
@@ -23,15 +23,15 @@
|
||||
#include <Wt/WTemplate>
|
||||
|
||||
#include "logger/Logger.hpp"
|
||||
#include "LmsApplication.hpp"
|
||||
|
||||
#include "TrackSearch.hpp"
|
||||
|
||||
namespace UserInterface {
|
||||
namespace Mobile {
|
||||
|
||||
TrackSearch::TrackSearch(Database::Handler& db, Wt::WContainerWidget *parent)
|
||||
TrackSearch::TrackSearch(Wt::WContainerWidget *parent)
|
||||
: Wt::WContainerWidget(parent),
|
||||
_db(db),
|
||||
_resCount(0)
|
||||
{
|
||||
Wt::WTemplate* title = new Wt::WTemplate(this);
|
||||
@@ -39,7 +39,6 @@ _resCount(0)
|
||||
|
||||
title->bindWidget("text", new Wt::WText("Tracks", Wt::PlainText));
|
||||
|
||||
_coverResource = new CoverResource(db, 56);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -61,9 +60,9 @@ TrackSearch::search(Database::SearchFilter filter, size_t max)
|
||||
void
|
||||
TrackSearch::addResults(Database::SearchFilter filter, size_t nb)
|
||||
{
|
||||
Wt::Dbo::Transaction transaction(_db.getSession());
|
||||
Wt::Dbo::Transaction transaction(DboSession());
|
||||
|
||||
std::vector< Database::Track::pointer > tracks = Database::Track::getTracks(_db.getSession(), filter, _resCount, nb + 1);
|
||||
std::vector< Database::Track::pointer > tracks = Database::Track::getTracks(DboSession(), filter, _resCount, nb + 1);
|
||||
|
||||
bool expectMoreResults;
|
||||
if (tracks.size() == nb + 1)
|
||||
@@ -81,7 +80,7 @@ TrackSearch::addResults(Database::SearchFilter filter, size_t nb)
|
||||
|
||||
Wt::WImage *cover = new Wt::WImage();
|
||||
cover->setStyleClass("center-block");
|
||||
cover->setImageLink( Wt::WLink (_coverResource->getTrackUrl(track.id())) );
|
||||
cover->setImageLink( Wt::WLink (LmsApplication::instance()->getCoverResource()->getTrackUrl(track.id(), 56)) );
|
||||
trackWidget->bindWidget("cover", cover);
|
||||
|
||||
// Track Name (bold)
|
||||
|
||||
@@ -27,8 +27,6 @@
|
||||
|
||||
#include "resource/CoverResource.hpp"
|
||||
|
||||
#include "database/DatabaseHandler.hpp"
|
||||
|
||||
namespace UserInterface {
|
||||
namespace Mobile {
|
||||
|
||||
@@ -36,7 +34,7 @@ class TrackSearch : public Wt::WContainerWidget
|
||||
{
|
||||
public:
|
||||
|
||||
TrackSearch(Database::Handler& db, Wt::WContainerWidget *parent = 0);
|
||||
TrackSearch(Wt::WContainerWidget *parent = 0);
|
||||
|
||||
void search(Database::SearchFilter filter, size_t nb);
|
||||
|
||||
@@ -52,10 +50,6 @@ class TrackSearch : public Wt::WContainerWidget
|
||||
void clear(void);
|
||||
void addResults(Database::SearchFilter filter, size_t nb);
|
||||
|
||||
Database::Handler& _db;
|
||||
|
||||
CoverResource* _coverResource;
|
||||
|
||||
std::size_t _resCount;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user