Created UserInterface namespace, WebServerService -> UserInterfaceService.

This commit is contained in:
emeric
2014-04-12 21:28:20 +02:00
parent 788a7638bc
commit 298f6fb885
46 changed files with 291 additions and 167 deletions
+19 -4
View File
@@ -11,6 +11,18 @@
#include "LmsApplication.hpp"
namespace UserInterface {
Wt::WApplication*
LmsApplication::create(const Wt::WEnvironment& env, boost::filesystem::path dbPath)
{
/*
* You could read information from the environment to decide whether
* the user has permission to start a new application
*/
std::cout << "Creating new Application" << std::endl;
return new LmsApplication(env, dbPath);
}
/*
* The env argument contains information about the new session, and
@@ -18,8 +30,9 @@
* constructor so it is typically also an argument for your custom
* application constructor.
*/
LmsApplication::LmsApplication(const Wt::WEnvironment& env)
: Wt::WApplication(env)
LmsApplication::LmsApplication(const Wt::WEnvironment& env, boost::filesystem::path dbPath)
: Wt::WApplication(env),
_sessionData(dbPath)
{
setTheme(new Wt::WBootstrapTheme());
@@ -40,8 +53,8 @@ LmsApplication::LmsApplication(const Wt::WEnvironment& env)
Wt::WMenu *leftMenu = new Wt::WMenu(contentsStack, container);
navigation->addMenu(leftMenu);
_audioWidget = new AudioWidget();
_videoWidget = new VideoWidget();
_audioWidget = new AudioWidget(_sessionData);
_videoWidget = new VideoWidget(_sessionData);
leftMenu->addItem("Audio", _audioWidget);
leftMenu->addItem("Video", _videoWidget);
@@ -79,3 +92,5 @@ LmsApplication::handleSearch(void)
_audioWidget->search( _searchEdit->text().toUTF8() );
}
} // namespace DatabaseHandler
+10 -1
View File
@@ -5,19 +5,28 @@
#include "audio/AudioWidget.hpp"
#include "video/VideoWidget.hpp"
namespace UserInterface {
class LmsApplication : public Wt::WApplication
{
public:
LmsApplication(const Wt::WEnvironment& env);
static Wt::WApplication *create(const Wt::WEnvironment& env, boost::filesystem::path dbPath);
LmsApplication(const Wt::WEnvironment& env, boost::filesystem::path dbPath);
private:
void handleSearch();
SessionData _sessionData;
Wt::WLineEdit* _searchEdit;
AudioWidget* _audioWidget;
VideoWidget* _videoWidget;
};
} // namespace UserInterface
+8 -6
View File
@@ -9,9 +9,10 @@
#include "SearchFilterWidget.hpp"
#include "TrackWidget.hpp"
AudioDatabaseWidget::AudioDatabaseWidget( Wt::WContainerWidget *parent)
namespace UserInterface {
AudioDatabaseWidget::AudioDatabaseWidget( DatabaseHandler& db, Wt::WContainerWidget *parent)
: Wt::WContainerWidget(parent),
_db("test.db"), // TODO
_refreshingFilters(false)
{
std::size_t idFilter (0);
@@ -22,23 +23,23 @@ _refreshingFilters(false)
}
{
TableFilterWidget* filterTable = new TableFilterWidget(_db, "genre", "name", this);
TableFilterWidget* filterTable = new TableFilterWidget(db, "genre", "name", this);
_filters.push_back( filterTable );
filterTable->update().connect( boost::bind(&AudioDatabaseWidget::handleFilterUpdated, this, idFilter++) );
}
{
TableFilterWidget* filterTable = new TableFilterWidget(_db, "artist", "name", this);
TableFilterWidget* filterTable = new TableFilterWidget(db, "artist", "name", this);
_filters.push_back( filterTable );
filterTable->update().connect( boost::bind(&AudioDatabaseWidget::handleFilterUpdated, this, idFilter++) );
}
{
TableFilterWidget* filterTable = new TableFilterWidget(_db, "release", "name", this);
TableFilterWidget* filterTable = new TableFilterWidget(db, "release", "name", this);
_filters.push_back( filterTable );
filterTable->update().connect( boost::bind(&AudioDatabaseWidget::handleFilterUpdated, this, idFilter++) );
}
{
TrackWidget* track = new TrackWidget(_db, this);
TrackWidget* track = new TrackWidget(db, this);
_filters.push_back( track );
track->trackSelected().connect(this, &AudioDatabaseWidget::handleTrackSelected);
}
@@ -104,5 +105,6 @@ AudioDatabaseWidget::selectNextTrack(void)
trackWidget->selectNextTrack();
}
} // namespace UserInterface
+5 -4
View File
@@ -6,14 +6,16 @@
#include <Wt/WContainerWidget>
#include <Wt/WSignal>
#include "database/DatabaseHandler.hpp"
#include "common/SessionData.hpp"
#include "FilterWidget.hpp"
namespace UserInterface {
class AudioDatabaseWidget : public Wt::WContainerWidget
{
public:
AudioDatabaseWidget( Wt::WContainerWidget *parent = 0);
AudioDatabaseWidget( DatabaseHandler& db, Wt::WContainerWidget *parent = 0);
void search(const std::string& text);
@@ -24,8 +26,6 @@ class AudioDatabaseWidget : public Wt::WContainerWidget
private:
DatabaseHandler _db;
Wt::Signal< boost::filesystem::path > _trackSelected;
void handleTrackSelected(boost::filesystem::path p);
@@ -37,6 +37,7 @@ class AudioDatabaseWidget : public Wt::WContainerWidget
};
} // namespace UserInterface
#endif
+3
View File
@@ -4,6 +4,7 @@
#include "AudioMediaPlayerWidget.hpp"
namespace UserInterface {
AudioMediaPlayerWidget::AudioMediaPlayerWidget( Wt::WContainerWidget *parent)
: Wt::WContainerWidget(parent),
@@ -155,3 +156,5 @@ AudioMediaPlayerWidget::handleVolumeSliderMoved(int value)
{
_mediaPlayer->setVolume( value / 100. );
}
} // namespace UserInterface
+3 -1
View File
@@ -10,10 +10,11 @@
#include <Wt/WLink>
#include <Wt/WText>
#include "transcode/Parameters.hpp"
#include "resource/AvConvTranscodeStreamResource.hpp"
namespace UserInterface {
class AudioMediaPlayerWidget : public Wt::WContainerWidget
{
public:
@@ -63,6 +64,7 @@ class AudioMediaPlayerWidget : public Wt::WContainerWidget
};
} // namespace UserInterface
#endif
+5 -2
View File
@@ -4,15 +4,17 @@
#include "metadata/Extractor.hpp"
namespace UserInterface {
AudioWidget::AudioWidget(Wt::WContainerWidget* parent)
AudioWidget::AudioWidget(SessionData& sessionData, Wt::WContainerWidget* parent)
: Wt::WContainerWidget(parent),
_sessionData(sessionData),
_audioDbWidget(nullptr),
_mediaPlayer(nullptr),
_imgResource(nullptr),
_img(nullptr)
{
_audioDbWidget = new AudioDatabaseWidget(this);
_audioDbWidget = new AudioDatabaseWidget(sessionData.getDatabaseHandler(), this);
_audioDbWidget->trackSelected().connect(this, &AudioWidget::playTrack);
@@ -78,4 +80,5 @@ AudioWidget::handleTrackEnded(void)
_audioDbWidget->selectNextTrack();
}
} // namespace UserInterface
+7 -1
View File
@@ -11,12 +11,14 @@
#include "audio/AudioMediaPlayerWidget.hpp"
#include "audio/AudioDatabaseWidget.hpp"
namespace UserInterface {
class AudioWidget : public Wt::WContainerWidget
{
public:
AudioWidget(Wt::WContainerWidget* parent = 0);
AudioWidget(SessionData& sessionData, Wt::WContainerWidget* parent = 0);
void search(const std::string& searchText);
@@ -26,6 +28,8 @@ class AudioWidget : public Wt::WContainerWidget
void handleTrackEnded(void);
SessionData& _sessionData;
AudioDatabaseWidget* _audioDbWidget;
AudioMediaPlayerWidget* _mediaPlayer;
@@ -39,5 +43,7 @@ class AudioWidget : public Wt::WContainerWidget
};
} // namespace UserInterface
#endif
+3 -3
View File
@@ -10,6 +10,8 @@
#include "database/SqlQuery.hpp"
namespace UserInterface {
class FilterWidget : public Wt::WContainerWidget {
public:
@@ -39,8 +41,6 @@ class FilterWidget : public Wt::WContainerWidget {
Wt::Signal<void> _update;
};
} // namespace UserInterface
#endif
+2
View File
@@ -2,6 +2,7 @@
#include "SearchFilterWidget.hpp"
namespace UserInterface {
SearchFilterWidget::SearchFilterWidget(Wt::WContainerWidget* parent)
: FilterWidget( parent )
@@ -30,4 +31,5 @@ SearchFilterWidget::getConstraint(Constraint& constraint)
// else no constraint!
}
} // namespace UserInterface
+3 -3
View File
@@ -5,6 +5,8 @@
#include "FilterWidget.hpp"
namespace UserInterface {
class SearchFilterWidget : public FilterWidget {
public:
SearchFilterWidget(Wt::WContainerWidget* parent = 0);
@@ -24,9 +26,7 @@ class SearchFilterWidget : public FilterWidget {
std::string _lastEmittedText;
};
} // namespace UserInterface
#endif
+4
View File
@@ -2,6 +2,8 @@
#include "TableFilterWidget.hpp"
namespace UserInterface {
TableFilterWidget::TableFilterWidget(DatabaseHandler& db, std::string table, std::string field, Wt::WContainerWidget* parent)
: FilterWidget( parent ),
_db(db),
@@ -88,3 +90,5 @@ TableFilterWidget::getConstraint(Constraint& constraint)
constraint.where.And( clause );
}
} // namespace UserInterface
+3 -1
View File
@@ -8,6 +8,8 @@
#include "FilterWidget.hpp"
#include "database/DatabaseHandler.hpp"
namespace UserInterface {
class TableFilterWidget : public FilterWidget
{
@@ -32,7 +34,7 @@ class TableFilterWidget : public FilterWidget
Wt::WTableView* _tableView;
};
} // namespace UserInterface
#endif
+4
View File
@@ -6,6 +6,8 @@
#include "TrackWidget.hpp"
namespace UserInterface {
TrackWidget::TrackWidget( DatabaseHandler& db, Wt::WContainerWidget* parent)
: FilterWidget( parent ),
_db(db),
@@ -132,3 +134,5 @@ TrackWidget::selectNextTrack(void)
}
}
} // namespace UserInterface
+3
View File
@@ -9,6 +9,7 @@
#include "FilterWidget.hpp"
namespace UserInterface {
class TrackWidget : public FilterWidget
{
@@ -45,5 +46,7 @@ class TrackWidget : public FilterWidget
};
} // namespace UserInterface
#endif
+11
View File
@@ -0,0 +1,11 @@
#include "SessionData.hpp"
namespace UserInterface {
SessionData::SessionData(boost::filesystem::path dbPath)
: _db(dbPath)
{
}
} // namespace UserInterface
+35
View File
@@ -0,0 +1,35 @@
#ifndef UI_SESSION_DATA_HPP
#define UI_SESSION_DATA_HPP
#include <string>
#include <boost/filesystem.hpp>
#include "database/DatabaseHandler.hpp"
namespace UserInterface {
class SessionData
{
public:
SessionData(boost::filesystem::path dbPath);
void setAuthenticatedUser(std::string user);
DatabaseHandler& getDatabaseHandler() { return _db;}
const DatabaseHandler& getDatabaseHandler() const { return _db;}
private:
DatabaseHandler _db;
std::string _authenticatedUser;
};
} // namespace UserInterface
#endif
@@ -3,6 +3,8 @@
#include <Wt/Http/Response>
#include "AvConvTranscodeStreamResource.hpp"
namespace UserInterface {
AvConvTranscodeStreamResource::AvConvTranscodeStreamResource(const Transcode::Parameters& parameters, Wt::WObject *parent)
: Wt::WResource(parent),
_parameters( parameters )
@@ -71,6 +73,6 @@ AvConvTranscodeStreamResource::handleRequest(const Wt::Http::Request& request,
std::cout << "No more data!" << std::endl;
}
} // namespace UserInterface
@@ -1,15 +1,15 @@
#ifndef AVCONV_TRANSCODE_STREAM_RESOURCE_HPP
#define AVCONV_TRANSCODE_STREAM_RESOURCE_HPP
#include <deque>
#include <iostream>
#include <memory>
#include <boost/filesystem.hpp>
#include <Wt/WResource>
#include "transcode/AvConvTranscoder.hpp"
#include "transcode/Parameters.hpp"
namespace UserInterface {
class AvConvTranscodeStreamResource : public Wt::WResource
{
@@ -28,7 +28,7 @@ class AvConvTranscodeStreamResource : public Wt::WResource
static const std::size_t _bufferSize = 8192*16;
};
} // namespace UserInterface
#endif
+5 -2
View File
@@ -11,10 +11,11 @@
#include "VideoDatabaseWidget.hpp"
namespace UserInterface {
VideoDatabaseWidget::VideoDatabaseWidget( Wt::WContainerWidget *parent)
VideoDatabaseWidget::VideoDatabaseWidget(DatabaseHandler& db, Wt::WContainerWidget *parent)
: Wt::WContainerWidget(parent),
_db("test.db") // TODO
_db(db)
{
_table = new Wt::WTable( this );
_table->setHeaderCount(1);
@@ -137,3 +138,5 @@ VideoDatabaseWidget::handlePlayVideo(const boost::filesystem::path& videoFilePat
}
} // namespace UserInterface
+7 -4
View File
@@ -4,13 +4,15 @@
#include <Wt/WTable>
#include <Wt/WContainerWidget>
#include "database/DatabaseHandler.hpp"
#include "common/SessionData.hpp"
#include "database/FileTypes.hpp"
namespace UserInterface {
class VideoDatabaseWidget : public Wt::WContainerWidget
{
public:
VideoDatabaseWidget( Wt::WContainerWidget *parent = 0);
VideoDatabaseWidget( DatabaseHandler& db, Wt::WContainerWidget *parent = 0);
// Signals
Wt::Signal< boost::filesystem::path >& playVideo() { return _playVideo; }
@@ -26,13 +28,14 @@ class VideoDatabaseWidget : public Wt::WContainerWidget
void addDirectory(const std::string& name, const boost::filesystem::path& path);
void addVideo(const std::string& name, const boost::posix_time::time_duration& duration, const boost::filesystem::path& path);
Wt::Signal< boost::filesystem::path > _playVideo;
DatabaseHandler& _db;
DatabaseHandler _db;
Wt::Signal< boost::filesystem::path > _playVideo;
Wt::WTable* _table;
};
} // namespace UserInterface
#endif
+3
View File
@@ -7,6 +7,7 @@
#include "VideoMediaPlayerWidget.hpp"
namespace UserInterface {
Wt::WMediaPlayer::Encoding
convert(Transcode::Format format)
@@ -178,3 +179,5 @@ VideoMediaPlayerWidget::handleParametersDone(Wt::WDialog::DialogCode code)
}
}
} // namespace UserInterface
+3
View File
@@ -12,6 +12,8 @@
#include "transcode/Parameters.hpp"
#include "resource/AvConvTranscodeStreamResource.hpp"
namespace UserInterface {
class VideoMediaPlayerWidget : public Wt::WContainerWidget
{
public:
@@ -58,6 +60,7 @@ class VideoMediaPlayerWidget : public Wt::WContainerWidget
VideoParametersDialog* _dialog;
};
} // namespace UserInterface
#endif
+3
View File
@@ -8,6 +8,8 @@
using namespace Transcode;
namespace UserInterface {
static const std::list<Stream::Type> streamTypes = {Stream::Video, Stream::Audio, Stream::Subtitle};
VideoParametersDialog::VideoParametersDialog(const Wt::WString &windowTitle, Wt::WDialog* parent)
@@ -165,4 +167,5 @@ VideoParametersDialog::save(Transcode::Parameters& parameters)
}
}
} // namespace UserInterface
+4
View File
@@ -11,6 +11,8 @@
#include "transcode/Parameters.hpp"
namespace UserInterface {
class VideoParametersDialog : public Wt::WDialog
{
public:
@@ -43,5 +45,7 @@ class VideoParametersDialog : public Wt::WDialog
std::map<Transcode::Stream::Type, std::pair<Wt::WComboBox*, Wt::WStringListModel* > > _streamSelection;
};
} // namespace UserInterface
#endif
+7 -3
View File
@@ -3,12 +3,14 @@
#include "VideoWidget.hpp"
namespace UserInterface {
VideoWidget::VideoWidget(Wt::WContainerWidget* parent )
: Wt::WContainerWidget(parent)
VideoWidget::VideoWidget(SessionData& sessionData, Wt::WContainerWidget* parent )
: Wt::WContainerWidget(parent),
_sessionData(sessionData)
{
_videoDbWidget = new VideoDatabaseWidget(this);
_videoDbWidget = new VideoDatabaseWidget(_sessionData.getDatabaseHandler(), this);
_videoDbWidget->playVideo().connect(this, &VideoWidget::playVideo);
@@ -61,3 +63,5 @@ VideoWidget::playVideo(boost::filesystem::path p)
}
}
} // namespace UserInterface
+9 -1
View File
@@ -5,14 +5,18 @@
#include <Wt/WContainerWidget>
#include "common/SessionData.hpp"
#include "video/VideoMediaPlayerWidget.hpp"
#include "video/VideoDatabaseWidget.hpp"
namespace UserInterface {
class VideoWidget : public Wt::WContainerWidget
{
public:
VideoWidget(Wt::WContainerWidget* parent = 0);
VideoWidget(SessionData& sessionData, Wt::WContainerWidget* parent = 0);
void search(const std::string& searchText);
@@ -21,10 +25,14 @@ class VideoWidget : public Wt::WContainerWidget
void backToList(void);
void playVideo(boost::filesystem::path p);
SessionData& _sessionData;
VideoDatabaseWidget* _videoDbWidget;
VideoMediaPlayerWidget* _mediaPlayer;
};
} // namespace UserInterface
#endif