Remove subscription levels; license valid = subscribed
This commit is contained in:
@@ -5,11 +5,8 @@
|
||||
|
||||
namespace radiantwave::license {
|
||||
|
||||
// NOTE: the system_kv keys where the validated subscription level is persisted
|
||||
// live in db/db_keys.h (KV_SUBSCRIPTION_LEVEL_*).
|
||||
|
||||
enum class Result {
|
||||
Ok, // license valid; subscription level persisted to the DB
|
||||
Ok, // license valid; subscription active
|
||||
NotConfigured, // email and/or license key missing from the DB
|
||||
Invalid, // API rejected the pair (bad key, wrong user, inactive, ...)
|
||||
NetworkError, // the request never completed
|
||||
@@ -22,29 +19,16 @@ enum class Result {
|
||||
constexpr long long GRACE_PERIOD_SECONDS = 7LL * 24 * 60 * 60;
|
||||
|
||||
// Validates the stored license key against the stored email address via the
|
||||
// portal API. On success the subscription level (id/name/description) is
|
||||
// written to the DB; on failure the stored level is left untouched so a
|
||||
// portal API. A successful validation is the device's "subscribed" flag — no
|
||||
// separate subscription state is tracked. On failure nothing is written, so a
|
||||
// previous good value survives a transient outage. Returns NotConfigured
|
||||
// without touching the network when either value is missing. Never throws.
|
||||
//
|
||||
// `outLevelName` / `outErrorMessage` are optional out-params.
|
||||
// `outErrorMessage` is an optional out-param.
|
||||
Result validateStoredLicense(radiantwave::db::DatabaseManager& db,
|
||||
const std::string& apiKey = "",
|
||||
std::string* outLevelName = nullptr,
|
||||
std::string* outErrorMessage = nullptr);
|
||||
|
||||
// Returns the subscription level id currently stored after a successful
|
||||
// license validation. Returns 0 when no validated license is on record.
|
||||
int getStoredSubscriptionLevelId(const radiantwave::db::DatabaseManager& db);
|
||||
|
||||
// Human-readable name for a subscription level id (Basic / Advanced / Elite).
|
||||
// Falls back to a generic label for unknown ids.
|
||||
std::string subscriptionLevelName(int levelId);
|
||||
|
||||
// Numeric id for a subscription level name (case-insensitive match against
|
||||
// Basic / Advanced / Elite). Returns 0 for an unknown or empty name.
|
||||
int subscriptionLevelIdForName(const std::string& name);
|
||||
|
||||
// Records the current time as the "last verified" stamp of the license. Called
|
||||
// after every successful server validation so the offline grace window starts
|
||||
// (or is extended) from the most recent confirmation.
|
||||
|
||||
Reference in New Issue
Block a user