Skip to content

Commit

Permalink
Move version checks to DigiDoc (open-eid#1181)
Browse files Browse the repository at this point in the history
IB-7689

Signed-off-by: Raul Metsma <[email protected]>
  • Loading branch information
metsma authored May 31, 2023
1 parent 601f172 commit 923e9e0
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 25 deletions.
72 changes: 48 additions & 24 deletions client/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class MacMenuBar {};
#include <QtCore/QTranslator>
#include <QtCore/QUrl>
#include <QtCore/QUrlQuery>
#include <QtCore/QVersionNumber>
#include <QtCore/QXmlStreamReader>
#include <QtGui/QDesktopServices>
#include <QtGui/QFileOpenEvent>
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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>("TokenData");
qRegisterMetaType<QSmartCardData>("QSmartCardData");
QToolTip::setFont(Styles::font(Styles::Regular, 14));

QStringList args = arguments();
args.removeFirst();
#ifndef Q_OS_MAC
Expand All @@ -339,14 +324,54 @@ 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 <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>."));
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 "
"<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>."));
}
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 "
"<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>."));
});
});
#endif

qRegisterMetaType<TokenData>("TokenData");
qRegisterMetaType<QSmartCardData>("QSmartCardData");
qRegisterMetaType<QEventLoop*>("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* {
if (classname == QLatin1String("QSvgWidget") && object && object->isWidgetType())
return new QAccessibleWidget(qobject_cast<QWidget *>(object), QAccessible::StaticText);
return {};
});

Settings::SETTINGS_MIGRATED.clear();

installTranslator( &d->appTranslator );
installTranslator( &d->commonTranslator );
Expand Down Expand Up @@ -410,7 +435,6 @@ Application::Application( int &argc, char **argv )
}
}

qRegisterMetaType<QEventLoop*>("QEventLoop*");
digidoc::initialize(applicationName().toUtf8().constData(), QStringLiteral("%1/%2 (%3)")
.arg(applicationName(), applicationVersion(), applicationOs()).toUtf8().constData(),
[](const digidoc::Exception *ex) {
Expand Down Expand Up @@ -892,7 +916,7 @@ void Application::showClient(const QStringList &params, bool crypto, bool sign,
if( !w )
{
w = new MainWindow();
QWidget *prev = [=]() -> QWidget* {
QWidget *prev = [w]() -> QWidget* {
for(QWidget *top: topLevelWidgets())
{
QWidget *prev = qobject_cast<MainWindow*>(top);
Expand All @@ -901,7 +925,7 @@ void Application::showClient(const QStringList &params, 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));
Expand Down
12 changes: 12 additions & 0 deletions client/translations/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,18 @@
<source>https://www.id.ee/en/id-help/</source>
<translation>https://www.id.ee/en/id-help/</translation>
</message>
<message>
<source>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 &lt;a href=&quot;https://www.id.ee/en/article/install-id-software/&quot;&gt;www.id.ee&lt;/a&gt;. macOS users can download the latest ID-software version from the &lt;a href=&quot;https://itunes.apple.com/ee/developer/ria/id556524921?mt=12&quot;&gt;Mac App Store&lt;/a&gt;.</source>
<translation>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 &lt;a href=&quot;https://www.id.ee/en/article/install-id-software/&quot;&gt;www.id.ee&lt;/a&gt;. macOS users can download the latest ID-software version from the &lt;a href=&quot;https://itunes.apple.com/ee/developer/ria/id556524921?mt=12&quot;&gt;Mac App Store&lt;/a&gt;.</translation>
</message>
<message>
<source>Your ID-software has expired. To download the latest software version, go to the &lt;a href=&quot;https://www.id.ee/en/article/install-id-software/&quot;&gt;id.ee&lt;/a&gt; website. macOS users can download the latest ID-software version from the &lt;a href=&quot;https://itunes.apple.com/ee/developer/ria/id556524921?mt=12&quot;&gt;Mac App Store&lt;/a&gt;.</source>
<translation>Your ID-software has expired. To download the latest software version, go to the &lt;a href=&quot;https://www.id.ee/en/article/install-id-software/&quot;&gt;id.ee&lt;/a&gt; website. macOS users can download the latest ID-software version from the &lt;a href=&quot;https://itunes.apple.com/ee/developer/ria/id556524921?mt=12&quot;&gt;Mac App Store&lt;/a&gt;.</translation>
</message>
<message>
<source>An ID-software update has been found. To download the update, go to the &lt;a href=&quot;https://www.id.ee/en/article/install-id-software/&quot;&gt;id.ee&lt;/a&gt; website. macOS users can download the update from the &lt;a href=&quot;https://itunes.apple.com/ee/developer/ria/id556524921?mt=12&quot;&gt;Mac App Store&lt;/a&gt;.</source>
<translation>An ID-software update has been found. To download the update, go to the &lt;a href=&quot;https://www.id.ee/en/article/install-id-software/&quot;&gt;id.ee&lt;/a&gt; website. macOS users can download the update from the &lt;a href=&quot;https://itunes.apple.com/ee/developer/ria/id556524921?mt=12&quot;&gt;Mac App Store&lt;/a&gt;.</translation>
</message>
</context>
<context>
<name>CDocumentModel</name>
Expand Down
12 changes: 12 additions & 0 deletions client/translations/et.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,18 @@
<source>https://www.id.ee/en/id-help/</source>
<translation>https://www.id.ee/id-abikeskus/</translation>
</message>
<message>
<source>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 &lt;a href=&quot;https://www.id.ee/en/article/install-id-software/&quot;&gt;www.id.ee&lt;/a&gt;. macOS users can download the latest ID-software version from the &lt;a href=&quot;https://itunes.apple.com/ee/developer/ria/id556524921?mt=12&quot;&gt;Mac App Store&lt;/a&gt;.</source>
<translation>Sinu arvutis olev ID-tarkvara ei ole toetatud. DigiDoc4 kliendi kasutamiseks pead ID-tarkvara uuendama. Paigalda uus ID-tarkvara veebilehelt &lt;a href=&quot;https://www.id.ee/artikkel/paigalda-id-tarkvara/&quot;&gt;www.id.ee&lt;/a&gt;, macOS kasutajad saavad uusima tarkvara &lt;a href=&quot;https://itunes.apple.com/ee/developer/ria/id556524921?mt=12&quot;&gt;Mac App Store&lt;/a&gt;&apos;ist.</translation>
</message>
<message>
<source>Your ID-software has expired. To download the latest software version, go to the &lt;a href=&quot;https://www.id.ee/en/article/install-id-software/&quot;&gt;id.ee&lt;/a&gt; website. macOS users can download the latest ID-software version from the &lt;a href=&quot;https://itunes.apple.com/ee/developer/ria/id556524921?mt=12&quot;&gt;Mac App Store&lt;/a&gt;.</source>
<translation>Sinu kasutatav ID-tarkvara on aegunud. Tarkvara viimase versiooni saad alla laadida veebilehelt &lt;a href=&quot;https://www.id.ee/artikkel/paigalda-id-tarkvara/&quot;&gt;id.ee&lt;/a&gt;, macOS kasutajad saavad uusima tarkvara &lt;a href=&quot;https://itunes.apple.com/ee/developer/ria/id556524921?mt=12&quot;&gt;Mac App Store&lt;/a&gt;&apos;ist.</translation>
</message>
<message>
<source>An ID-software update has been found. To download the update, go to the &lt;a href=&quot;https://www.id.ee/en/article/install-id-software/&quot;&gt;id.ee&lt;/a&gt; website. macOS users can download the update from the &lt;a href=&quot;https://itunes.apple.com/ee/developer/ria/id556524921?mt=12&quot;&gt;Mac App Store&lt;/a&gt;.</source>
<translation>Saadaval on ID-tarkvara uuendus, mille saad paigaldada veebilehelt &lt;a href=&quot;https://www.id.ee/artikkel/paigalda-id-tarkvara/&quot;&gt;id.ee&lt;/a&gt;, macOS kasutajad saavad uuenduse alla laadida &lt;a href=&quot;https://itunes.apple.com/ee/developer/ria/id556524921?mt=12&quot;&gt;Mac App Store&lt;/a&gt;&apos;ist.</translation>
</message>
</context>
<context>
<name>CDocumentModel</name>
Expand Down
12 changes: 12 additions & 0 deletions client/translations/ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,18 @@
<source>https://www.id.ee/en/id-help/</source>
<translation>https://www.id.ee/ru/id-pomoshh/</translation>
</message>
<message>
<source>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 &lt;a href=&quot;https://www.id.ee/en/article/install-id-software/&quot;&gt;www.id.ee&lt;/a&gt;. macOS users can download the latest ID-software version from the &lt;a href=&quot;https://itunes.apple.com/ee/developer/ria/id556524921?mt=12&quot;&gt;Mac App Store&lt;/a&gt;.</source>
<translation>Программное обеспечение ID на вашем компьютере не поддерживается. Чтобы использовать программу DigiDoc4 клиент, вам необходимо обновить программное обеспечение ID. Установите новое программное обеспечение ID с веб-сайта &lt;a href=&quot;https://www.id.ee/ru/artikkel/ustanovite-id-programmu/&quot;&gt;www.id.ee&lt;/a&gt;. Пользователи macOS могут скачать последнюю версию программного обеспечения ID-карты в магазине &lt;a href=&quot;https://itunes.apple.com/ee/developer/ria/id556524921?mt=12&quot;&gt;Mac App Store&lt;/a&gt;.</translation>
</message>
<message>
<source>Your ID-software has expired. To download the latest software version, go to the &lt;a href=&quot;https://www.id.ee/en/article/install-id-software/&quot;&gt;id.ee&lt;/a&gt; website. macOS users can download the latest ID-software version from the &lt;a href=&quot;https://itunes.apple.com/ee/developer/ria/id556524921?mt=12&quot;&gt;Mac App Store&lt;/a&gt;.</source>
<translation>Вам необходимо обновить программное обеспечение ID-карты. Чтобы скачать последнюю версию программы, перейдите на сайт &lt;a href=&quot;https://www.id.ee/ru/artikkel/ustanovite-id-programmu/&quot;&gt;id.ee&lt;/a&gt;. Пользователи macOS могут скачать последнюю версию программного обеспечения ID-карты в магазине &lt;a href=&quot;https://itunes.apple.com/ee/developer/ria/id556524921?mt=12&quot;&gt;Mac App Store&lt;/a&gt;.</translation>
</message>
<message>
<source>An ID-software update has been found. To download the update, go to the &lt;a href=&quot;https://www.id.ee/en/article/install-id-software/&quot;&gt;id.ee&lt;/a&gt; website. macOS users can download the update from the &lt;a href=&quot;https://itunes.apple.com/ee/developer/ria/id556524921?mt=12&quot;&gt;Mac App Store&lt;/a&gt;.</source>
<translation>Выпущено обновление для программного обеспечения ID-карты. Чтобы скачать обновление, перейдите на сайт &lt;a href=&quot;https://www.id.ee/ru/artikkel/ustanovite-id-programmu/&quot;&gt;id.ee&lt;/a&gt;. Пользователи macOS могут скачать обновление в магазине &lt;a href=&quot;https://itunes.apple.com/ee/developer/ria/id556524921?mt=12&quot;&gt;Mac App Store&lt;/a&gt;.</translation>
</message>
</context>
<context>
<name>CDocumentModel</name>
Expand Down
2 changes: 1 addition & 1 deletion common

0 comments on commit 923e9e0

Please sign in to comment.