* @brief Activate the stored license key against the LemonSqueezy server. */
| 197 | * @brief Activate the stored license key against the LemonSqueezy server. |
| 198 | */ |
| 199 | API::CommandResponse API::Handlers::LicensingHandler::activate(const QString& id, |
| 200 | const QJsonObject&) |
| 201 | { |
| 202 | auto& ls = Licensing::LemonSqueezy::instance(); |
| 203 | |
| 204 | if (!ls.canActivate()) { |
| 205 | return CommandResponse::makeError( |
| 206 | id, ErrorCode::InvalidParam, QStringLiteral("No valid license key set (must be 36 chars)")); |
| 207 | } |
| 208 | |
| 209 | if (ls.busy()) { |
| 210 | return CommandResponse::makeError( |
| 211 | id, ErrorCode::ExecutionError, QStringLiteral("Licensing operation already in progress")); |
| 212 | } |
| 213 | |
| 214 | ls.activate(); |
| 215 | return CommandResponse::makeSuccess(id, {}); |
| 216 | } |
| 217 | |
| 218 | /** |
| 219 | * @brief Deactivate the current license on this machine, freeing a seat. |
nothing calls this directly
no test coverage detected