From 923e9e051c97b4a84701ec975ac7c0f97cdf413f Mon Sep 17 00:00:00 2001 From: Raul Metsma Date: Wed, 31 May 2023 12:00:13 +0300 Subject: [PATCH] Move version checks to DigiDoc (#1181) IB-7689 Signed-off-by: Raul Metsma --- client/Application.cpp | 72 ++++++++++++++++++++++++++------------- client/translations/en.ts | 12 +++++++ client/translations/et.ts | 12 +++++++ client/translations/ru.ts | 12 +++++++ common | 2 +- 5 files changed, 85 insertions(+), 25 deletions(-) diff --git a/client/Application.cpp b/client/Application.cpp index 3edecf66a..e0f27006b 100644 --- a/client/Application.cpp +++ b/client/Application.cpp @@ -58,6 +58,7 @@ class MacMenuBar {}; #include #include #include +#include #include #include #include @@ -96,7 +97,6 @@ class DigidocConf final: public digidoc::XmlConfCurrent #endif #ifdef CONFIG_URL reload(); - QTimer::singleShot(0, qApp->conf(), [] { qApp->conf()->checkVersion(QStringLiteral("QDIGIDOC4")); }); Configuration::connect(qApp->conf(), &Configuration::finished, [](bool changed, const QString & /*error*/){ if(changed) reload(); @@ -205,18 +205,15 @@ class DigidocConf final: public digidoc::XmlConfCurrent bool TSLAllowExpired() const final { - static enum { - Undefined, - Approved, - } status = Undefined; - if(status == Undefined) + static bool isAllowed = false; + if(!isAllowed) { QEventLoop e; QMetaObject::invokeMethod( qApp, "showTSLWarning", Q_ARG(QEventLoop*,&e) ); e.exec(); - status = Approved; + isAllowed = true; } - return status == Approved; + return isAllowed; } private: @@ -316,18 +313,6 @@ Application::Application( int &argc, char **argv ) #endif , d(new Private) { -#ifdef CONFIG_URL - d->conf = new Configuration(this); - connect(d->conf, &Configuration::updateReminder, - [](bool /* expired */, const QString & /* title */, const QString &message){ - WarningDialog::show(Application::activeWindow(), message); - }); -#endif - - qRegisterMetaType("TokenData"); - qRegisterMetaType("QSmartCardData"); - QToolTip::setFont(Styles::font(Styles::Regular, 14)); - QStringList args = arguments(); args.removeFirst(); #ifndef Q_OS_MAC @@ -339,6 +324,46 @@ Application::Application( int &argc, char **argv ) connect( this, SIGNAL(messageReceived(QString)), SLOT(parseArgs(QString)) ); #endif +#ifdef CONFIG_URL + d->conf = new Configuration(this); + QTimer::singleShot(0, this, [this] { + auto lessThanVersion = [](QLatin1String key) { + return QVersionNumber::fromString(applicationVersion()) < + QVersionNumber::fromString(confValue(key).toString()); + }; + if(lessThanVersion(QLatin1String("QDIGIDOC4-UNSUPPORTED"))) + { + auto *dlg = WarningDialog::show(activeWindow(), tr( + "This version of ID-software on your computer is unsupported. " + "DigiDoc4 Client cannot be used until you update ID-software. " + "Install new ID-software from www.id.ee. " + "macOS users can download the latest ID-software version from the " + "Mac App Store.")); + connect(dlg, &WarningDialog::finished, this, &Application::quit); + } + else if(lessThanVersion(QLatin1String("QDIGIDOC4-SUPPORTED"))) + { + WarningDialog::show(activeWindow(), tr( + "Your ID-software has expired. To download the latest software version, go to the " + "id.ee website. " + "macOS users can download the latest ID-software version from the " + "Mac App Store.")); + } + connect(d->conf, &Configuration::finished, this, [=](bool changed, const QString &){ + if(changed && lessThanVersion(QLatin1String("QDIGIDOC4-LATEST"))) + WarningDialog::show(activeWindow(), tr( + "An ID-software update has been found. To download the update, go to the " + "id.ee website. " + "macOS users can download the update from the " + "Mac App Store.")); + }); + }); +#endif + + qRegisterMetaType("TokenData"); + qRegisterMetaType("QSmartCardData"); + qRegisterMetaType("QEventLoop*"); + QToolTip::setFont(Styles::font(Styles::Regular, 14)); QDesktopServices::setUrlHandler(QStringLiteral("browse"), this, "browse"); QDesktopServices::setUrlHandler(QStringLiteral("mailto"), this, "mailTo"); QAccessible::installFactory([](const QString &classname, QObject *object) -> QAccessibleInterface* { @@ -346,7 +371,7 @@ Application::Application( int &argc, char **argv ) return new QAccessibleWidget(qobject_cast(object), QAccessible::StaticText); return {}; }); - + Settings::SETTINGS_MIGRATED.clear(); installTranslator( &d->appTranslator ); installTranslator( &d->commonTranslator ); @@ -410,7 +435,6 @@ Application::Application( int &argc, char **argv ) } } - qRegisterMetaType("QEventLoop*"); digidoc::initialize(applicationName().toUtf8().constData(), QStringLiteral("%1/%2 (%3)") .arg(applicationName(), applicationVersion(), applicationOs()).toUtf8().constData(), [](const digidoc::Exception *ex) { @@ -892,7 +916,7 @@ void Application::showClient(const QStringList ¶ms, bool crypto, bool sign, if( !w ) { w = new MainWindow(); - QWidget *prev = [=]() -> QWidget* { + QWidget *prev = [w]() -> QWidget* { for(QWidget *top: topLevelWidgets()) { QWidget *prev = qobject_cast(top); @@ -901,7 +925,7 @@ void Application::showClient(const QStringList ¶ms, bool crypto, bool sign, if(prev && prev != w && prev->isVisible()) return prev; } - return nullptr; + return {}; }(); if(prev) w->move(prev->geometry().topLeft() + QPoint(20, 20)); diff --git a/client/translations/en.ts b/client/translations/en.ts index ebf6c59f4..19caaea0e 100644 --- a/client/translations/en.ts +++ b/client/translations/en.ts @@ -220,6 +220,18 @@ https://www.id.ee/en/id-help/ https://www.id.ee/en/id-help/ + + This version of ID-software on your computer is unsupported. DigiDoc4 Client cannot be used until you update ID-software. Install new ID-software from <a href="https://www.id.ee/en/article/install-id-software/">www.id.ee</a>. macOS users can download the latest ID-software version from the <a href="https://itunes.apple.com/ee/developer/ria/id556524921?mt=12">Mac App Store</a>. + This version of ID-software on your computer is unsupported. DigiDoc4 Client cannot be used until you update ID-software. Install new ID-software from <a href="https://www.id.ee/en/article/install-id-software/">www.id.ee</a>. macOS users can download the latest ID-software version from the <a href="https://itunes.apple.com/ee/developer/ria/id556524921?mt=12">Mac App Store</a>. + + + Your ID-software has expired. To download the latest software version, go to the <a href="https://www.id.ee/en/article/install-id-software/">id.ee</a> website. macOS users can download the latest ID-software version from the <a href="https://itunes.apple.com/ee/developer/ria/id556524921?mt=12">Mac App Store</a>. + Your ID-software has expired. To download the latest software version, go to the <a href="https://www.id.ee/en/article/install-id-software/">id.ee</a> website. macOS users can download the latest ID-software version from the <a href="https://itunes.apple.com/ee/developer/ria/id556524921?mt=12">Mac App Store</a>. + + + An ID-software update has been found. To download the update, go to the <a href="https://www.id.ee/en/article/install-id-software/">id.ee</a> website. macOS users can download the update from the <a href="https://itunes.apple.com/ee/developer/ria/id556524921?mt=12">Mac App Store</a>. + An ID-software update has been found. To download the update, go to the <a href="https://www.id.ee/en/article/install-id-software/">id.ee</a> website. macOS users can download the update from the <a href="https://itunes.apple.com/ee/developer/ria/id556524921?mt=12">Mac App Store</a>. + CDocumentModel diff --git a/client/translations/et.ts b/client/translations/et.ts index 4a2e06932..859e7025f 100644 --- a/client/translations/et.ts +++ b/client/translations/et.ts @@ -220,6 +220,18 @@ https://www.id.ee/en/id-help/ https://www.id.ee/id-abikeskus/ + + This version of ID-software on your computer is unsupported. DigiDoc4 Client cannot be used until you update ID-software. Install new ID-software from <a href="https://www.id.ee/en/article/install-id-software/">www.id.ee</a>. macOS users can download the latest ID-software version from the <a href="https://itunes.apple.com/ee/developer/ria/id556524921?mt=12">Mac App Store</a>. + Sinu arvutis olev ID-tarkvara ei ole toetatud. DigiDoc4 kliendi kasutamiseks pead ID-tarkvara uuendama. Paigalda uus ID-tarkvara veebilehelt <a href="https://www.id.ee/artikkel/paigalda-id-tarkvara/">www.id.ee</a>, macOS kasutajad saavad uusima tarkvara <a href="https://itunes.apple.com/ee/developer/ria/id556524921?mt=12">Mac App Store</a>'ist. + + + Your ID-software has expired. To download the latest software version, go to the <a href="https://www.id.ee/en/article/install-id-software/">id.ee</a> website. macOS users can download the latest ID-software version from the <a href="https://itunes.apple.com/ee/developer/ria/id556524921?mt=12">Mac App Store</a>. + Sinu kasutatav ID-tarkvara on aegunud. Tarkvara viimase versiooni saad alla laadida veebilehelt <a href="https://www.id.ee/artikkel/paigalda-id-tarkvara/">id.ee</a>, macOS kasutajad saavad uusima tarkvara <a href="https://itunes.apple.com/ee/developer/ria/id556524921?mt=12">Mac App Store</a>'ist. + + + An ID-software update has been found. To download the update, go to the <a href="https://www.id.ee/en/article/install-id-software/">id.ee</a> website. macOS users can download the update from the <a href="https://itunes.apple.com/ee/developer/ria/id556524921?mt=12">Mac App Store</a>. + Saadaval on ID-tarkvara uuendus, mille saad paigaldada veebilehelt <a href="https://www.id.ee/artikkel/paigalda-id-tarkvara/">id.ee</a>, macOS kasutajad saavad uuenduse alla laadida <a href="https://itunes.apple.com/ee/developer/ria/id556524921?mt=12">Mac App Store</a>'ist. + CDocumentModel diff --git a/client/translations/ru.ts b/client/translations/ru.ts index 908a522a6..2afd33b69 100644 --- a/client/translations/ru.ts +++ b/client/translations/ru.ts @@ -220,6 +220,18 @@ https://www.id.ee/en/id-help/ https://www.id.ee/ru/id-pomoshh/ + + This version of ID-software on your computer is unsupported. DigiDoc4 Client cannot be used until you update ID-software. Install new ID-software from <a href="https://www.id.ee/en/article/install-id-software/">www.id.ee</a>. macOS users can download the latest ID-software version from the <a href="https://itunes.apple.com/ee/developer/ria/id556524921?mt=12">Mac App Store</a>. + Программное обеспечение ID на вашем компьютере не поддерживается. Чтобы использовать программу DigiDoc4 клиент, вам необходимо обновить программное обеспечение ID. Установите новое программное обеспечение ID с веб-сайта <a href="https://www.id.ee/ru/artikkel/ustanovite-id-programmu/">www.id.ee</a>. Пользователи macOS могут скачать последнюю версию программного обеспечения ID-карты в магазине <a href="https://itunes.apple.com/ee/developer/ria/id556524921?mt=12">Mac App Store</a>. + + + Your ID-software has expired. To download the latest software version, go to the <a href="https://www.id.ee/en/article/install-id-software/">id.ee</a> website. macOS users can download the latest ID-software version from the <a href="https://itunes.apple.com/ee/developer/ria/id556524921?mt=12">Mac App Store</a>. + Вам необходимо обновить программное обеспечение ID-карты. Чтобы скачать последнюю версию программы, перейдите на сайт <a href="https://www.id.ee/ru/artikkel/ustanovite-id-programmu/">id.ee</a>. Пользователи macOS могут скачать последнюю версию программного обеспечения ID-карты в магазине <a href="https://itunes.apple.com/ee/developer/ria/id556524921?mt=12">Mac App Store</a>. + + + An ID-software update has been found. To download the update, go to the <a href="https://www.id.ee/en/article/install-id-software/">id.ee</a> website. macOS users can download the update from the <a href="https://itunes.apple.com/ee/developer/ria/id556524921?mt=12">Mac App Store</a>. + Выпущено обновление для программного обеспечения ID-карты. Чтобы скачать обновление, перейдите на сайт <a href="https://www.id.ee/ru/artikkel/ustanovite-id-programmu/">id.ee</a>. Пользователи macOS могут скачать обновление в магазине <a href="https://itunes.apple.com/ee/developer/ria/id556524921?mt=12">Mac App Store</a>. + CDocumentModel diff --git a/common b/common index a84bdde01..33d878cbc 160000 --- a/common +++ b/common @@ -1 +1 @@ -Subproject commit a84bdde01027c3562d1aa1a344bd1d3cc69d2916 +Subproject commit 33d878cbcf538a2cdf991527c715adaf41cba19f