* @brief Loads and decrypts cached licensing data from QSettings; the offline * grace period is recomputed from the last check, with monotonicNow() flooring * the clock so rewinding the system time cannot extend it. */
| 375 | * the clock so rewinding the system time cannot extend it. |
| 376 | */ |
| 377 | void Licensing::LemonSqueezy::readSettings() |
| 378 | { |
| 379 | m_settings.beginGroup("licensing"); |
| 380 | auto license = m_settings.value("license", "").toString(); |
| 381 | auto data = m_settings.value("data", "").toString(); |
| 382 | auto dt = m_settings.value("lastCheck", "").toString(); |
| 383 | m_settings.endGroup(); |
| 384 | |
| 385 | if (data.isEmpty() || license.isEmpty()) |
| 386 | return; |
| 387 | |
| 388 | m_license = m_simpleCrypt.decryptToString(license); |
| 389 | auto decryptedData = m_simpleCrypt.decryptToByteArray(data); |
| 390 | |
| 391 | m_gracePeriod = 0; |
| 392 | if (!dt.isEmpty()) { |
| 393 | auto dateTime = m_simpleCrypt.decryptToString(dt); |
| 394 | auto currentDt = monotonicNow(); |
| 395 | auto lastCheck = QDateTime::fromString(dateTime, Qt::RFC2822Date); |
| 396 | if (lastCheck.isValid() && lastCheck < currentDt) |
| 397 | m_gracePeriod = qMax(0, 30 - lastCheck.daysTo(currentDt)); |
| 398 | } |
| 399 | |
| 400 | readValidationResponse(decryptedData, true); |
| 401 | Q_EMIT licenseChanged(); |
| 402 | } |
| 403 | |
| 404 | /** |
| 405 | * @brief Encrypts and writes the current license key and metadata to QSettings. |
nothing calls this directly
no test coverage detected