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

Method activateLicense

app/src/Misc/CLI.cpp:719–755  ·  view source on GitHub ↗

* @brief Activates a license key against the Lemon Squeezy API and exits. */

Source from the content-addressed store, hash-verified

717 * @brief Activates a license key against the Lemon Squeezy API and exits.
718 */
719int CLI::activateLicense(QApplication& app, const QString& licenseKey)
720{
721 auto& ls = Licensing::LemonSqueezy::instance();
722
723 ls.setLicense(licenseKey);
724 if (!ls.canActivate()) {
725 qCritical() << "Invalid license key format:" << licenseKey;
726 return EXIT_FAILURE;
727 }
728
729 int result = EXIT_FAILURE;
730
731 QTimer timeout;
732 timeout.setSingleShot(true);
733 timeout.setInterval(30'000);
734
735 QObject::connect(&ls, &Licensing::LemonSqueezy::activatedChanged, &app, [&] {
736 result = ls.isActivated() ? EXIT_SUCCESS : EXIT_FAILURE;
737 if (ls.isActivated())
738 qInfo() << "License activated successfully.";
739 else
740 qCritical() << "License activation failed.";
741
742 app.quit();
743 });
744
745 QObject::connect(&timeout, &QTimer::timeout, &app, [&] {
746 qCritical() << "License activation timed out.";
747 app.quit();
748 });
749
750 QTimer::singleShot(0, &ls, &Licensing::LemonSqueezy::activate);
751 timeout.start();
752
753 app.exec();
754 return result;
755}
756
757/**
758 * @brief Deactivates the stored license instance on this machine and exits.

Callers

nothing calls this directly

Calls 5

canActivateMethod · 0.80
execMethod · 0.80
setLicenseMethod · 0.45
isActivatedMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected