Commit 94b830c0 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

Remove using namespace medialibrary::

parent 7567bb62
......@@ -192,7 +192,7 @@ std::string Album::orderBy( medialibrary::SortingCriteria sort, bool desc )
return req;
}
std::vector<MediaPtr> Album::tracks( medialibrary::SortingCriteria sort, bool desc ) const
std::vector<medialibrary::MediaPtr> Album::tracks( medialibrary::SortingCriteria sort, bool desc ) const
{
// This doesn't return the cached version, because it would be fairly complicated, if not impossible or
// counter productive, to maintain a cache that respects all orderings.
......@@ -200,10 +200,10 @@ std::vector<MediaPtr> Album::tracks( medialibrary::SortingCriteria sort, bool de
" INNER JOIN " + policy::AlbumTrackTable::Name + " att ON att.media_id = med.id_media "
" WHERE att.album_id = ? AND med.is_present = 1";
req += orderTracksBy( sort, desc );
return Media::fetchAll<IMedia>( m_ml, req, m_id );
return Media::fetchAll<medialibrary::IMedia>( m_ml, req, m_id );
}
std::vector<std::shared_ptr<IMedia>> Album::tracks( GenrePtr genre, medialibrary::SortingCriteria sort, bool desc ) const
std::vector<medialibrary::MediaPtr> Album::tracks( medialibrary::GenrePtr genre, medialibrary::SortingCriteria sort, bool desc ) const
{
if ( genre == nullptr )
return {};
......@@ -212,10 +212,10 @@ std::vector<std::shared_ptr<IMedia>> Album::tracks( GenrePtr genre, medialibrary
" WHERE att.album_id = ? AND med.is_present = 1"
" AND genre_id = ?";
req += orderTracksBy( sort, desc );
return Media::fetchAll<IMedia>( m_ml, req, m_id, genre->id() );
return Media::fetchAll<medialibrary::IMedia>( m_ml, req, m_id, genre->id() );
}
std::vector<MediaPtr> Album::cachedTracks() const
std::vector<medialibrary::MediaPtr> Album::cachedTracks() const
{
auto lock = m_tracks.lock();
if ( m_tracks.isCached() == false )
......@@ -258,7 +258,7 @@ unsigned int Album::duration() const
return m_duration;
}
ArtistPtr Album::albumArtist() const
medialibrary::ArtistPtr Album::albumArtist() const
{
if ( m_artistId == 0 )
return nullptr;
......@@ -293,14 +293,14 @@ bool Album::setAlbumArtist( std::shared_ptr<Artist> artist )
return true;
}
std::vector<ArtistPtr> Album::artists( bool desc ) const
std::vector<medialibrary::ArtistPtr> Album::artists( bool desc ) const
{
std::string req = "SELECT art.* FROM " + policy::ArtistTable::Name + " art "
"INNER JOIN AlbumArtistRelation aar ON aar.artist_id = art.id_artist "
"WHERE aar.album_id = ? ORDER BY art.name";
if ( desc == true )
req += " DESC";
return Artist::fetchAll<IArtist>( m_ml, req, m_id );
return Artist::fetchAll<medialibrary::IArtist>( m_ml, req, m_id );
}
bool Album::addArtist( std::shared_ptr<Artist> artist )
......@@ -422,7 +422,7 @@ std::shared_ptr<Album> Album::createUnknownAlbum( MediaLibraryPtr ml, const Arti
return album;
}
std::vector<AlbumPtr> Album::search( MediaLibraryPtr ml, const std::string& pattern )
std::vector<medialibrary::AlbumPtr> Album::search( MediaLibraryPtr ml, const std::string& pattern )
{
static const std::string req = "SELECT * FROM " + policy::AlbumTable::Name + " WHERE id_album IN "
"(SELECT rowid FROM " + policy::AlbumTable::Name + "Fts WHERE " +
......@@ -431,7 +431,7 @@ std::vector<AlbumPtr> Album::search( MediaLibraryPtr ml, const std::string& patt
return fetchAll<IAlbum>( ml, req, pattern + "*" );
}
std::vector<AlbumPtr> Album::fromArtist( MediaLibraryPtr ml, int64_t artistId, medialibrary::SortingCriteria sort, bool desc )
std::vector<medialibrary::AlbumPtr> Album::fromArtist( MediaLibraryPtr ml, int64_t artistId, medialibrary::SortingCriteria sort, bool desc )
{
std::string req = "SELECT * FROM " + policy::AlbumTable::Name + " alb "
"WHERE artist_id = ? AND is_present=1 ORDER BY ";
......@@ -456,7 +456,7 @@ std::vector<AlbumPtr> Album::fromArtist( MediaLibraryPtr ml, int64_t artistId, m
return fetchAll<IAlbum>( ml, req, artistId );
}
std::vector<AlbumPtr> Album::fromGenre( MediaLibraryPtr ml, int64_t genreId, medialibrary::SortingCriteria sort, bool desc)
std::vector<medialibrary::AlbumPtr> Album::fromGenre( MediaLibraryPtr ml, int64_t genreId, medialibrary::SortingCriteria sort, bool desc)
{
std::string req = "SELECT a.* FROM " + policy::AlbumTable::Name + " a "
"INNER JOIN " + policy::AlbumTrackTable::Name + " att ON att.album_id = a.id_album "
......@@ -465,7 +465,7 @@ std::vector<AlbumPtr> Album::fromGenre( MediaLibraryPtr ml, int64_t genreId, med
return fetchAll<IAlbum>( ml, req, genreId );
}
std::vector<AlbumPtr> Album::listAll( MediaLibraryPtr ml, medialibrary::SortingCriteria sort, bool desc )
std::vector<medialibrary::AlbumPtr> Album::listAll( MediaLibraryPtr ml, medialibrary::SortingCriteria sort, bool desc )
{
std::string req = "SELECT * FROM " + policy::AlbumTable::Name +
" WHERE is_present=1";
......
......@@ -48,7 +48,7 @@ struct AlbumTable
};
}
class Album : public IAlbum, public DatabaseHelpers<Album, policy::AlbumTable>
class Album : public medialibrary::IAlbum, public DatabaseHelpers<Album, policy::AlbumTable>
{
public:
Album( MediaLibraryPtr ml, sqlite::Row& row );
......@@ -72,14 +72,14 @@ class Album : public IAlbum, public DatabaseHelpers<Album, policy::AlbumTable>
bool setShortSummary( const std::string& summary );
virtual const std::string& artworkMrl() const override;
bool setArtworkMrl( const std::string& artworkMrl );
virtual std::vector<MediaPtr> tracks( medialibrary::SortingCriteria sort, bool desc ) const override;
virtual std::vector<std::shared_ptr<IMedia>> tracks( GenrePtr genre, medialibrary::SortingCriteria sort, bool desc ) const override;
virtual std::vector<medialibrary::MediaPtr> tracks( medialibrary::SortingCriteria sort, bool desc ) const override;
virtual std::vector<medialibrary::MediaPtr> tracks( medialibrary::GenrePtr genre, medialibrary::SortingCriteria sort, bool desc ) const override;
///
/// \brief cachedTracks Returns a cached list of tracks
/// This has no warranty of ordering, validity, or anything else.
/// \return An unordered-list of this album's tracks
///
std::vector<MediaPtr> cachedTracks() const;
std::vector<medialibrary::MediaPtr> cachedTracks() const;
///
/// \brief addTrack Add a track to the album.
/// This will modify the media, but *not* save it.
......@@ -89,9 +89,9 @@ class Album : public IAlbum, public DatabaseHelpers<Album, policy::AlbumTable>
unsigned int nbTracks() const override;
unsigned int duration() const override;
virtual ArtistPtr albumArtist() const override;
virtual medialibrary::ArtistPtr albumArtist() const override;
bool setAlbumArtist( std::shared_ptr<Artist> artist );
virtual std::vector<ArtistPtr> artists(bool desc) const override;
virtual std::vector<medialibrary::ArtistPtr> artists(bool desc) const override;
bool addArtist( std::shared_ptr<Artist> artist );
bool removeArtist( Artist* artist );
......@@ -104,10 +104,10 @@ class Album : public IAlbum, public DatabaseHelpers<Album, policy::AlbumTable>
/// \param pattern A pattern representing the title, or the name of the main artist
/// \return
///
static std::vector<AlbumPtr> search( MediaLibraryPtr ml, const std::string& pattern );
static std::vector<AlbumPtr> fromArtist( MediaLibraryPtr ml, int64_t artistId, medialibrary::SortingCriteria sort, bool desc );
static std::vector<AlbumPtr> fromGenre( MediaLibraryPtr ml, int64_t genreId, medialibrary::SortingCriteria sort, bool desc );
static std::vector<AlbumPtr> listAll( MediaLibraryPtr ml, medialibrary::SortingCriteria sort, bool desc );
static std::vector<medialibrary::AlbumPtr> search( MediaLibraryPtr ml, const std::string& pattern );
static std::vector<medialibrary::AlbumPtr> fromArtist( MediaLibraryPtr ml, int64_t artistId, medialibrary::SortingCriteria sort, bool desc );
static std::vector<medialibrary::AlbumPtr> fromGenre( MediaLibraryPtr ml, int64_t genreId, medialibrary::SortingCriteria sort, bool desc );
static std::vector<medialibrary::AlbumPtr> listAll( MediaLibraryPtr ml, medialibrary::SortingCriteria sort, bool desc );
private:
static std::string orderTracksBy( medialibrary::SortingCriteria sort, bool desc );
......@@ -124,7 +124,7 @@ class Album : public IAlbum, public DatabaseHelpers<Album, policy::AlbumTable>
unsigned int m_duration;
bool m_isPresent;
mutable Cache<std::vector<MediaPtr>> m_tracks;
mutable Cache<std::vector<medialibrary::MediaPtr>> m_tracks;
mutable Cache<std::shared_ptr<Artist>> m_albumArtist;
friend struct policy::AlbumTable;
......
......@@ -63,7 +63,7 @@ int64_t AlbumTrack::id() const
return m_id;
}
ArtistPtr AlbumTrack::artist() const
medialibrary::ArtistPtr AlbumTrack::artist() const
{
if ( m_artistId == 0 )
return nullptr;
......@@ -130,14 +130,14 @@ std::shared_ptr<AlbumTrack> AlbumTrack::create( MediaLibraryPtr ml, int64_t albu
return self;
}
AlbumTrackPtr AlbumTrack::fromMedia( MediaLibraryPtr ml, int64_t mediaId )
medialibrary::AlbumTrackPtr AlbumTrack::fromMedia( MediaLibraryPtr ml, int64_t mediaId )
{
static const std::string req = "SELECT * FROM " + policy::AlbumTrackTable::Name +
" WHERE media_id = ?";
return fetch( ml, req, mediaId );
}
std::vector<MediaPtr> AlbumTrack::fromGenre( MediaLibraryPtr ml, int64_t genreId, medialibrary::SortingCriteria sort, bool desc )
std::vector<medialibrary::MediaPtr> AlbumTrack::fromGenre( MediaLibraryPtr ml, int64_t genreId, medialibrary::SortingCriteria sort, bool desc )
{
std::string req = "SELECT m.* FROM " + policy::MediaTable::Name + " m"
" INNER JOIN " + policy::AlbumTrackTable::Name + " t ON m.id_media = t.media_id"
......@@ -166,10 +166,10 @@ std::vector<MediaPtr> AlbumTrack::fromGenre( MediaLibraryPtr ml, int64_t genreId
if ( desc == true )
req += " DESC";
return Media::fetchAll<IMedia>( ml, req, genreId );
return Media::fetchAll<medialibrary::IMedia>( ml, req, genreId );
}
GenrePtr AlbumTrack::genre()
medialibrary::GenrePtr AlbumTrack::genre()
{
auto l = m_genre.lock();
if ( m_genre.isCached() == false )
......@@ -203,7 +203,7 @@ unsigned int AlbumTrack::discNumber() const
return m_discNumber;
}
std::shared_ptr<IAlbum> AlbumTrack::album()
std::shared_ptr<medialibrary::IAlbum> AlbumTrack::album()
{
auto album = m_album.lock();
if ( album == nullptr && m_albumId != 0 )
......@@ -214,7 +214,7 @@ std::shared_ptr<IAlbum> AlbumTrack::album()
return album;
}
std::shared_ptr<IMedia> AlbumTrack::media()
std::shared_ptr<medialibrary::IMedia> AlbumTrack::media()
{
auto lock = m_media.lock();
if ( m_media.isCached() == false )
......
......@@ -48,28 +48,28 @@ struct AlbumTrackTable
};
}
class AlbumTrack : public IAlbumTrack, public DatabaseHelpers<AlbumTrack, policy::AlbumTrackTable>
class AlbumTrack : public medialibrary::IAlbumTrack, public DatabaseHelpers<AlbumTrack, policy::AlbumTrackTable>
{
public:
AlbumTrack( MediaLibraryPtr ml, sqlite::Row& row );
AlbumTrack( MediaLibraryPtr ml, int64_t mediaId, unsigned int trackNumber, int64_t albumId, unsigned int discNumber);
virtual int64_t id() const override;
virtual ArtistPtr artist() const override;
virtual medialibrary::ArtistPtr artist() const override;
bool setArtist( std::shared_ptr<Artist> artist );
virtual GenrePtr genre() override;
virtual medialibrary::GenrePtr genre() override;
bool setGenre( std::shared_ptr<Genre> genre );
virtual unsigned int trackNumber() override;
virtual unsigned int discNumber() const override;
virtual std::shared_ptr<IAlbum> album() override;
virtual std::shared_ptr<IMedia> media() override;
virtual std::shared_ptr<medialibrary::IAlbum> album() override;
virtual std::shared_ptr<medialibrary::IMedia> media() override;
static bool createTable( DBConnection dbConnection );
static std::shared_ptr<AlbumTrack> create( MediaLibraryPtr ml, int64_t albumId,
std::shared_ptr<Media> media, unsigned int trackNb , unsigned int discNumber );
static AlbumTrackPtr fromMedia( MediaLibraryPtr ml, int64_t mediaId );
static std::vector<MediaPtr> fromGenre( MediaLibraryPtr ml, int64_t genreId, medialibrary::SortingCriteria sort, bool desc );
static std::vector<MediaPtr> search(DBConnection dbConn, const std::string& title );
static medialibrary::AlbumTrackPtr fromMedia( MediaLibraryPtr ml, int64_t mediaId );
static std::vector<medialibrary::MediaPtr> fromGenre( MediaLibraryPtr ml, int64_t genreId, medialibrary::SortingCriteria sort, bool desc );
static std::vector<medialibrary::MediaPtr> search(DBConnection dbConn, const std::string& title );
private:
MediaLibraryPtr m_ml;
......
......@@ -78,12 +78,12 @@ bool Artist::setShortBio(const std::string &shortBio)
return true;
}
std::vector<AlbumPtr> Artist::albums( medialibrary::SortingCriteria sort, bool desc ) const
std::vector<medialibrary::AlbumPtr> Artist::albums( medialibrary::SortingCriteria sort, bool desc ) const
{
return Album::fromArtist( m_ml, m_id, sort, desc );
}
std::vector<MediaPtr> Artist::media( medialibrary::SortingCriteria sort, bool desc ) const
std::vector<medialibrary::MediaPtr> Artist::media( medialibrary::SortingCriteria sort, bool desc ) const
{
std::string req = "SELECT med.* FROM " + policy::MediaTable::Name + " med "
"INNER JOIN MediaArtistRelation mar ON mar.media_id = med.id_media "
......@@ -106,7 +106,7 @@ std::vector<MediaPtr> Artist::media( medialibrary::SortingCriteria sort, bool de
if ( desc == true )
req += " DESC";
return Media::fetchAll<IMedia>( m_ml, req, m_id );
return Media::fetchAll<medialibrary::IMedia>( m_ml, req, m_id );
}
bool Artist::addMedia( Media& media )
......@@ -261,7 +261,7 @@ std::shared_ptr<Artist> Artist::create( MediaLibraryPtr ml, const std::string &n
return artist;
}
std::vector<ArtistPtr> Artist::search( MediaLibraryPtr ml, const std::string& name )
std::vector<medialibrary::ArtistPtr> Artist::search( MediaLibraryPtr ml, const std::string& name )
{
static const std::string req = "SELECT * FROM " + policy::ArtistTable::Name + " WHERE id_artist IN "
"(SELECT rowid FROM " + policy::ArtistTable::Name + "Fts WHERE name MATCH ?)"
......@@ -269,7 +269,7 @@ std::vector<ArtistPtr> Artist::search( MediaLibraryPtr ml, const std::string& na
return fetchAll<IArtist>( ml, req, name + "*" );
}
std::vector<ArtistPtr> Artist::listAll(MediaLibraryPtr ml, medialibrary::SortingCriteria sort, bool desc)
std::vector<medialibrary::ArtistPtr> Artist::listAll(MediaLibraryPtr ml, medialibrary::SortingCriteria sort, bool desc)
{
std::string req = "SELECT * FROM " + policy::ArtistTable::Name +
" WHERE nb_albums > 0 AND is_present = 1 ORDER BY ";
......
......@@ -40,7 +40,7 @@ struct ArtistTable
};
}
class Artist : public IArtist, public DatabaseHelpers<Artist, policy::ArtistTable>
class Artist : public medialibrary::IArtist, public DatabaseHelpers<Artist, policy::ArtistTable>
{
public:
Artist( MediaLibraryPtr ml, sqlite::Row& row );
......@@ -50,8 +50,8 @@ public:
virtual const std::string &name() const override;
virtual const std::string& shortBio() const override;
bool setShortBio( const std::string& shortBio );
virtual std::vector<AlbumPtr> albums( medialibrary::SortingCriteria sort, bool desc ) const override;
virtual std::vector<MediaPtr> media(medialibrary::SortingCriteria sort, bool desc) const override;
virtual std::vector<medialibrary::AlbumPtr> albums( medialibrary::SortingCriteria sort, bool desc ) const override;
virtual std::vector<medialibrary::MediaPtr> media(medialibrary::SortingCriteria sort, bool desc) const override;
bool addMedia( Media& media );
virtual const std::string& artworkMrl() const override;
bool setArtworkMrl( const std::string& artworkMrl );
......@@ -64,8 +64,8 @@ public:
static bool createTriggers( DBConnection dbConnection );
static bool createDefaultArtists( DBConnection dbConnection );
static std::shared_ptr<Artist> create( MediaLibraryPtr ml, const std::string& name );
static std::vector<ArtistPtr> search( MediaLibraryPtr ml, const std::string& name );
static std::vector<ArtistPtr> listAll( MediaLibraryPtr ml, medialibrary::SortingCriteria sort, bool desc );
static std::vector<medialibrary::ArtistPtr> search( MediaLibraryPtr ml, const std::string& name );
static std::vector<medialibrary::ArtistPtr> listAll( MediaLibraryPtr ml, medialibrary::SortingCriteria sort, bool desc );
private:
MediaLibraryPtr m_ml;
......
......@@ -39,7 +39,7 @@ struct AudioTrackTable
};
}
class AudioTrack : public IAudioTrack, public DatabaseHelpers<AudioTrack, policy::AudioTrackTable>
class AudioTrack : public medialibrary::IAudioTrack, public DatabaseHelpers<AudioTrack, policy::AudioTrackTable>
{
public:
AudioTrack(MediaLibraryPtr ml, sqlite::Row& row );
......
......@@ -22,7 +22,7 @@
#include "MediaLibrary.h"
extern "C" IMediaLibrary* NewMediaLibrary()
extern "C" medialibrary::IMediaLibrary* NewMediaLibrary()
{
return new MediaLibrary();
}
......@@ -77,7 +77,7 @@ const std::string& File::mrl() const
return m_fullPath;
}
IFile::Type File::type() const
medialibrary::IFile::Type File::type() const
{
return m_type;
}
......
......@@ -57,7 +57,7 @@ const std::string& Genre::name() const
return m_name;
}
std::vector<ArtistPtr> Genre::artists( medialibrary::SortingCriteria, bool desc ) const
std::vector<medialibrary::ArtistPtr> Genre::artists( medialibrary::SortingCriteria, bool desc ) const
{
std::string req = "SELECT a.* FROM " + policy::ArtistTable::Name + " a "
"INNER JOIN " + policy::AlbumTrackTable::Name + " att ON att.artist_id = a.id_artist "
......@@ -65,15 +65,15 @@ std::vector<ArtistPtr> Genre::artists( medialibrary::SortingCriteria, bool desc
" ORDER BY a.name";
if ( desc == true )
req += " DESC";
return Artist::fetchAll<IArtist>( m_ml, req, m_id );
return Artist::fetchAll<medialibrary::IArtist>( m_ml, req, m_id );
}
std::vector<MediaPtr> Genre::tracks( medialibrary::SortingCriteria sort, bool desc ) const
std::vector<medialibrary::MediaPtr> Genre::tracks( medialibrary::SortingCriteria sort, bool desc ) const
{
return AlbumTrack::fromGenre( m_ml, m_id, sort, desc );
}
std::vector<AlbumPtr> Genre::albums( medialibrary::SortingCriteria sort, bool desc ) const
std::vector<medialibrary::AlbumPtr> Genre::albums( medialibrary::SortingCriteria sort, bool desc ) const
{
return Album::fromGenre( m_ml, m_id, sort, desc );
}
......@@ -122,14 +122,14 @@ std::shared_ptr<Genre> Genre::fromName( MediaLibraryPtr ml, const std::string& n
return fetch( ml, req, name );
}
std::vector<GenrePtr> Genre::search( MediaLibraryPtr ml, const std::string& name )
std::vector<medialibrary::GenrePtr> Genre::search( MediaLibraryPtr ml, const std::string& name )
{
static const std::string req = "SELECT * FROM " + policy::GenreTable::Name + " WHERE id_genre IN "
"(SELECT rowid FROM " + policy::GenreTable::Name + "Fts WHERE name MATCH ?)";
return fetchAll<IGenre>( ml, req, name + "*" );
}
std::vector<GenrePtr> Genre::listAll( MediaLibraryPtr ml, medialibrary::SortingCriteria, bool desc )
std::vector<medialibrary::GenrePtr> Genre::listAll( MediaLibraryPtr ml, medialibrary::SortingCriteria, bool desc )
{
std::string req = "SELECT * FROM " + policy::GenreTable::Name + " ORDER BY name";
if ( desc == true )
......
......@@ -38,22 +38,22 @@ struct GenreTable
};
}
class Genre : public IGenre, public DatabaseHelpers<Genre, policy::GenreTable>
class Genre : public medialibrary::IGenre, public DatabaseHelpers<Genre, policy::GenreTable>
{
public:
Genre( MediaLibraryPtr ml, sqlite::Row& row );
Genre( MediaLibraryPtr ml, const std::string& name );
virtual int64_t id() const;
virtual const std::string& name() const override;
virtual std::vector<ArtistPtr> artists( medialibrary::SortingCriteria sort, bool desc ) const override;
virtual std::vector<MediaPtr> tracks(medialibrary::SortingCriteria sort, bool desc) const override;
virtual std::vector<AlbumPtr> albums( medialibrary::SortingCriteria sort, bool desc ) const override;
virtual std::vector<medialibrary::ArtistPtr> artists( medialibrary::SortingCriteria sort, bool desc ) const override;
virtual std::vector<medialibrary::MediaPtr> tracks(medialibrary::SortingCriteria sort, bool desc) const override;
virtual std::vector<medialibrary::AlbumPtr> albums( medialibrary::SortingCriteria sort, bool desc ) const override;
static bool createTable( DBConnection dbConn );
static std::shared_ptr<Genre> create( MediaLibraryPtr ml, const std::string& name );
static std::shared_ptr<Genre> fromName( MediaLibraryPtr ml, const std::string& name );
static std::vector<GenrePtr> search( MediaLibraryPtr ml, const std::string& name );
static std::vector<GenrePtr> listAll( MediaLibraryPtr ml, medialibrary::SortingCriteria sort, bool desc );
static std::vector<medialibrary::GenrePtr> search( MediaLibraryPtr ml, const std::string& name );
static std::vector<medialibrary::GenrePtr> listAll( MediaLibraryPtr ml, medialibrary::SortingCriteria sort, bool desc );
private:
MediaLibraryPtr m_ml;
......
......@@ -75,7 +75,7 @@ bool History::insert( DBConnection dbConn, const std::string& mrl )
return sqlite::Tools::executeInsert( dbConn, req, mrl, mrl ) != 0;
}
std::vector<std::shared_ptr<IHistoryEntry> > History::fetch( MediaLibraryPtr ml )
std::vector<medialibrary::HistoryPtr> History::fetch( MediaLibraryPtr ml )
{
static const std::string req = "SELECT * FROM " + policy::HistoryTable::Name + " ORDER BY insertion_date DESC";
return fetchAll<IHistoryEntry>( ml, req );
......
......@@ -42,13 +42,13 @@ struct HistoryTable
};
}
class History : public IHistoryEntry, public DatabaseHelpers<History, policy::HistoryTable>
class History : public medialibrary::IHistoryEntry, public DatabaseHelpers<History, policy::HistoryTable>
{
public:
History( MediaLibraryPtr ml, sqlite::Row& row );
static bool createTable( DBConnection dbConnection );
static bool insert( DBConnection dbConn, const std::string& mrl );
static std::vector<std::shared_ptr<IHistoryEntry>> fetch( MediaLibraryPtr ml );
static std::vector<medialibrary::HistoryPtr> fetch( MediaLibraryPtr ml );
virtual const std::string& mrl() const override;
virtual unsigned int insertionDate() const override;
......
......@@ -56,15 +56,15 @@ const std::string& Label::name() const
return m_name;
}
std::vector<MediaPtr> Label::files()
std::vector<medialibrary::MediaPtr> Label::files()
{
static const std::string req = "SELECT f.* FROM " + policy::MediaTable::Name + " f "
"INNER JOIN LabelFileRelation lfr ON lfr.media_id = f.id_media "
"WHERE lfr.label_id = ?";
return Media::fetchAll<IMedia>( m_ml, req, m_id );
return Media::fetchAll<medialibrary::IMedia>( m_ml, req, m_id );
}
LabelPtr Label::create( MediaLibraryPtr ml, const std::string& name )
medialibrary::LabelPtr Label::create( MediaLibraryPtr ml, const std::string& name )
{
auto self = std::make_shared<Label>( ml, name );
const char* req = "INSERT INTO Label VALUES(NULL, ?)";
......
......@@ -42,7 +42,7 @@ struct LabelTable
};
}
class Label : public ILabel, public DatabaseHelpers<Label, policy::LabelTable>
class Label : public medialibrary::ILabel, public DatabaseHelpers<Label, policy::LabelTable>
{
public:
Label( MediaLibraryPtr ml, sqlite::Row& row );
......@@ -51,9 +51,9 @@ class Label : public ILabel, public DatabaseHelpers<Label, policy::LabelTable>
public:
virtual int64_t id() const override;
virtual const std::string& name() const override;
virtual std::vector<MediaPtr> files() override;
virtual std::vector<medialibrary::MediaPtr> files() override;
static LabelPtr create( MediaLibraryPtr ml, const std::string& name );
static medialibrary::LabelPtr create( MediaLibraryPtr ml, const std::string& name );
static bool createTable( DBConnection dbConnection );
private:
......
......@@ -101,7 +101,7 @@ std::shared_ptr<Media> Media::create( MediaLibraryPtr ml, Type type, const fs::I
return self;
}
AlbumTrackPtr Media::albumTrack() const
medialibrary::AlbumTrackPtr Media::albumTrack() const
{
if ( m_subType != SubType::AlbumTrack )
return nullptr;
......@@ -112,7 +112,7 @@ AlbumTrackPtr Media::albumTrack() const
return m_albumTrack.get();
}
void Media::setAlbumTrack( AlbumTrackPtr albumTrack )
void Media::setAlbumTrack( medialibrary::AlbumTrackPtr albumTrack )
{
auto lock = m_albumTrack.lock();
m_albumTrack = albumTrack;
......@@ -133,7 +133,7 @@ void Media::setDuration( int64_t duration )
m_changed = true;
}
ShowEpisodePtr Media::showEpisode() const
medialibrary::ShowEpisodePtr Media::showEpisode() const
{
if ( m_subType != SubType::ShowEpisode )
return nullptr;
......@@ -144,7 +144,7 @@ ShowEpisodePtr Media::showEpisode() const
return m_showEpisode.get();
}
void Media::setShowEpisode( ShowEpisodePtr episode )
void Media::setShowEpisode( medialibrary::ShowEpisodePtr episode )
{
auto lock = m_showEpisode.lock();
m_showEpisode = episode;
......@@ -152,12 +152,12 @@ void Media::setShowEpisode( ShowEpisodePtr episode )
m_changed = true;
}
std::vector<LabelPtr> Media::labels()
std::vector<medialibrary::LabelPtr> Media::labels()
{
static const std::string req = "SELECT l.* FROM " + policy::LabelTable::Name + " l "
"INNER JOIN LabelFileRelation lfr ON lfr.label_id = l.id_label "
"WHERE lfr.media_id = ?";
return Label::fetchAll<ILabel>( m_ml, req, m_id );
return Label::fetchAll<medialibrary::ILabel>( m_ml, req, m_id );
}
int Media::playCount() const
......@@ -225,19 +225,19 @@ bool Media::setFavorite( bool favorite )
return true;
}
const std::vector<FilePtr>& Media::files() const
const std::vector<medialibrary::FilePtr>& Media::files() const
{
auto lock = m_files.lock();
if ( m_files.isCached() == false )
{
static const std::string req = "SELECT * FROM " + policy::FileTable::Name
+ " WHERE media_id = ?";
m_files = File::fetchAll<IFile>( m_ml, req, m_id );
m_files = File::fetchAll<medialibrary::IFile>( m_ml, req, m_id );
}
return m_files;
}
MoviePtr Media::movie() const
medialibrary::MoviePtr Media::movie() const
{
if ( m_subType != SubType::Movie )
return nullptr;
......@@ -249,7 +249,7 @@ MoviePtr Media::movie() const
return m_movie.get();
}
void Media::setMovie(MoviePtr movie)
void Media::setMovie(medialibrary::MoviePtr movie)
{
auto lock = m_movie.lock();
m_movie = movie;
......@@ -262,11 +262,11 @@ bool Media::addVideoTrack(const std::string& codec, unsigned int width, unsigned
return VideoTrack::create( m_ml, codec, width, height, fps, m_id ) != nullptr;
}
std::vector<VideoTrackPtr> Media::videoTracks()
std::vector<medialibrary::VideoTrackPtr> Media::videoTracks()
{
static const std::string req = "SELECT * FROM " + policy::VideoTrackTable::Name +
" WHERE media_id = ?";
return VideoTrack::fetchAll<IVideoTrack>( m_ml, req, m_id );
return VideoTrack::fetchAll<medialibrary::IVideoTrack>( m_ml, req, m_id );
}
bool Media::addAudioTrack( const std::string& codec, unsigned int bitrate,
......@@ -276,11 +276,11 @@ bool Media::addAudioTrack( const std::string& codec, unsigned int bitrate,
return AudioTrack::create( m_ml, codec, bitrate, sampleRate, nbChannels, language, desc, m_id ) != nullptr;
}
std::vector<AudioTrackPtr> Media::audioTracks()
std::vector<medialibrary::AudioTrackPtr> Media::audioTracks()
{
static const std::string req = "SELECT * FROM " + policy::AudioTrackTable::Name +
" WHERE media_id = ?";
return AudioTrack::fetchAll<IAudioTrack>( m_ml, req, m_id );
return AudioTrack::fetchAll<medialibrary::IAudioTrack>( m_ml, req, m_id );
}
const std::string &Media::thumbnail()
......@@ -330,7 +330,7 @@ bool Media::save()
return true;
}
std::shared_ptr<File> Media::addFile( const fs::IFile& fileFs, Folder& parentFolder, fs::IDirectory& parentFolderFs, IFile::Type type )
std::shared_ptr<File> Media::addFile( const fs::IFile& fileFs, Folder& parentFolder, fs::IDirectory& parentFolderFs, medialibrary::IFile::Type type )
{
auto file = File::create( m_ml, m_id, type, fileFs, parentFolder.id(), parentFolderFs.device()->isRemovable() );
if ( file == nullptr )
......@@ -347,12 +347,12 @@ void Media::removeFile( File& file )
auto lock = m_files.lock();
if ( m_files.isCached() == false )
return;
m_files.get().erase( std::remove_if( begin( m_files.get() ), end( m_files.get() ), [&file]( const FilePtr& f ) {
m_files.get().erase( std::remove_if( begin( m_files.get() ), end( m_files.get() ), [&file]( const medialibrary::FilePtr& f ) {
return f->id() == file.id();
}));
}
std::vector<MediaPtr> Media::listAll( MediaLibraryPtr ml, IMedia::Type type, medialibrary::SortingCriteria sort, bool desc )
std::vector<medialibrary::MediaPtr> Media::listAll( MediaLibraryPtr ml, IMedia::Type type, medialibrary::SortingCriteria sort, bool desc )
{
std::string req;
if ( sort == medialibrary::SortingCriteria::LastModificationDate )
......@@ -393,12 +393,12 @@ int64_t Media::id() const
return m_id;
}
IMedia::Type Media::type()
medialibrary::IMedia::Type Media::type()
{
return m_type;
}
IMedia::SubType Media::subType() const
medialibrary::IMedia::SubType Media::subType() const
{
return m_subType;
}
......@@ -494,7 +494,7 @@ bool Media::createTriggers( DBConnection connection )
sqlite::Tools::executeRequest( connection, vtableUpdateTitleTrigger2 );
}
bool Media::addLabel( LabelPtr label )
bool Media::addLabel( medialibrary::LabelPtr label )
{
if ( m_id == 0 || label->id() == 0 )
{
......@@ -509,7 +509,7 @@ bool Media::addLabel( LabelPtr label )
return sqlite::Tools::executeUpdate( m_ml->getConn(), reqFts, label->name(), m_id );
}
bool Media::removeLabel( LabelPtr label )
bool Media::removeLabel( medialibrary::LabelPtr label )
{
if ( m_id == 0 || label->id() == 0 )
{
......@@ -525,7 +525,7 @@ bool Media::removeLabel( LabelPtr label )
}
std::vector<MediaPtr> Media::search( MediaLibraryPtr ml, const std::string& title )
std::vector<medialibrary::MediaPtr> Media::search( MediaLibraryPtr ml, const std::string& title )
{
static const std::string req = "SELECT * FROM " + policy::MediaTable::Name + " WHERE"
" id_media IN (SELECT rowid FROM " + policy::MediaTable::Name + "Fts"
......@@ -534,7 +534,7 @@ std::vector<MediaPtr> Media::search( MediaLibraryPtr ml, const std::string& titl
return Media::fetchAll<IMedia>( ml, req, title + "*" );
}
std::vector<MediaPtr> Media::fetchHistory( MediaLibraryPtr ml )
std::vector<medialibrary::MediaPtr> Media::fetchHistory( MediaLibraryPtr ml )
{
static const std::string req = "SELECT * FROM " + policy::MediaTable::Name + " WHERE last_played_date IS NOT NULL"
" ORDER BY last_played_date DESC LIMIT 100";
......
......@@ -49,7 +49,7 @@ struct MediaTable
};
}
class Media : public IMedia, public DatabaseHelpers<Media, policy::MediaTable>
class Media : public medialibrary::IMedia, public DatabaseHelpers<Media, policy::MediaTable>
{
public:
// Those should be private, however the standard states that the expression
......@@ -69,15 +69,15 @@ class Media : public IMedia, public DatabaseHelpers<Media, policy::MediaTable>
void setType( Type type );
virtual const std::string& title() const override;
void setTitle( const std::string& title );
virtual AlbumTrackPtr albumTrack() const override;
void setAlbumTrack( AlbumTrackPtr albumTrack );
virtual medialibrary::AlbumTrackPtr albumTrack() const override;
void setAlbumTrack( medialibrary::AlbumTrackPtr albumTrack );
virtual int64_t duration() const override;
void setDuration( int64_t duration);
virtual ShowEpisodePtr showEpisode() const override;
void setShowEpisode( ShowEpisodePtr episode );
virtual bool addLabel( LabelPtr label ) override;
virtual bool removeLabel( LabelPtr label ) override;
virtual std::vector<LabelPtr> labels() override;
virtual medialibrary::ShowEpisodePtr showEpisode() const override;
void setShowEpisode( medialibrary::ShowEpisodePtr episode );
virtual bool addLabel( medialibrary::LabelPtr label ) override;
virtual bool removeLabel( medialibrary::LabelPtr label ) override;
virtual std::vector<medialibrary::LabelPtr> labels() override;
virtual int playCount() const override;
virtual bool increasePlayCount() override;