Commit 393002bc authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

Use int64_t for primary keys

parent 3a011c8a
......@@ -31,7 +31,7 @@ class IAlbum
{
public:
virtual ~IAlbum() = default;
virtual unsigned int id() const = 0;
virtual int64_t id() const = 0;
virtual const std::string& title() const = 0;
/**
* @brief releaseYear returns the release year, or 0 if unknown.
......
......@@ -30,7 +30,7 @@ class IAlbumTrack
public:
virtual ~IAlbumTrack() {}
virtual unsigned int id() const = 0;
virtual int64_t id() const = 0;
/**
* @brief artist Returns the artist, as tagged in the media.
* This can be different from the associated media's artist.
......
......@@ -31,7 +31,7 @@ class IArtist
{
public:
virtual ~IArtist() = default;
virtual unsigned int id() const = 0;
virtual int64_t id() const = 0;
virtual const std::string& name() const = 0;
virtual const std::string& shortBio() const = 0;
virtual std::vector<AlbumPtr> albums( medialibrary::SortingCriteria sort, bool desc ) const = 0;
......
......@@ -29,7 +29,7 @@ class IAudioTrack
{
public:
virtual ~IAudioTrack() {}
virtual unsigned int id() const = 0;
virtual int64_t id() const = 0;
virtual const std::string& codec() const = 0;
/**
* @return The bitrate in bits per second
......
......@@ -48,7 +48,7 @@ public:
};
virtual ~IFile() = default;
virtual unsigned int id() const = 0;
virtual int64_t id() const = 0;
virtual const std::string& mrl() const = 0;
virtual Type type() const = 0;
virtual unsigned int lastModificationDate() const = 0;
......
......@@ -30,7 +30,7 @@ class IGenre
{
public:
virtual ~IGenre() = default;
virtual unsigned int id() const = 0;
virtual int64_t id() const = 0;
virtual const std::string& name() const = 0;
virtual std::vector<ArtistPtr> artists( medialibrary::SortingCriteria sort, bool desc ) const = 0;
virtual std::vector<AlbumTrackPtr> tracks( medialibrary::SortingCriteria sort, bool desc ) const = 0;
......
......@@ -33,7 +33,7 @@ class ILabel
public:
virtual ~ILabel() {}
virtual unsigned int id() const = 0;
virtual int64_t id() const = 0;
virtual const std::string& name() const = 0;
virtual std::vector<MediaPtr> files() = 0;
};
......
......@@ -50,7 +50,7 @@ class IMedia
virtual ~IMedia() = default;
virtual unsigned int id() const = 0;
virtual int64_t id() const = 0;
virtual Type type() = 0;
virtual SubType subType() const = 0;
virtual const std::string& title() const = 0;
......
......@@ -133,11 +133,11 @@ class IMediaLibrary
virtual bool deleteLabel( LabelPtr label ) = 0;
virtual std::vector<MediaPtr> audioFiles( medialibrary::SortingCriteria sort, bool desc ) const = 0;
virtual std::vector<MediaPtr> videoFiles( medialibrary::SortingCriteria sort, bool desc ) const = 0;
virtual AlbumPtr album( unsigned int id ) const = 0;
virtual AlbumPtr album( int64_t id ) const = 0;
virtual std::vector<AlbumPtr> albums( medialibrary::SortingCriteria sort, bool desc ) const = 0;
virtual ShowPtr show( const std::string& name ) const = 0;
virtual MoviePtr movie( const std::string& title ) const = 0;
virtual ArtistPtr artist( unsigned int id ) const = 0;
virtual ArtistPtr artist( int64_t id ) const = 0;
/**
* @brief artists List all artists that have at least an album.
* Artists that only appear on albums as guests won't be listed from here, but will be
......@@ -158,7 +158,7 @@ class IMediaLibrary
*/
virtual PlaylistPtr createPlaylist( const std::string& name ) = 0;
virtual std::vector<PlaylistPtr> playlists( medialibrary::SortingCriteria sort, bool desc ) = 0;
virtual bool deletePlaylist( unsigned int playlistId ) = 0;
virtual bool deletePlaylist( int64_t playlistId ) = 0;
/**
* History
......
......@@ -29,7 +29,7 @@ class IMovie
{
public:
virtual ~IMovie() {}
virtual unsigned int id() const = 0;
virtual int64_t id() const = 0;
virtual const std::string& title() const = 0;
virtual const std::string& shortSummary() const = 0;
virtual const std::string& artworkMrl() const = 0;
......
......@@ -30,7 +30,7 @@ class IPlaylist
{
public:
virtual ~IPlaylist() = default;
virtual unsigned int id() const = 0;
virtual int64_t id() const = 0;
virtual const std::string& name() const = 0;
virtual bool setName( const std::string& name ) = 0;
virtual unsigned int creationDate() const = 0;
......@@ -42,7 +42,7 @@ public:
/// \param media The media to add
/// \return true on success, false on failure.
///
virtual bool append( unsigned int mediaId ) = 0;
virtual bool append( int64_t mediaId ) = 0;
///
/// \brief add Add a media to the playlist at the given position.
/// Valid positions start at 1. 0 means appending.
......@@ -50,7 +50,7 @@ public:
/// \param position The position of this new media
/// \return true on success, false on failure
///
virtual bool add( unsigned int mediaId, unsigned int position ) = 0;
virtual bool add( int64_t mediaId, unsigned int position ) = 0;
///
/// \brief move Change the position of a media
/// \param mediaId The media to move reorder
......@@ -64,11 +64,11 @@ public:
/// [<1,2>, <2,3>, <3,4>]
/// \return true on success, false on failure
///
virtual bool move( unsigned int mediaId, unsigned int position ) = 0;
virtual bool move( int64_t mediaId, unsigned int position ) = 0;
///
/// \brief remove Removes a media from the playlist
/// \param mediaId The media to remove.
/// \return true on success, false on failure
///
virtual bool remove( unsigned int mediaId ) = 0;
virtual bool remove( int64_t mediaId ) = 0;
};
......@@ -29,7 +29,7 @@ class IShow
{
public:
virtual ~IShow() {}
virtual unsigned int id() const = 0;
virtual int64_t id() const = 0;
virtual const std::string& name() const = 0;
virtual time_t releaseDate() const = 0;
virtual const std::string& shortSummary() const = 0;
......
......@@ -32,7 +32,7 @@ class IShowEpisode
public:
virtual ~IShowEpisode(){}
virtual unsigned int id() const = 0;
virtual int64_t id() const = 0;
virtual const std::string& artworkMrl() const = 0;
virtual unsigned int episodeNumber() const = 0;
virtual const std::string& name() const = 0;
......
......@@ -29,7 +29,7 @@ class IVideoTrack
{
public:
virtual ~IVideoTrack() {}
virtual unsigned int id() const = 0;
virtual int64_t id() const = 0;
virtual const std::string& codec() const = 0;
virtual unsigned int width() const = 0;
virtual unsigned int height() const = 0;
......
......@@ -32,7 +32,7 @@
const std::string policy::AlbumTable::Name = "Album";
const std::string policy::AlbumTable::PrimaryKeyColumn = "id_album";
unsigned int Album::* const policy::AlbumTable::PrimaryKey = &Album::m_id;
int64_t Album::* const policy::AlbumTable::PrimaryKey = &Album::m_id;
Album::Album(MediaLibraryPtr ml, sqlite::Row& row)
: m_ml( ml )
......@@ -68,7 +68,7 @@ Album::Album( MediaLibraryPtr ml, const Artist* artist )
{
}
unsigned int Album::id() const
int64_t Album::id() const
{
return m_id;
}
......@@ -411,7 +411,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, unsigned int artistId, medialibrary::SortingCriteria sort, bool desc )
std::vector<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 ";
......@@ -436,7 +436,7 @@ std::vector<AlbumPtr> Album::fromArtist( MediaLibraryPtr ml, unsigned int artist
return fetchAll<IAlbum>( ml, req, artistId );
}
std::vector<AlbumPtr> Album::fromGenre(MediaLibraryPtr ml, unsigned int genreId, medialibrary::SortingCriteria sort, bool desc)
std::vector<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 "
......
......@@ -44,7 +44,7 @@ struct AlbumTable
{
static const std::string Name;
static const std::string PrimaryKeyColumn;
static unsigned int Album::*const PrimaryKey;
static int64_t Album::*const PrimaryKey;
};
}
......@@ -55,7 +55,7 @@ class Album : public IAlbum, public DatabaseHelpers<Album, policy::AlbumTable>
Album( MediaLibraryPtr ml, const std::string& title );
Album( MediaLibraryPtr ml, const Artist* artist );
virtual unsigned int id() const override;
virtual int64_t id() const override;
virtual const std::string& title() const override;
virtual unsigned int releaseYear() const override;
/**
......@@ -104,8 +104,8 @@ class Album : public IAlbum, public DatabaseHelpers<Album, policy::AlbumTable>
/// \return
///
static std::vector<AlbumPtr> search( MediaLibraryPtr ml, const std::string& pattern );
static std::vector<AlbumPtr> fromArtist( MediaLibraryPtr ml, unsigned int artistId, medialibrary::SortingCriteria sort, bool desc );
static std::vector<AlbumPtr> fromGenre( MediaLibraryPtr ml, unsigned int genreId, medialibrary::SortingCriteria sort, bool desc );
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 );
private:
......@@ -113,9 +113,9 @@ class Album : public IAlbum, public DatabaseHelpers<Album, policy::AlbumTable>
static std::string orderBy( medialibrary::SortingCriteria sort, bool desc );
protected:
MediaLibraryPtr m_ml;
unsigned int m_id;
int64_t m_id;
std::string m_title;
unsigned int m_artistId;
int64_t m_artistId;
unsigned int m_releaseYear;
std::string m_shortSummary;
std::string m_artworkMrl;
......
......@@ -30,7 +30,7 @@
const std::string policy::AlbumTrackTable::Name = "AlbumTrack";
const std::string policy::AlbumTrackTable::PrimaryKeyColumn = "id_track";
unsigned int AlbumTrack::* const policy::AlbumTrackTable::PrimaryKey = &AlbumTrack::m_id;
int64_t AlbumTrack::* const policy::AlbumTrackTable::PrimaryKey = &AlbumTrack::m_id;
AlbumTrack::AlbumTrack( MediaLibraryPtr ml, sqlite::Row& row )
: m_ml( ml )
......@@ -45,7 +45,7 @@ AlbumTrack::AlbumTrack( MediaLibraryPtr ml, sqlite::Row& row )
>> m_isPresent;
}
AlbumTrack::AlbumTrack( MediaLibraryPtr ml, unsigned int mediaId, unsigned int trackNumber, unsigned int albumId, unsigned int discNumber )
AlbumTrack::AlbumTrack( MediaLibraryPtr ml, int64_t mediaId, unsigned int trackNumber, int64_t albumId, unsigned int discNumber )
: m_ml( ml )
, m_id( 0 )
, m_mediaId( mediaId )
......@@ -56,7 +56,7 @@ AlbumTrack::AlbumTrack( MediaLibraryPtr ml, unsigned int mediaId, unsigned int t
{
}
unsigned int AlbumTrack::id() const
int64_t AlbumTrack::id() const
{
return m_id;
}
......@@ -115,7 +115,7 @@ bool AlbumTrack::createTable( DBConnection dbConnection )
sqlite::Tools::executeRequest( dbConnection, triggerReq );
}
std::shared_ptr<AlbumTrack> AlbumTrack::create( MediaLibraryPtr ml, unsigned int albumId,
std::shared_ptr<AlbumTrack> AlbumTrack::create( MediaLibraryPtr ml, int64_t albumId,
std::shared_ptr<Media> media, unsigned int trackNb,
unsigned int discNumber )
{
......@@ -128,14 +128,14 @@ std::shared_ptr<AlbumTrack> AlbumTrack::create( MediaLibraryPtr ml, unsigned int
return self;
}
AlbumTrackPtr AlbumTrack::fromMedia( MediaLibraryPtr ml, unsigned int mediaId )
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<AlbumTrackPtr> AlbumTrack::fromGenre( MediaLibraryPtr ml, unsigned int genreId, medialibrary::SortingCriteria sort, bool desc )
std::vector<AlbumTrackPtr> AlbumTrack::fromGenre( MediaLibraryPtr ml, int64_t genreId, medialibrary::SortingCriteria sort, bool desc )
{
std::string req = "SELECT t.* FROM " + policy::AlbumTrackTable::Name + " t"
" INNER JOIN " + policy::MediaTable::Name + " m ON m.id_media = t.media_id"
......
......@@ -44,7 +44,7 @@ struct AlbumTrackTable
{
static const std::string Name;
static const std::string PrimaryKeyColumn;
static unsigned int AlbumTrack::*const PrimaryKey;
static int64_t AlbumTrack::*const PrimaryKey;
};
}
......@@ -52,9 +52,9 @@ class AlbumTrack : public IAlbumTrack, public DatabaseHelpers<AlbumTrack, policy
{
public:
AlbumTrack( MediaLibraryPtr ml, sqlite::Row& row );
AlbumTrack( MediaLibraryPtr ml, unsigned int mediaId, unsigned int trackNumber, unsigned int albumId , unsigned int discNumber);
AlbumTrack( MediaLibraryPtr ml, int64_t mediaId, unsigned int trackNumber, int64_t albumId, unsigned int discNumber);
virtual unsigned int id() const override;
virtual int64_t id() const override;
virtual ArtistPtr artist() const override;
bool setArtist( std::shared_ptr<Artist> artist );
virtual GenrePtr genre() override;
......@@ -65,20 +65,20 @@ class AlbumTrack : public IAlbumTrack, public DatabaseHelpers<AlbumTrack, policy
virtual std::shared_ptr<IMedia> media() override;
static bool createTable( DBConnection dbConnection );
static std::shared_ptr<AlbumTrack> create( MediaLibraryPtr ml, unsigned int albumId,
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, unsigned int mediaId );
static std::vector<AlbumTrackPtr> fromGenre( MediaLibraryPtr ml, unsigned int genreId, medialibrary::SortingCriteria sort, bool desc );
static AlbumTrackPtr fromMedia( MediaLibraryPtr ml, int64_t mediaId );
static std::vector<AlbumTrackPtr> fromGenre( MediaLibraryPtr ml, int64_t genreId, medialibrary::SortingCriteria sort, bool desc );
static std::vector<MediaPtr> search(DBConnection dbConn, const std::string& title );
private:
MediaLibraryPtr m_ml;
unsigned int m_id;
unsigned int m_mediaId;
unsigned int m_artistId;
unsigned int m_genreId;
int64_t m_id;
int64_t m_mediaId;
int64_t m_artistId;
int64_t m_genreId;
unsigned int m_trackNumber;
unsigned int m_albumId;
int64_t m_albumId;
unsigned int m_discNumber;
bool m_isPresent;
......
......@@ -29,7 +29,7 @@
const std::string policy::ArtistTable::Name = "Artist";
const std::string policy::ArtistTable::PrimaryKeyColumn = "id_artist";
unsigned int Artist::*const policy::ArtistTable::PrimaryKey = &Artist::m_id;
int64_t Artist::*const policy::ArtistTable::PrimaryKey = &Artist::m_id;
Artist::Artist( MediaLibraryPtr ml, sqlite::Row& row )
......@@ -53,7 +53,7 @@ Artist::Artist( MediaLibraryPtr ml, const std::string& name )
{
}
unsigned int Artist::id() const
int64_t Artist::id() const
{
return m_id;
}
......
......@@ -36,7 +36,7 @@ struct ArtistTable
{
static const std::string Name;
static const std::string PrimaryKeyColumn;
static unsigned int Artist::*const PrimaryKey;
static int64_t Artist::*const PrimaryKey;
};
}
......@@ -46,7 +46,7 @@ public:
Artist( MediaLibraryPtr ml, sqlite::Row& row );
Artist( MediaLibraryPtr ml, const std::string& name );
virtual unsigned int id() const override;
virtual int64_t id() const override;
virtual const std::string &name() const override;
virtual const std::string& shortBio() const override;
bool setShortBio( const std::string& shortBio );
......@@ -69,7 +69,7 @@ public:
private:
MediaLibraryPtr m_ml;
unsigned int m_id;
int64_t m_id;
std::string m_name;
std::string m_shortBio;
std::string m_artworkMrl;
......
......@@ -26,7 +26,7 @@
const std::string policy::AudioTrackTable::Name = "AudioTrack";
const std::string policy::AudioTrackTable::PrimaryKeyColumn = "id_track";
unsigned int AudioTrack::* const policy::AudioTrackTable::PrimaryKey = &AudioTrack::m_id;
int64_t AudioTrack::* const policy::AudioTrackTable::PrimaryKey = &AudioTrack::m_id;
AudioTrack::AudioTrack( MediaLibraryPtr ml, sqlite::Row& row )
: m_ml( ml )
......@@ -43,7 +43,7 @@ AudioTrack::AudioTrack( MediaLibraryPtr ml, sqlite::Row& row )
AudioTrack::AudioTrack( MediaLibraryPtr ml, const std::string& codec, unsigned int bitrate, unsigned int sampleRate,
unsigned int nbChannels, const std::string& language, const std::string& desc,
unsigned int mediaId )
int64_t mediaId )
: m_ml( ml )
, m_id( 0 )
, m_codec( codec )
......@@ -56,7 +56,7 @@ AudioTrack::AudioTrack( MediaLibraryPtr ml, const std::string& codec, unsigned i
{
}
unsigned int AudioTrack::id() const
int64_t AudioTrack::id() const
{
return m_id;
}
......@@ -112,7 +112,7 @@ bool AudioTrack::createTable( DBConnection dbConnection )
std::shared_ptr<AudioTrack> AudioTrack::create( MediaLibraryPtr ml, const std::string& codec,
unsigned int bitrate, unsigned int sampleRate, unsigned int nbChannels,
const std::string& language, const std::string& desc, unsigned int mediaId )
const std::string& language, const std::string& desc, int64_t mediaId )
{
static const std::string req = "INSERT INTO " + policy::AudioTrackTable::Name
+ "(codec, bitrate, samplerate, nb_channels, language, description, media_id) VALUES(?, ?, ?, ?, ?, ?, ?)";
......
......@@ -35,7 +35,7 @@ struct AudioTrackTable
{
static const std::string Name;
static const std::string PrimaryKeyColumn;
static unsigned int AudioTrack::* const PrimaryKey;
static int64_t AudioTrack::* const PrimaryKey;
};
}
......@@ -43,9 +43,11 @@ class AudioTrack : public IAudioTrack, public DatabaseHelpers<AudioTrack, policy
{
public:
AudioTrack(MediaLibraryPtr ml, sqlite::Row& row );
AudioTrack( MediaLibraryPtr ml, const std::string& codec, unsigned int bitrate, unsigned int sampleRate, unsigned int nbChannels, const std::string& language, const std::string& desc , unsigned int mediaId);
AudioTrack( MediaLibraryPtr ml, const std::string& codec, unsigned int bitrate,
unsigned int sampleRate, unsigned int nbChannels, const std::string& language,
const std::string& desc, int64_t mediaId );
virtual unsigned int id() const override;
virtual int64_t id() const override;
virtual const std::string&codec() const override;
virtual unsigned int bitrate() const override;
virtual unsigned int sampleRate() const override;
......@@ -55,19 +57,19 @@ class AudioTrack : public IAudioTrack, public DatabaseHelpers<AudioTrack, policy
static bool createTable( DBConnection dbConnection );
static std::shared_ptr<AudioTrack> create( MediaLibraryPtr ml, const std::string& codec,
unsigned int bitrate , unsigned int sampleRate, unsigned int nbChannels,
const std::string& language, const std::string& desc, unsigned int mediaId );
unsigned int bitrate, unsigned int sampleRate, unsigned int nbChannels,
const std::string& language, const std::string& desc, int64_t mediaId );
private:
MediaLibraryPtr m_ml;
unsigned int m_id;
int64_t m_id;
std::string m_codec;
unsigned int m_bitrate;
unsigned int m_sampleRate;
unsigned int m_nbChannels;
std::string m_language;
std::string m_description;
unsigned int m_mediaId;
int64_t m_mediaId;
private:
friend struct policy::AudioTrackTable;
......
......@@ -24,7 +24,7 @@
const std::string policy::DeviceTable::Name = "Device";
const std::string policy::DeviceTable::PrimaryKeyColumn = "id_device";
unsigned int Device::* const policy::DeviceTable::PrimaryKey = &Device::m_id;
int64_t Device::* const policy::DeviceTable::PrimaryKey = &Device::m_id;
Device::Device( MediaLibraryPtr ml, sqlite::Row& row )
: m_ml( ml )
......@@ -46,7 +46,7 @@ Device::Device( MediaLibraryPtr ml, const std::string& uuid, bool isRemovable )
{
}
unsigned int Device::id() const
int64_t Device::id() const
{
return m_id;
}
......
......@@ -33,7 +33,7 @@ struct DeviceTable
{
static const std::string Name;
static const std::string PrimaryKeyColumn;
static unsigned int Device::*const PrimaryKey;
static int64_t Device::*const PrimaryKey;
};
}
......@@ -42,7 +42,7 @@ class Device : public DatabaseHelpers<Device, policy::DeviceTable>
public:
Device( MediaLibraryPtr ml, const std::string& uuid, bool isRemovable );
Device( MediaLibraryPtr ml, sqlite::Row& row );
unsigned int id() const;
int64_t id() const;
const std::string& uuid() const;
bool isRemovable() const;
bool isPresent() const;
......@@ -55,7 +55,7 @@ public:
private:
MediaLibraryPtr m_ml;
// This is a database ID
unsigned int m_id;
int64_t m_id;
// This is a unique ID on the system side, in the /dev/disk/by-uuid sense.
// It can be a name or what not, depending on the OS.
std::string m_uuid;
......
......@@ -27,7 +27,7 @@
const std::string policy::FileTable::Name = "File";
const std::string policy::FileTable::PrimaryKeyColumn = "id_file";
unsigned int File::* const policy::FileTable::PrimaryKey = &File::m_id;
int64_t File::* const policy::FileTable::PrimaryKey = &File::m_id;
File::File( MediaLibraryPtr ml, sqlite::Row& row )
: m_ml( ml )
......@@ -43,7 +43,7 @@ File::File( MediaLibraryPtr ml, sqlite::Row& row )
>> m_isRemovable;
}
File::File( MediaLibraryPtr ml, unsigned int mediaId, Type type, const fs::IFile& file, unsigned int folderId, bool isRemovable )
File::File( MediaLibraryPtr ml, int64_t mediaId, Type type, const fs::IFile& file, int64_t folderId, bool isRemovable )
: m_ml( ml )
, m_id( 0 )
, m_mediaId( mediaId )
......@@ -57,7 +57,7 @@ File::File( MediaLibraryPtr ml, unsigned int mediaId, Type type, const fs::IFile
{
}
unsigned int File::id() const
int64_t File::id() const
{
return m_id;
}
......@@ -147,7 +147,7 @@ bool File::createTable( DBConnection dbConnection )
sqlite::Tools::executeRequest( dbConnection, indexReq );
}
std::shared_ptr<File> File::create( MediaLibraryPtr ml, unsigned int mediaId, Type type, const fs::IFile& fileFs, unsigned int folderId, bool isRemovable )
std::shared_ptr<File> File::create( MediaLibraryPtr ml, int64_t mediaId, Type type, const fs::IFile& fileFs, int64_t folderId, bool isRemovable )
{
auto self = std::make_shared<File>( ml, mediaId, type, fileFs, folderId, isRemovable );
static const std::string req = "INSERT INTO " + policy::FileTable::Name +
......
......@@ -37,7 +37,7 @@ struct FileTable
{
static const std::string Name;
static const std::string PrimaryKeyColumn;
static unsigned int File::*const PrimaryKey;
static int64_t File::*const PrimaryKey;
};
}
......@@ -45,8 +45,8 @@ class File : public IFile, public DatabaseHelpers<File, policy::FileTable>
{
public:
File( MediaLibraryPtr ml, sqlite::Row& row );
File(MediaLibraryPtr ml, unsigned int mediaId, Type type, const fs::IFile& file, unsigned int folderId, bool isRemovable );
virtual unsigned int id() const override;
File( MediaLibraryPtr ml, int64_t mediaId, Type type, const fs::IFile& file, int64_t folderId, bool isRemovable );
virtual int64_t id() const override;
virtual const std::string& mrl() const override;
virtual Type type() const override;
virtual unsigned int lastModificationDate() const override;
......@@ -59,18 +59,19 @@ public:
bool destroy();
static bool createTable( DBConnection dbConnection );
static std::shared_ptr<File> create( MediaLibraryPtr ml, unsigned int mediaId, Type type, const fs::IFile& file, unsigned int folderId, bool isRemovable );
static std::shared_ptr<File> create( MediaLibraryPtr ml, int64_t mediaId, Type type,
const fs::IFile& file, int64_t folderId, bool isRemovable );
private:
MediaLibraryPtr m_ml;
unsigned int m_id;
unsigned int m_mediaId;
int64_t m_id;
int64_t m_mediaId;
std::string m_mrl;
Type m_type;
unsigned int m_lastModificationDate;
bool m_isParsed;
unsigned int m_folderId;
int64_t m_folderId;
bool m_isPresent;
bool m_isRemovable;
......
......@@ -36,7 +36,7 @@ namespace policy
{
const std::string FolderTable::Name = "Folder";
const std::string FolderTable::PrimaryKeyColumn = "id_folder";
unsigned int Folder::* const FolderTable::PrimaryKey = &Folder::m_id;
int64_t Folder::* const FolderTable::PrimaryKey = &Folder::m_id;
}
std::shared_ptr<factory::IFileSystem> Folder::FsFactory;
......@@ -53,7 +53,7 @@ Folder::Folder( MediaLibraryPtr ml, sqlite::Row& row )
>> m_isRemovable;
}
Folder::Folder(MediaLibraryPtr ml, const std::string& path, unsigned int parent, unsigned int deviceId, bool isRemovable )
Folder::Folder(MediaLibraryPtr ml, const std::string& path, int64_t parent, int64_t deviceId, bool isRemovable )
: m_ml( ml )
, m_id( 0 )
, m_path( path )
......@@ -91,7 +91,8 @@ bool Folder::createTable( DBConnection connection)
sqlite::Tools::executeRequest( connection, triggerReq );
}
std::shared_ptr<Folder> Folder::create( MediaLibraryPtr ml, const std::string& fullPath, unsigned int parentId, Device& device, fs::IDevice& deviceFs )
std::shared_ptr<Folder> Folder::create( MediaLibraryPtr ml, const std::string& fullPath,
int64_t parentId, Device& device, fs::IDevice& deviceFs )
{
std::string path;
if ( device.isRemovable() == true )
......@@ -182,7 +183,7 @@ std::shared_ptr<Folder> Folder::fromPath( MediaLibraryPtr ml, const std::string&
return folder;
}
unsigned int Folder::id() const
int64_t Folder::id() const
{
return m_id;
}
......@@ -220,7 +221,7 @@ std::shared_ptr<Folder> Folder::parent()
return fetch( m_ml, m_parent );
}
unsigned int Folder::deviceId() const
int64_t Folder::deviceId() const
{
return m_deviceId;
}
......@@ -230,7 +231,7 @@ bool Folder::isPresent() const
return m_isPresent;
}
std::vector<std::shared_ptr<Folder>> Folder::fetchAll( MediaLibraryPtr ml, unsigned int parentFolderId )
std::vector<std::shared_ptr<Folder>> Folder::fetchAll( MediaLibraryPtr ml, int64_t parentFolderId )
{
if ( parentFolderId == 0 )
{
......
......@@ -43,7 +43,7 @@ struct FolderTable
{
static const std::string Name;
static const std::string PrimaryKeyColumn;
static unsigned int Folder::*const PrimaryKey;
static int64_t Folder::*const PrimaryKey;
};
}
......@@ -55,12 +55,12 @@ class Folder : public DatabaseHelpers<Folder, policy::FolderTable>
{
public:
Folder( MediaLibraryPtr ml, sqlite::Row& row );
Folder( MediaLibraryPtr ml, const std::string& path, unsigned int parent , unsigned int deviceId , bool isRemovable );
Folder(MediaLibraryPtr ml, const std::string& path, int64_t parent , int64_t deviceId , bool isRemovable );
static bool createTable( DBConnection connection );
static std::shared_ptr<Folder> create( MediaLibraryPtr ml, const std::string& path, unsigned int parentId, Device& device, fs::IDevice& deviceFs );
static std::shared_ptr<Folder> create( MediaLibraryPtr ml, const std::string& path, int64_t parentId, Device& device, fs::IDevice& deviceFs );
static bool blacklist( MediaLibraryPtr ml, const std::string& fullPath );
static std::vector<std::shared_ptr<Folder>> fetchAll(MediaLibraryPtr ml, unsigned int parentFolderId );
static std::vector<std::shared_ptr<Folder>> fetchAll( MediaLibraryPtr ml, int64_t parentFolderId );
///
/// \brief setFileSystemFactory Sets a file system factory to be used when building IDevices
/// This is assumed to be called once, before any discovery/reloading process is launched.
......@@ -71,12 +71,12 @@ public:
static std::shared_ptr<Folder> fromPath(MediaLibraryPtr ml, const std::string& fullPath );
static std::shared_ptr<Folder> blacklistedFolder(MediaLibraryPtr ml, const std::string& fullPath );
unsigned int id() const;
int64_t id() const;
const std::string& path() const;
std::vector<std::shared_ptr<File>> files();
std::vector<std::shared_ptr<Folder>> folders();
std::shared_ptr<Folder> parent();
unsigned int deviceId() const;
int64_t deviceId() const;
bool isPresent() const;