Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions client/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,7 @@ Application::Application( int &argc, char **argv )

// Clear obsolete registriy settings
Settings::CDOC2_NOTIFICATION.clear();
Settings::MOBILEID_ORDER.clear();
#ifndef Q_OS_DARWIN
Settings::DEFAULT_DIR.clear();
#endif
Expand Down
7 changes: 4 additions & 3 deletions client/CDocSupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,12 +201,13 @@ DDCryptoBackend::getLastErrorStr(libcdoc::result_t code) const
static bool
checkConnection()
{
if(CheckConnection().check()) {
CheckConnection check;
if(check.check()) {
return true;
}
return dispatchToMain([] {
return dispatchToMain([check] {
FadeInNotification::error(Application::mainWindow()->findChild<QWidget*>(QStringLiteral("topBar")),
QCoreApplication::translate("MainWindow", "Check internet connection"));
check.errorString());
return false;
});
}
Expand Down
3 changes: 1 addition & 2 deletions client/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ add_subdirectory(libcdoc EXCLUDE_FROM_ALL)
file(GLOB WIDGETS CONFIGURE_DEPENDS
"dialogs/*.cpp" "dialogs/*.h" "dialogs/*.ui"
"effects/*.cpp" "effects/*.h" "effects/*.ui"
"signer/*.cpp" "signer/*.h"
"widgets/*.cpp" "widgets/*.h" "widgets/*.ui"
)
add_executable(${PROJECT_NAME} WIN32 MACOSX_BUNDLE
Expand Down Expand Up @@ -66,8 +67,6 @@ add_executable(${PROJECT_NAME} WIN32 MACOSX_BUNDLE
QPCSC.h
QPKCS11.cpp
QPKCS11.h
QSigner.cpp
QSigner.h
QSmartCard.cpp
QSmartCard_p.h
QSmartCard.h
Expand Down
2 changes: 1 addition & 1 deletion client/CheckConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ QString CheckConnection::errorString() const
case QNetworkReply::ProxyAuthenticationRequiredError:
return QCoreApplication::translate("CheckConnection", "Check proxy username and password");
default:
return QCoreApplication::translate("CheckConnection", "Cannot connect to certificate status service!");
return QCoreApplication::translate("CheckConnection", "Check internet connection");
}
}

Expand Down
61 changes: 21 additions & 40 deletions client/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,15 @@
#include "DigiDoc.h"
#include "QCryptoBackend.h"
#include "QPCSC.h"
#include "QSigner.h"
#include "Settings.h"
#include "SslCertificate.h"
#include "TokenData.h"
#include "effects/FadeInNotification.h"
#include "effects/Overlay.h"
#include "dialogs/FileDialog.h"
#include "dialogs/MobileProgress.h"
#include "dialogs/RoleAddressDialog.h"
#include "dialogs/SettingsDialog.h"
#include "dialogs/SmartIDProgress.h"
#include "dialogs/SigningDialog.h"
#include "dialogs/WaitDialog.h"
#include "dialogs/WarningDialog.h"
#include "widgets/CardPopup.h"
Expand Down Expand Up @@ -94,7 +92,6 @@ MainWindow::MainWindow( QWidget *parent )

// Refresh ID card info in card widget
connect(qApp->cryptoManager(), &QCryptoManager::cacheChanged, this, &MainWindow::updateSelector);
connect(qApp->cryptoManager(), &QCryptoManager::signDataChanged, ui->signContainerPage, &ContainerPage::tokenChanged);
connect(qApp->cryptoManager(), &QCryptoManager::authDataChanged, ui->cryptoContainerPage, &ContainerPage::tokenChanged);

// Refresh card info on "My EID" page
Expand Down Expand Up @@ -123,7 +120,6 @@ MainWindow::MainWindow( QWidget *parent )
connect(ui->infoStack, &MyEidInfo::changePinClicked, this, &MainWindow::changePinClicked);
connect(ui->cardInfo, &CardWidget::selected, ui->selector, &QToolButton::toggle);

ui->signContainerPage->tokenChanged(qApp->cryptoManager()->tokensign());
ui->cryptoContainerPage->tokenChanged(qApp->cryptoManager()->tokenauth());
updateMyEID(qApp->cryptoManager()->smartcard()->tokenData());
updateMyEid(qApp->cryptoManager()->smartcard()->data());
Expand Down Expand Up @@ -221,7 +217,6 @@ void MainWindow::mouseReleaseEvent(QMouseEvent *event)
{
if(auto *cardPopup = findChild<CardPopup*>())
cardPopup->deleteLater();
ui->signContainerPage->clearPopups();
QWidget::mouseReleaseEvent(event);
}

Expand Down Expand Up @@ -286,30 +281,12 @@ void MainWindow::navigateToPage( Pages page, const QStringList &files, bool crea
selectPage(page);
}

void MainWindow::onSignAction(int action, const QString &idCode, const QString &info2)
void MainWindow::onSignAction(int action)
{
switch(action)
{
case SignatureAdd:
case SignatureToken:
sign([this](const QString &city, const QString &state, const QString &zip, const QString &country, const QString &role) {
QSigner signer(qApp->cryptoManager()->tokensign());
return digiDoc->sign(city, state, zip, country, role, &signer);
});
break;
case SignatureMobile:
sign([this, idCode, info2](const QString &city, const QString &state, const QString &zip, const QString &country, const QString &role) {
MobileProgress m(this);
return m.init(idCode, info2) &&
digiDoc->sign(city, state, zip, country, role, &m);
});
break;
case SignatureSmartID:
sign([this, idCode, info2](const QString &city, const QString &state, const QString &zip, const QString &country, const QString &role) {
SmartIDProgress s(this);
return s.init(info2, idCode, digiDoc->fileName()) &&
digiDoc->sign(city, state, zip, country, role, &s);
});
sign();
break;
case ContainerClearWarning:
ui->signature->warningIcon(false);
Expand Down Expand Up @@ -363,7 +340,7 @@ void MainWindow::convertToCDoc()
FadeInNotification::success(ui->topBar, tr("Converted to crypto container!"));
}

void MainWindow::onCryptoAction(int action, const QString &/*id*/, const QString &/*phone*/)
void MainWindow::onCryptoAction(int action)
{
switch(action)
{
Expand Down Expand Up @@ -556,41 +533,46 @@ void MainWindow::showSettings(int page)
dlg->open();
}

template<typename F>
void MainWindow::sign(F &&sign)
void MainWindow::sign()
{
if(!CheckConnection().check())
if(CheckConnection check; !check.check())
{
FadeInNotification::error(ui->topBar, tr("Check internet connection"));
FadeInNotification::error(ui->topBar, check.errorString());
return;
}

QString role, city, state, country, zip;
if(RoleAddressDialog(this).get(city, country, state, zip, role) == QDialog::Rejected)
return;

WaitDialogHolder waitDialog(this, tr("Signing"));
if(digiDoc->isPDF())
{
QString wrappedFile = digiDoc->fileName();
if(!wrap(wrappedFile, true))
QString pdfFile = digiDoc->fileName();
if(!wrap(pdfFile, true))
return;

if(!sign(city, state, zip, country, role))
SigningDialog dlg(digiDoc.get(), ui->signContainerPage);
dlg.setRoleAddress(city, country, state, zip, role);
if(dlg.exec() != QDialog::Accepted)
{
digiDoc.reset();
openFiles({std::move(wrappedFile)});
openFiles({std::move(pdfFile)});
return;
}
}
else if(!sign(city, state, zip, country, role))
return;
else
{
SigningDialog dlg(digiDoc.get(), ui->signContainerPage);
dlg.setRoleAddress(city, country, state, zip, role);
if(dlg.exec() != QDialog::Accepted)
return;
}
WaitDialogHolder waitDialog(this, tr("Signing"));

if(!digiDoc->save())
return;

ui->signContainerPage->transition(digiDoc.get());

FadeInNotification::success(ui->topBar, tr("The container has been successfully signed!"));
}

Expand Down Expand Up @@ -663,7 +645,6 @@ void MainWindow::updateMyEid(const QSmartCardData &data)
pin1Blocked || pin1Locked ||
pin2Blocked || pin2Locked ||
pukBlocked);
ui->signContainerPage->cardChanged(data.signCert(), pin2Blocked || pin2Locked);
ui->cryptoContainerPage->cardChanged(data.authCert(), pin1Blocked || pin1Locked);

using enum WarningText::WarningType;
Expand Down
7 changes: 3 additions & 4 deletions client/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,11 @@ class MainWindow final : public QWidget
void changePinClicked(QSmartCardData::PinType type, QSmartCard::PinAction action);
void convertToCDoc();
void navigateToPage(Pages page, const QStringList &files = QStringList(), bool create = true);
void onCryptoAction(int action, const QString &id, const QString &phone);
void onSignAction(int action, const QString &idCode, const QString &info2);
void onCryptoAction(int action);
void onSignAction(int action);
void openContainer(const QString &filter);
void resetDigiDoc(std::unique_ptr<DigiDoc> &&doc);
template <typename F>
void sign(F &&sign);
void sign();
void updateSelector();
void updateMyEID(const TokenData &t);
void updateMyEid(const QSmartCardData &data);
Expand Down
22 changes: 7 additions & 15 deletions client/QCryptoBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,17 +239,10 @@ void QCryptoManager::selectCard(const TokenData &token)
break;
}
}
if(isSign)
Q_EMIT signDataChanged(token);
else
if(!isSign)
Q_EMIT authDataChanged(token);
if(!other.isNull())
{
if(isSign)
Q_EMIT authDataChanged(other);
else
Q_EMIT signDataChanged(other);
}
else if(!other.isNull())
Q_EMIT authDataChanged(other);
d->smartcard.reloadCard(token, false);
}

Expand Down Expand Up @@ -310,13 +303,12 @@ void QCryptoManager::refresh()

if(cacheChangedFlag)
Q_EMIT cacheChanged();
TokenData update;
if(aold != anew)
Q_EMIT authDataChanged(update = anew);
Q_EMIT authDataChanged(anew);
if(sold != snew)
Q_EMIT signDataChanged(update = snew);
if(aold != anew || sold != snew)
d->smartcard.reloadCard(update, false);
d->smartcard.reloadCard(snew, false);
else if(aold != anew)
d->smartcard.reloadCard(anew, false);

d->operationLock.unlock();
}
1 change: 0 additions & 1 deletion client/QCryptoBackend.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ class QCryptoManager final : public QThread
Q_SIGNALS:
void cacheChanged();
void authDataChanged(const TokenData &token);
void signDataChanged(const TokenData &token);

private:
friend class QCryptoBackend;
Expand Down
1 change: 1 addition & 0 deletions client/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#pragma once

#include <QCoreApplication>
#include <QEventLoop>
#include <QIODevice>
#include <QTimer>
Expand Down
6 changes: 1 addition & 5 deletions client/common_enums.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,12 @@ enum Actions : unsigned char {
ContainerEncrypt,

EncryptContainer,
EncryptLT,
EncryptContainerSuccess,
DecryptContainer,
DecryptToken,
DecryptContainerSuccess,

SignatureAdd,
SignatureMobile,
SignatureSmartID,
SignatureToken,
EncryptLT
};

}
105 changes: 0 additions & 105 deletions client/dialogs/MobileDialog.cpp

This file was deleted.

Loading
Loading