From 17529615d1978b175c9efec0943d48588b22a0df Mon Sep 17 00:00:00 2001 From: Karuma Date: Sat, 27 Jun 2026 18:58:25 +0300 Subject: [PATCH] Fix: offline activation key, reset grace period on activation, update checker, remove OpenBoard from preferences.ui --- release.json | 1 + resources/forms/preferences.ui | 4 +-- src/core/UBLicenseManager.cpp | 54 ++++++++++++++++++++++++++++++++-- src/core/UBLicenseManager.h | 4 +++ src/core/main.cpp | 7 +++++ 5 files changed, 66 insertions(+), 4 deletions(-) create mode 100644 release.json diff --git a/release.json b/release.json new file mode 100644 index 0000000..dc09c80 --- /dev/null +++ b/release.json @@ -0,0 +1 @@ +{"tag_name":"v1.0.0","target_commitish":"main","name":"SaiCore v1.0.0","body":"SaiCore v1.0.0 — отечественное ПО для интерактивных панелей и досок.\n\nВозможности:\n- Рисование, презентации, запись уроков\n- Работа с документами PDF\n- Кроссплатформенность: Astra Linux, Debian, Ubuntu\n- Проприетарная лицензия EULA\n- Пробный период 30 дней\n- Система лицензирования с grace period 7 дней\n\nПравообладатель: ООО «КАРУМА»","draft":false,"prerelease":false} diff --git a/resources/forms/preferences.ui b/resources/forms/preferences.ui index b848ded..40d149c 100644 --- a/resources/forms/preferences.ui +++ b/resources/forms/preferences.ui @@ -3227,9 +3227,9 @@ hr { height: 1px; border-width: 0; } <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Cantarell'; font-size:10pt;"><br /></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Cantarell'; font-size:10pt;">SaiCore — программное обеспечение для интерактивных панелей. © 2026 SaiCore. Все права защищены.</span></p> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Cantarell'; font-size:10pt;"><br /></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Cantarell'; font-size:10pt;">SaiCore основано на OpenBoard. OpenBoard является производным от Open-Sankoré. Open-Sankoré © 2010-2015 GIP ENA. Все права защищены.</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Cantarell'; font-size:10pt;">SaiCore разработано ООО «КАРУМА». Все права защищены.</span></p> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Cantarell'; font-size:10pt;"><br /></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Cantarell'; font-size:10pt;">SaiCore — свободное программное обеспечение: вы можете распространять и изменять его на условиях GNU General Public License версии 3, опубликованной Free Software Foundation. Исходный код доступен на </span><a href="https://saicore.ru"><span style=" font-family:'Cantarell'; font-size:10pt; text-decoration: underline; color:#0000ff;">saicore.ru</span></a><span style=" font-family:'Cantarell'; font-size:10pt;">.</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Cantarell'; font-size:10pt;">SaiCore — проприетарное программное обеспечение ООО «КАРУМА». Использование без лицензионного ключа допускается только в течение пробного периода (30 дней). Подробнее: </span><a href="https://saicore.ru"><span style=" font-family:'Cantarell'; font-size:10pt; text-decoration: underline; color:#0000ff;">saicore.ru</span></a><span style=" font-family:'Cantarell'; font-size:10pt;">.</span></p> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Cantarell'; font-size:10pt;"><br /></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Cantarell'; font-size:10pt;">Контактная информация:</span></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="https://saicore.ru"><span style=" font-family:'Cantarell'; font-size:10pt; text-decoration: underline; color:#0000ff;">saicore.ru</span></a></p></td></tr></table></body></html> diff --git a/src/core/UBLicenseManager.cpp b/src/core/UBLicenseManager.cpp index f5dff8c..18b19a6 100644 --- a/src/core/UBLicenseManager.cpp +++ b/src/core/UBLicenseManager.cpp @@ -25,6 +25,7 @@ UBLicenseManager* UBLicenseManager::sInstance = nullptr; const QString LICENSE_SERVER_URL = "https://license.saicore.ru/api/activate"; +const QString UPDATE_CHECK_URL = "https://license.saicore.ru/api/check_update"; const int TRIAL_DURATION_DAYS = 30; const int GRACE_PERIOD_DAYS = 7; @@ -311,6 +312,8 @@ bool UBLicenseManager::activateLicense(const QString& key) json["product"] = "SaiCore"; json["version"] = "1.0.0"; + mPendingActivationKey = key.trimmed().toUpper(); + QNetworkReply* reply = mNetworkManager->post(request, QJsonDocument(json).toJson(QJsonDocument::Compact)); connect(reply, &QNetworkReply::finished, this, [this, reply]() { onActivationReply(reply); }); @@ -323,10 +326,11 @@ void UBLicenseManager::onActivationReply(QNetworkReply* reply) if (reply->error() != QNetworkReply::NoError) { - if (validateLicenseOffline(mLicenseKey)) + if (validateLicenseOffline(mPendingActivationKey)) { - mLicenseKey = reply->property("key").toString(); + mLicenseKey = mPendingActivationKey; mLicenseExpiry = QDateTime::currentDateTime().addYears(1); + mGracePeriodStart = QDateTime(); mState = LicenseActive; saveState(); emit licenseStateChanged(mState); @@ -354,6 +358,7 @@ void UBLicenseManager::onActivationReply(QNetworkReply* reply) mLicenseKey = obj.value("license_key").toString(); mLicenseExpiry = expiry; + mGracePeriodStart = QDateTime(); mState = LicenseActive; saveState(); emit licenseStateChanged(mState); @@ -389,3 +394,48 @@ void UBLicenseManager::deactivateLicense() saveState(); emit licenseStateChanged(mState); } + +void UBLicenseManager::checkForUpdates() +{ + QNetworkRequest request; + request.setUrl(QUrl(UPDATE_CHECK_URL)); + request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json"); + request.setRawHeader("User-Agent", "SaiCore/1.0.0"); + + QJsonObject json; + json["version"] = "1.0.0"; + json["platform"] = QSysInfo::productType(); + + QNetworkReply* reply = mNetworkManager->post(request, QJsonDocument(json).toJson(QJsonDocument::Compact)); + connect(reply, &QNetworkReply::finished, this, [this, reply]() { onUpdateCheckReply(reply); }); +} + +void UBLicenseManager::onUpdateCheckReply(QNetworkReply* reply) +{ + reply->deleteLater(); + + if (reply->error() != QNetworkReply::NoError) + { + qWarning() << "Update check failed:" << reply->errorString(); + return; + } + + QByteArray data = reply->readAll(); + QJsonDocument doc = QJsonDocument::fromJson(data); + QJsonObject obj = doc.object(); + + bool hasUpdate = obj.value("update_available").toBool(false); + if (hasUpdate) + { + QString version = obj.value("latest_version").toString(); + QString downloadUrl = obj.value("download_url").toString(); + QString changelog = obj.value("changelog").toString(); + + qInfo() << "Update available:" << version; + emit updateAvailable(version, downloadUrl, changelog); + } + else + { + qDebug() << "SaiCore is up to date"; + } +} diff --git a/src/core/UBLicenseManager.h b/src/core/UBLicenseManager.h index 0e68cb2..9e3fb1e 100644 --- a/src/core/UBLicenseManager.h +++ b/src/core/UBLicenseManager.h @@ -59,6 +59,7 @@ public: bool activateLicense(const QString& key); bool validateLicenseFormat(const QString& key) const; bool validateLicenseOffline(const QString& key) const; + void checkForUpdates(); void startTrial(); void deactivateLicense(); @@ -68,9 +69,11 @@ public: signals: void licenseStateChanged(LicenseState newState); void activationResult(bool success, const QString& message); + void updateAvailable(const QString& version, const QString& downloadUrl, const QString& changelog); private slots: void onActivationReply(QNetworkReply* reply); + void onUpdateCheckReply(QNetworkReply* reply); private: UBLicenseManager(QObject* parent = nullptr); @@ -84,6 +87,7 @@ private: QDateTime mTrialStart; QDateTime mLicenseExpiry; QDateTime mGracePeriodStart; + QString mPendingActivationKey; QNetworkAccessManager* mNetworkManager; static const int GRACE_PERIOD_DAYS = 7; diff --git a/src/core/main.cpp b/src/core/main.cpp index f00efaf..584b774 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -222,6 +222,13 @@ int main(int argc, char *argv[]) << "days remaining. License required."; } + QObject::connect(licenseManager, &UBLicenseManager::updateAvailable, + [](const QString& version, const QString& url, const QString& changelog) { + qDebug() << "Update available:" << version << url; + }); + + licenseManager->checkForUpdates(); + qDebug() << "file name argument" << fileToOpen; result = app.exec(fileToOpen); }