Play-/Source/ui_shared/BootablesDbClient.h

80 lines
1.8 KiB
C
Raw Normal View History

#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"
#include "Types.h"
#include "Singleton.h"
#include "sqlite/SqliteDb.h"
#include "sqlite/SqliteStatement.h"
namespace BootablesDb
{
2022-02-19 00:40:29 +00:00
struct BootableState
{
std::string name;
std::string color;
};
using BootableStateList = std::vector<BootableState>;
2024-10-17 21:40:04 +01:00
enum BOOTABLE_TYPE
{
UNKNOWN = 0,
PS2_DISC = 1 << 0,
PS2_ARCADE = 1 << 1,
PS2_ELF = 1 << 2,
};
struct Bootable
{
2019-10-16 20:51:11 -04:00
fs::path path;
std::string discId;
std::string title;
std::string coverUrl;
std::string overview;
time_t lastBootedTime = 0;
2022-02-19 00:40:29 +00:00
BootableStateList states;
2024-10-17 21:40:04 +01:00
BOOTABLE_TYPE bootableType = BOOTABLE_TYPE::UNKNOWN;
};
class CClient : public CSingleton<CClient>
{
public:
//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,
2022-09-29 08:27:05 -04:00
SORT_METHOD_ARCADE,
};
CClient();
virtual ~CClient() = default;
bool BootableExists(const fs::path&);
2019-10-16 20:51:11 -04:00
Bootable GetBootable(const fs::path&);
std::vector<Bootable> GetBootables(int32_t = SORT_METHOD_NONE);
2022-02-19 00:03:53 +00:00
BootableStateList GetStates();
2024-10-17 21:40:04 +01:00
void RegisterBootable(const fs::path&, const char*, const char*, BootablesDb::BOOTABLE_TYPE);
2019-10-16 20:51:11 -04:00
void UnregisterBootable(const fs::path&);
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);
private:
2022-02-19 00:40:29 +00:00
Bootable ReadBootable(Framework::CSqliteStatement&);
BootableStateList GetGameStates(std::string);
2024-10-17 21:40:04 +01:00
void UpgradeDb();
2019-10-16 20:51:11 -04:00
fs::path m_dbPath;
Framework::CSqliteDb m_db;
2022-02-19 00:40:29 +00:00
bool m_attachedState = false;
};
};