From 1e9f205d354b87c28191042ba548db074d3bbe15 Mon Sep 17 00:00:00 2001 From: Raul Metsma Date: Mon, 6 Feb 2023 17:15:16 +0200 Subject: [PATCH] Update error description (#1153) IB-7623 Signed-off-by: Raul Metsma --- client/dialogs/MobileProgress.cpp | 79 +++++++++++------------------- client/dialogs/SmartIDProgress.cpp | 63 ++++++++---------------- client/dialogs/WarningDialog.cpp | 5 +- client/dialogs/WarningDialog.h | 2 +- client/translations/en.ts | 8 +++ client/translations/et.ts | 8 +++ client/translations/ru.ts | 8 +++ 7 files changed, 76 insertions(+), 97 deletions(-) diff --git a/client/dialogs/MobileProgress.cpp b/client/dialogs/MobileProgress.cpp index 76d9f72f0..bb83e3ed3 100644 --- a/client/dialogs/MobileProgress.cpp +++ b/client/dialogs/MobileProgress.cpp @@ -24,7 +24,6 @@ #include "Styles.h" #include "Utils.h" #include "dialogs/WarningDialog.h" -#include "dialogs/WaitDialog.h" #include #include @@ -85,13 +84,13 @@ MobileProgress::MobileProgress(QWidget *parent) { const_cast(MIDLog()).setEnabled(QtDebugMsg, QFile::exists(QStringLiteral("%1/%2.log").arg(QDir::tempPath(), qApp->applicationName()))); - d->setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint); + d->setWindowFlag(Qt::CustomizeWindowHint); d->setupUi(d); d->move(parent->geometry().center() - d->geometry().center()); d->code->setBuddy(d->signProgressBar); d->code->setFont(Styles::font(Styles::Regular, 48)); d->info->setFont(Styles::font(Styles::Regular, 14)); - d->controlCode->setFont(Styles::font(Styles::Regular, 14)); + d->controlCode->setFont(d->info->font()); d->signProgressBar->setFont(d->info->font()); #if defined(Q_OS_UNIX) && !defined(Q_OS_MAC) const auto styleSheet = R"(QProgressBar { @@ -163,9 +162,8 @@ background-color: #007aff; qCWarning(MIDLog) << err; stop(); d->hide(); - WarningDialog dlg(err, details, d->parentWidget()); - QObject::connect(&dlg, &WarningDialog::finished, &d->l, &QEventLoop::exit); - dlg.exec(); + WarningDialog *dlg = WarningDialog::show(d->parentWidget(), err, details); + QObject::connect(dlg, &WarningDialog::finished, &d->l, &QEventLoop::exit); }; switch(reply->error()) @@ -173,61 +171,45 @@ background-color: #007aff; case QNetworkReply::NoError: break; case QNetworkReply::ContentNotFoundError: - returnError(d->sessionID.isEmpty() ? tr("Account not found") : tr("Session not found")); - return; + return returnError(d->sessionID.isEmpty() ? tr("Account not found") : tr("Session not found")); case QNetworkReply::ConnectionRefusedError: - returnError(tr("%1 service has encountered technical errors. Please try again later.").arg(tr("Mobile-ID"))); - return; + return returnError(tr("%1 service has encountered technical errors. Please try again later.").arg(tr("Mobile-ID"))); case QNetworkReply::SslHandshakeFailedError: - returnError(tr("SSL handshake failed. Check the proxy settings of your computer or software upgrades.")); - return; + return returnError(tr("SSL handshake failed. Check the proxy settings of your computer or software upgrades.")); case QNetworkReply::TimeoutError: case QNetworkReply::UnknownNetworkError: - returnError(tr("Failed to connect with service server. Please check your network settings or try again later.")); - return; + return returnError(tr("Failed to connect with service server. Please check your network settings or try again later.")); case QNetworkReply::HostNotFoundError: case QNetworkReply::AuthenticationRequiredError: - returnError(tr("Failed to send request. Check your %1 service access settings.").arg(tr("mobile-ID"))); - return; + return returnError(tr("Failed to send request. Check your %1 service access settings.").arg(tr("mobile-ID"))); default: + { + const auto httpStatusCode = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); + qCWarning(MIDLog) << httpStatusCode << "Error :" << reply->error(); + switch(httpStatusCode) { - const auto httpStatusCode = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); - qCWarning(MIDLog) << httpStatusCode << "Error :" << reply->error(); - if (400 == httpStatusCode) - { - break; - } - switch(httpStatusCode) - { - case 409: - returnError(tr("Failed to send request. The number of unsuccesful request from this IP address has been exceeded. Please try again later.")); - break; - case 429: - returnError(tr("The limit for %1 digital signatures per month has been reached for this IP address. " - "Additional information").arg(tr("mobile-ID"))); - break; - default: - returnError(tr("Failed to send request. %1 service has encountered technical errors. Please try again later.").arg(tr("Mobile-ID")), reply->errorString()); - break; - } - return; + case 409: + return returnError(tr("Failed to send request. The number of unsuccesful request from this IP address has been exceeded. Please try again later.")); + case 429: + return returnError(tr("The limit for %1 digital signatures per month has been reached for this IP address. " + "Additional information").arg(tr("mobile-ID"))); + case 580: + return returnError(tr("Failed to send request. A valid session is associated with this personal code. " + "It is not possible to start a new signing before the current session expires. Please try again later.")); + default: + return returnError(tr("Failed to send request. %1 service has encountered technical errors. Please try again later.").arg(tr("Mobile-ID")), reply->errorString()); } + } } // switch (reply->error()) - static const QStringList contentType{"application/json", "application/json;charset=UTF-8"}; + static const QStringList contentType{QStringLiteral("application/json"), QStringLiteral("application/json;charset=UTF-8")}; if(!contentType.contains(reply->header(QNetworkRequest::ContentTypeHeader).toString())) - { - returnError(tr("Invalid content type header ") + reply->header(QNetworkRequest::ContentTypeHeader).toString()); - return; - } + return returnError(tr("Invalid content type header ") + reply->header(QNetworkRequest::ContentTypeHeader).toString()); QByteArray data = reply->readAll(); qCDebug(MIDLog).noquote() << data; QJsonObject result = QJsonDocument::fromJson(data, nullptr).object(); if(result.isEmpty()) - { - returnError(tr("Failed to parse JSON content")); - return; - } + return returnError(tr("Failed to parse JSON content")); if(result.contains(QStringLiteral("error"))) { @@ -344,11 +326,6 @@ std::vector MobileProgress::sign(const std::string &method, const "and enter mobile-ID PIN2-code.")); d->code->setAccessibleName(QStringLiteral("%1 %2. %3").arg(d->controlCode->text(), d->code->text(), d->info->text())); - QHash lang; - lang[QStringLiteral("et")] = QStringLiteral("EST"); - lang[QStringLiteral("en")] = QStringLiteral("ENG"); - lang[QStringLiteral("ru")] = QStringLiteral("RUS"); - QByteArray data = QJsonDocument(QJsonObject::fromVariantHash({ {"relyingPartyUUID", d->UUID.isEmpty() ? QStringLiteral("00000000-0000-0000-0000-000000000000") : d->UUID}, {"relyingPartyName", d->NAME}, @@ -356,7 +333,7 @@ std::vector MobileProgress::sign(const std::string &method, const {"phoneNumber", d->cell}, {"hash", QByteArray::fromRawData((const char*)digest.data(), int(digest.size())).toBase64()}, {"hashType", digestMethod}, - {"language", lang.value(Common::language(), QStringLiteral("EST"))}, + {"language", tr("ENG")}, {"displayText", "%1"}, {"displayTextFormat", "UCS-2"} })).toJson(); diff --git a/client/dialogs/SmartIDProgress.cpp b/client/dialogs/SmartIDProgress.cpp index 415f00b6d..e94a175e2 100644 --- a/client/dialogs/SmartIDProgress.cpp +++ b/client/dialogs/SmartIDProgress.cpp @@ -23,7 +23,6 @@ #include "Application.h" #include "Styles.h" #include "Utils.h" -#include "dialogs/WaitDialog.h" #include "dialogs/WarningDialog.h" #include @@ -95,14 +94,14 @@ SmartIDProgress::SmartIDProgress(QWidget *parent) { const_cast(SIDLog()).setEnabled(QtDebugMsg, QFile::exists(QStringLiteral("%1/%2.log").arg(QDir::tempPath(), qApp->applicationName()))); - d->setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint); + d->setWindowFlag(Qt::CustomizeWindowHint); d->setupUi(d); d->move(parent->geometry().center() - d->geometry().center()); d->signProgressBar->setMaximum(100); d->code->setBuddy(d->signProgressBar); d->code->setFont(Styles::font(Styles::Regular, 48)); d->info->setFont(Styles::font(Styles::Regular, 14)); - d->controlCode->setFont(Styles::font(Styles::Regular, 14)); + d->controlCode->setFont(d->info->font()); d->signProgressBar->setFont(d->info->font()); #if defined(Q_OS_UNIX) && !defined(Q_OS_MAC) const auto styleSheet = R"(QProgressBar { @@ -172,9 +171,8 @@ background-color: #007aff; auto returnError = [=](const QString &err, const QString &details = {}) { qCWarning(SIDLog) << err; d->hide(); - WarningDialog dlg(err, details, d->parentWidget()); - QObject::connect(&dlg, &WarningDialog::finished, &d->l, &QEventLoop::exit); - dlg.exec(); + WarningDialog *dlg = WarningDialog::show(d->parentWidget(), err, details); + QObject::connect(dlg, &WarningDialog::finished, &d->l, &QEventLoop::exit); }; switch(reply->error()) @@ -182,73 +180,52 @@ background-color: #007aff; case QNetworkReply::NoError: break; case QNetworkReply::ContentNotFoundError: - returnError(tr("Failed to sign container. Your Smart-ID transaction has expired or user account not found.")); - return; + return returnError(tr("Failed to sign container. Your Smart-ID transaction has expired or user account not found.")); case QNetworkReply::ConnectionRefusedError: - returnError(tr("%1 service has encountered technical errors. Please try again later.").arg(tr("Smart-ID"))); - return; + return returnError(tr("%1 service has encountered technical errors. Please try again later.").arg(tr("Smart-ID"))); case QNetworkReply::SslHandshakeFailedError: - returnError(tr("SSL handshake failed. Check the proxy settings of your computer or software upgrades.")); - return; + return returnError(tr("SSL handshake failed. Check the proxy settings of your computer or software upgrades.")); case QNetworkReply::TimeoutError: case QNetworkReply::UnknownNetworkError: - returnError(tr("Failed to connect with service server. Please check your network settings or try again later.")); - return; - case QNetworkReply::ProtocolInvalidOperationError: - qCWarning(SIDLog) << reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); - returnError(reply->readAll()); - return; + return returnError(tr("Failed to connect with service server. Please check your network settings or try again later.")); case QNetworkReply::HostNotFoundError: case QNetworkReply::AuthenticationRequiredError: - returnError(tr("Failed to send request. Check your %1 service access settings.").arg(tr("Smart-ID"))); - return; + return returnError(tr("Failed to send request. Check your %1 service access settings.").arg(tr("Smart-ID"))); default: const auto httpStatusCode = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); qCWarning(SIDLog) << httpStatusCode << "Error :" << reply->error(); switch (httpStatusCode) { case 403: - returnError(tr("Failed to sign container. Check your %1 service access settings. " + return returnError(tr("Failed to sign container. Check your %1 service access settings. " "Additional information").arg(tr("Smart-ID"))); - return; case 409: - returnError(tr("Failed to send request. The number of unsuccesful request from this IP address has been exceeded. Please try again later.")); - return; + return returnError(tr("Failed to send request. The number of unsuccesful request from this IP address has been exceeded. Please try again later.")); case 429: - returnError(tr("The limit for %1 digital signatures per month has been reached for this IP address. " + return returnError(tr("The limit for %1 digital signatures per month has been reached for this IP address. " "Additional information").arg(tr("Smart-ID"))); - return; case 471: - returnError(tr("Your Smart-ID certificate level must be qualified to sign documents in DigiDoc4 Client.")); - return; + return returnError(tr("Your Smart-ID certificate level must be qualified to sign documents in DigiDoc4 Client.")); case 480: - returnError(tr("Your signing software needs an upgrade. Please update your ID software, which you can get from " + return returnError(tr("Your signing software needs an upgrade. Please update your ID software, which you can get from " "www.id.ee. Additional info is available ID-helpline (+372) 666 8888.")); - return; case 580: - returnError(tr("%1 service has encountered technical errors. Please try again later.").arg(QLatin1String("Smart-ID"))); - return; + return returnError(tr("Failed to send request. A valid session is associated with this personal code. " + "It is not possible to start a new signing before the current session expires. Please try again later.")); default: - returnError(tr("Failed to send request. %1 service has encountered technical errors. Please try again later.").arg(QLatin1String("Smart-ID")), reply->errorString()); - return; + return returnError(tr("Failed to send request. %1 service has encountered technical errors. Please try again later.").arg(QLatin1String("Smart-ID")), reply->errorString()); } } - static const QStringList contentType{"application/json", "application/json;charset=UTF-8"}; + static const QStringList contentType{QStringLiteral("application/json"), QStringLiteral("application/json;charset=UTF-8")}; if(!contentType.contains(reply->header(QNetworkRequest::ContentTypeHeader).toString())) - { - returnError(tr("Invalid content type header ") + reply->header(QNetworkRequest::ContentTypeHeader).toString()); - return; - } + return returnError(tr("Invalid content type header ") + reply->header(QNetworkRequest::ContentTypeHeader).toString()); QByteArray data = reply->readAll(); reply->deleteLater(); qCDebug(SIDLog).noquote() << data; QJsonObject result = QJsonDocument::fromJson(data, nullptr).object(); if(result.isEmpty()) - { - returnError(tr("Failed to parse JSON content")); - return; - } + return returnError(tr("Failed to parse JSON content")); if(d->sessionID.isEmpty()) d->sessionID = result.value(QLatin1String("sessionID")).toString(); else if(result.value(QLatin1String("state")).toString() != QLatin1String("RUNNING")) diff --git a/client/dialogs/WarningDialog.cpp b/client/dialogs/WarningDialog.cpp index 73b51025c..23c7bd831 100644 --- a/client/dialogs/WarningDialog.cpp +++ b/client/dialogs/WarningDialog.cpp @@ -27,7 +27,7 @@ WarningDialog::WarningDialog(const QString &text, const QString &details, QWidge , ui(new Ui::WarningDialog) { ui->setupUi(this); - setWindowFlags( Qt::Dialog | Qt::CustomizeWindowHint ); + setWindowFlag(Qt::CustomizeWindowHint); connect( ui->cancel, &QPushButton::clicked, this, &WarningDialog::reject ); connect( this, &WarningDialog::finished, this, &WarningDialog::close ); @@ -112,9 +112,10 @@ void WarningDialog::setText(const QString& text) adjustSize(); } -void WarningDialog::show(QWidget *parent, const QString &text, const QString &details) +WarningDialog* WarningDialog::show(QWidget *parent, const QString &text, const QString &details) { WarningDialog *dlg = new WarningDialog(text, details, parent); dlg->setAttribute(Qt::WA_DeleteOnClose); dlg->open(); + return dlg; } diff --git a/client/dialogs/WarningDialog.h b/client/dialogs/WarningDialog.h index d3293f12e..88c0e5fc8 100644 --- a/client/dialogs/WarningDialog.h +++ b/client/dialogs/WarningDialog.h @@ -41,7 +41,7 @@ class WarningDialog : public QDialog void setCancelText(const QString& label); void resetCancelStyle(); void setText(const QString& text); - static void show(QWidget *parent, const QString &text, const QString &details = {}); + static WarningDialog *show(QWidget *parent, const QString &text, const QString &details = {}); private: Ui::WarningDialog *ui; diff --git a/client/translations/en.ts b/client/translations/en.ts index 9d0b2d428..b615d231f 100644 --- a/client/translations/en.ts +++ b/client/translations/en.ts @@ -1929,6 +1929,14 @@ and enter Smart-ID PIN2-code. Failed to sign container. You need to update your Smart-ID application to sign documents in DigiDoc4 Client. Failed to sign container. You need to update your Smart-ID application to sign documents in DigiDoc4 Client. + + Failed to send request. A valid session is associated with this personal code. It is not possible to start a new signing before the current session expires. Please try again later. + Failed to send request. A valid session is associated with this personal code. It is not possible to start a new signing before the current session expires. Please try again later. + + + ENG + ENG + NoCardInfo diff --git a/client/translations/et.ts b/client/translations/et.ts index f17fdbed6..b6d277383 100644 --- a/client/translations/et.ts +++ b/client/translations/et.ts @@ -1929,6 +1929,14 @@ ja sisesta nutiseadmes Smart-ID PIN2-kood. Failed to sign container. You need to update your Smart-ID application to sign documents in DigiDoc4 Client. Ümbriku allkirjastamine ebaõnnestus. DigiDoc4 kliendis allkirjastamiseks pead Smart-ID rakendust uuendama. + + Failed to send request. A valid session is associated with this personal code. It is not possible to start a new signing before the current session expires. Please try again later. + Päringu saatmine ebaõnnestus. Selle isikukoodiga on seotud kehtiv sessioon. Enne kehtiva sessiooni aegumist ei ole võimalik uut allkirjastamist alustada. Palun proovige mõne aja pärast uuesti. + + + ENG + EST + NoCardInfo diff --git a/client/translations/ru.ts b/client/translations/ru.ts index ee0aa5955..fd81bdf5c 100644 --- a/client/translations/ru.ts +++ b/client/translations/ru.ts @@ -1932,6 +1932,14 @@ and enter Smart-ID PIN2-code. Failed to sign container. You need to update your Smart-ID application to sign documents in DigiDoc4 Client. Не удалось подписать контейнер. Для подписания с помощью Smart-ID в программе DigiDoc4 клиент нужно обновить приложение Smart-ID. + + Failed to send request. A valid session is associated with this personal code. It is not possible to start a new signing before the current session expires. Please try again later. + Не удалось отправить запрос. С данным персональным номером связана действующая сессия. До истечения действующей сессии невозможно начать новое подписание. Пожалуйста, попробуйте позже. + + + ENG + RUS + NoCardInfo