* @brief Deactivates the stored license instance on this machine and exits. */
| 758 | * @brief Deactivates the stored license instance on this machine and exits. |
| 759 | */ |
| 760 | int CLI::deactivateLicense(QApplication& app) |
| 761 | { |
| 762 | auto& ls = Licensing::LemonSqueezy::instance(); |
| 763 | |
| 764 | if (!ls.isActivated()) { |
| 765 | qInfo() << "License is not active on this machine; nothing to deactivate."; |
| 766 | return EXIT_SUCCESS; |
| 767 | } |
| 768 | |
| 769 | int result = EXIT_FAILURE; |
| 770 | |
| 771 | QTimer timeout; |
| 772 | timeout.setSingleShot(true); |
| 773 | timeout.setInterval(30'000); |
| 774 | |
| 775 | QObject::connect(&ls, &Licensing::LemonSqueezy::activatedChanged, &app, [&] { |
| 776 | result = !ls.isActivated() ? EXIT_SUCCESS : EXIT_FAILURE; |
| 777 | if (!ls.isActivated()) |
| 778 | qInfo() << "License deactivated successfully."; |
| 779 | else |
| 780 | qCritical() << "License deactivation failed."; |
| 781 | |
| 782 | app.quit(); |
| 783 | }); |
| 784 | |
| 785 | QObject::connect(&timeout, &QTimer::timeout, &app, [&] { |
| 786 | qCritical() << "License deactivation timed out."; |
| 787 | app.quit(); |
| 788 | }); |
| 789 | |
| 790 | QTimer::singleShot(0, &ls, &Licensing::LemonSqueezy::deactivate); |
| 791 | timeout.start(); |
| 792 | |
| 793 | app.exec(); |
| 794 | return result; |
| 795 | } |
| 796 | |
| 797 | //--------------------------------------------------------------------------------------------------- |
| 798 | // Commercial: Modbus helpers |
nothing calls this directly
no test coverage detected