Skip to content

Commit 58f650e

Browse files
committed
Move QPCSC to digidoc and increase version number
IB-7927 Signed-off-by: Raul Metsma <[email protected]>
1 parent b331f52 commit 58f650e

22 files changed

+875
-70
lines changed

.github/workflows/build.yml

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
container: ubuntu:${{ matrix.container }}
5757
strategy:
5858
matrix:
59-
container: ['20.04', '22.04', '24.04']
59+
container: ['20.04', '22.04', '24.04', '24.10']
6060
env:
6161
DEBIAN_FRONTEND: noninteractive
6262
DEBFULLNAME: github-actions
@@ -103,18 +103,12 @@ jobs:
103103
container: fedora:${{ matrix.container }}
104104
strategy:
105105
matrix:
106-
container: [39, 40]
106+
container: [40, 41]
107107
steps:
108108
- name: Install Deps
109109
run: |
110110
dnf install -y --setopt=install_weak_deps=False \
111111
git gcc-c++ cmake rpm-build gettext openssl-devel openldap-devel pcsc-lite-devel qt6-qtsvg-devel qt6-qttools-devel flatbuffers-devel flatbuffers-compiler zlib-devel
112-
- name: Install CMake
113-
if: matrix.container == 39
114-
run: |
115-
dnf install -y --setopt=install_weak_deps=False wget
116-
wget -q https://github.com/Kitware/CMake/releases/download/v3.28.1/cmake-3.28.1-linux-x86_64.sh
117-
sh cmake-3.28.1-linux-x86_64.sh --skip-license --prefix=/usr/local
118112
- name: Checkout
119113
uses: actions/checkout@v4
120114
with:
@@ -143,10 +137,8 @@ jobs:
143137
runs-on: ${{ matrix.image }}
144138
strategy:
145139
matrix:
146-
vcver: [142, 143]
140+
vcver: [143]
147141
include:
148-
- vcver: 142
149-
image: windows-2019
150142
- vcver: 143
151143
image: windows-2022
152144
env:
@@ -208,7 +200,7 @@ jobs:
208200
coverity:
209201
name: Run Coverity tests
210202
if: github.repository == 'open-eid/DigiDoc4-Client' && contains(github.ref, 'coverity_scan')
211-
runs-on: ubuntu-22.04
203+
runs-on: ubuntu-24.04
212204
env:
213205
TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }}
214206
PROJECTNAME: open-eid/DigiDoc4-Client
@@ -222,7 +214,7 @@ jobs:
222214
with:
223215
workflow: build.yml
224216
branch: master
225-
name: ubuntu_22.04
217+
name: ubuntu_24.04
226218
path: libdigidocpp-pkg
227219
repo: open-eid/libdigidocpp
228220
- name: Install dependencies
@@ -251,7 +243,7 @@ jobs:
251243
codeql:
252244
name: Run CodeQL tests
253245
if: github.repository == 'open-eid/DigiDoc4-Client'
254-
runs-on: ubuntu-22.04
246+
runs-on: ubuntu-24.04
255247
permissions:
256248
security-events: write
257249
steps:
@@ -264,7 +256,7 @@ jobs:
264256
with:
265257
workflow: build.yml
266258
branch: master
267-
name: ubuntu_22.04
259+
name: ubuntu_24.04
268260
path: libdigidocpp-pkg
269261
repo: open-eid/libdigidocpp
270262
- name: Install dependencies

CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16)
22
if(NOT EXISTS ${CMAKE_SOURCE_DIR}/cmake/modules/VersionInfo.cmake)
33
message(FATAL_ERROR "cmake submodule directory empty, did you 'git clone --recursive'?")
44
endif()
5-
project(qdigidoc4 VERSION 4.6.1)
5+
project(qdigidoc4 VERSION 4.7.0)
66

77
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)
88
set(CMAKE_INCLUDE_CURRENT_DIR ON)
@@ -11,7 +11,6 @@ set(CMAKE_AUTOMOC ON)
1111
include( GNUInstallDirs )
1212
include( VersionInfo )
1313

14-
find_package( PKCS11 )
1514
find_package(LibDigiDocpp 4.0.0 REQUIRED)
1615
find_package( LDAP REQUIRED )
1716
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED)
@@ -25,6 +24,8 @@ set_env(CDOC2_GET_URL "https://cdoc2-keyserver-get" CACHE STRING "CDoc 2.0 Key S
2524
set_env(CDOC2_POST_URL "https://cdoc2-keyserver-post" CACHE STRING "CDoc 2.0 Key Server post URL")
2625
set_env( MOBILEID_URL "https://dd-mid.ria.ee/mid-api" CACHE STRING "URL for Mobile-ID" )
2726
set_env( SMARTID_URL "https://dd-sid.ria.ee/v1" CACHE STRING "URL for Smart-ID" )
27+
set(CMAKE_CXX_STANDARD 20)
28+
set(CMAKE_CXX_STANDARD_REQUIRED YES)
2829
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION YES)
2930
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_DEBUG NO)
3031
if(CMAKE_CXX_COMPILER_ID MATCHES "AppleClang")

client/Application.cpp

Lines changed: 58 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121

2222
#include "Application.h"
2323

24+
#include "Common.h"
25+
#include "Configuration.h"
2426
#include "MainWindow.h"
2527
#include "QSigner.h"
2628
#include "QSmartCard.h"
@@ -40,7 +42,6 @@ class MacMenuBar {};
4042
#include "dialogs/WarningDialog.h"
4143
#include "effects/Overlay.h"
4244

43-
#include <common/Configuration.h>
4445
#include <optional>
4546

4647
#include <digidocpp/Container.h>
@@ -308,13 +309,35 @@ class Application::Private
308309
};
309310

310311
Application::Application( int &argc, char **argv )
311-
#ifdef Q_OS_MAC
312-
: Common(argc, argv, QStringLiteral("qdigidoc4"), QStringLiteral(":/images/Icon.svg"))
313-
#else
314-
: Common(argc, argv, QStringLiteral("qdigidoc4"), QStringLiteral(":/images/digidoc_128.png"))
315-
#endif
312+
: BaseApplication(argc, argv)
316313
, d(new Private)
317314
{
315+
setApplicationName(QStringLiteral("qdigidoc4"));
316+
setApplicationVersion(QStringLiteral("%1.%2.%3.%4")
317+
.arg( MAJOR_VER ).arg( MINOR_VER ).arg( RELEASE_VER ).arg( BUILD_VER ) );
318+
setOrganizationDomain(QStringLiteral("ria.ee"));
319+
setOrganizationName(QStringLiteral("RIA"));
320+
setWindowIcon(QIcon(QStringLiteral(":/images/Icon.svg")));
321+
if(QFile::exists(QStringLiteral("%1/%2.log").arg(QDir::tempPath(), applicationName())))
322+
qInstallMessageHandler(msgHandler);
323+
324+
Q_INIT_RESOURCE(common_tr);
325+
#if defined(Q_OS_WIN)
326+
AllowSetForegroundWindow( ASFW_ANY );
327+
#ifdef NDEBUG
328+
setLibraryPaths({ applicationDirPath() });
329+
#endif
330+
#elif defined(Q_OS_MAC)
331+
qputenv("OPENSSL_CONF", applicationDirPath().toUtf8() + "../Resources/openssl.cnf");
332+
#ifdef NDEBUG
333+
setLibraryPaths({ applicationDirPath() + "/../PlugIns" });
334+
#endif
335+
#endif
336+
setStyleSheet(QStringLiteral(
337+
"QDialogButtonBox { dialogbuttonbox-buttons-have-icons: 0; }\n"));
338+
339+
QNetworkProxyFactory::setUseSystemConfiguration(true);
340+
318341
QStringList args = arguments();
319342
args.removeFirst();
320343
#ifndef Q_OS_MAC
@@ -432,7 +455,7 @@ Application::Application( int &argc, char **argv )
432455
updateTSLCache(QDateTime::currentDateTimeUtc().addDays(-7));
433456

434457
digidoc::initialize(applicationName().toUtf8().constData(), QStringLiteral("%1/%2 (%3)")
435-
.arg(applicationName(), applicationVersion(), applicationOs()).toUtf8().constData(),
458+
.arg(applicationName(), applicationVersion(), Common::applicationOs()).toUtf8().constData(),
436459
[](const digidoc::Exception *ex) {
437460
qDebug() << "TSL loading finished";
438461
Q_EMIT qApp->TSLLoadingFinished();
@@ -627,9 +650,9 @@ bool Application::event(QEvent *event)
627650
// Load here because cocoa NSApplication overides events
628651
case QEvent::ApplicationActivate:
629652
initMacEvents();
630-
return Common::event(event);
653+
return BaseApplication::event(event);
631654
#endif
632-
default: return Common::event(event);
655+
default: return BaseApplication::event(event);
633656
}
634657
}
635658

@@ -756,6 +779,32 @@ QWidget* Application::mainWindow()
756779
return nullptr;
757780
}
758781

782+
void Application::msgHandler(QtMsgType type, const QMessageLogContext &ctx, const QString &msg)
783+
{
784+
QFile f(QStringLiteral("%1/%2.log").arg(QDir::tempPath(), applicationName()));
785+
if(!f.open( QFile::Append ))
786+
return;
787+
f.write(QDateTime::currentDateTime().toString(QStringLiteral("yyyy-MM-dd hh:mm:ss ")).toUtf8());
788+
switch(type)
789+
{
790+
case QtDebugMsg: f.write("D"); break;
791+
case QtWarningMsg: f.write("W"); break;
792+
case QtCriticalMsg: f.write("C"); break;
793+
case QtFatalMsg: f.write("F"); break;
794+
default: f.write("I"); break;
795+
}
796+
f.write(QStringLiteral(" %1 ").arg(QLatin1String(ctx.category)).toUtf8());
797+
if(ctx.line > 0)
798+
{
799+
f.write(QStringLiteral("%1:%2 \"%3\" ")
800+
.arg(QFileInfo(QString::fromLatin1(ctx.file)).fileName())
801+
.arg(ctx.line)
802+
.arg(QLatin1String(ctx.function)).toUtf8());
803+
}
804+
f.write(msg.toUtf8());
805+
f.write("\n");
806+
}
807+
759808
bool Application::notify(QObject *object, QEvent *event)
760809
{
761810
try

client/Application.h

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,15 @@
1919

2020
#pragma once
2121

22-
#include <common/Common.h>
22+
#include <QtCore/QtGlobal>
2323

24-
#include <QtCore/QStringList>
25-
#include <QtCore/QVariant>
24+
#ifdef Q_OS_MAC
25+
#include <QtWidgets/QApplication>
26+
using BaseApplication = QApplication;
27+
#else
28+
#include "qtsingleapplication/src/QtSingleApplication"
29+
using BaseApplication = QtSingleApplication;
30+
#endif
2631

2732
#if defined(qApp)
2833
#undef qApp
@@ -33,12 +38,12 @@ namespace digidoc { class Exception; }
3338
class Configuration;
3439
class QAction;
3540
class QSigner;
36-
class Application final: public Common
41+
class Application final: public BaseApplication
3742
{
3843
Q_OBJECT
3944

4045
public:
41-
enum ConfParameter
46+
enum ConfParameter : quint8
4247
{
4348
SiVaUrl,
4449
ProxyHost,
@@ -86,6 +91,7 @@ private Q_SLOTS:
8691
private:
8792
bool event(QEvent *event) final;
8893
static void closeWindow();
94+
static void msgHandler(QtMsgType type, const QMessageLogContext &ctx, const QString &msg);
8995
static void parseArgs(const QString &msg = {});
9096
static void parseArgs(QStringList args);
9197
static void showWarning(const QString &msg, const digidoc::Exception &e);
@@ -102,7 +108,7 @@ private Q_SLOTS:
102108
class REOpenEvent: public QEvent
103109
{
104110
public:
105-
enum { Type = QEvent::User + 1 };
111+
enum : quint16 { Type = QEvent::User + 1 };
106112
REOpenEvent(): QEvent( QEvent::Type(Type) ) {}
107113
};
108114

client/CMakeLists.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ add_executable(${PROJECT_NAME} WIN32 MACOSX_BUNDLE
7373
QCardLock.h
7474
QCryptoBackend.cpp
7575
QCryptoBackend.h
76+
QPCSC.cpp
77+
QPCSC_p.h
78+
QPCSC.h
7679
QPKCS11.cpp
7780
QPKCS11.h
7881
QSigner.cpp
@@ -118,7 +121,7 @@ set_target_properties(${PROJECT_NAME} PROPERTIES
118121
MACOSX_BUNDLE_BUNDLE_NAME ${PROJECT_NAME}
119122
MACOSX_BUNDLE_GUI_IDENTIFIER "ee.ria.${PROJECT_NAME}"
120123
)
121-
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR} ${LIBDIGIDOCPP_INCLUDE_DIR})
124+
target_include_directories(${PROJECT_NAME} PRIVATE ${LIBDIGIDOCPP_INCLUDE_DIR})
122125
target_compile_definitions(${PROJECT_NAME} PRIVATE
123126
CDOC2_GET_URL="${CDOC2_GET_URL}"
124127
CDOC2_POST_URL="${CDOC2_POST_URL}"
@@ -160,6 +163,7 @@ if( APPLE )
160163
set_source_files_properties( Application_mac.mm dialogs/CertificateDetails_mac.mm PROPERTIES COMPILE_FLAGS "-fobjc-arc" )
161164
set_source_files_properties( LdapSearch.cpp PROPERTIES COMPILE_FLAGS "-Wno-deprecated-declarations" )
162165
target_link_libraries(${PROJECT_NAME} "-framework Quartz" "-fobjc-arc")
166+
find_library(PKCS11_MODULE NAMES opensc-pkcs11.so HINTS /Library/OpenSC/lib)
163167
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
164168
COMMAND cp -a ${PKCS11_MODULE} $<TARGET_FILE_DIR:${PROJECT_NAME}>
165169
COMMAND mkdir -p $<TARGET_BUNDLE_CONTENT_DIR:${PROJECT_NAME}>/Library/QuickLook
@@ -229,7 +233,6 @@ elseif(WIN32)
229233
-ext WixToolset.UI.wixext
230234
-bv WixUIDialogBmp=${CMAKE_SOURCE_DIR}/cmake/modules/dlgbmp.bmp
231235
-bv WixUIBannerBmp=${CMAKE_SOURCE_DIR}/cmake/modules/banner.bmp
232-
-d MSI_VERSION=${VERSION}
233236
-d ico_path=${CMAKE_CURRENT_SOURCE_DIR}/images/digidoc.ico
234237
-d libs_path=${LIBS_PATH}
235238
-d client_path=$<TARGET_FILE:${PROJECT_NAME}>

client/CheckConnection.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "CheckConnection.h"
2121

2222
#include "Application.h"
23+
#include "Common.h"
2324

2425
#include <QtCore/QCoreApplication>
2526
#include <QtCore/QEventLoop>
@@ -42,7 +43,6 @@ bool CheckConnection::check(const QUrl &url)
4243
return m_error == QNetworkReply::NoError;
4344
}
4445

45-
QNetworkReply::NetworkError CheckConnection::error() const { return m_error; }
4646
QString CheckConnection::errorDetails() const { return qtmessage; }
4747
QString CheckConnection::errorString() const
4848
{
@@ -106,8 +106,10 @@ QSslConfiguration CheckConnection::sslConfiguration(const QByteArray &add)
106106
{
107107
QSslConfiguration ssl = QSslConfiguration::defaultConfiguration();
108108
#ifdef CONFIG_URL
109+
const auto list = Application::confValue(QLatin1String("CERT-BUNDLE")).toArray();
109110
QList<QSslCertificate> trusted;
110-
for(const auto &cert: Application::confValue(QLatin1String("CERT-BUNDLE")).toArray())
111+
trusted.reserve(list.size());
112+
for(const auto &cert: list)
111113
trusted.append(QSslCertificate(QByteArray::fromBase64(cert.toString().toLatin1()), QSsl::Der));
112114
if(!add.isEmpty())
113115
trusted.append(QSslCertificate(QByteArray::fromBase64(add), QSsl::Der));

client/CheckConnection.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ class CheckConnection
2525
{
2626
public:
2727
bool check(const QUrl &url = QStringLiteral("https://id.eesti.ee/config.json"));
28-
QNetworkReply::NetworkError error() const;
2928
QString errorString() const;
3029
QString errorDetails() const;
3130

client/Diagnostics.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "Diagnostics.h"
2020

2121
#include "Application.h"
22+
#include "Common.h"
2223
#include "QPCSC.h"
2324
#include "Settings.h"
2425

@@ -148,6 +149,6 @@ void Diagnostics::generalInfo(QTextStream &s)
148149
}
149150

150151
#ifdef Q_OS_WIN
151-
s << "<b>" << tr("Smart Card reader drivers") << ":</b><br />" << QPCSC::instance().drivers().join(QLatin1String("<br />"));
152+
s << "<b>" << tr("Smart Card reader drivers") << ":</b><br />" << Common::drivers().join(QLatin1String("<br />"));
152153
#endif
153154
}

client/Diagnostics_unix.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
#include "Common.h"
2323

24+
#include <QtCore/QCoreApplication>
2425
#include <QtCore/QFile>
2526
#include <QtCore/QRegularExpression>
2627
#include <QtCore/QTextStream>

client/Diagnostics_win.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
#include "Common.h"
2323

24+
#include <QtCore/QCoreApplication>
2425
#include <QtCore/QProcess>
2526
#include <QtCore/QRegularExpression>
2627
#include <QtCore/QSettings>
@@ -145,7 +146,7 @@ void Diagnostics::run()
145146
+ ";C:\\Program Files\\Open-EID"
146147
+ ";C:\\Program Files\\EstIDMinidriver Minidriver"
147148
+ ";C:\\Program Files (x86)\\EstIDMinidriver Minidriver");
148-
SetDllDirectory(LPCWSTR(qApp->applicationDirPath().utf16()));
149+
SetDllDirectory(LPCWSTR(QCoreApplication::applicationDirPath().utf16()));
149150
static const QStringList dlls{
150151
"digidocpp", "qdigidoc4.exe", "EsteidShellExtension", "id-updater.exe",
151152
"EstIDMinidriver", "EstIDMinidriver64", "web-eid.exe",

0 commit comments

Comments
 (0)