Skip to content

Commit

Permalink
Move version checks to DigiDoc (#133)
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 30, 2023
1 parent a84bdde commit 33d878c
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 107 deletions.
35 changes: 6 additions & 29 deletions Configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ class Configuration::Private
{
public:
void initCache(bool clear);
static bool lessThanVersion( const QString &current, const QString &available );
void setData(const QByteArray &data, const QByteArray &signature);
bool validate(const QByteArray &data, const QByteArray &signature) const;

Expand Down Expand Up @@ -103,11 +102,6 @@ void Configuration::Private::initCache(bool clear)
#endif
}

bool Configuration::Private::lessThanVersion( const QString &current, const QString &available )
{
return QVersionNumber::fromString(current) < QVersionNumber::fromString(available);
}

void Configuration::Private::setData(const QByteArray &_data, const QByteArray &_signature)
{
data = _data;
Expand All @@ -116,7 +110,7 @@ void Configuration::Private::setData(const QByteArray &_data, const QByteArray &
#ifdef Q_OS_MAC
QSettings s2(QSettings::SystemScope, nullptr);
#else
QSettings s2(QSettings::SystemScope, qApp->organizationName(), qApp->applicationName());
QSettings s2(QSettings::SystemScope, QApplication::organizationName(), QApplication::applicationName());
#endif

for(const QString &key: s2.childKeys())
Expand Down Expand Up @@ -184,7 +178,7 @@ Configuration::Configuration(QObject *parent)
d->url.adjusted(QUrl::RemoveFilename).toString(),
QFileInfo(d->url.fileName()).baseName());
d->req.setRawHeader("User-Agent", QStringLiteral("%1/%2 (%3) Lang: %4 Devices: %5")
.arg(qApp->applicationName(), qApp->applicationVersion(),
.arg(QApplication::applicationName(), QApplication::applicationVersion(),
Common::applicationOs(), Common::language(), QPCSC::instance().drivers().join('/')).toUtf8());
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
d->req.setTransferTimeout();
Expand Down Expand Up @@ -261,7 +255,7 @@ Configuration::Configuration(QObject *parent)
return;
}

#if OPENSSL_VERSION < 0x30000000L
#if OPENSSL_VERSION_NUMBER < 0x30000000L
RSA *rsa = PEM_read_bio_RSAPublicKey(bio, nullptr, nullptr, nullptr);
d->publicKey = EVP_PKEY_new();
EVP_PKEY_set1_RSA(d->publicKey, rsa);
Expand Down Expand Up @@ -308,7 +302,8 @@ Configuration::Configuration(QObject *parent)
else if(lastCheck < QDate::currentDate().addDays(-LAST_CHECK_DAYS))
update();
// DigiDoc4 updated
else if(Private::lessThanVersion(QSettings().value(QStringLiteral("LastVersion")).toString(), qApp->applicationVersion()))
else if(QVersionNumber::fromString(QSettings().value(QStringLiteral("LastVersion")).toString()) <
QVersionNumber::fromString(QApplication::applicationVersion()))
update();
#endif
}
Expand All @@ -320,24 +315,6 @@ Configuration::~Configuration()
delete d;
}

void Configuration::checkVersion(const QString &name)
{
if(Private::lessThanVersion(qApp->applicationVersion(), object()[name+"-SUPPORTED"].toString()))
Q_EMIT updateReminder(true, tr("Update is available"), 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(this, &Configuration::finished, this, [=](bool changed, const QString &){
if(changed && Private::lessThanVersion(qApp->applicationVersion(), object()[name+"-LATEST"].toString()))
Q_EMIT updateReminder(false, tr("Update is available"),
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>."));
});
}

QJsonObject Configuration::object() const
{
return d->dataobject;
Expand Down Expand Up @@ -371,5 +348,5 @@ void Configuration::update(bool force)
{
d->initCache(force);
sendRequest(d->rsaurl);
QSettings().setValue(QStringLiteral("LastVersion"), qApp->applicationVersion());
QSettings().setValue(QStringLiteral("LastVersion"), QApplication::applicationVersion());
}
2 changes: 0 additions & 2 deletions Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,11 @@ class Configuration final : public QObject
public:
explicit Configuration(QObject *parent = nullptr);
~Configuration() final;
void checkVersion(const QString &name);
QJsonObject object() const;
void update(bool force = false);

Q_SIGNALS:
void finished(bool changed, const QString &error);
void updateReminder(bool expired, const QString &title, const QString &message);

private:
QNetworkReply *sendRequest(const QUrl &url);
Expand Down
19 changes: 0 additions & 19 deletions translations/common_en.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="en">
<context>
<name>Common</name>
<message>
<source>Unknown OS</source>
<translation>Unknown OS</translation>
</message>
</context>
<context>
<name>Configuration</name>
<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>
<message>
<source>Request timed out</source>
<translation>Request timed out</translation>
Expand All @@ -30,9 +15,5 @@
<source>Your computer&apos;s configuration file is later than the server has.</source>
<translation>Your computer&apos;s configuration file is later than the server has.</translation>
</message>
<message>
<source>Update is available</source>
<translation>Update is available</translation>
</message>
</context>
</TS>
19 changes: 0 additions & 19 deletions translations/common_et.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="et">
<context>
<name>Common</name>
<message>
<source>Unknown OS</source>
<translation>Tundmatu operatsioonisüsteem</translation>
</message>
</context>
<context>
<name>Configuration</name>
<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>
<message>
<source>Request timed out</source>
<translation>Päring aegus</translation>
Expand All @@ -30,9 +15,5 @@
<source>Your computer&apos;s configuration file is later than the server has.</source>
<translation>Sinu arvutis on uuem konfiguratsioonifail kui serveris.</translation>
</message>
<message>
<source>Update is available</source>
<translation>ID-tarkvara uus versioon on saadaval</translation>
</message>
</context>
</TS>
19 changes: 0 additions & 19 deletions translations/common_pt-br.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="en">
<context>
<name>Common</name>
<message>
<source>Unknown OS</source>
<translation>SO desconhecida</translation>
</message>
</context>
<context>
<name>Configuration</name>
<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>Seu ID-software expirou. Para baixar a última versão do software, acesse a página &lt;a href=&quot;https://www.id.ee/en/article/install-id-software/&quot;&gt;id.ee&lt;/a&gt;. Usuários Mac OS X podem baixar a última versão em &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>Uma atualização do ID-software está disponível. Para baixar a atualização, acesse a página &lt;a href=&quot;https://www.id.ee/en/article/install-id-software/&quot;&gt;id.ee&lt;/a&gt;. Usuários de Mac OS X podem fazer o download da atualização na &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>Request timed out</source>
<translation>Tempo de requesição expirada</translation>
Expand All @@ -30,9 +15,5 @@
<source>Your computer&apos;s configuration file is later than the server has.</source>
<translation>O arquivo de configuração do seu computador está desatualizado em relação ao do servidor.</translation>
</message>
<message>
<source>Update is available</source>
<translation>Atualização disponível</translation>
</message>
</context>
</TS>
19 changes: 0 additions & 19 deletions translations/common_ru.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="ru">
<context>
<name>Common</name>
<message>
<source>Unknown OS</source>
<translation>Неизвестный OS</translation>
</message>
</context>
<context>
<name>Configuration</name>
<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>
<message>
<source>Request timed out</source>
<translation>Время запроса истекло</translation>
Expand All @@ -30,9 +15,5 @@
<source>Your computer&apos;s configuration file is later than the server has.</source>
<translation>Находящийся на Вашем компьютере конфигурационный файл новее файла на сервере.</translation>
</message>
<message>
<source>Update is available</source>
<translation>Доступна обновлённая версия</translation>
</message>
</context>
</TS>

0 comments on commit 33d878c

Please sign in to comment.