2017-10-20 11:26:15 -04:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <string>
|
2019-10-17 18:15:16 -04:00
|
|
|
#include <vector>
|
2019-10-16 20:51:11 -04:00
|
|
|
#include "filesystem_def.h"
|
2017-10-20 11:26:15 -04:00
|
|
|
#include "Types.h"
|
|
|
|
#include "Singleton.h"
|
|
|
|
#include "sqlite/SqliteDb.h"
|
2017-10-20 12:23:10 -04:00
|
|
|
#include "sqlite/SqliteStatement.h"
|
2017-10-20 11:26:15 -04:00
|
|
|
|
|
|
|
namespace BootablesDb
|
|
|
|
{
|
2022-02-19 00:40:29 +00:00
|
|
|
struct BootableState
|
|
|
|
{
|
|
|
|
std::string name;
|
|
|
|
std::string color;
|
|
|
|
};
|
|
|
|
using BootableStateList = std::vector<BootableState>;
|
|
|
|
|
2017-10-20 11:26:15 -04:00
|
|
|
struct Bootable
|
|
|
|
{
|
2019-10-16 20:51:11 -04:00
|
|
|
fs::path path;
|
2017-10-20 11:26:15 -04:00
|
|
|
std::string discId;
|
2017-10-20 12:23:10 -04:00
|
|
|
std::string title;
|
|
|
|
std::string coverUrl;
|
2019-01-05 22:57:08 +00:00
|
|
|
std::string overview;
|
2017-10-20 11:26:15 -04:00
|
|
|
time_t lastBootedTime = 0;
|
2022-02-19 00:40:29 +00:00
|
|
|
BootableStateList states;
|
2017-10-20 11:26:15 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
class CClient : public CSingleton<CClient>
|
|
|
|
{
|
|
|
|
public:
|
2019-02-11 13:23:13 -05:00
|
|
|
//NOTE: This is duplicated in the Android Java code (in BootablesInterop.java) - values matter
|
|
|
|
enum SORT_METHOD
|
|
|
|
{
|
|
|
|
SORT_METHOD_RECENT,
|
|
|
|
SORT_METHOD_HOMEBREW,
|
|
|
|
SORT_METHOD_NONE,
|
|
|
|
};
|
|
|
|
|
2017-10-20 11:26:15 -04:00
|
|
|
CClient();
|
|
|
|
virtual ~CClient() = default;
|
|
|
|
|
2020-12-15 13:33:59 -05:00
|
|
|
bool BootableExists(const fs::path&);
|
2019-10-16 20:51:11 -04:00
|
|
|
Bootable GetBootable(const fs::path&);
|
2019-02-11 13:23:13 -05:00
|
|
|
std::vector<Bootable> GetBootables(int32_t = SORT_METHOD_NONE);
|
2022-02-19 00:03:53 +00:00
|
|
|
BootableStateList GetStates();
|
2017-10-20 11:26:15 -04:00
|
|
|
|
2019-10-16 20:51:11 -04:00
|
|
|
void RegisterBootable(const fs::path&, const char*, const char*);
|
|
|
|
void UnregisterBootable(const fs::path&);
|
2017-10-20 11:26:15 -04:00
|
|
|
|
2019-10-16 20:51:11 -04:00
|
|
|
void SetDiscId(const fs::path&, const char*);
|
|
|
|
void SetTitle(const fs::path&, const char*);
|
|
|
|
void SetCoverUrl(const fs::path&, const char*);
|
|
|
|
void SetLastBootedTime(const fs::path&, time_t);
|
|
|
|
void SetOverview(const fs::path& path, const char* overview);
|
2017-10-20 11:26:15 -04:00
|
|
|
|
|
|
|
private:
|
2022-02-19 00:40:29 +00:00
|
|
|
Bootable ReadBootable(Framework::CSqliteStatement&);
|
|
|
|
BootableStateList GetGameStates(std::string);
|
2017-10-20 12:23:10 -04:00
|
|
|
|
2017-10-20 11:26:15 -04:00
|
|
|
void CheckDbVersion();
|
|
|
|
|
2019-10-16 20:51:11 -04:00
|
|
|
fs::path m_dbPath;
|
2017-10-20 11:26:15 -04:00
|
|
|
Framework::CSqliteDb m_db;
|
2022-02-19 00:40:29 +00:00
|
|
|
bool m_attachedState = false;
|
2017-10-20 11:26:15 -04:00
|
|
|
};
|
|
|
|
};
|