Removed all uint32 and uint64 handling when dealing with sqlite and resource

ids. Use signed integers only. This simplifies things, and simplifies dealing
with these values in languages that don't natively support unsigned value
types, e.g. Java. It also slims down our SDK interfaces and implementations.
This commit is contained in:
Casey Langen 2017-05-16 11:13:30 -07:00
parent 002d0266e0
commit 0201741689
59 changed files with 226 additions and 340 deletions

View File

@ -236,7 +236,7 @@ void PlaybackService::ToggleShuffle() {
/* remember the ID of the playing track -- we're going to need to look /* remember the ID of the playing track -- we're going to need to look
it up after the shuffle */ it up after the shuffle */
uint64_t id = -1; int64_t id = -1;
if (this->index < this->playlist.Count()) { if (this->index < this->playlist.Count()) {
id = this->playlist.GetId(this->index); id = this->playlist.GetId(this->index);
} }
@ -796,7 +796,7 @@ PlaybackService::Editor::~Editor() {
/* implicitly unlocks the mutex when this block exists */ /* implicitly unlocks the mutex when this block exists */
} }
bool PlaybackService::Editor::Insert(uint64_t id, size_t index) { bool PlaybackService::Editor::Insert(int64_t id, size_t index) {
if ((this->edited = this->tracks.Insert(id, index))) { if ((this->edited = this->tracks.Insert(id, index))) {
if (index == this->playIndex) { if (index == this->playIndex) {
++this->playIndex; ++this->playIndex;
@ -864,7 +864,7 @@ bool PlaybackService::Editor::Delete(size_t index) {
return false; return false;
} }
void PlaybackService::Editor::Add(const uint64_t id) { void PlaybackService::Editor::Add(const int64_t id) {
this->tracks.Add(id); this->tracks.Add(id);
if (this->playback.Count() - 1 == this->playIndex + 1) { if (this->playback.Count() - 1 == this->playIndex + 1) {

View File

@ -131,11 +131,11 @@ namespace musik { namespace core { namespace audio {
~Editor(); ~Editor();
/* ITrackListEditor */ /* ITrackListEditor */
virtual bool Insert(uint64_t id, size_t index); virtual bool Insert(int64_t id, size_t index);
virtual bool Swap(size_t index1, size_t index2); virtual bool Swap(size_t index1, size_t index2);
virtual bool Move(size_t from, size_t to); virtual bool Move(size_t from, size_t to);
virtual bool Delete(size_t index); virtual bool Delete(size_t index);
virtual void Add(const uint64_t id); virtual void Add(const int64_t id);
virtual void Clear(); virtual void Clear();
virtual void Shuffle(); virtual void Shuffle();
virtual void Release(); virtual void Release();

View File

@ -154,7 +154,7 @@ void Connection::Checkpoint() {
sqlite3_wal_checkpoint(this->connection, nullptr); sqlite3_wal_checkpoint(this->connection, nullptr);
} }
uint64_t Connection::LastInsertedId() { int64_t Connection::LastInsertedId() {
return sqlite3_last_insert_rowid(this->connection); return sqlite3_last_insert_rowid(this->connection);
} }

View File

@ -66,7 +66,7 @@ namespace musik { namespace core { namespace db {
int Execute(const char* sql); int Execute(const char* sql);
int Execute(const wchar_t* sql); int Execute(const wchar_t* sql);
uint64_t LastInsertedId(); int64_t LastInsertedId();
int LastModifiedRowCount(); int LastModifiedRowCount();

View File

@ -81,18 +81,10 @@ void Statement::BindInt32(int position, int bindInt) {
sqlite3_bind_int(this->stmt, position + 1, bindInt); sqlite3_bind_int(this->stmt, position + 1, bindInt);
} }
void Statement::BindUint32(int position, size_t bindInt) {
sqlite3_bind_int(this->stmt, position + 1, (int) bindInt);
}
void Statement::BindInt64(int position, int64_t bindInt) { void Statement::BindInt64(int position, int64_t bindInt) {
sqlite3_bind_int64(this->stmt, position + 1, (sqlite3_int64) bindInt); sqlite3_bind_int64(this->stmt, position + 1, (sqlite3_int64) bindInt);
} }
void Statement::BindUint64(int position, uint64_t bindInt) {
sqlite3_bind_int64(this->stmt, position + 1, (sqlite3_int64) bindInt);
}
void Statement::BindText(int position, const char* bindText) { void Statement::BindText(int position, const char* bindText) {
sqlite3_bind_text( sqlite3_bind_text(
this->stmt, this->stmt,
@ -136,18 +128,10 @@ int Statement::ColumnInt32(int column) {
return sqlite3_column_int(this->stmt, column); return sqlite3_column_int(this->stmt, column);
} }
size_t Statement::ColumnUint32(int column) {
return (size_t) sqlite3_column_int(this->stmt, column);
}
int64_t Statement::ColumnInt64(int column) { int64_t Statement::ColumnInt64(int column) {
return sqlite3_column_int64(this->stmt, column); return sqlite3_column_int64(this->stmt, column);
} }
uint64_t Statement::ColumnUint64(int column) {
return (uint64_t) sqlite3_column_int64(this->stmt, column);
}
const char* Statement::ColumnText(int column) { const char* Statement::ColumnText(int column) {
const char* text = (char*) sqlite3_column_text(this->stmt, column); const char* text = (char*) sqlite3_column_text(this->stmt, column);
return text ? text : ""; return text ? text : "";

View File

@ -54,9 +54,7 @@ namespace musik { namespace core { namespace db {
int Step(); int Step();
void BindInt32(int position, int bindInt); void BindInt32(int position, int bindInt);
void BindUint32(int position, size_t bindInt);
void BindInt64(int position, int64_t bindInt); void BindInt64(int position, int64_t bindInt);
void BindUint64(int position, uint64_t bindInt);
void BindText(int position, const char* bindText); void BindText(int position, const char* bindText);
void BindText(int position, const std::string &bindText); void BindText(int position, const std::string &bindText);
void BindTextW(int position, const wchar_t* bindText); void BindTextW(int position, const wchar_t* bindText);
@ -64,8 +62,6 @@ namespace musik { namespace core { namespace db {
void BindNull(int position); void BindNull(int position);
int ColumnInt32(int column); int ColumnInt32(int column);
size_t ColumnUint32(int column);
uint64_t ColumnUint64(int column);
int64_t ColumnInt64(int column); int64_t ColumnInt64(int column);
const char* ColumnText(int column); const char* ColumnText(int column);
const wchar_t* ColumnTextW(int column); const wchar_t* ColumnTextW(int column);

View File

@ -65,7 +65,7 @@
static const std::string TAG = "Indexer"; static const std::string TAG = "Indexer";
static const int MAX_THREADS = 2; static const int MAX_THREADS = 2;
static const size_t TRANSACTION_INTERVAL = 300; static const size_t TRANSACTION_INTERVAL = 300;
static std::atomic<uint64_t> nextExternalId; static std::atomic<int64_t> nextExternalId;
using namespace musik::core; using namespace musik::core;
using namespace musik::core::sdk; using namespace musik::core::sdk;
@ -251,20 +251,20 @@ void Indexer::Synchronize(const SyncContext& context, boost::asio::io_service* i
{ {
db::Statement stmt("SELECT MAX(id) FROM tracks", this->dbConnection); db::Statement stmt("SELECT MAX(id) FROM tracks", this->dbConnection);
if (stmt.Step() == db::Row) { if (stmt.Step() == db::Row) {
auto id = std::max((uint64_t) 1, stmt.ColumnUint64(0)); auto id = std::max((int64_t) 1, stmt.ColumnInt64(0));
nextExternalId.store(id); nextExternalId.store(id);
} }
} }
std::vector<std::string> paths; std::vector<std::string> paths;
std::vector<uint64_t> pathIds; std::vector<int64_t> pathIds;
/* resolve all the path and path ids (required for local files */ /* resolve all the path and path ids (required for local files */
db::Statement stmt("SELECT id, path FROM paths", this->dbConnection); db::Statement stmt("SELECT id, path FROM paths", this->dbConnection);
while (stmt.Step() == db::Row) { while (stmt.Step() == db::Row) {
try { try {
uint64_t id = stmt.ColumnUint64(0); int64_t id = stmt.ColumnInt64(0);
std::string path = stmt.ColumnText(1); std::string path = stmt.ColumnText(1);
boost::filesystem::path dir(path); boost::filesystem::path dir(path);
@ -415,7 +415,7 @@ void Indexer::SyncDirectory(
boost::asio::io_service* io, boost::asio::io_service* io,
const std::string &syncRoot, const std::string &syncRoot,
const std::string &currentPath, const std::string &currentPath,
uint64_t pathId) int64_t pathId)
{ {
if (this->Exited()) { if (this->Exited()) {
return; return;
@ -487,7 +487,7 @@ ScanResult Indexer::SyncSource(IIndexerSource* source) {
tracks.BindInt32(0, source->SourceId()); tracks.BindInt32(0, source->SourceId());
while (tracks.Step() == db::Row) { while (tracks.Step() == db::Row) {
TrackPtr track(new IndexerTrack(tracks.ColumnUint64(0))); TrackPtr track(new IndexerTrack(tracks.ColumnInt64(0)));
track->SetValue(constants::Track::FILENAME, tracks.ColumnText(1)); track->SetValue(constants::Track::FILENAME, tracks.ColumnText(1));
source->ScanTrack(this, new RetainedTrackWriter(track), tracks.ColumnText(2)); source->ScanTrack(this, new RetainedTrackWriter(track), tracks.ColumnText(2));
} }
@ -670,7 +670,7 @@ static int optimize(
int count = 0; int count = 0;
while (outerStmt.Step() == db::Row) { while (outerStmt.Step() == db::Row) {
innerStmt.BindInt32(0, count); innerStmt.BindInt32(0, count);
innerStmt.BindUint64(1, outerStmt.ColumnUint64(0)); innerStmt.BindInt64(1, outerStmt.ColumnInt64(0));
innerStmt.Step(); innerStmt.Step();
innerStmt.Reset(); innerStmt.Reset();
++count; ++count;
@ -732,16 +732,16 @@ void Indexer::RunAnalyzers() {
/* for each track... */ /* for each track... */
uint64_t trackId = 0; int64_t trackId = 0;
db::Statement getNextTrack( db::Statement getNextTrack(
"SELECT id FROM tracks WHERE id>? ORDER BY id LIMIT 1", "SELECT id FROM tracks WHERE id>? ORDER BY id LIMIT 1",
this->dbConnection); this->dbConnection);
getNextTrack.BindUint64(0, trackId); getNextTrack.BindInt64(0, trackId);
while(getNextTrack.Step() == db::Row ) { while(getNextTrack.Step() == db::Row ) {
trackId = getNextTrack.ColumnUint64(0); trackId = getNextTrack.ColumnInt64(0);
getNextTrack.Reset(); getNextTrack.Reset();
getNextTrack.UnbindAll(); getNextTrack.UnbindAll();
@ -806,7 +806,7 @@ void Indexer::RunAnalyzers() {
return; return;
} }
getNextTrack.BindUint64(0, trackId); getNextTrack.BindInt64(0, trackId);
} }
} }

View File

@ -131,7 +131,7 @@ namespace musik { namespace core {
boost::asio::io_service* io, boost::asio::io_service* io,
const std::string& syncRoot, const std::string& syncRoot,
const std::string& currentPath, const std::string& currentPath,
uint64_t pathId); int64_t pathId);
void ReadMetadataFromFile( void ReadMetadataFromFile(
const boost::filesystem::path& path, const boost::filesystem::path& path,

View File

@ -260,15 +260,15 @@ static void upgradeV1toV2(db::Connection &db) {
{ {
db::ScopedTransaction transaction(db); db::ScopedTransaction transaction(db);
uint64_t id; int64_t id;
db::Statement update("UPDATE tracks SET external_id=? WHERE id=?", db); db::Statement update("UPDATE tracks SET external_id=? WHERE id=?", db);
db::Statement query("SELECT id FROM tracks WHERE coalesce(external_id, '') == ''", db); db::Statement query("SELECT id FROM tracks WHERE coalesce(external_id, '') == ''", db);
while (query.Step() == db::Row) { while (query.Step() == db::Row) {
id = query.ColumnUint64(0); id = query.ColumnInt64(0);
update.Reset(); update.Reset();
update.BindText(0, "local://" + std::to_string(id)); update.BindText(0, "local://" + std::to_string(id));
update.BindUint64(1, id); update.BindInt64(1, id);
update.Step(); update.Step();
} }
} }

View File

@ -87,7 +87,7 @@ ITrackList* LocalSimpleDataProvider::QueryTracks(const char* query, int limit, i
return nullptr; return nullptr;
} }
IRetainedTrack* LocalSimpleDataProvider::QueryTrackById(uint64_t trackId) { IRetainedTrack* LocalSimpleDataProvider::QueryTrackById(int64_t trackId) {
try { try {
TrackPtr target(new LibraryTrack(trackId, this->library)); TrackPtr target(new LibraryTrack(trackId, this->library));
@ -132,7 +132,7 @@ IRetainedTrack* LocalSimpleDataProvider::QueryTrackByExternalId(const char* exte
ITrackList* LocalSimpleDataProvider::QueryTracksByCategory( ITrackList* LocalSimpleDataProvider::QueryTracksByCategory(
const char* categoryType, const char* categoryType,
uint64_t selectedId, int64_t selectedId,
const char* filter, const char* filter,
int limit, int limit,
int offset) int offset)
@ -185,7 +185,7 @@ IMetadataValueList* LocalSimpleDataProvider::QueryCategory(const char* type, con
IMetadataMapList* LocalSimpleDataProvider::QueryAlbums( IMetadataMapList* LocalSimpleDataProvider::QueryAlbums(
const char* categoryIdName, const char* categoryIdName,
uint64_t categoryIdValue, int64_t categoryIdValue,
const char* filter) const char* filter)
{ {
try { try {

View File

@ -51,14 +51,14 @@ namespace musik { namespace core { namespace db { namespace local {
int limit = -1, int limit = -1,
int offset = 0); int offset = 0);
virtual musik::core::sdk::IRetainedTrack* QueryTrackById(uint64_t trackId); virtual musik::core::sdk::IRetainedTrack* QueryTrackById(int64_t trackId);
virtual musik::core::sdk::IRetainedTrack* QueryTrackByExternalId(const char* externalId); virtual musik::core::sdk::IRetainedTrack* QueryTrackByExternalId(const char* externalId);
virtual musik::core::sdk::ITrackList* virtual musik::core::sdk::ITrackList*
QueryTracksByCategory( QueryTracksByCategory(
const char* categoryType, const char* categoryType,
uint64_t selectedId, int64_t selectedId,
const char* filter = "", const char* filter = "",
int limit = -1, int limit = -1,
int offset = 0); int offset = 0);
@ -73,7 +73,7 @@ namespace musik { namespace core { namespace db { namespace local {
virtual musik::core::sdk::IMetadataMapList* QueryAlbums( virtual musik::core::sdk::IMetadataMapList* QueryAlbums(
const char* categoryIdName, const char* categoryIdName,
uint64_t categoryIdValue, int64_t categoryIdValue,
const char* filter = ""); const char* filter = "");
private: private:

View File

@ -55,11 +55,9 @@ namespace {
public: public:
SdkWrapper(MetadataMapPtr wrapped) { this->wrapped = wrapped; }; SdkWrapper(MetadataMapPtr wrapped) { this->wrapped = wrapped; };
virtual void Release() { this->wrapped.reset(); } virtual void Release() { this->wrapped.reset(); }
virtual uint64_t GetId() { return this->wrapped->GetId(); } virtual int64_t GetId() { return this->wrapped->GetId(); }
virtual int GetValue(const char* key, char* dst, int size) { return this->wrapped->GetValue(key, dst, size); } virtual int GetValue(const char* key, char* dst, int size) { return this->wrapped->GetValue(key, dst, size); }
virtual uint64_t GetUint64(const char* key, uint64_t defaultValue) { return this->wrapped->GetUint64(key, defaultValue); }
virtual long long GetInt64(const char* key, long long defaultValue) { return this->wrapped->GetInt64(key, defaultValue); } virtual long long GetInt64(const char* key, long long defaultValue) { return this->wrapped->GetInt64(key, defaultValue); }
virtual unsigned int GetUint32(const char* key, unsigned long defaultValue) { return this->wrapped->GetUint32(key, defaultValue); }
virtual int GetInt32(const char* key, unsigned int defaultValue) { return this->wrapped->GetInt32(key, defaultValue); } virtual int GetInt32(const char* key, unsigned int defaultValue) { return this->wrapped->GetInt32(key, defaultValue); }
virtual double GetDouble(const char* key, double defaultValue) { return this->wrapped->GetDouble(key, defaultValue); } virtual double GetDouble(const char* key, double defaultValue) { return this->wrapped->GetDouble(key, defaultValue); }
virtual const char* GetDescription() { return this->wrapped->GetDescription(); } virtual const char* GetDescription() { return this->wrapped->GetDescription(); }
@ -69,7 +67,7 @@ namespace {
} }
MetadataMap::MetadataMap( MetadataMap::MetadataMap(
uint64_t id, int64_t id,
const std::string& description, const std::string& description,
const std::string& type) const std::string& type)
{ {
@ -86,7 +84,7 @@ void MetadataMap::Release() {
/* nothing... */ /* nothing... */
} }
uint64_t MetadataMap::GetId() { int64_t MetadataMap::GetId() {
return this->id; return this->id;
} }
@ -111,18 +109,6 @@ std::string MetadataMap::GetValue(const char* key) {
return ""; return "";
} }
uint64_t MetadataMap::GetUint64(const char* key, uint64_t defaultValue) {
try {
std::string value = GetValue(key);
if (value.size()) {
return std::stoull(GetValue(key));
}
}
catch (...) {
}
return defaultValue;
}
long long MetadataMap::GetInt64(const char* key, long long defaultValue) { long long MetadataMap::GetInt64(const char* key, long long defaultValue) {
try { try {
std::string value = GetValue(key); std::string value = GetValue(key);
@ -135,18 +121,6 @@ long long MetadataMap::GetInt64(const char* key, long long defaultValue) {
return defaultValue; return defaultValue;
} }
unsigned int MetadataMap::GetUint32(const char* key, unsigned long defaultValue) {
try {
std::string value = GetValue(key);
if (value.size()) {
return std::stoul(GetValue(key));
}
}
catch (...) {
}
return defaultValue;
}
int MetadataMap::GetInt32(const char* key, unsigned int defaultValue) { int MetadataMap::GetInt32(const char* key, unsigned int defaultValue) {
try { try {
std::string value = GetValue(key); std::string value = GetValue(key);

View File

@ -47,7 +47,7 @@ namespace musik { namespace core {
{ {
public: public:
MetadataMap( MetadataMap(
uint64_t id, int64_t id,
const std::string& description, const std::string& description,
const std::string& type); const std::string& type);
@ -55,14 +55,12 @@ namespace musik { namespace core {
/* IMetadataMap */ /* IMetadataMap */
virtual void Release(); virtual void Release();
virtual uint64_t GetId(); virtual int64_t GetId();
virtual const char* GetDescription(); virtual const char* GetDescription();
virtual const char* GetType(); virtual const char* GetType();
virtual int GetValue(const char* key, char* dst, int size); virtual int GetValue(const char* key, char* dst, int size);
virtual uint64_t GetUint64(const char* key, uint64_t defaultValue = 0ULL);
virtual long long GetInt64(const char* key, long long defaultValue = 0LL); virtual long long GetInt64(const char* key, long long defaultValue = 0LL);
virtual unsigned int GetUint32(const char* key, unsigned long defaultValue = 0);
virtual int GetInt32(const char* key, unsigned int defaultValue = 0); virtual int GetInt32(const char* key, unsigned int defaultValue = 0);
virtual double GetDouble(const char* key, double defaultValue = 0.0f); virtual double GetDouble(const char* key, double defaultValue = 0.0f);
@ -72,7 +70,7 @@ namespace musik { namespace core {
musik::core::sdk::IMetadataMap* GetSdkValue(); musik::core::sdk::IMetadataMap* GetSdkValue();
private: private:
uint64_t id; int64_t id;
std::string type, description; std::string type, description;
std::unordered_map<std::string, std::string> metadata; std::unordered_map<std::string, std::string> metadata;
}; };

View File

@ -93,7 +93,7 @@ AlbumListQuery::AlbumListQuery(const std::string& filter)
AlbumListQuery::AlbumListQuery( AlbumListQuery::AlbumListQuery(
const std::string& fieldIdName, const std::string& fieldIdName,
uint64_t fieldIdValue, int64_t fieldIdValue,
const std::string& filter) const std::string& filter)
: filter(filter) : filter(filter)
, fieldIdValue(fieldIdValue) { , fieldIdValue(fieldIdValue) {
@ -143,12 +143,12 @@ bool AlbumListQuery::OnRun(Connection& db) {
} }
if (category) { if (category) {
stmt.BindUint64(bindIndex, this->fieldIdValue); stmt.BindInt64(bindIndex, this->fieldIdValue);
} }
while (stmt.Step() == Row) { while (stmt.Step() == Row) {
std::shared_ptr<MetadataMap> row(new MetadataMap( std::shared_ptr<MetadataMap> row(new MetadataMap(
stmt.ColumnUint64(0), stmt.ColumnInt64(0),
stmt.ColumnText(1), stmt.ColumnText(1),
"album")); "album"));

View File

@ -44,7 +44,7 @@ namespace musik { namespace core { namespace db { namespace local {
public: public:
AlbumListQuery( AlbumListQuery(
const std::string& fieldIdName, const std::string& fieldIdName,
uint64_t fieldIdValue, int64_t fieldIdValue,
const std::string& filter = ""); const std::string& filter = "");
AlbumListQuery( AlbumListQuery(
@ -62,7 +62,7 @@ namespace musik { namespace core { namespace db { namespace local {
std::string filter; std::string filter;
std::string fieldIdName; std::string fieldIdName;
uint64_t fieldIdValue; int64_t fieldIdValue;
musik::core::MetadataMapListPtr result; musik::core::MetadataMapListPtr result;
}; };

View File

@ -171,7 +171,7 @@ musik::core::sdk::IMetadataValueList* CategoryListQuery::GetSdkResult() {
return new MetadataList(this->result); return new MetadataList(this->result);
} }
int CategoryListQuery::GetIndexOf(uint64_t id) { int CategoryListQuery::GetIndexOf(int64_t id) {
auto result = this->GetResult(); auto result = this->GetResult();
for (size_t i = 0; i < result->size(); i++) { for (size_t i = 0; i < result->size(); i++) {
if (id == (*result)[i]->id) { if (id == (*result)[i]->id) {
@ -202,7 +202,7 @@ bool CategoryListQuery::OnRun(Connection& db) {
while (stmt.Step() == Row) { while (stmt.Step() == Row) {
std::shared_ptr<Result> row(new Result()); std::shared_ptr<Result> row(new Result());
row->id = stmt.ColumnUint64(0); row->id = stmt.ColumnInt64(0);
row->displayValue = stmt.ColumnText(1); row->displayValue = stmt.ColumnText(1);
result->push_back(row); result->push_back(row);
} }

View File

@ -47,7 +47,7 @@ namespace musik { namespace core { namespace db { namespace local {
/* note we implement the SDK's IMetadataValue interface so /* note we implement the SDK's IMetadataValue interface so
we can return data to plugins! */ we can return data to plugins! */
struct Result : public musik::core::sdk::IMetadataValue { struct Result : public musik::core::sdk::IMetadataValue {
virtual uint64_t GetId() { virtual int64_t GetId() {
return this->id; return this->id;
} }
@ -60,7 +60,7 @@ namespace musik { namespace core { namespace db { namespace local {
} }
std::string displayValue; std::string displayValue;
uint64_t id; int64_t id;
}; };
typedef std::shared_ptr<std::vector< typedef std::shared_ptr<std::vector<
@ -75,7 +75,7 @@ namespace musik { namespace core { namespace db { namespace local {
std::string Name() { return "CategoryListQuery"; } std::string Name() { return "CategoryListQuery"; }
virtual ResultList GetResult(); virtual ResultList GetResult();
virtual int GetIndexOf(uint64_t id); virtual int GetIndexOf(int64_t id);
musik::core::sdk::IMetadataValueList* GetSdkResult(); musik::core::sdk::IMetadataValueList* GetSdkResult();

View File

@ -66,7 +66,7 @@ static std::map<std::string, std::string> FIELD_TO_FOREIGN_KEY =
CategoryTrackListQuery::CategoryTrackListQuery( CategoryTrackListQuery::CategoryTrackListQuery(
ILibraryPtr library, ILibraryPtr library,
const std::string& column, const std::string& column,
uint64_t id, int64_t id,
const std::string& filter) const std::string& filter)
{ {
this->library = library; this->library = library;
@ -134,18 +134,18 @@ bool CategoryTrackListQuery::OnRun(Connection& db) {
Statement trackQuery(query.c_str(), db); Statement trackQuery(query.c_str(), db);
if (this->filter.size()) { if (this->filter.size()) {
trackQuery.BindUint64(0, this->id); trackQuery.BindInt64(0, this->id);
trackQuery.BindText(1, this->filter); trackQuery.BindText(1, this->filter);
trackQuery.BindText(2, this->filter); trackQuery.BindText(2, this->filter);
trackQuery.BindText(3, this->filter); trackQuery.BindText(3, this->filter);
trackQuery.BindText(4, this->filter); trackQuery.BindText(4, this->filter);
} }
else { else {
trackQuery.BindUint64(0, this->id); trackQuery.BindInt64(0, this->id);
} }
while (trackQuery.Step() == Row) { while (trackQuery.Step() == Row) {
uint64_t id = trackQuery.ColumnUint64(0); int64_t id = trackQuery.ColumnInt64(0);
std::string album = trackQuery.ColumnText(1); std::string album = trackQuery.ColumnText(1);
if (album != lastAlbum) { if (album != lastAlbum) {

View File

@ -47,7 +47,7 @@ namespace musik { namespace core { namespace db { namespace local {
CategoryTrackListQuery( CategoryTrackListQuery(
musik::core::ILibraryPtr library, musik::core::ILibraryPtr library,
const std::string& column, const std::string& column,
uint64_t id, int64_t id,
const std::string& filter = ""); const std::string& filter = "");
virtual ~CategoryTrackListQuery(); virtual ~CategoryTrackListQuery();
@ -66,7 +66,7 @@ namespace musik { namespace core { namespace db { namespace local {
Result result; Result result;
Headers headers; Headers headers;
std::string column; std::string column;
uint64_t id; int64_t id;
size_t hash; size_t hash;
std::string filter; std::string filter;
}; };

View File

@ -48,7 +48,7 @@ static std::string DELETE_PLAYLIST_TRACKS_QUERY =
static std::string DELETE_PLAYLIST_QUERY = static std::string DELETE_PLAYLIST_QUERY =
"DELETE FROM playlists WHERE id=?;"; "DELETE FROM playlists WHERE id=?;";
DeletePlaylistQuery::DeletePlaylistQuery(const uint64_t playlistId) { DeletePlaylistQuery::DeletePlaylistQuery(const int64_t playlistId) {
this->playlistId = playlistId; this->playlistId = playlistId;
} }
@ -60,7 +60,7 @@ bool DeletePlaylistQuery::OnRun(musik::core::db::Connection &db) {
/* create playlist */ /* create playlist */
Statement deleteTracks(DELETE_PLAYLIST_TRACKS_QUERY.c_str(), db); Statement deleteTracks(DELETE_PLAYLIST_TRACKS_QUERY.c_str(), db);
deleteTracks.BindUint64(0, this->playlistId); deleteTracks.BindInt64(0, this->playlistId);
if (deleteTracks.Step() == db::Error) { if (deleteTracks.Step() == db::Error) {
transaction.Cancel(); transaction.Cancel();
@ -69,7 +69,7 @@ bool DeletePlaylistQuery::OnRun(musik::core::db::Connection &db) {
/* add tracks to playlist */ /* add tracks to playlist */
Statement deletePlaylist(DELETE_PLAYLIST_QUERY.c_str(), db); Statement deletePlaylist(DELETE_PLAYLIST_QUERY.c_str(), db);
deletePlaylist.BindUint64(0, this->playlistId); deletePlaylist.BindInt64(0, this->playlistId);
if (deletePlaylist.Step() == db::Error) { if (deletePlaylist.Step() == db::Error) {
transaction.Cancel(); transaction.Cancel();

View File

@ -41,7 +41,7 @@ namespace musik { namespace core { namespace db { namespace local {
class DeletePlaylistQuery : public musik::core::db::LocalQueryBase { class DeletePlaylistQuery : public musik::core::db::LocalQueryBase {
public: public:
DeletePlaylistQuery(const uint64_t playlistId); DeletePlaylistQuery(const int64_t playlistId);
virtual ~DeletePlaylistQuery(); virtual ~DeletePlaylistQuery();
virtual std::string Name() { return "DeletePlaylistQuery"; } virtual std::string Name() { return "DeletePlaylistQuery"; }
@ -50,7 +50,7 @@ namespace musik { namespace core { namespace db { namespace local {
virtual bool OnRun(musik::core::db::Connection &db); virtual bool OnRun(musik::core::db::Connection &db);
private: private:
uint64_t playlistId; int64_t playlistId;
}; };
} } } } } } } }

View File

@ -49,12 +49,12 @@ using namespace musik::core::db;
using namespace musik::core::library::constants; using namespace musik::core::library::constants;
using namespace musik::core::db::local; using namespace musik::core::db::local;
GetPlaylistQuery::GetPlaylistQuery(ILibraryPtr library, uint64_t playlistId) { GetPlaylistQuery::GetPlaylistQuery(ILibraryPtr library, int64_t playlistId) {
this->library = library; this->library = library;
this->playlistId = playlistId; this->playlistId = playlistId;
this->result.reset(new musik::core::TrackList(library)); this->result.reset(new musik::core::TrackList(library));
this->headers.reset(new std::set<size_t>()); this->headers.reset(new std::set<size_t>());
this->hash = std::hash<uint64_t>()(this->playlistId); this->hash = std::hash<int64_t>()(this->playlistId);
} }
GetPlaylistQuery::~GetPlaylistQuery() { GetPlaylistQuery::~GetPlaylistQuery() {
@ -87,10 +87,10 @@ bool GetPlaylistQuery::OnRun(Connection& db) {
this->GetLimitAndOffset(); this->GetLimitAndOffset();
Statement trackQuery(query.c_str(), db); Statement trackQuery(query.c_str(), db);
trackQuery.BindUint64(0, this->playlistId); trackQuery.BindInt64(0, this->playlistId);
while (trackQuery.Step() == Row) { while (trackQuery.Step() == Row) {
result->Add(trackQuery.ColumnUint64(0)); result->Add(trackQuery.ColumnInt64(0));
} }
return true; return true;

View File

@ -46,7 +46,7 @@ namespace musik { namespace core { namespace db { namespace local {
public: public:
GetPlaylistQuery( GetPlaylistQuery(
musik::core::ILibraryPtr library, musik::core::ILibraryPtr library,
uint64_t playlistId); int64_t playlistId);
virtual ~GetPlaylistQuery(); virtual ~GetPlaylistQuery();
@ -63,7 +63,7 @@ namespace musik { namespace core { namespace db { namespace local {
musik::core::ILibraryPtr library; musik::core::ILibraryPtr library;
Result result; Result result;
Headers headers; Headers headers;
uint64_t playlistId; int64_t playlistId;
size_t hash; size_t hash;
}; };

View File

@ -63,7 +63,7 @@ std::shared_ptr<SavePlaylistQuery> SavePlaylistQuery::Save(
} }
std::shared_ptr<SavePlaylistQuery> SavePlaylistQuery::Replace( std::shared_ptr<SavePlaylistQuery> SavePlaylistQuery::Replace(
const uint64_t playlistId, const int64_t playlistId,
std::shared_ptr<musik::core::TrackList> tracks) std::shared_ptr<musik::core::TrackList> tracks)
{ {
return std::shared_ptr<SavePlaylistQuery>( return std::shared_ptr<SavePlaylistQuery>(
@ -71,7 +71,7 @@ std::shared_ptr<SavePlaylistQuery> SavePlaylistQuery::Replace(
} }
std::shared_ptr<SavePlaylistQuery> SavePlaylistQuery::Rename( std::shared_ptr<SavePlaylistQuery> SavePlaylistQuery::Rename(
const uint64_t playlistId, const int64_t playlistId,
const std::string& playlistName) const std::string& playlistName)
{ {
return std::shared_ptr<SavePlaylistQuery>( return std::shared_ptr<SavePlaylistQuery>(
@ -88,7 +88,7 @@ SavePlaylistQuery::SavePlaylistQuery(
} }
SavePlaylistQuery::SavePlaylistQuery( SavePlaylistQuery::SavePlaylistQuery(
const uint64_t playlistId, const int64_t playlistId,
std::shared_ptr<musik::core::TrackList> tracks) std::shared_ptr<musik::core::TrackList> tracks)
{ {
this->playlistId = playlistId; this->playlistId = playlistId;
@ -96,7 +96,7 @@ SavePlaylistQuery::SavePlaylistQuery(
} }
SavePlaylistQuery::SavePlaylistQuery( SavePlaylistQuery::SavePlaylistQuery(
const uint64_t playlistId, const int64_t playlistId,
const std::string& playlistName) const std::string& playlistName)
{ {
this->playlistId = playlistId; this->playlistId = playlistId;
@ -106,7 +106,7 @@ SavePlaylistQuery::SavePlaylistQuery(
SavePlaylistQuery::~SavePlaylistQuery() { SavePlaylistQuery::~SavePlaylistQuery() {
} }
bool SavePlaylistQuery::AddTracksToPlaylist(musik::core::db::Connection &db, uint64_t playlistId) { bool SavePlaylistQuery::AddTracksToPlaylist(musik::core::db::Connection &db, int64_t playlistId) {
Statement insertTrack(INSERT_PLAYLIST_TRACK_QUERY.c_str(), db); Statement insertTrack(INSERT_PLAYLIST_TRACK_QUERY.c_str(), db);
TrackPtr track; TrackPtr track;
@ -116,7 +116,7 @@ bool SavePlaylistQuery::AddTracksToPlaylist(musik::core::db::Connection &db, uin
insertTrack.Reset(); insertTrack.Reset();
insertTrack.BindText(0, track->GetValue("external_id")); insertTrack.BindText(0, track->GetValue("external_id"));
insertTrack.BindText(1, track->GetValue("source_id")); insertTrack.BindText(1, track->GetValue("source_id"));
insertTrack.BindUint64(2, playlistId); insertTrack.BindInt64(2, playlistId);
insertTrack.BindInt32(3, (int) i); insertTrack.BindInt32(3, (int) i);
if (insertTrack.Step() == db::Error) { if (insertTrack.Step() == db::Error) {
@ -139,7 +139,7 @@ bool SavePlaylistQuery::CreatePlaylist(musik::core::db::Connection &db) {
return false; return false;
} }
uint64_t playlistId = db.LastInsertedId(); int64_t playlistId = db.LastInsertedId();
/* add tracks to playlist */ /* add tracks to playlist */
if (!this->AddTracksToPlaylist(db, playlistId)) { if (!this->AddTracksToPlaylist(db, playlistId)) {
@ -153,7 +153,7 @@ bool SavePlaylistQuery::CreatePlaylist(musik::core::db::Connection &db) {
bool SavePlaylistQuery::RenamePlaylist(musik::core::db::Connection &db) { bool SavePlaylistQuery::RenamePlaylist(musik::core::db::Connection &db) {
Statement renamePlaylist(RENAME_PLAYLIST_QUERY.c_str(), db); Statement renamePlaylist(RENAME_PLAYLIST_QUERY.c_str(), db);
renamePlaylist.BindText(0, this->playlistName); renamePlaylist.BindText(0, this->playlistName);
renamePlaylist.BindUint64(1, this->playlistId); renamePlaylist.BindInt64(1, this->playlistId);
return (renamePlaylist.Step() != db::Error); return (renamePlaylist.Step() != db::Error);
} }
@ -162,7 +162,7 @@ bool SavePlaylistQuery::ReplacePlaylist(musik::core::db::Connection &db) {
/* delete existing tracks, we'll replace 'em */ /* delete existing tracks, we'll replace 'em */
Statement createPlaylist(DELETE_PLAYLIST_TRACKS_QUERY.c_str(), db); Statement createPlaylist(DELETE_PLAYLIST_TRACKS_QUERY.c_str(), db);
createPlaylist.BindUint64(0, this->playlistId); createPlaylist.BindInt64(0, this->playlistId);
if (createPlaylist.Step() == db::Error) { if (createPlaylist.Step() == db::Error) {
transaction.Cancel(); transaction.Cancel();

View File

@ -48,11 +48,11 @@ namespace musik { namespace core { namespace db { namespace local {
std::shared_ptr<musik::core::TrackList> tracks); std::shared_ptr<musik::core::TrackList> tracks);
static std::shared_ptr<SavePlaylistQuery> Replace( static std::shared_ptr<SavePlaylistQuery> Replace(
const uint64_t playlistId, const int64_t playlistId,
std::shared_ptr<musik::core::TrackList> tracks); std::shared_ptr<musik::core::TrackList> tracks);
static std::shared_ptr<SavePlaylistQuery> Rename( static std::shared_ptr<SavePlaylistQuery> Rename(
const uint64_t playlistId, const int64_t playlistId,
const std::string& playlistName); const std::string& playlistName);
virtual std::string Name() { return "SavePlaylistQuery"; } virtual std::string Name() { return "SavePlaylistQuery"; }
@ -68,20 +68,20 @@ namespace musik { namespace core { namespace db { namespace local {
std::shared_ptr<musik::core::TrackList> tracks); std::shared_ptr<musik::core::TrackList> tracks);
SavePlaylistQuery( SavePlaylistQuery(
const uint64_t playlistId, const int64_t playlistId,
std::shared_ptr<musik::core::TrackList> tracks); std::shared_ptr<musik::core::TrackList> tracks);
SavePlaylistQuery( SavePlaylistQuery(
const uint64_t playlistId, const int64_t playlistId,
const std::string& newName); const std::string& newName);
bool CreatePlaylist(musik::core::db::Connection &db); bool CreatePlaylist(musik::core::db::Connection &db);
bool RenamePlaylist(musik::core::db::Connection &db); bool RenamePlaylist(musik::core::db::Connection &db);
bool ReplacePlaylist(musik::core::db::Connection &db); bool ReplacePlaylist(musik::core::db::Connection &db);
bool AddTracksToPlaylist(musik::core::db::Connection &db, uint64_t playlistId); bool AddTracksToPlaylist(musik::core::db::Connection &db, int64_t playlistId);
std::string playlistName; std::string playlistName;
uint64_t playlistId; int64_t playlistId;
std::shared_ptr<musik::core::TrackList> tracks; std::shared_ptr<musik::core::TrackList> tracks;
}; };

View File

@ -125,7 +125,7 @@ bool SearchTrackListQuery::OnRun(Connection& db) {
} }
while (trackQuery.Step() == Row) { while (trackQuery.Step() == Row) {
uint64_t id = trackQuery.ColumnUint64(0); int64_t id = trackQuery.ColumnInt64(0);
std::string album = trackQuery.ColumnText(1); std::string album = trackQuery.ColumnText(1);
if (!album.size()) { if (!album.size()) {

View File

@ -97,11 +97,11 @@ namespace musik { namespace core { namespace db { namespace local {
return this->wrapped->GetRetainedTrack(index); return this->wrapped->GetRetainedTrack(index);
} }
virtual uint64_t GetId(size_t index) const { virtual int64_t GetId(size_t index) const {
return this->wrapped->GetId(index); return this->wrapped->GetId(index);
} }
virtual int IndexOf(uint64_t id) const { virtual int IndexOf(int64_t id) const {
return this->wrapped->IndexOf(id); return this->wrapped->IndexOf(id);
} }

View File

@ -70,7 +70,7 @@ bool TrackMetadataQuery::OnRun(Connection& db) {
Statement trackQuery(query.c_str(), db); Statement trackQuery(query.c_str(), db);
if (queryById) { if (queryById) {
trackQuery.BindUint64(0, (uint64_t) this->result->GetId()); trackQuery.BindInt64(0, (int64_t) this->result->GetId());
} }
else { else {
const std::string& externalId = this->result->GetValue("external_id"); const std::string& externalId = this->result->GetValue("external_id");

View File

@ -65,7 +65,7 @@ void IndexerTrack::ResetIdCache() {
metadataIdCache.clear(); metadataIdCache.clear();
} }
IndexerTrack::IndexerTrack(uint64_t id) IndexerTrack::IndexerTrack(int64_t id)
: internalMetadata(new IndexerTrack::MetadataWithThumbnail()) : internalMetadata(new IndexerTrack::MetadataWithThumbnail())
, id(id) , id(id)
{ {
@ -87,17 +87,6 @@ std::string IndexerTrack::GetValue(const char* metakey) {
return ""; return "";
} }
uint64_t IndexerTrack::GetUint64(const char* key, uint64_t defaultValue) {
try {
std::string value = GetValue(key);
if (value.size()) {
return std::stoull(GetValue(key));
}
} catch (...) {
}
return defaultValue;
}
long long IndexerTrack::GetInt64(const char* key, long long defaultValue) { long long IndexerTrack::GetInt64(const char* key, long long defaultValue) {
try { try {
std::string value = GetValue(key); std::string value = GetValue(key);
@ -109,17 +98,6 @@ long long IndexerTrack::GetInt64(const char* key, long long defaultValue) {
return defaultValue; return defaultValue;
} }
unsigned int IndexerTrack::GetUint32(const char* key, unsigned long defaultValue) {
try {
std::string value = GetValue(key);
if (value.size()) {
return std::stoul(GetValue(key));
}
} catch (...) {
}
return defaultValue;
}
int IndexerTrack::GetInt32(const char* key, unsigned int defaultValue) { int IndexerTrack::GetInt32(const char* key, unsigned int defaultValue) {
try { try {
std::string value = GetValue(key); std::string value = GetValue(key);
@ -197,7 +175,7 @@ Track::MetadataIteratorRange IndexerTrack::GetAllValues() {
return Track::MetadataIteratorRange(); return Track::MetadataIteratorRange();
} }
uint64_t IndexerTrack::GetId() { int64_t IndexerTrack::GetId() {
return this->id; return this->id;
} }
@ -230,7 +208,7 @@ bool IndexerTrack::NeedsToBeIndexed(
bool fileDifferent = true; bool fileDifferent = true;
if (stmt.Step() == db::Row) { if (stmt.Step() == db::Row) {
this->id = stmt.ColumnUint64(0); this->id = stmt.ColumnInt64(0);
int dbFileSize = stmt.ColumnInt32(2); int dbFileSize = stmt.ColumnInt32(2);
int dbFileTime = stmt.ColumnInt32(3); int dbFileTime = stmt.ColumnInt32(3);
@ -245,12 +223,12 @@ bool IndexerTrack::NeedsToBeIndexed(
return true; return true;
} }
static uint64_t writeToTracksTable( static int64_t writeToTracksTable(
db::Connection &dbConnection, db::Connection &dbConnection,
IndexerTrack& track) IndexerTrack& track)
{ {
std::string externalId = track.GetValue("external_id"); std::string externalId = track.GetValue("external_id");
uint64_t id = track.GetId(); int64_t id = track.GetId();
if (externalId.size() == 0) { if (externalId.size() == 0) {
return 0; return 0;
@ -267,7 +245,7 @@ static uint64_t writeToTracksTable(
stmt.BindInt32(0, sourceId); stmt.BindInt32(0, sourceId);
stmt.BindText(1, externalId); stmt.BindText(1, externalId);
if (stmt.Step() == db::Row) { if (stmt.Step() == db::Row) {
track.SetId(stmt.ColumnUint64(0)); track.SetId(stmt.ColumnInt64(0));
} }
} }
else { else {
@ -276,7 +254,7 @@ static uint64_t writeToTracksTable(
db::Statement stmt("SELECT id, external_id FROM tracks WHERE filename=?", dbConnection); db::Statement stmt("SELECT id, external_id FROM tracks WHERE filename=?", dbConnection);
stmt.BindText(0, track.GetValue("filename")); stmt.BindText(0, track.GetValue("filename"));
if (stmt.Step() == db::Row) { if (stmt.Step() == db::Row) {
id = stmt.ColumnUint64(0); id = stmt.ColumnInt64(0);
track.SetId(id); track.SetId(id);
track.SetValue("external_id", stmt.ColumnText(1)); track.SetValue("external_id", stmt.ColumnText(1));
} }
@ -311,11 +289,11 @@ static uint64_t writeToTracksTable(
stmt.BindText(6, track.GetValue("title")); stmt.BindText(6, track.GetValue("title"));
stmt.BindText(7, track.GetValue("filename")); stmt.BindText(7, track.GetValue("filename"));
stmt.BindInt32(8, track.GetInt32("filetime")); stmt.BindInt32(8, track.GetInt32("filetime"));
stmt.BindUint64(9, track.GetInt64("path_id")); stmt.BindInt64(9, track.GetInt64("path_id"));
stmt.BindText(10, track.GetValue("external_id")); stmt.BindText(10, track.GetValue("external_id"));
if (id != 0) { if (id != 0) {
stmt.BindUint64(11, id); stmt.BindInt64(11, id);
} }
if (stmt.Step() == db::Done) { if (stmt.Step() == db::Done) {
@ -330,11 +308,11 @@ static uint64_t writeToTracksTable(
static void removeRelation( static void removeRelation(
db::Connection& connection, db::Connection& connection,
const std::string& field, const std::string& field,
uint64_t trackId) int64_t trackId)
{ {
std::string query = boost::str(boost::format("DELETE FROM %1% WHERE track_id=?") % field); std::string query = boost::str(boost::format("DELETE FROM %1% WHERE track_id=?") % field);
db::Statement stmt(query.c_str(), connection); db::Statement stmt(query.c_str(), connection);
stmt.BindUint64(0, trackId); stmt.BindInt64(0, trackId);
stmt.Step(); stmt.Step();
} }
@ -360,24 +338,24 @@ static void removeKnownFields(Track::MetadataMap& metadata) {
metadata.erase("visible"); metadata.erase("visible");
} }
uint64_t IndexerTrack::SaveThumbnail(db::Connection& connection, const std::string& libraryDirectory) { int64_t IndexerTrack::SaveThumbnail(db::Connection& connection, const std::string& libraryDirectory) {
uint64_t thumbnailId = 0; int64_t thumbnailId = 0;
if (this->internalMetadata->thumbnailData) { if (this->internalMetadata->thumbnailData) {
uint64_t sum = Checksum(this->internalMetadata->thumbnailData, this->internalMetadata->thumbnailSize); int64_t sum = Checksum(this->internalMetadata->thumbnailData, this->internalMetadata->thumbnailSize);
db::Statement thumbs("SELECT id FROM thumbnails WHERE filesize=? AND checksum=?", connection); db::Statement thumbs("SELECT id FROM thumbnails WHERE filesize=? AND checksum=?", connection);
thumbs.BindInt32(0, this->internalMetadata->thumbnailSize); thumbs.BindInt32(0, this->internalMetadata->thumbnailSize);
thumbs.BindUint64(1, sum); thumbs.BindInt64(1, sum);
if (thumbs.Step() == db::Row) { if (thumbs.Step() == db::Row) {
thumbnailId = thumbs.ColumnUint64(0); /* thumbnail already exists */ thumbnailId = thumbs.ColumnInt64(0); /* thumbnail already exists */
} }
if (thumbnailId == 0) { /* doesn't exist yet, let's insert the record and write the file */ if (thumbnailId == 0) { /* doesn't exist yet, let's insert the record and write the file */
db::Statement insertThumb("INSERT INTO thumbnails (filesize,checksum) VALUES (?,?)", connection); db::Statement insertThumb("INSERT INTO thumbnails (filesize,checksum) VALUES (?,?)", connection);
insertThumb.BindInt32(0, this->internalMetadata->thumbnailSize); insertThumb.BindInt32(0, this->internalMetadata->thumbnailSize);
insertThumb.BindUint64(1, sum); insertThumb.BindInt64(1, sum);
if (insertThumb.Step() == db::Done) { if (insertThumb.Step() == db::Done) {
thumbnailId = connection.LastInsertedId(); thumbnailId = connection.LastInsertedId();
@ -415,7 +393,7 @@ void IndexerTrack::ProcessNonStandardMetadata(db::Connection& connection) {
MetadataMap::const_iterator it = unknownFields.begin(); MetadataMap::const_iterator it = unknownFields.begin();
for ( ; it != unknownFields.end(); ++it){ for ( ; it != unknownFields.end(); ++it){
uint64_t keyId = 0; int64_t keyId = 0;
std::string key; std::string key;
/* lookup the ID for the key; insert if it doesn't exist.. */ /* lookup the ID for the key; insert if it doesn't exist.. */
@ -425,7 +403,7 @@ void IndexerTrack::ProcessNonStandardMetadata(db::Connection& connection) {
else { else {
selectMetaKey.BindText(0, it->first); selectMetaKey.BindText(0, it->first);
if (selectMetaKey.Step() == db::Row) { if (selectMetaKey.Step() == db::Row) {
keyId = selectMetaKey.ColumnUint64(0); keyId = selectMetaKey.ColumnInt64(0);
} }
else { else {
insertMetaKey.BindText(0, it->first); insertMetaKey.BindText(0, it->first);
@ -446,20 +424,20 @@ void IndexerTrack::ProcessNonStandardMetadata(db::Connection& connection) {
/* see if we already have the value as a normalized row in our table. /* see if we already have the value as a normalized row in our table.
if we don't, insert it. */ if we don't, insert it. */
uint64_t valueId = 0; int64_t valueId = 0;
if (metadataIdCache.find("metaValue-" + it->second) != metadataIdCache.end()) { if (metadataIdCache.find("metaValue-" + it->second) != metadataIdCache.end()) {
valueId = metadataIdCache["metaValue-" + it->second]; valueId = metadataIdCache["metaValue-" + it->second];
} }
else { else {
selectMetaValue.BindUint64(0, keyId); selectMetaValue.BindInt64(0, keyId);
selectMetaValue.BindText(1, it->second); selectMetaValue.BindText(1, it->second);
if (selectMetaValue.Step() == db::Row) { if (selectMetaValue.Step() == db::Row) {
valueId = selectMetaValue.ColumnUint64(0); valueId = selectMetaValue.ColumnInt64(0);
} }
else { else {
insertMetaValue.BindUint64(0, keyId); insertMetaValue.BindInt64(0, keyId);
insertMetaValue.BindText(1, it->second); insertMetaValue.BindText(1, it->second);
if (insertMetaValue.Step() == db::Done) { if (insertMetaValue.Step() == db::Done) {
@ -476,8 +454,8 @@ void IndexerTrack::ProcessNonStandardMetadata(db::Connection& connection) {
/* now that we have a keyId and a valueId, create the relationship */ /* now that we have a keyId and a valueId, create the relationship */
if (valueId != 0) { if (valueId != 0) {
insertTrackMeta.BindUint64(0, this->id); insertTrackMeta.BindInt64(0, this->id);
insertTrackMeta.BindUint64(1, valueId); insertTrackMeta.BindInt64(1, valueId);
insertTrackMeta.Step(); insertTrackMeta.Step();
insertTrackMeta.Reset(); insertTrackMeta.Reset();
} }
@ -496,7 +474,7 @@ static size_t hash32(const char* str) {
return h; return h;
} }
uint64_t IndexerTrack::SaveAlbum(db::Connection& dbConnection) { int64_t IndexerTrack::SaveAlbum(db::Connection& dbConnection) {
std::string album = this->GetValue("album"); std::string album = this->GetValue("album");
std::string value = album + "-" + this->GetValue("album_artist"); std::string value = album + "-" + this->GetValue("album_artist");
@ -511,7 +489,7 @@ uint64_t IndexerTrack::SaveAlbum(db::Connection& dbConnection) {
else { else {
std::string insertStatement = "INSERT INTO albums (id, name) VALUES (?, ?)"; std::string insertStatement = "INSERT INTO albums (id, name) VALUES (?, ?)";
db::Statement insertValue(insertStatement.c_str(), dbConnection); db::Statement insertValue(insertStatement.c_str(), dbConnection);
insertValue.BindUint64(0, id); insertValue.BindInt64(0, id);
insertValue.BindText(1, album); insertValue.BindText(1, album);
if (insertValue.Step() == db::Done) { if (insertValue.Step() == db::Done) {
@ -522,12 +500,12 @@ uint64_t IndexerTrack::SaveAlbum(db::Connection& dbConnection) {
return id; return id;
} }
uint64_t IndexerTrack::SaveSingleValueField( int64_t IndexerTrack::SaveSingleValueField(
db::Connection& dbConnection, db::Connection& dbConnection,
const std::string& trackMetadataKeyName, const std::string& trackMetadataKeyName,
const std::string& fieldTableName) const std::string& fieldTableName)
{ {
uint64_t id = 0; int64_t id = 0;
std::string selectQuery = boost::str(boost::format( std::string selectQuery = boost::str(boost::format(
"SELECT id FROM %1% WHERE name=?") % fieldTableName); "SELECT id FROM %1% WHERE name=?") % fieldTableName);
@ -541,7 +519,7 @@ uint64_t IndexerTrack::SaveSingleValueField(
else { else {
stmt.BindText(0, value); stmt.BindText(0, value);
if (stmt.Step() == db::Row) { if (stmt.Step() == db::Row) {
id = stmt.ColumnUint64(0); id = stmt.ColumnInt64(0);
} }
else { else {
std::string insertStatement = boost::str(boost::format( std::string insertStatement = boost::str(boost::format(
@ -561,7 +539,7 @@ uint64_t IndexerTrack::SaveSingleValueField(
return id; return id;
} }
uint64_t IndexerTrack::SaveMultiValueField( int64_t IndexerTrack::SaveMultiValueField(
db::Connection& connection, db::Connection& connection,
const std::string& tracksTableColumnName, const std::string& tracksTableColumnName,
const std::string& fieldTableName, const std::string& fieldTableName,
@ -569,7 +547,7 @@ uint64_t IndexerTrack::SaveMultiValueField(
const std::string& junctionTableForeignKeyColumnName) const std::string& junctionTableForeignKeyColumnName)
{ {
std::string aggregatedValue; std::string aggregatedValue;
uint64_t fieldId = 0; int64_t fieldId = 0;
int count = 0; int count = 0;
std::set<std::string> processed; /* for deduping */ std::set<std::string> processed; /* for deduping */
@ -612,7 +590,7 @@ uint64_t IndexerTrack::SaveMultiValueField(
return fieldId; return fieldId;
} }
uint64_t IndexerTrack::SaveGenre(db::Connection& dbConnection) { int64_t IndexerTrack::SaveGenre(db::Connection& dbConnection) {
return this->SaveMultiValueField( return this->SaveMultiValueField(
dbConnection, dbConnection,
GENRE_TRACK_COLUMN_NAME, GENRE_TRACK_COLUMN_NAME,
@ -621,7 +599,7 @@ uint64_t IndexerTrack::SaveGenre(db::Connection& dbConnection) {
GENRE_TRACK_FOREIGN_KEY); GENRE_TRACK_FOREIGN_KEY);
} }
uint64_t IndexerTrack::SaveArtist(db::Connection& dbConnection) { int64_t IndexerTrack::SaveArtist(db::Connection& dbConnection) {
return this->SaveMultiValueField( return this->SaveMultiValueField(
dbConnection, dbConnection,
ARTIST_TRACK_COLUMN_NAME, ARTIST_TRACK_COLUMN_NAME,
@ -649,11 +627,11 @@ bool IndexerTrack::Save(db::Connection &dbConnection, std::string libraryDirecto
this->id = writeToTracksTable(dbConnection, *this); this->id = writeToTracksTable(dbConnection, *this);
uint64_t albumId = this->SaveAlbum(dbConnection); int64_t albumId = this->SaveAlbum(dbConnection);
uint64_t genreId = this->SaveGenre(dbConnection); int64_t genreId = this->SaveGenre(dbConnection);
uint64_t artistId = this->SaveArtist(dbConnection); int64_t artistId = this->SaveArtist(dbConnection);
uint64_t albumArtistId = this->SaveSingleValueField(dbConnection, "album_artist", "artists"); int64_t albumArtistId = this->SaveSingleValueField(dbConnection, "album_artist", "artists");
uint64_t thumbnailId = this->SaveThumbnail(dbConnection, libraryDirectory); int64_t thumbnailId = this->SaveThumbnail(dbConnection, libraryDirectory);
/* ensure we have a correct source id */ /* ensure we have a correct source id */
int sourceId = 0; int sourceId = 0;
@ -676,13 +654,13 @@ bool IndexerTrack::Save(db::Connection &dbConnection, std::string libraryDirecto
"SET album_id=?, visual_genre_id=?, visual_artist_id=?, album_artist_id=?, thumbnail_id=?, source_id=? " \ "SET album_id=?, visual_genre_id=?, visual_artist_id=?, album_artist_id=?, thumbnail_id=?, source_id=? " \
"WHERE id=?", dbConnection); "WHERE id=?", dbConnection);
stmt.BindUint64(0, albumId); stmt.BindInt64(0, albumId);
stmt.BindUint64(1, genreId); stmt.BindInt64(1, genreId);
stmt.BindUint64(2, artistId); stmt.BindInt64(2, artistId);
stmt.BindUint64(3, albumArtistId); stmt.BindInt64(3, albumArtistId);
stmt.BindUint64(4, thumbnailId); stmt.BindInt64(4, thumbnailId);
stmt.BindUint64(5, sourceId); stmt.BindInt64(5, sourceId);
stmt.BindUint64(6, this->id); stmt.BindInt64(6, this->id);
stmt.Step(); stmt.Step();
} }
@ -691,7 +669,7 @@ bool IndexerTrack::Save(db::Connection &dbConnection, std::string libraryDirecto
return true; return true;
} }
uint64_t IndexerTrack::SaveNormalizedFieldValue( int64_t IndexerTrack::SaveNormalizedFieldValue(
db::Connection &dbConnection, db::Connection &dbConnection,
const std::string& tableName, const std::string& tableName,
const std::string& fieldValue, const std::string& fieldValue,
@ -699,7 +677,7 @@ uint64_t IndexerTrack::SaveNormalizedFieldValue(
const std::string& relationJunctionTableName, const std::string& relationJunctionTableName,
const std::string& relationJunctionTableColumn) const std::string& relationJunctionTableColumn)
{ {
uint64_t fieldId = 0; int64_t fieldId = 0;
/* find by value */ /* find by value */
@ -713,7 +691,7 @@ uint64_t IndexerTrack::SaveNormalizedFieldValue(
stmt.BindText(0, fieldValue); stmt.BindText(0, fieldValue);
if (stmt.Step() == db::Row) { if (stmt.Step() == db::Row) {
fieldId = stmt.ColumnUint64(0); fieldId = stmt.ColumnInt64(0);
metadataIdCache[tableName + "-" + fieldValue] = fieldId; metadataIdCache[tableName + "-" + fieldValue] = fieldId;
} }
} }
@ -743,8 +721,8 @@ uint64_t IndexerTrack::SaveNormalizedFieldValue(
% relationJunctionTableName % relationJunctionTableColumn); % relationJunctionTableName % relationJunctionTableColumn);
db::Statement stmt(query.c_str(), dbConnection); db::Statement stmt(query.c_str(), dbConnection);
stmt.BindUint64(0, this->id); stmt.BindInt64(0, this->id);
stmt.BindUint64(1, fieldId); stmt.BindInt64(1, fieldId);
stmt.Step(); stmt.Step();
} }

View File

@ -42,7 +42,7 @@ namespace musik { namespace core {
class IndexerTrack : public Track { class IndexerTrack : public Track {
public: public:
IndexerTrack(uint64_t id); IndexerTrack(int64_t id);
virtual ~IndexerTrack(void); virtual ~IndexerTrack(void);
/* IWritableTrack */ /* IWritableTrack */
@ -53,9 +53,7 @@ namespace musik { namespace core {
/* ITrack */ /* ITrack */
virtual std::string GetValue(const char* metakey); virtual std::string GetValue(const char* metakey);
virtual int GetValue(const char* key, char* dst, int size); virtual int GetValue(const char* key, char* dst, int size);
virtual uint64_t GetUint64(const char* key, uint64_t defaultValue = 0ULL);
virtual long long GetInt64(const char* key, long long defaultValue = 0LL); virtual long long GetInt64(const char* key, long long defaultValue = 0LL);
virtual unsigned int GetUint32(const char* key, unsigned long defaultValue = 0);
virtual int GetInt32(const char* key, unsigned int defaultValue = 0); virtual int GetInt32(const char* key, unsigned int defaultValue = 0);
virtual double GetDouble(const char* key, double defaultValue = 0.0f); virtual double GetDouble(const char* key, double defaultValue = 0.0f);
@ -66,8 +64,8 @@ namespace musik { namespace core {
virtual MetadataIteratorRange GetAllValues(); virtual MetadataIteratorRange GetAllValues();
virtual TrackPtr Copy(); virtual TrackPtr Copy();
virtual uint64_t GetId(); virtual int64_t GetId();
virtual void SetId(uint64_t id) { this->id = id; } virtual void SetId(int64_t id) { this->id = id; }
bool NeedsToBeIndexed( bool NeedsToBeIndexed(
const boost::filesystem::path &file, const boost::filesystem::path &file,
@ -80,7 +78,7 @@ namespace musik { namespace core {
static void ResetIdCache(); static void ResetIdCache();
private: private:
uint64_t id; int64_t id;
private: private:
class MetadataWithThumbnail { class MetadataWithThumbnail {
@ -95,29 +93,29 @@ namespace musik { namespace core {
MetadataWithThumbnail *internalMetadata; MetadataWithThumbnail *internalMetadata;
uint64_t SaveThumbnail( int64_t SaveThumbnail(
db::Connection& connection, db::Connection& connection,
const std::string& libraryDirectory); const std::string& libraryDirectory);
uint64_t SaveGenre(db::Connection& connection); int64_t SaveGenre(db::Connection& connection);
uint64_t SaveArtist(db::Connection& connection); int64_t SaveArtist(db::Connection& connection);
uint64_t SaveAlbum(db::Connection& connection); int64_t SaveAlbum(db::Connection& connection);
uint64_t SaveSingleValueField( int64_t SaveSingleValueField(
db::Connection& connection, db::Connection& connection,
const std::string& trackMetadataKeyName, const std::string& trackMetadataKeyName,
const std::string& fieldTableName); const std::string& fieldTableName);
uint64_t SaveMultiValueField( int64_t SaveMultiValueField(
db::Connection& connection, db::Connection& connection,
const std::string& tracksTableColumnName, const std::string& tracksTableColumnName,
const std::string& fieldTableName, const std::string& fieldTableName,
const std::string& junctionTableName, const std::string& junctionTableName,
const std::string& junctionTableForeignKeyColumnName); const std::string& junctionTableForeignKeyColumnName);
uint64_t SaveNormalizedFieldValue( int64_t SaveNormalizedFieldValue(
db::Connection& dbConnection, db::Connection& dbConnection,
const std::string& tableName, const std::string& tableName,
const std::string& fieldValue, const std::string& fieldValue,

View File

@ -49,12 +49,12 @@ LibraryTrack::LibraryTrack()
, libraryId(0) { , libraryId(0) {
} }
LibraryTrack::LibraryTrack(uint64_t id, int libraryId) LibraryTrack::LibraryTrack(int64_t id, int libraryId)
: id(id) : id(id)
, libraryId(libraryId) { , libraryId(libraryId) {
} }
LibraryTrack::LibraryTrack(uint64_t id, musik::core::ILibraryPtr library) LibraryTrack::LibraryTrack(int64_t id, musik::core::ILibraryPtr library)
: id(id) : id(id)
, libraryId(library->Id()) { , libraryId(library->Id()) {
} }
@ -71,18 +71,6 @@ std::string LibraryTrack::GetValue(const char* metakey) {
return ""; return "";
} }
uint64_t LibraryTrack::GetUint64(const char* key, uint64_t defaultValue) {
try {
std::string value = GetValue(key);
if (value.size()) {
return std::stoull(GetValue(key));
}
}
catch (...) {
}
return defaultValue;
}
long long LibraryTrack::GetInt64(const char* key, long long defaultValue) { long long LibraryTrack::GetInt64(const char* key, long long defaultValue) {
try { try {
std::string value = GetValue(key); std::string value = GetValue(key);
@ -95,18 +83,6 @@ long long LibraryTrack::GetInt64(const char* key, long long defaultValue) {
return defaultValue; return defaultValue;
} }
unsigned int LibraryTrack::GetUint32(const char* key, unsigned long defaultValue) {
try {
std::string value = GetValue(key);
if (value.size()) {
return std::stoul(GetValue(key));
}
}
catch (...) {
}
return defaultValue;
}
int LibraryTrack::GetInt32(const char* key, unsigned int defaultValue) { int LibraryTrack::GetInt32(const char* key, unsigned int defaultValue) {
try { try {
std::string value = GetValue(key); std::string value = GetValue(key);
@ -174,7 +150,7 @@ Track::MetadataIteratorRange LibraryTrack::GetAllValues() {
return Track::MetadataIteratorRange(); return Track::MetadataIteratorRange();
} }
uint64_t LibraryTrack::GetId() { int64_t LibraryTrack::GetId() {
return this->id; return this->id;
} }
@ -208,7 +184,7 @@ bool LibraryTrack::Load(Track *target, db::Connection &db) {
return false; return false;
} }
target->SetId(idFromFn.ColumnUint64(0)); target->SetId(idFromFn.ColumnInt64(0));
} }
db::Statement genresQuery( db::Statement genresQuery(
@ -234,7 +210,7 @@ bool LibraryTrack::Load(Track *target, db::Connection &db) {
"FROM tracks t, paths p, albums al " \ "FROM tracks t, paths p, albums al " \
"WHERE t.id=? AND t.album_id=al.id", db); "WHERE t.id=? AND t.album_id=al.id", db);
trackQuery.BindUint64(0, (uint64_t) target->GetId()); trackQuery.BindInt64(0, (int64_t) target->GetId());
if (trackQuery.Step() == db::Row) { if (trackQuery.Step() == db::Row) {
target->SetValue("track", trackQuery.ColumnText(0)); target->SetValue("track", trackQuery.ColumnText(0));
target->SetValue("disc", trackQuery.ColumnText(1)); target->SetValue("disc", trackQuery.ColumnText(1));
@ -252,17 +228,17 @@ bool LibraryTrack::Load(Track *target, db::Connection &db) {
target->SetValue("album_artist_id", trackQuery.ColumnText(13)); target->SetValue("album_artist_id", trackQuery.ColumnText(13));
target->SetValue("album_id", trackQuery.ColumnText(14)); target->SetValue("album_id", trackQuery.ColumnText(14));
genresQuery.BindUint64(0, (uint64_t) target->GetId()); genresQuery.BindInt64(0, (int64_t) target->GetId());
while (genresQuery.Step() == db::Row) { while (genresQuery.Step() == db::Row) {
target->SetValue("genre", genresQuery.ColumnText(0)); target->SetValue("genre", genresQuery.ColumnText(0));
} }
artistsQuery.BindUint64(0, (uint64_t) target->GetId()); artistsQuery.BindInt64(0, (int64_t) target->GetId());
while (artistsQuery.Step() == db::Row) { while (artistsQuery.Step() == db::Row) {
target->SetValue("artist", artistsQuery.ColumnText(0)); target->SetValue("artist", artistsQuery.ColumnText(0));
} }
allMetadataQuery.BindUint64(0, (uint64_t) target->GetId()); allMetadataQuery.BindInt64(0, (int64_t) target->GetId());
while (allMetadataQuery.Step() == db::Row) { while (allMetadataQuery.Step() == db::Row) {
target->SetValue(allMetadataQuery.ColumnText(1), allMetadataQuery.ColumnText(0)); target->SetValue(allMetadataQuery.ColumnText(1), allMetadataQuery.ColumnText(0));
} }

View File

@ -45,14 +45,14 @@ namespace musik { namespace core {
class LibraryTrack : public Track { class LibraryTrack : public Track {
public: public:
LibraryTrack(); LibraryTrack();
LibraryTrack(uint64_t id, int libraryId); LibraryTrack(int64_t id, int libraryId);
LibraryTrack(uint64_t id, musik::core::ILibraryPtr library); LibraryTrack(int64_t id, musik::core::ILibraryPtr library);
virtual ~LibraryTrack(); virtual ~LibraryTrack();
virtual int LibraryId(); virtual int LibraryId();
virtual uint64_t GetId(); virtual int64_t GetId();
virtual void SetId(uint64_t id) { this->id = id; } virtual void SetId(int64_t id) { this->id = id; }
virtual std::string GetValue(const char* metakey); virtual std::string GetValue(const char* metakey);
virtual std::string Uri(); virtual std::string Uri();
@ -63,9 +63,7 @@ namespace musik { namespace core {
virtual void SetThumbnail(const char *data, long size); virtual void SetThumbnail(const char *data, long size);
/* ITrack */ /* ITrack */
virtual uint64_t GetUint64(const char* key, uint64_t defaultValue = 0ULL);
virtual long long GetInt64(const char* key, long long defaultValue = 0LL); virtual long long GetInt64(const char* key, long long defaultValue = 0LL);
virtual unsigned int GetUint32(const char* key, unsigned long defaultValue = 0);
virtual int GetInt32(const char* key, unsigned int defaultValue = 0); virtual int GetInt32(const char* key, unsigned int defaultValue = 0);
virtual double GetDouble(const char* key, double defaultValue = 0.0f); virtual double GetDouble(const char* key, double defaultValue = 0.0f);
virtual int GetValue(const char* key, char* dst, int size); virtual int GetValue(const char* key, char* dst, int size);
@ -78,7 +76,7 @@ namespace musik { namespace core {
static bool Load(Track *target, db::Connection &db); static bool Load(Track *target, db::Connection &db);
private: private:
uint64_t id; int64_t id;
int libraryId; int libraryId;
struct LibraryData { struct LibraryData {

View File

@ -68,18 +68,10 @@ int RetainedTrack::Uri(char* dst, int size) {
return track->Uri(dst, size); return track->Uri(dst, size);
} }
uint64_t RetainedTrack::GetUint64(const char* key, uint64_t defaultValue) {
return track->GetUint64(key, defaultValue);
}
long long RetainedTrack::GetInt64(const char* key, long long defaultValue) { long long RetainedTrack::GetInt64(const char* key, long long defaultValue) {
return track->GetInt64(key, defaultValue); return track->GetInt64(key, defaultValue);
} }
unsigned int RetainedTrack::GetUint32(const char* key, unsigned long defaultValue) {
return track->GetUint32(key, defaultValue);
}
int RetainedTrack::GetInt32(const char* key, unsigned int defaultValue) { int RetainedTrack::GetInt32(const char* key, unsigned int defaultValue) {
return track->GetInt32(key, defaultValue); return track->GetInt32(key, defaultValue);
} }
@ -88,7 +80,7 @@ double RetainedTrack::GetDouble(const char* key, double defaultValue) {
return track->GetDouble(key, defaultValue); return track->GetDouble(key, defaultValue);
} }
uint64_t RetainedTrack::GetId() { int64_t RetainedTrack::GetId() {
return track->GetId(); return track->GetId();
} }

View File

@ -49,11 +49,9 @@ namespace musik { namespace core {
virtual void Retain(); virtual void Retain();
/* ITrack */ /* ITrack */
virtual uint64_t GetId(); virtual int64_t GetId();
virtual int GetValue(const char* key, char* dst, int size); virtual int GetValue(const char* key, char* dst, int size);
virtual uint64_t GetUint64(const char* key, uint64_t defaultValue = 0ULL);
virtual long long GetInt64(const char* key, long long defaultValue = 0LL); virtual long long GetInt64(const char* key, long long defaultValue = 0LL);
virtual unsigned int GetUint32(const char* key, unsigned long defaultValue = 0);
virtual int GetInt32(const char* key, unsigned int defaultValue = 0); virtual int GetInt32(const char* key, unsigned int defaultValue = 0);
virtual double GetDouble(const char* key, double defaultValue = 0.0f); virtual double GetDouble(const char* key, double defaultValue = 0.0f);
virtual int Uri(char* dst, int size); virtual int Uri(char* dst, int size);

View File

@ -42,7 +42,7 @@ using namespace musik::core;
Track::~Track() { Track::~Track() {
} }
uint64_t Track::GetId() { int64_t Track::GetId() {
return 0; return 0;
} }

View File

@ -57,8 +57,8 @@ namespace musik { namespace core {
virtual ~Track(); virtual ~Track();
virtual uint64_t GetId(); virtual int64_t GetId();
virtual void SetId(uint64_t id) = 0; virtual void SetId(int64_t id) = 0;
virtual musik::core::ILibraryPtr Library(); virtual musik::core::ILibraryPtr Library();
virtual int LibraryId(); virtual int LibraryId();
@ -73,9 +73,7 @@ namespace musik { namespace core {
/* ITrack */ /* ITrack */
virtual int GetValue(const char* key, char* dst, int size) = 0; virtual int GetValue(const char* key, char* dst, int size) = 0;
virtual uint64_t GetUint64(const char* key, uint64_t defaultValue = 0ULL) = 0;
virtual long long GetInt64(const char* key, long long defaultValue = 0LL) = 0; virtual long long GetInt64(const char* key, long long defaultValue = 0LL) = 0;
virtual unsigned int GetUint32(const char* key, unsigned long defaultValue = 0) = 0;
virtual int GetInt32(const char* key, unsigned int defaultValue = 0) = 0; virtual int GetInt32(const char* key, unsigned int defaultValue = 0) = 0;
virtual double GetDouble(const char* key, double defaultValue = 0.0f) = 0; virtual double GetDouble(const char* key, double defaultValue = 0.0f) = 0;
virtual int Uri(char* dst, int size) = 0; virtual int Uri(char* dst, int size) = 0;

View File

@ -65,11 +65,11 @@ size_t TrackList::Count() const {
return ids.size(); return ids.size();
} }
void TrackList::Add(const uint64_t id) { void TrackList::Add(const int64_t id) {
this->ids.push_back(id); this->ids.push_back(id);
} }
bool TrackList::Insert(uint64_t id, size_t index) { bool TrackList::Insert(int64_t id, size_t index) {
if (index < (int) this->ids.size()) { if (index < (int) this->ids.size()) {
this->ids.insert(this->ids.begin() + index, id); this->ids.insert(this->ids.begin() + index, id);
return true; return true;
@ -143,7 +143,7 @@ ITrack* TrackList::GetTrack(size_t index) const {
return this->Get(index).get(); return this->Get(index).get();
} }
uint64_t TrackList::GetId(size_t index) const { int64_t TrackList::GetId(size_t index) const {
return this->ids.at(index); return this->ids.at(index);
} }
@ -156,7 +156,7 @@ void TrackList::CopyFrom(const TrackList& from) {
std::back_inserter(this->ids)); std::back_inserter(this->ids));
} }
int TrackList::IndexOf(uint64_t id) const { int TrackList::IndexOf(int64_t id) const {
auto it = std::find(this->ids.begin(), this->ids.end(), id); auto it = std::find(this->ids.begin(), this->ids.end(), id);
return (it == this->ids.end()) ? -1 : it - this->ids.begin(); return (it == this->ids.end()) ? -1 : it - this->ids.begin();
} }
@ -179,7 +179,7 @@ void TrackList::Swap(TrackList& tl) {
std::swap(tl.ids, this->ids); std::swap(tl.ids, this->ids);
} }
TrackPtr TrackList::GetFromCache(uint64_t key) const { TrackPtr TrackList::GetFromCache(int64_t key) const {
auto it = this->cacheMap.find(key); auto it = this->cacheMap.find(key);
if (it != this->cacheMap.end()) { if (it != this->cacheMap.end()) {
this->cacheList.splice( /* promote to front */ this->cacheList.splice( /* promote to front */
@ -193,7 +193,7 @@ TrackPtr TrackList::GetFromCache(uint64_t key) const {
return TrackPtr(); return TrackPtr();
} }
void TrackList::AddToCache(uint64_t key, TrackPtr value) const { void TrackList::AddToCache(int64_t key, TrackPtr value) const {
auto it = this->cacheMap.find(key); auto it = this->cacheMap.find(key);
if (it != this->cacheMap.end()) { if (it != this->cacheMap.end()) {
cacheList.erase(it->second.second); cacheList.erase(it->second.second);

View File

@ -66,13 +66,13 @@ namespace musik { namespace core {
/* ITrackList */ /* ITrackList */
virtual size_t Count() const; virtual size_t Count() const;
virtual musik::core::sdk::IRetainedTrack* GetRetainedTrack(size_t index) const; virtual musik::core::sdk::IRetainedTrack* GetRetainedTrack(size_t index) const;
virtual uint64_t GetId(size_t index) const; virtual int64_t GetId(size_t index) const;
virtual int IndexOf(uint64_t id) const; virtual int IndexOf(int64_t id) const;
virtual musik::core::sdk::ITrack* GetTrack(size_t index) const; virtual musik::core::sdk::ITrack* GetTrack(size_t index) const;
/* ITrackListEditor */ /* ITrackListEditor */
virtual void Add(const uint64_t id); virtual void Add(const int64_t id);
virtual bool Insert(uint64_t id, size_t index); virtual bool Insert(int64_t id, size_t index);
virtual bool Swap(size_t index1, size_t index2); virtual bool Swap(size_t index1, size_t index2);
virtual bool Move(size_t from, size_t to); virtual bool Move(size_t from, size_t to);
virtual bool Delete(size_t index); virtual bool Delete(size_t index);
@ -86,18 +86,18 @@ namespace musik { namespace core {
void CopyFrom(const TrackList& from); void CopyFrom(const TrackList& from);
private: private:
typedef std::list<uint64_t> CacheList; typedef std::list<int64_t> CacheList;
typedef std::pair<TrackPtr, CacheList::iterator> CacheValue; typedef std::pair<TrackPtr, CacheList::iterator> CacheValue;
typedef std::unordered_map<uint64_t, CacheValue> CacheMap; typedef std::unordered_map<int64_t, CacheValue> CacheMap;
TrackPtr GetFromCache(uint64_t key) const; TrackPtr GetFromCache(int64_t key) const;
void AddToCache(uint64_t key, TrackPtr value) const; void AddToCache(int64_t key, TrackPtr value) const;
/* lru cache structures */ /* lru cache structures */
mutable CacheList cacheList; mutable CacheList cacheList;
mutable CacheMap cacheMap; mutable CacheMap cacheMap;
std::vector<uint64_t> ids; std::vector<int64_t> ids;
ILibraryPtr library; ILibraryPtr library;
}; };
} } } }

View File

@ -41,11 +41,9 @@ namespace musik { namespace core { namespace sdk {
class IMetadataMap { class IMetadataMap {
public: public:
virtual void Release() = 0; virtual void Release() = 0;
virtual uint64_t GetId() = 0; virtual int64_t GetId() = 0;
virtual int GetValue(const char* key, char* dst, int size) = 0; virtual int GetValue(const char* key, char* dst, int size) = 0;
virtual uint64_t GetUint64(const char* key, uint64_t defaultValue = 0ULL) = 0;
virtual long long GetInt64(const char* key, long long defaultValue = 0LL) = 0; virtual long long GetInt64(const char* key, long long defaultValue = 0LL) = 0;
virtual unsigned int GetUint32(const char* key, unsigned long defaultValue = 0) = 0;
virtual int GetInt32(const char* key, unsigned int defaultValue = 0) = 0; virtual int GetInt32(const char* key, unsigned int defaultValue = 0) = 0;
virtual double GetDouble(const char* key, double defaultValue = 0.0f) = 0; virtual double GetDouble(const char* key, double defaultValue = 0.0f) = 0;
virtual const char* GetDescription() = 0; virtual const char* GetDescription() = 0;

View File

@ -40,7 +40,7 @@ namespace musik { namespace core { namespace sdk {
class IMetadataValue { class IMetadataValue {
public: public:
virtual uint64_t GetId() = 0; virtual int64_t GetId() = 0;
virtual const char* GetValue() = 0; virtual const char* GetValue() = 0;
virtual int GetValue(char* dst, size_t size) = 0; virtual int GetValue(char* dst, size_t size) = 0;
}; };

View File

@ -48,13 +48,13 @@ namespace musik { namespace core { namespace sdk {
int limit = -1, int limit = -1,
int offset = 0) = 0; int offset = 0) = 0;
virtual IRetainedTrack* QueryTrackById(uint64_t trackId) = 0; virtual IRetainedTrack* QueryTrackById(int64_t trackId) = 0;
virtual IRetainedTrack* QueryTrackByExternalId(const char* externalId) = 0; virtual IRetainedTrack* QueryTrackByExternalId(const char* externalId) = 0;
virtual ITrackList* QueryTracksByCategory( virtual ITrackList* QueryTracksByCategory(
const char* categoryType, const char* categoryType,
uint64_t selectedId, int64_t selectedId,
const char* filter = "", const char* filter = "",
int limit = -1, int limit = -1,
int offset = 0) = 0; int offset = 0) = 0;
@ -67,7 +67,7 @@ namespace musik { namespace core { namespace sdk {
virtual IMetadataMapList* QueryAlbums( virtual IMetadataMapList* QueryAlbums(
const char* categoryIdName, const char* categoryIdName,
uint64_t categoryIdValue, int64_t categoryIdValue,
const char* filter = "") = 0; const char* filter = "") = 0;
}; };

View File

@ -40,11 +40,9 @@ namespace musik { namespace core { namespace sdk {
class ITrack { class ITrack {
public: public:
virtual uint64_t GetId() = 0; virtual int64_t GetId() = 0;
virtual int GetValue(const char* key, char* dst, int size) = 0; virtual int GetValue(const char* key, char* dst, int size) = 0;
virtual uint64_t GetUint64(const char* key, uint64_t defaultValue = 0ULL) = 0;
virtual long long GetInt64(const char* key, long long defaultValue = 0LL) = 0; virtual long long GetInt64(const char* key, long long defaultValue = 0LL) = 0;
virtual unsigned int GetUint32(const char* key, unsigned long defaultValue = 0) = 0;
virtual int GetInt32(const char* key, unsigned int defaultValue = 0) = 0; virtual int GetInt32(const char* key, unsigned int defaultValue = 0) = 0;
virtual double GetDouble(const char* key, double defaultValue = 0.0f) = 0; virtual double GetDouble(const char* key, double defaultValue = 0.0f) = 0;
virtual int Uri(char* dst, int size) = 0; virtual int Uri(char* dst, int size) = 0;

View File

@ -47,8 +47,8 @@ namespace musik {
virtual void Release() = 0; virtual void Release() = 0;
virtual size_t Count() const = 0; virtual size_t Count() const = 0;
virtual IRetainedTrack* GetRetainedTrack(size_t index) const = 0; virtual IRetainedTrack* GetRetainedTrack(size_t index) const = 0;
virtual uint64_t GetId(size_t index) const = 0; virtual int64_t GetId(size_t index) const = 0;
virtual int IndexOf(uint64_t id) const = 0; virtual int IndexOf(int64_t id) const = 0;
/* sdk v3 */ /* sdk v3 */
virtual ITrack* GetTrack(size_t index) const = 0; virtual ITrack* GetTrack(size_t index) const = 0;

View File

@ -42,11 +42,11 @@ namespace musik {
class ITrackListEditor { class ITrackListEditor {
public: public:
virtual bool Insert(uint64_t id, size_t index) = 0; virtual bool Insert(int64_t id, size_t index) = 0;
virtual bool Swap(size_t index1, size_t index2) = 0; virtual bool Swap(size_t index1, size_t index2) = 0;
virtual bool Move(size_t from, size_t to) = 0; virtual bool Move(size_t from, size_t to) = 0;
virtual bool Delete(size_t index) = 0; virtual bool Delete(size_t index) = 0;
virtual void Add(const uint64_t id) = 0; virtual void Add(const int64_t id) = 0;
virtual void Clear() = 0; virtual void Clear() = 0;
virtual void Shuffle() = 0; virtual void Shuffle() = 0;
virtual void Release() = 0; virtual void Release() = 0;

View File

@ -133,5 +133,5 @@ namespace musik {
static const char* ExternalId = "external_id"; static const char* ExternalId = "external_id";
} }
static const int SdkVersion = 7; static const int SdkVersion = 8;
} } } } } }

View File

@ -185,11 +185,11 @@ std::string musik::core::GetPath(const std::string &sFile) {
return sPath; return sPath;
} }
uint64_t musik::core::Checksum(char *data,unsigned int bytes) { int64_t musik::core::Checksum(char *data,unsigned int bytes) {
uint64_t sum = 0; int64_t sum = 0;
for(unsigned int i = 0; i < bytes; ++i) { for(unsigned int i = 0; i < bytes; ++i) {
char ch = *(data + i); char ch = *(data + i);
sum += (uint64_t) ch; sum += (int64_t) ch;
} }
return sum; return sum;
} }

View File

@ -44,7 +44,7 @@ namespace musik { namespace core {
std::string GetDataDirectory(bool create = true); std::string GetDataDirectory(bool create = true);
std::string GetPath(const std::string &sFile); std::string GetPath(const std::string &sFile);
std::string GetPluginDirectory(); std::string GetPluginDirectory();
uint64_t Checksum(char *data,unsigned int bytes); int64_t Checksum(char *data,unsigned int bytes);
size_t CopyString(const std::string& src, char* dst, size_t size); size_t CopyString(const std::string& src, char* dst, size_t size);
bool FileToByteArray(const std::string& path, char** target, int& size, bool nullTerminate = false); bool FileToByteArray(const std::string& path, char** target, int& size, bool nullTerminate = false);

View File

@ -146,7 +146,7 @@ void BrowseLayout::ProcessMessage(musik::core::runtime::IMessage &message) {
LayoutBase::ProcessMessage(message); LayoutBase::ProcessMessage(message);
} }
void BrowseLayout::ScrollTo(const std::string& fieldType, uint64_t fieldId) { void BrowseLayout::ScrollTo(const std::string& fieldType, int64_t fieldId) {
this->SetFocus(this->trackList); this->SetFocus(this->trackList);
this->categoryList->RequeryWithField(fieldType, "", fieldId); this->categoryList->RequeryWithField(fieldType, "", fieldId);
@ -172,7 +172,7 @@ void BrowseLayout::OnIndexerProgress(int count) {
void BrowseLayout::RequeryTrackList(ListWindow *view) { void BrowseLayout::RequeryTrackList(ListWindow *view) {
if (view == this->categoryList.get()) { if (view == this->categoryList.get()) {
uint64_t selectedId = this->categoryList->GetSelectedId(); int64_t selectedId = this->categoryList->GetSelectedId();
if (selectedId != -1) { if (selectedId != -1) {
this->trackList->Requery(std::shared_ptr<TrackListQueryBase>( this->trackList->Requery(std::shared_ptr<TrackListQueryBase>(
new CategoryTrackListQuery( new CategoryTrackListQuery(

View File

@ -66,7 +66,7 @@ namespace musik {
virtual cursespp::IWindowPtr GetFocus(); virtual cursespp::IWindowPtr GetFocus();
virtual bool KeyPress(const std::string& key); virtual bool KeyPress(const std::string& key);
virtual void ProcessMessage(musik::core::runtime::IMessage &message); virtual void ProcessMessage(musik::core::runtime::IMessage &message);
void ScrollTo(const std::string& fieldType, uint64_t fieldId); void ScrollTo(const std::string& fieldType, int64_t fieldId);
protected: protected:
virtual void OnLayout(); virtual void OnLayout();

View File

@ -219,7 +219,7 @@ void LibraryLayout::OnRemovedFromParent(IWindow* parent) {
} }
void LibraryLayout::OnSearchResultSelected( void LibraryLayout::OnSearchResultSelected(
SearchLayout* layout, std::string fieldType, uint64_t fieldId) SearchLayout* layout, std::string fieldType, int64_t fieldId)
{ {
this->ShowBrowse(); this->ShowBrowse();
this->browseLayout->ScrollTo(fieldType, fieldId); this->browseLayout->ScrollTo(fieldType, fieldId);

View File

@ -84,7 +84,7 @@ namespace musik {
void OnSearchResultSelected( void OnSearchResultSelected(
SearchLayout* layout, SearchLayout* layout,
std::string fieldType, std::string fieldType,
uint64_t fieldId); int64_t fieldId);
void OnMainLayoutFocusTerminated( void OnMainLayoutFocusTerminated(
LayoutBase::FocusDirection direction); LayoutBase::FocusDirection direction);

View File

@ -207,7 +207,7 @@ void NowPlayingLayout::RequeryTrackList() {
this->OnTrackListRequeried(nullptr); this->OnTrackListRequeried(nullptr);
} }
void NowPlayingLayout::OnPlaylistSelected(uint64_t playlistId) { void NowPlayingLayout::OnPlaylistSelected(int64_t playlistId) {
auto query = std::shared_ptr<GetPlaylistQuery>( auto query = std::shared_ptr<GetPlaylistQuery>(
new GetPlaylistQuery(library, playlistId)); new GetPlaylistQuery(library, playlistId));

View File

@ -75,7 +75,7 @@ namespace musik {
/* callbacks */ /* callbacks */
void OnTrackListRequeried(musik::core::db::local::TrackListQueryBase* query); void OnTrackListRequeried(musik::core::db::local::TrackListQueryBase* query);
int64_t RowDecorator(musik::core::TrackPtr track, size_t index); int64_t RowDecorator(musik::core::TrackPtr track, size_t index);
void OnPlaylistSelected(uint64_t playlistId); void OnPlaylistSelected(int64_t playlistId);
musik::core::audio::PlaybackService& playback; musik::core::audio::PlaybackService& playback;
musik::core::ILibraryPtr library; musik::core::ILibraryPtr library;

View File

@ -57,7 +57,7 @@ namespace musik {
public sigslot::has_slots<> public sigslot::has_slots<>
{ {
public: public:
sigslot::signal3<SearchLayout*, std::string, uint64_t> SearchResultSelected; sigslot::signal3<SearchLayout*, std::string, int64_t> SearchResultSelected;
SearchLayout( SearchLayout(
musik::core::audio::PlaybackService& playback, musik::core::audio::PlaybackService& playback,

View File

@ -119,7 +119,7 @@ static void showPlaylistListOverlay(
static void confirmOverwritePlaylist( static void confirmOverwritePlaylist(
musik::core::ILibraryPtr library, musik::core::ILibraryPtr library,
const std::string& playlistName, const std::string& playlistName,
const uint64_t playlistId, const int64_t playlistId,
std::shared_ptr<TrackList> tracks) std::shared_ptr<TrackList> tracks)
{ {
std::shared_ptr<DialogOverlay> dialog(new DialogOverlay()); std::shared_ptr<DialogOverlay> dialog(new DialogOverlay());
@ -162,7 +162,7 @@ static void createNewPlaylist(
static void renamePlaylist( static void renamePlaylist(
musik::core::ILibraryPtr library, musik::core::ILibraryPtr library,
const uint64_t playlistId, const int64_t playlistId,
const std::string& oldName) const std::string& oldName)
{ {
std::shared_ptr<InputOverlay> dialog(new InputOverlay()); std::shared_ptr<InputOverlay> dialog(new InputOverlay());
@ -183,7 +183,7 @@ static void renamePlaylist(
static void confirmDeletePlaylist( static void confirmDeletePlaylist(
musik::core::ILibraryPtr library, musik::core::ILibraryPtr library,
const std::string& playlistName, const std::string& playlistName,
const uint64_t playlistId) const int64_t playlistId)
{ {
std::shared_ptr<DialogOverlay> dialog(new DialogOverlay()); std::shared_ptr<DialogOverlay> dialog(new DialogOverlay());
@ -220,7 +220,7 @@ static void handleAddCategorySelection(
musik::core::audio::PlaybackService& playback, musik::core::audio::PlaybackService& playback,
musik::core::ILibraryPtr library, musik::core::ILibraryPtr library,
const std::string& fieldColumn, const std::string& fieldColumn,
uint64_t fieldId, int64_t fieldId,
size_t type) size_t type)
{ {
std::shared_ptr<CategoryTrackListQuery> query( std::shared_ptr<CategoryTrackListQuery> query(
@ -256,20 +256,20 @@ static void handleJumpTo(
musik::core::runtime::IMessageQueue& messageQueue, musik::core::runtime::IMessageQueue& messageQueue,
musik::core::TrackPtr track) musik::core::TrackPtr track)
{ {
uint64_t type; int64_t type;
uint64_t id; int64_t id;
if (index == 0) { if (index == 0) {
type = message::category::Album; type = message::category::Album;
id = track->GetUint64(library::constants::Track::ALBUM_ID); id = track->GetInt64(library::constants::Track::ALBUM_ID);
} }
else if (index == 1) { else if (index == 1) {
type = message::category::Artist; type = message::category::Artist;
id = track->GetUint64(library::constants::Track::ARTIST_ID); id = track->GetInt64(library::constants::Track::ARTIST_ID);
} }
else if (index == 2) { else if (index == 2) {
type = message::category::Genre; type = message::category::Genre;
id = track->GetUint64(library::constants::Track::GENRE_ID); id = track->GetInt64(library::constants::Track::GENRE_ID);
} }
messageQueue.Broadcast(runtime::Message::Create( messageQueue.Broadcast(runtime::Message::Create(
@ -330,7 +330,7 @@ void PlayQueueOverlays::ShowAddCategoryOverlay(
musik::core::audio::PlaybackService& playback, musik::core::audio::PlaybackService& playback,
musik::core::ILibraryPtr library, musik::core::ILibraryPtr library,
const std::string& fieldColumn, const std::string& fieldColumn,
uint64_t fieldId) int64_t fieldId)
{ {
std::shared_ptr<Adapter> adapter(new Adapter()); std::shared_ptr<Adapter> adapter(new Adapter());
adapter->AddEntry(_TSTR("playqueue_overlay_add_to_start")); adapter->AddEntry(_TSTR("playqueue_overlay_add_to_start"));
@ -387,7 +387,7 @@ void PlayQueueOverlays::ShowAlbumDividerOverlay(
} }
auto albumColumn = library::constants::Track::ALBUM; auto albumColumn = library::constants::Track::ALBUM;
auto albumId = firstTrack->GetUint64(library::constants::Track::ALBUM_ID); auto albumId = firstTrack->GetInt64(library::constants::Track::ALBUM_ID);
/* items 0, 1, and 2 jump to category */ /* items 0, 1, and 2 jump to category */
if (index <= 2) { if (index <= 2) {
@ -435,7 +435,7 @@ void PlayQueueOverlays::ShowLoadPlaylistOverlay(
[library, result, callback] [library, result, callback]
(ListOverlay* overlay, IScrollAdapterPtr adapter, size_t index) { (ListOverlay* overlay, IScrollAdapterPtr adapter, size_t index) {
if (index != ListWindow::NO_SELECTION && callback) { if (index != ListWindow::NO_SELECTION && callback) {
uint64_t playlistId = (*result)[index]->id; int64_t playlistId = (*result)[index]->id;
callback(playlistId); callback(playlistId);
} }
}); });
@ -444,7 +444,7 @@ void PlayQueueOverlays::ShowLoadPlaylistOverlay(
void PlayQueueOverlays::ShowSavePlaylistOverlay( void PlayQueueOverlays::ShowSavePlaylistOverlay(
musik::core::audio::PlaybackService& playback, musik::core::audio::PlaybackService& playback,
musik::core::ILibraryPtr library, musik::core::ILibraryPtr library,
uint64_t selectedPlaylistId) int64_t selectedPlaylistId)
{ {
std::shared_ptr<CategoryListQuery> query = queryPlaylists(library); std::shared_ptr<CategoryListQuery> query = queryPlaylists(library);
auto result = query->GetResult(); auto result = query->GetResult();
@ -479,7 +479,7 @@ void PlayQueueOverlays::ShowSavePlaylistOverlay(
} }
else { /* replace existing */ else { /* replace existing */
--index; --index;
uint64_t playlistId = (*result)[index]->id; int64_t playlistId = (*result)[index]->id;
std::string playlistName = (*result)[index]->displayValue; std::string playlistName = (*result)[index]->displayValue;
confirmOverwritePlaylist(library, playlistName, playlistId, tracks); confirmOverwritePlaylist(library, playlistName, playlistId, tracks);
} }
@ -505,7 +505,7 @@ void PlayQueueOverlays::ShowRenamePlaylistOverlay(musik::core::ILibraryPtr libra
adapter, adapter,
[library, result](ListOverlay* overlay, IScrollAdapterPtr adapter, size_t index) { [library, result](ListOverlay* overlay, IScrollAdapterPtr adapter, size_t index) {
if (index != ListWindow::NO_SELECTION) { if (index != ListWindow::NO_SELECTION) {
uint64_t playlistId = (*result)[index]->id; int64_t playlistId = (*result)[index]->id;
std::string playlistName = (*result)[index]->displayValue; std::string playlistName = (*result)[index]->displayValue;
renamePlaylist(library, playlistId, playlistName); renamePlaylist(library, playlistId, playlistName);
} }
@ -531,7 +531,7 @@ void PlayQueueOverlays::ShowDeletePlaylistOverlay(musik::core::ILibraryPtr libra
[library, result] [library, result]
(ListOverlay* overlay, IScrollAdapterPtr adapter, size_t index) { (ListOverlay* overlay, IScrollAdapterPtr adapter, size_t index) {
if (index != ListWindow::NO_SELECTION) { if (index != ListWindow::NO_SELECTION) {
uint64_t playlistId = (*result)[index]->id; int64_t playlistId = (*result)[index]->id;
std::string playlistName = (*result)[index]->displayValue; std::string playlistName = (*result)[index]->displayValue;
confirmDeletePlaylist(library, playlistName, playlistId); confirmDeletePlaylist(library, playlistName, playlistId);
} }

View File

@ -43,7 +43,7 @@ namespace musik {
namespace box { namespace box {
class PlayQueueOverlays { class PlayQueueOverlays {
public: public:
using PlaylistSelectedCallback = std::function<void(uint64_t)>; using PlaylistSelectedCallback = std::function<void(int64_t)>;
static void ShowAddTrackOverlay( static void ShowAddTrackOverlay(
musik::core::runtime::IMessageQueue& messageQueue, musik::core::runtime::IMessageQueue& messageQueue,
@ -54,7 +54,7 @@ namespace musik {
musik::core::audio::PlaybackService& playback, musik::core::audio::PlaybackService& playback,
musik::core::ILibraryPtr library, musik::core::ILibraryPtr library,
const std::string& fieldColumn, const std::string& fieldColumn,
uint64_t fieldId); int64_t fieldId);
static void ShowAlbumDividerOverlay( static void ShowAlbumDividerOverlay(
musik::core::runtime::IMessageQueue& messageQueue, musik::core::runtime::IMessageQueue& messageQueue,
@ -70,7 +70,7 @@ namespace musik {
static void ShowSavePlaylistOverlay( static void ShowSavePlaylistOverlay(
musik::core::audio::PlaybackService& playback, musik::core::audio::PlaybackService& playback,
musik::core::ILibraryPtr library, musik::core::ILibraryPtr library,
uint64_t selectedPlaylistId = -1); int64_t selectedPlaylistId = -1);
static void ShowRenamePlaylistOverlay( static void ShowRenamePlaylistOverlay(
musik::core::ILibraryPtr library); musik::core::ILibraryPtr library);

View File

@ -82,7 +82,7 @@ CategoryListView::~CategoryListView() {
void CategoryListView::RequeryWithField( void CategoryListView::RequeryWithField(
const std::string& fieldName, const std::string& fieldName,
const std::string& filter, const std::string& filter,
const uint64_t selectAfterQuery) const int64_t selectAfterQuery)
{ {
if (this->activeQuery) { if (this->activeQuery) {
this->activeQuery->Cancel(); this->activeQuery->Cancel();
@ -94,7 +94,7 @@ void CategoryListView::RequeryWithField(
this->library->Enqueue(activeQuery); this->library->Enqueue(activeQuery);
} }
void CategoryListView::Requery(const std::string& filter, const uint64_t selectAfterQuery) { void CategoryListView::Requery(const std::string& filter, const int64_t selectAfterQuery) {
this->RequeryWithField(this->fieldName, filter, selectAfterQuery); this->RequeryWithField(this->fieldName, filter, selectAfterQuery);
} }
@ -103,7 +103,7 @@ void CategoryListView::Reset() {
this->OnAdapterChanged(); this->OnAdapterChanged();
} }
uint64_t CategoryListView::GetSelectedId() { int64_t CategoryListView::GetSelectedId() {
size_t index = this->GetSelectedIndex(); size_t index = this->GetSelectedIndex();
if (index != NO_SELECTION && this->metadata && index < this->metadata->size()) { if (index != NO_SELECTION && this->metadata && index < this->metadata->size()) {
return this->metadata->at(index)->id; return this->metadata->at(index)->id;
@ -152,7 +152,7 @@ void CategoryListView::ScrollToPlaying() {
bool CategoryListView::KeyPress(const std::string& key) { bool CategoryListView::KeyPress(const std::string& key) {
if (Hotkeys::Is(Hotkeys::ContextMenu, key)) { if (Hotkeys::Is(Hotkeys::ContextMenu, key)) {
uint64_t id = this->GetSelectedId(); int64_t id = this->GetSelectedId();
if (id != -1) { if (id != -1) {
PlayQueueOverlays::ShowAddCategoryOverlay( PlayQueueOverlays::ShowAddCategoryOverlay(
this->playback, this->playback,

View File

@ -68,17 +68,17 @@ namespace musik {
void RequeryWithField( void RequeryWithField(
const std::string& fieldName, const std::string& fieldName,
const std::string& filter = "", const std::string& filter = "",
const uint64_t selectAfterQuery = 0); const int64_t selectAfterQuery = 0);
void Requery( void Requery(
const std::string& filter = "", const std::string& filter = "",
const uint64_t selectAfterQuery = 0); const int64_t selectAfterQuery = 0);
virtual bool KeyPress(const std::string& key); virtual bool KeyPress(const std::string& key);
void Reset(); void Reset();
uint64_t GetSelectedId(); int64_t GetSelectedId();
std::string GetFieldName(); std::string GetFieldName();
void SetFieldName(const std::string& fieldName); void SetFieldName(const std::string& fieldName);
@ -113,7 +113,7 @@ namespace musik {
musik::core::TrackPtr playing; musik::core::TrackPtr playing;
std::string fieldName; std::string fieldName;
uint64_t selectAfterQuery; int64_t selectAfterQuery;
musik::core::db::local::CategoryListQuery::ResultList metadata; musik::core::db::local::CategoryListQuery::ResultList metadata;
}; };
} }

View File

@ -173,7 +173,7 @@ size_t TrackListView::Count() {
void TrackListView::ScrollToPlaying() { void TrackListView::ScrollToPlaying() {
if (this->playing && this->tracks) { if (this->playing && this->tracks) {
uint64_t id = this->playing->GetId(); int64_t id = this->playing->GetId();
for (size_t i = 0; i < this->tracks->Count(); i++) { for (size_t i = 0; i < this->tracks->Count(); i++) {
if (this->tracks->GetId(i) == id) { if (this->tracks->GetId(i) == id) {
size_t rawIndex = headers.TrackListToAdapterIndex(i); size_t rawIndex = headers.TrackListToAdapterIndex(i);