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

Method applyValidatedLicense

app/src/Licensing/LemonSqueezy.cpp:611–658  ·  view source on GitHub ↗

* @brief Persists fresh license fields, installs the commercial token, and notifies QML. */

Source from the content-addressed store, hash-verified

609 * @brief Persists fresh license fields, installs the commercial token, and notifies QML.
610 */
611void Licensing::LemonSqueezy::applyValidatedLicense(const QJsonObject& json,
612 const bool cachedResponse)
613{
614 const auto meta = json.value("meta").toObject();
615 const auto instance = json.value("instance").toObject();
616 const auto licenseKey = json.value("license_key").toObject();
617
618 m_activated = true;
619 m_licensingData = json;
620 m_instanceId = instance.value("id").toString();
621 m_variantName = meta.value("variant_name").toString();
622 m_instanceName = instance.value("name").toString();
623 m_seatLimit = licenseKey.value("activation_limit").toInt(-1);
624 m_seatUsage = licenseKey.value("activation_usage").toInt(-1);
625 m_customerName = meta.value("customer_name").toString();
626 m_customerEmail = meta.value("customer_email").toString();
627 m_activationDate = instance.value("created_at").toVariant().toDateTime();
628
629 updateAppNameFromVariant(m_variantName);
630
631 CommercialToken token;
632 token.setVariantName(m_variantName);
633 token.setInstanceName(m_instanceName);
634 token.setGraceDaysRemaining(cachedResponse ? m_gracePeriod : 30);
635 token.setFeatureTier(tierFromVariant(m_variantName));
636 token.seal();
637 CommercialToken::setCurrent(token);
638
639 m_busy = false;
640 Q_EMIT busyChanged();
641 Q_EMIT licenseDataChanged();
642
643 if (!cachedResponse) {
644 const auto dt = QDateTime::currentDateTime().toString(Qt::RFC2822Date);
645 m_settings.beginGroup("licensing");
646 m_settings.setValue("lastCheck", m_simpleCrypt.encryptToString(dt));
647 m_settings.endGroup();
648 }
649
650 if (!m_silentValidation) {
651 m_silentValidation = true;
652 Q_EMIT activatedChanged();
653 Misc::Utilities::showMessageBox(
654 tr("Your license has been successfully activated."),
655 tr("Thank you for supporting Serial Studio!\nYou now have access to all premium features."),
656 QMessageBox::Information);
657 }
658}
659
660/**
661 * @brief Processes the response from the license validation request.

Callers

nothing calls this directly

Calls 9

tierFromVariantFunction · 0.85
toVariantMethod · 0.80
setVariantNameMethod · 0.80
setInstanceNameMethod · 0.80
setGraceDaysRemainingMethod · 0.80
setFeatureTierMethod · 0.80
sealMethod · 0.80
encryptToStringMethod · 0.80
valueMethod · 0.45

Tested by

no test coverage detected