don't save licenses for replay sessions

This commit is contained in:
Martin Michelsen
2023-12-07 20:27:46 -08:00
parent 6136f8dfb3
commit e901f5e681
6 changed files with 111 additions and 75 deletions
+27 -5
View File
@@ -10,7 +10,8 @@
class LicenseIndex;
struct License {
class License {
public:
enum Flag : uint32_t {
// clang-format off
KICK_USER = 0x00000001,
@@ -53,14 +54,25 @@ struct License {
License() = default;
explicit License(const JSON& json);
virtual ~License() = default;
JSON json() const;
void save() const;
void delete_file() const;
virtual void save() const;
virtual void delete_file() const;
std::string str() const;
};
class DiskLicense : public License {
public:
DiskLicense() = default;
explicit DiskLicense(const JSON& json);
virtual ~DiskLicense() = default;
virtual void save() const;
virtual void delete_file() const;
};
class LicenseIndex {
public:
class no_username : public std::invalid_argument {
@@ -80,8 +92,10 @@ public:
missing_license() : invalid_argument("missing license") {}
};
LicenseIndex();
~LicenseIndex() = default;
LicenseIndex() = default;
virtual ~LicenseIndex() = default;
virtual std::shared_ptr<License> create_license() const;
size_t count() const;
std::shared_ptr<License> get(uint32_t serial_number) const;
@@ -101,3 +115,11 @@ protected:
std::unordered_map<std::string, std::shared_ptr<License>> xb_gamertag_to_license;
std::unordered_map<uint32_t, std::shared_ptr<License>> serial_number_to_license;
};
class DiskLicenseIndex : public LicenseIndex {
public:
DiskLicenseIndex();
virtual ~DiskLicenseIndex() = default;
virtual std::shared_ptr<License> create_license() const;
};