Skip to content

Commit

Permalink
Move QPCSC to digidoc and increase version number
Browse files Browse the repository at this point in the history
IB-7927

Signed-off-by: Raul Metsma <[email protected]>
  • Loading branch information
metsma committed Nov 8, 2024
1 parent b331f52 commit 9cd4149
Show file tree
Hide file tree
Showing 21 changed files with 868 additions and 61 deletions.
22 changes: 7 additions & 15 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
container: ubuntu:${{ matrix.container }}
strategy:
matrix:
container: ['20.04', '22.04', '24.04']
container: ['20.04', '22.04', '24.04', '24.10']
env:
DEBIAN_FRONTEND: noninteractive
DEBFULLNAME: github-actions
Expand Down Expand Up @@ -103,18 +103,12 @@ jobs:
container: fedora:${{ matrix.container }}
strategy:
matrix:
container: [39, 40]
container: [40, 41]
steps:
- name: Install Deps
run: |
dnf install -y --setopt=install_weak_deps=False \
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
- name: Install CMake
if: matrix.container == 39
run: |
dnf install -y --setopt=install_weak_deps=False wget
wget -q https://github.com/Kitware/CMake/releases/download/v3.28.1/cmake-3.28.1-linux-x86_64.sh
sh cmake-3.28.1-linux-x86_64.sh --skip-license --prefix=/usr/local
- name: Checkout
uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -143,10 +137,8 @@ jobs:
runs-on: ${{ matrix.image }}
strategy:
matrix:
vcver: [142, 143]
vcver: [143]
include:
- vcver: 142
image: windows-2019
- vcver: 143
image: windows-2022
env:
Expand Down Expand Up @@ -208,7 +200,7 @@ jobs:
coverity:
name: Run Coverity tests
if: github.repository == 'open-eid/DigiDoc4-Client' && contains(github.ref, 'coverity_scan')
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
env:
TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }}
PROJECTNAME: open-eid/DigiDoc4-Client
Expand All @@ -222,7 +214,7 @@ jobs:
with:
workflow: build.yml
branch: master
name: ubuntu_22.04
name: ubuntu_24.04
path: libdigidocpp-pkg
repo: open-eid/libdigidocpp
- name: Install dependencies
Expand Down Expand Up @@ -251,7 +243,7 @@ jobs:
codeql:
name: Run CodeQL tests
if: github.repository == 'open-eid/DigiDoc4-Client'
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
permissions:
security-events: write
steps:
Expand All @@ -264,7 +256,7 @@ jobs:
with:
workflow: build.yml
branch: master
name: ubuntu_22.04
name: ubuntu_24.04
path: libdigidocpp-pkg
repo: open-eid/libdigidocpp
- name: Install dependencies
Expand Down
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16)
if(NOT EXISTS ${CMAKE_SOURCE_DIR}/cmake/modules/VersionInfo.cmake)
message(FATAL_ERROR "cmake submodule directory empty, did you 'git clone --recursive'?")
endif()
project(qdigidoc4 VERSION 4.6.1)
project(qdigidoc4 VERSION 4.7.0)

set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
Expand All @@ -11,7 +11,6 @@ set(CMAKE_AUTOMOC ON)
include( GNUInstallDirs )
include( VersionInfo )

find_package( PKCS11 )
find_package(LibDigiDocpp 4.0.0 REQUIRED)
find_package( LDAP REQUIRED )
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED)
Expand All @@ -25,6 +24,8 @@ set_env(CDOC2_GET_URL "https://cdoc2-keyserver-get" CACHE STRING "CDoc 2.0 Key S
set_env(CDOC2_POST_URL "https://cdoc2-keyserver-post" CACHE STRING "CDoc 2.0 Key Server post URL")
set_env( MOBILEID_URL "https://dd-mid.ria.ee/mid-api" CACHE STRING "URL for Mobile-ID" )
set_env( SMARTID_URL "https://dd-sid.ria.ee/v1" CACHE STRING "URL for Smart-ID" )
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED YES)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION YES)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_DEBUG NO)
if(CMAKE_CXX_COMPILER_ID MATCHES "AppleClang")
Expand Down
67 changes: 58 additions & 9 deletions client/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

#include "Application.h"

#include "Common.h"
#include "Configuration.h"
#include "MainWindow.h"
#include "QSigner.h"
#include "QSmartCard.h"
Expand All @@ -40,7 +42,6 @@ class MacMenuBar {};
#include "dialogs/WarningDialog.h"
#include "effects/Overlay.h"

#include <common/Configuration.h>
#include <optional>

#include <digidocpp/Container.h>
Expand Down Expand Up @@ -308,13 +309,35 @@ class Application::Private
};

Application::Application( int &argc, char **argv )
#ifdef Q_OS_MAC
: Common(argc, argv, QStringLiteral("qdigidoc4"), QStringLiteral(":/images/Icon.svg"))
#else
: Common(argc, argv, QStringLiteral("qdigidoc4"), QStringLiteral(":/images/digidoc_128.png"))
#endif
: BaseApplication(argc, argv)
, d(new Private)
{
setApplicationName(QStringLiteral("qdigidoc4"));
setApplicationVersion(QStringLiteral("%1.%2.%3.%4")
.arg( MAJOR_VER ).arg( MINOR_VER ).arg( RELEASE_VER ).arg( BUILD_VER ) );
setOrganizationDomain(QStringLiteral("ria.ee"));
setOrganizationName(QStringLiteral("RIA"));
setWindowIcon(QIcon(QStringLiteral(":/images/Icon.svg")));
if(QFile::exists(QStringLiteral("%1/%2.log").arg(QDir::tempPath(), applicationName())))
qInstallMessageHandler(msgHandler);

Q_INIT_RESOURCE(common_tr);
#if defined(Q_OS_WIN)
AllowSetForegroundWindow( ASFW_ANY );
#ifdef NDEBUG
setLibraryPaths({ applicationDirPath() });
#endif
#elif defined(Q_OS_MAC)
qputenv("OPENSSL_CONF", applicationDirPath().toUtf8() + "../Resources/openssl.cnf");
#ifdef NDEBUG
setLibraryPaths({ applicationDirPath() + "/../PlugIns" });
#endif
#endif
setStyleSheet(QStringLiteral(
"QDialogButtonBox { dialogbuttonbox-buttons-have-icons: 0; }\n"));

QNetworkProxyFactory::setUseSystemConfiguration(true);

QStringList args = arguments();
args.removeFirst();
#ifndef Q_OS_MAC
Expand Down Expand Up @@ -432,7 +455,7 @@ Application::Application( int &argc, char **argv )
updateTSLCache(QDateTime::currentDateTimeUtc().addDays(-7));

digidoc::initialize(applicationName().toUtf8().constData(), QStringLiteral("%1/%2 (%3)")
.arg(applicationName(), applicationVersion(), applicationOs()).toUtf8().constData(),
.arg(applicationName(), applicationVersion(), Common::applicationOs()).toUtf8().constData(),
[](const digidoc::Exception *ex) {
qDebug() << "TSL loading finished";
Q_EMIT qApp->TSLLoadingFinished();
Expand Down Expand Up @@ -627,9 +650,9 @@ bool Application::event(QEvent *event)
// Load here because cocoa NSApplication overides events
case QEvent::ApplicationActivate:
initMacEvents();
return Common::event(event);
return BaseApplication::event(event);
#endif
default: return Common::event(event);
default: return BaseApplication::event(event);
}
}

Expand Down Expand Up @@ -756,6 +779,32 @@ QWidget* Application::mainWindow()
return nullptr;
}

void Application::msgHandler(QtMsgType type, const QMessageLogContext &ctx, const QString &msg)
{
QFile f(QStringLiteral("%1/%2.log").arg(QDir::tempPath(), applicationName()));
if(!f.open( QFile::Append ))
return;
f.write(QDateTime::currentDateTime().toString(QStringLiteral("yyyy-MM-dd hh:mm:ss ")).toUtf8());
switch(type)
{
case QtDebugMsg: f.write("D"); break;
case QtWarningMsg: f.write("W"); break;
case QtCriticalMsg: f.write("C"); break;
case QtFatalMsg: f.write("F"); break;
default: f.write("I"); break;
}
f.write(QStringLiteral(" %1 ").arg(QLatin1String(ctx.category)).toUtf8());
if(ctx.line > 0)
{
f.write(QStringLiteral("%1:%2 \"%3\" ")
.arg(QFileInfo(QString::fromLatin1(ctx.file)).fileName())
.arg(ctx.line)
.arg(QLatin1String(ctx.function)).toUtf8());
}
f.write(msg.toUtf8());
f.write("\n");
}

bool Application::notify(QObject *object, QEvent *event)
{
try
Expand Down
18 changes: 12 additions & 6 deletions client/Application.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,15 @@

#pragma once

#include <common/Common.h>
#include <QtCore/QtGlobal>

#include <QtCore/QStringList>
#include <QtCore/QVariant>
#ifdef Q_OS_MAC
#include <QtWidgets/QApplication>
using BaseApplication = QApplication;
#else
#include "qtsingleapplication/src/QtSingleApplication"
using BaseApplication = QtSingleApplication;
#endif

#if defined(qApp)
#undef qApp
Expand All @@ -33,12 +38,12 @@ namespace digidoc { class Exception; }
class Configuration;
class QAction;
class QSigner;
class Application final: public Common
class Application final: public BaseApplication
{
Q_OBJECT

public:
enum ConfParameter
enum ConfParameter : quint8
{
SiVaUrl,
ProxyHost,
Expand Down Expand Up @@ -86,6 +91,7 @@ private Q_SLOTS:
private:
bool event(QEvent *event) final;
static void closeWindow();
static void msgHandler(QtMsgType type, const QMessageLogContext &ctx, const QString &msg);
static void parseArgs(const QString &msg = {});
static void parseArgs(QStringList args);
static void showWarning(const QString &msg, const digidoc::Exception &e);
Expand All @@ -102,7 +108,7 @@ private Q_SLOTS:
class REOpenEvent: public QEvent
{
public:
enum { Type = QEvent::User + 1 };
enum : quint16 { Type = QEvent::User + 1 };
REOpenEvent(): QEvent( QEvent::Type(Type) ) {}
};

Expand Down
7 changes: 5 additions & 2 deletions client/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ add_executable(${PROJECT_NAME} WIN32 MACOSX_BUNDLE
QCardLock.h
QCryptoBackend.cpp
QCryptoBackend.h
QPCSC.cpp
QPCSC_p.h
QPCSC.h
QPKCS11.cpp
QPKCS11.h
QSigner.cpp
Expand Down Expand Up @@ -118,7 +121,7 @@ set_target_properties(${PROJECT_NAME} PROPERTIES
MACOSX_BUNDLE_BUNDLE_NAME ${PROJECT_NAME}
MACOSX_BUNDLE_GUI_IDENTIFIER "ee.ria.${PROJECT_NAME}"
)
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR} ${LIBDIGIDOCPP_INCLUDE_DIR})
target_include_directories(${PROJECT_NAME} PRIVATE ${LIBDIGIDOCPP_INCLUDE_DIR})
target_compile_definitions(${PROJECT_NAME} PRIVATE
CDOC2_GET_URL="${CDOC2_GET_URL}"
CDOC2_POST_URL="${CDOC2_POST_URL}"
Expand Down Expand Up @@ -160,6 +163,7 @@ if( APPLE )
set_source_files_properties( Application_mac.mm dialogs/CertificateDetails_mac.mm PROPERTIES COMPILE_FLAGS "-fobjc-arc" )
set_source_files_properties( LdapSearch.cpp PROPERTIES COMPILE_FLAGS "-Wno-deprecated-declarations" )
target_link_libraries(${PROJECT_NAME} "-framework Quartz" "-fobjc-arc")
find_library(PKCS11_MODULE NAMES opensc-pkcs11.so HINTS /Library/OpenSC/lib)
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND cp -a ${PKCS11_MODULE} $<TARGET_FILE_DIR:${PROJECT_NAME}>
COMMAND mkdir -p $<TARGET_BUNDLE_CONTENT_DIR:${PROJECT_NAME}>/Library/QuickLook
Expand Down Expand Up @@ -229,7 +233,6 @@ elseif(WIN32)
-ext WixToolset.UI.wixext
-bv WixUIDialogBmp=${CMAKE_SOURCE_DIR}/cmake/modules/dlgbmp.bmp
-bv WixUIBannerBmp=${CMAKE_SOURCE_DIR}/cmake/modules/banner.bmp
-d MSI_VERSION=${VERSION}
-d ico_path=${CMAKE_CURRENT_SOURCE_DIR}/images/digidoc.ico
-d libs_path=${LIBS_PATH}
-d client_path=$<TARGET_FILE:${PROJECT_NAME}>
Expand Down
6 changes: 4 additions & 2 deletions client/CheckConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "CheckConnection.h"

#include "Application.h"
#include "Common.h"

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

QNetworkReply::NetworkError CheckConnection::error() const { return m_error; }
QString CheckConnection::errorDetails() const { return qtmessage; }
QString CheckConnection::errorString() const
{
Expand Down Expand Up @@ -106,8 +106,10 @@ QSslConfiguration CheckConnection::sslConfiguration(const QByteArray &add)
{
QSslConfiguration ssl = QSslConfiguration::defaultConfiguration();
#ifdef CONFIG_URL
const auto list = Application::confValue(QLatin1String("CERT-BUNDLE")).toArray();
QList<QSslCertificate> trusted;
for(const auto &cert: Application::confValue(QLatin1String("CERT-BUNDLE")).toArray())
trusted.reserve(list.size());
for(const auto &cert: list)
trusted.append(QSslCertificate(QByteArray::fromBase64(cert.toString().toLatin1()), QSsl::Der));
if(!add.isEmpty())
trusted.append(QSslCertificate(QByteArray::fromBase64(add), QSsl::Der));
Expand Down
1 change: 0 additions & 1 deletion client/CheckConnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class CheckConnection
{
public:
bool check(const QUrl &url = QStringLiteral("https://id.eesti.ee/config.json"));
QNetworkReply::NetworkError error() const;
QString errorString() const;
QString errorDetails() const;

Expand Down
3 changes: 2 additions & 1 deletion client/Diagnostics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "Diagnostics.h"

#include "Application.h"
#include "Common.h"
#include "QPCSC.h"
#include "Settings.h"

Expand Down Expand Up @@ -148,6 +149,6 @@ void Diagnostics::generalInfo(QTextStream &s)
}

#ifdef Q_OS_WIN
s << "<b>" << tr("Smart Card reader drivers") << ":</b><br />" << QPCSC::instance().drivers().join(QLatin1String("<br />"));
s << "<b>" << tr("Smart Card reader drivers") << ":</b><br />" << Common::drivers().join(QLatin1String("<br />"));
#endif
}
1 change: 1 addition & 0 deletions client/Diagnostics_unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include "Common.h"

#include <QtCore/QCoreApplication>
#include <QtCore/QFile>
#include <QtCore/QRegularExpression>
#include <QtCore/QTextStream>
Expand Down
3 changes: 2 additions & 1 deletion client/Diagnostics_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include "Common.h"

#include <QtCore/QCoreApplication>
#include <QtCore/QProcess>
#include <QtCore/QRegularExpression>
#include <QtCore/QSettings>
Expand Down Expand Up @@ -145,7 +146,7 @@ void Diagnostics::run()
+ ";C:\\Program Files\\Open-EID"
+ ";C:\\Program Files\\EstIDMinidriver Minidriver"
+ ";C:\\Program Files (x86)\\EstIDMinidriver Minidriver");
SetDllDirectory(LPCWSTR(qApp->applicationDirPath().utf16()));
SetDllDirectory(LPCWSTR(QCoreApplication::applicationDirPath().utf16()));
static const QStringList dlls{
"digidocpp", "qdigidoc4.exe", "EsteidShellExtension", "id-updater.exe",
"EstIDMinidriver", "EstIDMinidriver64", "web-eid.exe",
Expand Down
1 change: 1 addition & 0 deletions client/QCNG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include "QCNG.h"

#include "QPCSC.h"
#include "SslCertificate.h"
#include "TokenData.h"

Expand Down
Loading

0 comments on commit 9cd4149

Please sign in to comment.