WIP. Database updater now has its own namespace and dedicated directory

This commit is contained in:
emeric
2014-07-01 23:43:49 +02:00
parent 7fd546eb44
commit 16d1194d61
35 changed files with 320 additions and 224 deletions
+4 -3
View File
@@ -8,7 +8,7 @@ bin_PROGRAMS = lms
lms_SOURCES = \
$(top_srcdir)/main/main.cpp \
$(top_srcdir)/main/ServiceManager.cpp \
$(top_srcdir)/main/DatabaseRefreshService.cpp \
$(top_srcdir)/main/DatabaseUpdateService.cpp \
$(top_srcdir)/main/UserInterfaceService.cpp \
$(top_srcdir)/av/CodecContext.cpp \
$(top_srcdir)/av/Common.cpp \
@@ -34,13 +34,14 @@ lms_SOURCES = \
$(top_srcdir)/database/Artist.cpp \
$(top_srcdir)/database/Genre.cpp \
$(top_srcdir)/database/Release.cpp \
$(top_srcdir)/database/MediaDirectory.cpp \
$(top_srcdir)/database/Track.cpp \
$(top_srcdir)/database/Database.cpp \
$(top_srcdir)/database/DatabaseHandler.cpp \
$(top_srcdir)/database/Checksum.cpp \
$(top_srcdir)/database/SqlQuery.cpp \
$(top_srcdir)/database/Path.cpp \
$(top_srcdir)/database/Video.cpp \
$(top_srcdir)/database-updater/DatabaseUpdater.cpp \
$(top_srcdir)/database-updater/Checksum.cpp \
$(top_srcdir)/transcode/AvConvTranscoder.cpp \
$(top_srcdir)/transcode/Format.cpp \
$(top_srcdir)/transcode/Parameters.cpp \
@@ -3,16 +3,19 @@
#include <boost/foreach.hpp>
#include <boost/thread.hpp>
#include "Database.hpp"
#include "Checksum.hpp"
#include "AudioTypes.hpp"
#include "database/MediaDirectory.hpp"
#include "database/AudioTypes.hpp"
#include "transcode/InputMediaFile.hpp"
namespace Database {
#include "Checksum.hpp"
#include "DatabaseUpdater.hpp"
Database::Database(boost::filesystem::path dbPath, MetaData::Parser& parser)
namespace DatabaseUpdater {
using namespace Database;
Updater::Updater(boost::filesystem::path dbPath, MetaData::Parser& parser)
: _db(dbPath),
_metadataParser(parser)
{
@@ -20,42 +23,30 @@ Database::Database(boost::filesystem::path dbPath, MetaData::Parser& parser)
}
void
Database::watchDirectory(WatchedDirectory directory)
{
_directories.push_back(directory);
}
void
Database::unwatchDirectory(WatchedDirectory directory)
{
std::list<WatchedDirectory>::iterator it = std::find(_directories.begin(), _directories.end(), directory);
if (it != _directories.end())
_directories.erase(it);
}
void
Database::refresh(void)
Updater::process(void)
{
removeMissingAudioFiles();
// TODO video files
BOOST_FOREACH( const WatchedDirectory& directory, _directories) {
switch (directory.getType()) {
case WatchedDirectory::Audio:
refreshAudioDirectory(directory.getPath());
Wt::Dbo::Transaction transaction(_db.getSession());
std::vector<MediaDirectory::pointer> mediaDirectories = MediaDirectory::getAll(_db.getSession());
BOOST_FOREACH( MediaDirectory::pointer directory, mediaDirectories)
{
switch (directory->getType()) {
case MediaDirectory::Audio:
refreshAudioDirectory(directory->getPath());
break;
case WatchedDirectory::Video:
refreshVideoDirectory(directory.getPath());
case MediaDirectory::Video:
refreshVideoDirectory(directory->getPath());
break;
default:
assert(0);
}
}
}
void
Database::processAudioFile( const boost::filesystem::path& file)
Updater::processAudioFile( const boost::filesystem::path& file)
{
try {
@@ -231,7 +222,7 @@ Database::processAudioFile( const boost::filesystem::path& file)
void
Database::refreshAudioDirectory( const boost::filesystem::path& p)
Updater::refreshAudioDirectory( const boost::filesystem::path& p)
{
std::cout << "Refreshing audio directory " << p << std::endl;
if (boost::filesystem::exists(p) && boost::filesystem::is_directory(p)) {
@@ -265,7 +256,7 @@ Database::refreshAudioDirectory( const boost::filesystem::path& p)
}
void
Database::removeMissingAudioFiles( void )
Updater::removeMissingAudioFiles( void )
{
std::cerr << "Removing missing files..." << std::endl;
Wt::Dbo::Transaction transaction(_db.getSession());
@@ -291,7 +282,7 @@ Database::removeMissingAudioFiles( void )
}
Path::pointer
Database::getAddPath(const boost::filesystem::path& path)
Updater::getAddPath(const boost::filesystem::path& path)
{
Path::pointer res;
Path::pointer parentDirectory;
@@ -314,7 +305,7 @@ Database::getAddPath(const boost::filesystem::path& path)
void
Database::refreshVideoDirectory( const boost::filesystem::path& path)
Updater::refreshVideoDirectory( const boost::filesystem::path& path)
{
std::cout << "Refreshing video directory " << path << std::endl;
if (boost::filesystem::exists(path) && boost::filesystem::is_directory(path))
@@ -353,7 +344,7 @@ Database::refreshVideoDirectory( const boost::filesystem::path& path)
}
void
Database::processVideoFile( const boost::filesystem::path& file)
Updater::processVideoFile( const boost::filesystem::path& file)
{
try {
@@ -430,4 +421,4 @@ Database::processVideoFile( const boost::filesystem::path& file)
}
}
} // namespace Database
} // namespace DatabaseUpdater
+44
View File
@@ -0,0 +1,44 @@
#ifndef DB_UPDATER_UPDATER_HPP
#define DB_UPDATER_UPDATER_HPP
#include "metadata/MetaData.hpp"
#include "database/DatabaseHandler.hpp"
#include "database/FileTypes.hpp"
#include "database/DatabaseHandler.hpp"
namespace DatabaseUpdater {
class Updater
{
public:
Updater(boost::filesystem::path db, MetaData::Parser& parser);
// Update database
void process();
private:
// void refresh(const WatchedDirectory& directory);
// Video
void refreshVideoDirectory( const boost::filesystem::path& directory );
void processVideoFile( const boost::filesystem::path& file);
// Audio
void removeMissingAudioFiles( void );
void refreshAudioDirectory( const boost::filesystem::path& directory);
void processAudioFile( const boost::filesystem::path& file);
Database::Path::pointer getAddPath(const boost::filesystem::path& path);
Database::Handler _db;
MetaData::Parser& _metadataParser;
}; // class Updater
} // DatabaseUpdater
#endif
-69
View File
@@ -1,69 +0,0 @@
#include "metadata/MetaData.hpp"
#include "DatabaseHandler.hpp"
#include "FileTypes.hpp"
namespace Database {
class WatchedDirectory {
public:
enum Type {
Audio,
Video,
};
WatchedDirectory( boost::filesystem::path path, Type type) : _path(path), _type(type) {
if (!boost::filesystem::is_directory(path))
throw std::runtime_error( "path '" + path.string() + "' is not a directory!");
}
bool operator==(WatchedDirectory const& other) { return _path == other._path && _type == other._type; }
const boost::filesystem::path& getPath() const { return _path; }
Type getType() const { return _type; }
private:
boost::filesystem::path _path;
Type _type;
};
class Database
{
public:
Database(boost::filesystem::path db, MetaData::Parser& parser);
void watchDirectory(WatchedDirectory dir);
void unwatchDirectory(WatchedDirectory dir);
// Rescan media folders
void refresh();
private:
void refresh(const WatchedDirectory& directory);
// Video
void refreshVideoDirectory( const boost::filesystem::path& directory );
void processVideoFile( const boost::filesystem::path& file);
// Audio
void removeMissingAudioFiles( void );
void refreshAudioDirectory( const boost::filesystem::path& directory);
void processAudioFile( const boost::filesystem::path& file);
Path::pointer getAddPath(const boost::filesystem::path& path);
DatabaseHandler _db;
std::list<WatchedDirectory> _directories;
MetaData::Parser& _metadataParser;
};
} // Database
+6 -1
View File
@@ -2,9 +2,11 @@
#include "AudioTypes.hpp"
#include "FileTypes.hpp"
#include "MediaDirectory.hpp"
namespace Database {
DatabaseHandler::DatabaseHandler(boost::filesystem::path db)
Handler::Handler(boost::filesystem::path db)
:
_path(db),
_dbBackend( db.string() )
@@ -17,6 +19,8 @@ _dbBackend( db.string() )
_session.mapClass<Database::Release>("release");
_session.mapClass<Database::Path>("path");
_session.mapClass<Database::Video>("video");
_session.mapClass<Database::MediaDirectory>("media_directory");
_session.mapClass<Database::MediaDirectorySettings>("media_directory_settings");
try {
_session.createTables();
@@ -28,3 +32,4 @@ _dbBackend( db.string() )
_dbBackend.executeSql("pragma journal_mode=WAL");
}
} // namespace Database
+5 -2
View File
@@ -6,11 +6,13 @@
#include <Wt/Dbo/Dbo>
#include <Wt/Dbo/backend/Sqlite3>
namespace Database {
// Long living class handling the database
class DatabaseHandler
class Handler
{
public:
DatabaseHandler(boost::filesystem::path db);
Handler(boost::filesystem::path db);
Wt::Dbo::Session& getSession() { return _session; }
@@ -25,6 +27,7 @@ class DatabaseHandler
};
} // namespace Database
#endif
+26
View File
@@ -0,0 +1,26 @@
#include "MediaDirectory.hpp"
namespace Database {
MediaDirectorySettings::pointer
MediaDirectorySettings::get(Wt::Dbo::Session& session)
{
MediaDirectorySettings::pointer res;
res = session.find<MediaDirectorySettings>().where("id = ?").bind(1);
if (!res)
res = session.add( new MediaDirectorySettings());
return res;
}
std::vector<MediaDirectory::pointer>
MediaDirectory::getAll(Wt::Dbo::Session& session)
{
Wt::Dbo::collection< MediaDirectory::pointer > res = session.find<MediaDirectory>();
return std::vector<MediaDirectory::pointer>(res.begin(), res.end());
}
} // namespace Database
+91
View File
@@ -0,0 +1,91 @@
#ifndef DATABASE_MEDIA_DIRECTORY_HPP
#define DATABASE_MEDIA_DIRECTORY_HPP
#include <vector>
#include <boost/filesystem/path.hpp>
#include <Wt/Dbo/Dbo>
#include <Wt/Dbo/WtSqlTraits>
namespace Database {
class MediaDirectory;
class MediaDirectorySettings
{
public:
typedef Wt::Dbo::ptr<MediaDirectorySettings> pointer;
MediaDirectorySettings() {}
// accessors
static pointer get(Wt::Dbo::Session& session);
// write accessors
void addMediaDirectory(Wt::Dbo::ptr<MediaDirectory> mediaDirectory);
void setLastUpdate(boost::posix_time::ptime time) { _lastUpdate = time; }
void setLastScan(boost::posix_time::ptime time) { _lastScan = time; }
// Read accessors
boost::posix_time::ptime getLastUpdated(void) const { return _lastUpdate; }
template<class Action>
void persist(Action& a)
{
Wt::Dbo::field(a, _lastUpdate, "last_update");
Wt::Dbo::field(a, _lastScan, "last_scan");
Wt::Dbo::hasMany(a, _mediaDirectories, Wt::Dbo::ManyToOne, "media_directory_settings");
}
private:
boost::posix_time::time_duration _updatePeriod; // TODO
boost::posix_time::ptime _lastUpdate; // last time the database has changed
boost::posix_time::ptime _lastScan; // last time the database has been scanned
Wt::Dbo::collection< Wt::Dbo::ptr<MediaDirectory> > _mediaDirectories; // list of media directories
};
class MediaDirectory
{
public:
typedef Wt::Dbo::ptr<MediaDirectory> pointer;
enum Type {
Audio = 1,
Video = 2,
};
MediaDirectory() {}
MediaDirectory(boost::filesystem::path p, Type type);
// Accessors
static std::vector<MediaDirectory::pointer> getAll(Wt::Dbo::Session& session);
Type getType(void) const { return _type; }
boost::filesystem::path getPath(void) const { return boost::filesystem::path(_path); }
template<class Action>
void persist(Action& a)
{
Wt::Dbo::field(a, _type, "type");
Wt::Dbo::field(a, _path, "path");
Wt::Dbo::belongsTo(a, _settings, "media_directory_settings", Wt::Dbo::OnDeleteCascade);
}
private:
Type _type;
std::string _path;
MediaDirectorySettings::pointer _settings; // back pointer
};
} // namespace Database
#endif
-37
View File
@@ -1,37 +0,0 @@
#include <boost/thread.hpp>
#include "DatabaseRefreshService.hpp"
DatabaseRefreshService::DatabaseRefreshService(boost::asio::io_service& ioService, const boost::filesystem::path& p)
: _metadataParser(),
_database( p, _metadataParser)
{
// TODO read from the database itself!
// Move this code in the database class
_database.watchDirectory( Database::WatchedDirectory("/storage/common/Media/Son/Metal", Database::WatchedDirectory::Audio) );
_database.watchDirectory( Database::WatchedDirectory("/storage/common/Media/Video", Database::WatchedDirectory::Video) );
}
void
DatabaseRefreshService::start(void)
{
// _thread = boost::thread(boost::bind(&Database::refresh, &_database));
}
void
DatabaseRefreshService::stop(void)
{
std::cout << "DatabaseRefreshService::stop, processing..." << std::endl;
_thread.interrupt();
_thread.join();
std::cout << "DatabaseRefreshService::stop, process done" << std::endl;
}
void
DatabaseRefreshService::restart(void)
{
std::cout << "DatabaseRefreshService::restart, not implemented" << std::endl;
}
-31
View File
@@ -1,31 +0,0 @@
#ifndef DB_REFRESH_SERVICE_HPP
#define DB_REFRESH_SERVICE_HPP
#include <boost/thread.hpp>
#include <boost/asio/io_service.hpp>
#include "metadata/AvFormat.hpp"
#include "database/Database.hpp"
#include "Service.hpp"
class DatabaseRefreshService : public Service
{
public:
DatabaseRefreshService(boost::asio::io_service& ioService, const boost::filesystem::path& p);
void start(void);
void stop(void);
void restart(void);
private:
boost::thread _thread;
MetaData::AvFormat _metadataParser;
Database::Database _database; // Todo use handler
};
#endif
+33
View File
@@ -0,0 +1,33 @@
#include <boost/thread.hpp>
#include "DatabaseUpdateService.hpp"
DatabaseUpdateService::DatabaseUpdateService(boost::asio::io_service& ioService, const boost::filesystem::path& p)
: _metadataParser(),
_databaseUpdater( p, _metadataParser)
{
}
void
DatabaseUpdateService::start(void)
{
// _thread = boost::thread(boost::bind(&Database::refresh, &_databaseUpdater.);
}
void
DatabaseUpdateService::stop(void)
{
std::cout << "DatabaseUpdateService::stop, processing..." << std::endl;
_thread.interrupt();
_thread.join();
std::cout << "DatabaseUpdateService::stop, process done" << std::endl;
}
void
DatabaseUpdateService::restart(void)
{
std::cout << "DatabaseUpdateService::restart, not implemented" << std::endl;
}
+31
View File
@@ -0,0 +1,31 @@
#ifndef DB_UPDATE_SERVICE_HPP
#define DB_UPDATE_SERVICE_HPP
#include <boost/thread.hpp>
#include <boost/asio/io_service.hpp>
#include "metadata/AvFormat.hpp"
#include "database-updater/DatabaseUpdater.hpp"
#include "Service.hpp"
class DatabaseUpdateService : public Service
{
public:
DatabaseUpdateService(boost::asio::io_service& ioService, const boost::filesystem::path& p);
void start(void);
void stop(void);
void restart(void);
private:
boost::thread _thread;
MetaData::AvFormat _metadataParser;
DatabaseUpdater::Updater _databaseUpdater; // Todo use handler
};
#endif
+2 -2
View File
@@ -7,7 +7,7 @@
#include "av/Common.hpp"
#include "ServiceManager.hpp"
#include "DatabaseRefreshService.hpp"
#include "DatabaseUpdateService.hpp"
#include "UserInterfaceService.hpp"
#include "RemoteServerService.hpp"
@@ -32,7 +32,7 @@ int main(int argc, char* argv[])
std::cout << "Starting services..." << std::endl;
serviceManager.startService( std::make_shared<DatabaseRefreshService>( serviceManager.getIoService(), dbPath) );
serviceManager.startService( std::make_shared<DatabaseUpdateService>( serviceManager.getIoService(), dbPath) );
serviceManager.startService( std::make_shared<RemoteServerService>( serviceManager.getIoService(), remoteListenEndpoint, dbPath) );
serviceManager.startService( std::make_shared<UserInterfaceService>(argc, argv, dbPath) );
@@ -12,7 +12,7 @@
namespace Remote {
namespace Server {
AudioCollectionRequestHandler::AudioCollectionRequestHandler(DatabaseHandler& db)
AudioCollectionRequestHandler::AudioCollectionRequestHandler(Database::Handler& db)
: _db(db)
{}
@@ -11,7 +11,7 @@ namespace Server {
class AudioCollectionRequestHandler
{
public:
AudioCollectionRequestHandler(DatabaseHandler& db);
AudioCollectionRequestHandler(Database::Handler& db);
bool process(const AudioCollectionRequest& request, AudioCollectionResponse& response);
@@ -23,7 +23,7 @@ class AudioCollectionRequestHandler
bool processGetTracks(const AudioCollectionRequest::GetTrackList& request, AudioCollectionResponse::TrackList& response);
bool processGetCoverArt(const AudioCollectionRequest::GetCoverArt& request, AudioCollectionResponse& response);
DatabaseHandler& _db;
Database::Handler& _db;
static const std::size_t _maxListArtists = 256;
static const std::size_t _maxListGenres = 256;
+1 -1
View File
@@ -5,7 +5,7 @@
namespace Remote {
namespace Server {
MediaRequestHandler::MediaRequestHandler(DatabaseHandler& db)
MediaRequestHandler::MediaRequestHandler(Database::Handler& db)
: _db(db)
{}
+2 -2
View File
@@ -14,7 +14,7 @@ namespace Server {
class MediaRequestHandler
{
public:
MediaRequestHandler(DatabaseHandler& db);
MediaRequestHandler(Database::Handler& db);
bool process(const MediaRequest& request, MediaResponse& response);
@@ -28,7 +28,7 @@ class MediaRequestHandler
std::shared_ptr<Transcode::AvConvTranscoder> _transcoder;
DatabaseHandler& _db;
Database::Handler& _db;
static const std::size_t _maxPartSize = 65536 - 128;
};
+1 -1
View File
@@ -25,7 +25,7 @@ class RequestHandler
private:
DatabaseHandler _db;
Database::Handler _db;
AudioCollectionRequestHandler _audioCollectionRequestHandler;
MediaRequestHandler _mediaRequestHandler;
+7 -1
View File
@@ -4,6 +4,7 @@
#include "database/DatabaseHandler.hpp"
#include "database/FileTypes.hpp"
#include "database/MediaDirectory.hpp"
int main(void)
{
@@ -13,7 +14,7 @@ int main(void)
boost::filesystem::remove("test2.db");
// Set up the long living database session
DatabaseHandler database("test2.db");
Database::Handler database("test2.db");
Wt::Dbo::Transaction transaction(database.getSession());
@@ -70,6 +71,11 @@ int main(void)
std::cout << "Parent's = " << path->getParent()->getPath() << std::endl;
}
// Update last update
Database::MediaDirectorySettings::pointer settings = Database::MediaDirectorySettings::get(database.getSession());
settings.modify()->setLastUpdate(boost::posix_time::second_clock::local_time());
std::cout << "last update = " << settings->getLastUpdated() << std::endl;
// make some empty root dirs
+1 -1
View File
@@ -15,7 +15,7 @@ int main(void)
std::cout << "Starting test!" << std::endl;
// Set up the long living database session
DatabaseHandler database("test.db");
Database::Handler database("test.db");
Wt::Dbo::Transaction transaction(database.getSession());
+4 -6
View File
@@ -36,8 +36,7 @@ remote_SOURCES = \
$(top_srcdir)/database/DatabaseHandler.cpp \
$(top_srcdir)/database/SqlQuery.cpp \
$(top_srcdir)/database/Path.cpp \
$(top_srcdir)/database/Video.cpp \
$(top_srcdir)/database/Checksum.cpp
$(top_srcdir)/database/Video.cpp
remote_CXXFLAGS=-std=c++11 -Wall -Wextra -I$(top_srcdir) -I$(top_srcdir)/remote -I$(top_srcdir)/boost
@@ -50,8 +49,7 @@ database_integrity_SOURCES = \
$(top_srcdir)/database/DatabaseHandler.cpp \
$(top_srcdir)/database/SqlQuery.cpp \
$(top_srcdir)/database/Path.cpp \
$(top_srcdir)/database/Video.cpp \
$(top_srcdir)/database/Checksum.cpp
$(top_srcdir)/database/Video.cpp
database_integrity_CXXFLAGS=-std=c++11 -Wall -Wextra -I$(top_srcdir)
@@ -62,10 +60,10 @@ database_basics_SOURCES = \
$(top_srcdir)/database/Release.cpp \
$(top_srcdir)/database/Track.cpp \
$(top_srcdir)/database/DatabaseHandler.cpp \
$(top_srcdir)/database/MediaDirectory.cpp \
$(top_srcdir)/database/SqlQuery.cpp \
$(top_srcdir)/database/Path.cpp \
$(top_srcdir)/database/Video.cpp \
$(top_srcdir)/database/Checksum.cpp
$(top_srcdir)/database/Video.cpp
database_basics_CXXFLAGS=-std=c++11 -Wall -Wextra -I$(top_srcdir)
+10 -6
View File
@@ -651,6 +651,7 @@ int main()
{
try {
bool extendedTests = true;
bool writeCovers = false;
std::cout << "Running test... extendedTests = " << std::boolalpha << extendedTests << std::endl;
@@ -709,13 +710,16 @@ int main()
std::vector<Cover> coverArts;
client.getCoverRelease(coverArts, release.id);
boost::filesystem::create_directory("cover");
BOOST_FOREACH(const Cover coverArt, coverArts)
if (writeCovers)
{
std::ostringstream oss; oss << "cover/" << release.id << "." << release.name << ".jpeg";
std::ofstream out(oss.str().c_str());
BOOST_FOREACH(unsigned char c, coverArt.data)
out.put(c);
boost::filesystem::create_directory("cover");
BOOST_FOREACH(const Cover coverArt, coverArts)
{
std::ostringstream oss; oss << "cover/" << release.id << "." << release.name << ".jpeg";
std::ofstream out(oss.str().c_str());
BOOST_FOREACH(unsigned char c, coverArt.data)
out.put(c);
}
}
std::cout << "Release '" << release << "', spotted " << coverArts.size() << " covers!" << std::endl;
+2 -2
View File
@@ -3,7 +3,7 @@
namespace TestDatabase {
DatabaseHandler* create()
Database::Handler* create()
{
boost::filesystem::path p ("test_db");
@@ -11,7 +11,7 @@ DatabaseHandler* create()
// Remove previous db
// boost::filesystem::remove(p);
DatabaseHandler* db = new DatabaseHandler(p);
Database::Handler* db = new Database::Handler(p);
// Populate DB
+1 -1
View File
@@ -3,6 +3,6 @@
namespace TestDatabase {
DatabaseHandler* create();
Database::Handler* create();
} // namespace TestDatabase
+1 -1
View File
@@ -11,7 +11,7 @@
namespace UserInterface {
AudioDatabaseWidget::AudioDatabaseWidget( DatabaseHandler& db, Wt::WContainerWidget *parent)
AudioDatabaseWidget::AudioDatabaseWidget( Database::Handler& db, Wt::WContainerWidget *parent)
: Wt::WContainerWidget(parent),
_refreshingFilters(false)
{
+1 -1
View File
@@ -15,7 +15,7 @@ namespace UserInterface {
class AudioDatabaseWidget : public Wt::WContainerWidget
{
public:
AudioDatabaseWidget( DatabaseHandler& db, Wt::WContainerWidget *parent = 0);
AudioDatabaseWidget( Database::Handler& db, Wt::WContainerWidget *parent = 0);
void search(const std::string& text);
+1 -1
View File
@@ -4,7 +4,7 @@
namespace UserInterface {
TableFilterWidget::TableFilterWidget(DatabaseHandler& db, std::string table, std::string field, Wt::WContainerWidget* parent)
TableFilterWidget::TableFilterWidget(Database::Handler& db, std::string table, std::string field, Wt::WContainerWidget* parent)
: FilterWidget( parent ),
_db(db),
_table(table),
+2 -2
View File
@@ -14,7 +14,7 @@ class TableFilterWidget : public FilterWidget
{
public:
TableFilterWidget(DatabaseHandler& db, std::string table, std::string field, Wt::WContainerWidget* parent = 0);
TableFilterWidget(Database::Handler& db, std::string table, std::string field, Wt::WContainerWidget* parent = 0);
// Set constraints on this filter
virtual void refresh(const Constraint& constraint);
@@ -24,7 +24,7 @@ class TableFilterWidget : public FilterWidget
protected:
DatabaseHandler& _db;
Database::Handler& _db;
const std::string _table;
const std::string _field;
+1 -1
View File
@@ -8,7 +8,7 @@
namespace UserInterface {
TrackWidget::TrackWidget( DatabaseHandler& db, Wt::WContainerWidget* parent)
TrackWidget::TrackWidget( Database::Handler& db, Wt::WContainerWidget* parent)
: FilterWidget( parent ),
_db(db),
_tableView(nullptr),
+4 -4
View File
@@ -15,7 +15,7 @@ class TrackWidget : public FilterWidget
{
public:
TrackWidget( DatabaseHandler& db, Wt::WContainerWidget* parent = 0);
TrackWidget( Database::Handler& db, Wt::WContainerWidget* parent = 0);
// Set constraints created by parent filters
void refresh(const Constraint& constraint);
@@ -34,11 +34,11 @@ class TrackWidget : public FilterWidget
Wt::Signal< boost::filesystem::path > _trackSelected;
DatabaseHandler& _db;
Database::Handler& _db;
typedef boost::tuple<Database::Track::pointer, Database::Release::pointer, Database::Artist::pointer> ResultType;
Wt::Dbo::QueryModel< ResultType > _queryModel;
Wt::WTableView* _tableView;
Wt::Dbo::QueryModel< ResultType > _queryModel;
Wt::WTableView* _tableView;
void updateStats(void);
+4 -4
View File
@@ -18,14 +18,14 @@ class SessionData
void setAuthenticatedUser(std::string user);
DatabaseHandler& getDatabaseHandler() { return _db;}
const DatabaseHandler& getDatabaseHandler() const { return _db;}
Database::Handler& getDatabaseHandler() { return _db;}
const Database::Handler& getDatabaseHandler() const { return _db;}
private:
DatabaseHandler _db;
std::string _authenticatedUser;
Database::Handler _db;
std::string _authenticatedUser;
};
+1 -1
View File
@@ -13,7 +13,7 @@
namespace UserInterface {
VideoDatabaseWidget::VideoDatabaseWidget(DatabaseHandler& db, Wt::WContainerWidget *parent)
VideoDatabaseWidget::VideoDatabaseWidget(Database::Handler& db, Wt::WContainerWidget *parent)
: Wt::WContainerWidget(parent),
_db(db)
{
+2 -2
View File
@@ -12,7 +12,7 @@ namespace UserInterface {
class VideoDatabaseWidget : public Wt::WContainerWidget
{
public:
VideoDatabaseWidget( DatabaseHandler& db, Wt::WContainerWidget *parent = 0);
VideoDatabaseWidget( Database::Handler& db, Wt::WContainerWidget *parent = 0);
// Signals
Wt::Signal< boost::filesystem::path >& playVideo() { return _playVideo; }
@@ -28,7 +28,7 @@ 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);
DatabaseHandler& _db;
Database::Handler& _db;
Wt::Signal< boost::filesystem::path > _playVideo;