MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / readSettings

Method readSettings

app/src/Licensing/LemonSqueezy.cpp:377–402  ·  view source on GitHub ↗

* @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. */

Source from the content-addressed store, hash-verified

375 * the clock so rewinding the system time cannot extend it.
376 */
377void 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.

Callers

nothing calls this directly

Calls 5

isEmptyMethod · 0.80
decryptToStringMethod · 0.80
decryptToByteArrayMethod · 0.80
valueMethod · 0.45
isValidMethod · 0.45

Tested by

no test coverage detected